@supacloud/cli 0.54.0 → 0.55.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 +47 -18
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -220119,10 +220119,24 @@ function renderApplication(graph, options) {
220119
220119
  ""
220120
220120
  ].join(`
220121
220121
  `);
220122
+ const commandGovernance = graph.modules.flatMap((module) => module.commands.map((command) => ({
220123
+ module: module.name,
220124
+ className: command.className,
220125
+ name: command.name,
220126
+ permission: command.permission ?? null,
220127
+ rpc: command.rpc ?? null,
220128
+ transaction: command.transaction ?? null,
220129
+ audit: command.audit ?? null,
220130
+ idempotency: command.idempotency ?? null
220131
+ }))).sort((left, right) => `${left.module}:${left.name}`.localeCompare(`${right.module}:${right.name}`));
220122
220132
  const manifest = {
220123
220133
  version: 1,
220124
220134
  modules: graph.modules,
220125
- externalTokens: graph.externalTokens
220135
+ externalTokens: graph.externalTokens,
220136
+ commandGovernance: {
220137
+ defaults: { authorization: "required", audit: "required", idempotency: "required", transaction: "required" },
220138
+ commands: commandGovernance
220139
+ }
220126
220140
  };
220127
220141
  const clientCode = options.generateClient ? renderClient(graph, options) : undefined;
220128
220142
  const openApiCode = options.generateOpenApi ? renderOpenApi(graph, options) : undefined;
@@ -223561,7 +223575,7 @@ function validateGraph(graph, options = false) {
223561
223575
  if (typeof options === "object" && options.commandCapabilities) {
223562
223576
  const hostCaps = options.commandCapabilities;
223563
223577
  const rpcCaps = command.rpc && Object.hasOwn(hostCaps.rpc ?? {}, command.rpc) ? hostCaps.rpc?.[command.rpc] : undefined;
223564
- if (hostCaps.requirePersistentAdapters && (!rpcCaps?.boundary || rpcCaps.audit !== true || rpcCaps.idempotency !== true || hostCaps.permission !== true || !command.permission || !command.audit || command.idempotency !== "required" || rpcCaps.boundary === "database" && (rpcCaps.transaction !== true || command.transaction !== "required"))) {
223578
+ if (hostCaps.requirePersistentAdapters && (command.rpc !== undefined && (!rpcCaps?.boundary || rpcCaps.audit !== true || rpcCaps.idempotency !== true) || hostCaps.permission !== true || !command.permission || !command.audit || command.idempotency !== "required" || command.rpc !== undefined && rpcCaps?.boundary === "database" && (rpcCaps.transaction !== true || command.transaction !== "required") || command.rpc === undefined && (hostCaps.audit !== true || hostCaps.idempotency !== true || hostCaps.transaction !== true || command.transaction !== "required"))) {
223565
223579
  error("command-persistence-required", `Command ${command.name} requires an explicit persistent adapter, permission, audit and idempotency policy.`, module.file, module.line, "Register a named database/external adapter, enable permission checks and declare permission, audit and required idempotency on the command.");
223566
223580
  }
223567
223581
  if (rpcCaps?.boundary === "external" && (command.transaction === "required" || rpcCaps.transaction === true)) {
@@ -226509,10 +226523,20 @@ function validateRouteContracts(graph) {
226509
226523
  });
226510
226524
  });
226511
226525
  }
226526
+ function withDefaultGovernance(options) {
226527
+ return options.commandCapabilities === undefined ? { ...options, commandCapabilities: {
226528
+ requirePersistentAdapters: true,
226529
+ permission: true,
226530
+ audit: true,
226531
+ idempotency: true,
226532
+ transaction: true
226533
+ } } : options;
226534
+ }
226512
226535
  async function renderOptionalGraphql(options) {
226513
226536
  return options.graphql ? (await Promise.resolve().then(() => (init_graphql(), exports_graphql))).renderGraphql(options) : { diagnostics: [], files: {} };
226514
226537
  }
