defaultFunctionBundleLoader function

Future<FunctionBundle> defaultFunctionBundleLoader(
  1. String slug
)

Default implementation: read assets/functions/<slug>.files.txt (a newline-separated manifest emitted by ./dto schema bundle), then load each listed file from assets/functions/<slug>/<relative>.

Follows the convention that every Dutato-bundled Edge Function uses index.ts as its entrypoint — the one case where Supabase's default matches our source layout.

Implementation

Future<FunctionBundle> defaultFunctionBundleLoader(String slug) async {
  final manifestText = await rootBundle.loadString(
    'assets/functions/$slug.files.txt',
  );
  final relPaths = manifestText
      .split('\n')
      .map((line) => line.trim())
      .where((line) => line.isNotEmpty)
      .toList();

  final files = <String, String>{};
  for (final rel in relPaths) {
    files[rel] = await rootBundle.loadString('assets/functions/$slug/$rel');
  }

  return FunctionBundle(entrypoint: 'index.ts', files: files);
}