@supacloud/cli 0.56.2 → 0.57.0

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.
Files changed (2) hide show
  1. package/dist/index.js +287 -55
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -220075,7 +220075,9 @@ function buildContractManifest(graph, artifacts) {
220075
220075
  ...route.responses === undefined ? {} : {
220076
220076
  responseSchemas: Object.fromEntries(Object.entries(route.responses).sort(([left], [right]) => left.localeCompare(right)))
220077
220077
  },
220078
- ...route.contract?.evidence === undefined ? {} : { evidence: route.contract.evidence }
220078
+ ...route.contract?.evidence === undefined ? {} : { evidence: route.contract.evidence },
220079
+ ...route.parse === undefined ? {} : { parse: route.parse },
220080
+ ...route.allowDeleteBody === undefined ? {} : { allowDeleteBody: route.allowDeleteBody }
220079
220081
  });
220080
220082
  }
220081
220083
  }
@@ -220159,7 +220161,7 @@ function renderApplication(graph, options) {
220159
220161
  providers: mod.providers.filter((p) => p.providedIn !== "root" || p.multi || referencedTokens.has(p.token) || p.exported)
220160
220162
  }));
220161
220163
  }
220162
- const imports = new ImportManager;
220164
+ const imports = new ImportManager(new Set(["CompiledApplicationModule"]));
220163
220165
  const factorySections = [];
220164
220166
  const descriptorEntries = [];
220165
220167
  for (const module of modules) {
@@ -220176,7 +220178,13 @@ function renderApplication(graph, options) {
220176
220178
  "",
220177
220179
  TYPE_GUARDS,
220178
220180
  "",
220179
- "export function createCompiledModules(): CompiledModule[] {",
220181
+ ...modules.length > 0 ? [
220182
+ 'export type CompiledApplicationModule = Omit<CompiledModule, "name" | "createServices"> & (',
220183
+ ...modules.map((module) => ` | { name: ${JSON.stringify(module.name)}; createServices: typeof create${pascalName(module.name)}Services }`),
220184
+ ");"
220185
+ ] : ["export type CompiledApplicationModule = CompiledModule;"],
220186
+ "",
220187
+ "export function createCompiledModules(): CompiledApplicationModule[] {",
220180
220188
  " return [",
220181
220189
  ...descriptorEntries.map((entry) => indent5(entry, 4) + ","),
220182
220190
  " ];",
@@ -220256,8 +220264,7 @@ function renderApplication(graph, options) {
220256
220264
  ...permissionsCode === undefined ? {} : { permissionsCode }
220257
220265
  };
220258
220266
  }
220259
- async function generateApplication(graph, options) {
220260
- const rendered = renderApplication(graph, options);
220267
+ async function writeRenderedApplication(rendered, options) {
220261
220268
  await mkdir(options.outDir, { recursive: true });
220262
220269
  const applicationPath = join22(options.outDir, "application.ts");
220263
220270
  const manifestPath = join22(options.outDir, "app.manifest.json");
@@ -220344,8 +220351,12 @@ function indent5(text, spaces) {
220344
220351
  }
220345
220352
 
220346
220353
  class ImportManager {
220354
+ reserved;
220347
220355
  entries = new Map;
220348
220356
  lookup = new Map;
220357
+ constructor(reserved = new Set) {
220358
+ this.reserved = reserved;
220359
+ }
220349
220360
  get size() {
220350
220361
  return this.entries.size;
220351
220362
  }
@@ -220360,7 +220371,7 @@ class ImportManager {
220360
220371
  return existing;
220361
220372
  let local = exported;
220362
220373
  let counter = 2;
220363
- while (this.entries.has(local)) {
220374
+ while (this.entries.has(local) || this.reserved.has(local)) {
220364
220375
  local = `${exported}${counter}`;
220365
220376
  counter += 1;
220366
220377
  }
@@ -220417,7 +220428,7 @@ class ModuleGenerator {
220417
220428
  renderDescriptor() {
220418
220429
  const lines = [
220419
220430
  `{`,
220420
- ` name: ${JSON.stringify(this.module.name)},`,
220431
+ ` name: ${JSON.stringify(this.module.name)} as const,`,
220421
220432
  ` createServices: create${this.pascal}Services,`
220422
220433
  ];
220423
220434
  if (this.hasFactoryContent("request")) {
@@ -220556,6 +220567,10 @@ class ModuleGenerator {
220556
220567
  if (route.contract !== undefined) {
220557
220568
  fields.push(`contract: ${JSON.stringify(route.contract)}`);
220558
220569
  }
220570
+ if (route.parse === "none")
220571
+ fields.push('parse: "none"');
220572
+ if (route.allowDeleteBody === true)
220573
+ fields.push("allowDeleteBody: true");
220559
220574
  if (route.schemaKinds !== undefined && Object.keys(route.schemaKinds).length > 0) {
220560
220575
  fields.push(`schemaKinds: ${JSON.stringify(route.schemaKinds)}`);
220561
220576
  }
@@ -220655,7 +220670,7 @@ ${indent5(item, 2)}`).join(",")}
220655
220670
  `function create${this.pascal}Services(`,
220656
220671
  ` deps: Record<string, unknown>,`,
220657
220672
  ` imported: Record<string, Record<string, unknown>>,`,
220658
- `): Record<string, unknown> {`,
220673
+ `) {`,
220659
220674
  indent5(this.renderFactoryBody("services"), 2),
220660
220675
  `}`
220661
220676
  ].join(`
@@ -220752,7 +220767,7 @@ ${indent5(item, 2)}`).join(",")}
220752
220767
  `);
220753
220768
  }
220754
220769
  const entries = [...returns.entries()].map(([key, expr]) => key === expr ? key : `${key}: ${expr}`);
220755
- lines.push(`return { ${entries.join(", ")} };`);
220770
+ lines.push(`return retainPlatformDependencies({ ${entries.join(", ")} }, deps);`);
220756
220771
  return lines.join(`
220757
220772
  `);
220758
220773
  }
@@ -220853,6 +220868,9 @@ ${indent5(item, 2)}`).join(",")}
220853
220868
  return this.depExpr(own.useExisting ?? token, kind, options);
220854
220869
  }
220855
220870
  }
220871
+ if (own && factoryOfScope(own.scope) === "services" && kind !== "services" && !isSkipSelf && !isSelf) {
220872
+ return `services.${camelName(token)}`;
220873
+ }
220856
220874
  if (isSelf) {
220857
220875
  return isOptional ? "undefined" : `services.${camelName(token)}`;
220858
220876
  }
@@ -220870,13 +220888,14 @@ ${indent5(item, 2)}`).join(",")}
220870
220888
  return `imported.${mod.name}.${camelName(token)}`;
220871
220889
  }
220872
220890
  }
220873
- if (isOptional && !this.graph.externalTokens.includes(token)) {
220874
- return "undefined";
220875
- }
220876
220891
  if (isSelf)
220877
220892
  return isOptional ? "undefined" : `services.${camelName(token)}`;
220878
220893
  if (kind === "services")
220879
220894
  return isOptional ? `(deps.${camelName(token)} ?? undefined)` : `deps.${camelName(token)}`;
220895
+ if (!own || isSkipSelf) {
220896
+ const external = `platformDependencies.get(services)?.${camelName(token)}`;
220897
+ return isOptional ? `(${external} ?? undefined)` : external;
220898
+ }
220880
220899
  return isOptional ? `(services.${camelName(token)} ?? undefined)` : `services.${camelName(token)}`;
220881
220900
  }
220882
220901
  }
@@ -220904,7 +220923,7 @@ function orderProviders(providers) {
220904
220923
  function renderClient(graph, options) {
220905
220924
  const rootDir = options?.rootDir ?? process.cwd();
220906
220925
  const outDir = options?.outDir ?? process.cwd();
220907
- const imports = new ImportManager;
220926
+ const imports = new ImportManager(new Set(["ApiClientError", "ApiClientErrorCode", "ApiClientErrorDetails"]));
220908
220927
  const controllerEntries = [];
220909
220928
  const routeTypes = [];
220910
220929
  const schemaEntries = [];
@@ -220962,11 +220981,14 @@ function renderClient(graph, options) {
220962
220981
  }).filter((entry) => entry.length === 2));
220963
220982
  if (Object.keys(responseSchemas).length > 0)
220964
220983
  usesValue = true;
220965
- const paramNames = [...new Set((fullPath.match(/:([a-zA-Z0-9_]+)/g) ?? []).map((p) => p.slice(1)))];
220984
+ const paramNames = [...new Set([
220985
+ ...(fullPath.match(/:([a-zA-Z0-9_]+)/g) ?? []).map((p) => p.slice(1)),
220986
+ ...fullPath.endsWith("/*") ? ["*"] : []
220987
+ ])];
220966
220988
  const pathParamsType = paramNames.length > 0 ? `{ ${paramNames.map((p) => `${/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p) ? p : JSON.stringify(p)}: string | number`).join("; ")} }` : "Record<string, string | number>";
