@supacloud/compiler 0.42.1 → 0.43.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.
package/dist/index.js CHANGED
@@ -34,8 +34,8 @@ function getModuleBoundaryProfile(name) {
34
34
  ...profile,
35
35
  rules: profile.rules.map((rule) => ({
36
36
  ...rule,
37
- onlyDependOnLibsWithTags: rule.onlyDependOnLibsWithTags ? [...rule.onlyDependOnLibsWithTags] : undefined,
38
- bannedDependenciesWithTags: rule.bannedDependenciesWithTags ? [...rule.bannedDependenciesWithTags] : undefined
37
+ ...rule.onlyDependOnLibsWithTags === undefined ? {} : { onlyDependOnLibsWithTags: [...rule.onlyDependOnLibsWithTags] },
38
+ ...rule.bannedDependenciesWithTags === undefined ? {} : { bannedDependenciesWithTags: [...rule.bannedDependenciesWithTags] }
39
39
  }))
40
40
  };
41
41
  }
@@ -251,7 +251,13 @@ var REQUEST_CONTEXT_TOKEN_NAME = "supacloud.request-context", JOB_CONTEXT_TOKEN_
251
251
  function validateFeatureSpec(spec, module) {
252
252
  const diagnostics = [];
253
253
  const error = (code, message) => {
254
- diagnostics.push({ severity: "error", code, message, file: spec.file, line: spec.line });
254
+ diagnostics.push({
255
+ severity: "error",
256
+ code,
257
+ message,
258
+ ...spec.file === undefined ? {} : { file: spec.file },
259
+ ...spec.line === undefined ? {} : { line: spec.line }
260
+ });
255
261
  };
256
262
  if (!spec.name.trim() || spec.states.length === 0 || spec.states.some((state) => !state.trim()) || new Set(spec.states).size !== spec.states.length) {
257
263
  error("invalid-feature-states", "Feature name and states must be non-empty; states must be unique.");
@@ -289,7 +295,7 @@ function validateFeatureSpec(spec, module) {
289
295
  const routes = module.controllers.flatMap((controller) => controller.routes.filter((route) => `${route.method} ${joinRoutePaths(controller.path, route.path)}` === transition.route));
290
296
  if (routes.length !== 1) {
291
297
  error("feature-route-unresolved", `Transition ${transition.name} must reference exactly one route '${transition.route}' in module ${module.name}.`);
292
- } else if (command && routes[0].command !== command.className) {
298
+ } else if (command && routes[0]?.command !== command.className) {
293
299
  error("feature-route-drift", `Route ${transition.route} is not bound to ${command.className}.`);
294
300
  }
295
301
  }
@@ -2657,7 +2663,7 @@ ${procedureMethods.join(`
2657
2663
  "",
2658
2664
  "function selectResponseSchema(status: number, schemas: Readonly<Record<string, unknown>>): unknown {",
2659
2665
  " const family = `${Math.floor(status / 100)}xx`;",
2660
- " return schemas[String(status)] ?? schemas[family] ?? schemas[family.toUpperCase()] ?? schemas.default;",
2666
+ ' return schemas[String(status)] ?? schemas[family] ?? schemas[family.toUpperCase()] ?? schemas["default"];',
2661
2667
  "}",
2662
2668
  "",
2663
2669
  ...usesValue ? [
@@ -2685,16 +2691,16 @@ ${procedureMethods.join(`
2685
2691
  "function schemaReferenceTarget(ref: string, root: unknown): unknown {",
2686
2692
  ' const localRef = ref.startsWith("#/$defs/") ? ref.slice(8) : ref.startsWith("#/definitions/") ? ref.slice(14) : ref.startsWith("#/components/schemas/") ? ref.slice(21) : ref.startsWith("#") ? undefined : ref;',
2687
2693
  " if (localRef !== undefined && isRecord(root)) {",
2688
- ' const defs = ref.startsWith("#/definitions/") ? root.definitions : ref.startsWith("#/components/schemas/") ? root.components : root.$defs;',
2694
+ ' const defs = ref.startsWith("#/definitions/") ? root["definitions"] : ref.startsWith("#/components/schemas/") ? root["components"] : root["$defs"];',
2689
2695
  ' if (ref.startsWith("#/components/schemas/") && isRecord(defs)) {',
2690
- " const components = defs.schemas;",
2696
+ ' const components = defs["schemas"];',
2691
2697
  " if (isRecord(components) && components[localRef] !== undefined) return components[localRef];",
2692
2698
  " } else if (isRecord(defs) && defs[localRef] !== undefined) return defs[localRef];",
2693
2699
  " }",
2694
2700
  " for (const entry of API_SCHEMAS as readonly { name: string; schema: unknown }[]) {",
2695
2701
  " if (entry.name === ref) return entry.schema;",
2696
2702
  " if (!isRecord(entry.schema)) continue;",
2697
- " if (entry.schema.$id === ref || entry.schema.$id === localRef) return entry.schema;",
2703
+ ' if (entry.schema["$id"] === ref || entry.schema["$id"] === localRef) return entry.schema;',
2698
2704
  ' for (const key of ["$defs", "definitions"] as const) {',
2699
2705
  " const defs = entry.schema[key];",
2700
2706
  " if (isRecord(defs) && localRef !== undefined && defs[localRef] !== undefined) return defs[localRef];",
@@ -2721,52 +2727,52 @@ ${procedureMethods.join(`
2721
2727
  " if (schema === true) return value;",
2722
2728
  " if (schema === false || !isRecord(schema)) return schemaError();",
2723
2729
  ' if ("~codec" in schema || Object.getOwnPropertySymbols(schema).some((symbol) => String(symbol).includes("Transform"))) throw new Error("Response schema transforms are unsupported by the generated decoder");',
2724
- ' if (typeof schema.$ref === "string") {',
2725
- " if (seenRefs.has(schema.$ref)) return schemaError();",
2726
- " const target = schemaReferenceTarget(schema.$ref, root);",
2730
+ ' if (typeof schema["$ref"] === "string") {',
2731
+ ' if (seenRefs.has(schema["$ref"])) return schemaError();',
2732
+ ' const target = schemaReferenceTarget(schema["$ref"], root);',
2727
2733
  " if (target === undefined) return schemaError();",
2728
- " const nextRefs = new Set(seenRefs); nextRefs.add(schema.$ref);",
2734
+ ' const nextRefs = new Set(seenRefs); nextRefs.add(schema["$ref"]);',
2729
2735
  " return decodeSchemaValue(target, value, root, nextRefs, normalize);",
2730
2736
  " }",
2731
- " if (schema.nullable === true && value === null) return value;",
2732
- ' if (Object.hasOwn(schema, "const") && !sameJsonValue(schema.const, value)) return schemaError();',
2733
- " if (Array.isArray(schema.enum) && !schema.enum.some((entry) => sameJsonValue(entry, value))) return schemaError();",
2734
- " if (Array.isArray(schema.anyOf)) {",
2737
+ ' if (schema["nullable"] === true && value === null) return value;',
2738
+ ' if (Object.hasOwn(schema, "const") && !sameJsonValue(schema["const"], value)) return schemaError();',
2739
+ ' if (Array.isArray(schema["enum"]) && !schema["enum"].some((entry) => sameJsonValue(entry, value))) return schemaError();',
2740
+ ' if (Array.isArray(schema["anyOf"])) {',
2735
2741
  " const matches: unknown[] = [];",
2736
- " for (const variant of schema.anyOf) { try { matches.push(decodeSchemaValue(variant, value, root, new Set(seenRefs), normalize)); } catch {} }",
2742
+ ' for (const variant of schema["anyOf"]) { try { matches.push(decodeSchemaValue(variant, value, root, new Set(seenRefs), normalize)); } catch {} }',
2737
2743
  " if (matches.length === 0) return schemaError();",
2738
2744
  " return matches[0];",
2739
2745
  " }",
2740
- " if (Array.isArray(schema.oneOf)) {",
2746
+ ' if (Array.isArray(schema["oneOf"])) {',
2741
2747
  " const matches: unknown[] = [];",
2742
- " for (const variant of schema.oneOf) { try { matches.push(decodeSchemaValue(variant, value, root, new Set(seenRefs), normalize)); } catch {} }",
2748
+ ' for (const variant of schema["oneOf"]) { try { matches.push(decodeSchemaValue(variant, value, root, new Set(seenRefs), normalize)); } catch {} }',
2743
2749
  " if (matches.length !== 1) return schemaError();",
2744
2750
  " return matches[0];",
2745
2751
  " }",
2746
- " if (Array.isArray(schema.allOf)) {",
2752
+ ' if (Array.isArray(schema["allOf"])) {',
2747
2753
  " let output: unknown = value;",
2748
- " for (const variant of schema.allOf) {",
2754
+ ' for (const variant of schema["allOf"]) {',
2749
2755
  " const decoded = decodeSchemaValue(variant, value, root, new Set(seenRefs), normalize);",
2750
2756
  " output = isRecord(output) && isRecord(decoded) ? { ...output, ...decoded } : decoded;",
2751
2757
  " }",
2752
2758
  " return output;",
2753
2759
  " }",
2754
- " if (schema.not !== undefined) {",
2755
- " try { decodeSchemaValue(schema.not, value, root, new Set(seenRefs), normalize); } catch { return value; }",
2760
+ ' if (schema["not"] !== undefined) {',
2761
+ ' try { decodeSchemaValue(schema["not"], value, root, new Set(seenRefs), normalize); } catch { return value; }',
2756
2762
  " return schemaError();",
2757
2763
  " }",
2758
- " if (Array.isArray(schema.type)) {",
2759
- " for (const type of schema.type) { try { return decodeSchemaValue({ ...schema, type }, value, root, new Set(seenRefs), normalize); } catch {} }",
2764
+ ' if (Array.isArray(schema["type"])) {',
2765
+ ' for (const type of schema["type"]) { try { return decodeSchemaValue({ ...schema, type }, value, root, new Set(seenRefs), normalize); } catch {} }',
2760
2766
  " return schemaError();",
2761
2767
  " }",
2762
- ' if (schema.type === "object" || (schema.type === undefined && (isRecord(schema.properties) || schema.required !== undefined))) {',
2768
+ ' if (schema["type"] === "object" || (schema["type"] === undefined && (isRecord(schema["properties"]) || schema["required"] !== undefined))) {',
2763
2769
  " if (!isRecord(value)) return schemaError();",
2764
- " const properties = isRecord(schema.properties) ? schema.properties : {};",
2765
- " const patterns = isRecord(schema.patternProperties) ? schema.patternProperties : {};",
2766
- " const required = Array.isArray(schema.required) ? schema.required : [];",
2770
+ ' const properties = isRecord(schema["properties"]) ? schema["properties"] : {};',
2771
+ ' const patterns = isRecord(schema["patternProperties"]) ? schema["patternProperties"] : {};',
2772
+ ' const required = Array.isArray(schema["required"]) ? schema["required"] : [];',
2767
2773
  ' for (const name of required) if (typeof name === "string" && !Object.hasOwn(value, name)) return schemaError();',
2768
- ' if (typeof schema.minProperties === "number" && Object.keys(value).length < schema.minProperties) return schemaError();',
2769
- ' if (typeof schema.maxProperties === "number" && Object.keys(value).length > schema.maxProperties) return schemaError();',
2774
+ ' if (typeof schema["minProperties"] === "number" && Object.keys(value).length < schema["minProperties"]) return schemaError();',
2775
+ ' if (typeof schema["maxProperties"] === "number" && Object.keys(value).length > schema["maxProperties"]) return schemaError();',
2770
2776
  " const output: Record<string, unknown> = {};",
2771
2777
  " for (const [name, item] of Object.entries(value)) {",
2772
2778
  " const propertySchema = properties[name];",
@@ -2777,52 +2783,52 @@ ${procedureMethods.join(`
2777
2783
  " if (applies) { output[name] = decodeSchemaValue(patternSchema, item, root, new Set<string>(), normalize); matched = true; }",
2778
2784
  " }",
2779
2785
  " if (matched) continue;",
2780
- " if (schema.additionalProperties === false || schema.unevaluatedProperties === false || schema.additionalProperties === undefined) {",
2786
+ ' if (schema["additionalProperties"] === false || schema["unevaluatedProperties"] === false || schema["additionalProperties"] === undefined) {',
2781
2787
  " if (normalize) continue;",
2782
2788
  " return schemaError();",
2783
2789
  " }",
2784
- " if (isRecord(schema.additionalProperties)) output[name] = decodeSchemaValue(schema.additionalProperties, item, root, new Set<string>(), normalize);",
2785
- " else if (schema.additionalProperties === true) output[name] = item;",
2790
+ ' if (isRecord(schema["additionalProperties"])) output[name] = decodeSchemaValue(schema["additionalProperties"], item, root, new Set<string>(), normalize);',
2791
+ ' else if (schema["additionalProperties"] === true) output[name] = item;',
2786
2792
  " }",
2787
2793
  " return output;",
2788
2794
  " }",
2789
- ' if (schema.type === "array") {',
2795
+ ' if (schema["type"] === "array") {',
2790
2796
  " if (!Array.isArray(value)) return schemaError();",
2791
- ' if (typeof schema.minItems === "number" && value.length < schema.minItems) return schemaError();',
2792
- ' if (typeof schema.maxItems === "number" && value.length > schema.maxItems) return schemaError();',
2793
- " if (schema.uniqueItems === true) { const keys = value.map((item) => JSON.stringify(item)); if (new Set(keys).size !== keys.length) return schemaError(); }",
2794
- " const tuple = Array.isArray(schema.prefixItems) ? schema.prefixItems : Array.isArray(schema.items) ? schema.items : undefined;",
2797
+ ' if (typeof schema["minItems"] === "number" && value.length < schema["minItems"]) return schemaError();',
2798
+ ' if (typeof schema["maxItems"] === "number" && value.length > schema["maxItems"]) return schemaError();',
2799
+ ' if (schema["uniqueItems"] === true) { const keys = value.map((item) => JSON.stringify(item)); if (new Set(keys).size !== keys.length) return schemaError(); }',
2800
+ ' const tuple = Array.isArray(schema["prefixItems"]) ? schema["prefixItems"] : Array.isArray(schema["items"]) ? schema["items"] : undefined;',
2795
2801
  " if (tuple) {",
2796
- " if (schema.additionalItems === false && value.length > tuple.length) return schemaError();",
2797
- " return value.map((item, index) => index < tuple.length ? decodeSchemaValue(tuple[index], item, root, new Set<string>(), normalize) : schema.items && !Array.isArray(schema.items) ? decodeSchemaValue(schema.items, item, root, new Set<string>(), normalize) : item);",
2802
+ ' if (schema["additionalItems"] === false && value.length > tuple.length) return schemaError();',
2803
+ ' return value.map((item, index) => index < tuple.length ? decodeSchemaValue(tuple[index], item, root, new Set<string>(), normalize) : schema["items"] && !Array.isArray(schema["items"]) ? decodeSchemaValue(schema["items"], item, root, new Set<string>(), normalize) : item);',
2798
2804
  " }",
2799
- " if (schema.items === undefined || schema.items === true) return value;",
2800
- " if (schema.items === false && value.length > 0) return schemaError();",
2801
- " return value.map((item) => decodeSchemaValue(schema.items, item, root, new Set<string>(), normalize));",
2805
+ ' if (schema["items"] === undefined || schema["items"] === true) return value;',
2806
+ ' if (schema["items"] === false && value.length > 0) return schemaError();',
2807
+ ' return value.map((item) => decodeSchemaValue(schema["items"], item, root, new Set<string>(), normalize));',
2802
2808
  " }",
2803
- ' if (schema.type === "string") {',
2809
+ ' if (schema["type"] === "string") {',
2804
2810
  ' if (typeof value !== "string") return schemaError();',
2805
- ' if (typeof schema.minLength === "number" && value.length < schema.minLength) return schemaError();',
2806
- ' if (typeof schema.maxLength === "number" && value.length > schema.maxLength) return schemaError();',
2807
- ' if (typeof schema.pattern === "string") { let matches = false; try { matches = new RegExp(schema.pattern).test(value); } catch { return schemaError(); } if (!matches) return schemaError(); }',
2808
- " if (!matchesFormat(schema.format, value)) return schemaError();",
2811
+ ' if (typeof schema["minLength"] === "number" && value.length < schema["minLength"]) return schemaError();',
2812
+ ' if (typeof schema["maxLength"] === "number" && value.length > schema["maxLength"]) return schemaError();',
2813
+ ' if (typeof schema["pattern"] === "string") { let matches = false; try { matches = new RegExp(schema["pattern"]).test(value); } catch { return schemaError(); } if (!matches) return schemaError(); }',
2814
+ ' if (!matchesFormat(schema["format"], value)) return schemaError();',
2809
2815
  " return value;",
2810
2816
  " }",
2811
- ' if (schema.type === "boolean") { if (typeof value !== "boolean") return schemaError(); return value; }',
2812
- ' if (schema.type === "number" || schema.type === "integer") {',
2813
- ' if (typeof value !== "number" || !Number.isFinite(value) || (schema.type === "integer" && !Number.isInteger(value))) return schemaError();',
2814
- ' if (typeof schema.minimum === "number" && value < schema.minimum) return schemaError();',
2815
- ' if (typeof schema.maximum === "number" && value > schema.maximum) return schemaError();',
2816
- ' if (typeof schema.exclusiveMinimum === "number" && value <= schema.exclusiveMinimum) return schemaError();',
2817
- ' if (typeof schema.exclusiveMaximum === "number" && value >= schema.exclusiveMaximum) return schemaError();',
2818
- ' if (schema.exclusiveMinimum === true && typeof schema.minimum === "number" && value <= schema.minimum) return schemaError();',
2819
- ' if (schema.exclusiveMaximum === true && typeof schema.maximum === "number" && value >= schema.maximum) return schemaError();',
2820
- ' if (typeof schema.multipleOf === "number" && schema.multipleOf > 0 && Math.abs(value / schema.multipleOf - Math.round(value / schema.multipleOf)) > 1e-9) return schemaError();',
2817
+ ' if (schema["type"] === "boolean") { if (typeof value !== "boolean") return schemaError(); return value; }',
2818
+ ' if (schema["type"] === "number" || schema["type"] === "integer") {',
2819
+ ' if (typeof value !== "number" || !Number.isFinite(value) || (schema["type"] === "integer" && !Number.isInteger(value))) return schemaError();',
2820
+ ' if (typeof schema["minimum"] === "number" && value < schema["minimum"]) return schemaError();',
2821
+ ' if (typeof schema["maximum"] === "number" && value > schema["maximum"]) return schemaError();',
2822
+ ' if (typeof schema["exclusiveMinimum"] === "number" && value <= schema["exclusiveMinimum"]) return schemaError();',
2823
+ ' if (typeof schema["exclusiveMaximum"] === "number" && value >= schema["exclusiveMaximum"]) return schemaError();',
2824
+ ' if (schema["exclusiveMinimum"] === true && typeof schema["minimum"] === "number" && value <= schema["minimum"]) return schemaError();',
2825
+ ' if (schema["exclusiveMaximum"] === true && typeof schema["maximum"] === "number" && value >= schema["maximum"]) return schemaError();',
2826
+ ' if (typeof schema["multipleOf"] === "number" && schema["multipleOf"] > 0 && Math.abs(value / schema["multipleOf"] - Math.round(value / schema["multipleOf"])) > 1e-9) return schemaError();',
2821
2827
  " return value;",
2822
2828
  " }",
2823
- ' if (schema.type === "null") { if (value !== null) return schemaError(); return value; }',
2824
- ' if (schema.type === "void" || schema.type === "undefined") { if (value !== undefined) return schemaError(); return value; }',
2825
- ' if (schema.type === "never") return schemaError();',
2829
+ ' if (schema["type"] === "null") { if (value !== null) return schemaError(); return value; }',
2830
+ ' if (schema["type"] === "void" || schema["type"] === "undefined") { if (value !== undefined) return schemaError(); return value; }',
2831
+ ' if (schema["type"] === "never") return schemaError();',
2826
2832
  " return value;",
2827
2833
  "}",
2828
2834
  ""
@@ -2896,7 +2902,7 @@ ${procedureMethods.join(`
2896
2902
  " ...options.headers,",
2897
2903
  " };",
2898
2904
  ' if (options.cookie && !Object.keys(headers).some((key) => key.toLowerCase() === "cookie")) {',
2899
- ' headers.cookie = Object.entries(options.cookie).map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`).join("; " );',
2905
+ ' headers["cookie"] = Object.entries(options.cookie).map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`).join("; " );',
2900
2906
  " }",
2901
2907
  " const interceptors = config.interceptors ?? [];",
2902
2908
  " const executeChain = (",
@@ -3087,7 +3093,7 @@ function renderOpenApi(graph, options) {
3087
3093
  for (const module of graph.modules) {
3088
3094
  for (const controller of module.controllers) {
3089
3095
  for (const route of controller.routes) {
3090
- const documentation = route.data?.openapi;
3096
+ const documentation = route.data?.["openapi"];
3091
3097
  if (documentation !== null && typeof documentation === "object" && "hide" in documentation && documentation.hide === true)
3092
3098
  continue;
3093
3099
  const fullPath = joinRoutePaths(controller.path, route.path);
@@ -3274,11 +3280,11 @@ function renderOpenApi(graph, options) {
3274
3280
  "function isUndefinedSchema(value: unknown, seen = new WeakSet<object>(), refs = new Set<string>(), scope?: unknown): boolean {",
3275
3281
  " if (!isRecord(value) || seen.has(value)) return false;",
3276
3282
  " seen.add(value);",
3277
- " const nextScope = isRecord(value.$defs) || isRecord(value.definitions) ? value : scope;",
3283
+ ' const nextScope = isRecord(value["$defs"]) || isRecord(value["definitions"]) ? value : scope;',
3278
3284
  " try {",
3279
- ' if (value.type === "undefined") return true;',
3280
- ' if (Array.isArray(value.type) && value.type.length > 0 && value.type.every((type) => type === "undefined")) return true;',
3281
- ' const ref = typeof value.$ref === "string" ? value.$ref : undefined;',
3285
+ ' if (value["type"] === "undefined") return true;',
3286
+ ' if (Array.isArray(value["type"]) && value["type"].length > 0 && value["type"].every((type) => type === "undefined")) return true;',
3287
+ ' const ref = typeof value["$ref"] === "string" ? value["$ref"] : undefined;',
3282
3288
  " if (ref !== undefined && !refs.has(ref)) {",
3283
3289
  " const target = openApiSchemaRefTarget(ref, nextScope);",
3284
3290
  " if (target !== undefined) {",
@@ -3302,10 +3308,10 @@ function renderOpenApi(graph, options) {
3302
3308
  "function cloneSchema(value: unknown, seen = new WeakSet<object>(), scope?: unknown): OpenApiSchema {",
3303
3309
  " if (!isRecord(value)) return {};",
3304
3310
  " if (seen.has(value)) return {};",
3305
- " const nextScope = isRecord(value.$defs) || isRecord(value.definitions) ? value : scope;",
3311
+ ' const nextScope = isRecord(value["$defs"]) || isRecord(value["definitions"]) ? value : scope;',
3306
3312
  " if (isUndefinedSchema(value, new WeakSet<object>(), new Set<string>(), nextScope)) return {};",
3307
3313
  " seen.add(value);",
3308
- ' if (value.type === "void" || value.type === "undefined") { seen.delete(value); return {}; }',
3314
+ ' if (value["type"] === "void" || value["type"] === "undefined") { seen.delete(value); return {}; }',
3309
3315
  " const allowed = new Set([",
3310
3316
  ' "$id", "$ref", "$schema", "$defs", "definitions", "title", "description", "type", "enum", "const", "examples", "default",',
3311
3317
  ' "deprecated", "readOnly", "writeOnly", "format", "pattern", "minLength", "maxLength", "minimum",',
@@ -3352,12 +3358,12 @@ function renderOpenApi(graph, options) {
3352
3358
  "function schemaAllowsUndefined(value: unknown, seen = new WeakSet<object>(), refs = new Set<string>(), scope?: unknown): boolean {",
3353
3359
  " if (!isRecord(value) || seen.has(value)) return false;",
3354
3360
  " seen.add(value);",
3355
- " const nextScope = isRecord(value.$defs) || isRecord(value.definitions) ? value : scope;",
3361
+ ' const nextScope = isRecord(value["$defs"]) || isRecord(value["definitions"]) ? value : scope;',
3356
3362
  " try {",
3357
3363
  ' if (Object.getOwnPropertySymbols(value).some((symbol) => String(symbol).toLowerCase().includes("optional"))) return true;',
3358
- ' if (value.type === "undefined") return true;',
3359
- ' if (Array.isArray(value.type) && value.type.includes("undefined")) return true;',
3360
- ' const ref = typeof value.$ref === "string" ? value.$ref : undefined;',
3364
+ ' if (value["type"] === "undefined") return true;',
3365
+ ' if (Array.isArray(value["type"]) && value["type"].includes("undefined")) return true;',
3366
+ ' const ref = typeof value["$ref"] === "string" ? value["$ref"] : undefined;',
3361
3367
  " if (ref !== undefined && !refs.has(ref)) {",
3362
3368
  " const target = openApiSchemaRefTarget(ref, nextScope);",
3363
3369
  " if (target !== undefined) {",
@@ -3377,11 +3383,11 @@ function renderOpenApi(graph, options) {
3377
3383
  "",
3378
3384
  "function resolveRegistrySchema(value: unknown, seen = new Set<string>()): OpenApiSchema {",
3379
3385
  " const schema = cloneSchema(value);",
3380
- ' const ref = typeof schema.$ref === "string" ? schema.$ref : undefined;',
3386
+ ' const ref = typeof schema["$ref"] === "string" ? schema["$ref"] : undefined;',
3381
3387
  " if (!ref || seen.has(ref)) return schema;",
3382
3388
  ' const localName = ref.startsWith("#/components/schemas/") ? ref.slice(21) : ref.startsWith("#/$defs/") ? ref.slice(8) : ref.startsWith("#/definitions/") ? ref.slice(14) : ref;',
3383
3389
  ' if (ref.startsWith("#/$defs/") || ref.startsWith("#/definitions/")) {',
3384
- ' const defs = ref.startsWith("#/$defs/") ? schema.$defs : schema.definitions;',
3390
+ ' const defs = ref.startsWith("#/$defs/") ? schema["$defs"] : schema["definitions"];',
3385
3391
  " if (isRecord(defs) && defs[localName] !== undefined) return resolveRegistrySchema(defs[localName], new Set([...seen, ref]));",
3386
3392
  " }",
3387
3393
  " for (const [name, candidate] of Object.entries(OPENAPI_SCHEMA_REGISTRY)) {",
@@ -3394,18 +3400,18 @@ function renderOpenApi(graph, options) {
3394
3400
  "",
3395
3401
  "function schemaProperty(schema: unknown, name: string): OpenApiSchema {",
3396
3402
  " const document = resolveRegistrySchema(schema);",
3397
- " const properties = document.properties;",
3403
+ ' const properties = document["properties"];',
3398
3404
  ' return isRecord(properties) && isRecord(properties[name]) ? properties[name] : { type: "string" };',
3399
3405
  "}",
3400
3406
  "",
3401
3407
  "function schemaPropertyNames(schema: unknown): string[] {",
3402
3408
  " const document = resolveRegistrySchema(schema);",
3403
- " return isRecord(document.properties) ? Object.keys(document.properties).sort() : [];",
3409
+ ' return isRecord(document["properties"]) ? Object.keys(document["properties"]).sort() : [];',
3404
3410
  "}",
3405
3411
  "",
3406
3412
  "function schemaRequired(schema: unknown, name: string): boolean {",
3407
3413
  " const document = resolveRegistrySchema(schema);",
3408
- " return Array.isArray(document.required) && document.required.includes(name);",
3414
+ ' return Array.isArray(document["required"]) && document["required"].includes(name);',
3409
3415
  "}",
3410
3416
  "",
3411
3417
  "function schemaReference(name: string): OpenApiSchema {",
@@ -4050,24 +4056,24 @@ function assertGraphqlOptions(value) {
4050
4056
  if (unsupported.length) {
4051
4057
  fail(`Unsupported options: ${unsupported.join(", ")}. Configure only schema, documents, scalars and typedDocuments; server schema authoring modes are not supported.`);
4052
4058
  }
4053
- const schema = options.schema;
4059
+ const schema = options["schema"];
4054
4060
  if (typeof schema !== "string" || !schema.trim() || schema !== schema.trim() || /[\r\n\0]/.test(schema) || /^[a-z][a-z0-9+.-]*:/i.test(schema) && !/^[a-z]:[\\/]/i.test(schema) || ![".graphql", ".gql", ".json"].includes(extname(schema))) {
4055
4061
  fail("graphql.schema must be a local .graphql, .gql or .json database snapshot. Export it with graphql-schema; URLs, inline SDL and executable schema sources are not supported.");
4056
4062
  }
4057
- if (options.documents !== undefined && (!Array.isArray(options.documents) || options.documents.some((pattern) => typeof pattern !== "string" || !pattern.trim()))) {
4063
+ if (options["documents"] !== undefined && (!Array.isArray(options["documents"]) || options["documents"].some((pattern) => typeof pattern !== "string" || !pattern.trim()))) {
4058
4064
  fail("graphql.documents must contain local query/fragment glob strings.");
4059
4065
  }
4060
- if (options.typedDocuments !== undefined && typeof options.typedDocuments !== "boolean") {
4066
+ if (options["typedDocuments"] !== undefined && typeof options["typedDocuments"] !== "boolean") {
4061
4067
  fail("graphql.typedDocuments must be a boolean output option.");
4062
4068
  }
4063
- if (options.mutations !== undefined && typeof options.mutations !== "boolean") {
4069
+ if (options["mutations"] !== undefined && typeof options["mutations"] !== "boolean") {
4064
4070
  fail("graphql.mutations must be a boolean opt-in for database-backed mutation documents.");
4065
4071
  }
4066
- if (options.scalars !== undefined) {
4067
- if (!options.scalars || typeof options.scalars !== "object" || Array.isArray(options.scalars)) {
4072
+ if (options["scalars"] !== undefined) {
4073
+ if (!options["scalars"] || typeof options["scalars"] !== "object" || Array.isArray(options["scalars"])) {
4068
4074
  fail("graphql.scalars must be a map of explicit wire types.");
4069
4075
  }
4070
- for (const mapping of Object.values(options.scalars)) {
4076
+ for (const mapping of Object.values(options["scalars"])) {
4071
4077
  if (typeof mapping === "string" && mapping.trim())
4072
4078
  continue;
4073
4079
  if (mapping && typeof mapping === "object" && !Array.isArray(mapping) && "input" in mapping && typeof mapping.input === "string" && mapping.input.trim() && "output" in mapping && typeof mapping.output === "string" && mapping.output.trim())
@@ -4090,7 +4096,7 @@ var init_graphql_options = __esm(() => {
4090
4096
 
4091
4097
  // src/graphql-inputs.ts
4092
4098
  import { resolve as resolve5 } from "node:path";
4093
- import * as ts10 from "@typescript/typescript6";
4099
+ import * as ts11 from "@typescript/typescript6";
4094
4100
  function graphqlInputPaths(options) {
4095
4101
  if (!options.graphql)
4096
4102
  return [];
@@ -4101,7 +4107,7 @@ function graphqlInputPaths(options) {
4101
4107
  }
4102
4108
  const root = resolve5(options.rootDir);
4103
4109
  const schema = resolve5(root, options.graphql.schema);
4104
- const documents = ts10.sys.readDirectory(root, [".graphql", ".gql"], ["**/node_modules/**", "**/.git/**", resolve5(options.outDir)], options.graphql.documents ?? ["**/*.graphql", "**/*.gql"]).map((path) => resolve5(path)).filter((path) => path !== schema);
4110
+ const documents = ts11.sys.readDirectory(root, [".graphql", ".gql"], ["**/node_modules/**", "**/.git/**", resolve5(options.outDir)], options.graphql.documents ?? ["**/*.graphql", "**/*.gql"]).map((path) => resolve5(path)).filter((path) => path !== schema);
4105
4111
  return [schema, ...[...new Set(documents)].sort()];
4106
4112
  }
4107
4113
  var init_graphql_inputs = __esm(() => {
@@ -4109,7 +4115,7 @@ var init_graphql_inputs = __esm(() => {
4109
4115
  });
4110
4116
 
4111
4117
  // src/graphql-runtime.ts
4112
- import * as ts11 from "@typescript/typescript6";
4118
+ import * as ts12 from "@typescript/typescript6";
4113
4119
  import { resolve as resolve6 } from "node:path";
4114
4120
  function renderGraphqlValidators(source, operationNames, operationKinds = new Map) {
4115
4121
  const fileName = resolve6("/__supacloud_graphql__/contracts.ts");
@@ -4121,18 +4127,18 @@ function renderGraphqlValidators(source, operationNames, operationKinds = new Ma
4121
4127
  noPropertyAccessFromIndexSignature: true,
4122
4128
  noFallthroughCasesInSwitch: true,
4123
4129
  skipLibCheck: false,
4124
- target: ts11.ScriptTarget.ES2022,
4130
+ target: ts12.ScriptTarget.ES2022,
4125
4131
  lib: ["lib.es2022.d.ts"],
4126
4132
  types: [],
4127
4133
  noEmit: true
4128
4134
  };
4129
- const host = ts11.createCompilerHost(options);
4135
+ const host = ts12.createCompilerHost(options);
4130
4136
  const getSourceFile = host.getSourceFile.bind(host);
4131
- host.getSourceFile = (path, languageVersion, onError, shouldCreateNewSourceFile) => resolve6(path) === fileName ? ts11.createSourceFile(path, source, languageVersion, true) : getSourceFile(path, languageVersion, onError, shouldCreateNewSourceFile);
4132
- const program = ts11.createProgram([fileName], options, host);
4133
- const diagnostics = ts11.getPreEmitDiagnostics(program);
4137
+ host.getSourceFile = (path, languageVersion, onError, shouldCreateNewSourceFile) => resolve6(path) === fileName ? ts12.createSourceFile(path, source, languageVersion, true) : getSourceFile(path, languageVersion, onError, shouldCreateNewSourceFile);
4138
+ const program = ts12.createProgram([fileName], options, host);
4139
+ const diagnostics = ts12.getPreEmitDiagnostics(program);
4134
4140
  if (diagnostics.length) {
4135
- throw new Error(`Generated GraphQL types cannot be validated: ${diagnostics.map((item) => ts11.flattenDiagnosticMessageText(item.messageText, `
4141
+ throw new Error(`Generated GraphQL types cannot be validated: ${diagnostics.map((item) => ts12.flattenDiagnosticMessageText(item.messageText, `
4136
4142
  `)).join("; ")}`);
4137
4143
  }
4138
4144
  const checker = program.getTypeChecker();
@@ -4162,25 +4168,25 @@ function renderGraphqlValidators(source, operationNames, operationKinds = new Ma
4162
4168
  return name;
4163
4169
  }
4164
4170
  function expression(type) {
4165
- if (type.flags & ts11.TypeFlags.Any)
4171
+ if (type.flags & ts12.TypeFlags.Any)
4166
4172
  return unsupported(type);
4167
- if (type.flags & ts11.TypeFlags.Unknown)
4173
+ if (type.flags & ts12.TypeFlags.Unknown)
4168
4174
  return "true";
4169
- if (type.flags & ts11.TypeFlags.Never)
4175
+ if (type.flags & ts12.TypeFlags.Never)
4170
4176
  return "false";
4171
- if (type.flags & ts11.TypeFlags.Null)
4177
+ if (type.flags & ts12.TypeFlags.Null)
4172
4178
  return "value === null";
4173
- if (type.flags & ts11.TypeFlags.Undefined)
4179
+ if (type.flags & ts12.TypeFlags.Undefined)
4174
4180
  return "value === undefined";
4175
4181
  if (type.isStringLiteral() || type.isNumberLiteral())
4176
4182
  return `value === ${JSON.stringify(type.value)}`;
4177
- if (type.flags & ts11.TypeFlags.BooleanLiteral)
4183
+ if (type.flags & ts12.TypeFlags.BooleanLiteral)
4178
4184
  return `value === ${checker.typeToString(type)}`;
4179
- if (type.flags & ts11.TypeFlags.String)
4185
+ if (type.flags & ts12.TypeFlags.String)
4180
4186
  return 'typeof value === "string"';
4181
- if (type.flags & ts11.TypeFlags.Number)
4187
+ if (type.flags & ts12.TypeFlags.Number)
4182
4188
  return 'typeof value === "number" && Number.isFinite(value)';
4183
- if (type.flags & ts11.TypeFlags.Boolean)
4189
+ if (type.flags & ts12.TypeFlags.Boolean)
4184
4190
  return 'typeof value === "boolean"';
4185
4191
  if (type.isUnion())
4186
4192
  return type.types.map((part) => `${reference(part)}(value)`).join(" || ");
@@ -4189,16 +4195,16 @@ function renderGraphqlValidators(source, operationNames, operationKinds = new Ma
4189
4195
  if (checker.isTupleType(type))
4190
4196
  return unsupported(type);
4191
4197
  if (checker.isArrayType(type)) {
4192
- const item = checker.getIndexTypeOfType(type, ts11.IndexKind.Number);
4198
+ const item = checker.getIndexTypeOfType(type, ts12.IndexKind.Number);
4193
4199
  if (!item)
4194
4200
  return unsupported(type);
4195
4201
  return `isGraphqlArray(value) && Array.from(value).every(${reference(item)})`;
4196
4202
  }
4197
- if (type.flags & ts11.TypeFlags.Object) {
4203
+ if (type.flags & ts12.TypeFlags.Object) {
4198
4204
  if (type.getCallSignatures().length || type.getConstructSignatures().length)
4199
4205
  return unsupported(type);
4200
4206
  const indexes = checker.getIndexInfosOfType(type);
4201
- if (indexes.some((index) => !(index.keyType.flags & ts11.TypeFlags.String)))
4207
+ if (indexes.some((index) => !(index.keyType.flags & ts12.TypeFlags.String)))
4202
4208
  return unsupported(type);
4203
4209
  const properties = checker.getPropertiesOfType(type).map((property) => {
4204
4210
  const declaration = property.valueDeclaration ?? property.declarations?.[0];
@@ -4207,7 +4213,7 @@ function renderGraphqlValidators(source, operationNames, operationKinds = new Ma
4207
4213
  const check = reference(checker.getTypeOfSymbolAtLocation(property, declaration));
4208
4214
  const key = JSON.stringify(property.name);
4209
4215
  const present = `Object.prototype.hasOwnProperty.call(value, ${key})`;
4210
- return property.flags & ts11.SymbolFlags.Optional ? `(!${present} || ${check}(value[${key}]))` : `(${present} && ${check}(value[${key}]))`;
4216
+ return property.flags & ts12.SymbolFlags.Optional ? `(!${present} || ${check}(value[${key}]))` : `(${present} && ${check}(value[${key}]))`;
4211
4217
  });
4212
4218
  const indexedValues = indexes.map((index) => `Object.values(value).every(${reference(index.type)})`);
4213
4219
  return ["isGraphqlRecord(value)", ...properties, ...indexedValues].join(" && ");
@@ -4345,8 +4351,8 @@ async function renderGraphql(options) {
4345
4351
  severity: "error",
4346
4352
  code,
4347
4353
  message: error instanceof Error ? error.message : String(error),
4348
- file: source ? localPath(source) : undefined,
4349
- line: gql?.locations?.[0]?.line,
4354
+ ...source === undefined ? {} : { file: localPath(source) },
4355
+ ...gql?.locations?.[0]?.line === undefined ? {} : { line: gql.locations[0].line },
4350
4356
  suggestion: "Update the role-scoped local schema snapshot or correct the query, then recompile."
4351
4357
  });
4352
4358
  };
@@ -4396,8 +4402,8 @@ async function renderGraphql(options) {
4396
4402
  severity: "error",
4397
4403
  code: "graphql-query-only",
4398
4404
  message: "GraphQL subscriptions are not supported by the HTTP contract compiler. Use the governed Realtime transport for subscriptions.",
4399
- file: definition.loc ? localPath(definition.loc.source.name) : undefined,
4400
- line: definition.loc?.startToken.line,
4405
+ ...definition.loc ? { file: localPath(definition.loc.source.name) } : {},
4406
+ ...definition.loc?.startToken.line === undefined ? {} : { line: definition.loc.startToken.line },
4401
4407
  suggestion: "Remove this subscription from the GraphQL documents and use the supported Realtime contract."
4402
4408
  });
4403
4409
  } else if (definition.operation === "mutation" && !options.graphql.mutations) {
@@ -4405,8 +4411,8 @@ async function renderGraphql(options) {
4405
4411
  severity: "error",
4406
4412
  code: "graphql-query-only",
4407
4413
  message: "GraphQL mutations are disabled by default. Set graphql.mutations to true only after reviewing database grants, RLS, audit and idempotency behavior.",
4408
- file: definition.loc ? localPath(definition.loc.source.name) : undefined,
4409
- line: definition.loc?.startToken.line,
4414
+ ...definition.loc ? { file: localPath(definition.loc.source.name) } : {},
4415
+ ...definition.loc?.startToken.line === undefined ? {} : { line: definition.loc.startToken.line },
4410
4416
  suggestion: "Keep business writes in the governed Command API, or explicitly opt in with graphql.mutations: true."
4411
4417
  });
4412
4418
  }
@@ -5216,11 +5222,22 @@ var init_dependent = __esm(() => {
5216
5222
  });
5217
5223
 
5218
5224
  // node_modules/typebox/build/type/engine/enum/typescript_enum_to_enum_values.mjs
5225
+ function IsTypeScriptEnumLike(value) {
5226
+ return IsObjectNotArray(value);
5227
+ }
5228
+ function TypeScriptEnumToEnumValues(type) {
5229
+ const keys = Keys(type).filter((key) => isNaN(key));
5230
+ return keys.reduce((result, key) => [...result, type[key]], []);
5231
+ }
5219
5232
  var init_typescript_enum_to_enum_values = __esm(() => {
5220
5233
  init_guard2();
5221
5234
  });
5222
5235
 
5223
5236
  // node_modules/typebox/build/type/types/enum.mjs
5237
+ function Enum(value, options) {
5238
+ const values = IsTypeScriptEnumLike(value) ? TypeScriptEnumToEnumValues(value) : value;
5239
+ return Create({ "~kind": "Enum" }, { enum: values }, options);
5240
+ }
5224
5241
  function IsEnum(value) {
5225
5242
  return IsKind(value, "Enum");
5226
5243
  }
@@ -15322,6 +15339,12 @@ function createExecutionSnapshot(graph, subjects = graph.modules.map((module) =>
15322
15339
  contexts: subjects.map((subject) => {
15323
15340
  const context = createContextPack(graph, subject);
15324
15341
  const owner = graph.modules.find((module) => module.name === context.subject);
15342
+ if (owner === undefined)
15343
+ throw new Error(`Execution context owner is missing: ${context.subject}`);
15344
+ const modules = context.modules.map((module) => {
15345
+ const file = executionSourceFile(module.file);
15346
+ return { name: module.name, ...file === undefined ? {} : { file } };
15347
+ });
15325
15348
  return {
15326
15349
  subject: context.subject,
15327
15350
  aliases: [...new Set([
@@ -15332,10 +15355,7 @@ function createExecutionSnapshot(graph, subjects = graph.modules.map((module) =>
15332
15355
  ...(owner.jobs ?? []).flatMap((job) => [job.name, job.className, job.serviceKey]),
15333
15356
  ...owner.queries.flatMap((query) => [query.name, query.className])
15334
15357
  ])],
15335
- modules: context.modules.map((module) => ({
15336
- name: module.name,
15337
- ...executionSourceFile(module.file) ? { file: executionSourceFile(module.file) } : {}
15338
- })),
15358
+ modules,
15339
15359
  files: context.files,
15340
15360
  diagnostics: context.diagnostics.map((diagnostic) => {
15341
15361
  const repair = createDiagnosticRepairPlan([diagnostic])[0];
@@ -15681,10 +15701,11 @@ function createApplicationDevelopmentContext(graph, options = {}) {
15681
15701
  const providers = bound(names(module.providers.map((provider) => provider.token)), moduleIndex < APPLICATION_DEVELOPMENT_LIMITS2.modules ? remainingProviders : 0);
15682
15702
  remainingProviders -= providers.items.length;
15683
15703
  omittedProviders += providers.omitted;
15704
+ const file = executionSourceFile(module.file);
15684
15705
  developmentModules.push({
15685
15706
  name: module.name,
15686
15707
  className: module.className,
15687
- ...executionSourceFile(module.file) ? { file: executionSourceFile(module.file) } : {},
15708
+ ...file === undefined ? {} : { file },
15688
15709
  ...module.tags && module.tags.length > 0 ? { tags: names(module.tags) } : {},
15689
15710
  providers: providers.items,
15690
15711
  controllers: names(module.controllers.map((controller) => controller.className)),
@@ -15697,6 +15718,7 @@ function createApplicationDevelopmentContext(graph, options = {}) {
15697
15718
  for (const route of controller.routes) {
15698
15719
  const candidates = module.commands.filter((command) => command.className === route.command || command.name === route.command);
15699
15720
  const command = candidates.length === 1 ? candidates[0]?.name : undefined;
15721
+ const kinds = schemaKinds(route);
15700
15722
  routes.push({
15701
15723
  module: module.name,
15702
15724
  method: route.method,
@@ -15705,7 +15727,7 @@ function createApplicationDevelopmentContext(graph, options = {}) {
15705
15727
  handler: route.handler,
15706
15728
  ...command === undefined ? {} : { command },
15707
15729
  aspects: (route.aspects ?? []).map((aspect) => aspect.name),
15708
- ...schemaKinds(route) ? { schemaKinds: schemaKinds(route) } : {}
15730
+ ...kinds === undefined ? {} : { schemaKinds: kinds }
15709
15731
  });
15710
15732
  }
15711
15733
  }
@@ -15738,11 +15760,13 @@ function createApplicationDevelopmentContext(graph, options = {}) {
15738
15760
  const diagnostics = [];
15739
15761
  for (const diagnostic of graph.diagnostics ?? []) {
15740
15762
  const repair = createDiagnosticRepairPlan([diagnostic])[0];
15763
+ const file = executionSourceFile(diagnostic.file);
15764
+ const line = Number.isSafeInteger(diagnostic.line) && diagnostic.line !== undefined && diagnostic.line > 0 ? diagnostic.line : undefined;
15741
15765
  diagnostics.push({
15742
15766
  code: diagnostic.code,
15743
15767
  severity: diagnostic.severity,
15744
- ...executionSourceFile(diagnostic.file) ? { file: executionSourceFile(diagnostic.file) } : {},
15745
- ...Number.isSafeInteger(diagnostic.line) && diagnostic.line > 0 ? { line: diagnostic.line } : {},
15768
+ ...file === undefined ? {} : { file },
15769
+ ...line === undefined ? {} : { line },
15746
15770
  ...repair ? { repair: { type: repair.type, readiness: repair.readiness } } : {}
15747
15771
  });
15748
15772
  }
@@ -15992,7 +16016,7 @@ var init_application_configuration = __esm(() => {
15992
16016
  });
15993
16017
 
15994
16018
  // node_modules/@supacloud/delivery/src/application-activation.ts
15995
- var ApplicationActivationIdSchema, ApplicationActivationWriteSchema, ApplicationActivationResultSchema, ApplicationActivationRetirementResultSchema;
16019
+ var ApplicationActivationIdSchema, ApplicationActivationWriteSchema, ApplicationActivationResultSchema, ApplicationActivationRetirementResultSchema, RollbackActivationSchema, ApplicationRollbackSnapshotSchema;
15996
16020
  var init_application_activation = __esm(() => {
15997
16021
  init_build();
15998
16022
  init_application_configuration();
@@ -16019,16 +16043,261 @@ var init_application_activation = __esm(() => {
16019
16043
  activation_id: ApplicationActivationIdSchema,
16020
16044
  retired_at: String2()
16021
16045
  }, { additionalProperties: false });
16046
+ RollbackActivationSchema = _Object_({
16047
+ release_id: ApplicationReleaseIdSchema,
16048
+ configuration_id: ApplicationConfigurationIdSchema,
16049
+ activation_id: ApplicationActivationIdSchema
16050
+ }, { additionalProperties: false });
16051
+ ApplicationRollbackSnapshotSchema = _Object_({
16052
+ schema: Literal("supacloud.application-rollback-snapshot.v1"),
16053
+ project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
16054
+ application_id: ApplicationIdSchema,
16055
+ environment_id: ApplicationIdSchema,
16056
+ active: Union([RollbackActivationSchema, Null()]),
16057
+ previous: Union([RollbackActivationSchema, Null()])
16058
+ }, { additionalProperties: false });
16059
+ });
16060
+
16061
+ // node_modules/@supacloud/delivery/src/application-deploy-plan.ts
16062
+ var CandidateSchema, ApplicationDeployPlanSchema;
16063
+ var init_application_deploy_plan = __esm(() => {
16064
+ init_build();
16065
+ init_value2();
16066
+ init_application_release();
16067
+ init_application_activation();
16068
+ init_application_configuration();
16069
+ CandidateSchema = _Object_({
16070
+ release_id: ApplicationReleaseIdSchema,
16071
+ configuration_id: ApplicationConfigurationIdSchema
16072
+ }, { additionalProperties: false });
16073
+ ApplicationDeployPlanSchema = _Object_({
16074
+ schema: Literal("supacloud.application-deploy-plan.v1"),
16075
+ project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
16076
+ application_id: ApplicationIdSchema,
16077
+ environment_id: ApplicationIdSchema,
16078
+ candidate: CandidateSchema,
16079
+ current: Union([_Object_({
16080
+ ...CandidateSchema.properties,
16081
+ activation_id: ApplicationActivationIdSchema
16082
+ }, { additionalProperties: false }), Null()]),
16083
+ expected_activation_id: Union([ApplicationActivationIdSchema, Null()]),
16084
+ action: Union([Literal("activate"), Literal("no-op")]),
16085
+ changes: _Object_({
16086
+ release: Boolean2(),
16087
+ configuration: Boolean2(),
16088
+ targets: _Object_({
16089
+ added: _Array_(String2()),
16090
+ removed: _Array_(String2()),
16091
+ changed: _Array_(String2())
16092
+ }, { additionalProperties: false })
16093
+ }, { additionalProperties: false }),
16094
+ migrations: _Object_({
16095
+ ledger_digest: ApplicationReleaseIdSchema,
16096
+ ledger_compatible: Boolean2(),
16097
+ project_migrations_applied: Boolean2(),
16098
+ operator_provisioning: Union([
16099
+ Literal("separate-verification-required"),
16100
+ Literal("not-declared")
16101
+ ])
16102
+ }, { additionalProperties: false }),
16103
+ compatibility: Literal("not-proven"),
16104
+ execution_performed: Literal(false)
16105
+ }, { additionalProperties: false });
16106
+ });
16107
+
16108
+ // node_modules/@supacloud/delivery/src/application-release-operation.ts
16109
+ var closed6, nullableActivation, ApplicationReleaseRequestSchema, ApplicationReleaseResultSchema;
16110
+ var init_application_release_operation = __esm(() => {
16111
+ init_build();
16112
+ init_value2();
16113
+ init_application_activation();
16114
+ init_application_configuration();
16115
+ init_application_release();
16116
+ closed6 = { additionalProperties: false };
16117
+ nullableActivation = Union([ApplicationActivationIdSchema, Null()]);
16118
+ ApplicationReleaseRequestSchema = _Object_({
16119
+ release_id: ApplicationReleaseIdSchema,
16120
+ configuration_id: Optional(ApplicationConfigurationIdSchema),
16121
+ configuration_write: Optional(ApplicationConfigurationWriteSchema),
16122
+ activation_id: Optional(ApplicationActivationIdSchema),
16123
+ expected_activation_id: Optional(nullableActivation),
16124
+ expected_plan_sha256: Optional(ApplicationReleaseIdSchema)
16125
+ }, closed6);
16126
+ ApplicationReleaseResultSchema = _Object_({
16127
+ schema: Literal("supacloud.application-release.v1"),
16128
+ project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
16129
+ application_id: ApplicationIdSchema,
16130
+ environment_id: ApplicationIdSchema,
16131
+ release_id: ApplicationReleaseIdSchema,
16132
+ configuration_id: ApplicationConfigurationIdSchema,
16133
+ activation_id: ApplicationActivationIdSchema,
16134
+ expected_activation_id: nullableActivation,
16135
+ plan_sha256: ApplicationReleaseIdSchema,
16136
+ action: Union([Literal("activate"), Literal("no-op")]),
16137
+ replayed: Boolean2(),
16138
+ execution_performed: Boolean2()
16139
+ }, closed6);
16140
+ });
16141
+
16142
+ // node_modules/@supacloud/delivery/src/application-history.ts
16143
+ var scope, timestamp, ApplicationActivationHistoryPositionSchema, cursorSchema, ApplicationActivationHistoryCursorSchema, entrySchema, ApplicationActivationHistorySchema;
16144
+ var init_application_history = __esm(() => {
16145
+ init_build();
16146
+ init_value2();
16147
+ init_application_activation();
16148
+ init_application_configuration();
16149
+ init_application_release();
16150
+ scope = {
16151
+ project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
16152
+ application_id: ApplicationIdSchema,
16153
+ environment_id: ApplicationIdSchema
16154
+ };
16155
+ timestamp = String2({ pattern: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}Z$" });
16156
+ ApplicationActivationHistoryPositionSchema = _Object_({
16157
+ completed_at: timestamp,
16158
+ activation_id: ApplicationActivationIdSchema
16159
+ }, { additionalProperties: false });
16160
+ cursorSchema = _Object_({
16161
+ ...scope,
16162
+ ...ApplicationActivationHistoryPositionSchema.properties
16163
+ }, { additionalProperties: false });
16164
+ ApplicationActivationHistoryCursorSchema = String2({
16165
+ pattern: "^[A-Za-z0-9_-]+$",
16166
+ maxLength: 1024,
16167
+ minLength: 1
16168
+ });
16169
+ entrySchema = _Object_({
16170
+ ...ApplicationActivationHistoryPositionSchema.properties,
16171
+ release_id: ApplicationReleaseIdSchema,
16172
+ configuration_id: Union([ApplicationConfigurationIdSchema, Null()]),
16173
+ previous_activation_id: Union([ApplicationActivationIdSchema, Null()]),
16174
+ is_active: Boolean2()
16175
+ }, { additionalProperties: false });
16176
+ ApplicationActivationHistorySchema = _Object_({
16177
+ schema: Literal("supacloud.application-activation-history.v1"),
16178
+ ...scope,
16179
+ active_activation_id: Union([ApplicationActivationIdSchema, Null()]),
16180
+ activations: _Array_(entrySchema, { maxItems: 100 }),
16181
+ next_cursor: Union([ApplicationActivationHistoryCursorSchema, Null()])
16182
+ }, { additionalProperties: false });
16183
+ });
16184
+
16185
+ // node_modules/@supacloud/delivery/src/application-preview.ts
16186
+ var phaseStatus, closed7, ApplicationPreviewReceiptSchema;
16187
+ var init_application_preview = __esm(() => {
16188
+ init_build();
16189
+ init_value2();
16190
+ init_application_configuration();
16191
+ init_application_activation();
16192
+ init_application_release();
16193
+ phaseStatus = Union([
16194
+ Literal("pending"),
16195
+ Literal("ready"),
16196
+ Literal("failed"),
16197
+ Literal("cleaned")
16198
+ ]);
16199
+ closed7 = { additionalProperties: false };
16200
+ ApplicationPreviewReceiptSchema = _Object_({
16201
+ schema: Literal("supacloud.application-preview.v1"),
16202
+ preview_id: String2({ pattern: "^[a-f0-9-]{8,64}$" }),
16203
+ project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
16204
+ application_id: ApplicationIdSchema,
16205
+ environment_id: ApplicationIdSchema,
16206
+ release_id: ApplicationReleaseIdSchema,
16207
+ expires_at: Optional(Union([String2({
16208
+ pattern: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$",
16209
+ maxLength: 24
16210
+ }), Null()])),
16211
+ status: Union([
16212
+ Literal("planned"),
16213
+ Literal("provisioning"),
16214
+ Literal("ready"),
16215
+ Literal("failed"),
16216
+ Literal("cleaned")
16217
+ ]),
16218
+ resources: _Object_({
16219
+ build_artifact: _Object_({ status: phaseStatus, release_id: ApplicationReleaseIdSchema }, closed7),
16220
+ database_branch: _Object_({
16221
+ status: phaseStatus,
16222
+ branch_ref: String2({ pattern: "^[A-Za-z0-9_-]{1,20}$" }),
16223
+ data_mode: Union([Literal("schema_only"), Literal("full_clone")])
16224
+ }, closed7),
16225
+ queue_namespace: _Object_({
16226
+ status: phaseStatus,
16227
+ namespace: String2({ minLength: 1, maxLength: 128 })
16228
+ }, closed7),
16229
+ storage_namespace: _Object_({
16230
+ status: phaseStatus,
16231
+ namespace: String2({ minLength: 1, maxLength: 128 })
16232
+ }, closed7),
16233
+ test_secret: _Object_({
16234
+ status: phaseStatus,
16235
+ name: String2({ minLength: 1, maxLength: 128 }),
16236
+ value_issued: Literal(false)
16237
+ }, closed7),
16238
+ configuration_revision: _Object_({
16239
+ status: phaseStatus,
16240
+ configuration_id: Union([ApplicationConfigurationIdSchema, Null()])
16241
+ }, closed7),
16242
+ application_activation: _Object_({
16243
+ status: phaseStatus,
16244
+ activation_id: Union([ApplicationActivationIdSchema, Null()])
16245
+ }, closed7),
16246
+ smoke_test: _Object_({
16247
+ status: phaseStatus,
16248
+ checks: _Array_(String2({ minLength: 1, maxLength: 64 }), { maxItems: 32 }),
16249
+ passed: _Array_(String2({ minLength: 1, maxLength: 64 }), { maxItems: 32 }),
16250
+ failed: _Array_(String2({ minLength: 1, maxLength: 64 }), { maxItems: 32 })
16251
+ }, closed7)
16252
+ }, closed7),
16253
+ cleanup: _Object_({
16254
+ required: Boolean2(),
16255
+ completed: Boolean2(),
16256
+ error: Union([String2({ minLength: 1, maxLength: 128 }), Null()])
16257
+ }, closed7)
16258
+ }, closed7);
16259
+ });
16260
+
16261
+ // node_modules/@supacloud/delivery/src/application-release-transfer.ts
16262
+ var projectRef, source, identity, ApplicationReleaseTransferPlanSchema, ApplicationReleaseTransferResultSchema;
16263
+ var init_application_release_transfer = __esm(() => {
16264
+ init_build();
16265
+ init_value2();
16266
+ init_application_release();
16267
+ projectRef = String2({ pattern: "^[A-Za-z0-9_-]{1,20}$" });
16268
+ source = _Object_({
16269
+ project_ref: projectRef,
16270
+ release_id: ApplicationReleaseIdSchema,
16271
+ manifest_sha256: ApplicationReleaseIdSchema
16272
+ }, { additionalProperties: false });
16273
+ identity = {
16274
+ project_ref: projectRef,
16275
+ application_id: ApplicationIdSchema,
16276
+ source,
16277
+ candidate_release_id: ApplicationReleaseIdSchema
16278
+ };
16279
+ ApplicationReleaseTransferPlanSchema = _Object_({
16280
+ schema: Literal("supacloud.application-release-transfer-plan.v1"),
16281
+ ...identity,
16282
+ action: Union([Literal("materialize"), Literal("no-op")]),
16283
+ execution_performed: Literal(false)
16284
+ }, { additionalProperties: false });
16285
+ ApplicationReleaseTransferResultSchema = _Object_({
16286
+ schema: Literal("supacloud.application-release-transfer-result.v1"),
16287
+ ...identity,
16288
+ release: ApplicationReleaseRecordSchema,
16289
+ activation_performed: Literal(false)
16290
+ }, { additionalProperties: false });
16022
16291
  });
16023
16292
 
16024
16293
  // node_modules/@supacloud/delivery/src/deployment-evidence.ts
16025
- var closed6, sha256, isoDate, status, evidenceStatus, DEPLOYMENT_EVIDENCE_SCHEMA = "supacloud.deployment-evidence.v1", DatabaseProviderSchema, componentName, DeploymentComponentEvidenceSchema, DeploymentEvidenceSchema;
16294
+ var closed8, sha256, isoDate, status, evidenceStatus, DEPLOYMENT_EVIDENCE_SCHEMA = "supacloud.deployment-evidence.v1", DatabaseProviderSchema, componentName, DeploymentComponentEvidenceSchema, DeploymentEvidenceSchema;
16026
16295
  var init_deployment_evidence = __esm(() => {
16027
16296
  init_build();
16028
16297
  init_value2();
16029
16298
  init_application_configuration();
16030
16299
  init_application_release();
16031
- closed6 = { additionalProperties: false };
16300
+ closed8 = { additionalProperties: false };
16032
16301
  sha256 = String2({ pattern: "^[a-f0-9]{64}$" });
16033
16302
  isoDate = String2({ minLength: 20, maxLength: 40 });
16034
16303
  status = Union([
@@ -16054,19 +16323,19 @@ var init_deployment_evidence = __esm(() => {
16054
16323
  Literal("not-proven"),
16055
16324
  Literal("failed")
16056
16325
  ])
16057
- }, closed6),
16326
+ }, closed8),
16058
16327
  backup: _Object_({
16059
16328
  status,
16060
16329
  latest_success_at: Union([isoDate, Null()]),
16061
16330
  freshness_seconds: Union([Integer({ minimum: 0 }), Null()])
16062
- }, closed6),
16331
+ }, closed8),
16063
16332
  recovery: _Object_({
16064
16333
  status,
16065
16334
  drill_id: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
16066
16335
  rpo_seconds: Union([Integer({ minimum: 0 }), Null()]),
16067
16336
  rto_seconds: Union([Integer({ minimum: 0 }), Null()])
16068
- }, closed6)
16069
- }, closed6);
16337
+ }, closed8)
16338
+ }, closed8);
16070
16339
  componentName = Union([
16071
16340
  Literal("management-api"),
16072
16341
  Literal("web-console"),
@@ -16084,7 +16353,7 @@ var init_deployment_evidence = __esm(() => {
16084
16353
  status,
16085
16354
  health_check: Union([String2({ minLength: 1, maxLength: 256 }), Null()]),
16086
16355
  checked_at: Union([isoDate, Null()])
16087
- }, closed6);
16356
+ }, closed8);
16088
16357
  DeploymentEvidenceSchema = _Object_({
16089
16358
  schema: Literal(DEPLOYMENT_EVIDENCE_SCHEMA),
16090
16359
  status: evidenceStatus,
@@ -16093,33 +16362,110 @@ var init_deployment_evidence = __esm(() => {
16093
16362
  project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
16094
16363
  application_id: ApplicationIdSchema,
16095
16364
  environment_id: ApplicationIdSchema
16096
- }, closed6),
16365
+ }, closed8),
16097
16366
  source: _Object_({
16098
16367
  commit_sha: Union([String2({ pattern: "^[0-9a-f]{7,64}$" }), Null()]),
16099
16368
  manifest_sha256: sha256,
16100
16369
  contract_schema: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
16101
16370
  environment_binding_version: Union([sha256, Null()])
16102
- }, closed6),
16371
+ }, closed8),
16103
16372
  database: DatabaseProviderSchema,
16104
16373
  components: _Array_(DeploymentComponentEvidenceSchema, { minItems: 1, maxItems: 32 }),
16105
16374
  activation: _Object_({
16106
16375
  release_id: ApplicationReleaseIdSchema,
16107
16376
  configuration_id: ApplicationConfigurationIdSchema,
16108
16377
  activation_id: ApplicationConfigurationIdSchema
16109
- }, closed6),
16378
+ }, closed8),
16110
16379
  health: _Object_({
16111
16380
  status,
16112
16381
  checked_at: Union([isoDate, Null()]),
16113
16382
  authenticated_smoke: status
16114
- }, closed6),
16383
+ }, closed8),
16115
16384
  rollback: _Object_({
16116
16385
  release_id: Union([ApplicationReleaseIdSchema, Null()]),
16117
16386
  configuration_id: Union([ApplicationConfigurationIdSchema, Null()]),
16118
16387
  status: Union([Literal("ready"), Literal("not-ready"), Literal("unknown")]),
16119
16388
  result: Union([status, Null()])
16120
- }, closed6),
16389
+ }, closed8),
16121
16390
  notes: _Array_(String2({ minLength: 1, maxLength: 512 }), { maxItems: 32 })
16122
- }, closed6);
16391
+ }, closed8);
16392
+ });
16393
+
16394
+ // node_modules/@supacloud/delivery/src/application-promotion.ts
16395
+ var closed9, projectRef2, sha2562, nullableActivation2, nullableDigest, observation, blocker, ApplicationPromotionPlanSchema;
16396
+ var init_application_promotion = __esm(() => {
16397
+ init_build();
16398
+ init_value2();
16399
+ init_delivery_files();
16400
+ init_application_activation();
16401
+ init_application_configuration();
16402
+ init_application_release();
16403
+ closed9 = { additionalProperties: false };
16404
+ projectRef2 = String2({ pattern: "^[a-z0-9-]{1,20}$" });
16405
+ sha2562 = ApplicationReleaseIdSchema;
16406
+ nullableActivation2 = Union([ApplicationActivationIdSchema, Null()]);
16407
+ nullableDigest = Union([sha2562, Null()]);
16408
+ observation = {
16409
+ activation_id: nullableActivation2,
16410
+ receipt_confirmed: Boolean2(),
16411
+ ready: Boolean2(),
16412
+ smoke_verified: Boolean2(),
16413
+ evidence_sha256: nullableDigest,
16414
+ migration_ledger_digest: nullableDigest
16415
+ };
16416
+ blocker = [
16417
+ "SOURCE_NOT_ACTIVE",
16418
+ "SOURCE_RECEIPT_UNCONFIRMED",
16419
+ "SOURCE_NOT_READY",
16420
+ "SOURCE_SMOKE_UNVERIFIED",
16421
+ "TARGET_CONFIGURATION_MISSING",
16422
+ "TARGET_CONFIGURATION_MISMATCH",
16423
+ "MIGRATION_PENDING",
16424
+ "MIGRATION_CONFLICT",
16425
+ "OPERATOR_PROVISIONING_REQUIRED",
16426
+ "BACKUP_REQUIRED"
16427
+ ];
16428
+ ApplicationPromotionPlanSchema = _Object_({
16429
+ schema: Literal("supacloud.application-promotion-plan.v1"),
16430
+ project_ref: projectRef2,
16431
+ application_id: ApplicationIdSchema,
16432
+ environment_id: ApplicationIdSchema,
16433
+ manifest_sha256: sha2562,
16434
+ plan_sha256: sha2562,
16435
+ source: _Object_({
16436
+ project_ref: projectRef2,
16437
+ environment_id: ApplicationIdSchema,
16438
+ release_id: sha2562,
16439
+ ...observation
16440
+ }, closed9),
16441
+ target: _Object_({
16442
+ candidate_release_id: sha2562,
16443
+ current_release_id: Union([sha2562, Null()]),
16444
+ artifact_action: Union([Literal("materialize"), Literal("reuse")]),
16445
+ configuration_id: Union([ApplicationConfigurationIdSchema, Null()]),
16446
+ configuration: Union([ApplicationConfigurationViewSchema, Null()]),
16447
+ ...observation
16448
+ }, closed9),
16449
+ migrations: _Object_({
16450
+ ledger_digest: sha2562,
16451
+ ledger_compatible: Boolean2(),
16452
+ project_migrations_applied: Boolean2(),
16453
+ pending_versions: _Array_(String2({ pattern: "^\\d{1,20}$" }), { maxItems: 4096, uniqueItems: true }),
16454
+ operator_provisioning_required: Boolean2()
16455
+ }, closed9),
16456
+ backup: _Object_({
16457
+ required: Boolean2(),
16458
+ confirmed: Literal(false)
16459
+ }, closed9),
16460
+ action: Union([Literal("promote"), Literal("no-op"), Literal("blocked")]),
16461
+ blockers: _Array_(Enum([...blocker]), {
16462
+ maxItems: blocker.length,
16463
+ uniqueItems: true
16464
+ }),
16465
+ steps: _Array_(String2({ minLength: 1, maxLength: 64 }), { maxItems: 8, uniqueItems: true }),
16466
+ execution_performed: Literal(false),
16467
+ data_recovery: Literal("separate-required")
16468
+ }, closed9);
16123
16469
  });
16124
16470
 
16125
16471
  // node_modules/@supacloud/delivery/src/application-runtime-identity.ts
@@ -16210,13 +16556,13 @@ async function readDeliveryMigrationArchive(manifestPath, target) {
16210
16556
  throw new Error("Invalid delivery migration archive.");
16211
16557
  }
16212
16558
  }
16213
- var entrySchema, archiveSchema;
16559
+ var entrySchema2, archiveSchema;
16214
16560
  var init_delivery_migration_archive = __esm(() => {
16215
16561
  init_build();
16216
16562
  init_value2();
16217
16563
  init_delivery_artifact();
16218
16564
  init_delivery_files();
16219
- entrySchema = _Object_({
16565
+ entrySchema2 = _Object_({
16220
16566
  version: String2({ pattern: "^[1-9][0-9]{0,18}$" }),
16221
16567
  name: String2({ pattern: "^[A-Za-z][A-Za-z0-9_-]{0,127}$" }),
16222
16568
  executor: Union([Literal("project-migration"), Literal("operator-provisioning")]),
@@ -16230,7 +16576,7 @@ var init_delivery_migration_archive = __esm(() => {
16230
16576
  compatibility: Literal("not-proven"),
16231
16577
  executionPerformed: Literal(false),
16232
16578
  dataRecovery: Literal("separate-required"),
16233
- migrations: _Array_(entrySchema, { minItems: 1, maxItems: 128 })
16579
+ migrations: _Array_(entrySchema2, { minItems: 1, maxItems: 128 })
16234
16580
  }, { additionalProperties: false });
16235
16581
  });
16236
16582
 
@@ -16243,9 +16589,15 @@ var init_src = __esm(() => {
16243
16589
  init_worker_execution();
16244
16590
  init_worker_execution();
16245
16591
  init_application_activation();
16592
+ init_application_deploy_plan();
16593
+ init_application_release_operation();
16594
+ init_application_history();
16246
16595
  init_application_release();
16596
+ init_application_preview();
16597
+ init_application_release_transfer();
16247
16598
  init_application_configuration();
16248
16599
  init_deployment_evidence();
16600
+ init_application_promotion();
16249
16601
  init_application_runtime_identity();
16250
16602
  init_delivery_build_schema();
16251
16603
  init_delivery_migration_archive();
@@ -16261,7 +16613,7 @@ var init_delivery_migration_archive2 = __esm(() => {
16261
16613
  import { createHash as createHash9, randomUUID } from "node:crypto";
16262
16614
  import { lstat as lstat2, readFile as readFile6, realpath as realpath4, rename as rename4, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
16263
16615
  import { dirname as dirname8, isAbsolute as isAbsolute3, relative as relative8, resolve as resolve13, sep as sep8 } from "node:path";
16264
- import * as ts15 from "@typescript/typescript6";
16616
+ import * as ts16 from "@typescript/typescript6";
16265
16617
  async function applyDiagnosticFix(fix, options = {}) {
16266
16618
  if (!fix || typeof fix.targetFile !== "string")
16267
16619
  throw new Error("Invalid DiagnosticFix");
@@ -16290,7 +16642,7 @@ async function applyDiagnosticFix(fix, options = {}) {
16290
16642
  if (!current || current.initializer.getText(source) !== fix.expectedExpression) {
16291
16643
  throw new Error("Command mode changed since diagnosis; analyze the project again");
16292
16644
  }
16293
- content = replaceProperty(source, object, fix.property, ts15.factory.createStringLiteral(fix.value));
16645
+ content = replaceProperty(source, object, fix.property, ts16.factory.createStringLiteral(fix.value));
16294
16646
  break;
16295
16647
  }
16296
16648
  case "add_module_import": {
@@ -16301,15 +16653,15 @@ async function applyDiagnosticFix(fix, options = {}) {
16301
16653
  source = parse5(file, withImport);
16302
16654
  const object = unique(moduleObjects(source).filter((candidate) => !fix.targetModule || stringProperty(candidate, "name") === fix.targetModule), "target module");
16303
16655
  const imports = property(object, "imports");
16304
- if (imports && !ts15.isArrayLiteralExpression(imports.initializer)) {
16656
+ if (imports && !ts16.isArrayLiteralExpression(imports.initializer)) {
16305
16657
  throw new Error("Module imports must be a static array");
16306
16658
  }
16307
- const values = imports && ts15.isArrayLiteralExpression(imports.initializer) ? imports.initializer.elements : [];
16308
- if (values.some(ts15.isSpreadElement))
16659
+ const values = imports && ts16.isArrayLiteralExpression(imports.initializer) ? imports.initializer.elements : [];
16660
+ if (values.some(ts16.isSpreadElement))
16309
16661
  throw new Error("Module imports cannot contain spread elements");
16310
- content = values.some((value) => ts15.isIdentifier(value) && value.text === fix.symbol) ? withImport : replaceProperty(source, object, "imports", ts15.factory.createArrayLiteralExpression([
16662
+ content = values.some((value) => ts16.isIdentifier(value) && value.text === fix.symbol) ? withImport : replaceProperty(source, object, "imports", ts16.factory.createArrayLiteralExpression([
16311
16663
  ...values,
16312
- ts15.factory.createIdentifier(fix.symbol)
16664
+ ts16.factory.createIdentifier(fix.symbol)
16313
16665
  ]));
16314
16666
  break;
16315
16667
  }
@@ -16321,24 +16673,24 @@ async function applyDiagnosticFix(fix, options = {}) {
16321
16673
  const command = findClass(source, fix.command);
16322
16674
  const object = decoratorObject(command, "Command");
16323
16675
  const current = property(object, "permission");
16324
- if (current && (!ts15.isStringLiteral(current.initializer) || current.initializer.text !== permission)) {
16676
+ if (current && (!ts16.isStringLiteral(current.initializer) || current.initializer.text !== permission)) {
16325
16677
  throw new Error("Command permission already exists with a different value");
16326
16678
  }
16327
- content = current ? original : replaceProperty(source, object, "permission", ts15.factory.createStringLiteral(permission));
16679
+ content = current ? original : replaceProperty(source, object, "permission", ts16.factory.createStringLiteral(permission));
16328
16680
  break;
16329
16681
  }
16330
16682
  case "add_route_parameter_binding": {
16331
16683
  const controller = findClass(source, fix.controller);
16332
- const method = unique(controller.members.filter((member) => ts15.isMethodDeclaration(member) && nameOf(member.name) === fix.route), "route handler");
16333
- const parameter = unique(method.parameters.filter((candidate) => ts15.isIdentifier(candidate.name) && candidate.name.text === fix.parameter), "same-named route parameter");
16684
+ const method = unique(controller.members.filter((member) => ts16.isMethodDeclaration(member) && nameOf(member.name) === fix.route), "route handler");
16685
+ const parameter = unique(method.parameters.filter((candidate) => ts16.isIdentifier(candidate.name) && candidate.name.text === fix.parameter), "same-named route parameter");
16334
16686
  const binding = fix.binding === "param" ? "Param" : fix.binding === "query" ? "Query" : undefined;
16335
16687
  if (!binding)
16336
16688
  throw new Error("Invalid route binding");
16337
- const decorators = ts15.getDecorators(parameter) ?? [];
16689
+ const decorators = ts16.getDecorators(parameter) ?? [];
16338
16690
  if (decorators.length > 0)
16339
16691
  throw new Error("Parameter already has a decorator");
16340
- const framework = unique(source.statements.filter((statement) => ts15.isImportDeclaration(statement) && statement.importClause?.namedBindings && ts15.isNamedImports(statement.importClause.namedBindings) && statement.importClause.namedBindings.elements.some((element) => ["Controller", "Get", "Post", "Put", "Patch", "Delete", "Head", "Options"].includes(element.name.text))), "framework import");
16341
- if (!ts15.isImportDeclaration(framework) || !ts15.isStringLiteral(framework.moduleSpecifier)) {
16692
+ const framework = unique(source.statements.filter((statement) => ts16.isImportDeclaration(statement) && statement.importClause?.namedBindings && ts16.isNamedImports(statement.importClause.namedBindings) && statement.importClause.namedBindings.elements.some((element) => ["Controller", "Get", "Post", "Put", "Patch", "Delete", "Head", "Options"].includes(element.name.text))), "framework import");
16693
+ if (!ts16.isImportDeclaration(framework) || !ts16.isStringLiteral(framework.moduleSpecifier)) {
16342
16694
  throw new Error("Framework import must be static");
16343
16695
  }
16344
16696
  const edited = original.slice(0, parameter.getStart(source)) + `@${binding}(${JSON.stringify(fix.parameter)}) ` + original.slice(parameter.getStart(source));
@@ -16364,20 +16716,22 @@ async function applyDiagnosticFix(fix, options = {}) {
16364
16716
  return result;
16365
16717
  }
16366
16718
  function parse5(file, text) {
16367
- const result = ts15.transpileModule(text, {
16719
+ const result = ts16.transpileModule(text, {
16368
16720
  fileName: file,
16369
16721
  reportDiagnostics: true,
16370
- compilerOptions: { target: ts15.ScriptTarget.ESNext, experimentalDecorators: true }
16722
+ compilerOptions: { target: ts16.ScriptTarget.ESNext, experimentalDecorators: true }
16371
16723
  });
16372
- if (result.diagnostics?.some((item) => item.category === ts15.DiagnosticCategory.Error)) {
16724
+ if (result.diagnostics?.some((item) => item.category === ts16.DiagnosticCategory.Error)) {
16373
16725
  throw new Error("Cannot fix syntactically invalid TypeScript");
16374
16726
  }
16375
- return ts15.createSourceFile(file, text, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.TS);
16727
+ return ts16.createSourceFile(file, text, ts16.ScriptTarget.Latest, true, ts16.ScriptKind.TS);
16376
16728
  }
16377
16729
  function unique(items, description) {
16378
- if (items.length !== 1)
16730
+ const [item] = items;
16731
+ if (items.length !== 1 || item === undefined) {
16379
16732
  throw new Error(`Expected exactly one ${description}; found ${items.length}`);
16380
- return items[0];
16733
+ }
16734
+ return item;
16381
16735
  }
16382
16736
  function identifier2(value) {
16383
16737
  if (!/^[A-Za-z_$][\w$]*$/.test(value))
@@ -16386,50 +16740,50 @@ function identifier2(value) {
16386
16740
  function nameOf(name) {
16387
16741
  if (!name)
16388
16742
  return "";
16389
- return ts15.isIdentifier(name) || ts15.isStringLiteral(name) || ts15.isNumericLiteral(name) ? name.text : "";
16743
+ return ts16.isIdentifier(name) || ts16.isStringLiteral(name) || ts16.isNumericLiteral(name) ? name.text : "";
16390
16744
  }
16391
16745
  function property(object, key) {
16392
- if (object.properties.some((item) => !ts15.isPropertyAssignment(item) || ts15.isComputedPropertyName(item.name))) {
16746
+ if (object.properties.some((item) => !ts16.isPropertyAssignment(item) || ts16.isComputedPropertyName(item.name))) {
16393
16747
  throw new Error("Fix requires explicit static object properties");
16394
16748
  }
16395
- const values = object.properties.filter((item) => ts15.isPropertyAssignment(item) && nameOf(item.name) === key);
16749
+ const values = object.properties.filter((item) => ts16.isPropertyAssignment(item) && nameOf(item.name) === key);
16396
16750
  if (values.length > 1)
16397
16751
  throw new Error(`Duplicate '${key}' property`);
16398
16752
  return values[0];
16399
16753
  }
16400
16754
  function stringProperty(object, key) {
16401
16755
  const value = property(object, key)?.initializer;
16402
- return value && ts15.isStringLiteral(value) ? value.text : undefined;
16756
+ return value && ts16.isStringLiteral(value) ? value.text : undefined;
16403
16757
  }
16404
16758
  function replaceProperty(source, object, key, value) {
16405
16759
  const previous = property(object, key);
16406
- const replacement = ts15.factory.createPropertyAssignment(key, value);
16760
+ const replacement = ts16.factory.createPropertyAssignment(key, value);
16407
16761
  const properties = object.properties.map((item) => item === previous ? replacement : item);
16408
16762
  if (!previous)
16409
16763
  properties.push(replacement);
16410
- const updated = ts15.factory.updateObjectLiteralExpression(object, properties);
16411
- return source.text.slice(0, object.getStart(source)) + ts15.createPrinter().printNode(ts15.EmitHint.Expression, updated, source) + source.text.slice(object.end);
16764
+ const updated = ts16.factory.updateObjectLiteralExpression(object, properties);
16765
+ return source.text.slice(0, object.getStart(source)) + ts16.createPrinter().printNode(ts16.EmitHint.Expression, updated, source) + source.text.slice(object.end);
16412
16766
  }
16413
16767
  function findClass(source, name) {
16414
- return unique(source.statements.filter((statement) => ts15.isClassDeclaration(statement) && statement.name?.text === name), `class '${name}'`);
16768
+ return unique(source.statements.filter((statement) => ts16.isClassDeclaration(statement) && statement.name?.text === name), `class '${name}'`);
16415
16769
  }
16416
16770
  function decoratorObject(node, name) {
16417
- const decorator = unique((ts15.getDecorators(node) ?? []).filter((item) => ts15.isCallExpression(item.expression) && item.expression.expression.getText() === name), `@${name} decorator`);
16418
- const argument = ts15.isCallExpression(decorator.expression) ? decorator.expression.arguments[0] : undefined;
16419
- if (!argument || !ts15.isObjectLiteralExpression(argument))
16771
+ const decorator = unique((ts16.getDecorators(node) ?? []).filter((item) => ts16.isCallExpression(item.expression) && item.expression.expression.getText() === name), `@${name} decorator`);
16772
+ const argument = ts16.isCallExpression(decorator.expression) ? decorator.expression.arguments[0] : undefined;
16773
+ if (!argument || !ts16.isObjectLiteralExpression(argument))
16420
16774
  throw new Error(`@${name} requires a static object`);
16421
16775
  return argument;
16422
16776
  }
16423
16777
  function moduleObjects(source) {
16424
16778
  const result = [];
16425
16779
  for (const statement of source.statements) {
16426
- if (ts15.isClassDeclaration(statement) && (ts15.getDecorators(statement) ?? []).some((item) => ts15.isCallExpression(item.expression) && item.expression.expression.getText() === "Module")) {
16780
+ if (ts16.isClassDeclaration(statement) && (ts16.getDecorators(statement) ?? []).some((item) => ts16.isCallExpression(item.expression) && item.expression.expression.getText() === "Module")) {
16427
16781
  result.push(decoratorObject(statement, "Module"));
16428
16782
  }
16429
- if (ts15.isVariableStatement(statement)) {
16783
+ if (ts16.isVariableStatement(statement)) {
16430
16784
  for (const declaration of statement.declarationList.declarations) {
16431
16785
  const call = declaration.initializer;
16432
- if (call && ts15.isCallExpression(call) && ["defineModule", "defineFeatureSlice"].includes(call.expression.getText()) && call.arguments[0] && ts15.isObjectLiteralExpression(call.arguments[0])) {
16786
+ if (call && ts16.isCallExpression(call) && ["defineModule", "defineFeatureSlice"].includes(call.expression.getText()) && call.arguments[0] && ts16.isObjectLiteralExpression(call.arguments[0])) {
16433
16787
  result.push(call.arguments[0]);
16434
16788
  }
16435
16789
  }
@@ -16443,19 +16797,19 @@ function importSymbol(source, path, symbol) {
16443
16797
  const target = resolve13(dirname8(source.fileName), path).replace(/\.(tsx?|mts|cts)$/, "");
16444
16798
  if (current === target)
16445
16799
  return source.text;
16446
- const matches = source.statements.filter((item) => ts15.isImportDeclaration(item) && ts15.isStringLiteral(item.moduleSpecifier) && item.moduleSpecifier.text === path);
16800
+ const matches = source.statements.filter((item) => ts16.isImportDeclaration(item) && ts16.isStringLiteral(item.moduleSpecifier) && item.moduleSpecifier.text === path);
16447
16801
  if (matches.length > 1)
16448
16802
  throw new Error(`Ambiguous imports from '${path}'`);
16449
16803
  const match = matches[0];
16450
- if (match && ts15.isImportDeclaration(match) && match.importClause?.namedBindings && ts15.isNamedImports(match.importClause.namedBindings) && !match.importClause.isTypeOnly) {
16804
+ if (match && ts16.isImportDeclaration(match) && match.importClause?.namedBindings && ts16.isNamedImports(match.importClause.namedBindings) && !match.importClause.isTypeOnly) {
16451
16805
  if (match.importClause.namedBindings.elements.some((item) => item.name.text === symbol))
16452
16806
  return source.text;
16453
16807
  const bindings = match.importClause.namedBindings;
16454
- const updated = ts15.factory.updateNamedImports(bindings, [
16808
+ const updated = ts16.factory.updateNamedImports(bindings, [
16455
16809
  ...bindings.elements,
16456
- ts15.factory.createImportSpecifier(false, undefined, ts15.factory.createIdentifier(symbol))
16810
+ ts16.factory.createImportSpecifier(false, undefined, ts16.factory.createIdentifier(symbol))
16457
16811
  ]);
16458
- return source.text.slice(0, bindings.getStart(source)) + ts15.createPrinter().printNode(ts15.EmitHint.Unspecified, updated, source) + source.text.slice(bindings.end);
16812
+ return source.text.slice(0, bindings.getStart(source)) + ts16.createPrinter().printNode(ts16.EmitHint.Unspecified, updated, source) + source.text.slice(bindings.end);
16459
16813
  }
16460
16814
  if (match)
16461
16815
  throw new Error(`Import from '${path}' is not a named value import`);
@@ -16483,21 +16837,21 @@ function requestIdentifier(input) {
16483
16837
  }
16484
16838
  function decodeMetadata(input) {
16485
16839
  const envelope = record4(input);
16486
- if (Object.keys(envelope).some((key) => key !== "version" && key !== "events") || envelope.version !== 1 || !Array.isArray(envelope.events) || envelope.events.length > EXECUTION_CONTEXT_LIMITS.inputEvents)
16840
+ if (Object.keys(envelope).some((key) => key !== "version" && key !== "events") || envelope["version"] !== 1 || !Array.isArray(envelope["events"]) || envelope["events"].length > EXECUTION_CONTEXT_LIMITS.inputEvents)
16487
16841
  return invalid();
16488
- const events = envelope.events.map((entry) => {
16842
+ const events = envelope["events"].map((entry) => {
16489
16843
  const event = record4(entry);
16490
- if (Object.keys(event).some((key) => !["kind", "operation", "stage", "phase", "requestId", "durationMs", "attempt", "traceId"].includes(key)) || event.kind !== "route" && event.kind !== "command" && event.kind !== "job" || event.phase !== "started" && event.phase !== "succeeded" && event.phase !== "failed" || !metadataText(event.operation, 512) || !metadataText(event.stage, 256) || "requestId" in event && !requestIdentifier(event.requestId) || "traceId" in event && !requestIdentifier(event.traceId) || "attempt" in event && (typeof event.attempt !== "number" || !Number.isInteger(event.attempt) || event.attempt < 1 || event.attempt > 1e6) || "durationMs" in event && (typeof event.durationMs !== "number" || !Number.isFinite(event.durationMs) || event.durationMs < 0 || event.durationMs > Number.MAX_SAFE_INTEGER))
16844
+ if (Object.keys(event).some((key) => !["kind", "operation", "stage", "phase", "requestId", "durationMs", "attempt", "traceId"].includes(key)) || event["kind"] !== "route" && event["kind"] !== "command" && event["kind"] !== "job" || event["phase"] !== "started" && event["phase"] !== "succeeded" && event["phase"] !== "failed" || !metadataText(event["operation"], 512) || !metadataText(event["stage"], 256) || "requestId" in event && !requestIdentifier(event["requestId"]) || "traceId" in event && !requestIdentifier(event["traceId"]) || "attempt" in event && (typeof event["attempt"] !== "number" || !Number.isInteger(event["attempt"]) || event["attempt"] < 1 || event["attempt"] > 1e6) || "durationMs" in event && (typeof event["durationMs"] !== "number" || !Number.isFinite(event["durationMs"]) || event["durationMs"] < 0 || event["durationMs"] > Number.MAX_SAFE_INTEGER))
16491
16845
  return invalid();
16492
16846
  return {
16493
- kind: event.kind,
16494
- operation: event.operation,
16495
- stage: event.stage,
16496
- phase: event.phase,
16497
- ...event.requestId === undefined ? {} : { requestId: event.requestId },
16498
- ...event.durationMs === undefined ? {} : { durationMs: event.durationMs },
16499
- ...event.attempt === undefined ? {} : { attempt: event.attempt },
16500
- ...event.traceId === undefined ? {} : { traceId: event.traceId }
16847
+ kind: event["kind"],
16848
+ operation: event["operation"],
16849
+ stage: event["stage"],
16850
+ phase: event["phase"],
16851
+ ...event["requestId"] === undefined ? {} : { requestId: event["requestId"] },
16852
+ ...event["durationMs"] === undefined ? {} : { durationMs: event["durationMs"] },
16853
+ ...event["attempt"] === undefined ? {} : { attempt: event["attempt"] },
16854
+ ...event["traceId"] === undefined ? {} : { traceId: event["traceId"] }
16501
16855
  };
16502
16856
  });
16503
16857
  if (Buffer.byteLength(JSON.stringify({ version: 1, events }), "utf8") > EXECUTION_CONTEXT_LIMITS.inputBytes)
@@ -16662,10 +17016,10 @@ function correlateSnapshot(snapshot, subject, events, requestId) {
16662
17016
  correlation: "current-graph-only",
16663
17017
  deploymentVerified: false,
16664
17018
  eventsTrusted: false,
16665
- modules: modules.slice(0, EXECUTION_CONTEXT_LIMITS.modules).map((module) => ({
16666
- name: module.name,
16667
- ...executionSourceFile(module.file) ? { file: executionSourceFile(module.file) } : {}
16668
- })),
17019
+ modules: modules.slice(0, EXECUTION_CONTEXT_LIMITS.modules).map((module) => {
17020
+ const file = executionSourceFile(module.file);
17021
+ return { name: module.name, ...file === undefined ? {} : { file } };
17022
+ }),
16669
17023
  files: files.slice(0, EXECUTION_CONTEXT_LIMITS.files),
16670
17024
  executionPlans: [...matchedPlans].slice(0, EXECUTION_CONTEXT_LIMITS.plans),
16671
17025
  events: retained,
@@ -16754,16 +17108,16 @@ async function createDeliveryExecutionContextPack(manifestPath, target, subject,
16754
17108
  if (!observations || typeof observations !== "object" || Array.isArray(observations))
16755
17109
  throw invalid();
16756
17110
  const envelope = observations;
16757
- if (Object.keys(envelope).some((key) => !["version", "events", "delivery"].includes(key)) || !envelope.delivery || typeof envelope.delivery !== "object" || Array.isArray(envelope.delivery))
17111
+ if (Object.keys(envelope).some((key) => !["version", "events", "delivery"].includes(key)) || !envelope["delivery"] || typeof envelope["delivery"] !== "object" || Array.isArray(envelope["delivery"]))
16758
17112
  throw invalid();
16759
- const identity = envelope.delivery;
16760
- if (Object.keys(identity).length !== 2 || typeof identity.target !== "string" || typeof identity.objectId !== "string" || !/^[a-f0-9]{64}$/.test(identity.objectId))
17113
+ const identity = envelope["delivery"];
17114
+ if (Object.keys(identity).length !== 2 || typeof identity["target"] !== "string" || typeof identity["objectId"] !== "string" || !/^[a-f0-9]{64}$/.test(identity["objectId"]))
16761
17115
  throw invalid();
16762
17116
  let object;
16763
17117
  let snapshot;
16764
17118
  try {
16765
17119
  const { root, object: found, planned } = await readDeliverySelection(manifestPath, target);
16766
- if (!found || identity.target !== target || identity.objectId !== found.objectId) {
17120
+ if (!found || identity["target"] !== target || identity["objectId"] !== found.objectId) {
16767
17121
  throw new DeliveryContextError("DELIVERY_CONTEXT_IDENTITY_MISMATCH");
16768
17122
  }
16769
17123
  object = found;
@@ -16780,7 +17134,7 @@ async function createDeliveryExecutionContextPack(manifestPath, target, subject,
16780
17134
  throw new DeliveryContextError("DELIVERY_CONTEXT_INTEGRITY_FAILED");
16781
17135
  }
16782
17136
  const pack = {
16783
- ...executionContextFromSnapshot(snapshot, subject, { version: envelope.version, events: envelope.events }, requestId),
17137
+ ...executionContextFromSnapshot(snapshot, subject, { version: envelope["version"], events: envelope["events"] }, requestId),
16784
17138
  correlation: "verified-build-snapshot",
16785
17139
  delivery: { target, objectId: object.objectId, artifactVerified: true }
16786
17140
  };
@@ -16988,7 +17342,7 @@ var init_graphql_schema = __esm(() => {
16988
17342
  import { createHash as createHash12 } from "node:crypto";
16989
17343
  import { mkdir as mkdir6, readFile as readFile14 } from "node:fs/promises";
16990
17344
  import { dirname as dirname12, relative as relative12, resolve as resolve23 } from "node:path";
16991
- import * as ts17 from "@typescript/typescript6";
17345
+ import * as ts18 from "@typescript/typescript6";
16992
17346
  function hash3(value) {
16993
17347
  return createHash12("sha256").update(value).digest("hex");
16994
17348
  }
@@ -17028,20 +17382,20 @@ async function generateDatabaseContracts(options, check = false) {
17028
17382
  const rootDir = resolve23(options.rootDir), outDir = resolve23(options.outDir);
17029
17383
  const postgrestTypes = resolve23(rootDir, options.postgrestTypes), drizzleSchema = resolve23(rootDir, options.drizzleSchema);
17030
17384
  const snapshot = await readFile14(postgrestTypes, "utf8");
17031
- const syntax = ts17.createSourceFile(postgrestTypes, snapshot, ts17.ScriptTarget.Latest, true);
17032
- const database = syntax.statements.find((node) => (ts17.isTypeAliasDeclaration(node) || ts17.isInterfaceDeclaration(node)) && node.name.text === "Database" && node.modifiers?.some((modifier) => modifier.kind === ts17.SyntaxKind.ExportKeyword));
17385
+ const syntax = ts18.createSourceFile(postgrestTypes, snapshot, ts18.ScriptTarget.Latest, true);
17386
+ const database = syntax.statements.find((node) => (ts18.isTypeAliasDeclaration(node) || ts18.isInterfaceDeclaration(node)) && node.name.text === "Database" && node.modifiers?.some((modifier) => modifier.kind === ts18.SyntaxKind.ExportKeyword));
17033
17387
  if (!database)
17034
17388
  throw new Error("PostgREST snapshot must export Database from the official type generator");
17035
- const program = ts17.createProgram([postgrestTypes], {
17389
+ const program = ts18.createProgram([postgrestTypes], {
17036
17390
  strict: true,
17037
17391
  noEmit: true,
17038
17392
  skipLibCheck: true,
17039
17393
  types: [],
17040
- target: ts17.ScriptTarget.ES2022,
17041
- module: ts17.ModuleKind.ESNext,
17042
- moduleResolution: ts17.ModuleResolutionKind.Bundler
17394
+ target: ts18.ScriptTarget.ES2022,
17395
+ module: ts18.ModuleKind.ESNext,
17396
+ moduleResolution: ts18.ModuleResolutionKind.Bundler
17043
17397
  });
17044
- if (ts17.getPreEmitDiagnostics(program).length)
17398
+ if (ts18.getPreEmitDiagnostics(program).length)
17045
17399
  throw new Error("PostgREST snapshot has TypeScript errors");
17046
17400
  const artifacts = await renderGraphql({
17047
17401
  rootDir,
@@ -17059,11 +17413,11 @@ async function generateDatabaseContracts(options, check = false) {
17059
17413
  };
17060
17414
  await addInput(postgrestTypes);
17061
17415
  await addInput(drizzleSchema);
17062
- const drizzleProgram = ts17.createProgram([drizzleSchema], {
17416
+ const drizzleProgram = ts18.createProgram([drizzleSchema], {
17063
17417
  noEmit: true,
17064
- moduleResolution: ts17.ModuleResolutionKind.Bundler,
17065
- module: ts17.ModuleKind.ESNext,
17066
- target: ts17.ScriptTarget.ES2022,
17418
+ moduleResolution: ts18.ModuleResolutionKind.Bundler,
17419
+ module: ts18.ModuleKind.ESNext,
17420
+ target: ts18.ScriptTarget.ES2022,
17067
17421
  types: [],
17068
17422
  skipLibCheck: true
17069
17423
  });
@@ -17437,7 +17791,6 @@ function readProjectConfig(rootDir) {
17437
17791
  skipLibCheck: true
17438
17792
  },
17439
17793
  errors: [],
17440
- projectReferences: undefined,
17441
17794
  configFingerprint: "defaults"
17442
17795
  };
17443
17796
  }
@@ -17459,7 +17812,7 @@ function readProjectConfig(rootDir) {
17459
17812
  return {
17460
17813
  options: parsed.options,
17461
17814
  errors: parsed.errors,
17462
- projectReferences: parsed.projectReferences,
17815
+ ...parsed.projectReferences === undefined ? {} : { projectReferences: parsed.projectReferences },
17463
17816
  configFingerprint: JSON.stringify([...configReads])
17464
17817
  };
17465
17818
  }
@@ -20669,7 +21022,7 @@ import { join as join4 } from "node:path";
20669
21022
  // src/type-safety.ts
20670
21023
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
20671
21024
  import { dirname as dirname3, join as join3, relative as relative3, resolve as resolve3, sep as sep3 } from "node:path";
20672
- import * as ts9 from "@typescript/typescript6";
21025
+ import * as ts10 from "@typescript/typescript6";
20673
21026
 
20674
21027
  // src/sql-safety.ts
20675
21028
  import * as ts8 from "@typescript/typescript6";
@@ -20712,6 +21065,198 @@ function scanDrizzleSql(sourceFile, checker, file, strict) {
20712
21065
  return diagnostics;
20713
21066
  }
20714
21067
 
21068
+ // src/source-semantics.ts
21069
+ import * as ts9 from "@typescript/typescript6";
21070
+ var SOURCE_SEMANTIC_DIAGNOSTIC_CODES = {
21071
+ "source-unsafe-any": { errorCode: "SC6009", docsUrl: "https://supacloud.dev/errors/SC6009" },
21072
+ "source-floating-promise": { errorCode: "SC6010", docsUrl: "https://supacloud.dev/errors/SC6010" },
21073
+ "source-non-exhaustive-switch": { errorCode: "SC6011", docsUrl: "https://supacloud.dev/errors/SC6011" }
21074
+ };
21075
+ function scanSourceSemantics(source, checker, file, rootDir) {
21076
+ const diagnostics = [];
21077
+ const report = (code, node, message) => {
21078
+ diagnostics.push({
21079
+ severity: "error",
21080
+ code,
21081
+ ...SOURCE_SEMANTIC_DIAGNOSTIC_CODES[code],
21082
+ file,
21083
+ message,
21084
+ line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1
21085
+ });
21086
+ };
21087
+ const unsafe = (value, target) => {
21088
+ if (isUnknownBoundary(target, checker) || containsAny(target, checker, new Set, rootDir))
21089
+ return;
21090
+ if (containsAny(checker.getTypeAtLocation(value), checker, new Set, rootDir)) {
21091
+ report("source-unsafe-any", value, "An any-containing value cannot enter a concrete type. Quarantine it as unknown and decode it before use.");
21092
+ }
21093
+ };
21094
+ const declared = (node) => {
21095
+ let hasAnyKeyword = false;
21096
+ const visitType = (child) => {
21097
+ if (child.kind === ts9.SyntaxKind.AnyKeyword)
21098
+ hasAnyKeyword = true;
21099
+ ts9.forEachChild(child, visitType);
21100
+ };
21101
+ visitType(node);
21102
+ if (!hasAnyKeyword && containsAny(checker.getTypeAtLocation(node), checker, new Set, rootDir)) {
21103
+ report("source-unsafe-any", node, "Declared application types must not hide any through aliases or generic arguments.");
21104
+ }
21105
+ };
21106
+ const visit = (node) => {
21107
+ if (ts9.isTypeAliasDeclaration(node))
21108
+ declared(node.type);
21109
+ if ((ts9.isVariableDeclaration(node) || ts9.isParameter(node) || ts9.isPropertyDeclaration(node) || ts9.isPropertySignature(node)) && node.type)
21110
+ declared(node.type);
21111
+ if (ts9.isVariableDeclaration(node) && node.initializer) {
21112
+ const type = checker.getTypeAtLocation(node.name);
21113
+ if (node.type)
21114
+ unsafe(node.initializer, type);
21115
+ else if (ts9.isIdentifier(node.name) && !ts9.isArrowFunction(node.initializer) && !ts9.isFunctionExpression(node.initializer) && !(type.flags & ts9.TypeFlags.Any) && containsAny(type, checker, new Set, rootDir)) {
21116
+ report("source-unsafe-any", node.name, "Inferred values must not contain any, including nested and generic result types.");
21117
+ }
21118
+ }
21119
+ if (ts9.isPropertyDeclaration(node) && !node.type && node.initializer && containsAny(checker.getTypeAtLocation(node.name), checker, new Set, rootDir)) {
21120
+ report("source-unsafe-any", node.name, "Inferred class fields must not propagate any. Decode the value or quarantine it as unknown.");
21121
+ }
21122
+ if ((ts9.isFunctionDeclaration(node) || ts9.isMethodDeclaration(node) || ts9.isArrowFunction(node) || ts9.isFunctionExpression(node)) && !node.type && node.body) {
21123
+ const signature = checker.getSignatureFromDeclaration(node);
21124
+ if (signature && containsAny(checker.getReturnTypeOfSignature(signature), checker, new Set, rootDir)) {
21125
+ report("source-unsafe-any", node.name ?? node, "Inferred function results must not propagate any. Return unknown at the boundary or a decoded concrete result.");
21126
+ }
21127
+ }
21128
+ if (ts9.isFunctionLike(node) && node.type)
21129
+ declared(node.type);
21130
+ if (ts9.isBinaryExpression(node) && node.operatorToken.kind === ts9.SyntaxKind.EqualsToken) {
21131
+ unsafe(node.right, checker.getTypeAtLocation(node.left));
21132
+ }
21133
+ if (ts9.isAsExpression(node) || ts9.isTypeAssertionExpression(node)) {
21134
+ unsafe(node.expression, checker.getTypeAtLocation(node));
21135
+ }
21136
+ if (ts9.isReturnStatement(node) && node.expression) {
21137
+ let owner = node.parent;
21138
+ while (owner && !ts9.isFunctionLike(owner))
21139
+ owner = owner.parent;
21140
+ if (owner && ts9.isFunctionLike(owner) && owner.type) {
21141
+ const signature = checker.getSignatureFromDeclaration(owner);
21142
+ if (signature)
21143
+ unsafe(node.expression, checker.getReturnTypeOfSignature(signature));
21144
+ }
21145
+ }
21146
+ if (ts9.isCallExpression(node)) {
21147
+ const signature = checker.getResolvedSignature(node);
21148
+ const parameters = signature?.getParameters() ?? [];
21149
+ node.arguments.forEach((argument, index) => {
21150
+ const parameter = parameters[index] ?? parameters.at(-1);
21151
+ if (!parameter)
21152
+ return;
21153
+ const type = checker.getTypeOfSymbolAtLocation(parameter, node);
21154
+ const declaration = parameter.valueDeclaration;
21155
+ const rest = declaration && ts9.isParameter(declaration) && declaration.dotDotDotToken;
21156
+ const target = rest ? checker.getIndexTypeOfType(type, ts9.IndexKind.Number) ?? type : type;
21157
+ unsafe(argument, target);
21158
+ });
21159
+ }
21160
+ if (ts9.isExpressionStatement(node)) {
21161
+ const expression = unwrap(node.expression);
21162
+ if (isPromise(checker.getTypeAtLocation(expression), checker, expression) && !handlesRejection(expression, checker)) {
21163
+ report("source-floating-promise", node, "Promise work must be awaited, returned, or have a callable rejection handler. void does not establish cancellation ownership.");
21164
+ }
21165
+ }
21166
+ if (ts9.isSwitchStatement(node)) {
21167
+ const type = checker.getTypeAtLocation(node.expression);
21168
+ const members = type.isUnion() ? type.types : [type];
21169
+ if (members.every(isFiniteLiteral)) {
21170
+ const cases = node.caseBlock.clauses.filter(ts9.isCaseClause);
21171
+ const missing = members.filter((member) => !cases.some((clause) => sameLiteral(member, checker.getTypeAtLocation(clause.expression))));
21172
+ if (missing.length > 0) {
21173
+ report("source-non-exhaustive-switch", node.expression, `Switch is missing cases for ${missing.map((member) => checker.typeToString(member)).join(", ")}. A default branch does not replace explicit union cases.`);
21174
+ }
21175
+ }
21176
+ }
21177
+ ts9.forEachChild(node, visit);
21178
+ };
21179
+ visit(source);
21180
+ return diagnostics;
21181
+ }
21182
+ function containsAny(type, checker, seen, rootDir) {
21183
+ if (type.flags & ts9.TypeFlags.Any)
21184
+ return true;
21185
+ if (seen.has(type))
21186
+ return false;
21187
+ seen.add(type);
21188
+ if (type.isUnionOrIntersection())
21189
+ return type.types.some((part) => containsAny(part, checker, seen, rootDir));
21190
+ const declarations = type.getSymbol()?.declarations ?? [];
21191
+ if (declarations.some((declaration) => ts9.isClassDeclaration(declaration) && (declaration.getSourceFile().isDeclarationFile || declaration.getSourceFile().fileName.replaceAll("\\", "/").includes("/node_modules/"))))
21192
+ return false;
21193
+ const arguments_ = isTypeReference2(type) ? checker.getTypeArguments(type) : type.aliasTypeArguments ?? [];
21194
+ if (arguments_.some((argument) => containsAny(argument, checker, seen, rootDir)))
21195
+ return true;
21196
+ if (checker.getSignaturesOfType(type, ts9.SignatureKind.Call).some((signature) => {
21197
+ const declaration = signature.getDeclaration();
21198
+ return declaration !== undefined && isWithinRoot(declaration.getSourceFile().fileName, rootDir) && (containsAny(checker.getReturnTypeOfSignature(signature), checker, seen, rootDir) || signature.getParameters().some((parameter) => containsAny(checker.getTypeOfSymbolAtLocation(parameter, declaration), checker, seen, rootDir)));
21199
+ }))
21200
+ return true;
21201
+ return checker.getPropertiesOfType(type).some((property) => {
21202
+ const declaration = property.valueDeclaration ?? property.declarations?.[0];
21203
+ return declaration !== undefined && isWithinRoot(declaration.getSourceFile().fileName, rootDir) && containsAny(checker.getTypeOfSymbolAtLocation(property, declaration), checker, seen, rootDir);
21204
+ });
21205
+ }
21206
+ function isWithinRoot(file, rootDir) {
21207
+ const normalizedFile = file.replaceAll("\\", "/");
21208
+ const normalizedRoot = rootDir.replaceAll("\\", "/").replace(/\/+$/, "");
21209
+ return normalizedFile === normalizedRoot || normalizedFile.startsWith(`${normalizedRoot}/`);
21210
+ }
21211
+ function isUnknownBoundary(type, checker) {
21212
+ if (type.flags & (ts9.TypeFlags.Unknown | ts9.TypeFlags.Void))
21213
+ return true;
21214
+ const promised = promiseArgument(type, checker);
21215
+ return promised !== undefined && Boolean(promised.flags & ts9.TypeFlags.Unknown);
21216
+ }
21217
+ function unwrap(expression) {
21218
+ while (ts9.isParenthesizedExpression(expression) || ts9.isVoidExpression(expression))
21219
+ expression = expression.expression;
21220
+ return expression;
21221
+ }
21222
+ function isPromise(type, checker, node) {
21223
+ return type.isUnion() ? type.types.some((part) => isPromise(part, checker, node)) : promiseArgument(type, checker) !== undefined;
21224
+ }
21225
+ function handlesRejection(expression, checker) {
21226
+ if (!ts9.isCallExpression(expression) || !ts9.isPropertyAccessExpression(expression.expression))
21227
+ return false;
21228
+ const { name, expression: receiver } = expression.expression;
21229
+ if (!isPromise(checker.getTypeAtLocation(receiver), checker, receiver))
21230
+ return false;
21231
+ const handler = name.text === "catch" ? expression.arguments[0] : name.text === "then" ? expression.arguments[1] : undefined;
21232
+ return handler !== undefined && checker.getTypeAtLocation(handler).getCallSignatures().length > 0;
21233
+ }
21234
+ function isFiniteLiteral(type) {
21235
+ return Boolean(type.flags & (ts9.TypeFlags.StringLiteral | ts9.TypeFlags.NumberLiteral | ts9.TypeFlags.BigIntLiteral | ts9.TypeFlags.BooleanLiteral | ts9.TypeFlags.Null | ts9.TypeFlags.Undefined));
21236
+ }
21237
+ function sameLiteral(left, right) {
21238
+ if (left.flags !== right.flags)
21239
+ return false;
21240
+ if (left.isStringLiteral() && right.isStringLiteral())
21241
+ return left.value === right.value;
21242
+ if (left.isNumberLiteral() && right.isNumberLiteral())
21243
+ return left.value === right.value;
21244
+ return left === right;
21245
+ }
21246
+ function isTypeReference2(type) {
21247
+ return Boolean(type.flags & ts9.TypeFlags.Object) && "objectFlags" in type && typeof type.objectFlags === "number" && Boolean(type.objectFlags & ts9.ObjectFlags.Reference) && "target" in type;
21248
+ }
21249
+ function promiseArgument(type, checker) {
21250
+ if (type.flags & (ts9.TypeFlags.Any | ts9.TypeFlags.Unknown | ts9.TypeFlags.Never))
21251
+ return;
21252
+ const then = checker.getPropertyOfType(type, "then");
21253
+ const declaration = then?.valueDeclaration ?? then?.declarations?.[0];
21254
+ if (!then || !declaration || checker.getTypeOfSymbolAtLocation(then, declaration).getCallSignatures().length === 0)
21255
+ return;
21256
+ const awaited = checker.getAwaitedType(type);
21257
+ return awaited !== type ? awaited : undefined;
21258
+ }
21259
+
20715
21260
  // src/type-safety.ts
20716
21261
  var DEFAULT_EXCLUDES = [
20717
21262
  "**/*.test.ts",
@@ -20726,6 +21271,7 @@ var DEFAULT_EXCLUDES = [
20726
21271
  ];
20727
21272
  var TYPE_SAFETY_DIAGNOSTIC_CODES = {
20728
21273
  ...SQL_SAFETY_DIAGNOSTIC_CODES,
21274
+ ...SOURCE_SEMANTIC_DIAGNOSTIC_CODES,
20729
21275
  "generated-any": { errorCode: "SC6001", docsUrl: "https://supacloud.dev/errors/SC6001" },
20730
21276
  "source-any": { errorCode: "SC6002", docsUrl: "https://supacloud.dev/errors/SC6002" },
20731
21277
  "source-type-assertion": { errorCode: "SC6003", docsUrl: "https://supacloud.dev/errors/SC6003" },
@@ -20738,7 +21284,7 @@ function scanGeneratedArtifacts(artifacts, strict = true) {
20738
21284
  for (const [file, content] of Object.entries(artifacts)) {
20739
21285
  if (content === undefined)
20740
21286
  continue;
20741
- const sourceFile = ts9.createSourceFile(file, content, ts9.ScriptTarget.Latest, true, ts9.ScriptKind.TS);
21287
+ const sourceFile = ts10.createSourceFile(file, content, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TS);
20742
21288
  for (const node of descendantsOfKind2(sourceFile, isAnyKeyword)) {
20743
21289
  diagnostics.push(makeDiagnostic("generated-any", `生成产物 ${file} 包含 any;严格生成模式要求使用 unknown、具体接口或泛型约束。`, sourceFile, node, strict));
20744
21290
  }
@@ -20747,36 +21293,58 @@ function scanGeneratedArtifacts(artifacts, strict = true) {
20747
21293
  }
20748
21294
  function scanProductionSource(options) {
20749
21295
  const rootDir = resolve3(options.rootDir);
20750
- const configPath = ts9.findConfigFile(rootDir, ts9.sys.fileExists) ?? join3(rootDir, "tsconfig.json");
21296
+ const configPath = ts10.findConfigFile(rootDir, ts10.sys.fileExists) ?? join3(rootDir, "tsconfig.json");
20751
21297
  const projectConfig = existsSync2(configPath) ? readProjectConfig2(configPath) : {
20752
21298
  options: {
20753
21299
  strict: true,
21300
+ experimentalDecorators: true,
20754
21301
  skipLibCheck: true,
20755
- target: ts9.ScriptTarget.ES2022,
20756
- module: ts9.ModuleKind.ESNext,
20757
- moduleResolution: ts9.ModuleResolutionKind.Bundler
21302
+ target: ts10.ScriptTarget.ES2022,
21303
+ module: ts10.ModuleKind.ESNext,
21304
+ moduleResolution: ts10.ModuleResolutionKind.Bundler
20758
21305
  },
20759
21306
  errors: []
20760
21307
  };
20761
21308
  const include = options.include ?? ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"];
20762
- const rootNames = ts9.sys.readDirectory(rootDir, [".ts", ".tsx", ".mts", ".cts"], ["node_modules", "dist"], include).filter((file) => isProductionSourcePath(rootDir, file, [...DEFAULT_EXCLUDES, ...options.exclude ?? []]));
20763
- const compilerOptions = { ...projectConfig.options, noEmit: true };
20764
- const host = ts9.createCompilerHost(compilerOptions);
21309
+ const rootNames = ts10.sys.readDirectory(rootDir, [".ts", ".tsx", ".mts", ".cts"], ["node_modules", "dist"], include).filter((file) => isProductionSourcePath(rootDir, file, [...DEFAULT_EXCLUDES, ...options.exclude ?? []]));
21310
+ const compilerOptions = {
21311
+ ...projectConfig.options,
21312
+ noCheck: false,
21313
+ strict: true,
21314
+ noImplicitAny: true,
21315
+ strictNullChecks: true,
21316
+ strictFunctionTypes: true,
21317
+ strictBindCallApply: true,
21318
+ strictPropertyInitialization: true,
21319
+ strictBuiltinIteratorReturn: true,
21320
+ noImplicitThis: true,
21321
+ useUnknownInCatchVariables: true,
21322
+ alwaysStrict: true,
21323
+ noUncheckedIndexedAccess: true,
21324
+ exactOptionalPropertyTypes: true,
21325
+ noImplicitOverride: true,
21326
+ noPropertyAccessFromIndexSignature: true,
21327
+ noFallthroughCasesInSwitch: true,
21328
+ forceConsistentCasingInFileNames: true,
21329
+ noEmit: true
21330
+ };
21331
+ const host = ts10.createCompilerHost(compilerOptions);
20765
21332
  host.getCurrentDirectory = () => dirname3(configPath);
20766
- const program = ts9.createProgram(rootNames, compilerOptions, host);
21333
+ const program = ts10.createProgram(rootNames, compilerOptions, host);
20767
21334
  const outDir = options.outDir ? normalizeRelative(rootDir, options.outDir) : undefined;
20768
21335
  const excludes = [...DEFAULT_EXCLUDES, ...options.exclude ?? []];
20769
21336
  const sourceFiles = program.getSourceFiles().filter((sourceFile) => isProductionSource(rootDir, sourceFile, excludes, outDir));
20770
21337
  const diagnostics = [...projectConfig.errors, ...program.getOptionsDiagnostics()].map((diagnostic) => ({
20771
21338
  severity: "error",
20772
21339
  code: "source-config",
20773
- message: ts9.flattenDiagnosticMessageText(diagnostic.messageText, `
21340
+ message: ts10.flattenDiagnosticMessageText(diagnostic.messageText, `
20774
21341
  `),
20775
21342
  file: diagnostic.file ? normalizeRelative(rootDir, diagnostic.file.fileName) : normalizeRelative(rootDir, configPath),
20776
21343
  ...diagnostic.file && diagnostic.start !== undefined ? { line: diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start).line + 1 } : {},
20777
21344
  errorCode: `TS${diagnostic.code}`
20778
21345
  }));
20779
21346
  const checker = program.getTypeChecker();
21347
+ const moduleResolutionCodes = new Set([2307, 2688, 2792]);
20780
21348
  for (const diagnostic of [
20781
21349
  ...program.getGlobalDiagnostics(),
20782
21350
  ...sourceFiles.flatMap((sourceFile) => [
@@ -20786,8 +21354,8 @@ function scanProductionSource(options) {
20786
21354
  ]) {
20787
21355
  diagnostics.push({
20788
21356
  severity: "error",
20789
- code: "source-typescript",
20790
- message: ts9.flattenDiagnosticMessageText(diagnostic.messageText, `
21357
+ code: moduleResolutionCodes.has(diagnostic.code) ? "source-config" : "source-typescript",
21358
+ message: ts10.flattenDiagnosticMessageText(diagnostic.messageText, `
20791
21359
  `),
20792
21360
  ...diagnostic.file ? { file: normalizeRelative(rootDir, diagnostic.file.fileName) } : {},
20793
21361
  ...diagnostic.file && diagnostic.start !== undefined ? { line: diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start).line + 1 } : {},
@@ -20796,10 +21364,11 @@ function scanProductionSource(options) {
20796
21364
  }
20797
21365
  for (const sourceFile of sourceFiles) {
20798
21366
  scanSourceFile(sourceFile, checker, rootDir, diagnostics, options.strict ?? false);
21367
+ diagnostics.push(...scanSourceSemantics(sourceFile, checker, normalizeRelative(rootDir, sourceFile.fileName), rootDir));
20799
21368
  diagnostics.push(...scanDrizzleSql(sourceFile, checker, normalizeRelative(rootDir, sourceFile.fileName), options.strict ?? false));
20800
- const scanner = ts9.createScanner(ts9.ScriptTarget.Latest, false, sourceFile.languageVariant, sourceFile.text);
20801
- for (let kind = scanner.scan();kind !== ts9.SyntaxKind.EndOfFileToken; kind = scanner.scan()) {
20802
- if ((kind === ts9.SyntaxKind.SingleLineCommentTrivia || kind === ts9.SyntaxKind.MultiLineCommentTrivia) && /@ts-(?:ignore|nocheck|expect-error)\b/.test(scanner.getTokenText())) {
21369
+ const scanner = ts10.createScanner(ts10.ScriptTarget.Latest, false, sourceFile.languageVariant, sourceFile.text);
21370
+ for (let kind = scanner.scan();kind !== ts10.SyntaxKind.EndOfFileToken; kind = scanner.scan()) {
21371
+ if ((kind === ts10.SyntaxKind.SingleLineCommentTrivia || kind === ts10.SyntaxKind.MultiLineCommentTrivia) && /@ts-(?:ignore|nocheck|expect-error)\b/.test(scanner.getTokenText())) {
20803
21372
  diagnostics.push({
20804
21373
  severity: "error",
20805
21374
  code: "source-type-suppression",
@@ -20819,22 +21388,22 @@ function scanSourceFile(sourceFile, checker, rootDir, diagnostics, strict) {
20819
21388
  diagnostics.push(makeDiagnostic("source-any", "生产源码使用了显式 any;请改用 unknown、具体接口或泛型约束。", sourceFile, node, strict, rootDir));
20820
21389
  }
20821
21390
  for (const node of descendants(sourceFile)) {
20822
- if (ts9.isAsExpression(node)) {
20823
- if (ts9.isAsExpression(node.parent) || ts9.isTypeAssertionExpression(node.parent))
21391
+ if (ts10.isAsExpression(node)) {
21392
+ if (ts10.isAsExpression(node.parent) || ts10.isTypeAssertionExpression(node.parent))
20824
21393
  continue;
20825
21394
  const assertedType = node.type.getText(sourceFile);
20826
21395
  if (assertedType === "const")
20827
21396
  continue;
20828
21397
  diagnostics.push(makeDiagnostic("source-type-assertion", `生产源码包含类型断言 ${node.getText(sourceFile)};请优先使用类型守卫、satisfies 或显式边界解析。`, sourceFile, node, strict, rootDir));
20829
- } else if (ts9.isTypeAssertionExpression(node)) {
20830
- if (ts9.isAsExpression(node.parent) || ts9.isTypeAssertionExpression(node.parent))
21398
+ } else if (ts10.isTypeAssertionExpression(node)) {
21399
+ if (ts10.isAsExpression(node.parent) || ts10.isTypeAssertionExpression(node.parent))
20831
21400
  continue;
20832
21401
  diagnostics.push(makeDiagnostic("source-type-assertion", `生产源码包含类型断言 ${node.getText(sourceFile)};请优先使用类型守卫、satisfies 或显式边界解析。`, sourceFile, node, strict, rootDir));
20833
- } else if (ts9.isNonNullExpression(node)) {
21402
+ } else if (ts10.isNonNullExpression(node)) {
20834
21403
  diagnostics.push(makeDiagnostic("source-non-null-assertion", `生产源码包含非空断言 ${node.getText(sourceFile)};请显式处理 null/undefined。`, sourceFile, node, strict, rootDir));
20835
21404
  }
20836
21405
  }
20837
- for (const declaration of descendantsOfKind2(sourceFile, ts9.isVariableDeclaration)) {
21406
+ for (const declaration of descendantsOfKind2(sourceFile, ts10.isVariableDeclaration)) {
20838
21407
  const initializer = declaration.initializer;
20839
21408
  if (!initializer || declaration.type)
20840
21409
  continue;
@@ -20850,11 +21419,11 @@ function scanSourceFile(sourceFile, checker, rootDir, diagnostics, strict) {
20850
21419
  if (isLetDeclaration(declaration) && isLiteralSyntax(initializer) && !isLiteralType(declarationType)) {
20851
21420
  diagnostics.push(makeDiagnostic("source-implicit-widening", `变量 ${declaration.name.getText(sourceFile)} 的字面量类型从 ${checker.typeToString(initializerType, initializer)} 隐式宽化为 ${checker.typeToString(declarationType, declaration)};请补充类型或使用 const。`, sourceFile, declaration, strict, rootDir));
20852
21421
  }
20853
- if (ts9.isObjectLiteralExpression(initializer) && isConstDeclaration(declaration) && initializer.getText(sourceFile).length > 0 && initializer.properties.some((property) => ts9.isPropertyAssignment(property) && property.initializer !== undefined && !ts9.isAsExpression(property.initializer) && isLiteralExpression(property.initializer))) {
21422
+ if (ts10.isObjectLiteralExpression(initializer) && isConstDeclaration(declaration) && initializer.getText(sourceFile).length > 0 && initializer.properties.some((property) => ts10.isPropertyAssignment(property) && property.initializer !== undefined && !ts10.isAsExpression(property.initializer) && isLiteralExpression(property.initializer))) {
20854
21423
  diagnostics.push(makeDiagnostic("source-implicit-widening", `常量对象 ${declaration.name.getText(sourceFile)} 的字面量属性会隐式宽化;请补充对象类型或使用 as const。`, sourceFile, declaration, strict, rootDir));
20855
21424
  }
20856
21425
  }
20857
- for (const parameter of descendantsOfKind2(sourceFile, ts9.isParameter)) {
21426
+ for (const parameter of descendantsOfKind2(sourceFile, ts10.isParameter)) {
20858
21427
  if (parameter.type)
20859
21428
  continue;
20860
21429
  for (const name of bindingNames(parameter.name)) {
@@ -20865,10 +21434,10 @@ function scanSourceFile(sourceFile, checker, rootDir, diagnostics, strict) {
20865
21434
  }
20866
21435
  }
20867
21436
  function readProjectConfig2(configPath) {
20868
- const config = ts9.readConfigFile(configPath, (file) => readFileSync2(file, "utf8"));
21437
+ const config = ts10.readConfigFile(configPath, (file) => readFileSync2(file, "utf8"));
20869
21438
  if (config.error)
20870
21439
  return { options: {}, errors: [config.error] };
20871
- const parsed = ts9.parseJsonConfigFileContent(config.config, ts9.sys, dirname3(configPath));
21440
+ const parsed = ts10.parseJsonConfigFileContent(config.config, ts10.sys, dirname3(configPath));
20872
21441
  return { options: parsed.options, errors: parsed.errors };
20873
21442
  }
20874
21443
  function isProductionSource(rootDir, sourceFile, excludes, outDir) {
@@ -20888,42 +21457,42 @@ function globMatches(value, pattern) {
20888
21457
  return new RegExp(`^${escaped}$`).test(value);
20889
21458
  }
20890
21459
  function bindingNames(name) {
20891
- if (ts9.isIdentifier(name))
21460
+ if (ts10.isIdentifier(name))
20892
21461
  return [name];
20893
- return name.elements.flatMap((element) => ts9.isBindingElement(element) ? bindingNames(element.name) : []);
21462
+ return name.elements.flatMap((element) => ts10.isBindingElement(element) ? bindingNames(element.name) : []);
20894
21463
  }
20895
21464
  function isLiteralExpression(node) {
20896
21465
  if (!node)
20897
21466
  return false;
20898
21467
  return [
20899
- ts9.SyntaxKind.StringLiteral,
20900
- ts9.SyntaxKind.NumericLiteral,
20901
- ts9.SyntaxKind.TrueKeyword,
20902
- ts9.SyntaxKind.FalseKeyword
21468
+ ts10.SyntaxKind.StringLiteral,
21469
+ ts10.SyntaxKind.NumericLiteral,
21470
+ ts10.SyntaxKind.TrueKeyword,
21471
+ ts10.SyntaxKind.FalseKeyword
20903
21472
  ].includes(node.kind);
20904
21473
  }
20905
21474
  function isLiteralSyntax(node) {
20906
- return ts9.isStringLiteral(node) || ts9.isNumericLiteral(node) || node.kind === ts9.SyntaxKind.TrueKeyword || node.kind === ts9.SyntaxKind.FalseKeyword;
21475
+ return ts10.isStringLiteral(node) || ts10.isNumericLiteral(node) || node.kind === ts10.SyntaxKind.TrueKeyword || node.kind === ts10.SyntaxKind.FalseKeyword;
20907
21476
  }
20908
21477
  function isLiteralType(type) {
20909
- return (type.flags & (ts9.TypeFlags.StringLiteral | ts9.TypeFlags.NumberLiteral | ts9.TypeFlags.BooleanLiteral | ts9.TypeFlags.BigIntLiteral)) !== 0;
21478
+ return (type.flags & (ts10.TypeFlags.StringLiteral | ts10.TypeFlags.NumberLiteral | ts10.TypeFlags.BooleanLiteral | ts10.TypeFlags.BigIntLiteral)) !== 0;
20910
21479
  }
20911
21480
  function isAnyType(type) {
20912
- return (type.flags & ts9.TypeFlags.Any) !== 0;
21481
+ return (type.flags & ts10.TypeFlags.Any) !== 0;
20913
21482
  }
20914
21483
  function isLetDeclaration(declaration) {
20915
- return ts9.isVariableDeclarationList(declaration.parent) && (declaration.parent.flags & ts9.NodeFlags.Let) !== 0;
21484
+ return ts10.isVariableDeclarationList(declaration.parent) && (declaration.parent.flags & ts10.NodeFlags.Let) !== 0;
20916
21485
  }
20917
21486
  function isConstDeclaration(declaration) {
20918
- return ts9.isVariableDeclarationList(declaration.parent) && (declaration.parent.flags & ts9.NodeFlags.Const) !== 0;
21487
+ return ts10.isVariableDeclarationList(declaration.parent) && (declaration.parent.flags & ts10.NodeFlags.Const) !== 0;
20919
21488
  }
20920
21489
  function descendants(root) {
20921
21490
  const result = [];
20922
21491
  const visit = (node) => {
20923
21492
  result.push(node);
20924
- ts9.forEachChild(node, visit);
21493
+ ts10.forEachChild(node, visit);
20925
21494
  };
20926
- ts9.forEachChild(root, visit);
21495
+ ts10.forEachChild(root, visit);
20927
21496
  return result;
20928
21497
  }
20929
21498
  function descendantsOfKind2(root, predicate) {
@@ -20931,9 +21500,9 @@ function descendantsOfKind2(root, predicate) {
20931
21500
  const visit = (node) => {
20932
21501
  if (predicate(node))
20933
21502
  result.push(node);
20934
- ts9.forEachChild(node, visit);
21503
+ ts10.forEachChild(node, visit);
20935
21504
  };
20936
- ts9.forEachChild(root, visit);
21505
+ ts10.forEachChild(root, visit);
20937
21506
  return result;
20938
21507
  }
20939
21508
  function makeDiagnostic(code, message, fileOrSourceFile, node, strict, rootDir) {
@@ -20941,7 +21510,7 @@ function makeDiagnostic(code, message, fileOrSourceFile, node, strict, rootDir)
20941
21510
  const file = typeof fileOrSourceFile === "string" ? fileOrSourceFile : rootDir ? normalizeRelative(rootDir, fileOrSourceFile.fileName) : fileOrSourceFile.fileName;
20942
21511
  const meta = TYPE_SAFETY_DIAGNOSTIC_CODES[code];
20943
21512
  return {
20944
- severity: strict ? "error" : "warn",
21513
+ severity: strict || code === "source-any" || code === "generated-any" ? "error" : "warn",
20945
21514
  code,
20946
21515
  message,
20947
21516
  file,
@@ -20954,7 +21523,7 @@ function normalizeRelative(rootDir, filePath) {
20954
21523
  return relative3(rootDir, filePath).split(sep3).join("/").replace(/^\.\//, "");
20955
21524
  }
20956
21525
  function isAnyKeyword(node) {
20957
- return node.kind === ts9.SyntaxKind.AnyKeyword;
21526
+ return node.kind === ts10.SyntaxKind.AnyKeyword;
20958
21527
  }
20959
21528
 
20960
21529
  // src/compile.ts
@@ -21115,11 +21684,12 @@ async function compileProject(options) {
21115
21684
  }, options.strict ?? false));
21116
21685
  }
21117
21686
  const hasErrors = diagnostics.some((diagnostic) => diagnostic.severity === "error");
21687
+ const hasTypeErrors = diagnostics.some(({ severity, code }) => severity === "error" && (code.startsWith("source-") || code === "generated-any"));
21118
21688
  const generatedOptions = {
21119
21689
  ...options,
21120
21690
  ...options.cache ? { artifactHashes: options.cache.generatedHashes } : {}
21121
21691
  };
21122
- const written = !hasErrors || options.writeOnError === true ? await writeRenderedApplication(rendered, generatedOptions) : [];
21692
+ const written = !hasErrors || options.writeOnError === true && !hasTypeErrors ? await writeRenderedApplication(rendered, generatedOptions) : [];
21123
21693
  if (!hasErrors) {
21124
21694
  for (const [filename, content] of Object.entries(graphql.files)) {
21125
21695
  const path = join4(options.outDir, filename);
@@ -21216,8 +21786,8 @@ async function checkProject(options) {
21216
21786
  }
21217
21787
  function resolveTypeSafety(options) {
21218
21788
  return {
21219
- noAnyInGenerated: options.typeSafety?.noAnyInGenerated ?? options.strict ?? false,
21220
- scanProductionSource: options.typeSafety?.scanProductionSource ?? options.strict ?? false,
21789
+ noAnyInGenerated: true,
21790
+ scanProductionSource: true,
21221
21791
  ...options.typeSafety?.exclude ? { exclude: options.typeSafety.exclude } : {}
21222
21792
  };
21223
21793
  }
@@ -21472,7 +22042,7 @@ function formatDeliveryPlan(result) {
21472
22042
  import { mkdir as mkdir3, mkdtemp, readFile as readFile5, realpath as realpath3, rename as rename3, rm as rm2 } from "node:fs/promises";
21473
22043
  import { readFileSync as readFileSync3 } from "node:fs";
21474
22044
  import { dirname as dirname7, join as join9, relative as relative7, resolve as resolve12, sep as sep7 } from "node:path";
21475
- import * as ts14 from "@typescript/typescript6";
22045
+ import * as ts15 from "@typescript/typescript6";
21476
22046
 
21477
22047
  // src/delivery-build-schema.ts
21478
22048
  init_delivery_build_schema();
@@ -21514,22 +22084,22 @@ init_delivery_files2();
21514
22084
  import { isBuiltin } from "node:module";
21515
22085
  import { readFile as readFile4 } from "node:fs/promises";
21516
22086
  import { join as join7, resolve as resolve9 } from "node:path";
21517
- import * as ts13 from "@typescript/typescript6";
22087
+ import * as ts14 from "@typescript/typescript6";
21518
22088
 
21519
22089
  // src/delivery-imports.ts
21520
- import * as ts12 from "@typescript/typescript6";
22090
+ import * as ts13 from "@typescript/typescript6";
21521
22091
  function staticDeliveryImports(path, contents) {
21522
22092
  if (!/\.[cm]?[jt]sx?$/.test(path))
21523
22093
  return contents;
21524
- const source = ts12.createSourceFile(path, new TextDecoder().decode(contents), ts12.ScriptTarget.Latest, true);
22094
+ const source = ts13.createSourceFile(path, new TextDecoder().decode(contents), ts13.ScriptTarget.Latest, true);
21525
22095
  const computed = [];
21526
22096
  function scan(node) {
21527
- if (ts12.isCallExpression(node) && (node.expression.kind === ts12.SyntaxKind.ImportKeyword || ts12.isIdentifier(node.expression) && node.expression.text === "require")) {
22097
+ if (ts13.isCallExpression(node) && (node.expression.kind === ts13.SyntaxKind.ImportKeyword || ts13.isIdentifier(node.expression) && node.expression.text === "require")) {
21528
22098
  const argument = node.arguments[0];
21529
- if (!argument || !ts12.isStringLiteral(argument) && !ts12.isNoSubstitutionTemplateLiteral(argument))
22099
+ if (!argument || !ts13.isStringLiteral(argument) && !ts13.isNoSubstitutionTemplateLiteral(argument))
21530
22100
  computed.push(node);
21531
22101
  }
21532
- ts12.forEachChild(node, scan);
22102
+ ts13.forEachChild(node, scan);
21533
22103
  }
21534
22104
  scan(source);
21535
22105
  if (computed.length === 0)
@@ -21537,36 +22107,36 @@ function staticDeliveryImports(path, contents) {
21537
22107
  const reject = () => {
21538
22108
  throw new Error("Computed module loading is not supported in independent delivery bundles.");
21539
22109
  };
21540
- if (!ts12.isExternalModule(source))
22110
+ if (!ts13.isExternalModule(source))
21541
22111
  return reject();
21542
- const host = ts12.createCompilerHost({ noLib: true, noResolve: true, allowJs: true });
22112
+ const host = ts13.createCompilerHost({ noLib: true, noResolve: true, allowJs: true });
21543
22113
  host.getSourceFile = (name) => name === path ? source : undefined;
21544
- const checker = ts12.createProgram([path], { noLib: true, noResolve: true, allowJs: true }, host).getTypeChecker();
22114
+ const checker = ts13.createProgram([path], { noLib: true, noResolve: true, allowJs: true }, host).getTypeChecker();
21545
22115
  const replacements = new Map;
21546
22116
  const removed = new Set;
21547
22117
  for (const call of computed) {
21548
22118
  let visit = function(node) {
21549
- const referenced = ts12.isIdentifier(node) ? ts12.isShorthandPropertyAssignment(node.parent) ? checker.getShorthandAssignmentValueSymbol(node.parent) : ts12.isExportSpecifier(node.parent) ? checker.getExportSpecifierLocalTargetSymbol(node.parent) : checker.getSymbolAtLocation(node) : undefined;
21550
- if (ts12.isIdentifier(node) && node !== declarationName && referenced === symbol) {
22119
+ const referenced = ts13.isIdentifier(node) ? ts13.isShorthandPropertyAssignment(node.parent) ? checker.getShorthandAssignmentValueSymbol(node.parent) : ts13.isExportSpecifier(node.parent) ? checker.getExportSpecifierLocalTargetSymbol(node.parent) : checker.getSymbolAtLocation(node) : undefined;
22120
+ if (ts13.isIdentifier(node) && node !== declarationName && referenced === symbol) {
21551
22121
  const use = node.parent;
21552
- if (!ts12.isCallExpression(use) || use.expression !== node || use.arguments.length !== 1 || use.questionDotToken || use.typeArguments?.length)
22122
+ if (!ts13.isCallExpression(use) || use.expression !== node || use.arguments.length !== 1 || use.questionDotToken || use.typeArguments?.length)
21553
22123
  return reject();
21554
22124
  const value = use.arguments[0];
21555
- if (!value || !ts12.isStringLiteral(value) && !ts12.isNoSubstitutionTemplateLiteral(value))
22125
+ if (!value || !ts13.isStringLiteral(value) && !ts13.isNoSubstitutionTemplateLiteral(value))
21556
22126
  return reject();
21557
22127
  references++;
21558
- replacements.set(use, ts12.factory.createCallExpression(call.expression, undefined, [value]));
22128
+ replacements.set(use, ts13.factory.createCallExpression(call.expression, undefined, [value]));
21559
22129
  }
21560
- ts12.forEachChild(node, visit);
22130
+ ts13.forEachChild(node, visit);
21561
22131
  };
21562
22132
  const statement = call.parent;
21563
22133
  const block = statement.parent;
21564
22134
  const declaration = block.parent;
21565
- if (call.expression.kind !== ts12.SyntaxKind.ImportKeyword || call.arguments.length !== 1 || !ts12.isReturnStatement(statement) || !ts12.isBlock(block) || block.statements.length !== 1 || !ts12.isFunctionDeclaration(declaration) || declaration.parent !== source || !declaration.name || declaration.modifiers?.length || declaration.asteriskToken || declaration.typeParameters?.length || declaration.parameters.length !== 1)
22135
+ if (call.expression.kind !== ts13.SyntaxKind.ImportKeyword || call.arguments.length !== 1 || !ts13.isReturnStatement(statement) || !ts13.isBlock(block) || block.statements.length !== 1 || !ts13.isFunctionDeclaration(declaration) || declaration.parent !== source || !declaration.name || declaration.modifiers?.length || declaration.asteriskToken || declaration.typeParameters?.length || declaration.parameters.length !== 1)
21566
22136
  return reject();
21567
22137
  const parameter = declaration.parameters[0];
21568
22138
  const argument = call.arguments[0];
21569
- if (!parameter || !ts12.isIdentifier(parameter.name) || parameter.initializer || parameter.dotDotDotToken || !argument || !ts12.isIdentifier(argument) || checker.getSymbolAtLocation(argument) !== checker.getSymbolAtLocation(parameter.name))
22139
+ if (!parameter || !ts13.isIdentifier(parameter.name) || parameter.initializer || parameter.dotDotDotToken || !argument || !ts13.isIdentifier(argument) || checker.getSymbolAtLocation(argument) !== checker.getSymbolAtLocation(parameter.name))
21570
22140
  return reject();
21571
22141
  const symbol = checker.getSymbolAtLocation(declaration.name);
21572
22142
  if (!symbol || symbol.declarations?.length !== 1)
@@ -21578,22 +22148,22 @@ function staticDeliveryImports(path, contents) {
21578
22148
  return reject();
21579
22149
  removed.add(declaration);
21580
22150
  }
21581
- const transformed = ts12.transform(source, [(context) => {
22151
+ const transformed = ts13.transform(source, [(context) => {
21582
22152
  const visit = (node) => {
21583
- if (ts12.isFunctionDeclaration(node) && removed.has(node))
22153
+ if (ts13.isFunctionDeclaration(node) && removed.has(node))
21584
22154
  return;
21585
- const replacement = ts12.isCallExpression(node) ? replacements.get(node) : undefined;
22155
+ const replacement = ts13.isCallExpression(node) ? replacements.get(node) : undefined;
21586
22156
  if (replacement)
21587
22157
  return replacement;
21588
- return ts12.visitEachChild(node, visit, context);
22158
+ return ts13.visitEachChild(node, visit, context);
21589
22159
  };
21590
- return (node) => ts12.visitNode(node, visit, ts12.isSourceFile) ?? node;
22160
+ return (node) => ts13.visitNode(node, visit, ts13.isSourceFile) ?? node;
21591
22161
  }]);
21592
22162
  try {
21593
22163
  const transformedSource = transformed.transformed[0];
21594
22164
  if (!transformedSource)
21595
22165
  return reject();
21596
- return new TextEncoder().encode(ts12.createPrinter().printFile(transformedSource));
22166
+ return new TextEncoder().encode(ts13.createPrinter().printFile(transformedSource));
21597
22167
  } finally {
21598
22168
  transformed.dispose();
21599
22169
  }
@@ -21741,16 +22311,16 @@ async function bundleDeliveryTargetInProcess(name, code, project, generatedDirec
21741
22311
  const bytes = new Uint8Array(await output.arrayBuffer());
21742
22312
  if (/\.[cm]?js$/.test(path)) {
21743
22313
  let check = function(node) {
21744
- const specifier = ts13.isImportDeclaration(node) || ts13.isExportDeclaration(node) ? node.moduleSpecifier : ts13.isCallExpression(node) && (node.expression.kind === ts13.SyntaxKind.ImportKeyword || ts13.isIdentifier(node.expression) && /^(?:__)?require$/.test(node.expression.text) || ts13.isPropertyAccessExpression(node.expression) && node.expression.name.text === "require" && ts13.isMetaProperty(node.expression.expression) && node.expression.expression.keywordToken === ts13.SyntaxKind.ImportKeyword) ? node.arguments[0] : undefined;
21745
- if (specifier && ts13.isStringLiteralLike(specifier)) {
22314
+ const specifier = ts14.isImportDeclaration(node) || ts14.isExportDeclaration(node) ? node.moduleSpecifier : ts14.isCallExpression(node) && (node.expression.kind === ts14.SyntaxKind.ImportKeyword || ts14.isIdentifier(node.expression) && /^(?:__)?require$/.test(node.expression.text) || ts14.isPropertyAccessExpression(node.expression) && node.expression.name.text === "require" && ts14.isMetaProperty(node.expression.expression) && node.expression.expression.keywordToken === ts14.SyntaxKind.ImportKeyword) ? node.arguments[0] : undefined;
22315
+ if (specifier && ts14.isStringLiteralLike(specifier)) {
21746
22316
  if (!isBuiltin(specifier.text) && specifier.text !== "bun" && !specifier.text.startsWith("bun:")) {
21747
22317
  throw new Error("Independent bundles cannot retain external package imports.");
21748
22318
  }
21749
22319
  runtimeImports.add(specifier.text);
21750
22320
  }
21751
- ts13.forEachChild(node, check);
22321
+ ts14.forEachChild(node, check);
21752
22322
  };
21753
- const source = ts13.createSourceFile(path, new TextDecoder().decode(bytes), ts13.ScriptTarget.Latest, true);
22323
+ const source = ts14.createSourceFile(path, new TextDecoder().decode(bytes), ts14.ScriptTarget.Latest, true);
21754
22324
  check(source);
21755
22325
  }
21756
22326
  files.set(`bundle/${path}`, bytes);
@@ -21769,16 +22339,16 @@ function renderDeliveryRuntimeIdentity() {
21769
22339
  return `
21770
22340
  function deliveryRuntimeIdentity(kind: "http" | "worker") {
21771
22341
  const env = deliveryProcess.env;
21772
- if (env.SUPACLOUD_ACTIVATION_ID === undefined) return null;
22342
+ if (env["SUPACLOUD_ACTIVATION_ID"] === undefined) return null;
21773
22343
  const identity = {
21774
22344
  schema: "supacloud.application-runtime.v1",
21775
- project_ref: env.SUPACLOUD_PROJECT_REF,
21776
- application_id: env.SUPACLOUD_APPLICATION_ID,
21777
- environment_id: env.SUPACLOUD_ENVIRONMENT_ID,
21778
- release_id: env.SUPACLOUD_RELEASE_ID,
21779
- activation_id: env.SUPACLOUD_ACTIVATION_ID,
21780
- target: env.SUPACLOUD_TARGET,
21781
- object_id: env.SUPACLOUD_OBJECT_ID,
22345
+ project_ref: env["SUPACLOUD_PROJECT_REF"],
22346
+ application_id: env["SUPACLOUD_APPLICATION_ID"],
22347
+ environment_id: env["SUPACLOUD_ENVIRONMENT_ID"],
22348
+ release_id: env["SUPACLOUD_RELEASE_ID"],
22349
+ activation_id: env["SUPACLOUD_ACTIVATION_ID"],
22350
+ target: env["SUPACLOUD_TARGET"],
22351
+ object_id: env["SUPACLOUD_OBJECT_ID"],
21782
22352
  kind, pid: deliveryProcess.pid,
21783
22353
  };
21784
22354
  const matches = (value: string | undefined, pattern: RegExp) => typeof value === "string" && pattern.test(value);
@@ -21811,8 +22381,8 @@ interface DeliveryHttpHost {
21811
22381
 
21812
22382
  async function startDeliveryHttp(signal: AbortSignal, shutdownTimeout: number, startDeadline: () => void) {
21813
22383
  const identity = deliveryRuntimeIdentity("http");
21814
- const port = Number(deliveryProcess.env.PORT ?? "3000");
21815
- const hostname = deliveryProcess.env.HOST ?? "127.0.0.1";
22384
+ const port = Number(deliveryProcess.env["PORT"] ?? "3000");
22385
+ const hostname = deliveryProcess.env["HOST"] ?? "127.0.0.1";
21816
22386
  if (!Number.isInteger(port) || port < 0 || port > 65535 || hostname.length === 0) {
21817
22387
  throw new Error("Invalid delivery HTTP listener configuration.");
21818
22388
  }
@@ -21880,7 +22450,7 @@ async function startDeliveryHttp(signal: AbortSignal, shutdownTimeout: number, s
21880
22450
 
21881
22451
  {
21882
22452
  const lifecycle = new AbortController();
21883
- const shutdownTimeout = Number(deliveryProcess.env.SHUTDOWN_TIMEOUT_MS ?? "10000");
22453
+ const shutdownTimeout = Number(deliveryProcess.env["SHUTDOWN_TIMEOUT_MS"] ?? "10000");
21884
22454
  let running: Awaited<ReturnType<typeof startDeliveryHttp>>;
21885
22455
  let deadline: ReturnType<typeof setTimeout> | undefined;
21886
22456
  const finish = (failed: boolean) => {
@@ -21948,7 +22518,7 @@ interface DeliveryWorkerHost {
21948
22518
 
21949
22519
  {
21950
22520
  const lifecycle = new AbortController();
21951
- const shutdownTimeout = Number(deliveryProcess.env.SHUTDOWN_TIMEOUT_MS ?? "10000");
22521
+ const shutdownTimeout = Number(deliveryProcess.env["SHUTDOWN_TIMEOUT_MS"] ?? "10000");
21952
22522
  let host: DeliveryWorkerHost | undefined;
21953
22523
  let running = false;
21954
22524
  let runtimeFailed = false;
@@ -22016,7 +22586,7 @@ interface DeliveryWorkerHost {
22016
22586
  const candidate = await createHost(createCompiledModules(), { signal: lifecycle.signal });
22017
22587
  if (!candidate || typeof candidate.close !== "function") throw new Error("Invalid delivery worker host.");
22018
22588
  host = candidate;
22019
- const execution = deliveryProcess.env.SUPACLOUD_WORKER_EXECUTION;
22589
+ const execution = deliveryProcess.env["SUPACLOUD_WORKER_EXECUTION"];
22020
22590
  if (execution) {
22021
22591
  const expected: unknown = JSON.parse(Buffer.from(execution, "base64").toString("utf8"));
22022
22592
  if (!deliveryPolicyEqual(host.execution, expected) || typeof host.health !== "function" || !host.failure) {
@@ -22120,7 +22690,7 @@ async function buildDeliveryProject(options, delivery) {
22120
22690
  const settings = parseDeliveryOptions(delivery);
22121
22691
  if (typeof Bun === "undefined")
22122
22692
  throw new Error("Independent delivery builds require Bun.");
22123
- const configPath = ts14.findConfigFile(resolve12(options.rootDir), ts14.sys.fileExists);
22693
+ const configPath = ts15.findConfigFile(resolve12(options.rootDir), ts15.sys.fileExists);
22124
22694
  if (!configPath)
22125
22695
  throw new Error("Independent delivery builds require a project tsconfig.json.");
22126
22696
  const lexicalProject = dirname7(configPath);
@@ -22136,8 +22706,8 @@ async function buildDeliveryProject(options, delivery) {
22136
22706
  if (inside(generatedRoot, sourceRoot))
22137
22707
  throw new Error("Output must not contain the application source root.");
22138
22708
  const configInputs = new Map;
22139
- const parsedConfig = ts14.getParsedCommandLineOfConfigFile(await realpath3(configPath), {}, {
22140
- ...ts14.sys,
22709
+ const parsedConfig = ts15.getParsedCommandLineOfConfigFile(await realpath3(configPath), {}, {
22710
+ ...ts15.sys,
22141
22711
  readFile(path) {
22142
22712
  const contents = readFileSync3(path, "utf8");
22143
22713
  configInputs.set(resolve12(path), digest(contents));
@@ -22257,7 +22827,7 @@ async function buildDeliveryProject(options, delivery) {
22257
22827
  for (const [name, contents] of Object.entries(generated))
22258
22828
  await writeArtifact(stage, `generated/${name}`, contents);
22259
22829
  {
22260
- const program = ts14.createProgram({
22830
+ const program = ts15.createProgram({
22261
22831
  rootNames: [
22262
22832
  ...parsedConfig.fileNames.filter((path) => !inside(generatedRoot, path)),
22263
22833
  ...Object.keys(generated).map((name) => join9(stage, "generated", name))
@@ -22265,12 +22835,12 @@ async function buildDeliveryProject(options, delivery) {
22265
22835
  options: { ...parsedConfig.options, rootDir: project },
22266
22836
  ...parsedConfig.projectReferences ? { projectReferences: parsedConfig.projectReferences } : {}
22267
22837
  });
22268
- const diagnostics = ts14.getPreEmitDiagnostics(program);
22269
- if (diagnostics.some((item) => item.category === ts14.DiagnosticCategory.Error)) {
22270
- return failed(diagnostics.filter((item) => item.category === ts14.DiagnosticCategory.Error).map((item) => ({
22838
+ const diagnostics = ts15.getPreEmitDiagnostics(program);
22839
+ if (diagnostics.some((item) => item.category === ts15.DiagnosticCategory.Error)) {
22840
+ return failed(diagnostics.filter((item) => item.category === ts15.DiagnosticCategory.Error).map((item) => ({
22271
22841
  severity: "error",
22272
22842
  code: "delivery-generated-type-error",
22273
- message: ts14.flattenDiagnosticMessageText(item.messageText, `
22843
+ message: ts15.flattenDiagnosticMessageText(item.messageText, `
22274
22844
  `),
22275
22845
  ...item.file ? { file: item.file.fileName } : {}
22276
22846
  })));
@@ -22665,19 +23235,7 @@ function createIncrementalCompiler() {
22665
23235
  const snapshot = !options.graphql && changedPaths && previousSnapshot && previousSnapshot.optionsKey === optionsKey ? await updateSnapshot(previousSnapshot, options, changedPaths) : await createSnapshot(options);
22666
23236
  const changedFiles = changedPaths && previousSnapshot ? diffFiles(previousSnapshot.files, snapshot.files) : diffFiles(previousSnapshot?.files, snapshot.files);
22667
23237
  const activeCache = options.cache ?? cache;
22668
- const cacheHit = Boolean(previousSnapshot && previousSnapshot.optionsKey === snapshot.optionsKey && previousCache === activeCache && changedFiles.length === 0) && !(options.typeSafety?.scanProductionSource ?? options.strict ?? false);
22669
- if (cacheHit && previousResult) {
22670
- return {
22671
- ...previousResult,
22672
- stats: {
22673
- cacheHit: true,
22674
- changedFiles: [],
22675
- affectedModules: [],
22676
- reusedModules: previousResult.graph.modules.map((m) => m.name),
22677
- reanalyzedModules: []
22678
- }
22679
- };
22680
- }
23238
+ const cacheHit = Boolean(previousSnapshot && previousSnapshot.optionsKey === snapshot.optionsKey && previousCache === activeCache && changedFiles.length === 0);
22681
23239
  if (!activeCache.dependencyGraph && previousResult) {
22682
23240
  activeCache.dependencyGraph = new ModuleDependencyGraph(previousResult.graph.modules);
22683
23241
  }
@@ -22693,7 +23251,7 @@ function createIncrementalCompiler() {
22693
23251
  activeCache.dependencyGraph = new ModuleDependencyGraph(result.graph.modules);
22694
23252
  }
22695
23253
  const stats = {
22696
- cacheHit: false,
23254
+ cacheHit: cacheHit && !result.diagnostics.some(({ severity }) => severity === "error"),
22697
23255
  changedFiles,
22698
23256
  affectedModules,
22699
23257
  reusedModules,
@@ -23091,7 +23649,7 @@ function watchProject(options) {
23091
23649
  // src/migrations.ts
23092
23650
  import { rename as rename5, readFile as readFile9, writeFile as writeFile4, rm as rm3 } from "node:fs/promises";
23093
23651
  import { relative as relative11, resolve as resolve17 } from "node:path";
23094
- import * as ts16 from "@typescript/typescript6";
23652
+ import * as ts17 from "@typescript/typescript6";
23095
23653
 
23096
23654
  // src/migration-policy.ts
23097
23655
  import { readFile as readFile8 } from "node:fs/promises";
@@ -23099,10 +23657,10 @@ import { readFileSync as readFileSync4 } from "node:fs";
23099
23657
  import { resolve as resolve16 } from "node:path";
23100
23658
 
23101
23659
  // src/migration-app-version.ts
23102
- var MIGRATION_APP_VERSION = "0.24.1";
23660
+ var MIGRATION_APP_VERSION = "0.25.0";
23103
23661
 
23104
23662
  // src/migration-elysia-version.ts
23105
- var MIGRATION_ELYSIA_VERSION = "0.29.0";
23663
+ var MIGRATION_ELYSIA_VERSION = "0.29.1";
23106
23664
 
23107
23665
  // src/migration-policy.ts
23108
23666
  var cachedCompilerVersion;
@@ -23143,29 +23701,29 @@ async function checkMigrationDependencies(rootDir) {
23143
23701
  // src/migrations.ts
23144
23702
  var ROUTE_DECORATORS2 = new Set(["Get", "Post", "Put", "Patch", "Delete", "Head", "Options"]);
23145
23703
  var MIGRATION_COMPILER_OPTIONS = {
23146
- target: ts16.ScriptTarget.ES2022,
23147
- module: ts16.ModuleKind.ESNext,
23148
- moduleResolution: ts16.ModuleResolutionKind.Bundler,
23704
+ target: ts17.ScriptTarget.ES2022,
23705
+ module: ts17.ModuleKind.ESNext,
23706
+ moduleResolution: ts17.ModuleResolutionKind.Bundler,
23149
23707
  noEmit: true,
23150
23708
  skipLibCheck: true
23151
23709
  };
23152
23710
  function migrationCompilerOptions(rootDir) {
23153
23711
  if (!rootDir)
23154
23712
  return MIGRATION_COMPILER_OPTIONS;
23155
- const configPath = ts16.findConfigFile(rootDir, ts16.sys.fileExists);
23713
+ const configPath = ts17.findConfigFile(rootDir, ts17.sys.fileExists);
23156
23714
  if (!configPath)
23157
23715
  return MIGRATION_COMPILER_OPTIONS;
23158
23716
  const configHost = {
23159
- ...ts16.sys,
23717
+ ...ts17.sys,
23160
23718
  onUnRecoverableConfigFileDiagnostic: (_diagnostic) => {}
23161
23719
  };
23162
- const parsed = ts16.getParsedCommandLineOfConfigFile(configPath, {}, configHost);
23720
+ const parsed = ts17.getParsedCommandLineOfConfigFile(configPath, {}, configHost);
23163
23721
  if (!parsed || parsed.errors.length > 0)
23164
23722
  return MIGRATION_COMPILER_OPTIONS;
23165
23723
  return { ...parsed.options, noEmit: true, skipLibCheck: true };
23166
23724
  }
23167
23725
  function propertyName2(property) {
23168
- if (ts16.isIdentifier(property) || ts16.isStringLiteral(property) || ts16.isNumericLiteral(property))
23726
+ if (ts17.isIdentifier(property) || ts17.isStringLiteral(property) || ts17.isNumericLiteral(property))
23169
23727
  return property.text;
23170
23728
  return;
23171
23729
  }
@@ -23175,7 +23733,7 @@ function lineOf2(sourceFile, node) {
23175
23733
  function resolveSymbol(symbol, checker) {
23176
23734
  if (!symbol)
23177
23735
  return;
23178
- for (let guard = 0;guard < 4 && (symbol.flags & ts16.SymbolFlags.Alias) !== 0; guard += 1) {
23736
+ for (let guard = 0;guard < 4 && (symbol.flags & ts17.SymbolFlags.Alias) !== 0; guard += 1) {
23179
23737
  const aliased = checker.getAliasedSymbol(symbol);
23180
23738
  if (aliased === symbol)
23181
23739
  break;
@@ -23184,12 +23742,12 @@ function resolveSymbol(symbol, checker) {
23184
23742
  return symbol;
23185
23743
  }
23186
23744
  function symbolForExpression(expression, checker) {
23187
- const location = ts16.isIdentifier(expression) ? expression : ts16.isPropertyAccessExpression(expression) ? expression.name : ts16.isElementAccessExpression(expression) && expression.argumentExpression && ts16.isStringLiteral(expression.argumentExpression) ? expression : undefined;
23745
+ const location = ts17.isIdentifier(expression) ? expression : ts17.isPropertyAccessExpression(expression) ? expression.name : ts17.isElementAccessExpression(expression) && expression.argumentExpression && ts17.isStringLiteral(expression.argumentExpression) ? expression : undefined;
23188
23746
  return location ? resolveSymbol(checker.getSymbolAtLocation(location), checker) : undefined;
23189
23747
  }
23190
23748
  function unwrapExpression(expression) {
23191
23749
  let current = expression;
23192
- while (ts16.isAsExpression(current) || ts16.isSatisfiesExpression(current) || ts16.isParenthesizedExpression(current) || ts16.isTypeAssertionExpression(current)) {
23750
+ while (ts17.isAsExpression(current) || ts17.isSatisfiesExpression(current) || ts17.isParenthesizedExpression(current) || ts17.isTypeAssertionExpression(current)) {
23193
23751
  current = current.expression;
23194
23752
  }
23195
23753
  return current;
@@ -23204,7 +23762,7 @@ function isRouteDecoratorCall(node, checker) {
23204
23762
  if (node.arguments.length < 2)
23205
23763
  return false;
23206
23764
  const name = node.expression.getText(node.getSourceFile());
23207
- if (ts16.isIdentifier(node.expression) && ROUTE_DECORATORS2.has(node.expression.text))
23765
+ if (ts17.isIdentifier(node.expression) && ROUTE_DECORATORS2.has(node.expression.text))
23208
23766
  return true;
23209
23767
  if (ROUTE_DECORATORS2.has(name))
23210
23768
  return true;
@@ -23218,14 +23776,14 @@ function resolveStaticObjectLiteral2(input, checker, seen = new Set) {
23218
23776
  if (seen.has(expression))
23219
23777
  return;
23220
23778
  seen.add(expression);
23221
- if (ts16.isObjectLiteralExpression(expression))
23779
+ if (ts17.isObjectLiteralExpression(expression))
23222
23780
  return expression;
23223
- if (ts16.isCallExpression(expression) && isDefineRouteContractCall(expression, checker)) {
23781
+ if (ts17.isCallExpression(expression) && isDefineRouteContractCall(expression, checker)) {
23224
23782
  return resolveStaticObjectLiteral2(expression.arguments[0], checker, seen);
23225
23783
  }
23226
23784
  const symbol = symbolForExpression(expression, checker);
23227
23785
  for (const declaration of symbol?.declarations ?? []) {
23228
- if (ts16.isVariableDeclaration(declaration) && declaration.initializer) {
23786
+ if (ts17.isVariableDeclaration(declaration) && declaration.initializer) {
23229
23787
  const resolved = resolveStaticObjectLiteral2(declaration.initializer, checker, seen);
23230
23788
  if (resolved)
23231
23789
  return resolved;
@@ -23239,7 +23797,7 @@ function displayFile(rootDir, fileName) {
23239
23797
  }
23240
23798
  function createMigrationProgram(fileNames, sourceOverrides, rootDir) {
23241
23799
  const compilerOptions = migrationCompilerOptions(rootDir);
23242
- const host = ts16.createCompilerHost(compilerOptions);
23800
+ const host = ts17.createCompilerHost(compilerOptions);
23243
23801
  const getSourceFile = host.getSourceFile.bind(host);
23244
23802
  const fileExists = host.fileExists.bind(host);
23245
23803
  const readFile = host.readFile.bind(host);
@@ -23248,16 +23806,16 @@ function createMigrationProgram(fileNames, sourceOverrides, rootDir) {
23248
23806
  host.readFile = (fileName) => sourceOverrides.get(resolve17(fileName)) ?? readFile(fileName);
23249
23807
  host.getSourceFile = (fileName, languageVersion, onError, shouldCreateNewSourceFile) => {
23250
23808
  const source = sourceOverrides.get(resolve17(fileName));
23251
- return source === undefined ? getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) : ts16.createSourceFile(fileName, source, languageVersion, true);
23809
+ return source === undefined ? getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) : ts17.createSourceFile(fileName, source, languageVersion, true);
23252
23810
  };
23253
23811
  host.getCurrentDirectory = () => rootDir ?? currentDirectory();
23254
- return ts16.createProgram(fileNames, compilerOptions, host);
23812
+ return ts17.createProgram(fileNames, compilerOptions, host);
23255
23813
  }
23256
23814
  function routeResponseProperties(object) {
23257
- const responseProperties = object.properties.filter((property) => ts16.isPropertyAssignment(property) && propertyName2(property.name) === "response");
23815
+ const responseProperties = object.properties.filter((property) => ts17.isPropertyAssignment(property) && propertyName2(property.name) === "response");
23258
23816
  return {
23259
23817
  response: responseProperties[0],
23260
- hasResponses: object.properties.some((property) => (ts16.isPropertyAssignment(property) || ts16.isShorthandPropertyAssignment(property)) && propertyName2(property.name) === "responses"),
23818
+ hasResponses: object.properties.some((property) => (ts17.isPropertyAssignment(property) || ts17.isShorthandPropertyAssignment(property)) && propertyName2(property.name) === "responses"),
23261
23819
  duplicateResponse: responseProperties.length > 1
23262
23820
  };
23263
23821
  }
@@ -23277,7 +23835,7 @@ function planRouteResponseMigration(sourceFiles, checker, rootDir, includedFiles
23277
23835
  if (!includedFiles.has(sourcePath))
23278
23836
  continue;
23279
23837
  const visit = (node) => {
23280
- if (ts16.isCallExpression(node) && isRouteDecoratorCall(node, checker)) {
23838
+ if (ts17.isCallExpression(node) && isRouteDecoratorCall(node, checker)) {
23281
23839
  const options = node.arguments[1];
23282
23840
  const object = options && resolveStaticObjectLiteral2(options, checker);
23283
23841
  if (object) {
@@ -23297,7 +23855,7 @@ function planRouteResponseMigration(sourceFiles, checker, rootDir, includedFiles
23297
23855
  }
23298
23856
  }
23299
23857
  }
23300
- ts16.forEachChild(node, visit);
23858
+ ts17.forEachChild(node, visit);
23301
23859
  };
23302
23860
  visit(sourceFile);
23303
23861
  }
@@ -23464,7 +24022,7 @@ async function migrateProject(options) {
23464
24022
  }
23465
24023
  }
23466
24024
  const include = options.include ?? ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"];
23467
- const files = ts16.sys.readDirectory(rootDir, [".ts", ".tsx", ".mts", ".cts"], ["node_modules", "dist", "generated"], include).sort();
24025
+ const files = ts17.sys.readDirectory(rootDir, [".ts", ".tsx", ".mts", ".cts"], ["node_modules", "dist", "generated"], include).sort();
23468
24026
  const results = [];
23469
24027
  const issues = [];
23470
24028
  const pendingWrites = new Map;
@@ -23607,30 +24165,30 @@ function resolveSchema(value, document, seen = new Set) {
23607
24165
  const schema = recordValue(value);
23608
24166
  if (!schema)
23609
24167
  return;
23610
- const ref = stringValue(schema.$ref);
24168
+ const ref = stringValue(schema["$ref"]);
23611
24169
  if (!ref || !ref.startsWith("#/components/schemas/"))
23612
24170
  return schema;
23613
24171
  if (seen.has(ref))
23614
24172
  return schema;
23615
24173
  const name = decodeJsonPointerPart(ref.slice("#/components/schemas/".length));
23616
- const components = recordValue(document.components);
23617
- const schemas = recordValue(components?.schemas);
24174
+ const components = recordValue(document["components"]);
24175
+ const schemas = recordValue(components?.["schemas"]);
23618
24176
  const target = schemas?.[name];
23619
24177
  if (target === undefined)
23620
24178
  return schema;
23621
24179
  return resolveSchema(target, document, new Set([...seen, ref]));
23622
24180
  }
23623
24181
  function schemaEnum(value) {
23624
- return Array.isArray(value?.enum) ? value.enum : undefined;
24182
+ return Array.isArray(value?.["enum"]) ? value["enum"] : undefined;
23625
24183
  }
23626
24184
  function schemaProperties(value) {
23627
- return recordValue(value?.properties);
24185
+ return recordValue(value?.["properties"]);
23628
24186
  }
23629
24187
  function schemaRequired(value) {
23630
- return new Set(arrayValue(value?.required).filter((item) => typeof item === "string"));
24188
+ return new Set(arrayValue(value?.["required"]).filter((item) => typeof item === "string"));
23631
24189
  }
23632
24190
  function schemaType(value) {
23633
- return value?.type;
24191
+ return value?.["type"];
23634
24192
  }
23635
24193
  function addChange(changes, change) {
23636
24194
  if (changes.some((item) => item.kind === change.kind && item.code === change.code && item.path === change.path && item.message === change.message))
@@ -23674,7 +24232,7 @@ function compareSchema(baseValue, currentValue, baseDocument, currentDocument, p
23674
24232
  if (baseProperties && currentProperties) {
23675
24233
  for (const name of sortedKeys2(baseProperties)) {
23676
24234
  if (currentProperties[name] === undefined) {
23677
- const inputRemovalIsBreaking = baseSchema.additionalProperties === false;
24235
+ const inputRemovalIsBreaking = baseSchema["additionalProperties"] === false;
23678
24236
  if (direction === "output" || inputRemovalIsBreaking) {
23679
24237
  addChange(changes, {
23680
24238
  kind: "breaking",
@@ -23701,7 +24259,7 @@ function compareSchema(baseValue, currentValue, baseDocument, currentDocument, p
23701
24259
  });
23702
24260
  }
23703
24261
  }
23704
- if (baseSchema.additionalProperties !== false && currentSchema.additionalProperties === false) {
24262
+ if (baseSchema["additionalProperties"] !== false && currentSchema["additionalProperties"] === false) {
23705
24263
  addChange(changes, {
23706
24264
  kind: "breaking",
23707
24265
  code: "request-additional-properties-rejected",
@@ -23724,13 +24282,13 @@ function compareSchema(baseValue, currentValue, baseDocument, currentDocument, p
23724
24282
  }
23725
24283
  function parameterKey(value) {
23726
24284
  const parameter = recordValue(value);
23727
- const name = stringValue(parameter?.name);
23728
- const location = stringValue(parameter?.in);
24285
+ const name = stringValue(parameter?.["name"]);
24286
+ const location = stringValue(parameter?.["in"]);
23729
24287
  return name && location ? `${location}:${name}` : undefined;
23730
24288
  }
23731
24289
  function operationParameters(pathItem, operation) {
23732
24290
  const result = new Map;
23733
- for (const source of [pathItem.parameters, operation.parameters]) {
24291
+ for (const source of [pathItem["parameters"], operation["parameters"]]) {
23734
24292
  for (const item of arrayValue(source)) {
23735
24293
  const parameter = recordValue(item);
23736
24294
  const key = parameterKey(parameter);
@@ -23741,7 +24299,7 @@ function operationParameters(pathItem, operation) {
23741
24299
  return result;
23742
24300
  }
23743
24301
  function parameterSchema(value) {
23744
- return value.schema;
24302
+ return value["schema"];
23745
24303
  }
23746
24304
  function compareParameters(basePathItem, currentPathItem, baseOperation, currentOperation, baseDocument, currentDocument, path, changes) {
23747
24305
  const baseParameters = operationParameters(basePathItem, baseOperation);
@@ -23758,7 +24316,7 @@ function compareParameters(basePathItem, currentPathItem, baseOperation, current
23758
24316
  });
23759
24317
  continue;
23760
24318
  }
23761
- if (currentParameter.required === true && baseParameter.required !== true) {
24319
+ if (currentParameter["required"] === true && baseParameter["required"] !== true) {
23762
24320
  addChange(changes, {
23763
24321
  kind: "breaking",
23764
24322
  code: "parameter-required",
@@ -23777,16 +24335,16 @@ function compareParameters(basePathItem, currentPathItem, baseOperation, current
23777
24335
  if (!parameter)
23778
24336
  continue;
23779
24337
  addChange(changes, {
23780
- kind: parameter.required === true ? "breaking" : "non-breaking",
23781
- code: parameter.required === true ? "parameter-required" : "parameter-added",
24338
+ kind: parameter["required"] === true ? "breaking" : "non-breaking",
24339
+ code: parameter["required"] === true ? "parameter-required" : "parameter-added",
23782
24340
  path: `${path}.parameters.${key}`,
23783
- message: parameter.required === true ? "A new required parameter was added." : "An optional parameter was added."
24341
+ message: parameter["required"] === true ? "A new required parameter was added." : "An optional parameter was added."
23784
24342
  });
23785
24343
  }
23786
24344
  }
23787
24345
  function compareRequestBody(baseOperation, currentOperation, baseDocument, currentDocument, path, changes) {
23788
- const baseBody = recordValue(baseOperation.requestBody);
23789
- const currentBody = recordValue(currentOperation.requestBody);
24346
+ const baseBody = recordValue(baseOperation["requestBody"]);
24347
+ const currentBody = recordValue(currentOperation["requestBody"]);
23790
24348
  if (!baseBody || !currentBody) {
23791
24349
  if (baseBody && !currentBody) {
23792
24350
  addChange(changes, {
@@ -23795,7 +24353,7 @@ function compareRequestBody(baseOperation, currentOperation, baseDocument, curre
23795
24353
  path: `${path}.requestBody`,
23796
24354
  message: "A request body from the previous contract was removed."
23797
24355
  });
23798
- } else if (!baseBody && currentBody?.required === true) {
24356
+ } else if (!baseBody && currentBody?.["required"] === true) {
23799
24357
  addChange(changes, {
23800
24358
  kind: "breaking",
23801
24359
  code: "request-body-required",
@@ -23812,7 +24370,7 @@ function compareRequestBody(baseOperation, currentOperation, baseDocument, curre
23812
24370
  }
23813
24371
  return;
23814
24372
  }
23815
- if (currentBody.required === true && baseBody.required !== true) {
24373
+ if (currentBody["required"] === true && baseBody["required"] !== true) {
23816
24374
  addChange(changes, {
23817
24375
  kind: "breaking",
23818
24376
  code: "request-body-required",
@@ -23820,8 +24378,8 @@ function compareRequestBody(baseOperation, currentOperation, baseDocument, curre
23820
24378
  message: "An optional request body became required."
23821
24379
  });
23822
24380
  }
23823
- const baseContent = recordValue(baseBody.content);
23824
- const currentContent = recordValue(currentBody.content);
24381
+ const baseContent = recordValue(baseBody["content"]);
24382
+ const currentContent = recordValue(currentBody["content"]);
23825
24383
  for (const mediaType of sortedKeys2(baseContent)) {
23826
24384
  const baseMedia = recordValue(baseContent?.[mediaType]);
23827
24385
  const currentMedia = recordValue(currentContent?.[mediaType]);
@@ -23834,14 +24392,14 @@ function compareRequestBody(baseOperation, currentOperation, baseDocument, curre
23834
24392
  });
23835
24393
  continue;
23836
24394
  }
23837
- if (baseMedia.schema !== undefined && currentMedia.schema !== undefined) {
23838
- compareSchema(baseMedia.schema, currentMedia.schema, baseDocument, currentDocument, `${path}.requestBody.content.${mediaType}.schema`, "input", changes);
24395
+ if (baseMedia["schema"] !== undefined && currentMedia["schema"] !== undefined) {
24396
+ compareSchema(baseMedia["schema"], currentMedia["schema"], baseDocument, currentDocument, `${path}.requestBody.content.${mediaType}.schema`, "input", changes);
23839
24397
  }
23840
24398
  }
23841
24399
  }
23842
24400
  function compareResponses(baseOperation, currentOperation, baseDocument, currentDocument, path, changes) {
23843
- const baseResponses = recordValue(baseOperation.responses);
23844
- const currentResponses = recordValue(currentOperation.responses);
24401
+ const baseResponses = recordValue(baseOperation["responses"]);
24402
+ const currentResponses = recordValue(currentOperation["responses"]);
23845
24403
  for (const status of sortedKeys2(baseResponses)) {
23846
24404
  const baseResponse = recordValue(baseResponses?.[status]);
23847
24405
  const currentResponse = recordValue(currentResponses?.[status]);
@@ -23854,8 +24412,8 @@ function compareResponses(baseOperation, currentOperation, baseDocument, current
23854
24412
  });
23855
24413
  continue;
23856
24414
  }
23857
- const baseContent = recordValue(baseResponse.content);
23858
- const currentContent = recordValue(currentResponse.content);
24415
+ const baseContent = recordValue(baseResponse["content"]);
24416
+ const currentContent = recordValue(currentResponse["content"]);
23859
24417
  for (const mediaType of sortedKeys2(baseContent)) {
23860
24418
  const baseMedia = recordValue(baseContent?.[mediaType]);
23861
24419
  const currentMedia = recordValue(currentContent?.[mediaType]);
@@ -23868,8 +24426,8 @@ function compareResponses(baseOperation, currentOperation, baseDocument, current
23868
24426
  });
23869
24427
  continue;
23870
24428
  }
23871
- if (baseMedia.schema !== undefined && currentMedia.schema !== undefined) {
23872
- compareSchema(baseMedia.schema, currentMedia.schema, baseDocument, currentDocument, `${path}.responses.${status}.content.${mediaType}.schema`, "output", changes);
24429
+ if (baseMedia["schema"] !== undefined && currentMedia["schema"] !== undefined) {
24430
+ compareSchema(baseMedia["schema"], currentMedia["schema"], baseDocument, currentDocument, `${path}.responses.${status}.content.${mediaType}.schema`, "output", changes);
23873
24431
  }
23874
24432
  }
23875
24433
  }
@@ -23888,8 +24446,8 @@ function compareOperation(basePathItem, currentPathItem, baseOperation, currentO
23888
24446
  compareParameters(basePathItem, currentPathItem, baseOperation, currentOperation, baseDocument, currentDocument, path, changes);
23889
24447
  compareRequestBody(baseOperation, currentOperation, baseDocument, currentDocument, path, changes);
23890
24448
  compareResponses(baseOperation, currentOperation, baseDocument, currentDocument, path, changes);
23891
- const baseSecurity = baseOperation.security;
23892
- const currentSecurity = currentOperation.security;
24449
+ const baseSecurity = baseOperation["security"];
24450
+ const currentSecurity = currentOperation["security"];
23893
24451
  if (Array.isArray(currentSecurity) && currentSecurity.length > 0 && (!Array.isArray(baseSecurity) || baseSecurity.length === 0)) {
23894
24452
  addChange(changes, {
23895
24453
  kind: "breaking",
@@ -23900,8 +24458,8 @@ function compareOperation(basePathItem, currentPathItem, baseOperation, currentO
23900
24458
  }
23901
24459
  }
23902
24460
  function compareComponents(baseDocument, currentDocument, changes) {
23903
- const baseComponents = recordValue(baseDocument.components);
23904
- const currentComponents = recordValue(currentDocument.components);
24461
+ const baseComponents = recordValue(baseDocument["components"]);
24462
+ const currentComponents = recordValue(currentDocument["components"]);
23905
24463
  for (const group of COMPONENT_GROUPS) {
23906
24464
  const baseGroup = recordValue(baseComponents?.[group]);
23907
24465
  const currentGroup = recordValue(currentComponents?.[group]);
@@ -23928,10 +24486,10 @@ function compareComponents(baseDocument, currentDocument, changes) {
23928
24486
  }
23929
24487
  }
23930
24488
  function parseOpenApiDocument(value) {
23931
- if (!isRecord(value) || typeof value.openapi !== "string" || !/^3\.[0-9]+(?:\.[0-9]+)?$/.test(value.openapi) || !isRecord(value.info) || !isRecord(value.paths)) {
24489
+ if (!isRecord(value) || typeof value["openapi"] !== "string" || !/^3\.[0-9]+(?:\.[0-9]+)?$/.test(value["openapi"]) || !isRecord(value["info"]) || !isRecord(value["paths"])) {
23932
24490
  throw new OpenApiDocumentError;
23933
24491
  }
23934
- return { ...value, openapi: value.openapi, info: value.info, paths: value.paths };
24492
+ return { ...value, openapi: value["openapi"], info: value["info"], paths: value["paths"] };
23935
24493
  }
23936
24494
  function serializeOpenApiJson(document, space = 2) {
23937
24495
  const parsed = parseOpenApiDocument(document);
@@ -23980,7 +24538,7 @@ async function loadGeneratedOpenApiDocument(modulePath) {
23980
24538
  const loaded = await import(moduleUrl.href);
23981
24539
  if (!isRecord(loaded))
23982
24540
  throw new OpenApiDocumentError;
23983
- return parseOpenApiDocument(loaded.OPENAPI_DOCUMENT);
24541
+ return parseOpenApiDocument(loaded["OPENAPI_DOCUMENT"]);
23984
24542
  } catch (error) {
23985
24543
  if (error instanceof OpenApiDocumentError)
23986
24544
  throw error;
@@ -24071,7 +24629,7 @@ function isRecord2(value) {
24071
24629
  function arrayLength(value) {
24072
24630
  return Array.isArray(value) ? value.length : undefined;
24073
24631
  }
24074
- async function sha2562(path) {
24632
+ async function sha2563(path) {
24075
24633
  return createHash11("sha256").update(await readFile11(path)).digest("hex");
24076
24634
  }
24077
24635
  function overallStatus(findings) {
@@ -24140,16 +24698,19 @@ async function assessMigration(options) {
24140
24698
  };
24141
24699
  try {
24142
24700
  const parsed = JSON.parse(await readFile11(contractsManifestPath, "utf8"));
24143
- if (!isRecord2(parsed) || parsed.version !== 1)
24701
+ if (!isRecord2(parsed) || parsed["version"] !== 1)
24144
24702
  throw new Error("invalid manifest");
24703
+ const commands = arrayLength(parsed["commands"]);
24704
+ const routes = arrayLength(parsed["routes"]);
24705
+ const permissions = arrayLength(parsed["permissions"]);
24145
24706
  contractsManifest = {
24146
24707
  path: contractsManifestPath,
24147
24708
  present: true,
24148
- sha256: await sha2562(contractsManifestPath),
24709
+ sha256: await sha2563(contractsManifestPath),
24149
24710
  version: 1,
24150
- ...arrayLength(parsed.commands) === undefined ? {} : { commands: arrayLength(parsed.commands) },
24151
- ...arrayLength(parsed.routes) === undefined ? {} : { routes: arrayLength(parsed.routes) },
24152
- ...arrayLength(parsed.permissions) === undefined ? {} : { permissions: arrayLength(parsed.permissions) }
24711
+ ...commands === undefined ? {} : { commands },
24712
+ ...routes === undefined ? {} : { routes },
24713
+ ...permissions === undefined ? {} : { permissions }
24153
24714
  };
24154
24715
  } catch {
24155
24716
  findings.push({
@@ -24168,9 +24729,9 @@ async function assessMigration(options) {
24168
24729
  const diff = diffOpenApiDocuments(await readOpenApiJson(baselinePath), await readOpenApiJson(currentPath));
24169
24730
  openApi = {
24170
24731
  baselinePath,
24171
- baselineSha256: await sha2562(baselinePath),
24732
+ baselineSha256: await sha2563(baselinePath),
24172
24733
  currentPath,
24173
- currentSha256: await sha2562(currentPath),
24734
+ currentSha256: await sha2563(currentPath),
24174
24735
  diff
24175
24736
  };
24176
24737
  if (!diff.ok) {
@@ -24402,10 +24963,10 @@ function resolveSupacloudConfig(config = {}, cwd = process.cwd()) {
24402
24963
  ...resolved.detectOrphanModules === undefined ? {} : { detectOrphanModules: resolved.detectOrphanModules },
24403
24964
  effect: resolved.effect === undefined ? { ...DEFAULT_SUPACLOUD_CONFIG.effect } : { ...DEFAULT_SUPACLOUD_CONFIG.effect, ...resolved.effect },
24404
24965
  treeShakeUnusedProviders: resolved.treeShakeUnusedProviders ?? DEFAULT_SUPACLOUD_CONFIG.treeShakeUnusedProviders,
24405
- graphql: resolved.graphql ? {
24966
+ ...resolved.graphql === undefined || resolved.graphql === false ? {} : { graphql: {
24406
24967
  ...resolved.graphql,
24407
24968
  schema: resolve20(cwd, resolved.graphql.schema)
24408
- } : undefined
24969
+ } }
24409
24970
  };
24410
24971
  }
24411
24972
  async function loadSupacloudConfig(cwd = process.cwd()) {
@@ -24567,15 +25128,20 @@ function checkGraphqlCompatibility(schema, documents, policy = {}) {
24567
25128
  try {
24568
25129
  parsed = parse6(document.source);
24569
25130
  } catch (error) {
24570
- diagnostics.push({ severity: "error", code: "graphql-document-invalid", message: error instanceof Error ? error.message : String(error), file: document.path });
25131
+ diagnostics.push({
25132
+ severity: "error",
25133
+ code: "graphql-document-invalid",
25134
+ message: error instanceof Error ? error.message : String(error),
25135
+ ...document.path === undefined ? {} : { file: document.path }
25136
+ });
24571
25137
  continue;
24572
25138
  }
24573
25139
  diagnostics.push(...validate2(schema, parsed).map((error) => ({
24574
25140
  severity: "error",
24575
25141
  code: "graphql-validation",
24576
25142
  message: error.message,
24577
- file: document.path,
24578
- line: error.locations?.[0]?.line
25143
+ ...document.path === undefined ? {} : { file: document.path },
25144
+ ...error.locations?.[0]?.line === undefined ? {} : { line: error.locations[0].line }
24579
25145
  })));
24580
25146
  const fragmentDefinitions = new Map(parsed.definitions.filter((definition) => definition.kind === Kind2.FRAGMENT_DEFINITION).map((definition) => [definition.name.value, definition]));
24581
25147
  for (const definition of parsed.definitions) {
@@ -24583,7 +25149,10 @@ function checkGraphqlCompatibility(schema, documents, policy = {}) {
24583
25149
  continue;
24584
25150
  const result = operationReport(schema, definition, fragmentDefinitions, policy);
24585
25151
  operations.push(result.report);
24586
- diagnostics.push(...result.diagnostics.map((item) => ({ ...item, file: document.path })));
25152
+ diagnostics.push(...result.diagnostics.map((item) => ({
25153
+ ...item,
25154
+ ...document.path === undefined ? {} : { file: document.path }
25155
+ })));
24587
25156
  }
24588
25157
  }
24589
25158
  return { ok: diagnostics.every((item) => item.severity !== "error"), features: graphqlFeatureMatrix(schema), operations, diagnostics };