@empire-builder-kit/nx 1.0.0-rc.43 → 1.0.0-rc.45

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 (88) hide show
  1. package/package.json +3 -3
  2. package/src/blueprints/external-sandbox.d.ts +1 -1
  3. package/src/cli/main.d.ts +11 -5
  4. package/src/cli/main.js +88 -29
  5. package/src/container-images.d.ts +1 -1
  6. package/src/container-images.js +1 -1
  7. package/src/executors/deployment-plan/deployment-plan.js +5 -1
  8. package/src/executors/deployment-plan/schema.json +1 -1
  9. package/src/executors/fleet/fleet.js +4 -0
  10. package/src/executors/fleet/schema.json +1 -1
  11. package/src/executors/local-deploy/federated-credential-transport.d.ts +4 -3
  12. package/src/executors/local-deploy/federated-credential-transport.js +15 -5
  13. package/src/foundation/cost-estimate.d.ts +8 -3
  14. package/src/foundation/cost-estimate.js +42 -19
  15. package/src/foundation/index.d.ts +1 -0
  16. package/src/foundation/index.js +1 -0
  17. package/src/foundation/local-private-smoke-access.js +6 -0
  18. package/src/foundation/logging.d.ts +3 -1
  19. package/src/foundation/logging.js +8 -1
  20. package/src/foundation/observability.d.ts +42 -0
  21. package/src/foundation/observability.js +181 -0
  22. package/src/foundation/preflight.js +1 -1
  23. package/src/generators/function/function.js +5 -2
  24. package/src/generators/observability-infrastructure.d.ts +2 -0
  25. package/src/generators/observability-infrastructure.js +31 -0
  26. package/src/generators/observability-policy.d.ts +4 -0
  27. package/src/generators/observability-policy.js +23 -0
  28. package/src/generators/preset/dependency-overrides.d.ts +34 -0
  29. package/src/generators/preset/dependency-overrides.js +35 -1
  30. package/src/generators/preset/tool-versions.d.ts +2 -2
  31. package/src/generators/preset/tool-versions.js +2 -2
  32. package/src/generators/preset/workspace-files-adopter-skills.js +28 -17
  33. package/src/generators/preset/workspace-files-agent-development.d.ts +9 -0
  34. package/src/generators/preset/workspace-files-agent-development.js +42 -0
  35. package/src/generators/preset/workspace-files-thin-deploy.js +12 -3
  36. package/src/generators/preset/workspace-files-thin-docs.js +10 -22
  37. package/src/generators/preset/workspace-files.d.ts +3 -0
  38. package/src/generators/preset/workspace-files.js +93 -8
  39. package/src/generators/slice/built-in-plan-alarm-identity.d.ts +173 -0
  40. package/src/generators/slice/built-in-plan-alarm-identity.js +202 -0
  41. package/src/generators/slice/built-in-plan-api-contract-files.js +136 -0
  42. package/src/generators/slice/built-in-plan-database-lifecycle-files.js +1 -1
  43. package/src/generators/slice/built-in-plan-event-contract-literal.d.ts +6 -0
  44. package/src/generators/slice/built-in-plan-event-contract-literal.js +52 -0
  45. package/src/generators/slice/built-in-plan-infrastructure-files.js +304 -144
  46. package/src/generators/slice/built-in-plan-key-value-retention-infrastructure.js +2 -2
  47. package/src/generators/slice/built-in-plan-metadata-files.js +33 -1
  48. package/src/generators/slice/built-in-plan-operations-files.js +106 -6
  49. package/src/generators/slice/built-in-plan-project-files.js +1 -0
  50. package/src/generators/slice/built-in-plan-release-files.js +2 -43
  51. package/src/generators/slice/built-in-plan-reliability-files.js +222 -236
  52. package/src/generators/slice/built-in-plan-shared.d.ts +29 -3
  53. package/src/generators/slice/built-in-plan-shared.js +29 -2
  54. package/src/generators/slice/built-in-plan-web-files.js +18 -1
  55. package/src/generators/slice/built-in-plan.js +1 -0
  56. package/src/generators/slice/slice.js +2 -0
  57. package/src/generators/upgrade/upgrade.d.ts +4 -3
  58. package/src/generators/upgrade/upgrade.js +50 -26
  59. package/src/generators/workload/frozen-container.d.ts +1 -1
  60. package/src/generators/workload/service-performance-files.js +22 -5
  61. package/src/generators/workload/workload.js +5 -1
  62. package/src/local-dev/dev-command-core.d.ts +24 -3
  63. package/src/local-dev/dev-command-core.js +124 -12
  64. package/src/local-dev/errors.d.ts +19 -1
  65. package/src/local-dev/errors.js +18 -1
  66. package/src/local-dev/fleet-client.d.ts +64 -6
  67. package/src/local-dev/fleet-client.js +189 -15
  68. package/src/local-dev/fleet-process.d.ts +47 -2
  69. package/src/local-dev/fleet-process.js +248 -31
  70. package/src/local-dev/fleet-runtime.d.ts +37 -0
  71. package/src/local-dev/fleet-runtime.js +127 -69
  72. package/src/local-dev/fleet-session.d.ts +1 -0
  73. package/src/local-dev/fleet-session.js +42 -3
  74. package/src/local-dev/fleet-state.d.ts +5 -0
  75. package/src/local-dev/fleet-state.js +11 -2
  76. package/src/local-dev/fleet-supervisor.d.ts +6 -0
  77. package/src/local-dev/fleet-supervisor.js +49 -1
  78. package/src/local-dev/ports.d.ts +11 -1
  79. package/src/local-dev/ports.js +78 -38
  80. package/src/local-dev/slice-runner.d.ts +19 -1
  81. package/src/local-dev/slice-runner.js +290 -91
  82. package/src/repository-policy/deployment-plan.d.ts +1 -1
  83. package/src/repository-policy/deployment-plan.js +16 -1
  84. package/src/secrets/generated-aws-control-plane.d.ts +11 -1
  85. package/src/secrets/generated-aws-control-plane.js +92 -29
  86. package/src/secrets/operator.d.ts +3 -2
  87. package/src/secrets/operator.js +27 -5
  88. package/src/supply-chain/generated-files.js +9 -0
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderProductApiContractFiles = renderProductApiContractFiles;
4
4
  const api_contract_1 = require("@empire-builder-kit/runtime/api-contract");
