@supacloud/cli 0.49.0 → 0.49.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 +43 -5
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -188311,6 +188311,37 @@ function normalizeRelative(rootDir, filePath) {
188311
188311
  function isAnyKeyword(node) {
188312
188312
  return node.kind === ts5.SyntaxKind.AnyKeyword;
188313
188313
  }
188314
+ function inspectRouteContracts(graph) {
188315
+ return graph.modules.flatMap((module) => module.controllers.flatMap((controller) => controller.routes.map((route) => {
188316
+ const missing = [];
188317
+ if ((route.hasBodyBinding || route.handlerParams?.some((param) => param.kind === "body")) && !route.body)
188318
+ missing.push("body");
188319
+ if ((route.pathParams?.length || route.paramBindings?.length || route.handlerParams?.some((param) => param.kind === "param") || /:[^/]+/.test(`${controller.path}/${route.path}`)) && !route.params)
188320
+ missing.push("params");
188321
+ if ((route.queryBindings?.length || route.handlerParams?.some((param) => param.kind === "query")) && !route.query)
188322
+ missing.push("query");
188323
+ if (!route.response)
188324
+ missing.push("response");
188325
+ return {
188326
+ module: module.name,
188327
+ controller: controller.className,
188328
+ handler: route.handler,
188329
+ method: route.method,
188330
+ path: `${controller.path}${route.path}`,
188331
+ file: controller.file,
188332
+ missing
188333
+ };
188334
+ })));
188335
+ }
188336
+ function validateRouteContracts(graph) {
188337
+ return inspectRouteContracts(graph).filter((route) => route.missing.length).map((route) => ({
188338
+ severity: "error",
188339
+ code: "route-contract-required",
188340
+ file: route.file,
188341
+ message: `${route.controller}.${route.handler} (${route.method} ${route.path}) is missing contract declarations: ${route.missing.join(", ")}.`,
188342
+ suggestion: "Declare the missing schemas and test actual request/response decoding. An opaque schema is not proof of validation."
188343
+ }));
188344
+ }
188314
188345
  async function compileProject(options) {
188315
188346
  const graph = await analyzeProject(options.rootDir, options.include, options.cache, options.changedPaths);
188316
188347
  const diagnostics = [
@@ -188332,6 +188363,8 @@ async function compileProject(options) {
188332
188363
  }
188333
188364
  }
188334
188365
  const typeSafety = resolveTypeSafety(options);
188366
+ if (options.requireRouteContracts)
188367
+ diagnostics.push(...validateRouteContracts(graph));
188335
188368
  const rendered = renderApplication(graph, {
188336
188369
  rootDir: options.rootDir,
188337
188370
  outDir: options.outDir,
@@ -188395,6 +188428,8 @@ async function checkProject(options) {
188395
188428
  }
188396
188429
  }
188397
188430
  const typeSafety = resolveTypeSafety(options);
188431
+ if (options.requireRouteContracts)
188432
+ diagnostics.push(...validateRouteContracts(graph));
188398
188433
  const rendered = renderApplication(graph, {
188399
188434
  rootDir: options.rootDir,
188400
188435
  outDir: options.outDir,
@@ -188459,6 +188494,7 @@ var DEFAULT_SUPACLOUD_CONFIG = {
188459
188494
  outDir: "generated",
188460
188495
  include: ["**/*.module.ts", "**/*.ts"],
188461
188496
  strict: true,
188497
+ requireRouteContracts: false,
188462
188498
  generateClient: true,
188463
188499
  generatePermissions: true,
188464
188500
  treeShakeUnusedProviders: true,
@@ -188478,6 +188514,7 @@ function resolveSupacloudConfig(config = {}, cwd = process.cwd()) {
188478
188514
  outDir: resolve62(cwd, resolved.outDir ?? DEFAULT_SUPACLOUD_CONFIG.outDir),
188479
188515
  include: resolved.include ?? [...DEFAULT_SUPACLOUD_CONFIG.include],
188480
188516
  strict: resolved.strict ?? DEFAULT_SUPACLOUD_CONFIG.strict,
188517
+ requireRouteContracts: resolved.requireRouteContracts ?? DEFAULT_SUPACLOUD_CONFIG.requireRouteContracts,
188481
188518
  generateClient: resolved.generateClient ?? DEFAULT_SUPACLOUD_CONFIG.generateClient,
188482
188519
  generatePermissions: resolved.generatePermissions ?? DEFAULT_SUPACLOUD_CONFIG.generatePermissions,
188483
188520
  moduleBoundaryPreset: resolved.moduleBoundaryPreset ?? DEFAULT_SUPACLOUD_CONFIG.moduleBoundaryPreset,
@@ -188505,6 +188542,7 @@ function compileOptionsFromConfig(config, cwd = process.cwd()) {
188505
188542
  outDir: resolved.outDir,
188506
188543
  include: resolved.include,
188507
188544
  strict: resolved.strict,
188545
+ requireRouteContracts: resolved.requireRouteContracts,
188508
188546
  generateClient: resolved.generateClient,
188509
188547
  generatePermissions: resolved.generatePermissions,
188510
188548
  moduleBoundaryPreset: resolved.moduleBoundaryPreset,
@@ -188764,7 +188802,7 @@ test("partial and untagged inherited remote profiles cannot mix with selected fi
188764
188802
  // ../compiler/package.json
188765
188803
  var package_default = {
188766
188804
  name: "@supacloud/compiler",
188767
- version: "0.10.0",
188805
+ version: "0.11.0",
188768
188806
  description: "Static compiler for @supacloud/app metadata: builds the application graph from AST, validates it, and generates reflection-free factory code",
188769
188807
  type: "module",
188770
188808
  main: "./dist/index.js",
@@ -188819,7 +188857,7 @@ var package_default = {
188819
188857
  // ../app/package.json
188820
188858
  var package_default2 = {
188821
188859
  name: "@supacloud/app",
188822
- version: "0.9.0",
188860
+ version: "0.10.0",
188823
188861
  description: "Angular-style application metadata for SupaCloud: modules, DI tokens, providers, scopes, controllers and commands",
188824
188862
  type: "module",
188825
188863
  main: "./dist/index.js",
@@ -188870,7 +188908,7 @@ var package_default2 = {
188870
188908
  // ../elysia/package.json
188871
188909
  var package_default3 = {
188872
188910
  name: "@supacloud/elysia",
188873
- version: "0.8.0",
188911
+ version: "0.8.1",
188874
188912
  description: "Elysia runtime adapter for SupaCloud compiled modules: application/request scopes, route registration and validation",
188875
188913
  type: "module",
188876
188914
  main: "./dist/index.js",
@@ -193154,7 +193192,7 @@ function registerRemoteDevTools(server2, options = {}) {
193154
193192
  // package.json
193155
193193
  var package_default4 = {
193156
193194
  name: "@supacloud/cli",
193157
- version: "0.49.0",
193195
+ version: "0.49.2",
193158
193196
  description: "Project-scoped CLI for SupaCloud users",
193159
193197
  type: "module",
193160
193198
  main: "./dist/index.js",
@@ -193187,7 +193225,7 @@ var package_default4 = {
193187
193225
  },
193188
193226
  dependencies: {
193189
193227
  "@sinclair/typebox": "^0.34.52",
193190
- "@supacloud/compiler": "^0.10.0",
193228
+ "@supacloud/compiler": "^0.11.0",
193191
193229
  "@supacloud/db": "^0.2.0",
193192
193230
  fflate: "^0.8.3"
193193
193231
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/cli",
3
- "version": "0.49.0",
3
+ "version": "0.49.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.10.0",
36
+ "@supacloud/compiler": "^0.11.0",
37
37
  "@supacloud/db": "^0.2.0",
38
38
  "fflate": "^0.8.3"
39
39
  },