@supacloud/compiler 0.51.2 → 0.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1573,12 +1573,18 @@ var init_time = __esm(() => {
1573
1573
 
1574
1574
  // node_modules/typebox/build/format/date_time.mjs
1575
1575
  function IsDateTime(value) {
1576
- const dateTime = value.split(/T/i);
1577
- return dateTime.length === 2 && IsDate2(dateTime[0]) && IsTime(dateTime[1]);
1576
+ const index = value.indexOf("[");
1577
+ const datetime = index === -1 ? value : value.slice(0, index);
1578
+ if (index !== -1 && !DATE_TIME_SUFFIX.test(value.slice(index)))
1579
+ return false;
1580
+ const split = datetime.split(/T/i);
1581
+ return split.length === 2 && IsDate2(split[0]) && IsTime(split[1]);
1578
1582
  }
1583
+ var DATE_TIME_SUFFIX;
1579
1584
  var init_date_time = __esm(() => {
1580
1585
  init_date();
1581
1586
  init_time();
1587
+ DATE_TIME_SUFFIX = /^(?:\[!?(?:(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13}(?:\/(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13})*|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])\](?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*|(?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*)$/;
1582
1588
  });
1583
1589
 
1584
1590
  // node_modules/typebox/build/format/duration.mjs
@@ -10129,10 +10135,27 @@ function parseDeliveryOptions(value) {
10129
10135
  throw new DeliveryConfigurationError;
10130
10136
  }
10131
10137
  for (const target of value.targets ?? []) {
10132
- const invalidShape = target.kind === "function" ? target.function === undefined || target.modules !== undefined || target.compute !== undefined : target.modules === undefined || target.function !== undefined;
10138
+ const invalidShape = target.kind === "function" ? target.function === undefined || target.compute !== undefined : target.modules === undefined || target.function !== undefined;
10133
10139
  if (invalidShape)
10134
10140
  throw new DeliveryConfigurationError;
10135
10141
  }
10142
+ const targetNames = new Set((value.targets ?? []).map((target) => target.name));
10143
+ const functionSlugs = new Set;
10144
+ for (const target of value.targets ?? []) {
10145
+ if (target.function !== undefined && functionSlugs.has(target.function.slug)) {
10146
+ throw new DeliveryConfigurationError;
10147
+ }
10148
+ if (target.function !== undefined)
10149
+ functionSlugs.add(target.function.slug);
10150
+ }
10151
+ for (const declared of value.functions ?? []) {
10152
+ const name = declared.name ?? declared.slug;
10153
+ if (targetNames.has(name) || functionSlugs.has(declared.slug)) {
10154
+ throw new DeliveryConfigurationError;
10155
+ }
10156
+ targetNames.add(name);
10157
+ functionSlugs.add(declared.slug);
10158
+ }
10136
10159
  const migrations = value.build?.migrations ?? [];
10137
10160
  try {
10138
10161
  validateWorkerExecution(value.execution?.groups ?? []);
@@ -10142,14 +10165,30 @@ function parseDeliveryOptions(value) {
10142
10165
  if (new Set(migrations.map((item) => item.version)).size !== migrations.length || new Set(migrations.map((item) => item.source)).size !== migrations.length || migrations.some((item) => BigInt(item.version) > 9223372036854775807n || !/\.sql$/i.test(item.source) || item.source.split("/").includes("node_modules"))) {
10143
10166
  throw new DeliveryConfigurationError;
10144
10167
  }
10145
- return value;
10168
+ if (value.functions === undefined || value.functions.length === 0)
10169
+ return value;
10170
+ const targets = [...value.targets ?? []];
10171
+ for (const declared of value.functions) {
10172
+ targets.push({
10173
+ name: declared.name ?? declared.slug,
10174
+ kind: "function",
10175
+ modules: [...declared.modules],
10176
+ function: {
10177
+ slug: declared.slug,
10178
+ entrypoint: declared.entrypoint,
10179
+ verifyJwt: declared.verifyJwt
10180
+ }
10181
+ });
10182
+ }
10183
+ const { functions: _expandedFunctions, ...rest } = value;
10184
+ return { ...rest, targets };
10146
10185
  }
10147
10186
  function parseDeliveryPlanResult(value) {
10148
10187
  if (!Check2(DeliveryPlanResultSchema, value))
10149
10188
  throw new Error("Invalid delivery plan result.");
10150
10189
  return value;
10151
10190
  }
10152
- var objectOptions, reference, references, kind, isolation, mode, DeliveryFilePathSchema, functionTarget, DeliveryOptionsSchema, DeliveryDiagnosticSchema, routeSchema, jobSchema, DeliveryTargetSchema, DeliveryPlanSchema, DeliveryPlanResultSchema, DeliveryConfigurationError;
10191
+ var objectOptions, reference, references, kind, isolation, targetName, functionSlug, mode, DeliveryFilePathSchema, functionTarget, automaticFunction, DeliveryOptionsSchema, DeliveryDiagnosticSchema, routeSchema, jobSchema, DeliveryTargetSchema, DeliveryPlanSchema, DeliveryPlanResultSchema, DeliveryConfigurationError;
10153
10192
  var init_delivery_schema = __esm(() => {
10154
10193
  init_build2();
10155
10194
  init_value2();
@@ -10159,13 +10198,22 @@ var init_delivery_schema = __esm(() => {
10159
10198
  references = _Array_(reference, { uniqueItems: true });
10160
10199
  kind = Union([Literal("api"), Literal("jobs"), Literal("webhook"), Literal("function")]);
10161
10200
  isolation = Union([Literal("shared"), Literal("process")]);
10201
+ targetName = String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" });
10202
+ functionSlug = String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" });
10162
10203
  mode = Union([Literal("required"), Literal("none")]);
10163
10204
  DeliveryFilePathSchema = String2({
10164
10205
  maxLength: 512,
10165
10206
  pattern: "^(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*/)*[A-Za-z0-9_-][A-Za-z0-9_.-]*$"
10166
10207
  });
10167
10208
  functionTarget = _Object_({
10168
- slug: String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
10209
+ slug: functionSlug,
10210
+ entrypoint: DeliveryFilePathSchema,
10211
+ verifyJwt: Boolean2()
10212
+ }, objectOptions);
10213
+ automaticFunction = _Object_({
10214
+ name: Optional(targetName),
10215
+ slug: functionSlug,
10216
+ modules: _Array_(reference, { minItems: 1, uniqueItems: true }),
10169
10217
  entrypoint: DeliveryFilePathSchema,
10170
10218
  verifyJwt: Boolean2()
10171
10219
  }, objectOptions);
@@ -10173,7 +10221,7 @@ var init_delivery_schema = __esm(() => {
10173
10221
  version: Literal(1),
10174
10222
  execution: Optional(WorkerExecutionSchema),
10175
10223
  targets: Optional(_Array_(_Object_({
10176
- name: String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
10224
+ name: targetName,
10177
10225
  kind,
10178
10226
  modules: Optional(_Array_(reference, { minItems: 1, uniqueItems: true })),
10179
10227
  isolation: Optional(isolation),
@@ -10181,6 +10229,7 @@ var init_delivery_schema = __esm(() => {
10181
10229
  compute: Optional(ComputeResourcesSchema),
10182
10230
  function: Optional(functionTarget)
10183
10231
  }, objectOptions))),
10232
+ functions: Optional(_Array_(automaticFunction, { maxItems: 32 })),
10184
10233
  runtime: Optional(_Object_({
10185
10234
  processIsolation: Boolean2(),
10186
10235
  durableQueue: Boolean2(),
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Wrap a module-backed Function target in the host-owned application factory.
3
+ * The generated application is already in scope as `createCompiledModules`.
4
+ */
5
+ export declare function renderDeliveryFunctionEntry(generatedDirectory: string, hostPath: string): string;
6
+ /** Re-export a standalone Edge Function entrypoint without requiring a compiler app graph. */
7
+ export declare function renderStandaloneFunctionEntry(generatedDirectory: string, entrypointPath: string): string;
@@ -3,12 +3,12 @@ import type { DeliveryTarget } from "./delivery-schema";
3
3
  import { type GenerateOptions } from "./generate";
4
4
  /** Keep conservative service factories while restricting exposed route/job descriptors. */
5
5
  export declare function renderDeliveryTarget(graph: ApplicationGraph, target: DeliveryTarget, options: GenerateOptions): {
6
- executionSnapshot: string;
7
- applicationDevelopment: string;
8
6
  applicationCode: string;
9
7
  manifestJson: string;
10
8
  contractsManifestJson: string;
11
9
  clientCode?: string;
12
10
  openApiCode?: string;
13
11
  permissionsCode?: string;
12
+ executionSnapshot: string;
13
+ applicationDevelopment: string;
14
14
  };
@@ -13,16 +13,6 @@ export interface DiagnosticReport {
13
13
  export declare function createDiagnosticReport(diagnostics: readonly Diagnostic[]): DiagnosticReport;
14
14
  /** LSP-shaped data only. It neither starts a language server nor applies unreviewed edits. */
15
15
  export declare function toEditorDiagnostics(diagnostics: readonly Diagnostic[]): {
16
- message: string;
17
- data: {
18
- diagnostic: Diagnostic;
19
- repair?: DiagnosticRepair;
20
- guidance?: string;
21
- format: 1;
22
- };
23
- codeDescription?: {
24
- href: string;
25
- } | undefined;
26
16
  range: {
27
17
  start: {
28
18
  line: number;
@@ -36,6 +26,16 @@ export declare function toEditorDiagnostics(diagnostics: readonly Diagnostic[]):
36
26
  severity: 1 | 2;
37
27
  source: string;
38
28
  code: string;
29
+ codeDescription?: {
30
+ href: string;
31
+ } | undefined;
32
+ message: string;
33
+ data: {
34
+ diagnostic: Diagnostic;
35
+ repair?: DiagnosticRepair;
36
+ guidance?: string;
37
+ format: 1;
38
+ };
39
39
  }[];
40
40
  /** Semantic editor commands are emitted only after a successful read-only preview.
41
41
  * Consumers execute the command through applyDiagnosticFix with expectedSourceHash;
package/dist/index.js CHANGED
@@ -3437,6 +3437,7 @@ ${procedureMethods.join(`
3437
3437
  function renderOpenApi(graph, options) {
3438
3438
  const rootDir = options?.rootDir ?? process.cwd();
3439
3439
  const outDir = options?.outDir ?? process.cwd();
3440
+ const snapshots = options?.openApi?.snapshots !== false;
3440
3441
  const imports = new ImportManager;
3441
3442
  const schemaLocals = new Map;
3442
3443
  const schemaComponents = new Map;
@@ -3932,14 +3933,18 @@ function renderOpenApi(graph, options) {
3932
3933
  " };",
3933
3934
  "}",
3934
3935
  "",
3935
- "export const OPENAPI_DOCUMENT = createOpenApiDocument();",
3936
- "",
3937
- "export function serializeOpenApiDocument(document: OpenApiDocument = OPENAPI_DOCUMENT, space = 2): string {",
3936
+ ...snapshots ? [
3937
+ "export const OPENAPI_DOCUMENT = /* @__PURE__ */ createOpenApiDocument();",
3938
+ ""
3939
+ ] : [],
3940
+ `export function serializeOpenApiDocument(document: OpenApiDocument = ${snapshots ? "OPENAPI_DOCUMENT" : "createOpenApiDocument()"}, space = 2): string {`,
3938
3941
  ' return JSON.stringify(document, null, space) + "\\n";',
3939
3942
  "}",
3940
3943
  "",
3941
- "export const OPENAPI_JSON = serializeOpenApiDocument();",
3942
- ""
3944
+ ...snapshots ? [
3945
+ "export const OPENAPI_JSON = /* @__PURE__ */ serializeOpenApiDocument();",
3946
+ ""
3947
+ ] : []
3943
3948
  ].join(`
3944
3949
  `);
3945
3950
  }
@@ -11736,12 +11741,18 @@ var init_time = __esm(() => {
11736
11741
 
11737
11742
  // node_modules/typebox/build/format/date_time.mjs
11738
11743
  function IsDateTime(value) {
11739
- const dateTime = value.split(/T/i);
11740
- return dateTime.length === 2 && IsDate2(dateTime[0]) && IsTime(dateTime[1]);
11744
+ const index = value.indexOf("[");
11745
+ const datetime = index === -1 ? value : value.slice(0, index);
11746
+ if (index !== -1 && !DATE_TIME_SUFFIX.test(value.slice(index)))
11747
+ return false;
11748
+ const split = datetime.split(/T/i);
11749
+ return split.length === 2 && IsDate2(split[0]) && IsTime(split[1]);
11741
11750
  }
11751
+ var DATE_TIME_SUFFIX;
11742
11752
  var init_date_time = __esm(() => {
11743
11753
  init_date();
11744
11754
  init_time();
11755
+ DATE_TIME_SUFFIX = /^(?:\[!?(?:(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13}(?:\/(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13})*|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])\](?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*|(?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*)$/;
11745
11756
  });
11746
11757
 
11747
11758
  // node_modules/typebox/build/format/duration.mjs
@@ -15049,10 +15060,27 @@ function parseDeliveryOptions(value) {
15049
15060
  throw new DeliveryConfigurationError;
15050
15061
  }
15051
15062
  for (const target of value.targets ?? []) {
15052
- const invalidShape = target.kind === "function" ? target.function === undefined || target.modules !== undefined || target.compute !== undefined : target.modules === undefined || target.function !== undefined;
15063
+ const invalidShape = target.kind === "function" ? target.function === undefined || target.compute !== undefined : target.modules === undefined || target.function !== undefined;
15053
15064
  if (invalidShape)
15054
15065
  throw new DeliveryConfigurationError;
15055
15066
  }
15067
+ const targetNames = new Set((value.targets ?? []).map((target) => target.name));
15068
+ const functionSlugs = new Set;
15069
+ for (const target of value.targets ?? []) {
15070
+ if (target.function !== undefined && functionSlugs.has(target.function.slug)) {
15071
+ throw new DeliveryConfigurationError;
15072
+ }
15073
+ if (target.function !== undefined)
15074
+ functionSlugs.add(target.function.slug);
15075
+ }
15076
+ for (const declared of value.functions ?? []) {
15077
+ const name = declared.name ?? declared.slug;
15078
+ if (targetNames.has(name) || functionSlugs.has(declared.slug)) {
15079
+ throw new DeliveryConfigurationError;
15080
+ }
15081
+ targetNames.add(name);
15082
+ functionSlugs.add(declared.slug);
15083
+ }
15056
15084
  const migrations = value.build?.migrations ?? [];
15057
15085
  try {
15058
15086
  validateWorkerExecution(value.execution?.groups ?? []);
@@ -15062,14 +15090,30 @@ function parseDeliveryOptions(value) {
15062
15090
  if (new Set(migrations.map((item) => item.version)).size !== migrations.length || new Set(migrations.map((item) => item.source)).size !== migrations.length || migrations.some((item) => BigInt(item.version) > 9223372036854775807n || !/\.sql$/i.test(item.source) || item.source.split("/").includes("node_modules"))) {
15063
15091
  throw new DeliveryConfigurationError;
15064
15092
  }
15065
- return value;
15093
+ if (value.functions === undefined || value.functions.length === 0)
15094
+ return value;
15095
+ const targets = [...value.targets ?? []];
15096
+ for (const declared of value.functions) {
15097
+ targets.push({
15098
+ name: declared.name ?? declared.slug,
15099
+ kind: "function",
15100
+ modules: [...declared.modules],
15101
+ function: {
15102
+ slug: declared.slug,
15103
+ entrypoint: declared.entrypoint,
15104
+ verifyJwt: declared.verifyJwt
15105
+ }
15106
+ });
15107
+ }
15108
+ const { functions: _expandedFunctions, ...rest } = value;
15109
+ return { ...rest, targets };
15066
15110
  }
15067
15111
  function parseDeliveryPlanResult(value) {
15068
15112
  if (!Check2(DeliveryPlanResultSchema, value))
15069
15113
  throw new Error("Invalid delivery plan result.");
15070
15114
  return value;
15071
15115
  }
15072
- var objectOptions, reference, references, kind, isolation, mode, DeliveryFilePathSchema, functionTarget, DeliveryOptionsSchema, DeliveryDiagnosticSchema, routeSchema, jobSchema, DeliveryTargetSchema, DeliveryPlanSchema, DeliveryPlanResultSchema, DeliveryConfigurationError;
15116
+ var objectOptions, reference, references, kind, isolation, targetName, functionSlug, mode, DeliveryFilePathSchema, functionTarget, automaticFunction, DeliveryOptionsSchema, DeliveryDiagnosticSchema, routeSchema, jobSchema, DeliveryTargetSchema, DeliveryPlanSchema, DeliveryPlanResultSchema, DeliveryConfigurationError;
15073
15117
  var init_delivery_schema = __esm(() => {
15074
15118
  init_build();
15075
15119
  init_value2();
@@ -15079,13 +15123,22 @@ var init_delivery_schema = __esm(() => {
15079
15123
  references = _Array_(reference, { uniqueItems: true });
15080
15124
  kind = Union([Literal("api"), Literal("jobs"), Literal("webhook"), Literal("function")]);
15081
15125
  isolation = Union([Literal("shared"), Literal("process")]);
15126
+ targetName = String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" });
15127
+ functionSlug = String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" });
15082
15128
  mode = Union([Literal("required"), Literal("none")]);
15083
15129
  DeliveryFilePathSchema = String2({
15084
15130
  maxLength: 512,
15085
15131
  pattern: "^(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*/)*[A-Za-z0-9_-][A-Za-z0-9_.-]*$"
15086
15132
  });
15087
15133
  functionTarget = _Object_({
15088
- slug: String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
15134
+ slug: functionSlug,
15135
+ entrypoint: DeliveryFilePathSchema,
15136
+ verifyJwt: Boolean2()
15137
+ }, objectOptions);
15138
+ automaticFunction = _Object_({
15139
+ name: Optional(targetName),
15140
+ slug: functionSlug,
15141
+ modules: _Array_(reference, { minItems: 1, uniqueItems: true }),
15089
15142
  entrypoint: DeliveryFilePathSchema,
15090
15143
  verifyJwt: Boolean2()
15091
15144
  }, objectOptions);
@@ -15093,7 +15146,7 @@ var init_delivery_schema = __esm(() => {
15093
15146
  version: Literal(1),
15094
15147
  execution: Optional(WorkerExecutionSchema),
15095
15148
  targets: Optional(_Array_(_Object_({
15096
- name: String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
15149
+ name: targetName,
15097
15150
  kind,
15098
15151
  modules: Optional(_Array_(reference, { minItems: 1, uniqueItems: true })),
15099
15152
  isolation: Optional(isolation),
@@ -15101,6 +15154,7 @@ var init_delivery_schema = __esm(() => {
15101
15154
  compute: Optional(ComputeResourcesSchema),
15102
15155
  function: Optional(functionTarget)
15103
15156
  }, objectOptions))),
15157
+ functions: Optional(_Array_(automaticFunction, { maxItems: 32 })),
15104
15158
  runtime: Optional(_Object_({
15105
15159
  processIsolation: Boolean2(),
15106
15160
  durableQueue: Boolean2(),
@@ -15405,7 +15459,7 @@ function parseDeliveryBuildManifest(value) {
15405
15459
  }
15406
15460
  for (const object of value.objects) {
15407
15461
  const target = value.plan.targets.find((target) => target.name === object.name);
15408
- if (["bun-worker-application", "go-worker-application", "scriptc-worker-application"].includes(object.entryKind) && target?.kind !== "jobs" || object.entryKind === "bun-http-application" && target?.kind === "jobs") {
15462
+ if (["bun-worker-application", "go-worker-application", "scriptc-worker-application"].includes(object.entryKind) && target?.kind !== "jobs" || object.entryKind === "bun-http-application" && target?.kind === "jobs" || object.entryKind === "bun-function-application" && target?.kind !== "function" || target?.kind === "function" && object.entryKind !== "bun-function-application") {
15409
15463
  throw new Error("Delivery executable kind does not match its target.");
15410
15464
  }
15411
15465
  if (new Set(object.files.map((file) => file.path)).size !== object.files.length || !object.files.some((file) => file.path === object.entrypoint) || deliveryObjectDigest(object) !== object.objectId) {
@@ -15449,6 +15503,7 @@ var init_delivery_build_schema = __esm(() => {
15449
15503
  Literal("compiled-module-factory"),
15450
15504
  Literal("bun-http-application"),
15451
15505
  Literal("bun-worker-application"),
15506
+ Literal("bun-function-application"),
15452
15507
  Literal("go-worker-application"),
15453
15508
  Literal("scriptc-worker-application")
15454
15509
  ]),
@@ -16522,7 +16577,7 @@ var init_application_release = __esm(() => {
16522
16577
  });
16523
16578
 
16524
16579
  // node_modules/@supacloud/delivery/src/application-configuration.ts
16525
- var ApplicationConfigurationIdSchema, targetName, variableName2, kind3, hosts, bunVersion, ApplicationConfigurationSchema, ApplicationConfigurationWriteSchema, ApplicationConfigurationViewSchema, APPLICATION_RESERVED_ENVIRONMENT_NAMES;
16580
+ var ApplicationConfigurationIdSchema, targetName2, variableName2, kind3, hosts, bunVersion, ApplicationConfigurationSchema, ApplicationConfigurationWriteSchema, ApplicationConfigurationViewSchema, APPLICATION_RESERVED_ENVIRONMENT_NAMES;
16526
16581
  var init_application_configuration = __esm(() => {
16527
16582
  init_build();
16528
16583
  init_value2();
@@ -16530,7 +16585,7 @@ var init_application_configuration = __esm(() => {
16530
16585
  ApplicationConfigurationIdSchema = String2({
16531
16586
  pattern: "^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
16532
16587
  });
16533
- targetName = String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" });
16588
+ targetName2 = String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" });
16534
16589
  variableName2 = String2({ pattern: "^[A-Z][A-Z0-9_]{0,127}$" });
16535
16590
  kind3 = Union([Literal("http"), Literal("worker")]);
16536
16591
  hosts = _Array_(String2({ minLength: 1, maxLength: 253 }), { maxItems: 32, uniqueItems: true });
@@ -16538,7 +16593,7 @@ var init_application_configuration = __esm(() => {
16538
16593
  ApplicationConfigurationSchema = _Object_({
16539
16594
  bun_version: bunVersion,
16540
16595
  targets: _Array_(_Object_({
16541
- name: targetName,
16596
+ name: targetName2,
16542
16597
  kind: kind3,
16543
16598
  hosts,
16544
16599
  environment: Record(variableName2, String2({ maxLength: 16384 }), {
@@ -16561,7 +16616,7 @@ var init_application_configuration = __esm(() => {
16561
16616
  created_at: String2(),
16562
16617
  bun_version: bunVersion,
16563
16618
  targets: _Array_(_Object_({
16564
- name: targetName,
16619
+ name: targetName2,
16565
16620
  kind: kind3,
16566
16621
  hosts,
16567
16622
  environment_names: _Array_(variableName2, { maxItems: 128, uniqueItems: true })
@@ -17348,6 +17403,19 @@ var init_delivery_migration_archive = __esm(() => {
17348
17403
  // node_modules/@supacloud/delivery/src/delivery-migration-plan.ts
17349
17404
  var init_delivery_migration_plan = () => {};
17350
17405
 
17406
+ // node_modules/@supacloud/delivery/src/release-contract.ts
17407
+ var ALLOWED_PHASE_TRANSITIONS;
17408
+ var init_release_contract = __esm(() => {
17409
+ ALLOWED_PHASE_TRANSITIONS = new Map([
17410
+ ["planned", ["mutating", "rollback-required"]],
17411
+ ["mutating", ["applied", "rollback-required"]],
17412
+ ["applied", ["reconciled", "rollback-required"]],
17413
+ ["reconciled", []],
17414
+ ["rollback-required", ["rolled-back", "reconciled"]],
17415
+ ["rolled-back", []]
17416
+ ]);
17417
+ });
17418
+
17351
17419
  // node_modules/@supacloud/delivery/src/index.ts
17352
17420
  var init_src = __esm(() => {
17353
17421
  init_delivery_artifact();
@@ -17371,6 +17439,7 @@ var init_src = __esm(() => {
17371
17439
  init_delivery_build_schema();
17372
17440
  init_delivery_migration_archive();
17373
17441
  init_delivery_migration_plan();
17442
+ init_release_contract();
17374
17443
  });
17375
17444
 
17376
17445
  // src/delivery-migration-archive.ts
@@ -22990,7 +23059,7 @@ function createDeliveryPlan(graph, input, validation) {
22990
23059
  name: declaration.name,
22991
23060
  kind: "function",
22992
23061
  isolation: "shared",
22993
- roots: [],
23062
+ roots: sorted(declaration.modules ?? []),
22994
23063
  modules: [],
22995
23064
  routes: [],
22996
23065
  jobs: [],
@@ -23778,6 +23847,53 @@ interface DeliveryWorkerHost {
23778
23847
  `;
23779
23848
  }
23780
23849
 
23850
+ // src/delivery-function.ts
23851
+ function renderDeliveryFunctionEntry(generatedDirectory, hostPath) {
23852
+ const specifier = relativeImportPath(generatedDirectory, hostPath);
23853
+ return `
23854
+ import * as deliveryFunctionHostModule from ${JSON.stringify(specifier)};
23855
+
23856
+ type DeliveryFunctionHost = {
23857
+ fetch(request: Request): Response | Promise<Response>;
23858
+ };
23859
+
23860
+ const createDeliveryFunctionHost = (deliveryFunctionHostModule as {
23861
+ createDeliveryApplication?: (
23862
+ modules: ReturnType<typeof createCompiledModules>,
23863
+ lifecycle: { signal: AbortSignal },
23864
+ ) => DeliveryFunctionHost | Promise<DeliveryFunctionHost>;
23865
+ }).createDeliveryApplication;
23866
+ if (typeof createDeliveryFunctionHost !== "function") {
23867
+ throw new Error("Invalid delivery Function host.");
23868
+ }
23869
+ const deliveryCreateHost = createDeliveryFunctionHost;
23870
+
23871
+ const deliveryFunctionLifecycle = new AbortController();
23872
+ let deliveryFunctionHost: Promise<DeliveryFunctionHost> | undefined;
23873
+ function deliveryHost(): Promise<DeliveryFunctionHost> {
23874
+ return deliveryFunctionHost ??= Promise.resolve(
23875
+ deliveryCreateHost(createCompiledModules(), { signal: deliveryFunctionLifecycle.signal }),
23876
+ );
23877
+ }
23878
+
23879
+ export default {
23880
+ async fetch(request: Request): Promise<Response> {
23881
+ return (await deliveryHost()).fetch(request);
23882
+ },
23883
+ };
23884
+ `;
23885
+ }
23886
+ function renderStandaloneFunctionEntry(generatedDirectory, entrypointPath) {
23887
+ const specifier = relativeImportPath(generatedDirectory, entrypointPath);
23888
+ return `
23889
+ import * as deliveryFunctionEntry from ${JSON.stringify(specifier)};
23890
+
23891
+ const deliveryFunctionDefault: unknown = (deliveryFunctionEntry as { default?: unknown }).default
23892
+ ?? deliveryFunctionEntry;
23893
+ export default deliveryFunctionDefault;
23894
+ `;
23895
+ }
23896
+
23781
23897
  // src/delivery-migrations.ts
23782
23898
  init_delivery_files2();
23783
23899
  import { resolve as resolve12 } from "node:path";
@@ -23873,14 +23989,6 @@ async function buildDeliveryProject(options, delivery) {
23873
23989
  const planned = createDeliveryPlan({ ...checked.graph, diagnostics: checked.diagnostics }, settings, options);
23874
23990
  if (!planned.ok)
23875
23991
  return failed(planned.diagnostics);
23876
- if (planned.plan.targets.some((target) => target.kind === "function")) {
23877
- return failed([{
23878
- severity: "error",
23879
- code: "delivery-function-build-unsupported",
23880
- message: "Function target rendering is not implemented yet; the delivery build only produces HTTP and Worker application objects.",
23881
- suggestion: "Declare HTTP/Worker application targets for now; Function and schedule delivery is tracked separately."
23882
- }]);
23883
- }
23884
23992
  if (options.graphql && checked.mismatches.some((mismatch) => mismatch.startsWith("graphql"))) {
23885
23993
  throw new Error("Refresh GraphQL artifacts with compile before building independent targets.");
23886
23994
  }
@@ -23910,6 +24018,17 @@ async function buildDeliveryProject(options, delivery) {
23910
24018
  hosts.set(app.target, { path, kind, hash: digest(await readOwned(sourceRoot, path)) });
23911
24019
  }
23912
24020
  }
24021
+ for (const target of planned.plan.targets) {
24022
+ if (target.kind !== "function" || target.modules.length === 0 || target.function === undefined)
24023
+ continue;
24024
+ if (hosts.has(target.name))
24025
+ throw new Error("Duplicate delivery application host.");
24026
+ const path = resolve13(sourceRoot, target.function.entrypoint);
24027
+ if (inside(generatedRoot, path) || !/\.[cm]?ts$/.test(path)) {
24028
+ throw new Error("Function hosts require application TypeScript source.");
24029
+ }
24030
+ hosts.set(target.name, { path, kind: "function", hash: digest(await readOwned(sourceRoot, path)) });
24031
+ }
23913
24032
  phase = "migration-inputs";
23914
24033
  const migrations = await prepareDeliveryMigrations(project, generatedRoot, settings.build?.migrations);
23915
24034
  phase = "output-ownership";
@@ -23964,19 +24083,38 @@ async function buildDeliveryProject(options, delivery) {
23964
24083
  const stage = await mkdtemp(join9(objectRoot, ".build-"));
23965
24084
  temporary.push(stage);
23966
24085
  const generatedDirectory = join9(objectRoot, "0".repeat(64), "generated");
23967
- const rendered = renderDeliveryTarget(checked.graph, target, {
24086
+ const host = hosts.get(target.name);
24087
+ const standaloneFunction = target.kind === "function" && target.modules.length === 0;
24088
+ const rendered = standaloneFunction ? undefined : renderDeliveryTarget(checked.graph, target, {
23968
24089
  ...options,
23969
24090
  rootDir: sourceRoot,
23970
24091
  outDir: generatedDirectory
23971
24092
  });
23972
- const host = hosts.get(target.name);
23973
- const entryKind = host?.kind === "http" ? "bun-http-application" : host?.kind === "worker" ? "bun-worker-application" : "compiled-module-factory";
23974
- const applicationCode = rendered.applicationCode + (host?.kind === "http" ? renderDeliveryHttpEntry(generatedDirectory, host.path) : host?.kind === "worker" ? renderDeliveryWorkerEntry(generatedDirectory, host.path) : "");
23975
- const generated = {
23976
- "application.ts": applicationCode,
23977
- ...rendered.clientCode === undefined ? {} : { "client.ts": rendered.clientCode },
23978
- ...rendered.permissionsCode === undefined ? {} : { "permissions.ts": rendered.permissionsCode }
23979
- };
24093
+ let entryKind;
24094
+ let applicationCode;
24095
+ let generated;
24096
+ if (standaloneFunction) {
24097
+ if (target.function === undefined)
24098
+ throw new Error("Function target requires an entrypoint descriptor.");
24099
+ const entrypointPath = resolve13(sourceRoot, target.function.entrypoint);
24100
+ if (inside(generatedRoot, entrypointPath) || !/\.[cm]?ts$/.test(entrypointPath)) {
24101
+ throw new Error("Standalone Function entrypoints require application TypeScript source.");
24102
+ }
24103
+ entryKind = "bun-function-application";
24104
+ applicationCode = renderStandaloneFunctionEntry(generatedDirectory, entrypointPath);
24105
+ generated = { "function.ts": applicationCode };
24106
+ } else {
24107
+ if (target.kind === "function" && host?.kind !== "function") {
24108
+ throw new Error("Module-backed Function targets require an entrypoint host.");
24109
+ }
24110
+ entryKind = target.kind === "function" ? "bun-function-application" : host?.kind === "http" ? "bun-http-application" : host?.kind === "worker" ? "bun-worker-application" : "compiled-module-factory";
24111
+ applicationCode = rendered.applicationCode + (host?.kind === "http" ? renderDeliveryHttpEntry(generatedDirectory, host.path) : host?.kind === "worker" ? renderDeliveryWorkerEntry(generatedDirectory, host.path) : host?.kind === "function" ? renderDeliveryFunctionEntry(generatedDirectory, host.path) : "");
24112
+ generated = {
24113
+ "application.ts": applicationCode,
24114
+ ...rendered.clientCode === undefined ? {} : { "client.ts": rendered.clientCode },
24115
+ ...rendered.permissionsCode === undefined ? {} : { "permissions.ts": rendered.permissionsCode }
24116
+ };
24117
+ }
23980
24118
  const unsafe = scanGeneratedArtifacts(generated, true);
23981
24119
  if (unsafe.some((item) => item.severity === "error"))
23982
24120
  return failed(unsafe);
@@ -24019,9 +24157,14 @@ async function buildDeliveryProject(options, delivery) {
24019
24157
  for (const [path, bytes] of bundled.files)
24020
24158
  await writeArtifact(stage, path, bytes);
24021
24159
  await writeArtifact(stage, "bundle/package.json", canonical2({ type: "module", private: true }));
24022
- await writeArtifact(stage, "bundle/app.manifest.json", rendered.manifestJson);
24023
- await writeArtifact(stage, "bundle/execution-context.json", rendered.executionSnapshot);
24024
- await writeArtifact(stage, "bundle/application-development.json", rendered.applicationDevelopment);
24160
+ if (target.kind === "function" && target.function !== undefined) {
24161
+ await writeArtifact(stage, "bundle/function.json", canonical2(target.function));
24162
+ }
24163
+ if (rendered !== undefined) {
24164
+ await writeArtifact(stage, "bundle/app.manifest.json", rendered.manifestJson);
24165
+ await writeArtifact(stage, "bundle/execution-context.json", rendered.executionSnapshot);
24166
+ await writeArtifact(stage, "bundle/application-development.json", rendered.applicationDevelopment);
24167
+ }
24025
24168
  for (const [path, bytes] of migrations.files)
24026
24169
  await writeArtifact(stage, path, bytes);
24027
24170
  await writeArtifact(stage, "bundle/target.json", canonical2({
@@ -24839,10 +24982,10 @@ import { readFileSync as readFileSync4 } from "node:fs";
24839
24982
  import { resolve as resolve17 } from "node:path";
24840
24983
 
24841
24984
  // src/migration-app-version.ts
24842
- var MIGRATION_APP_VERSION = "0.33.0";
24985
+ var MIGRATION_APP_VERSION = "0.34.1";
24843
24986
 
24844
24987
  // src/migration-elysia-version.ts
24845
- var MIGRATION_ELYSIA_VERSION = "0.36.2";
24988
+ var MIGRATION_ELYSIA_VERSION = "0.36.3";
24846
24989
 
24847
24990
  // src/migration-policy.ts
24848
24991
  var cachedCompilerVersion;
@@ -25720,7 +25863,11 @@ async function loadGeneratedOpenApiDocument(modulePath) {
25720
25863
  const loaded = await import(moduleUrl.href);
25721
25864
  if (!isRecord(loaded))
25722
25865
  throw new OpenApiDocumentError;
25723
- return parseOpenApiDocument(loaded["OPENAPI_DOCUMENT"]);
25866
+ if ("OPENAPI_DOCUMENT" in loaded)
25867
+ return parseOpenApiDocument(loaded["OPENAPI_DOCUMENT"]);
25868
+ if (typeof loaded["createOpenApiDocument"] !== "function")
25869
+ throw new OpenApiDocumentError;
25870
+ return parseOpenApiDocument(await loaded["createOpenApiDocument"]());
25724
25871
  } catch (error) {
25725
25872
  if (error instanceof OpenApiDocumentError)
25726
25873
  throw error;
@@ -1 +1 @@
1
- export declare const MIGRATION_APP_VERSION = "0.33.0";
1
+ export declare const MIGRATION_APP_VERSION = "0.34.1";
@@ -1 +1 @@
1
- export declare const MIGRATION_ELYSIA_VERSION = "0.36.2";
1
+ export declare const MIGRATION_ELYSIA_VERSION = "0.36.3";
@@ -4,14 +4,14 @@ export declare function inspectRouteContracts(graph: ApplicationGraph): {
4
4
  module: string;
5
5
  controller: string;
6
6
  handler: string;
7
- method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
7
+ method: "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT";
8
8
  path: string;
9
9
  file: string;
10
- missing: ("query" | "body" | "headers" | "cookie" | "params" | "response")[];
10
+ missing: ("body" | "cookie" | "headers" | "params" | "query" | "response")[];
11
11
  validation: {
12
12
  body: string;
13
13
  response: string;
14
- schemas: Partial<Record<"query" | "body" | "headers" | "cookie" | "params" | "response", "opaque" | "declared">>;
14
+ schemas: Partial<Record<"body" | "cookie" | "headers" | "params" | "query" | "response", "declared" | "opaque">>;
15
15
  evidence: string | null;
16
16
  verified: false;
17
17
  obligations: string[];