5
5
  const index_js_1 = require("../../api-contract/index.js");
6
+ const built_in_plan_event_contract_literal_js_1 = require("./built-in-plan-event-contract-literal.js");
6
7
  const built_in_plan_shared_js_1 = require("./built-in-plan-shared.js");
7
8
  const local_source_identity_js_1 = require("./local-source-identity.js");
8
9
  // Shared by the machine-readable contract and the generated operation source.
@@ -2040,6 +2041,7 @@ database code, or other implementation paths.
2040
2041
  } from 'node:fs';
2041
2042
  import { createRequire } from 'node:module';
2042
2043
  import { isAbsolute, join, relative, resolve, sep } from 'node:path';
2044
+ import ts from 'typescript';
2043
2045
 
2044
2046
  const require = createRequire(import.meta.url);
2045
2047
  const {
@@ -2211,6 +2213,139 @@ function validateContractExports(root, packageJson, publications) {
2211
2213
  }
2212
2214
  }
2213
2215
 
2216
+ ${built_in_plan_event_contract_literal_js_1.EVENT_CONTRACT_LITERAL_SOURCE}
2217
+ function producerEventContract(producer, slice) {
2218
+ const path = join(producer.root, 'contracts', 'events.ts');
2219
+ if (!existsSync(path)) {
2220
+ throw new Error(
2221
+ 'Producer ' + slice + ' publishes no contracts/events.ts EventContractSchema.',
2222
+ );
2223
+ }
2224
+ const file = ts.createSourceFile(
2225
+ path,
2226
+ readFileSync(path, 'utf8'),
2227
+ ts.ScriptTarget.ESNext,
2228
+ true,
2229
+ ts.ScriptKind.TS,
2230
+ );
2231
+ let schema;
2232
+ for (const statement of file.statements) {
2233
+ if (!ts.isVariableStatement(statement)) continue;
2234
+ for (const variable of statement.declarationList.declarations) {
2235
+ if (
2236
+ ts.isIdentifier(variable.name) &&
2237
+ variable.name.text === 'EventContractSchema' &&
2238
+ variable.initializer
2239
+ ) {
2240
+ if (schema !== undefined) {
2241
+ throw new Error(
2242
+ 'Producer ' + slice + ' EventContractSchema export is ambiguous.',
2243
+ );
2244
+ }
2245
+ schema = eventLiteral(variable.initializer);
2246
+ }
2247
+ }
2248
+ }
2249
+ if (
2250
+ schema?.kind !== 'ebk-event-contract-schema' ||
2251
+ schema.schemaVersion !== 1 ||
2252
+ schema.slice !== slice ||
2253
+ !Array.isArray(schema.events)
2254
+ ) {
2255
+ throw new Error(
2256
+ 'Producer ' +
2257
+ slice +
2258
+ ' contracts/events.ts must export one canonical v1 EventContractSchema.',
2259
+ );
2260
+ }
2261
+ return schema;
2262
+ }
2263
+
2264
+ // Bind each declared cross-Slice subscription to the producer's published
2265
+ // EventContractSchema, so a removed, renamed or re-versioned event fails here
2266
+ // instead of silently stopping delivery.
2267
+ async function checkEventSubscriptions(dependencies, projects) {
2268
+ const subscriptionPath = join(
2269
+ projectRoot,
2270
+ 'contracts',
2271
+ 'event-subscriptions.json',
2272
+ );
2273
+ if (!existsSync(subscriptionPath)) {
2274
+ throw new Error(
2275
+ 'contracts/event-subscriptions.json is missing. Restore the seeded ' +
2276
+ 'declaration with schemaVersion 1 and an empty subscriptions list.',
2277
+ );
2278
+ }
2279
+ // The managed infrastructure validator is the one authority for the
2280
+ // declaration shape; this check runs it exactly as deployment does.
2281
+ const validator = await import(
2282
+ 'data:text/javascript;base64,' +
2283
+ Buffer.from(
2284
+ ts.transpileModule(
2285
+ readFileSync(
2286
+ join(projectRoot, 'infra', 'event-subscriptions.ts'),
2287
+ 'utf8',
2288
+ ),
2289
+ {
2290
+ compilerOptions: {
2291
+ module: ts.ModuleKind.ESNext,
2292
+ target: ts.ScriptTarget.ES2022,
2293
+ },
2294
+ },
2295
+ ).outputText,
2296
+ ).toString('base64')
2297
+ );
2298
+ const subscriptions = validator.crossSliceEventSubscriptions(
2299
+ readJson(subscriptionPath),
2300
+ dependencies,
2301
+ );
2302
+ for (const subscription of subscriptions) {
2303
+ const producer = projects.get(subscription.source);
2304
+ if (
2305
+ !producer ||
2306
+ !dependencies.consumes.includes(producer.packageJson.name + '/contracts')
2307
+ ) {
2308
+ throw new Error(
2309
+ 'Subscribed source ' +
2310
+ subscription.source +
2311
+ ' is not a consumed Product Slice contracts package.',
2312
+ );
2313
+ }
2314
+ const schema = producerEventContract(producer, subscription.source);
2315
+ for (const detailType of subscription.detailTypes) {
2316
+ const published = schema.events.filter(
2317
+ (event) => event?.detailType === detailType,
2318
+ );
2319
+ if (
2320
+ published.length !== 1 ||
2321
+ published[0].source !== subscription.source
2322
+ ) {
2323
+ throw new Error(
2324
+ 'Producer ' +
2325
+ subscription.source +
2326
+ ' does not publish ' +
2327
+ detailType +
2328
+ ' in its EventContractSchema. Restore the producer event or ' +
2329
+ 'remove the subscription from contracts/event-subscriptions.json.',
2330
+ );
2331
+ }
2332
+ if (!subscription.schemaVersions.includes(published[0].schemaVersion)) {
2333
+ throw new Error(
2334
+ 'Producer ' +
2335
+ subscription.source +
2336
+ ' publishes ' +
2337
+ detailType +
2338
+ ' schemaVersion ' +
2339
+ published[0].schemaVersion +
2340
+ ', which ${name} does not subscribe to. Accept that version ' +
2341
+ 'in api/event-consumer.ts, then declare it in ' +
2342
+ 'contracts/event-subscriptions.json.',
2343
+ );
2344
+ }
2345
+ }
2346
+ }
2347
+ }
2348
+
2214
2349
  const declaration = readJson(declarationPath);
