@supacloud/cli 0.47.0 → 0.48.2

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 +354 -86
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -183699,8 +183699,8 @@ function registerAiTools(server2) {
183699
183699
 
183700
183700
  // src/shared/tools/app-tools.ts
183701
183701
  import { existsSync as existsSync9 } from "node:fs";
183702
- import { mkdir as mkdir2, readFile, writeFile as writeFile2 } from "node:fs/promises";
183703
- import { dirname as dirname4, join as join7, resolve as resolve8 } from "node:path";
183702
+ import { mkdir as mkdir2, readFile, writeFile } from "node:fs/promises";
183703
+ import { dirname as dirname5, join as join7, resolve as resolve8 } from "node:path";
183704
183704
 
183705
183705
  // node_modules/@supacloud/compiler/dist/index.js
183706
183706
  var ts3 = __toESM(require_typescript(), 1);
@@ -183712,12 +183712,18 @@ import { createHash as createHash22 } from "node:crypto";
183712
183712
  import { existsSync as existsSync8, readFileSync as readFileSync6 } from "node:fs";
183713
183713
  import { dirname as dirname3, join as join6, resolve as resolve7 } from "node:path";
183714
183714
  import { createHash as createHash4 } from "node:crypto";
183715
+ var ts4 = __toESM(require_typescript(), 1);
183715
183716
  import { createHash as createHash42 } from "node:crypto";
183716
- import { access, mkdir, rename, unlink, writeFile } from "node:fs/promises";
183717
+ import { access, mkdir, rename as rename2, unlink as unlink2, writeFile as writeFile2 } from "node:fs/promises";
183717
183718
  import { join as join22 } from "node:path";
183718
- var ts4 = __toESM(require_typescript(), 1);
183719
+ import { dirname as dirname32, relative as relative32, sep as sep32 } from "node:path";
183720
+ var ts5 = __toESM(require_typescript(), 1);
183719
183721
  import { existsSync as existsSync22, readFileSync as readFileSync22 } from "node:fs";
183720
- import { dirname as dirname22, join as join32, relative as relative22, resolve as resolve22, sep as sep22 } from "node:path";
183722
+ import { dirname as dirname4, join as join32, relative as relative4, resolve as resolve32, sep as sep4 } from "node:path";
183723
+ import { existsSync as existsSync52 } from "node:fs";
183724
+ import { join as join62, resolve as resolve62 } from "node:path";
183725
+ import { pathToFileURL } from "node:url";
183726
+
183721
183727
  class TraitCompiler {
183722
183728
  handlers;
183723
183729
  constructor(handlers = createDefaultTraitHandlers()) {
@@ -183807,6 +183813,15 @@ function createDefaultTraitHandlers() {
183807
183813
  return initializer && ts.isCallExpression(initializer) && expressionName(initializer.expression) === "defineModule" ? node.name.text : undefined;
183808
183814
  }
183809
183815
  },
183816
+ {
183817
+ kind: "defineFeatureSlice",
183818
+ detect: (node) => {
183819
+ if (!ts.isVariableDeclaration(node) || !ts.isIdentifier(node.name))
183820
+ return;
183821
+ const initializer = node.initializer;
183822
+ return initializer && ts.isCallExpression(initializer) && expressionName(initializer.expression) === "defineFeatureSlice" ? node.name.text : undefined;
183823
+ }
183824
+ },
183810
183825
  {
183811
183826
  kind: "injectionToken",
183812
183827
  detect: (node) => {
@@ -184149,6 +184164,7 @@ async function analyzeProject(rootDir, include, cache, changedPaths) {
184149
184164
  checker,
184150
184165
  tokensByName: new Map,
184151
184166
  classesByName: new Map,
184167
+ variablesByName: new Map,
184152
184168
  diagnostics: []
184153
184169
  };
184154
184170
  const nativeTraitFiles = new Map;
@@ -184183,9 +184199,9 @@ async function analyzeProject(rootDir, include, cache, changedPaths) {
184183
184199
  });
184184
184200
  }
184185
184201
  }
184186
- if (!cache || traits?.has("defineModule")) {
184202
+ if (!cache || traits?.has("defineModule") || traits?.has("defineFeatureSlice")) {
184187
184203
  for (const call of descendantsOfKind(sf, ts3.isCallExpression)) {
184188
- if (nodeText(call.expression) !== "defineModule")
184204
+ if (!["defineModule", "defineFeatureSlice"].includes(nodeText(call.expression)))
184189
184205
  continue;
184190
184206
  const parent = call.parent;
184191
184207
  if (!parent || !ts3.isVariableDeclaration(parent))
@@ -184491,6 +184507,9 @@ function indexFile(sf, ctx) {
184491
184507
  }
184492
184508
  for (const statement of sf.statements.filter(ts3.isVariableStatement)) {
184493
184509
  for (const decl of statement.declarationList.declarations) {
184510
+ if (ts3.isIdentifier(decl.name) && !ctx.variablesByName.has(decl.name.text)) {
184511
+ ctx.variablesByName.set(decl.name.text, decl);
184512
+ }
184494
184513
  const info = parseTokenVariable(decl, sf.fileName);
184495
184514
  if (info && !ctx.tokensByName.has(info.name)) {
184496
184515
  ctx.tokensByName.set(info.name, info);
@@ -184518,8 +184537,8 @@ function parseTokenVariable(decl, file) {
184518
184537
  if (providedIn === "root") {
184519
184538
  info.providedIn = "root";
184520
184539
  }
184521
- const factory = getProp(optionsArg, "factory");
184522
- if (factory) {
184540
+ const factory2 = getProp(optionsArg, "factory");
184541
+ if (factory2) {
184523
184542
  info.hasFactory = true;
184524
184543
  }
184525
184544
  }
@@ -184528,6 +184547,7 @@ function parseTokenVariable(decl, file) {
184528
184547
  function parseModule(candidate, nameByNode, ctx) {
184529
184548
  const { options, className, file, line } = candidate;
184530
184549
  const name = nameByNode.get(candidate.node) ?? className;
184550
+ const featureSpec = parseFeatureSpec(getProp(options, "spec"), ctx);
184531
184551
  const tags = arrayProp(options, "tags").map((el) => ts3.isStringLiteral(el) ? el.text : nodeText(el).replace(/['"]/g, "")).filter(Boolean);
184532
184552
  const aspects = parseAspectRefs(getProp(options, "aspects"), ctx, `module ${name}`);
184533
184553
  const imports = arrayProp(options, "imports").map((el) => {
@@ -184702,8 +184722,71 @@ function parseModule(candidate, nameByNode, ctx) {
184702
184722
  jobs,
184703
184723
  queries,
184704
184724
  ...aspects.length > 0 ? { aspects } : {},
184705
- exports
184725
+ exports,
184726
+ ...featureSpec ? { featureSpec } : {}
184727
+ };
184728
+ }
184729
+ function parseFeatureSpec(input, ctx, seen = new Set) {
184730
+ if (!input)
184731
+ return;
184732
+ if (seen.has(input))
184733
+ return;
184734
+ seen.add(input);
184735
+ if (ts3.isIdentifier(input)) {
184736
+ const local = input.getSourceFile().statements.flatMap((statement) => ts3.isVariableStatement(statement) ? [...statement.declarationList.declarations] : []);
184737
+ const resolved = resolveDeclaration(input, ctx)[0];
184738
+ const decl = (resolved && ts3.isVariableDeclaration(resolved) ? resolved : undefined) ?? ctx.variablesByName.get(input.text) ?? local.find((candidate) => ts3.isIdentifier(candidate.name) && candidate.name.text === input.text) ?? descendantsOfKind(input.getSourceFile(), ts3.isVariableDeclaration).find((candidate) => ts3.isIdentifier(candidate.name) && candidate.name.text === input.text);
184739
+ if (decl && ts3.isVariableDeclaration(decl))
184740
+ return parseFeatureSpec(decl.initializer, ctx, seen);
184741
+ }
184742
+ if (ts3.isCallExpression(input) && nodeText(input.expression) === "defineFeatureSpec") {
184743
+ return parseFeatureSpec(input.arguments[0], ctx, seen);
184744
+ }
184745
+ if (ts3.isAsExpression(input) || ts3.isSatisfiesExpression(input) || ts3.isParenthesizedExpression(input)) {
184746
+ return parseFeatureSpec(input.expression, ctx, seen);
184747
+ }
184748
+ const invalid = () => {
184749
+ ctx.diagnostics.push({
184750
+ severity: "error",
184751
+ code: "invalid-feature-spec",
184752
+ message: "Feature spec must use static name, states and transition objects.",
184753
+ file: sourcePath(ctx.rootDir, input.getSourceFile().fileName),
184754
+ line: lineOf(input)
184755
+ });
184756
+ return;
184706
184757
  };
184758
+ if (!ts3.isObjectLiteralExpression(input))
184759
+ return invalid();
184760
+ const name = stringLiteralProp(input, "name");
184761
+ const statesExpr = getProp(input, "states");
184762
+ const transitionObject = getProp(input, "transitions");
184763
+ if (!name || !statesExpr || !ts3.isArrayLiteralExpression(statesExpr) || statesExpr.elements.some((state) => !ts3.isStringLiteral(state)) || !transitionObject || !ts3.isObjectLiteralExpression(transitionObject) || input.properties.some((property) => !ts3.isPropertyAssignment(property))) {
184764
+ return invalid();
184765
+ }
184766
+ const states = statesExpr.elements.map((state) => state.text);
184767
+ const transitions = [];
184768
+ for (const property of transitionObject.properties) {
184769
+ if (!ts3.isPropertyAssignment(property) || ts3.isComputedPropertyName(property.name) || !ts3.isObjectLiteralExpression(property.initializer))
184770
+ return invalid();
184771
+ const options = property.initializer;
184772
+ const from = stringLiteralProp(options, "from");
184773
+ const to = stringLiteralProp(options, "to");
184774
+ if (!from || !to || options.properties.some((prop) => !ts3.isPropertyAssignment(prop)) || ["permission", "command", "route", "audit"].some((key) => getProp(options, key) && !stringLiteralProp(options, key)) || ["transaction", "idempotency"].some((key) => getProp(options, key) && !commandModeProp(options, key))) {
184775
+ return invalid();
184776
+ }
184777
+ transitions.push({
184778
+ name: propertyName(property.name),
184779
+ from,
184780
+ to,
184781
+ permission: stringLiteralProp(options, "permission"),
184782
+ command: stringLiteralProp(options, "command"),
184783
+ route: stringLiteralProp(options, "route"),
184784
+ transaction: commandModeProp(options, "transaction"),
184785
+ idempotency: commandModeProp(options, "idempotency"),
184786
+ audit: stringLiteralProp(options, "audit")
184787
+ });
184788
+ }
184789
+ return { name, states, transitions, file: sourcePath(ctx.rootDir, input.getSourceFile().fileName), line: lineOf(input) };
184707
184790
  }
184708
184791
  function commandModeProp(object, name) {
184709
184792
  const value = stringLiteralProp(object, name);
@@ -185874,6 +185957,54 @@ function sourcePath(rootDir, absFile) {
185874
185957
  function warn(ctx, code, message, file, line) {
185875
185958
  ctx.diagnostics.push({ severity: "warn", code, message, file, line });
185876
185959
  }
185960
+ function validateFeatureSpec(spec, module) {
185961
+ const diagnostics = [];
185962
+ const error = (code, message) => {
185963
+ diagnostics.push({ severity: "error", code, message, file: spec.file, line: spec.line });
185964
+ };
185965
+ if (!spec.name.trim() || spec.states.length === 0 || spec.states.some((state) => !state.trim()) || new Set(spec.states).size !== spec.states.length) {
185966
+ error("invalid-feature-states", "Feature name and states must be non-empty; states must be unique.");
185967
+ }
185968
+ const names = new Set;
185969
+ for (const transition of spec.transitions) {
185970
+ if (!transition.name.trim() || names.has(transition.name)) {
185971
+ error("duplicate-feature-transition", `Feature ${spec.name} has duplicate/empty transition '${transition.name}'.`);
185972
+ }
185973
+ names.add(transition.name);
185974
+ if (!spec.states.includes(transition.from) || !spec.states.includes(transition.to)) {
185975
+ error("invalid-feature-transition", `Transition ${transition.name} references an undeclared state.`);
185976
+ }
185977
+ if (transition.permission !== undefined && !transition.permission.trim()) {
185978
+ error("feature-governance-drift", `Transition ${transition.name} declares an empty permission.`);
185979
+ }
185980
+ if (!module)
185981
+ continue;
185982
+ const commands = module.commands.filter((command2) => command2.className === transition.command || command2.name === transition.command);
185983
+ const command = commands[0];
185984
+ if (transition.command && commands.length !== 1) {
185985
+ error("feature-command-unresolved", `Transition ${transition.name} must reference exactly one command in module ${module.name}.`);
185986
+ }
185987
+ if (!transition.command && [transition.permission, transition.transaction, transition.idempotency, transition.audit].some((value) => value !== undefined)) {
185988
+ error("feature-command-unresolved", `Transition ${transition.name} declares governance without a command binding.`);
185989
+ }
185990
+ if (command) {
185991
+ for (const key of ["permission", "transaction", "idempotency", "audit"]) {
185992
+ if (transition[key] !== undefined && transition[key] !== command[key]) {
185993
+ error("feature-governance-drift", `Transition ${transition.name} ${key} differs from command ${command.className}.`);
185994
+ }
185995
+ }
185996
+ }
185997
+ if (transition.route) {
185998
+ const routes = module.controllers.flatMap((controller) => controller.routes.filter((route) => `${route.method} ${joinRoutePaths(controller.path, route.path)}` === transition.route));
185999
+ if (routes.length !== 1) {
186000
+ error("feature-route-unresolved", `Transition ${transition.name} must reference exactly one route '${transition.route}' in module ${module.name}.`);
186001
+ } else if (command && routes[0].command !== command.className) {
186002
+ error("feature-route-drift", `Route ${transition.route} is not bound to ${command.className}.`);
186003
+ }
186004
+ }
186005
+ }
186006
+ return diagnostics;
186007
+ }
185877
186008
  var HEADER = "// GENERATED BY @supacloud/compiler — do not edit";
185878
186009
  var INTERFACES = `export interface CompiledRoute {
185879
186010
  method: string;
@@ -186173,10 +186304,10 @@ async function writeFileIfChanged(path, content, hashes) {
186173
186304
  async function writeFileAtomic(path, content) {
186174
186305
  const temporaryPath = `${path}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
186175
186306
  try {
186176
- await writeFile(temporaryPath, content, "utf8");
186177
- await rename(temporaryPath, path);
186307
+ await writeFile2(temporaryPath, content, "utf8");
186308
+ await rename2(temporaryPath, path);
186178
186309
  } catch (error) {
186179
- await unlink(temporaryPath).catch(() => {
186310
+ await unlink2(temporaryPath).catch(() => {
186180
186311
  return;
186181
186312
  });
186182
186313
  throw error;
@@ -186581,10 +186712,10 @@ ${indent(item, 2)}`).join(",")}
186581
186712
  const constLine = `const ${local2} = resolveFactoryValue(${tokenIdent});`;
186582
186713
  return { constLine, key, expr: local2 };
186583
186714
  }
186584
- const factory = this.imports.add(provider.useFactoryName ?? "", provider.importPath, provider.importModule);
186715
+ const factory2 = this.imports.add(provider.useFactoryName ?? "", provider.importPath, provider.importModule);
186585
186716
  const args = provider.deps.map((dep) => this.depExpr(dep, kind, this.depOptions(provider, dep))).join(", ");
186586
186717
  const local = this.localVar(isMulti ? provider.useFactoryName ?? `${provider.token}Item` : provider.token, kind);
186587
- return { constLine: `const ${local} = ${factory}(${args});`, key, expr: local };
186718
+ return { constLine: `const ${local} = ${factory2}(${args});`, key, expr: local };
186588
186719
  }
186589
186720
  case "existing": {
186590
186721
  return {
@@ -187161,6 +187292,7 @@ var COMPILER_DIAGNOSTIC_CODES = {
187161
187292
  "invalid-http-method-body": { code: "SC3004", docsUrl: "https://supacloud.dev/errors/SC3004" },
187162
187293
  "unmatched-route-parameter": { code: "SC3005", docsUrl: "https://supacloud.dev/errors/SC3005" },
187163
187294
  "missing-route-parameter-binding": { code: "SC3006", docsUrl: "https://supacloud.dev/errors/SC3006" },
187295
+ "missing-path-param": { code: "SC3006", docsUrl: "https://supacloud.dev/errors/SC3006" },
187164
187296
  "duplicate-route": { code: "SC3007", docsUrl: "https://supacloud.dev/errors/SC3007" },
187165
187297
  "missing-body-schema": { code: "SC3008", docsUrl: "https://supacloud.dev/errors/SC3008" },
187166
187298
  "unused-route-schema": { code: "SC3009", docsUrl: "https://supacloud.dev/errors/SC3009" },
@@ -187171,6 +187303,7 @@ var COMPILER_DIAGNOSTIC_CODES = {
187171
187303
  "unmatched-path-param-decorator": { code: "SC3014", docsUrl: "https://supacloud.dev/errors/SC3014" },
187172
187304
  "invalid-query-default-type": { code: "SC3015", docsUrl: "https://supacloud.dev/errors/SC3015" },
187173
187305
  "disallowed-body-on-get-delete": { code: "SC3016", docsUrl: "https://supacloud.dev/errors/SC3016" },
187306
+ "invalid-body-binding": { code: "SC3016", docsUrl: "https://supacloud.dev/errors/SC3016" },
187174
187307
  "duplicate-query-param-binding": { code: "SC3017", docsUrl: "https://supacloud.dev/errors/SC3017" },
187175
187308
  "conflicting-route-method": { code: "SC3018", docsUrl: "https://supacloud.dev/errors/SC3018" },
187176
187309
  "missing-param-colon": { code: "SC3019", docsUrl: "https://supacloud.dev/errors/SC3019" },
@@ -187186,7 +187319,15 @@ var COMPILER_DIAGNOSTIC_CODES = {
187186
187319
  "invalid-job-scope": { code: "SC4007", docsUrl: "https://supacloud.dev/errors/SC4007" },
187187
187320
  "dynamic-aspect-reference": { code: "SC4010", docsUrl: "https://supacloud.dev/errors/SC4010" },
187188
187321
  "invalid-aspect-reference": { code: "SC4011", docsUrl: "https://supacloud.dev/errors/SC4011" },
187189
- "unused-root-provider": { code: "SC5001", docsUrl: "https://supacloud.dev/errors/SC5001" }
187322
+ "unused-root-provider": { code: "SC5001", docsUrl: "https://supacloud.dev/errors/SC5001" },
187323
+ "invalid-feature-states": { code: "SC6001", docsUrl: "https://supacloud.dev/errors/SC6001" },
187324
+ "duplicate-feature-transition": { code: "SC6002", docsUrl: "https://supacloud.dev/errors/SC6002" },
187325
+ "invalid-feature-transition": { code: "SC6003", docsUrl: "https://supacloud.dev/errors/SC6003" },
187326
+ "feature-command-unresolved": { code: "SC6004", docsUrl: "https://supacloud.dev/errors/SC6004" },
187327
+ "feature-governance-drift": { code: "SC6005", docsUrl: "https://supacloud.dev/errors/SC6005" },
187328
+ "feature-route-unresolved": { code: "SC6006", docsUrl: "https://supacloud.dev/errors/SC6006" },
187329
+ "feature-route-drift": { code: "SC6007", docsUrl: "https://supacloud.dev/errors/SC6007" },
187330
+ "invalid-feature-spec": { code: "SC6008", docsUrl: "https://supacloud.dev/errors/SC6008" }
187190
187331
  };
187191
187332
  function validateGraph(graph, options = false) {
187192
187333
  const strict = typeof options === "boolean" ? options : options.strict ?? false;
@@ -187242,7 +187383,7 @@ function validateGraph(graph, options = false) {
187242
187383
  }
187243
187384
  return;
187244
187385
  }
187245
- const error = (code, message, file, line, suggestion) => {
187386
+ const error = (code, message, file, line, suggestion, fix) => {
187246
187387
  const meta = COMPILER_DIAGNOSTIC_CODES[code];
187247
187388
  diagnostics.push({
187248
187389
  severity: "error",
@@ -187252,10 +187393,11 @@ function validateGraph(graph, options = false) {
187252
187393
  line,
187253
187394
  suggestion,
187254
187395
  errorCode: meta?.code,
187255
- docsUrl: meta?.docsUrl
187396
+ docsUrl: meta?.docsUrl,
187397
+ fix
187256
187398
  });
187257
187399
  };
187258
- const warn2 = (code, message, file, line, suggestion) => {
187400
+ const warn2 = (code, message, file, line, suggestion, fix) => {
187259
187401
  const meta = COMPILER_DIAGNOSTIC_CODES[code];
187260
187402
  diagnostics.push({
187261
187403
  severity: strict ? "error" : "warn",
@@ -187265,7 +187407,8 @@ function validateGraph(graph, options = false) {
187265
187407
  line,
187266
187408
  suggestion,
187267
187409
  errorCode: meta?.code,
187268
- docsUrl: meta?.docsUrl
187410
+ docsUrl: meta?.docsUrl,
187411
+ fix
187269
187412
  });
187270
187413
  };
187271
187414
  const modulesByName = new Map;
@@ -187273,6 +187416,12 @@ function validateGraph(graph, options = false) {
187273
187416
  const routesByKey = new Map;
187274
187417
  const declaredRoutes = [];
187275
187418
  for (const module of graph.modules) {
187419
+ if (module.featureSpec) {
187420
+ for (const diagnostic of validateFeatureSpec(module.featureSpec, module)) {
187421
+ const meta = COMPILER_DIAGNOSTIC_CODES[diagnostic.code];
187422
+ diagnostics.push({ ...diagnostic, errorCode: meta?.code, docsUrl: meta?.docsUrl });
187423
+ }
187424
+ }
187276
187425
  const previousModule = modulesByName.get(module.name);
187277
187426
  if (previousModule) {
187278
187427
  error("duplicate-module", `模块名 ${module.name} 重复(首次声明于 ${previousModule.file}:${previousModule.line})`, module.file, module.line);
@@ -187365,7 +187514,14 @@ function validateGraph(graph, options = false) {
187365
187514
  if (paramBindings.length > 0) {
187366
187515
  for (const param of pathParams) {
187367
187516
  if (!paramBindings.includes(param)) {
187368
- warn2("missing-path-param", `Route path '${route.path}' defines parameter ':${param}', but handler ${controller.className}.${route.handler} does not bind it with @Param('${param}').`, controller.file, undefined, `Add @Param('${param}') to ${route.handler} arguments.`);
187517
+ warn2("missing-path-param", `Route path '${route.path}' defines parameter ':${param}', but handler ${controller.className}.${route.handler} does not bind it with @Param('${param}').`, controller.file, undefined, `Add @Param('${param}') to ${route.handler} arguments.`, {
187518
+ type: "add_route_parameter_binding",
187519
+ targetFile: controller.file,
187520
+ controller: controller.className,
187521
+ route: route.handler,
187522
+ parameter: param,
187523
+ binding: "param"
187524
+ });
187369
187525
  }
187370
187526
  }
187371
187527
  }
@@ -187392,10 +187548,20 @@ function validateGraph(graph, options = false) {
187392
187548
  }
187393
187549
  }
187394
187550
  if ((route.method === "GET" || route.method === "HEAD" || route.method === "OPTIONS" || route.method === "DELETE") && (route.hasBodyBinding || route.body)) {
187395
- 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().`);
187551
+ 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().`, {
187552
+ type: "remove_route_body_binding",
187553
+ targetFile: controller.file,
187554
+ controller: controller.className,
187555
+ route: route.handler
187556
+ });
187396
187557
  }
187397
187558
  if (route.hasBodyBinding && (route.method === "GET" || route.method === "HEAD" || route.method === "OPTIONS")) {
187398
- error("invalid-body-binding", `Route handler ${controller.className}.${route.handler} binds @Body() 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().`);
187559
+ error("invalid-body-binding", `Route handler ${controller.className}.${route.handler} binds @Body() 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().`, {
187560
+ type: "remove_route_body_binding",
187561
+ targetFile: controller.file,
187562
+ controller: controller.className,
187563
+ route: route.handler
187564
+ });
187399
187565
  } else if (route.hasBodyBinding && !route.body) {
187400
187566
  warn2("missing-body-schema", `Route handler ${controller.className}.${route.handler} binds @Body() on route '${route.path}', but route definition does not specify a body validation schema.`, controller.file, undefined, `Add schema to route options (e.g. body: Schema) for compile-time and runtime validation.`);
187401
187567
  } else if (route.body && !route.hasBodyBinding && !route.command) {
@@ -187536,23 +187702,51 @@ function validateGraph(graph, options = false) {
187536
187702
  const owner = globalProviders.get(dep);
187537
187703
  if (!owner)
187538
187704
  continue;
187539
- error("module-boundary", `模块 ${module.name} 的 provider ${provider.token} 依赖 ${dep},该 token 由模块 ${owner.module.name} 提供但未被 import`, provider.file, provider.line, `Import module '${owner.module.name}' in '${module.name}', add '${dep}' to '${owner.module.name}' exports, or mark @Injectable({ providedIn: 'root' }).`);
187705
+ error("module-boundary", `模块 ${module.name} 的 provider ${provider.token} 依赖 ${dep},该 token 由模块 ${owner.module.name} 提供但未被 import`, provider.file, provider.line, `Import module '${owner.module.name}' in '${module.name}', add '${dep}' to '${owner.module.name}' exports, or mark @Injectable({ providedIn: 'root' }).`, {
187706
+ type: "add_module_import",
187707
+ targetFile: module.file,
187708
+ module: owner.module.name,
187709
+ provider: dep,
187710
+ symbol: owner.module.className,
187711
+ targetModule: module.name,
187712
+ importPath: (() => {
187713
+ const value = relative32(dirname32(module.file), owner.module.file).replace(/\.(tsx?|mts|cts)$/, "").split(sep32).join("/");
187714
+ return value.startsWith(".") ? value : `./${value}`;
187715
+ })()
187716
+ });
187540
187717
  } else if (dep.includes("TOKEN") || dep.endsWith("Token") || dep.length > 2 && dep === dep.toUpperCase()) {
187541
187718
  error("missing-token-factory", `InjectionToken '${dep}' referenced by provider '${provider.token}' has no provider in module '${module.name}' and no default factory function.`, provider.file, provider.line, `Provide '${dep}' in @Module({ providers: [...] }) or declare it with new InjectionToken('${dep}', { factory: () => ... }).`);
187542
187719
  } else {
187543
- error("unresolved-token", `模块 ${module.name} 的 provider ${provider.token} 依赖的 token ${dep} 无法解析`, provider.file, provider.line, `Provide '${dep}' in a module, mark constructor parameter @Optional(), or define @Injectable({ providedIn: 'root' }).`);
187720
+ error("unresolved-token", `模块 ${module.name} 的 provider ${provider.token} 依赖的 token ${dep} 无法解析`, provider.file, provider.line, `Provide '${dep}' in a module, mark constructor parameter @Optional(), or define @Injectable({ providedIn: 'root' }).`, {
187721
+ type: "add_provider",
187722
+ targetFile: module.file,
187723
+ token: dep,
187724
+ module: module.name
187725
+ });
187544
187726
  }
187545
187727
  }
187546
187728
  continue;
187547
187729
  }
187548
187730
  if (SCOPE_LIFETIME_RANK[resolved.provider.scope] > SCOPE_LIFETIME_RANK[provider.scope]) {
187549
- error("scope-violation", `模块 ${module.name} 的 ${provider.scope} provider ${provider.token} 不能依赖 ${resolved.provider.scope} provider ${dep}`, provider.file, provider.line, `Change provider '${provider.token}' scope to '${resolved.provider.scope}', or inject a factory/context instead.`);
187731
+ error("scope-violation", `模块 ${module.name} 的 ${provider.scope} provider ${provider.token} 不能依赖 ${resolved.provider.scope} provider ${dep}`, provider.file, provider.line, `Change provider '${provider.token}' scope to '${resolved.provider.scope}', or inject a factory/context instead.`, {
187732
+ type: "change_provider_scope",
187733
+ targetFile: provider.file,
187734
+ provider: provider.token,
187735
+ from: provider.scope,
187736
+ to: resolved.provider.scope
187737
+ });
187550
187738
  }
187551
187739
  }
187552
187740
  }
187553
187741
  for (const command of module.commands) {
187554
187742
  if (!command.permission) {
187555
- error("command-missing-permission", `模块 ${module.name} 的 command ${command.name} (${command.className}) 未声明 permission`, module.file, module.line, "Add 'permission: string' to @Command({ ... }) or configure command execution capabilities permission=false.");
187743
+ error("command-missing-permission", `模块 ${module.name} 的 command ${command.name} (${command.className}) 未声明 permission`, module.file, module.line, "Add 'permission: string' to @Command({ ... }) or configure command execution capabilities permission=false.", {
187744
+ type: "add_command_permission",
187745
+ targetFile: module.providers.find((provider) => provider.useClass === command.className || provider.token === command.className)?.file ?? module.file,
187746
+ command: command.className,
187747
+ module: module.name,
187748
+ permission: `${module.name}.${command.name}`
187749
+ });
187556
187750
  }
187557
187751
  if (typeof options === "object" && options.commandCapabilities) {
187558
187752
  const caps = options.commandCapabilities;
@@ -187922,7 +188116,7 @@ function scanGeneratedArtifacts(artifacts, strict = true) {
187922
188116
  for (const [file, content] of Object.entries(artifacts)) {
187923
188117
  if (content === undefined)
187924
188118
  continue;
187925
- const sourceFile = ts4.createSourceFile(file, content, ts4.ScriptTarget.Latest, true, ts4.ScriptKind.TS);
188119
+ const sourceFile = ts5.createSourceFile(file, content, ts5.ScriptTarget.Latest, true, ts5.ScriptKind.TS);
187926
188120
  for (const node of descendantsOfKind2(sourceFile, isAnyKeyword)) {
187927
188121
  diagnostics.push(makeDiagnostic("generated-any", `生成产物 ${file} 包含 any;严格生成模式要求使用 unknown、具体接口或泛型约束。`, sourceFile, node, strict));
187928
188122
  }
@@ -187930,30 +188124,30 @@ function scanGeneratedArtifacts(artifacts, strict = true) {
187930
188124
  return diagnostics;
187931
188125
  }
187932
188126
  function scanProductionSource(options) {
187933
- const rootDir = resolve22(options.rootDir);
188127
+ const rootDir = resolve32(options.rootDir);
187934
188128
  const configPath = join32(rootDir, "tsconfig.json");
187935
188129
  const projectConfig = existsSync22(configPath) ? readProjectConfig2(configPath) : {
187936
188130
  options: {
187937
188131
  strict: true,
187938
188132
  skipLibCheck: true,
187939
- target: ts4.ScriptTarget.ES2022,
187940
- module: ts4.ModuleKind.ESNext
188133
+ target: ts5.ScriptTarget.ES2022,
188134
+ module: ts5.ModuleKind.ESNext
187941
188135
  },
187942
188136
  errors: []
187943
188137
  };
187944
188138
  const include = options.include ?? ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"];
187945
- const rootNames = ts4.sys.readDirectory(rootDir, [".ts", ".tsx", ".mts", ".cts"], ["node_modules", "dist"], include).filter((file) => isProductionSourcePath(rootDir, file, [...DEFAULT_EXCLUDES, ...options.exclude ?? []]));
188139
+ const rootNames = ts5.sys.readDirectory(rootDir, [".ts", ".tsx", ".mts", ".cts"], ["node_modules", "dist"], include).filter((file) => isProductionSourcePath(rootDir, file, [...DEFAULT_EXCLUDES, ...options.exclude ?? []]));
187946
188140
  const compilerOptions = { ...projectConfig.options, noEmit: true };
187947
- const host = ts4.createCompilerHost(compilerOptions);
188141
+ const host = ts5.createCompilerHost(compilerOptions);
187948
188142
  host.getCurrentDirectory = () => rootDir;
187949
- const program = ts4.createProgram(rootNames, compilerOptions, host);
188143
+ const program = ts5.createProgram(rootNames, compilerOptions, host);
187950
188144
  const outDir = options.outDir ? normalizeRelative(rootDir, options.outDir) : undefined;
187951
188145
  const excludes = [...DEFAULT_EXCLUDES, ...options.exclude ?? []];
187952
188146
  const sourceFiles = program.getSourceFiles().filter((sourceFile) => isProductionSource(rootDir, sourceFile, excludes, outDir));
187953
188147
  const diagnostics = [...projectConfig.errors, ...program.getOptionsDiagnostics()].map((diagnostic) => ({
187954
188148
  severity: "error",
187955
188149
  code: "source-config",
187956
- message: ts4.flattenDiagnosticMessageText(diagnostic.messageText, `
188150
+ message: ts5.flattenDiagnosticMessageText(diagnostic.messageText, `
187957
188151
  `),
187958
188152
  file: diagnostic.file ? normalizeRelative(rootDir, diagnostic.file.fileName) : normalizeRelative(rootDir, configPath),
187959
188153
  line: diagnostic.file && diagnostic.start !== undefined ? diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start).line + 1 : undefined,
@@ -187970,22 +188164,22 @@ function scanSourceFile(sourceFile, checker, rootDir, diagnostics, strict) {
187970
188164
  diagnostics.push(makeDiagnostic("source-any", "生产源码使用了显式 any;请改用 unknown、具体接口或泛型约束。", sourceFile, node, strict, rootDir));
187971
188165
  }
187972
188166
  for (const node of descendants(sourceFile)) {
187973
- if (ts4.isAsExpression(node)) {
187974
- if (ts4.isAsExpression(node.parent) || ts4.isTypeAssertionExpression(node.parent))
188167
+ if (ts5.isAsExpression(node)) {
188168
+ if (ts5.isAsExpression(node.parent) || ts5.isTypeAssertionExpression(node.parent))
187975
188169
  continue;
187976
188170
  const assertedType = node.type.getText(sourceFile);
187977
188171
  if (assertedType === "const")
187978
188172
  continue;
187979
188173
  diagnostics.push(makeDiagnostic("source-type-assertion", `生产源码包含类型断言 ${node.getText(sourceFile)};请优先使用类型守卫、satisfies 或显式边界解析。`, sourceFile, node, strict, rootDir));
187980
- } else if (ts4.isTypeAssertionExpression(node)) {
187981
- if (ts4.isAsExpression(node.parent) || ts4.isTypeAssertionExpression(node.parent))
188174
+ } else if (ts5.isTypeAssertionExpression(node)) {
188175
+ if (ts5.isAsExpression(node.parent) || ts5.isTypeAssertionExpression(node.parent))
187982
188176
  continue;
187983
188177
  diagnostics.push(makeDiagnostic("source-type-assertion", `生产源码包含类型断言 ${node.getText(sourceFile)};请优先使用类型守卫、satisfies 或显式边界解析。`, sourceFile, node, strict, rootDir));
187984
- } else if (ts4.isNonNullExpression(node)) {
188178
+ } else if (ts5.isNonNullExpression(node)) {
187985
188179
  diagnostics.push(makeDiagnostic("source-non-null-assertion", `生产源码包含非空断言 ${node.getText(sourceFile)};请显式处理 null/undefined。`, sourceFile, node, strict, rootDir));
187986
188180
  }
187987
188181
  }
187988
- for (const declaration of descendantsOfKind2(sourceFile, ts4.isVariableDeclaration)) {
188182
+ for (const declaration of descendantsOfKind2(sourceFile, ts5.isVariableDeclaration)) {
187989
188183
  const initializer = declaration.initializer;
187990
188184
  if (!initializer || declaration.type)
187991
188185
  continue;
@@ -188001,11 +188195,11 @@ function scanSourceFile(sourceFile, checker, rootDir, diagnostics, strict) {
188001
188195
  if (isLetDeclaration(declaration) && isLiteralSyntax(initializer) && !isLiteralType(declarationType)) {
188002
188196
  diagnostics.push(makeDiagnostic("source-implicit-widening", `变量 ${declaration.name.getText(sourceFile)} 的字面量类型从 ${checker.typeToString(initializerType, initializer)} 隐式宽化为 ${checker.typeToString(declarationType, declaration)};请补充类型或使用 const。`, sourceFile, declaration, strict, rootDir));
188003
188197
  }
188004
- if (ts4.isObjectLiteralExpression(initializer) && isConstDeclaration(declaration) && initializer.getText(sourceFile).length > 0 && initializer.properties.some((property) => ts4.isPropertyAssignment(property) && property.initializer !== undefined && !ts4.isAsExpression(property.initializer) && isLiteralExpression(property.initializer))) {
188198
+ if (ts5.isObjectLiteralExpression(initializer) && isConstDeclaration(declaration) && initializer.getText(sourceFile).length > 0 && initializer.properties.some((property2) => ts5.isPropertyAssignment(property2) && property2.initializer !== undefined && !ts5.isAsExpression(property2.initializer) && isLiteralExpression(property2.initializer))) {
188005
188199
  diagnostics.push(makeDiagnostic("source-implicit-widening", `常量对象 ${declaration.name.getText(sourceFile)} 的字面量属性会隐式宽化;请补充对象类型或使用 as const。`, sourceFile, declaration, strict, rootDir));
188006
188200
  }
188007
188201
  }
188008
- for (const parameter of descendantsOfKind2(sourceFile, ts4.isParameter)) {
188202
+ for (const parameter of descendantsOfKind2(sourceFile, ts5.isParameter)) {
188009
188203
  if (parameter.type)
188010
188204
  continue;
188011
188205
  for (const name of bindingNames(parameter.name)) {
@@ -188016,10 +188210,10 @@ function scanSourceFile(sourceFile, checker, rootDir, diagnostics, strict) {
188016
188210
  }
188017
188211
  }
188018
188212
  function readProjectConfig2(configPath) {
188019
- const config = ts4.readConfigFile(configPath, (file) => readFileSync22(file, "utf8"));
188213
+ const config = ts5.readConfigFile(configPath, (file) => readFileSync22(file, "utf8"));
188020
188214
  if (config.error)
188021
188215
  return { options: {}, errors: [config.error] };
188022
- const parsed = ts4.parseJsonConfigFileContent(config.config, ts4.sys, dirname22(configPath));
188216
+ const parsed = ts5.parseJsonConfigFileContent(config.config, ts5.sys, dirname4(configPath));
188023
188217
  return { options: parsed.options, errors: parsed.errors };
188024
188218
  }
188025
188219
  function isProductionSource(rootDir, sourceFile, excludes, outDir) {
@@ -188039,42 +188233,42 @@ function globMatches(value, pattern) {
188039
188233
  return new RegExp(`^${escaped}$`).test(value);
188040
188234
  }
188041
188235
  function bindingNames(name) {
188042
- if (ts4.isIdentifier(name))
188236
+ if (ts5.isIdentifier(name))
188043
188237
  return [name];
188044
- return name.elements.flatMap((element) => ts4.isBindingElement(element) ? bindingNames(element.name) : []);
188238
+ return name.elements.flatMap((element) => ts5.isBindingElement(element) ? bindingNames(element.name) : []);
188045
188239
  }
188046
188240
  function isLiteralExpression(node) {
188047
188241
  if (!node)
188048
188242
  return false;
188049
188243
  return [
188050
- ts4.SyntaxKind.StringLiteral,
188051
- ts4.SyntaxKind.NumericLiteral,
188052
- ts4.SyntaxKind.TrueKeyword,
188053
- ts4.SyntaxKind.FalseKeyword
188244
+ ts5.SyntaxKind.StringLiteral,
188245
+ ts5.SyntaxKind.NumericLiteral,
188246
+ ts5.SyntaxKind.TrueKeyword,
188247
+ ts5.SyntaxKind.FalseKeyword
188054
188248
  ].includes(node.kind);
188055
188249
  }
188056
188250
  function isLiteralSyntax(node) {
188057
- return ts4.isStringLiteral(node) || ts4.isNumericLiteral(node) || node.kind === ts4.SyntaxKind.TrueKeyword || node.kind === ts4.SyntaxKind.FalseKeyword;
188251
+ return ts5.isStringLiteral(node) || ts5.isNumericLiteral(node) || node.kind === ts5.SyntaxKind.TrueKeyword || node.kind === ts5.SyntaxKind.FalseKeyword;
188058
188252
  }
188059
188253
  function isLiteralType(type) {
188060
- return (type.flags & (ts4.TypeFlags.StringLiteral | ts4.TypeFlags.NumberLiteral | ts4.TypeFlags.BooleanLiteral | ts4.TypeFlags.BigIntLiteral)) !== 0;
188254
+ return (type.flags & (ts5.TypeFlags.StringLiteral | ts5.TypeFlags.NumberLiteral | ts5.TypeFlags.BooleanLiteral | ts5.TypeFlags.BigIntLiteral)) !== 0;
188061
188255
  }
188062
188256
  function isAnyType(type) {
188063
- return (type.flags & ts4.TypeFlags.Any) !== 0;
188257
+ return (type.flags & ts5.TypeFlags.Any) !== 0;
188064
188258
  }
188065
188259
  function isLetDeclaration(declaration) {
188066
- return ts4.isVariableDeclarationList(declaration.parent) && (declaration.parent.flags & ts4.NodeFlags.Let) !== 0;
188260
+ return ts5.isVariableDeclarationList(declaration.parent) && (declaration.parent.flags & ts5.NodeFlags.Let) !== 0;
188067
188261
  }
188068
188262
  function isConstDeclaration(declaration) {
188069
- return ts4.isVariableDeclarationList(declaration.parent) && (declaration.parent.flags & ts4.NodeFlags.Const) !== 0;
188263
+ return ts5.isVariableDeclarationList(declaration.parent) && (declaration.parent.flags & ts5.NodeFlags.Const) !== 0;
188070
188264
  }
188071
188265
  function descendants(root) {
188072
188266
  const result = [];
188073
188267
  const visit = (node) => {
188074
188268
  result.push(node);
188075
- ts4.forEachChild(node, visit);
188269
+ ts5.forEachChild(node, visit);
188076
188270
  };
188077
- ts4.forEachChild(root, visit);
188271
+ ts5.forEachChild(root, visit);
188078
188272
  return result;
188079
188273
  }
188080
188274
  function descendantsOfKind2(root, predicate) {
@@ -188082,9 +188276,9 @@ function descendantsOfKind2(root, predicate) {
188082
188276
  const visit = (node) => {
188083
188277
  if (predicate(node))
188084
188278
  result.push(node);
188085
- ts4.forEachChild(node, visit);
188279
+ ts5.forEachChild(node, visit);
188086
188280
  };
188087
- ts4.forEachChild(root, visit);
188281
+ ts5.forEachChild(root, visit);
188088
188282
  return result;
188089
188283
  }
188090
188284
  function makeDiagnostic(code, message, fileOrSourceFile, node, strict, rootDir) {
@@ -188102,10 +188296,10 @@ function makeDiagnostic(code, message, fileOrSourceFile, node, strict, rootDir)
188102
188296
  };
188103
188297
  }
188104
188298
  function normalizeRelative(rootDir, filePath) {
188105
- return relative22(rootDir, filePath).split(sep22).join("/").replace(/^\.\//, "");
188299
+ return relative4(rootDir, filePath).split(sep4).join("/").replace(/^\.\//, "");
188106
188300
  }
188107
188301
  function isAnyKeyword(node) {
188108
- return node.kind === ts4.SyntaxKind.AnyKeyword;
188302
+ return node.kind === ts5.SyntaxKind.AnyKeyword;
188109
188303
  }
188110
188304
  async function compileProject(options) {
188111
188305
  const graph = await analyzeProject(options.rootDir, options.include, options.cache, options.changedPaths);
@@ -188177,6 +188371,64 @@ function resolveTypeSafety(options) {
188177
188371
  exclude: options.typeSafety?.exclude
188178
188372
  };
188179
188373
  }
188374
+ var DEFAULT_SUPACLOUD_CONFIG = {
188375
+ root: "src",
188376
+ outDir: "generated",
188377
+ include: ["**/*.module.ts", "**/*.ts"],
188378
+ strict: true,
188379
+ generateClient: true,
188380
+ generatePermissions: true,
188381
+ treeShakeUnusedProviders: true,
188382
+ moduleBoundaryPreset: "modular-monolith"
188383
+ };
188384
+ function defineSupacloudConfig(config = {}) {
188385
+ return {
188386
+ ...DEFAULT_SUPACLOUD_CONFIG,
188387
+ ...config,
188388
+ include: config.include ?? [...DEFAULT_SUPACLOUD_CONFIG.include]
188389
+ };
188390
+ }
188391
+ function resolveSupacloudConfig(config = {}, cwd = process.cwd()) {
188392
+ const resolved = defineSupacloudConfig(config);
188393
+ return {
188394
+ rootDir: resolve62(cwd, resolved.root ?? DEFAULT_SUPACLOUD_CONFIG.root),
188395
+ outDir: resolve62(cwd, resolved.outDir ?? DEFAULT_SUPACLOUD_CONFIG.outDir),
188396
+ include: resolved.include ?? [...DEFAULT_SUPACLOUD_CONFIG.include],
188397
+ strict: resolved.strict ?? DEFAULT_SUPACLOUD_CONFIG.strict,
188398
+ generateClient: resolved.generateClient ?? DEFAULT_SUPACLOUD_CONFIG.generateClient,
188399
+ generatePermissions: resolved.generatePermissions ?? DEFAULT_SUPACLOUD_CONFIG.generatePermissions,
188400
+ moduleBoundaryPreset: resolved.moduleBoundaryPreset ?? DEFAULT_SUPACLOUD_CONFIG.moduleBoundaryPreset,
188401
+ commandCapabilities: resolved.commandCapabilities,
188402
+ treeShakeUnusedProviders: resolved.treeShakeUnusedProviders ?? DEFAULT_SUPACLOUD_CONFIG.treeShakeUnusedProviders
188403
+ };
188404
+ }
188405
+ async function loadSupacloudConfig(cwd = process.cwd()) {
188406
+ const candidates = [
188407
+ join62(cwd, "supacloud.config.ts"),
188408
+ join62(cwd, "supacloud.config.mts"),
188409
+ join62(cwd, "supacloud.config.js"),
188410
+ join62(cwd, "supacloud.config.mjs")
188411
+ ];
188412
+ const configPath = candidates.find((candidate) => existsSync52(candidate));
188413
+ if (!configPath)
188414
+ return defineSupacloudConfig();
188415
+ const imported = await import(pathToFileURL(configPath).href);
188416
+ return defineSupacloudConfig(imported.default ?? {});
188417
+ }
188418
+ function compileOptionsFromConfig(config, cwd = process.cwd()) {
188419
+ const resolved = resolveSupacloudConfig(config, cwd);
188420
+ return {
188421
+ rootDir: resolved.rootDir,
188422
+ outDir: resolved.outDir,
188423
+ include: resolved.include,
188424
+ strict: resolved.strict,
188425
+ generateClient: resolved.generateClient,
188426
+ generatePermissions: resolved.generatePermissions,
188427
+ moduleBoundaryPreset: resolved.moduleBoundaryPreset,
188428
+ commandCapabilities: resolved.commandCapabilities,
188429
+ treeShakeUnusedProviders: resolved.treeShakeUnusedProviders
188430
+ };
188431
+ }
188180
188432
 
188181
188433
  // src/shared/tools/app-tool-export.ts
188182
188434
  function sanitizeToolName(name) {
@@ -188318,11 +188570,11 @@ async function writeScaffold(path, content, force) {
188318
188570
  if (!force) {
188319
188571
  throw new Error(`File already exists: ${path}(使用 --force 覆盖)`);
188320
188572
  }
188321
- await writeFile2(path, content, "utf8");
188573
+ await writeFile(path, content, "utf8");
188322
188574
  return "overwritten";
188323
188575
  }
188324
- await mkdir2(dirname4(path), { recursive: true });
188325
- await writeFile2(path, content, "utf8");
188576
+ await mkdir2(dirname5(path), { recursive: true });
188577
+ await writeFile(path, content, "utf8");
188326
188578
  return "created";
188327
188579
  }
188328
188580
  function moduleScaffold(name) {
@@ -188402,12 +188654,16 @@ function parseInclude(include) {
188402
188654
  }
188403
188655
  async function runCompile(args) {
188404
188656
  const root = resolve8(args.root || process.cwd());
188405
- const outDir = resolve8(args.out_dir || join7(root, "generated"));
188657
+ const loadedConfig = await loadSupacloudConfig(root);
188658
+ const defaults = resolveSupacloudConfig(loadedConfig, root);
188406
188659
  const result = await compileProject({
188407
- rootDir: root,
188408
- include: parseInclude(args.include),
188409
- outDir,
188410
- strict: args.strict === true
188660
+ ...compileOptionsFromConfig({
188661
+ ...loadedConfig,
188662
+ root: args.root ? "." : loadedConfig.root,
188663
+ outDir: args.out_dir ? resolve8(root, args.out_dir) : defaults.outDir,
188664
+ include: parseInclude(args.include) ?? loadedConfig.include,
188665
+ strict: args.strict ?? loadedConfig.strict ?? false
188666
+ }, root)
188411
188667
  });
188412
188668
  const hasError = result.diagnostics.some((diagnostic) => diagnostic.severity === "error");
188413
188669
  const text = [
@@ -188421,12 +188677,24 @@ async function runCompile(args) {
188421
188677
  }
188422
188678
  async function runCheck(args) {
188423
188679
  const root = resolve8(args.root || process.cwd());
188424
- const graph = await analyzeProject(root, parseInclude(args.include));
188680
+ const loadedConfig = await loadSupacloudConfig(root);
188681
+ const defaults = resolveSupacloudConfig(loadedConfig, root);
188682
+ const config = compileOptionsFromConfig({
188683
+ ...loadedConfig,
188684
+ root: args.root ? "." : loadedConfig.root,
188685
+ outDir: args.out_dir ? resolve8(root, args.out_dir) : defaults.outDir,
188686
+ include: parseInclude(args.include) ?? loadedConfig.include,
188687
+ strict: args.strict ?? loadedConfig.strict ?? false
188688
+ }, root);
188689
+ const graph = await analyzeProject(config.rootDir, config.include);
188425
188690
  const diagnostics = [
188426
188691
  ...graph.diagnostics ?? [],
188427
- ...validateGraph(graph, args.strict === true)
188692
+ ...validateGraph(graph, {
188693
+ strict: config.strict,
188694
+ moduleBoundaryPreset: config.moduleBoundaryPreset
188695
+ })
188428
188696
  ];
188429
- if (args.strict === true) {
188697
+ if (config.strict) {
188430
188698
  for (const diagnostic of diagnostics) {
188431
188699
  if (diagnostic.severity === "warn")
188432
188700
  diagnostic.severity = "error";
@@ -188607,8 +188875,8 @@ async function runExportTools(args) {
188607
188875
  }
188608
188876
  const openaiPath = join7(outDir, "tool-definitions.openai.json");
188609
188877
  const mcpPath = join7(outDir, "tool-definitions.mcp.json");
188610
- await writeFile2(openaiPath, JSON.stringify(definitions.openai, null, 2), "utf8");
188611
- await writeFile2(mcpPath, JSON.stringify(definitions.mcp, null, 2), "utf8");
188878
+ await writeFile(openaiPath, JSON.stringify(definitions.openai, null, 2), "utf8");
188879
+ await writeFile(mcpPath, JSON.stringify(definitions.mcp, null, 2), "utf8");
188612
188880
  const summary = [
188613
188881
  `exported ${definitions.openai.length} tool(s):`,
188614
188882
  ` openai → ${openaiPath}`,
@@ -190313,7 +190581,7 @@ function registerReleaseTools(server2, http, options = {}) {
190313
190581
  import { access as access2, lstat, mkdtemp, opendir, readFile as readFile2, rm, writeFile as writeFile3 } from "node:fs/promises";
190314
190582
  import { createHash as createHash5 } from "node:crypto";
190315
190583
  import { tmpdir as tmpdir2 } from "node:os";
190316
- import { basename as basename4, dirname as dirname5, join as join9, relative as relative4, resolve as resolve11, sep as sep4 } from "node:path";
190584
+ import { basename as basename4, dirname as dirname7, join as join9, relative as relative5, resolve as resolve11, sep as sep5 } from "node:path";
190317
190585
  import { spawn as spawn3 } from "node:child_process";
190318
190586
 
190319
190587
  // node_modules/fflate/esm/index.mjs
@@ -191009,7 +191277,7 @@ async function findDeployConfigRoot(startDirectory) {
191009
191277
  while (true) {
191010
191278
  if (await pathExists(join9(directory, "supacloud.json")))
191011
191279
  return directory;
191012
- const parent = dirname5(directory);
191280
+ const parent = dirname7(directory);
191013
191281
  if (parent === directory)
191014
191282
  return resolve11(startDirectory);
191015
191283
  directory = parent;
@@ -191098,8 +191366,8 @@ async function defaultBuildCommand(projectDirectory, configRoot) {
191098
191366
  return "yarn build";
191099
191367
  if (directory === configRoot)
191100
191368
  break;
191101
- const parent = dirname5(directory);
191102
- if (parent === directory || !directory.startsWith(`${configRoot}${sep4}`))
191369
+ const parent = dirname7(directory);
191370
+ if (parent === directory || !directory.startsWith(`${configRoot}${sep5}`))
191103
191371
  break;
191104
191372
  directory = parent;
191105
191373
  }
@@ -191130,7 +191398,7 @@ function selectDeployment(deployments, requestedId, projectName) {
191130
191398
  }
191131
191399
  function targetRoot(configRoot, target, name) {
191132
191400
  const root = resolve11(configRoot, target.root || (name === "frontend" ? "." : name));
191133
- const prefix = `${resolve11(configRoot)}${sep4}`;
191401
+ const prefix = `${resolve11(configRoot)}${sep5}`;
191134
191402
  if (root !== resolve11(configRoot) && !root.startsWith(prefix)) {
191135
191403
  throw new Error(`Deploy target '${name}' root must stay inside the repository root`);
191136
191404
  }
@@ -191152,7 +191420,7 @@ function selectTarget(configRoot, invocationDirectory, config, requestedName) {
191152
191420
  throw new Error(`Deploy target '${requestedName}' was not found in supacloud.json`);
191153
191421
  return { name: selected[0], config: selected[1], root: targetRoot(configRoot, selected[1], selected[0]) };
191154
191422
  }
191155
- const containing = targets.map(([name, target]) => ({ name, target, root: targetRoot(configRoot, target, name) })).filter((candidate) => invocationDirectory === candidate.root || invocationDirectory.startsWith(`${candidate.root}${sep4}`)).sort((left, right) => right.root.length - left.root.length);
191423
+ const containing = targets.map(([name, target]) => ({ name, target, root: targetRoot(configRoot, target, name) })).filter((candidate) => invocationDirectory === candidate.root || invocationDirectory.startsWith(`${candidate.root}${sep5}`)).sort((left, right) => right.root.length - left.root.length);
191156
191424
  if (containing.length === 1 || containing.length > 1 && containing[0].root !== containing[1].root) {
191157
191425
  const selected = containing[0];
191158
191426
  return { name: selected.name, config: selected.target, root: selected.root };
@@ -191184,7 +191452,7 @@ function defaultOutputDirectory(framework) {
191184
191452
  function resolveInsideProject(projectDirectory, candidate, allowRoot = false) {
191185
191453
  const resolved = resolve11(projectDirectory, candidate);
191186
191454
  const projectRoot = resolve11(projectDirectory);
191187
- const projectPrefix = `${projectRoot}${sep4}`;
191455
+ const projectPrefix = `${projectRoot}${sep5}`;
191188
191456
  if (!allowRoot && resolved === projectRoot || resolved !== projectRoot && !resolved.startsWith(projectPrefix)) {
191189
191457
  throw new Error("Frontend output directory must stay inside the project directory");
191190
191458
  }
@@ -191236,7 +191504,7 @@ async function collectArchiveFiles(root) {
191236
191504
  bytes += data.byteLength;
191237
191505
  if (bytes > MAX_SOURCE_BYTES)
191238
191506
  throw new Error(`Frontend output exceeds ${MAX_SOURCE_BYTES} bytes`);
191239
- const archivePath = relative4(root, path).split(sep4).join("/");
191507
+ const archivePath = relative5(root, path).split(sep5).join("/");
191240
191508
  files[archivePath] = [data, { mtime: FIXED_ZIP_MTIME }];
191241
191509
  }
191242
191510
  return { files, bytes, count: paths.length };
@@ -191408,7 +191676,7 @@ function registerDeployTools(server2, http, options = {}) {
191408
191676
  } else {
191409
191677
  report("build", "skipped");
191410
191678
  }
191411
- report("package", relative4(projectDirectory, outputDirectory) || ".");
191679
+ report("package", relative5(projectDirectory, outputDirectory) || ".");
191412
191680
  const archive = await createFrontendArchive(outputDirectory);
191413
191681
  try {
191414
191682
  const inventory = payload(await listFrontendReleases(http, projectRef2, selected.id, undefined, 100));
@@ -191739,7 +192007,7 @@ function registerRemoteDevTools(server2, options = {}) {
191739
192007
  // package.json
191740
192008
  var package_default = {
191741
192009
  name: "@supacloud/cli",
191742
- version: "0.47.0",
192010
+ version: "0.48.2",
191743
192011
  description: "Project-scoped CLI for SupaCloud users",
191744
192012
  type: "module",
191745
192013
  main: "./dist/index.js",
@@ -191772,7 +192040,7 @@ var package_default = {
191772
192040
  },
191773
192041
  dependencies: {
191774
192042
  "@sinclair/typebox": "^0.34.52",
191775
- "@supacloud/compiler": "^0.6.2",
192043
+ "@supacloud/compiler": "^0.9.0",
191776
192044
  "@supacloud/db": "^0.2.0",
191777
192045
  fflate: "^0.8.3"
191778
192046
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/cli",
3
- "version": "0.47.0",
3
+ "version": "0.48.2",
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.6.2",
36
+ "@supacloud/compiler": "^0.9.0",
37
37
  "@supacloud/db": "^0.2.0",
38
38
  "fflate": "^0.8.3"
39
39
  },