226515
226538
  async function compileProject(options) {
226539
+ options = withDefaultGovernance(options);
226516
226540
  const graph = await analyzeProject(options.rootDir, options.include, options.cache, options.changedPaths);
226517
226541
  const diagnostics = [
226518
226542
  ...graph.diagnostics ?? [],
@@ -226574,6 +226598,7 @@ async function compileProject(options) {
226574
226598
  return { diagnostics, graph, written, ...stats ? { stats } : {} };
226575
226599
  }
226576
226600
  async function checkProject(options) {
226601
+ options = withDefaultGovernance(options);
226577
226602
  const graph = await analyzeProject(options.rootDir, options.include, options.cache, options.changedPaths);
226578
226603
  const diagnostics = [
226579
226604
  ...graph.diagnostics ?? [],
@@ -229741,6 +229766,13 @@ var DEFAULT_SUPACLOUD_CONFIG = {
229741
229766
  generateOpenApi: true,
229742
229767
  generatePermissions: true,
229743
229768
  treeShakeUnusedProviders: true,
229769
+ commandCapabilities: {
229770
+ requirePersistentAdapters: true,
229771
+ permission: true,
229772
+ audit: true,
229773
+ idempotency: true,
229774
+ transaction: true
229775
+ },
229744
229776
  moduleBoundaryPreset: "modular-monolith"
229745
229777
  };
229746
229778
  function defineSupacloudConfig(config = {}) {
@@ -229824,7 +229856,7 @@ function resolveSupacloudConfig(config = {}, cwd = process.cwd()) {
229824
229856
  ...resolved.openApi === undefined ? {} : { openApi: resolved.openApi },
229825
229857
  generatePermissions: resolved.generatePermissions ?? DEFAULT_SUPACLOUD_CONFIG.generatePermissions,
229826
229858
  moduleBoundaryPreset: resolved.moduleBoundaryPreset ?? DEFAULT_SUPACLOUD_CONFIG.moduleBoundaryPreset,
229827
- commandCapabilities: resolved.commandCapabilities,
229859
+ commandCapabilities: resolved.commandCapabilities ?? DEFAULT_SUPACLOUD_CONFIG.commandCapabilities,
229828
229860
  ...resolved.moduleBoundaries ? { moduleBoundaries: resolved.moduleBoundaries } : {},
229829
229861
  ...resolved.typeSafety ? { typeSafety: resolved.typeSafety } : {},
229830
229862
  ...resolved.allowRouteCommandBindings === undefined ? {} : { allowRouteCommandBindings: resolved.allowRouteCommandBindings },
@@ -230107,7 +230139,7 @@ test("partial and untagged inherited remote profiles cannot mix with selected fi
230107
230139
  // ../compiler/package.json
230108
230140
  var package_default = {
230109
230141
  name: "@supacloud/compiler",
230110
- version: "0.22.0",
230142
+ version: "0.23.0",
230111
230143
  description: "Static compiler for @supacloud/app metadata: builds the application graph from AST, validates it, and generates reflection-free factory code",
230112
230144
  type: "module",
230113
230145
  main: "./dist/index.js",
@@ -230172,7 +230204,7 @@ var package_default = {
230172
230204
  // ../app/package.json
230173
230205
  var package_default2 = {
230174
230206
  name: "@supacloud/app",
230175
- version: "0.14.0",
230207
+ version: "0.15.0",
230176
230208
  description: "Angular-style application metadata for SupaCloud: modules, DI tokens, providers, scopes, controllers and commands",
230177
230209
  type: "module",
230178
230210
  main: "./dist/index.js",
@@ -230223,7 +230255,7 @@ var package_default2 = {
230223
230255
  directory: "packages/app"
230224
230256
  },
230225
230257
  dependencies: {
230226
- "@supacloud/contracts": "file:../contracts",
230258
+ "@supacloud/contracts": "0.4.0",
230227
230259
  "@angular/core": "^22.1.5",
230228
230260
  "@sinclair/typebox": "^0.34.52"
230229
230261
  },
@@ -230236,7 +230268,7 @@ var package_default2 = {
230236
230268
  // ../elysia/package.json
230237
230269
  var package_default3 = {
230238
230270
  name: "@supacloud/elysia",
230239
- version: "0.17.0",
230271
+ version: "0.18.0",
230240
230272
  description: "Elysia runtime adapter for SupaCloud compiled modules: application/request scopes, route registration and validation",
230241
230273
  type: "module",
230242
230274
  main: "./dist/index.js",
@@ -230662,19 +230694,15 @@ test("transaction adapter rolls back mutations when work fails", async () => {
230662
230694
  expect(sandbox.db.get("reviews", "demo")).toEqual({ state: "draft", version: 1 });
230663
230695
  });
230664
230696
 
230665
- test("the production composition root rejects missing governance adapters", async () => {
230697
+ test("the production composition root rejects missing governance adapters", () => {
230666
230698
  const sandbox = createDemo();
230667
- const app = createApp({
230699
+ expect(() => createApp({
230668
230700
  deps: { dbClient: sandbox.db },
230669
230701
  requestContext: () => ({ identity: { authenticated: true, subject: "test" } }),
230670
230702
  commandGovernance: { authorize: () => {} },
230671
- });
230672
- const response = await app.handle(new Request("http://localhost/reviews/demo/approve", {
230673
- method: "POST", headers: { "content-type": "application/json", "idempotency-key": "production" },
230674
- body: JSON.stringify({ expectedVersion: 1 }),
230675
- }));
230676
- expect(response.status).toBe(501);
230703
+ })).toThrow('Command "review.approve" has no audit adapter');
230677
230704
  expect(sandbox.db.get("reviews", "demo")).toEqual({ state: "draft", version: 1 });
230705
+ expect(sandbox.audit).toEqual([]);
230678
230706
  });
230679
230707
  `,
230680
230708
  "README.md": `# ${name}
@@ -230786,7 +230814,8 @@ async database repository or a transactional RPC before production use. The
230786
230814
  authoritative database must lock or compare row versions, enforce authorization,
230787
230815
  and commit transition, idempotency receipt and audit atomically. For distributed
230788
230816
  side effects use a transactional outbox. Client state machines are projections,
230789
- not a security boundary. Missing declared runtime adapters return an error.
230817
+ not a security boundary. Missing declared runtime adapters reject application
230818
+ startup before any request is served.
230790
230819
 
230791
230820
  ## Unified User Center
230792
230821
 
@@ -234692,7 +234721,7 @@ function registerRemoteDevTools(server2, options = {}) {
234692
234721
  // package.json
234693
234722
  var package_default4 = {
234694
234723
  name: "@supacloud/cli",
234695
- version: "0.54.0",
234724
+ version: "0.55.0",
234696
234725
  description: "Project-scoped CLI for SupaCloud users",
234697
234726
  type: "module",
234698
234727
  main: "./dist/index.js",
@@ -234725,7 +234754,7 @@ var package_default4 = {
234725
234754
  },
234726
234755
  dependencies: {
234727
234756
  "@sinclair/typebox": "^0.34.52",
234728
- "@supacloud/compiler": "^0.22.0",
234757
+ "@supacloud/compiler": "^0.23.0",
234729
234758
  "@supacloud/db": "^0.2.0",
234730
234759
  fflate: "^0.8.3"
234731
234760
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/cli",
3
- "version": "0.54.0",
3
+ "version": "0.55.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.22.0",
36
+ "@supacloud/compiler": "^0.23.0",
37
37
  "@supacloud/db": "^0.2.0",
38
38
  "fflate": "^0.8.3"
39
39
  },