2215
2350
  if (
2216
2351
  !declaration ||
@@ -2345,6 +2480,7 @@ for (const publication of resolution.contracts) {
2345
2480
  const current = [...(ownership.contracts?.consumes ?? [])].sort();
2346
2481
  const expected = [...normalized.contracts.consumes];
2347
2482
  if (action === 'check') {
2483
+ await checkEventSubscriptions(declaration, projects);
2348
2484
  if (JSON.stringify(current) !== JSON.stringify(expected)) {
2349
2485
  throw new Error(
2350
2486
  'Contract declarations are out of sync. Run ' +
@@ -300,7 +300,7 @@ RUN --network=none pnpm --config.inject-workspace-packages=true --config.store-d
300
300
 
301
301
  FROM ${frozen_container_js_1.WORKLOAD_CONTAINER_NODE_IMAGE}
302
302
  WORKDIR /app
303
- ADD --chown=node:node --chmod=0444 --checksum=sha256:fe45bbebf92ad3e27a583bbb2ddd1553c521ed4d49af5514dc0a40372ea5395c https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem ./rds-global-bundle.pem
303
+ ADD --chown=node:node --chmod=0444 --checksum=sha256:90a6f1a7978a1b1b096dca6c57511ca48d3b8cf052f8e704baf358f34ea2f21b https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem ./rds-global-bundle.pem
304
304
  COPY --from=build --chown=node:node /opt/migration ./
305
305
  COPY --chown=node:node packages/${name}/jobs/database-lifecycle-logging.mjs ./jobs/database-lifecycle-logging.mjs
306
306
  COPY --chown=node:node packages/${name}/jobs/bootstrap-database.mjs ./jobs/bootstrap-database.mjs
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Literal-only evaluator for a Slice's canonical EventContractSchema export.
3
+ * Release compatibility and the cross-Slice subscription check render the
4
+ * same source so both read a producer contract identically.
5
+ */
6
+ export declare const EVENT_CONTRACT_LITERAL_SOURCE = "const eventLiteral = (node) => {\n while (\n ts.isAsExpression(node) ||\n ts.isSatisfiesExpression(node) ||\n ts.isParenthesizedExpression(node)\n ) {\n node = node.expression;\n }\n if (ts.isObjectLiteralExpression(node)) {\n return Object.fromEntries(\n node.properties.map((property) => {\n if (\n !ts.isPropertyAssignment(property) ||\n !(\n ts.isIdentifier(property.name) ||\n ts.isStringLiteral(property.name)\n )\n ) {\n throw new Error(\n 'EventContractSchema accepts only explicit literal properties.',\n );\n }\n return [property.name.text, eventLiteral(property.initializer)];\n }),\n );\n }\n if (ts.isArrayLiteralExpression(node)) {\n return node.elements.map(eventLiteral);\n }\n if (ts.isStringLiteral(node) || ts.isNumericLiteral(node)) {\n return ts.isNumericLiteral(node) ? Number(node.text) : node.text;\n }\n if (\n node.kind === ts.SyntaxKind.TrueKeyword ||\n node.kind === ts.SyntaxKind.FalseKeyword\n ) {\n return node.kind === ts.SyntaxKind.TrueKeyword;\n }\n throw new Error(\n 'EventContractSchema must remain a canonical literal-only export.',\n );\n};\n";
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EVENT_CONTRACT_LITERAL_SOURCE = void 0;
4
+ /**
5
+ * Literal-only evaluator for a Slice's canonical EventContractSchema export.
6
+ * Release compatibility and the cross-Slice subscription check render the
7
+ * same source so both read a producer contract identically.
8
+ */
9
+ exports.EVENT_CONTRACT_LITERAL_SOURCE = `const eventLiteral = (node) => {
10
+ while (
11
+ ts.isAsExpression(node) ||
12
+ ts.isSatisfiesExpression(node) ||
13
+ ts.isParenthesizedExpression(node)
14
+ ) {
15
+ node = node.expression;
16
+ }
17
+ if (ts.isObjectLiteralExpression(node)) {
18
+ return Object.fromEntries(
19
+ node.properties.map((property) => {
20
+ if (
21
+ !ts.isPropertyAssignment(property) ||
22
+ !(
23
+ ts.isIdentifier(property.name) ||
24
+ ts.isStringLiteral(property.name)
25
+ )
26
+ ) {
27
+ throw new Error(
28
+ 'EventContractSchema accepts only explicit literal properties.',
29
+ );
30
+ }
31
+ return [property.name.text, eventLiteral(property.initializer)];
32
+ }),
33
+ );
34
+ }
35
+ if (ts.isArrayLiteralExpression(node)) {
36
+ return node.elements.map(eventLiteral);
37
+ }
38
+ if (ts.isStringLiteral(node) || ts.isNumericLiteral(node)) {
39
+ return ts.isNumericLiteral(node) ? Number(node.text) : node.text;
40
+ }
41
+ if (
42
+ node.kind === ts.SyntaxKind.TrueKeyword ||
43
+ node.kind === ts.SyntaxKind.FalseKeyword
44
+ ) {
45
+ return node.kind === ts.SyntaxKind.TrueKeyword;
46
+ }
47
+ throw new Error(
48
+ 'EventContractSchema must remain a canonical literal-only export.',
49
+ );
50
+ };
51
+ `;
52
+ //# sourceMappingURL=built-in-plan-event-contract-literal.js.map