220967
220989
  const paramsType = paramsSchema ? `Static<typeof ${paramsSchema.local}>${paramNames.length > 0 ? ` & ${pathParamsType}` : ""}` : pathParamsType;
220968
220990
  const queryType = querySchema ? `Static<typeof ${querySchema.local}>` : "Record<string, unknown>";
220969
- const bodyType = bodySchema ? `Static<typeof ${bodySchema.local}>` : "unknown";
220991
+ const bodyType = route.parse === "none" ? "BodyInit" : bodySchema ? `Static<typeof ${bodySchema.local}>` : "unknown";
220970
220992
  const headersType = headersSchema ? `Static<typeof ${headersSchema.local}>` : "Record<string, string>";
220971
220993
  const cookieType = cookieSchema ? `Static<typeof ${cookieSchema.local}>` : "Record<string, string | number | boolean>";
220972
220994
  const responseTypes = [
@@ -221003,7 +221025,9 @@ function renderClient(graph, options) {
221003
221025
  ["queryTransforms", route.queryTransforms],
221004
221026
  ["queryDefaults", route.queryDefaults],
221005
221027
  ["title", route.title],
221006
- ["data", route.data]
221028
+ ["data", route.data],
221029
+ ["parse", route.parse],
221030
+ ["allowDeleteBody", route.allowDeleteBody]
221007
221031
  ]) {
221008
221032
  if (value !== undefined)
221009
221033
  routeFields.push(`${key}: ${JSON.stringify(value)}`);
@@ -221037,7 +221061,7 @@ function renderClient(graph, options) {
221037
221061
  const responseSchemaArgument = responseSchemaEntries.length > 0 ? `{ ${responseSchemaEntries.map(([status, local]) => `${JSON.stringify(status)}: ${local}`).join(", ")} }` : "undefined";
221038
221062
  const responseKindArgument = responseKind === undefined ? "undefined" : JSON.stringify(responseKind);
221039
221063
  routeMethods.push(`
221040
- ${route.handler}: makeRoute<${requestTypeName}, ${responseType === "never" ? "never" : responseTypeName}>(${JSON.stringify(route.method)}, ${JSON.stringify(fullPath)}, ${responseSchemaArgument}, ${responseKindArgument}),`);
221064
+ ${route.handler}: makeRoute<${requestTypeName}, ${responseType === "never" ? "never" : responseTypeName}>(${JSON.stringify(route.method)}, ${JSON.stringify(fullPath)}, ${responseSchemaArgument}, ${responseKindArgument}, ${route.parse === "none"}),`);
221041
221065
  }
221042
221066
  controllerEntries.push(`
221043
221067
  ${controllerKey}: {${routeMethods.join("")}
@@ -221068,6 +221092,40 @@ function renderClient(graph, options) {
221068
221092
  "",
221069
221093
  "export type ResponseDecoder<T> = (value: unknown) => T;",
221070
221094
  "",
221095
+ 'export type ApiClientErrorCode = "API_HTTP_ERROR" | "API_RESPONSE_INVALID" | "API_RESPONSE_UNDECLARED";',
221096
+ "",
221097
+ "export interface ApiClientErrorDetails {",
221098
+ " code: ApiClientErrorCode;",
221099
+ " method: string;",
221100
+ " path: string;",
221101
+ " status: number;",
221102
+ " requestId?: string | null;",
221103
+ " response?: Response;",
221104
+ "}",
221105
+ "",
221106
+ "/** Transport/contract metadata, not proof that a failed write rolled back. */",
221107
+ "export class ApiClientError extends Error {",
221108
+ " readonly code: ApiClientErrorCode;",
221109
+ " readonly method: string;",
221110
+ " readonly path: string;",
221111
+ " readonly status: number;",
221112
+ " readonly requestId: string | undefined;",
221113
+ " /** Undeclared HTTP response for explicit inspection; excluded from JSON serialization. */",
221114
+ " readonly response: Response | undefined;",
221115
+ " constructor(message: string, details: ApiClientErrorDetails) {",
221116
+ " super(message);",
221117
+ ' this.name = "ApiClientError";',
221118
+ " const { code, method, path, status, requestId, response } = details;",
221119
+ " this.code = code;",
221120
+ " this.method = method;",
221121
+ " this.path = path;",
221122
+ " this.status = status;",
221123
+ " this.requestId = requestId && /^[A-Za-z0-9._:-]{1,256}$/.test(requestId) ? requestId : undefined;",
221124
+ " this.response = response;",
221125
+ ' Object.defineProperty(this, "response", { enumerable: false });',
221126
+ " }",
221127
+ "}",
221128
+ "",
221071
221129
  "export type RouteMethod<",
221072
221130
  " Options extends ClientRequestOptions = ClientRequestOptions,",
221073
221131
  " Result = never,",
@@ -221121,6 +221179,13 @@ function renderClient(graph, options) {
221121
221179
  ' if (typeof value !== "string" && typeof value !== "number") throw new TypeError(`Missing route parameter: ${key}`);',
221122
221180
  " return encodeURIComponent(String(value));",
221123
221181
  " });",
221182
+ ' if (path.endsWith("/*")) {',
221183
+ ' const wildcard = params && Object.hasOwn(params, "*") ? params["*"] : undefined;',
221184
+ ' if (typeof wildcard !== "string" && typeof wildcard !== "number") throw new TypeError("Missing route parameter: *");',
221185
+ ' const segments = String(wildcard).split("/");',
221186
+ ' if (segments.some(segment => segment === "." || segment === "..")) throw new TypeError("Wildcard dot segments are not supported by Fetch URLs");',
221187
+ ' url = url.slice(0, -1) + segments.map(encodeURIComponent).join("/");',
221188
+ " }",
221124
221189
  " if (query) {",
221125
221190
  " const searchParams = new URLSearchParams();",
221126
221191
  " for (const [k, v] of Object.entries(query)) {",
@@ -221307,6 +221372,10 @@ function renderClient(graph, options) {
221307
221372
  "export function createApiClient(config: ApiClientConfig = {}) {",
221308
221373
  " const fetcher = config.fetch ?? globalThis.fetch.bind(globalThis);",
221309
221374
  ' const baseUrl = (config.baseUrl ?? "").replace(/\\/+$/, "");',
221375
+ " function rawBody(value: unknown): BodyInit {",
221376
+ ' if (typeof value === "string" || value instanceof Blob || value instanceof FormData || value instanceof URLSearchParams || value instanceof ArrayBuffer || ArrayBuffer.isView(value) || value instanceof ReadableStream) return value as BodyInit;',
221377
+ ' throw new TypeError("Raw routes require a BodyInit value; JSON encoding is not implicit");',
221378
+ " }",
221310
221379
  "",
221311
221380
  " async function request<T>(",
221312
221381
  " method: string,",
@@ -221315,6 +221384,7 @@ function renderClient(graph, options) {
221315
221384
  " decode: ResponseDecoder<T>,",
221316
221385
  ` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
221317
221386
  " responseKind?: string,",
221387
+ " raw?: boolean,",
221318
221388
  " ): Promise<T>;",
221319
221389
  " async function request<T>(",
221320
221390
  " method: string,",
@@ -221323,6 +221393,7 @@ function renderClient(graph, options) {
221323
221393
  " decode?: ResponseDecoder<T>,",
221324
221394
  ` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
221325
221395
  " responseKind?: string,",
221396
+ " raw?: boolean,",
221326
221397
  " ): Promise<T | unknown>;",
221327
221398
  " async function request(",
221328
221399
  " method: string,",
@@ -221336,11 +221407,12 @@ function renderClient(graph, options) {
221336
221407
  " decode?: ResponseDecoder<T>,",
221337
221408
  ` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
221338
221409
  " responseKind?: string,",
221410
+ " raw = false,",
221339
221411
  " ): Promise<T | unknown> {",
221340
221412
  " const url = `${baseUrl}${buildRouteUrl(path, options.params, options.query)}`;",
221341
221413
  ' const customHeaders = typeof config.headers === "function" ? await config.headers() : config.headers;',
221342
221414
  " const headers: Record<string, string> = {",
221343
- ' "content-type": "application/json",',
221415
+ ' ...(raw ? {} : { "content-type": "application/json" }),',
221344
221416
  " ...customHeaders,",
221345
221417
  " ...options.headers,",
221346
221418
  " };",
@@ -221359,21 +221431,27 @@ function renderClient(graph, options) {
221359
221431
  " return fetcher(reqPayload.url, {",
221360
221432
  " method: reqPayload.method,",
221361
221433
  " headers: reqPayload.headers,",
221362
- " ...(reqPayload.body === undefined ? {} : { body: JSON.stringify(reqPayload.body) }),",
221434
+ " ...(reqPayload.body === undefined ? {} : { body: raw ? rawBody(reqPayload.body) : JSON.stringify(reqPayload.body) }),",
221435
+ ' ...(raw && reqPayload.body instanceof ReadableStream ? { duplex: "half" } : {}),',
221363
221436
  " });",
221364
221437
  " };",
221365
221438
  " const response = await executeChain(0, { method, url, headers, body: options.body });",
221366
221439
  " const declaredSchema = responseSchemas ? selectResponseSchema(response.status, responseSchemas) : undefined;",
221440
+ " const failure = (code: ApiClientErrorCode, message: string) => new ApiClientError(message, {",
221441
+ ' code, method, path, status: response.status, requestId: response.headers.get("x-request-id"),',
221442
+ ' ...(code === "API_HTTP_ERROR" ? { response } : {}),',
221443
+ " });",
221367
221444
  " if (!response.ok && declaredSchema === undefined) {",
221368
- " const errBody = await response.text();",
221369
- " throw new Error(`API request failed: ${method} ${path} -> ${response.status} ${errBody}`);",
221445
+ ' throw failure("API_HTTP_ERROR", `API request failed: ${method} ${path} -> ${response.status}`);',
221370
221446
  " }",
221371
221447
  ' const contentType = response.headers?.get("content-type") ?? "";',
221372
221448
  " let value: unknown;",
221373
221449
  " if ([204, 205, 304].includes(response.status)) {",
221374
221450
  " value = undefined;",
221375
221451
  ' } else if (contentType.includes("application/json") || contentType.includes("+json")) {',
221376
- " value = await response.json();",
221452
+ " const responseText = await response.text();",
221453
+ " try { value = JSON.parse(responseText); }",
221454
+ ' catch { throw failure("API_RESPONSE_INVALID", "Response is not valid JSON"); }',
221377
221455
  ' } else if (responseKind === "binary" || contentType.includes("application/octet-stream")) {',
221378
221456
  " value = await response.arrayBuffer();",
221379
221457
  ' } else if (responseKind === "stream") {',
@@ -221384,20 +221462,24 @@ function renderClient(graph, options) {
221384
221462
  " if (!responseSchemas) return decode ? decode(value) : value;",
221385
221463
  " if (declaredSchema === undefined) {",
221386
221464
  ' const transportSuccess = response.ok && (responseKind === "binary" || responseKind === "stream");',
221387
- " if (!transportSuccess) throw new Error(`No response schema declared for HTTP ${response.status}`);",
221465
+ ' if (!transportSuccess) throw failure("API_RESPONSE_UNDECLARED", `No response schema declared for HTTP ${response.status}`);',
221388
221466
  " return decode ? decode(value) : value;",
221389
221467
  " }",
221390
- ...usesValue ? [" const checked = decodeResponseSchema(value, response.status, responseSchemas, { normalize: config.normalize ?? true });"] : [" const checked = value;"],
221468
+ ...usesValue ? [
221469
+ " let checked: unknown;",
221470
+ " try { checked = decodeResponseSchema(value, response.status, responseSchemas, { normalize: config.normalize ?? true }); }",
221471
+ ' catch { throw failure("API_RESPONSE_INVALID", "Response does not match schema"); }'
221472
+ ] : [" const checked = value;"],
221391
221473
  " return decode ? decode(checked) : checked;",
221392
221474
  " }",
221393
221475
  "",
221394
- ` function makeRoute<Options extends ClientRequestOptions, Result = never>(method: string, path: string, responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>, responseKind?: string): RouteMethod<Options, Result> {`,
221476
+ ` function makeRoute<Options extends ClientRequestOptions, Result = never>(method: string, path: string, responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>, responseKind?: string, raw = false): RouteMethod<Options, Result> {`,
221395
221477
  " function route<T>(options: Options, decode: ResponseDecoder<T>): Promise<T>;",
221396
221478
  " function route(options: Options): Promise<Result>;",
221397
221479
  " function route(options?: Options): Promise<unknown>;",
221398
221480
  " function route<T>(options?: Options, decode?: ResponseDecoder<T>): Promise<T | unknown> {",
221399
221481
  " const requestOptions = options ?? {};",
221400
- " return request(method, path, requestOptions, decode, responseSchemas, responseKind);",
221482
+ " return request(method, path, requestOptions, decode, responseSchemas, responseKind, raw);",
221401
221483
  " }",
221402
221484
  " return route as RouteMethod<Options, Result>;",
221403
221485
  " }",
@@ -221454,11 +221536,15 @@ function renderOpenApi(graph, options) {
221454
221536
  for (const module of graph.modules) {
221455
221537
  for (const controller of module.controllers) {
221456
221538
  for (const route of controller.routes) {
221539
+ const documentation = route.data?.openapi;
221540
+ if (documentation !== null && typeof documentation === "object" && "hide" in documentation && documentation.hide === true)
221541
+ continue;
221457
221542
  const fullPath = joinRoutePaths(controller.path, route.path);
221458
221543
  const responseEntries = normalizedResponseEntries(route.responses);
221459
221544
  const hasResponseMap = responseEntries.length > 0;
221460
221545
  const pathParams = [...new Set([
221461
221546
  ...(fullPath.match(/:([A-Za-z0-9_]+)/g) ?? []).map((item) => item.slice(1)),
221547
+ ...fullPath.endsWith("/*") ? ["*"] : [],
221462
221548
  ...route.pathParams ?? []
221463
221549
  ].filter((item) => item.length > 0))];
221464
221550
  const queryParams = [...new Set([
@@ -221491,6 +221577,8 @@ function renderOpenApi(graph, options) {
221491
221577
  }).filter((entry) => entry.length === 2)) } : {},
221492
221578
  responseContentType,
221493
221579
  responseKind: responseKind ?? (route.nativeResponse ? "native-response" : undefined),
221580
+ ...route.parse === undefined ? {} : { parse: route.parse },
221581
+ ...route.allowDeleteBody === undefined ? {} : { allowDeleteBody: route.allowDeleteBody },
221494
221582
  module: module.name,
221495
221583
  controller: controller.className,
221496
221584
  handler: route.handler,
@@ -221574,6 +221662,8 @@ function renderOpenApi(graph, options) {
221574
221662
  " canMatch?: readonly string[];",
221575
221663
  " canDeactivate?: readonly string[];",
221576
221664
  " contract?: Record<string, unknown>;",
221665
+ ' parse?: "none";',
221666
+ " allowDeleteBody?: true;",
221577
221667
  " data?: Record<string, unknown>;",
221578
221668
  " requiresAuth?: boolean;",
221579
221669
  "};",
@@ -221771,8 +221861,15 @@ function renderOpenApi(graph, options) {
221771
221861
  ' return { $ref: `#/components/schemas/${encodeURIComponent(name).replaceAll("%2F", "/")}` };',
221772
221862
  "}",
221773
221863
  "",
221864
+ "function wildcardParameterName(path: string): string {",
221865
+ " const names = new Set([...path.matchAll(/:([A-Za-z0-9_]+)/g)].map(match => match[1]));",
221866
+ ' let name = "wildcard";',
221867
+ ' while (names.has(name)) name += "_";',
221868
+ " return name;",
221869
+ "}",
221870
+ "",
221774
221871
  "function openApiPath(path: string): string {",
221775
- ' return path.replace(/:([A-Za-z0-9_]+)/g, "{$1}");',
221872
+ ' return path.replace(/:([A-Za-z0-9_]+)/g, "{$1}").replace(/\\/\\*$/, `/{${wildcardParameterName(path)}}`);',
221776
221873
  "}",
221777
221874
  "",
221778
221875
  "function responseHasBody(status: string, kind: string | undefined): boolean {",
@@ -221802,7 +221899,7 @@ function renderOpenApi(graph, options) {
221802
221899
  " const parameters: Record<string, unknown>[] = [];",
221803
221900
  " const paramsSchema = definition.paramsSchema ? OPENAPI_SCHEMA_REGISTRY[definition.paramsSchema as keyof typeof OPENAPI_SCHEMA_REGISTRY] : undefined;",
221804
221901
  " for (const name of definition.pathParams) parameters.push({",
221805
- ' name, in: "path", required: true, schema: schemaProperty(paramsSchema, name),',
221902
+ ' name: name === "*" ? wildcardParameterName(definition.path) : name, in: "path", required: true, schema: schemaProperty(paramsSchema, name),',
221806
221903
  " });",
221807
221904
  " const querySchema = definition.querySchema ? OPENAPI_SCHEMA_REGISTRY[definition.querySchema as keyof typeof OPENAPI_SCHEMA_REGISTRY] : undefined;",
221808
221905
  " const queryNames = new Set([...(querySchema ? schemaPropertyNames(querySchema) : []), ...definition.queryParams]);",
@@ -221839,6 +221936,7 @@ function renderOpenApi(graph, options) {
221839
221936
  " operationId: definition.operationId, tags: [...definition.tags], summary: definition.summary, responses,",
221840
221937
  " ...(parameters.length === 0 ? {} : { parameters }),",
221841
221938
  ' ...(definition.bodySchema ? { requestBody: { required: !schemaAllowsUndefined(OPENAPI_SCHEMA_REGISTRY[definition.bodySchema as keyof typeof OPENAPI_SCHEMA_REGISTRY]), content: { "application/json": { schema: schemaReference(definition.bodySchema) } } } } : {}),',
221939
+ ' ...(definition.parse === "none" ? { requestBody: { required: false, description: "Raw request bytes; validation and media types are owned by the domain handler.", content: { "*/*": { schema: { type: "string", format: "binary" } } } } } : {}),',
221842
221940
  " ...(definition.requiresAuth ? { security: [{ bearerAuth: [] }] } : {}),",
221843
221941
  ' "x-supacloud": {',
221844
221942
  " module: definition.module, controller: definition.controller, handler: definition.handler,",
@@ -221848,6 +221946,8 @@ function renderOpenApi(graph, options) {
221848
221946
  " ...(definition.canMatch ? { canMatch: [...definition.canMatch] } : {}),",
221849
221947
  " ...(definition.canDeactivate ? { canDeactivate: [...definition.canDeactivate] } : {}),",
221850
221948
  " ...(definition.contract ? { contract: definition.contract } : {}),",
221949
+ " ...(definition.parse ? { parse: definition.parse } : {}),",
221950
+ " ...(definition.allowDeleteBody ? { allowDeleteBody: true } : {}),",
221851
221951
  " ...(definition.data ? { data: definition.data } : {}),",
221852
221952
  " },",
221853
221953
  " };",
@@ -221944,6 +222044,8 @@ function renderPermissions(graph) {
221944
222044
  }
221945
222045
  var HEADER = "// GENERATED BY @supacloud/compiler — do not edit";
221946
222046
  var INTERFACES = `export interface CompiledRoute {
222047
+ parse?: "none";
222048
+ allowDeleteBody?: true;
221947
222049
  method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
221948
222050
  path: string;
221949
222051
  handler: string;
@@ -222097,6 +222199,12 @@ function resolveFactoryValue(value: unknown): unknown {
222097
222199
  }
222098
222200
 
222099
222201
  const scopeDestructions = new WeakMap<object, Promise<void>>();
222202
+ const platformDependencies = new WeakMap<object, Record<string, unknown>>();
222203
+
222204
+ function retainPlatformDependencies<T extends Record<string, unknown>>(services: T, deps: Record<string, unknown>): T {
222205
+ platformDependencies.set(services, deps);
222206
+ return services;
222207
+ }
222100
222208
 
222101
222209
  function destroyScopeInstances(
222102
222210
  scope: Record<string, unknown>,
@@ -223243,6 +223351,7 @@ var COMPILER_DIAGNOSTIC_CODES = {
223243
223351
  };
223244
223352
  function validateGraph(graph, options = false) {
223245
223353
  const strict = typeof options === "boolean" ? options : options.strict ?? false;
223354
+ const generateOpenApi = typeof options === "object" && options.generateOpenApi === true;
223246
223355
  const diagnostics = [];
223247
223356
  for (const module of graph.modules) {
223248
223357
  for (const owner of [...module.providers, ...module.controllers]) {
@@ -223378,7 +223487,7 @@ function validateGraph(graph, options = false) {
223378
223487
  }
223379
223488
  const fullPath = joinRoutePaths2(controller.path, route.path);
223380
223489
  const rawFullPath = joinRawRoutePaths(controller.path, route.path);
223381
- const key = `${route.method} ${fullPath}`;
223490
+ const key = `${route.method} ${generateOpenApi ? fullPath.replace(/:[A-Za-z0-9_]+|\*$/g, "{}") : fullPath}`;
223382
223491
  const openApiMatch = route.path.match(/\{([a-zA-Z0-9_]+)\}/);
223383
223492
  if (openApiMatch) {
223384
223493
  error("missing-param-colon", `Route path '${route.path}' in '${controller.className}.${route.handler}' uses OpenAPI-style '{${openApiMatch[1]}}'. SupaCloud routes require Express/Angular-style ':${openApiMatch[1]}'.`, controller.file, undefined, `Replace '{${openApiMatch[1]}}' with ':${openApiMatch[1]}'.`);
@@ -223478,7 +223587,13 @@ function validateGraph(graph, options = false) {
223478
223587
  }
223479
223588
  }
223480
223589
  }
223481
- if ((route.method === "GET" || route.method === "HEAD" || route.method === "OPTIONS" || route.method === "DELETE") && (route.hasBodyBinding || route.body)) {
223590
+ if (route.allowDeleteBody && (route.method !== "DELETE" || !route.body)) {
223591
+ error("invalid-delete-body-opt-in", `Route ${controller.className}.${route.handler} allowDeleteBody requires DELETE and an explicit body schema.`, controller.file);
223592
+ }
223593
+ if (route.parse === "none" && (route.body || route.hasBodyBinding || route.contract?.body !== "domain" || !route.contract.evidence?.trim())) {
223594
+ error("invalid-raw-body-contract", `Route ${controller.className}.${route.handler} parse: "none" requires domain body ownership and evidence, without a parsed body schema or @Body binding.`, controller.file);
223595
+ }
223596
+ if ((route.method === "GET" || route.method === "HEAD" || route.method === "OPTIONS" || route.method === "DELETE" && !route.allowDeleteBody) && (route.hasBodyBinding || route.body)) {
223482
223597
  error("disallowed-body-on-get-delete", `Route handler ${controller.className}.${route.handler} binds @Body() or declares body schema on HTTP ${route.method} route '${route.path}'. Request bodies are not supported on ${route.method} requests.`, controller.file, undefined, `Use POST, PUT, or PATCH for routes accepting a request body, or bind parameters via @Query() / @Param().`, {
223483
223598
  type: "remove_route_body_binding",
223484
223599
  targetFile: controller.file,
@@ -224186,6 +224301,7 @@ async function analyzeProject(rootDir, include, cache, changedPaths) {
224186
224301
  tokensByName: new Map,
224187
224302
  classesByName: new Map,
224188
224303
  variablesByName: new Map,
224304
+ moduleHandlerFiles: new Map,
224189
224305
  diagnostics: []
224190
224306
  };
224191
224307
  const nativeTraitFiles = new Map;
@@ -224276,10 +224392,11 @@ async function analyzeProject(rootDir, include, cache, changedPaths) {
224276
224392
  const hasChangedFile = entry.ownedFiles.some((f) => changedFiles.has(f));
224277
224393
  const moduleFileExists = currentFileHashes.has(entry.module.file);
224278
224394
  const isAffectedByDep = affectedModuleNames.has(modName);
224279
- if (!hasChangedFile && !isAffectedByDep && moduleFileExists) {
224395
+ if (!hasChangedFile && !isAffectedByDep && moduleFileExists && entry.handlerFiles !== undefined) {
224280
224396
  modulesToKeep.set(modName, entry);
224281
224397
  reusedModules.push(modName);
224282
224398
  finalModules.push(entry.module);
224399
+ ctx.moduleHandlerFiles.set(modName, entry.handlerFiles);
224283
224400
  if (entry.diagnostics)
224284
224401
  finalDiagnostics.push(...entry.diagnostics);
224285
224402
  }
@@ -224299,6 +224416,7 @@ async function analyzeProject(rootDir, include, cache, changedPaths) {
224299
224416
  }
224300
224417
  cache.modules.set(parsed.name, {
224301
224418
  module: parsed,
224419
+ handlerFiles: ctx.moduleHandlerFiles.get(parsed.name) ?? [],
224302
224420
  ownedFiles: [...ownedFiles],
224303
224421
  fileHashes,
224304
224422
  diagnostics: moduleDiagnostics
@@ -224467,6 +224585,7 @@ async function analyzeProject(rootDir, include, cache, changedPaths) {
224467
224585
  externalTokens,
224468
224586
  diagnostics: ctx.diagnostics.map(withDiagnosticMetadata),
224469
224587
  tokenNames,
224588
+ moduleHandlerFiles: Object.fromEntries(ctx.moduleHandlerFiles),
224470
224589
  ...cache ? { cacheStats: { reusedModules, reanalyzedModules } } : {}
224471
224590
  };
224472
224591
  }
@@ -224679,6 +224798,7 @@ function parseModule(candidate, nameByNode, ctx) {
224679
224798
  arrayProp(options, "commands").forEach(collectHandler);
224680
224799
  arrayProp(options, "jobs").forEach(collectHandler);
224681
224800
  arrayProp(options, "queries").forEach(collectHandler);
224801
+ ctx.moduleHandlerFiles.set(name, [...new Set([...handlerClasses].map((cls) => sourcePath(ctx.rootDir, cls.getSourceFile().fileName)))].sort());
224682
224802
  const commands = [];
224683
224803
  const jobs = [];
224684
224804
  const queries = [];
@@ -224857,6 +224977,25 @@ function resolveStaticObjectLiteral(input, ctx, seen = new Set) {
224857
224977
  }
224858
224978
  return ts4.isObjectLiteralExpression(input) ? input : undefined;
224859
224979
  }
224980
+ function routePolicyProperty(object, name, ctx, seen = new Set) {
224981
+ if (seen.has(object))
224982
+ return { unresolved: true };
224983
+ const ancestry = new Set(seen).add(object);
224984
+ let result = { unresolved: false };
224985
+ for (const property of object.properties) {
224986
+ if (ts4.isSpreadAssignment(property)) {
224987
+ const spread = resolveStaticObjectLiteral(property.expression, ctx);
224988
+ const nested = spread ? routePolicyProperty(spread, name, ctx, ancestry) : { unresolved: true };
224989
+ if (nested.unresolved || nested.value !== undefined)
224990
+ result = nested;
224991
+ } else if (ts4.isComputedPropertyName(property.name)) {
224992
+ result = { unresolved: true };
224993
+ } else if (propertyName(property.name) === name) {
224994
+ result = ts4.isPropertyAssignment(property) ? { value: property.initializer, unresolved: false } : { unresolved: true };
224995
+ }
224996
+ }
224997
+ return result;
224998
+ }
224860
224999
  function commandModeProp(object, name) {
224861
225000
  const value = stringLiteralProp(object, name);
224862
225001
  return value === "required" || value === "none" ? value : undefined;
@@ -225364,10 +225503,13 @@ function parseController(input, ctx) {
225364
225503
  const pathParams = [];
225365
225504
  const paramRegex = /:([a-zA-Z0-9_]+)/g;
225366
225505
  let match;
225367
- while ((match = paramRegex.exec(routePath)) !== null) {
225506
+ const fullPath = joinRoutePaths(path, routePath);
225507
+ while ((match = paramRegex.exec(fullPath)) !== null) {
225368
225508
  if (match[1] !== undefined)
225369
225509
  pathParams.push(match[1]);
225370
225510
  }
225511
+ if (joinRoutePaths(path, routePath).endsWith("/*"))
225512
+ pathParams.push("*");
225371
225513
  if (pathParams.length > 0)
225372
225514
  route.pathParams = pathParams;
225373
225515
  const paramBindings = [];
@@ -225518,6 +225660,40 @@ function parseController(input, ctx) {
225518
225660
  const optionsArg = args[1];
225519
225661
  const optionsObject = resolveStaticObjectLiteral(optionsArg, ctx);
225520
225662
  if (optionsObject) {
225663
+ const parsePolicy = routePolicyProperty(optionsObject, "parse", ctx);
225664
+ const deletePolicy = routePolicyProperty(optionsObject, "allowDeleteBody", ctx);
225665
+ if (parsePolicy.unresolved || deletePolicy.unresolved) {
225666
+ ctx.diagnostics.push({
225667
+ severity: "error",
225668
+ code: "unresolved-route-body-policy",
225669
+ file,
225670
+ message: `Route ${route.handler} body policy must be statically resolvable; dynamic spreads, computed keys and shorthand policies are unsupported.`
225671
+ });
225672
+ }
225673
+ const parse = parsePolicy.value;
225674
+ if (parse) {
225675
+ if (ts4.isStringLiteral(parse) && parse.text === "none")
225676
+ route.parse = "none";
225677
+ else
225678
+ ctx.diagnostics.push({
225679
+ severity: "error",
225680
+ code: "invalid-route-parser",
225681
+ file,
225682
+ message: `Route ${route.handler} parse must be the literal "none".`
225683
+ });
225684
+ }
225685
+ const allowDeleteBody = deletePolicy.value;
225686
+ if (allowDeleteBody) {
225687
+ if (allowDeleteBody.kind === ts4.SyntaxKind.TrueKeyword)
225688
+ route.allowDeleteBody = true;
225689
+ else
225690
+ ctx.diagnostics.push({
225691
+ severity: "error",
225692
+ code: "invalid-delete-body-opt-in",
225693
+ file,
225694
+ message: `Route ${route.handler} allowDeleteBody must be the literal true.`
225695
+ });
225696
+ }
225521
225697
  const legacyResponseExpr = getProp(optionsObject, "response");
225522
225698
  const responsesExpr = getProp(optionsObject, "responses");
225523
225699
  if (legacyResponseExpr !== undefined && responsesExpr !== undefined) {
@@ -226691,7 +226867,7 @@ async function compileProject(options) {
226691
226867
  ...options,
226692
226868
  ...options.cache ? { artifactHashes: options.cache.generatedHashes } : {}
226693
226869
  };
226694
- const written = !hasErrors || options.writeOnError === true ? await generateApplication(graph, generatedOptions) : [];
226870
+ const written = !hasErrors || options.writeOnError === true ? await writeRenderedApplication(rendered, generatedOptions) : [];
226695
226871
  if (!hasErrors) {
226696
226872
  for (const [filename, content] of Object.entries(graphql.files)) {
226697
226873
  const path = join42(options.outDir, filename);
@@ -230052,6 +230228,47 @@ function importSymbol(source, path, symbol) {
230052
230228
  return `import { ${symbol} } from ${JSON.stringify(path)};
230053
230229
  ${source.text}`;
230054
230230
  }
230231
+ function createDiagnosticRepairPlan(diagnostics) {
230232
+ return diagnostics.flatMap((diagnostic) => {
230233
+ const fix = diagnostic.fix;
230234
+ if (!fix)
230235
+ return [];
230236
+ return [{
230237
+ code: diagnostic.code,
230238
+ ...diagnostic.errorCode === undefined ? {} : { errorCode: diagnostic.errorCode },
230239
+ ...diagnostic.file === undefined ? {} : { file: diagnostic.file },
230240
+ ...diagnostic.line === undefined ? {} : { line: diagnostic.line },
230241
+ type: fix.type,
230242
+ targetFile: fix.targetFile,
230243
+ fix,
230244
+ ...classifyFix(fix)
230245
+ }];
230246
+ });
230247
+ }
230248
+ function classifyFix(fix) {
230249
+ switch (fix.type) {
230250
+ case "set_command_mode":
230251
+ if (fix.value !== "required" && fix.value !== "none") {
230252
+ return { readiness: "input-required", reason: "Choose an explicit transaction or idempotency policy; no policy is inferred." };
230253
+ }
230254
+ break;
230255
+ case "add_command_permission":
230256
+ if (!fix.permission?.trim()) {
230257
+ return { readiness: "input-required", reason: "Choose an explicit business permission; privileges are never inferred." };
230258
+ }
230259
+ break;
230260
+ case "add_module_import":
230261
+ if (!fix.importPath || !fix.symbol) {
230262
+ return { readiness: "input-required", reason: "Supply the module import path and exported symbol before previewing." };
230263
+ }
230264
+ break;
230265
+ case "add_route_parameter_binding":
230266
+ break;
230267
+ default:
230268
+ return { readiness: "manual", reason: "The semantic fix executor does not implement this suggestion; edit and verify it manually." };
230269
+ }
230270
+ return { readiness: "preview", reason: "Preview with the semantic fix executor; source preconditions are checked before writing." };
230271
+ }
230055
230272
  init_graphql_inputs();
230056
230273
  var ROUTE_DECORATORS2 = new Set(["Get", "Post", "Put", "Patch", "Delete", "Head", "Options"]);
230057
230274
  var MIGRATION_COMPILER_OPTIONS = {
@@ -230062,10 +230279,7 @@ var MIGRATION_COMPILER_OPTIONS = {
230062
230279
  skipLibCheck: true
230063
230280
  };
230064
230281
  function createContextPack(graph, subject) {
230065
- const subjectModule = graph.modules.find((module) => module.name === subject);
230066
- if (!subjectModule) {
230067
- throw new Error(`No module named "${subject}". Context packs require a module name.`);
230068
- }
230282
+ const subjectModule = resolveContextModule(graph, subject);
230069
230283
  const byName = new Map(graph.modules.map((module) => [module.name, module]));
230070
230284
  const selected = new Set([subjectModule.name]);
230071
230285
  const reverseDependents = new Map;
@@ -230113,6 +230327,7 @@ function createContextPack(graph, subject) {
230113
230327
  module.file,
230114
230328
  ...module.providers.map((provider) => provider.file),
230115
230329
  ...module.controllers.map((controller) => controller.file),
230330
+ ...graph.moduleHandlerFiles?.[module.name] ?? [],
230116
230331
  ...allAspects(module).flatMap((aspect) => aspect.file ? [aspect.file] : [])
230117
230332
  ]).concat(graphql ? [graphql.schema, ...queryDocuments] : []))].sort();
230118
230333
  const referencedTokens = new Set;
@@ -230142,6 +230357,18 @@ function createContextPack(graph, subject) {
230142
230357
  }
230143
230358
  };
230144
230359
  }
230360
+ function resolveContextModule(graph, subject) {
230361
+ const exact = graph.modules.find((module) => module.name === subject);
230362
+ if (exact)
230363
+ return exact;
230364
+ const matches = graph.modules.filter((module) => module.className === subject || module.providers.some((provider) => provider.token === subject || provider.useClass === subject) || module.controllers.some((controller) => controller.className === subject) || module.commands.some((command) => command.name === subject || command.className === subject) || (module.jobs ?? []).some((job) => job.name === subject || job.className === subject || job.serviceKey === subject) || module.queries.some((query) => query.name === subject || query.className === subject));
230365
+ if (matches.length === 1)
230366
+ return matches[0];
230367
+ if (matches.length > 1) {
230368
+ throw new Error(`Ambiguous context target "${subject}". Select a module name: ${matches.map((module) => module.name).sort().join(", ")}`);
230369
+ }
230370
+ throw new Error(`No context target named "${subject}". Select a module name: ${graph.modules.map((module) => module.name).sort().join(", ") || "(none)"}`);
230371
+ }
230145
230372
  function allAspects(module) {
230146
230373
  return [
230147
230374
  ...module.aspects ?? [],
@@ -230620,7 +230847,7 @@ test("partial and untagged inherited remote profiles cannot mix with selected fi
230620
230847
  // ../compiler/package.json
230621
230848
  var package_default = {
230622
230849
  name: "@supacloud/compiler",
230623
- version: "0.25.0",
230850
+ version: "0.26.0",
230624
230851
  description: "Static compiler for @supacloud/app metadata: builds the application graph from AST, validates it, and generates reflection-free factory code",
230625
230852
  type: "module",
230626
230853
  main: "./dist/index.js",
@@ -230685,7 +230912,7 @@ var package_default = {
230685
230912
  // ../app/package.json
230686
230913
  var package_default2 = {
230687
230914
  name: "@supacloud/app",
230688
- version: "0.16.0",
230915
+ version: "0.17.0",
230689
230916
  description: "Angular-style application metadata for SupaCloud: modules, DI tokens, providers, scopes, controllers and commands",
230690
230917
  type: "module",
230691
230918
  main: "./dist/index.js",
@@ -230736,7 +230963,7 @@ var package_default2 = {
230736
230963
  directory: "packages/app"
230737
230964
  },
230738
230965
  dependencies: {
230739
- "@supacloud/contracts": "file:../contracts",
230966
+ "@supacloud/contracts": "0.5.0",
230740
230967
  "@angular/core": "^22.1.5",
230741
230968
  "@sinclair/typebox": "^0.34.52"
230742
230969
  },
@@ -230749,7 +230976,7 @@ var package_default2 = {
230749
230976
  // ../elysia/package.json
230750
230977
  var package_default3 = {
230751
230978
  name: "@supacloud/elysia",
230752
- version: "0.18.0",
230979
+ version: "0.19.0",
230753
230980
  description: "Elysia runtime adapter for SupaCloud compiled modules: application/request scopes, route registration and validation",
230754
230981
  type: "module",
230755
230982
  main: "./dist/index.js",
@@ -230778,6 +231005,7 @@ var package_default3 = {
230778
231005
  "test:conformance": "bun test src/conformance.test.ts",
230779
231006
  "test:runtime-safety": "SUPACLOUD_REQUIRE_RUNTIME_SAFETY=1 bun test src/runtime-safety.test.ts",
230780
231007
  "test:contract-upgrade": "bun test src/contract-upgrade.test.ts",
231008
+ "bench:http-policy": "bun bench/http-policy.ts",
230781
231009
  typecheck: "tsc -p tsconfig.json --noEmit",
230782
231010
  "typecheck:test": "tsc -p tsconfig.test.json --noEmit"
230783
231011
  },
@@ -231971,7 +232199,7 @@ async function runContext(args) {
231971
232199
  compile: "supacloud app compile",
231972
232200
  context: "supacloud app context --format json",
231973
232201
  doctor: "supacloud app doctor",
231974
- fix: "supacloud app fix --fix <fix.json> --write",
232202
+ fix: "supacloud app fix --fix <fix.json>",
231975
232203
  graph: "supacloud app graph --format json",
231976
232204
  explain: "supacloud app explain --target <name>"
231977
232205
  }
@@ -231990,14 +232218,9 @@ async function runContext(args) {
231990
232218
  `));
231991
232219
  }
231992
232220
  function doctorFixPlan(doctor) {
231993
- return (doctor.diagnostics ?? []).filter((diagnostic) => diagnostic.fix !== undefined).map((diagnostic) => ({
231994
- code: diagnostic.code,
231995
- ...diagnostic.errorCode === undefined ? {} : { errorCode: diagnostic.errorCode },
231996
- ...diagnostic.file === undefined ? {} : { file: diagnostic.file },
231997
- ...diagnostic.line === undefined ? {} : { line: diagnostic.line },
231998
- type: diagnostic.fix.type,
231999
- targetFile: diagnostic.fix.targetFile,
232000
- command: "supacloud app fix --fix <fix.json> --write"
232221
+ return createDiagnosticRepairPlan(doctor.diagnostics ?? []).map((repair) => ({
232222
+ ...repair,
232223
+ command: "supacloud app fix --fix <fix.json>"
232001
232224
  }));
232002
232225
  }
232003
232226
  async function findUnwiredContracts(rootDir) {
@@ -232042,9 +232265,12 @@ async function runDoctor(args) {
232042
232265
  const { root, outDir, result } = await projectCompileConfig(args);
232043
232266
  const doctor = doctorProject(root, outDir, result.graph, result.upToDate, result.diagnostics);
232044
232267
  const fixPlan = doctorFixPlan(doctor);
232268
+ const autoFixable = fixPlan.filter((repair) => repair.readiness === "preview").length;
232269
+ const inputRequired = fixPlan.filter((repair) => repair.readiness === "input-required").length;
232270
+ const manualFixes = fixPlan.filter((repair) => repair.readiness === "manual").length;
232045
232271
  const unwiredContracts = await findUnwiredContracts(root);
232046
232272
  if (args.format === "json") {
232047
- return textResult(JSON.stringify({ ok: doctor.errors === 0, autoFixable: fixPlan.length, fixPlan, unwiredContracts, ...doctor }, null, 2), doctor.errors > 0);
232273
+ return textResult(JSON.stringify({ ok: doctor.errors === 0, autoFixable, inputRequired, manualFixes, fixPlan, unwiredContracts, ...doctor }, null, 2), doctor.errors > 0);
232048
232274
  }
232049
232275
  const lines = doctor.checks.map((check) => `${check.ok ? "OK" : "FAIL"} ${check.name}: ${check.detail}`);
232050
232276
  for (const diagnostic of doctor.diagnostics ?? []) {
@@ -232052,8 +232278,14 @@ async function runDoctor(args) {
232052
232278
  }
232053
232279
  lines.push("");
232054
232280
  lines.push(doctor.errors === 0 ? "No blocking issues. Run `supacloud app compile` to refresh generated artifacts." : `${doctor.errors} blocking issue(s). Run \`supacloud app check\` for the full diagnostic list.`);
232055
- if (fixPlan.length > 0) {
232056
- lines.push(`${fixPlan.length} auto-fixable diagnostic(s): run \`supacloud app doctor --format json\`, save each \`fix\`, then \`supacloud app fix --fix <fix.json> --write\`.`);
232281
+ if (autoFixable > 0) {
232282
+ lines.push(`${autoFixable} preview-ready fix(es): run \`supacloud app doctor --format json\`, save each \`fix\`, then preview with \`supacloud app fix --fix <fix.json>\`. Add --write only after review.`);
232283
+ }
232284
+ if (inputRequired > 0 || manualFixes > 0) {
232285
+ lines.push(`${inputRequired} fix(es) require explicit input; ${manualFixes} require manual implementation.`);
232286
+ for (const repair of fixPlan.filter((entry) => entry.readiness !== "preview")) {
232287
+ lines.push(` ${repair.code}: ${repair.reason}`);
232288
+ }
232057
232289
  }
232058
232290
  if (unwiredContracts.length > 0) {
232059
232291
  lines.push(`${unwiredContracts.length} unwired contract file(s): ${unwiredContracts.map((contract) => contract.file).join(", ")}. Import their schemas into a controller route or remove them.`);
@@ -235835,7 +236067,7 @@ function registerRemoteDevTools(server2, options = {}) {
235835
236067
  // package.json
235836
236068
  var package_default4 = {
235837
236069
  name: "@supacloud/cli",
235838
- version: "0.56.2",
236070
+ version: "0.57.0",
235839
236071
  description: "Project-scoped CLI for SupaCloud users",
235840
236072
  type: "module",
235841
236073
  main: "./dist/index.js",
@@ -235868,7 +236100,7 @@ var package_default4 = {
235868
236100
  },
235869
236101
  dependencies: {
235870
236102
  "@sinclair/typebox": "^0.34.52",
235871
- "@supacloud/compiler": "^0.25.0",
236103
+ "@supacloud/compiler": "^0.26.0",
235872
236104
  "@supacloud/db": "^0.2.0",
235873
236105
  fflate: "^0.8.3"
235874
236106
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/cli",
3
- "version": "0.56.2",
3
+ "version": "0.57.0",
4
4
  "description": "Project-scoped CLI for SupaCloud users",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@sinclair/typebox": "^0.34.52",
36
- "@supacloud/compiler": "^0.25.0",
36
+ "@supacloud/compiler": "^0.26.0",
37
37
  "@supacloud/db": "^0.2.0",
38
38
  "fflate": "^0.8.3"
39
39
  },