@fabricorg/fabric-gen 0.6.3 → 0.7.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.
package/dist/cli.cjs CHANGED
@@ -27,7 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var import_promises = require("fs/promises");
28
28
  var import_node_crypto = require("crypto");
29
29
  var import_node_path = __toESM(require("path"), 1);
30
+ var import_node_url = require("url");
30
31
  var import_compiler = require("@fabricorg/compiler");
32
+ var import_manifest = require("@fabricorg/platform/manifest");
31
33
  var import_gen_capability = require("@fabricorg/gen-capability");
32
34
  var import_gen_docs = require("@fabricorg/gen-docs");
33
35
  var import_gen_events = require("@fabricorg/gen-events");
@@ -53,6 +55,7 @@ var compareCanonicalStrings = (left, right) => left < right ? -1 : left > right
53
55
  var usage = [
54
56
  "Usage:",
55
57
  " fabric-gen init capability <namespace> [--directory <path>]",
58
+ " fabric-gen export --module <file> [--export <name>] --out <manifest.json>",
56
59
  " fabric-gen init experience <application> [--directory <path>]",
57
60
  " fabric-gen check-application [--config <path>]",
58
61
  " fabric-gen promote-experience --config <path> --key <pem> [--out <path>]",
@@ -72,6 +75,13 @@ function flagValue(args2, flag) {
72
75
  return value;
73
76
  }
74
77
  async function runFabricGenCommand(args2) {
78
+ if (args2[0] === "export") {
79
+ const moduleFile = flagValue(args2, "--module");
80
+ const out = flagValue(args2, "--out");
81
+ if (!moduleFile || !out) throw new FabricGenUsageError(usage);
82
+ const result2 = await exportModuleManifestFile({ moduleFile, out, exportName: flagValue(args2, "--export") });
83
+ return `Exported "${result2.namespace}" from ${result2.exportName} to ${out}: ${result2.objectTypes} object types, ${result2.actions} actions, ${result2.eventTypes} event types.`;
84
+ }
75
85
  if (args2[0] === "init") {
76
86
  if (!args2[2] || args2[2].startsWith("--")) {
77
87
  throw new FabricGenUsageError(usage);
@@ -121,6 +131,40 @@ async function runFabricGenCommand(args2) {
121
131
  });
122
132
  return `${args2.includes("--check") ? "Checked" : "Generated"} ${result.files.length} files.`;
123
133
  }
134
+ function experienceReadme(application) {
135
+ return [
136
+ `# ${application} experience integration`,
137
+ "",
138
+ "| File | What it is |",
139
+ "| --- | --- |",
140
+ "| `fabric.experience.ts` | The server runtime and gateway, wired to your host. |",
141
+ "| `fabric.component-pack.ts` | The components this application is allowed to render. |",
142
+ "| `fabric.application.json` | What the deployment gate reads. |",
143
+ "| `fabric.assembly.lock.json` | The resolved assembly. Empty until you add capabilities. |",
144
+ "| `fabric.runtime.json` | Capabilities the running host actually registers. |",
145
+ "",
146
+ "## Install",
147
+ "",
148
+ "The scaffolded files import three packages this generator does not install:",
149
+ "",
150
+ "```bash",
151
+ "pnpm add @fabricorg/experience-runtime @fabricorg/experience-gateway @fabricorg/component-pack",
152
+ "```",
153
+ "",
154
+ "## Check it",
155
+ "",
156
+ "```bash",
157
+ "fabric-gen check-application --config fabric.application.json",
158
+ "```",
159
+ "",
160
+ "It passes on the scaffold and keeps passing as you add capabilities, as long",
161
+ "as the lockfile, the runtime capabilities, and every promoted release agree.",
162
+ "Regenerate the lockfile from your composition root with `resolveAssembly`;",
163
+ "`fabric.runtime.json` must list what that same root registers with the host,",
164
+ "which is what stops a deployment from serving a plan its host cannot answer.",
165
+ ""
166
+ ].join("\n");
167
+ }
124
168
  async function initializeExperience(options) {
125
169
  if (!/^[a-z][a-z0-9-]*$/.test(options.application)) {
126
170
  throw new Error("Application name must use lowercase letters, numbers, and hyphens.");
@@ -172,6 +216,35 @@ async function initializeExperience(options) {
172
216
  releases: []
173
217
  }, null, 2)}
174
218
  `
219
+ ],
220
+ // The application config names these two files, so the scaffold has to
221
+ // produce them. Without them `fabric-gen check-application`, the very
222
+ // next step, failed on a missing file rather than on anything the
223
+ // author had done. The lockfile is resolved here, not hand-written, so
224
+ // it carries a real assembly digest from the first commit.
225
+ [
226
+ import_node_path.default.join(options.directory, "fabric.assembly.lock.json"),
227
+ `${JSON.stringify((0, import_assembly.resolveAssembly)({
228
+ manifest: {
229
+ formatVersion: 2,
230
+ application: options.application,
231
+ capabilities: [],
232
+ componentPacks: [],
233
+ bindings: [],
234
+ contracts: []
235
+ },
236
+ capabilities: [],
237
+ componentPacks: []
238
+ }).lockfile, null, 2)}
239
+ `
240
+ ],
241
+ [
242
+ import_node_path.default.join(options.directory, "fabric.runtime.json"),
243
+ "[]\n"
244
+ ],
245
+ [
246
+ import_node_path.default.join(options.directory, "README.md"),
247
+ experienceReadme(options.application)
175
248
  ]
176
249
  ];
177
250
  await (0, import_promises.mkdir)(options.directory, { recursive: true });
@@ -245,14 +318,54 @@ async function checkApplication(options) {
245
318
  assemblyDigest: assembly.assemblyDigest
246
319
  };
247
320
  }
321
+ async function exportModuleManifestFile(options) {
322
+ const absolute = import_node_path.default.resolve(options.moduleFile);
323
+ let loaded;
324
+ try {
325
+ loaded = await import((0, import_node_url.pathToFileURL)(absolute).href);
326
+ } catch (error) {
327
+ const reason = error instanceof Error ? error.message : String(error);
328
+ throw new Error(`Could not load module file "${options.moduleFile}": ${reason}
329
+ A TypeScript file needs a runtime that strips types (Node 22.18 or newer); otherwise point --module at the built JavaScript.`);
330
+ }
331
+ const candidates = Object.entries(loaded).filter(([, value]) => isFabricModuleLike(value));
332
+ let entry;
333
+ if (options.exportName) {
334
+ const named = loaded[options.exportName];
335
+ if (named === void 0) throw new Error(`"${options.moduleFile}" has no export named "${options.exportName}". It exports: ${Object.keys(loaded).join(", ") || "nothing"}.`);
336
+ if (!isFabricModuleLike(named)) throw new Error(`Export "${options.exportName}" of "${options.moduleFile}" is not a FabricModule: it has no string "namespace".`);
337
+ entry = [options.exportName, named];
338
+ } else if (candidates.length === 1) {
339
+ entry = candidates[0];
340
+ } else if (candidates.length === 0) {
341
+ throw new Error(`"${options.moduleFile}" exports no FabricModule. Export one, with a string "namespace", or name it with --export.`);
342
+ } else {
343
+ throw new Error(`"${options.moduleFile}" exports ${candidates.length} modules (${candidates.map(([name]) => name).join(", ")}). Choose one with --export.`);
344
+ }
345
+ const manifest = (0, import_manifest.exportModuleManifest)(entry[1]);
346
+ (0, import_compiler.compileManifestBundle)({ manifestVersion: 2, modules: [manifest] });
347
+ await (0, import_promises.mkdir)(import_node_path.default.dirname(import_node_path.default.resolve(options.out)), { recursive: true });
348
+ await (0, import_promises.writeFile)(import_node_path.default.resolve(options.out), `${JSON.stringify(manifest, null, 2)}
349
+ `, "utf8");
350
+ return {
351
+ namespace: manifest.namespace,
352
+ exportName: entry[0],
353
+ objectTypes: manifest.objectTypes.length,
354
+ actions: manifest.actions.length,
355
+ eventTypes: manifest.eventTypes.length
356
+ };
357
+ }
358
+ function isFabricModuleLike(value) {
359
+ return typeof value === "object" && value !== null && typeof value.namespace === "string";
360
+ }
248
361
  async function initializeCapability(options) {
249
362
  if (!/^[a-z][a-z0-9-]*$/.test(options.namespace)) {
250
363
  throw new Error("Capability namespace must use lowercase letters, numbers, and hyphens.");
251
364
  }
252
365
  const displayName = options.namespace.split("-").map((part, index) => index === 0 ? `${part.charAt(0).toUpperCase()}${part.slice(1)}` : part).join(" ");
253
- const manifestPath = import_node_path.default.join(options.directory, "fabric.manifest.json");
366
+ const modulePath = import_node_path.default.join(options.directory, "module.ts");
254
367
  const readmePath = import_node_path.default.join(options.directory, "README.md");
255
- for (const file of [readmePath, manifestPath]) {
368
+ for (const file of [readmePath, modulePath]) {
256
369
  try {
257
370
  await (0, import_promises.access)(file);
258
371
  throw new Error(`Refusing to overwrite existing file "${file}".`);
@@ -261,33 +374,108 @@ async function initializeCapability(options) {
261
374
  if (error.code !== "ENOENT") throw error;
262
375
  }
263
376
  }
264
- const manifest = {
265
- manifestVersion: 2,
266
- namespace: options.namespace,
267
- objectTypes: [],
268
- subjectTypes: [],
269
- idPrefixes: [],
270
- dependencies: [],
271
- policies: [],
272
- eventTypes: [],
273
- actions: [],
274
- views: [],
275
- stateMachines: [],
276
- capability: {
277
- displayName,
278
- description: `Governed ${displayName.toLowerCase()} capability.`,
279
- stability: "experimental"
280
- }
281
- };
377
+ const module2 = [
378
+ `import type { ActionDefinition } from "@fabricorg/platform/actions";`,
379
+ `import type { FabricModule } from "@fabricorg/platform/modules";`,
380
+ "",
381
+ `/** One governed action. Every field below is checked when the manifest is exported. */`,
382
+ `const recordExample: ActionDefinition = {`,
383
+ ` actionId: "${options.namespace}.record_example",`,
384
+ ` namespace: "${options.namespace}",`,
385
+ " version: 1,",
386
+ ' kind: "atomic",',
387
+ " idempotent: true,",
388
+ " mutatesDomain: true,",
389
+ ' emitsEvents: ["ExampleRecorded"],',
390
+ " // The six execution dimensions. A strict certification profile requires all of them.",
391
+ " execution: {",
392
+ ' connectivity: "online-required",',
393
+ ' authorityMoment: "execution",',
394
+ ' idempotency: "required",',
395
+ ' completion: "immediate",',
396
+ ' consistency: "authoritative-now",',
397
+ ' sensitivity: "internal",',
398
+ " },",
399
+ " schema: {",
400
+ " parse(value: unknown): { exampleId: string } {",
401
+ " const input = value as { exampleId?: unknown };",
402
+ ' if (typeof input?.exampleId !== "string") throw new Error("exampleId is required");',
403
+ " return { exampleId: input.exampleId };",
404
+ " },",
405
+ " safeParse(value: unknown) {",
406
+ " try {",
407
+ " return { success: true as const, data: this.parse(value) };",
408
+ " } catch (error) {",
409
+ ' return { success: false as const, error: { issues: [{ path: ["exampleId"], message: error instanceof Error ? error.message : String(error) }] } };',
410
+ " }",
411
+ " },",
412
+ " },",
413
+ " handler: async (_context, parameters) => ({",
414
+ " success: true,",
415
+ " data: {",
416
+ " ...(parameters as { exampleId: string }),",
417
+ " _events: [{",
418
+ ' eventType: "ExampleRecorded",',
419
+ ' entityType: "Example",',
420
+ " entityId: (parameters as { exampleId: string }).exampleId,",
421
+ " payload: parameters,",
422
+ " }],",
423
+ " },",
424
+ " }),",
425
+ "};",
426
+ "",
427
+ `export const ${camelCase(options.namespace)}Module: FabricModule = {`,
428
+ ` namespace: "${options.namespace}",`,
429
+ ' version: "0.1.0",',
430
+ " capability: {",
431
+ ` displayName: "${displayName}",`,
432
+ ` description: "Governed ${displayName.toLowerCase()} capability.",`,
433
+ ' stability: "experimental",',
434
+ " },",
435
+ " objectTypes: [{",
436
+ ' type: "Example",',
437
+ " schema: {",
438
+ ' type: "object",',
439
+ ' properties: { exampleId: { type: "string" } },',
440
+ ' required: ["exampleId"],',
441
+ " },",
442
+ " }],",
443
+ ` idPrefixes: [{ prefix: "exm", name: "Example", module: "${options.namespace}" }],`,
444
+ ' eventTypes: [{ eventType: "ExampleRecorded", schemaVersion: 1 }],',
445
+ " actions: [recordExample],",
446
+ "};",
447
+ ""
448
+ ].join("\n");
282
449
  const readme = [
283
450
  `# ${displayName}`,
284
451
  "",
285
- "Define domain objects, governed actions, events, and projections in `fabric.manifest.json`.",
452
+ "`module.ts` is the source of truth. It is TypeScript, so the shape of every",
453
+ "action, object type, and event is checked as you write it.",
454
+ "",
455
+ "## The loop",
286
456
  "",
287
457
  "```bash",
458
+ "# 1. Export the authored module to the normalized manifest the generators read.",
459
+ "fabric-gen export --module module.ts --out fabric.manifest.json",
460
+ "",
461
+ "# 2. Generate types, event contracts, the usage contract, and docs.",
288
462
  "fabric-gen --input fabric.manifest.json --out generated",
463
+ "",
464
+ "# 3. In CI, prove the generated files match the manifest.",
289
465
  "fabric-gen --input fabric.manifest.json --out generated --check",
290
466
  "```",
467
+ "",
468
+ "Commit both `fabric.manifest.json` and `generated/`. The manifest is the",
469
+ "contract other capabilities and applications compile against; regenerating",
470
+ "is how a consumer learns what changed.",
471
+ "",
472
+ "## What to edit",
473
+ "",
474
+ "- **Object types** carry a portable JSON Schema. They become generated TypeScript types.",
475
+ "- **Actions** declare six execution dimensions. A host refuses an action whose",
476
+ " declaration does not match how it is invoked, so declare them honestly.",
477
+ "- **Events** are the capability's public vocabulary. Adding a field is compatible;",
478
+ " removing or retyping one is not.",
291
479
  ""
292
480
  ].join("\n");
293
481
  await (0, import_promises.mkdir)(options.directory, { recursive: true });
@@ -295,8 +483,7 @@ async function initializeCapability(options) {
295
483
  try {
296
484
  for (const [file, content] of [
297
485
  [readmePath, readme],
298
- [manifestPath, `${JSON.stringify(manifest, null, 2)}
299
- `]
486
+ [modulePath, module2]
300
487
  ]) {
301
488
  await (0, import_promises.writeFile)(file, content, { encoding: "utf8", flag: "wx" });
302
489
  created.push(file);
@@ -310,6 +497,9 @@ async function initializeCapability(options) {
310
497
  }
311
498
  return { created };
312
499
  }
500
+ function camelCase(namespace) {
501
+ return namespace.split("-").map((part, index) => index === 0 ? part : `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("");
502
+ }
313
503
  async function generateFromManifest(options) {
314
504
  const input = JSON.parse(await (0, import_promises.readFile)(options.inputPath, "utf8"));
315
505
  if (!input || typeof input !== "object" || Array.isArray(input)) throw new Error("Manifest input must be a JSON object.");
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../index.ts","../cli.ts"],"sourcesContent":["import { access, mkdir, readFile, readdir, rm, writeFile } from \"node:fs/promises\";\nimport { createPrivateKey } from \"node:crypto\";\nimport path from \"node:path\";\nimport { compileManifestBundle, runGenerator, type GeneratedFile, type GeneratorTarget } from \"@fabricorg/compiler\";\nimport { capabilityGenerator } from \"@fabricorg/gen-capability\";\nimport { docsGenerator } from \"@fabricorg/gen-docs\";\nimport { eventsGenerator } from \"@fabricorg/gen-events\";\nimport { typesGenerator } from \"@fabricorg/gen-types\";\nimport { prismaGenerator } from \"@fabricorg/gen-prisma\";\nimport { graphqlGenerator } from \"@fabricorg/gen-graphql\";\nimport { sduiGenerator } from \"@fabricorg/gen-sdui\";\nimport type { UsageContractDocument } from \"@fabricorg/gen-capability\";\nimport { createEs256ReleaseSigner, promoteExperienceRelease } from \"@fabricorg/sdui-composer\";\nimport { conformanceGenerator } from \"@fabricorg/gen-conformance\";\nimport {\n\tassertAssemblyLockfile,\n\tassertAssemblyRuntimeCompatible,\n\ttype AssemblyLockfile,\n\ttype AvailableCapability,\n} from \"@fabricorg/assembly\";\nimport {\n\tassertSduiReleaseIntegrity,\n\ttype SduiRelease,\n} from \"@fabricorg/sdui-release\";\n\nexport const GENERATOR_TARGETS: Record<string, GeneratorTarget> = {\n\ttypes: typesGenerator,\n\tevents: eventsGenerator,\n\tcapability: capabilityGenerator,\n\tdocs: docsGenerator,\n\tprisma: prismaGenerator,\n\tgraphql: graphqlGenerator,\n\tsdui: sduiGenerator,\n\tconformance: conformanceGenerator,\n};\nconst compareCanonicalStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\n\nexport interface GenerateOptions { inputPath: string; outputDirectory: string; targets: string[]; check?: boolean; }\nexport interface GenerateResult { changed: string[]; stale: string[]; files: GeneratedFile[]; }\nexport interface InitializeCapabilityOptions { directory: string; namespace: string; }\nexport interface InitializeCapabilityResult { created: string[]; }\nexport interface InitializeExperienceOptions { directory: string; application: string; }\nexport interface InitializeExperienceResult { created: string[]; }\nexport interface CheckApplicationOptions { configPath: string; }\nexport interface PromoteExperienceOptions {\n\tconfigPath: string;\n\t/** PEM-encoded ES256 private key. Never read from the configuration file. */\n\tprivateKeyPath: string;\n\toutputPath?: string;\n}\nexport interface PromoteExperienceResult {\n\tapplication: string;\n\treleaseDigest: string;\n\tassemblyDigest: string;\n\troutes: { views: number; intents: number };\n\toutputPath: string;\n}\nexport interface CheckApplicationResult {\n\tapplication: string;\n\tcapabilities: number;\n\treleases: number;\n\tassemblyDigest: string;\n}\n\nconst usage = [\n\t\"Usage:\",\n\t\" fabric-gen init capability <namespace> [--directory <path>]\",\n\t\" fabric-gen init experience <application> [--directory <path>]\",\n\t\" fabric-gen check-application [--config <path>]\",\n\t\" fabric-gen promote-experience --config <path> --key <pem> [--out <path>]\",\n\t\" fabric-gen --input <manifest.json> --out <directory> [--targets <list>] [--check]\",\n].join(\"\\n\");\n\nexport class FabricGenUsageError extends Error {\n\toverride readonly name = \"FabricGenUsageError\";\n}\n\nexport function fabricGenCliExitCode(error: unknown): number {\n\treturn error instanceof FabricGenUsageError ? 2 : 1;\n}\n\nfunction flagValue(args: readonly string[], flag: string): string | undefined {\n\tconst index = args.indexOf(flag);\n\tif (index < 0) return undefined;\n\tconst value = args[index + 1];\n\tif (!value || value.startsWith(\"--\")) throw new FabricGenUsageError(usage);\n\treturn value;\n}\n\n/** Execute one CLI command and return its single human-readable result line. */\nexport async function runFabricGenCommand(args: readonly string[]): Promise<string> {\n\tif (args[0] === \"init\") {\n\t\tif (!args[2] || args[2].startsWith(\"--\")) {\n\t\t\tthrow new FabricGenUsageError(usage);\n\t\t}\n\t\tconst name = args[2];\n\t\tconst directory = flagValue(args, \"--directory\") ?? name;\n\t\tif (args[1] === \"capability\") {\n\t\t\tconst result = await initializeCapability({ directory, namespace: name });\n\t\t\treturn `Initialized capability \"${name}\" with ${result.created.length} files.`;\n\t\t}\n\t\tif (args[1] === \"experience\") {\n\t\t\tconst result = await initializeExperience({ directory, application: name });\n\t\t\treturn `Initialized experience integration \"${name}\" with ${result.created.length} files.`;\n\t\t}\n\t\tthrow new FabricGenUsageError(usage);\n\t}\n\tif (args[0] === \"promote-experience\") {\n\t\tconst configPath = flagValue(args, \"--config\");\n\t\tconst privateKeyPath = flagValue(args, \"--key\");\n\t\tif (!configPath) throw new FabricGenUsageError(\"promote-experience requires --config.\");\n\t\tif (!privateKeyPath) throw new FabricGenUsageError(\"promote-experience requires --key.\");\n\t\tconst outputPath = flagValue(args, \"--out\");\n\t\tconst result = await promoteExperience({\n\t\t\tconfigPath,\n\t\t\tprivateKeyPath,\n\t\t\t...(outputPath ? { outputPath } : {}),\n\t\t});\n\t\treturn [\n\t\t\t`Promoted ${result.application} release ${result.releaseDigest.slice(0, 12)} against assembly ${result.assemblyDigest.slice(0, 12)}.`,\n\t\t\t`Routes: ${result.routes.views} views, ${result.routes.intents} intents.`,\n\t\t\t`Wrote ${result.outputPath}`,\n\t\t].join(\"\\n\");\n\t}\n\n\tif (args[0] === \"check-application\") {\n\t\tconst configPath = flagValue(args, \"--config\") ?? \"fabric.application.json\";\n\t\tconst result = await checkApplication({ configPath });\n\t\treturn `Checked \"${result.application}\": ${result.capabilities} capabilities, ${result.releases} releases.`;\n\t}\n\tconst inputPath = flagValue(args, \"--input\");\n\tconst outputDirectory = flagValue(args, \"--out\");\n\tif (!inputPath || !outputDirectory) throw new FabricGenUsageError(usage);\n\tconst result = await generateFromManifest({\n\t\tinputPath,\n\t\toutputDirectory,\n\t\ttargets: (flagValue(args, \"--targets\") ?? \"types,events,capability,docs\")\n\t\t\t.split(\",\")\n\t\t\t.filter(Boolean),\n\t\tcheck: args.includes(\"--check\"),\n\t});\n\treturn `${args.includes(\"--check\") ? \"Checked\" : \"Generated\"} ${result.files.length} files.`;\n}\n\n/**\n * Add experience integration files to an existing application. It deliberately\n * does not create package.json, routes, authentication, billing, or navigation:\n * those remain owned by the Supastarter-derived application shell.\n */\nexport async function initializeExperience(\n\toptions: InitializeExperienceOptions,\n): Promise<InitializeExperienceResult> {\n\tif (!/^[a-z][a-z0-9-]*$/.test(options.application)) {\n\t\tthrow new Error(\"Application name must use lowercase letters, numbers, and hyphens.\");\n\t}\n\tconst functionName = options.application\n\t\t.split(\"-\")\n\t\t.map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`)\n\t\t.join(\"\");\n\tconst files = [\n\t\t[\n\t\t\tpath.join(options.directory, \"fabric.experience.ts\"),\n\t\t\t[\n\t\t\t\t'import { createExperienceServerRuntime } from \"@fabricorg/experience-runtime/server\";',\n\t\t\t\t'import { createExperienceGateway } from \"@fabricorg/experience-gateway\";',\n\t\t\t\t\"\",\n\t\t\t\t`export const create${functionName}ExperienceRuntime = (`,\n\t\t\t\t\"\\toptions: Parameters<typeof createExperienceServerRuntime>[0],\",\n\t\t\t\t\") => createExperienceServerRuntime(options);\",\n\t\t\t\t\"\",\n\t\t\t\t`export const create${functionName}ExperienceGateway = (`,\n\t\t\t\t\"\\toptions: Parameters<typeof createExperienceGateway>[0],\",\n\t\t\t\t\") => createExperienceGateway(options);\",\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\"),\n\t\t],\n\t\t[\n\t\t\tpath.join(options.directory, \"fabric.component-pack.ts\"),\n\t\t\t[\n\t\t\t\t'import { defineComponentPack } from \"@fabricorg/component-pack\";',\n\t\t\t\t\"\",\n\t\t\t\t`export const define${functionName}ComponentPack = (artifactDigest: string) =>`,\n\t\t\t\t\"\\tdefineComponentPack({\",\n\t\t\t\t`\\t\\tname: \"${options.application}\",`,\n\t\t\t\t`\\t\\tnamespace: \"${options.application}\",`,\n\t\t\t\t'\\t\\tversion: \"0.1.0\",',\n\t\t\t\t\"\\t\\tartifactDigest,\",\n\t\t\t\t'\\t\\ttokenContract: { name: \"fabric-family\", version: \"1.0.0\" },',\n\t\t\t\t\"\\t\\tcomponents: {\",\n\t\t\t\t'\\t\\t\\tText: { module: \"./components/text.js\", roles: [\"content\"], slots: [] },',\n\t\t\t\t\"\\t\\t},\",\n\t\t\t\t\"\\t});\",\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\"),\n\t\t],\n\t\t[\n\t\t\tpath.join(options.directory, \"fabric.application.json\"),\n\t\t\t`${JSON.stringify({\n\t\t\t\tformatVersion: 1,\n\t\t\t\tapplication: options.application,\n\t\t\t\tassembly: \"./fabric.assembly.lock.json\",\n\t\t\t\truntimeCapabilities: \"./fabric.runtime.json\",\n\t\t\t\treleases: [],\n\t\t\t}, null, 2)}\\n`,\n\t\t],\n\t] as const;\n\tawait mkdir(options.directory, { recursive: true });\n\tconst created: string[] = [];\n\ttry {\n\t\tfor (const [file, content] of files) {\n\t\t\tawait writeFile(file, content, { encoding: \"utf8\", flag: \"wx\" });\n\t\t\tcreated.push(file);\n\t\t}\n\t} catch (error) {\n\t\tawait Promise.all(created.map((file) => rm(file, { force: true })));\n\t\tif ((error as NodeJS.ErrnoException).code === \"EEXIST\") {\n\t\t\tthrow new Error(\"Refusing to overwrite an existing experience integration file.\");\n\t\t}\n\t\tthrow error;\n\t}\n\treturn { created };\n}\n\ninterface ApplicationCheckConfig {\n\tformatVersion: 1;\n\tassembly: string;\n\truntimeCapabilities: string;\n\treleases: string[];\n}\n\nasync function readJson(file: string): Promise<unknown> {\n\treturn JSON.parse(await readFile(file, \"utf8\"));\n}\n\nfunction assertApplicationCheckConfig(value: unknown): asserts value is ApplicationCheckConfig {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(\"Application check configuration must be a JSON object.\");\n\t}\n\tconst config = value as Record<string, unknown>;\n\tif (config.formatVersion !== 1) throw new Error(\"Application check configuration formatVersion must be 1.\");\n\tif (typeof config.assembly !== \"string\" || !config.assembly) {\n\t\tthrow new Error(\"Application check configuration assembly must be a file path.\");\n\t}\n\tif (typeof config.runtimeCapabilities !== \"string\" || !config.runtimeCapabilities) {\n\t\tthrow new Error(\"Application check configuration runtimeCapabilities must be a file path.\");\n\t}\n\tif (!Array.isArray(config.releases) || !config.releases.every((entry) => typeof entry === \"string\" && entry)) {\n\t\tthrow new Error(\"Application check configuration releases must be an array of file paths.\");\n\t}\n}\n\n/**\n * Verify an application's immutable composition inputs before deployment.\n * Every runtime capability must exactly match the approved lockfile, and every\n * promoted experience release must be intact and bound to that assembly.\n */\nexport async function checkApplication(\n\toptions: CheckApplicationOptions,\n): Promise<CheckApplicationResult> {\n\tconst configValue = await readJson(options.configPath);\n\tassertApplicationCheckConfig(configValue);\n\tconst base = path.dirname(options.configPath);\n\tconst resolve = (file: string): string => path.resolve(base, file);\n\tconst assembly = await readJson(resolve(configValue.assembly)) as AssemblyLockfile;\n\tassertAssemblyLockfile(assembly);\n\tconst runtimeCapabilities = await readJson(\n\t\tresolve(configValue.runtimeCapabilities),\n\t) as AvailableCapability[];\n\tif (!Array.isArray(runtimeCapabilities)) {\n\t\tthrow new Error(\"Runtime capabilities must be a JSON array.\");\n\t}\n\tassertAssemblyRuntimeCompatible(assembly, runtimeCapabilities);\n\tfor (const releasePath of configValue.releases) {\n\t\tconst release = await readJson(resolve(releasePath)) as SduiRelease;\n\t\ttry {\n\t\t\tassertSduiReleaseIntegrity(release);\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Experience release \"${releasePath}\" is invalid: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (release.assemblyDigest !== assembly.assemblyDigest) {\n\t\t\tthrow new Error(\n\t\t\t\t`Experience release \"${release.document.name}@${release.document.version}\" belongs to assembly \"${release.assemblyDigest}\", not \"${assembly.assemblyDigest}\".`,\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\tapplication: assembly.application,\n\t\tcapabilities: assembly.capabilities.length,\n\t\treleases: configValue.releases.length,\n\t\tassemblyDigest: assembly.assemblyDigest,\n\t};\n}\n\n/**\n * Create the smallest useful capability source tree. The manifest is accepted\n * by the compiler immediately, while leaving domain vocabulary to the adopter.\n */\nexport async function initializeCapability(\n\toptions: InitializeCapabilityOptions,\n): Promise<InitializeCapabilityResult> {\n\tif (!/^[a-z][a-z0-9-]*$/.test(options.namespace)) {\n\t\tthrow new Error(\"Capability namespace must use lowercase letters, numbers, and hyphens.\");\n\t}\n\tconst displayName = options.namespace\n\t\t.split(\"-\")\n\t\t.map((part, index) => index === 0\n\t\t\t? `${part.charAt(0).toUpperCase()}${part.slice(1)}`\n\t\t\t: part)\n\t\t.join(\" \");\n\tconst manifestPath = path.join(options.directory, \"fabric.manifest.json\");\n\tconst readmePath = path.join(options.directory, \"README.md\");\n\tfor (const file of [readmePath, manifestPath]) {\n\t\ttry {\n\t\t\tawait access(file);\n\t\t\tthrow new Error(`Refusing to overwrite existing file \"${file}\".`);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.message.startsWith(\"Refusing to overwrite\")) throw error;\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n\t\t}\n\t}\n\tconst manifest = {\n\t\tmanifestVersion: 2,\n\t\tnamespace: options.namespace,\n\t\tobjectTypes: [],\n\t\tsubjectTypes: [],\n\t\tidPrefixes: [],\n\t\tdependencies: [],\n\t\tpolicies: [],\n\t\teventTypes: [],\n\t\tactions: [],\n\t\tviews: [],\n\t\tstateMachines: [],\n\t\tcapability: {\n\t\t\tdisplayName,\n\t\t\tdescription: `Governed ${displayName.toLowerCase()} capability.`,\n\t\t\tstability: \"experimental\",\n\t\t},\n\t};\n\tconst readme = [\n\t\t`# ${displayName}`,\n\t\t\"\",\n\t\t\"Define domain objects, governed actions, events, and projections in `fabric.manifest.json`.\",\n\t\t\"\",\n\t\t\"```bash\",\n\t\t\"fabric-gen --input fabric.manifest.json --out generated\",\n\t\t\"fabric-gen --input fabric.manifest.json --out generated --check\",\n\t\t\"```\",\n\t\t\"\",\n\t].join(\"\\n\");\n\tawait mkdir(options.directory, { recursive: true });\n\tconst created: string[] = [];\n\ttry {\n\t\tfor (const [file, content] of [\n\t\t\t[readmePath, readme],\n\t\t\t[manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`],\n\t\t] as const) {\n\t\t\tawait writeFile(file, content, { encoding: \"utf8\", flag: \"wx\" });\n\t\t\tcreated.push(file);\n\t\t}\n\t} catch (error) {\n\t\tawait Promise.all(created.map((file) => rm(file, { force: true })));\n\t\tif ((error as NodeJS.ErrnoException).code === \"EEXIST\") {\n\t\t\tthrow new Error(\"Refusing to overwrite a file created during capability initialization.\");\n\t\t}\n\t\tthrow error;\n\t}\n\treturn { created };\n}\n\nexport async function generateFromManifest(options: GenerateOptions): Promise<GenerateResult> {\n\tconst input = JSON.parse(await readFile(options.inputPath, \"utf8\"));\n\tif (!input || typeof input !== \"object\" || Array.isArray(input)) throw new Error(\"Manifest input must be a JSON object.\");\n\tconst bundle = \"modules\" in input ? input : { manifestVersion: input.manifestVersion, modules: [input] };\n\tconst ir = compileManifestBundle(bundle);\n\tconst files = (await Promise.all(options.targets.map(async (name) => {\n\t\tconst target = GENERATOR_TARGETS[name];\n\t\tif (!target) throw new Error(`Unknown generator target \"${name}\".`);\n\t\treturn (await runGenerator(target, ir)).map((file) => ({ ...file, path: `${name}/${file.path}` }));\n\t}))).flat().sort((left, right) => compareCanonicalStrings(left.path, right.path));\n\tconst expected = new Set(files.map((file) => file.path));\n\tconst existing = await listFiles(options.outputDirectory);\n\tconst selectedPrefixes = options.targets.map((target) => `${target}/`);\n\tconst stale = existing.filter((file) => selectedPrefixes.some((prefix) => file.startsWith(prefix)) && !expected.has(file));\n\tif (!options.check) await Promise.all(stale.map((file) => rm(path.join(options.outputDirectory, file), { force: true })));\n\tconst changed: string[] = [];\n\tfor (const file of files) {\n\t\tconst target = path.join(options.outputDirectory, file.path);\n\t\tlet current: string | undefined;\n\t\ttry { current = await readFile(target, \"utf8\"); } catch { current = undefined; }\n\t\tif (current !== file.content) {\n\t\t\tchanged.push(file.path);\n\t\t\tif (!options.check) { await mkdir(path.dirname(target), { recursive: true }); await writeFile(target, file.content, \"utf8\"); }\n\t\t}\n\t}\n\tif (options.check && (changed.length || stale.length)) throw new Error(`Generated artifacts drifted: ${[...changed, ...stale.map((file) => `stale:${file}`)].join(\", \")}`);\n\treturn { changed, stale, files };\n}\n\nasync function listFiles(directory: string, prefix = \"\"): Promise<string[]> {\n\tlet entries;\n\ttry { entries = await readdir(directory, { withFileTypes: true }); } catch { return []; }\n\tconst nested = await Promise.all(entries.map((entry) => entry.isDirectory() ? listFiles(path.join(directory, entry.name), `${prefix}${entry.name}/`) : [`${prefix}${entry.name}`]));\n\treturn nested.flat().sort();\n}\n\ninterface ExperiencePromotionConfig {\n\tformatVersion: 1;\n\tapplication: string;\n\tissuer: string;\n\tkeyId: string;\n\tassembly: string;\n\trelease: string;\n\tcontracts: string[];\n}\n\nfunction assertExperiencePromotionConfig(value: unknown): asserts value is ExperiencePromotionConfig {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(\"Experience promotion configuration must be a JSON object.\");\n\t}\n\tconst config = value as Record<string, unknown>;\n\tif (config.formatVersion !== 1) throw new Error(\"Experience promotion configuration formatVersion must be 1.\");\n\tfor (const field of [\"application\", \"issuer\", \"keyId\", \"assembly\", \"release\"] as const) {\n\t\tif (typeof config[field] !== \"string\" || !config[field]) {\n\t\t\tthrow new Error(`Experience promotion configuration ${field} must be a non-empty string.`);\n\t\t}\n\t}\n\t// The application name is interpolated into the default output path and\n\t// signed into the release body, so \"../../x\" would escape the configuration\n\t// directory and \"/etc/x\" would ignore it entirely.\n\tif (!/^[a-z][a-z0-9-]*$/.test(config.application as string)) {\n\t\tthrow new Error(\"Experience promotion configuration application must be lowercase letters, numbers, and hyphens.\");\n\t}\n\tif (!Array.isArray(config.contracts) || !config.contracts.every((entry) => typeof entry === \"string\" && entry)) {\n\t\tthrow new Error(\"Experience promotion configuration contracts must be an array of file paths.\");\n\t}\n\t// A signing key in a checked-in configuration file is a key in version\n\t// control. Enumerating two spellings only catches two spellings, so reject\n\t// anything that reads like one, and reject unknown fields so a future\n\t// spelling cannot arrive unnoticed.\n\tconst known = new Set([\"formatVersion\", \"application\", \"issuer\", \"keyId\", \"assembly\", \"release\", \"contracts\"]);\n\tfor (const field of Object.keys(config)) {\n\t\tif (/key|secret|credential|token|pem|password/i.test(field) && field !== \"keyId\") {\n\t\t\tthrow new Error(`Experience promotion configuration must not carry \"${field}\"; pass the signing key with --key.`);\n\t\t}\n\t\tif (!known.has(field)) {\n\t\t\tthrow new Error(`Experience promotion configuration has an unknown field \"${field}\".`);\n\t\t}\n\t}\n}\n\n/**\n * Turn a validated release into a signed one.\n *\n * Promotion is where a granted `capability://` reference becomes a concrete\n * action id and version, so it is also where that mapping has to be bound to\n * the assembly that approved it. The signing key is a command-line argument\n * rather than a configuration field, because a configuration file is the kind\n * of thing that ends up committed.\n */\nexport async function promoteExperience(\n\toptions: PromoteExperienceOptions,\n): Promise<PromoteExperienceResult> {\n\tconst configValue = await readJson(options.configPath);\n\tassertExperiencePromotionConfig(configValue);\n\tconst base = path.dirname(options.configPath);\n\tconst resolve = (file: string): string => path.resolve(base, file);\n\n\tconst assembly = await readJson(resolve(configValue.assembly)) as AssemblyLockfile;\n\tassertAssemblyLockfile(assembly);\n\tconst release = await readJson(resolve(configValue.release)) as SduiRelease;\n\tassertSduiReleaseIntegrity(release);\n\tconst contracts = await Promise.all(\n\t\tconfigValue.contracts.map(async (file) => await readJson(resolve(file)) as UsageContractDocument),\n\t);\n\n\tconst privateKey = createPrivateKey(await readFile(options.privateKeyPath, \"utf8\"));\n\tconst promoted = await promoteExperienceRelease({\n\t\tapplication: configValue.application,\n\t\trelease,\n\t\tcontracts,\n\t\tassembly,\n\t\tissuer: configValue.issuer,\n\t\tsigner: createEs256ReleaseSigner({ keyId: configValue.keyId, privateKey }),\n\t});\n\n\tconst outputPath = options.outputPath\n\t\t? path.resolve(options.outputPath)\n\t\t: resolve(`${configValue.application}.experience-release.jws`);\n\tawait mkdir(path.dirname(outputPath), { recursive: true });\n\tawait writeFile(outputPath, `${promoted.compactJws}\\n`, \"utf8\");\n\n\treturn {\n\t\tapplication: configValue.application,\n\t\treleaseDigest: release.releaseDigest,\n\t\tassemblyDigest: assembly.assemblyDigest,\n\t\troutes: {\n\t\t\tviews: promoted.release.routes.views.length,\n\t\t\tintents: promoted.release.routes.intents.length,\n\t\t},\n\t\toutputPath,\n\t};\n}\n","#!/usr/bin/env node\nimport { fabricGenCliExitCode, runFabricGenCommand } from \"./index\";\n\nconst args = process.argv.slice(2);\nrunFabricGenCommand(args)\n\t.then((message) => console.log(message))\n\t.catch((error: unknown) => {\n\t\tconsole.error(error instanceof Error ? error.message : String(error));\n\t\tprocess.exitCode = fabricGenCliExitCode(error);\n\t});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sBAAgE;AAChE,yBAAiC;AACjC,uBAAiB;AACjB,sBAA8F;AAC9F,4BAAoC;AACpC,sBAA8B;AAC9B,wBAAgC;AAChC,uBAA+B;AAC/B,wBAAgC;AAChC,yBAAiC;AACjC,sBAA8B;AAE9B,2BAAmE;AACnE,6BAAqC;AACrC,sBAKO;AACP,0BAGO;AAEA,IAAM,oBAAqD;AAAA,EACjE,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,YAAY;A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AAO,SAAS,QAAQ,OAAO,MAAM;AAAA,MACrC,SAAS,SAAS,QAAQ,OAAO,QAAQ;AAAA,IAC1C;AAAA,IACA;AAAA,EACD;AACD;;;ACpfA,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,oBAAoB,IAAI,EACtB,KAAK,CAAC,YAAY,QAAQ,IAAI,OAAO,CAAC,EACtC,MAAM,CAAC,UAAmB;AAC1B,UAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AACpE,UAAQ,WAAW,qBAAqB,KAAK;AAC9C,CAAC;","names":["args","result","path"]}
1
+ {"version":3,"sources":["../index.ts","../cli.ts"],"sourcesContent":["import { access, mkdir, readFile, readdir, rm, writeFile } from \"node:fs/promises\";\nimport { createPrivateKey } from \"node:crypto\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { compileManifestBundle, runGenerator, type GeneratedFile, type GeneratorTarget } from \"@fabricorg/compiler\";\nimport { exportModuleManifest } from \"@fabricorg/platform/manifest\";\nimport { capabilityGenerator } from \"@fabricorg/gen-capability\";\nimport { docsGenerator } from \"@fabricorg/gen-docs\";\nimport { eventsGenerator } from \"@fabricorg/gen-events\";\nimport { typesGenerator } from \"@fabricorg/gen-types\";\nimport { prismaGenerator } from \"@fabricorg/gen-prisma\";\nimport { graphqlGenerator } from \"@fabricorg/gen-graphql\";\nimport { sduiGenerator } from \"@fabricorg/gen-sdui\";\nimport type { UsageContractDocument } from \"@fabricorg/gen-capability\";\nimport { createEs256ReleaseSigner, promoteExperienceRelease } from \"@fabricorg/sdui-composer\";\nimport { conformanceGenerator } from \"@fabricorg/gen-conformance\";\nimport {\n\tassertAssemblyLockfile,\n\tresolveAssembly,\n\tassertAssemblyRuntimeCompatible,\n\ttype AssemblyLockfile,\n\ttype AvailableCapability,\n} from \"@fabricorg/assembly\";\nimport {\n\tassertSduiReleaseIntegrity,\n\ttype SduiRelease,\n} from \"@fabricorg/sdui-release\";\n\nexport const GENERATOR_TARGETS: Record<string, GeneratorTarget> = {\n\ttypes: typesGenerator,\n\tevents: eventsGenerator,\n\tcapability: capabilityGenerator,\n\tdocs: docsGenerator,\n\tprisma: prismaGenerator,\n\tgraphql: graphqlGenerator,\n\tsdui: sduiGenerator,\n\tconformance: conformanceGenerator,\n};\nconst compareCanonicalStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\n\nexport interface GenerateOptions { inputPath: string; outputDirectory: string; targets: string[]; check?: boolean; }\nexport interface GenerateResult { changed: string[]; stale: string[]; files: GeneratedFile[]; }\nexport interface InitializeCapabilityOptions { directory: string; namespace: string; }\nexport interface InitializeCapabilityResult { created: string[]; }\nexport interface InitializeExperienceOptions { directory: string; application: string; }\nexport interface InitializeExperienceResult { created: string[]; }\nexport interface CheckApplicationOptions { configPath: string; }\nexport interface PromoteExperienceOptions {\n\tconfigPath: string;\n\t/** PEM-encoded ES256 private key. Never read from the configuration file. */\n\tprivateKeyPath: string;\n\toutputPath?: string;\n}\nexport interface PromoteExperienceResult {\n\tapplication: string;\n\treleaseDigest: string;\n\tassemblyDigest: string;\n\troutes: { views: number; intents: number };\n\toutputPath: string;\n}\nexport interface CheckApplicationResult {\n\tapplication: string;\n\tcapabilities: number;\n\treleases: number;\n\tassemblyDigest: string;\n}\n\nconst usage = [\n\t\"Usage:\",\n\t\" fabric-gen init capability <namespace> [--directory <path>]\",\n\t\" fabric-gen export --module <file> [--export <name>] --out <manifest.json>\",\n\t\" fabric-gen init experience <application> [--directory <path>]\",\n\t\" fabric-gen check-application [--config <path>]\",\n\t\" fabric-gen promote-experience --config <path> --key <pem> [--out <path>]\",\n\t\" fabric-gen --input <manifest.json> --out <directory> [--targets <list>] [--check]\",\n].join(\"\\n\");\n\nexport class FabricGenUsageError extends Error {\n\toverride readonly name = \"FabricGenUsageError\";\n}\n\nexport function fabricGenCliExitCode(error: unknown): number {\n\treturn error instanceof FabricGenUsageError ? 2 : 1;\n}\n\nfunction flagValue(args: readonly string[], flag: string): string | undefined {\n\tconst index = args.indexOf(flag);\n\tif (index < 0) return undefined;\n\tconst value = args[index + 1];\n\tif (!value || value.startsWith(\"--\")) throw new FabricGenUsageError(usage);\n\treturn value;\n}\n\n/** Execute one CLI command and return its single human-readable result line. */\nexport async function runFabricGenCommand(args: readonly string[]): Promise<string> {\n\tif (args[0] === \"export\") {\n\t\tconst moduleFile = flagValue(args, \"--module\");\n\t\tconst out = flagValue(args, \"--out\");\n\t\tif (!moduleFile || !out) throw new FabricGenUsageError(usage);\n\t\tconst result = await exportModuleManifestFile({ moduleFile, out, exportName: flagValue(args, \"--export\") });\n\t\treturn `Exported \"${result.namespace}\" from ${result.exportName} to ${out}: ${result.objectTypes} object types, ${result.actions} actions, ${result.eventTypes} event types.`;\n\t}\n\tif (args[0] === \"init\") {\n\t\tif (!args[2] || args[2].startsWith(\"--\")) {\n\t\t\tthrow new FabricGenUsageError(usage);\n\t\t}\n\t\tconst name = args[2];\n\t\tconst directory = flagValue(args, \"--directory\") ?? name;\n\t\tif (args[1] === \"capability\") {\n\t\t\tconst result = await initializeCapability({ directory, namespace: name });\n\t\t\treturn `Initialized capability \"${name}\" with ${result.created.length} files.`;\n\t\t}\n\t\tif (args[1] === \"experience\") {\n\t\t\tconst result = await initializeExperience({ directory, application: name });\n\t\t\treturn `Initialized experience integration \"${name}\" with ${result.created.length} files.`;\n\t\t}\n\t\tthrow new FabricGenUsageError(usage);\n\t}\n\tif (args[0] === \"promote-experience\") {\n\t\tconst configPath = flagValue(args, \"--config\");\n\t\tconst privateKeyPath = flagValue(args, \"--key\");\n\t\tif (!configPath) throw new FabricGenUsageError(\"promote-experience requires --config.\");\n\t\tif (!privateKeyPath) throw new FabricGenUsageError(\"promote-experience requires --key.\");\n\t\tconst outputPath = flagValue(args, \"--out\");\n\t\tconst result = await promoteExperience({\n\t\t\tconfigPath,\n\t\t\tprivateKeyPath,\n\t\t\t...(outputPath ? { outputPath } : {}),\n\t\t});\n\t\treturn [\n\t\t\t`Promoted ${result.application} release ${result.releaseDigest.slice(0, 12)} against assembly ${result.assemblyDigest.slice(0, 12)}.`,\n\t\t\t`Routes: ${result.routes.views} views, ${result.routes.intents} intents.`,\n\t\t\t`Wrote ${result.outputPath}`,\n\t\t].join(\"\\n\");\n\t}\n\n\tif (args[0] === \"check-application\") {\n\t\tconst configPath = flagValue(args, \"--config\") ?? \"fabric.application.json\";\n\t\tconst result = await checkApplication({ configPath });\n\t\treturn `Checked \"${result.application}\": ${result.capabilities} capabilities, ${result.releases} releases.`;\n\t}\n\tconst inputPath = flagValue(args, \"--input\");\n\tconst outputDirectory = flagValue(args, \"--out\");\n\tif (!inputPath || !outputDirectory) throw new FabricGenUsageError(usage);\n\tconst result = await generateFromManifest({\n\t\tinputPath,\n\t\toutputDirectory,\n\t\ttargets: (flagValue(args, \"--targets\") ?? \"types,events,capability,docs\")\n\t\t\t.split(\",\")\n\t\t\t.filter(Boolean),\n\t\tcheck: args.includes(\"--check\"),\n\t});\n\treturn `${args.includes(\"--check\") ? \"Checked\" : \"Generated\"} ${result.files.length} files.`;\n}\n\n/**\n * Add experience integration files to an existing application. It deliberately\n * does not create package.json, routes, authentication, billing, or navigation:\n * those remain owned by the Supastarter-derived application shell.\n */\n/** What the scaffolded files are, and what has to be installed for them to compile. */\nfunction experienceReadme(application: string): string {\n\treturn [\n\t\t`# ${application} experience integration`,\n\t\t\"\",\n\t\t\"| File | What it is |\",\n\t\t\"| --- | --- |\",\n\t\t\"| `fabric.experience.ts` | The server runtime and gateway, wired to your host. |\",\n\t\t\"| `fabric.component-pack.ts` | The components this application is allowed to render. |\",\n\t\t\"| `fabric.application.json` | What the deployment gate reads. |\",\n\t\t\"| `fabric.assembly.lock.json` | The resolved assembly. Empty until you add capabilities. |\",\n\t\t\"| `fabric.runtime.json` | Capabilities the running host actually registers. |\",\n\t\t\"\",\n\t\t\"## Install\",\n\t\t\"\",\n\t\t\"The scaffolded files import three packages this generator does not install:\",\n\t\t\"\",\n\t\t\"```bash\",\n\t\t\"pnpm add @fabricorg/experience-runtime @fabricorg/experience-gateway @fabricorg/component-pack\",\n\t\t\"```\",\n\t\t\"\",\n\t\t\"## Check it\",\n\t\t\"\",\n\t\t\"```bash\",\n\t\t\"fabric-gen check-application --config fabric.application.json\",\n\t\t\"```\",\n\t\t\"\",\n\t\t\"It passes on the scaffold and keeps passing as you add capabilities, as long\",\n\t\t\"as the lockfile, the runtime capabilities, and every promoted release agree.\",\n\t\t\"Regenerate the lockfile from your composition root with `resolveAssembly`;\",\n\t\t\"`fabric.runtime.json` must list what that same root registers with the host,\",\n\t\t\"which is what stops a deployment from serving a plan its host cannot answer.\",\n\t\t\"\",\n\t].join(\"\\n\");\n}\n\nexport async function initializeExperience(\n\toptions: InitializeExperienceOptions,\n): Promise<InitializeExperienceResult> {\n\tif (!/^[a-z][a-z0-9-]*$/.test(options.application)) {\n\t\tthrow new Error(\"Application name must use lowercase letters, numbers, and hyphens.\");\n\t}\n\tconst functionName = options.application\n\t\t.split(\"-\")\n\t\t.map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`)\n\t\t.join(\"\");\n\tconst files = [\n\t\t[\n\t\t\tpath.join(options.directory, \"fabric.experience.ts\"),\n\t\t\t[\n\t\t\t\t'import { createExperienceServerRuntime } from \"@fabricorg/experience-runtime/server\";',\n\t\t\t\t'import { createExperienceGateway } from \"@fabricorg/experience-gateway\";',\n\t\t\t\t\"\",\n\t\t\t\t`export const create${functionName}ExperienceRuntime = (`,\n\t\t\t\t\"\\toptions: Parameters<typeof createExperienceServerRuntime>[0],\",\n\t\t\t\t\") => createExperienceServerRuntime(options);\",\n\t\t\t\t\"\",\n\t\t\t\t`export const create${functionName}ExperienceGateway = (`,\n\t\t\t\t\"\\toptions: Parameters<typeof createExperienceGateway>[0],\",\n\t\t\t\t\") => createExperienceGateway(options);\",\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\"),\n\t\t],\n\t\t[\n\t\t\tpath.join(options.directory, \"fabric.component-pack.ts\"),\n\t\t\t[\n\t\t\t\t'import { defineComponentPack } from \"@fabricorg/component-pack\";',\n\t\t\t\t\"\",\n\t\t\t\t`export const define${functionName}ComponentPack = (artifactDigest: string) =>`,\n\t\t\t\t\"\\tdefineComponentPack({\",\n\t\t\t\t`\\t\\tname: \"${options.application}\",`,\n\t\t\t\t`\\t\\tnamespace: \"${options.application}\",`,\n\t\t\t\t'\\t\\tversion: \"0.1.0\",',\n\t\t\t\t\"\\t\\tartifactDigest,\",\n\t\t\t\t'\\t\\ttokenContract: { name: \"fabric-family\", version: \"1.0.0\" },',\n\t\t\t\t\"\\t\\tcomponents: {\",\n\t\t\t\t'\\t\\t\\tText: { module: \"./components/text.js\", roles: [\"content\"], slots: [] },',\n\t\t\t\t\"\\t\\t},\",\n\t\t\t\t\"\\t});\",\n\t\t\t\t\"\",\n\t\t\t].join(\"\\n\"),\n\t\t],\n\t\t[\n\t\t\tpath.join(options.directory, \"fabric.application.json\"),\n\t\t\t`${JSON.stringify({\n\t\t\t\tformatVersion: 1,\n\t\t\t\tapplication: options.application,\n\t\t\t\tassembly: \"./fabric.assembly.lock.json\",\n\t\t\t\truntimeCapabilities: \"./fabric.runtime.json\",\n\t\t\t\treleases: [],\n\t\t\t}, null, 2)}\\n`,\n\t\t],\n\t\t// The application config names these two files, so the scaffold has to\n\t\t// produce them. Without them `fabric-gen check-application`, the very\n\t\t// next step, failed on a missing file rather than on anything the\n\t\t// author had done. The lockfile is resolved here, not hand-written, so\n\t\t// it carries a real assembly digest from the first commit.\n\t\t[\n\t\t\tpath.join(options.directory, \"fabric.assembly.lock.json\"),\n\t\t\t`${JSON.stringify(resolveAssembly({\n\t\t\t\tmanifest: {\n\t\t\t\t\tformatVersion: 2,\n\t\t\t\t\tapplication: options.application,\n\t\t\t\t\tcapabilities: [],\n\t\t\t\t\tcomponentPacks: [],\n\t\t\t\t\tbindings: [],\n\t\t\t\t\tcontracts: [],\n\t\t\t\t},\n\t\t\t\tcapabilities: [],\n\t\t\t\tcomponentPacks: [],\n\t\t\t}).lockfile, null, 2)}\\n`,\n\t\t],\n\t\t[\n\t\t\tpath.join(options.directory, \"fabric.runtime.json\"),\n\t\t\t\"[]\\n\",\n\t\t],\n\t\t[\n\t\t\tpath.join(options.directory, \"README.md\"),\n\t\t\texperienceReadme(options.application),\n\t\t],\n\t] as const;\n\tawait mkdir(options.directory, { recursive: true });\n\tconst created: string[] = [];\n\ttry {\n\t\tfor (const [file, content] of files) {\n\t\t\tawait writeFile(file, content, { encoding: \"utf8\", flag: \"wx\" });\n\t\t\tcreated.push(file);\n\t\t}\n\t} catch (error) {\n\t\tawait Promise.all(created.map((file) => rm(file, { force: true })));\n\t\tif ((error as NodeJS.ErrnoException).code === \"EEXIST\") {\n\t\t\tthrow new Error(\"Refusing to overwrite an existing experience integration file.\");\n\t\t}\n\t\tthrow error;\n\t}\n\treturn { created };\n}\n\ninterface ApplicationCheckConfig {\n\tformatVersion: 1;\n\tassembly: string;\n\truntimeCapabilities: string;\n\treleases: string[];\n}\n\nasync function readJson(file: string): Promise<unknown> {\n\treturn JSON.parse(await readFile(file, \"utf8\"));\n}\n\nfunction assertApplicationCheckConfig(value: unknown): asserts value is ApplicationCheckConfig {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(\"Application check configuration must be a JSON object.\");\n\t}\n\tconst config = value as Record<string, unknown>;\n\tif (config.formatVersion !== 1) throw new Error(\"Application check configuration formatVersion must be 1.\");\n\tif (typeof config.assembly !== \"string\" || !config.assembly) {\n\t\tthrow new Error(\"Application check configuration assembly must be a file path.\");\n\t}\n\tif (typeof config.runtimeCapabilities !== \"string\" || !config.runtimeCapabilities) {\n\t\tthrow new Error(\"Application check configuration runtimeCapabilities must be a file path.\");\n\t}\n\tif (!Array.isArray(config.releases) || !config.releases.every((entry) => typeof entry === \"string\" && entry)) {\n\t\tthrow new Error(\"Application check configuration releases must be an array of file paths.\");\n\t}\n}\n\n/**\n * Verify an application's immutable composition inputs before deployment.\n * Every runtime capability must exactly match the approved lockfile, and every\n * promoted experience release must be intact and bound to that assembly.\n */\nexport async function checkApplication(\n\toptions: CheckApplicationOptions,\n): Promise<CheckApplicationResult> {\n\tconst configValue = await readJson(options.configPath);\n\tassertApplicationCheckConfig(configValue);\n\tconst base = path.dirname(options.configPath);\n\tconst resolve = (file: string): string => path.resolve(base, file);\n\tconst assembly = await readJson(resolve(configValue.assembly)) as AssemblyLockfile;\n\tassertAssemblyLockfile(assembly);\n\tconst runtimeCapabilities = await readJson(\n\t\tresolve(configValue.runtimeCapabilities),\n\t) as AvailableCapability[];\n\tif (!Array.isArray(runtimeCapabilities)) {\n\t\tthrow new Error(\"Runtime capabilities must be a JSON array.\");\n\t}\n\tassertAssemblyRuntimeCompatible(assembly, runtimeCapabilities);\n\tfor (const releasePath of configValue.releases) {\n\t\tconst release = await readJson(resolve(releasePath)) as SduiRelease;\n\t\ttry {\n\t\t\tassertSduiReleaseIntegrity(release);\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Experience release \"${releasePath}\" is invalid: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (release.assemblyDigest !== assembly.assemblyDigest) {\n\t\t\tthrow new Error(\n\t\t\t\t`Experience release \"${release.document.name}@${release.document.version}\" belongs to assembly \"${release.assemblyDigest}\", not \"${assembly.assemblyDigest}\".`,\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\tapplication: assembly.application,\n\t\tcapabilities: assembly.capabilities.length,\n\t\treleases: configValue.releases.length,\n\t\tassemblyDigest: assembly.assemblyDigest,\n\t};\n}\n\n/**\n * Create the smallest useful capability source tree. The manifest is accepted\n * by the compiler immediately, while leaving domain vocabulary to the adopter.\n */\nexport interface ExportModuleManifestFileOptions {\n\tmoduleFile: string;\n\tout: string;\n\texportName?: string;\n}\n\nexport interface ExportModuleManifestFileResult {\n\tnamespace: string;\n\texportName: string;\n\tobjectTypes: number;\n\tactions: number;\n\teventTypes: number;\n}\n\n/**\n * Turn an authored FabricModule into the normalized manifest every generator reads.\n *\n * This is the seam between the two halves of the authoring loop. The module is\n * TypeScript, so the compiler checks it as you write; the manifest is the\n * normalized JSON the code generators and the assembly compiler consume. Until\n * this command existed, nothing shipped connected them: `init capability`\n * scaffolded an empty manifest, and an author who filled it in by hand was\n * guessing at the shape of `exportModuleManifest`'s output.\n */\nexport async function exportModuleManifestFile(\n\toptions: ExportModuleManifestFileOptions,\n): Promise<ExportModuleManifestFileResult> {\n\tconst absolute = path.resolve(options.moduleFile);\n\tlet loaded: Record<string, unknown>;\n\ttry {\n\t\tloaded = (await import(pathToFileURL(absolute).href)) as Record<string, unknown>;\n\t} catch (error) {\n\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`Could not load module file \"${options.moduleFile}\": ${reason}\\nA TypeScript file needs a runtime that strips types (Node 22.18 or newer); otherwise point --module at the built JavaScript.`);\n\t}\n\tconst candidates = Object.entries(loaded).filter(([, value]) => isFabricModuleLike(value));\n\tlet entry: [string, unknown] | undefined;\n\tif (options.exportName) {\n\t\tconst named = loaded[options.exportName];\n\t\tif (named === undefined) throw new Error(`\"${options.moduleFile}\" has no export named \"${options.exportName}\". It exports: ${Object.keys(loaded).join(\", \") || \"nothing\"}.`);\n\t\tif (!isFabricModuleLike(named)) throw new Error(`Export \"${options.exportName}\" of \"${options.moduleFile}\" is not a FabricModule: it has no string \"namespace\".`);\n\t\tentry = [options.exportName, named];\n\t} else if (candidates.length === 1) {\n\t\tentry = candidates[0];\n\t} else if (candidates.length === 0) {\n\t\tthrow new Error(`\"${options.moduleFile}\" exports no FabricModule. Export one, with a string \"namespace\", or name it with --export.`);\n\t} else {\n\t\tthrow new Error(`\"${options.moduleFile}\" exports ${candidates.length} modules (${candidates.map(([name]) => name).join(\", \")}). Choose one with --export.`);\n\t}\n\tconst manifest = exportModuleManifest(entry[1] as Parameters<typeof exportModuleManifest>[0]);\n\t// Compile it here so the author learns about a bad field from this command,\n\t// standing in their own module, rather than from a generator two steps later.\n\tcompileManifestBundle({ manifestVersion: 2, modules: [manifest] });\n\tawait mkdir(path.dirname(path.resolve(options.out)), { recursive: true });\n\tawait writeFile(path.resolve(options.out), `${JSON.stringify(manifest, null, 2)}\\n`, \"utf8\");\n\treturn {\n\t\tnamespace: manifest.namespace,\n\t\texportName: entry[0],\n\t\tobjectTypes: manifest.objectTypes.length,\n\t\tactions: manifest.actions.length,\n\t\teventTypes: manifest.eventTypes.length,\n\t};\n}\n\nfunction isFabricModuleLike(value: unknown): boolean {\n\treturn typeof value === \"object\" && value !== null && typeof (value as { namespace?: unknown }).namespace === \"string\";\n}\n\nexport async function initializeCapability(\n\toptions: InitializeCapabilityOptions,\n): Promise<InitializeCapabilityResult> {\n\tif (!/^[a-z][a-z0-9-]*$/.test(options.namespace)) {\n\t\tthrow new Error(\"Capability namespace must use lowercase letters, numbers, and hyphens.\");\n\t}\n\tconst displayName = options.namespace\n\t\t.split(\"-\")\n\t\t.map((part, index) => index === 0\n\t\t\t? `${part.charAt(0).toUpperCase()}${part.slice(1)}`\n\t\t\t: part)\n\t\t.join(\" \");\n\tconst modulePath = path.join(options.directory, \"module.ts\");\n\tconst readmePath = path.join(options.directory, \"README.md\");\n\tfor (const file of [readmePath, modulePath]) {\n\t\ttry {\n\t\t\tawait access(file);\n\t\t\tthrow new Error(`Refusing to overwrite existing file \"${file}\".`);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.message.startsWith(\"Refusing to overwrite\")) throw error;\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n\t\t}\n\t}\n\t// The scaffold is a working module, not an empty shell. An empty manifest\n\t// teaches nothing about the shape it has to reach, and a manifest authored\n\t// by hand is a guess at the output of exportModuleManifest(). The module is\n\t// the source; `fabric-gen export` produces the manifest from it.\n\tconst module = [\n\t\t`import type { ActionDefinition } from \"@fabricorg/platform/actions\";`,\n\t\t`import type { FabricModule } from \"@fabricorg/platform/modules\";`,\n\t\t\"\",\n\t\t`/** One governed action. Every field below is checked when the manifest is exported. */`,\n\t\t`const recordExample: ActionDefinition = {`,\n\t\t`\\tactionId: \"${options.namespace}.record_example\",`,\n\t\t`\\tnamespace: \"${options.namespace}\",`,\n\t\t\"\\tversion: 1,\",\n\t\t'\\tkind: \"atomic\",',\n\t\t\"\\tidempotent: true,\",\n\t\t\"\\tmutatesDomain: true,\",\n\t\t'\\temitsEvents: [\"ExampleRecorded\"],',\n\t\t\"\\t// The six execution dimensions. A strict certification profile requires all of them.\",\n\t\t\"\\texecution: {\",\n\t\t'\\t\\tconnectivity: \"online-required\",',\n\t\t'\\t\\tauthorityMoment: \"execution\",',\n\t\t'\\t\\tidempotency: \"required\",',\n\t\t'\\t\\tcompletion: \"immediate\",',\n\t\t'\\t\\tconsistency: \"authoritative-now\",',\n\t\t'\\t\\tsensitivity: \"internal\",',\n\t\t\"\\t},\",\n\t\t\"\\tschema: {\",\n\t\t\"\\t\\tparse(value: unknown): { exampleId: string } {\",\n\t\t\"\\t\\t\\tconst input = value as { exampleId?: unknown };\",\n\t\t'\\t\\t\\tif (typeof input?.exampleId !== \"string\") throw new Error(\"exampleId is required\");',\n\t\t\"\\t\\t\\treturn { exampleId: input.exampleId };\",\n\t\t\"\\t\\t},\",\n\t\t\"\\t\\tsafeParse(value: unknown) {\",\n\t\t\"\\t\\t\\ttry {\",\n\t\t\"\\t\\t\\t\\treturn { success: true as const, data: this.parse(value) };\",\n\t\t\"\\t\\t\\t} catch (error) {\",\n\t\t'\\t\\t\\t\\treturn { success: false as const, error: { issues: [{ path: [\"exampleId\"], message: error instanceof Error ? error.message : String(error) }] } };',\n\t\t\"\\t\\t\\t}\",\n\t\t\"\\t\\t},\",\n\t\t\"\\t},\",\n\t\t\"\\thandler: async (_context, parameters) => ({\",\n\t\t\"\\t\\tsuccess: true,\",\n\t\t\"\\t\\tdata: {\",\n\t\t\"\\t\\t\\t...(parameters as { exampleId: string }),\",\n\t\t\"\\t\\t\\t_events: [{\",\n\t\t'\\t\\t\\t\\teventType: \"ExampleRecorded\",',\n\t\t\"\\t\\t\\t\\tentityType: \\\"Example\\\",\",\n\t\t\"\\t\\t\\t\\tentityId: (parameters as { exampleId: string }).exampleId,\",\n\t\t\"\\t\\t\\t\\tpayload: parameters,\",\n\t\t\"\\t\\t\\t}],\",\n\t\t\"\\t\\t},\",\n\t\t\"\\t}),\",\n\t\t\"};\",\n\t\t\"\",\n\t\t`export const ${camelCase(options.namespace)}Module: FabricModule = {`,\n\t\t`\\tnamespace: \"${options.namespace}\",`,\n\t\t'\\tversion: \"0.1.0\",',\n\t\t\"\\tcapability: {\",\n\t\t`\\t\\tdisplayName: \"${displayName}\",`,\n\t\t`\\t\\tdescription: \"Governed ${displayName.toLowerCase()} capability.\",`,\n\t\t'\\t\\tstability: \"experimental\",',\n\t\t\"\\t},\",\n\t\t\"\\tobjectTypes: [{\",\n\t\t'\\t\\ttype: \"Example\",',\n\t\t\"\\t\\tschema: {\",\n\t\t'\\t\\t\\ttype: \"object\",',\n\t\t'\\t\\t\\tproperties: { exampleId: { type: \"string\" } },',\n\t\t'\\t\\t\\trequired: [\"exampleId\"],',\n\t\t\"\\t\\t},\",\n\t\t\"\\t}],\",\n\t\t`\\tidPrefixes: [{ prefix: \"exm\", name: \"Example\", module: \"${options.namespace}\" }],`,\n\t\t'\\teventTypes: [{ eventType: \"ExampleRecorded\", schemaVersion: 1 }],',\n\t\t\"\\tactions: [recordExample],\",\n\t\t\"};\",\n\t\t\"\",\n\t].join(\"\\n\");\n\tconst readme = [\n\t\t`# ${displayName}`,\n\t\t\"\",\n\t\t\"`module.ts` is the source of truth. It is TypeScript, so the shape of every\",\n\t\t\"action, object type, and event is checked as you write it.\",\n\t\t\"\",\n\t\t\"## The loop\",\n\t\t\"\",\n\t\t\"```bash\",\n\t\t\"# 1. Export the authored module to the normalized manifest the generators read.\",\n\t\t\"fabric-gen export --module module.ts --out fabric.manifest.json\",\n\t\t\"\",\n\t\t\"# 2. Generate types, event contracts, the usage contract, and docs.\",\n\t\t\"fabric-gen --input fabric.manifest.json --out generated\",\n\t\t\"\",\n\t\t\"# 3. In CI, prove the generated files match the manifest.\",\n\t\t\"fabric-gen --input fabric.manifest.json --out generated --check\",\n\t\t\"```\",\n\t\t\"\",\n\t\t\"Commit both `fabric.manifest.json` and `generated/`. The manifest is the\",\n\t\t\"contract other capabilities and applications compile against; regenerating\",\n\t\t\"is how a consumer learns what changed.\",\n\t\t\"\",\n\t\t\"## What to edit\",\n\t\t\"\",\n\t\t\"- **Object types** carry a portable JSON Schema. They become generated TypeScript types.\",\n\t\t\"- **Actions** declare six execution dimensions. A host refuses an action whose\",\n\t\t\" declaration does not match how it is invoked, so declare them honestly.\",\n\t\t\"- **Events** are the capability's public vocabulary. Adding a field is compatible;\",\n\t\t\" removing or retyping one is not.\",\n\t\t\"\",\n\t].join(\"\\n\");\n\tawait mkdir(options.directory, { recursive: true });\n\tconst created: string[] = [];\n\ttry {\n\t\tfor (const [file, content] of [\n\t\t\t[readmePath, readme],\n\t\t\t[modulePath, module],\n\t\t] as const) {\n\t\t\tawait writeFile(file, content, { encoding: \"utf8\", flag: \"wx\" });\n\t\t\tcreated.push(file);\n\t\t}\n\t} catch (error) {\n\t\tawait Promise.all(created.map((file) => rm(file, { force: true })));\n\t\tif ((error as NodeJS.ErrnoException).code === \"EEXIST\") {\n\t\t\tthrow new Error(\"Refusing to overwrite a file created during capability initialization.\");\n\t\t}\n\t\tthrow error;\n\t}\n\treturn { created };\n}\n\nfunction camelCase(namespace: string): string {\n\treturn namespace.split(\"-\").map((part, index) => index === 0 ? part : `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join(\"\");\n}\n\nexport async function generateFromManifest(options: GenerateOptions): Promise<GenerateResult> {\n\tconst input = JSON.parse(await readFile(options.inputPath, \"utf8\"));\n\tif (!input || typeof input !== \"object\" || Array.isArray(input)) throw new Error(\"Manifest input must be a JSON object.\");\n\tconst bundle = \"modules\" in input ? input : { manifestVersion: input.manifestVersion, modules: [input] };\n\tconst ir = compileManifestBundle(bundle);\n\tconst files = (await Promise.all(options.targets.map(async (name) => {\n\t\tconst target = GENERATOR_TARGETS[name];\n\t\tif (!target) throw new Error(`Unknown generator target \"${name}\".`);\n\t\treturn (await runGenerator(target, ir)).map((file) => ({ ...file, path: `${name}/${file.path}` }));\n\t}))).flat().sort((left, right) => compareCanonicalStrings(left.path, right.path));\n\tconst expected = new Set(files.map((file) => file.path));\n\tconst existing = await listFiles(options.outputDirectory);\n\tconst selectedPrefixes = options.targets.map((target) => `${target}/`);\n\tconst stale = existing.filter((file) => selectedPrefixes.some((prefix) => file.startsWith(prefix)) && !expected.has(file));\n\tif (!options.check) await Promise.all(stale.map((file) => rm(path.join(options.outputDirectory, file), { force: true })));\n\tconst changed: string[] = [];\n\tfor (const file of files) {\n\t\tconst target = path.join(options.outputDirectory, file.path);\n\t\tlet current: string | undefined;\n\t\ttry { current = await readFile(target, \"utf8\"); } catch { current = undefined; }\n\t\tif (current !== file.content) {\n\t\t\tchanged.push(file.path);\n\t\t\tif (!options.check) { await mkdir(path.dirname(target), { recursive: true }); await writeFile(target, file.content, \"utf8\"); }\n\t\t}\n\t}\n\tif (options.check && (changed.length || stale.length)) throw new Error(`Generated artifacts drifted: ${[...changed, ...stale.map((file) => `stale:${file}`)].join(\", \")}`);\n\treturn { changed, stale, files };\n}\n\nasync function listFiles(directory: string, prefix = \"\"): Promise<string[]> {\n\tlet entries;\n\ttry { entries = await readdir(directory, { withFileTypes: true }); } catch { return []; }\n\tconst nested = await Promise.all(entries.map((entry) => entry.isDirectory() ? listFiles(path.join(directory, entry.name), `${prefix}${entry.name}/`) : [`${prefix}${entry.name}`]));\n\treturn nested.flat().sort();\n}\n\ninterface ExperiencePromotionConfig {\n\tformatVersion: 1;\n\tapplication: string;\n\tissuer: string;\n\tkeyId: string;\n\tassembly: string;\n\trelease: string;\n\tcontracts: string[];\n}\n\nfunction assertExperiencePromotionConfig(value: unknown): asserts value is ExperiencePromotionConfig {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(\"Experience promotion configuration must be a JSON object.\");\n\t}\n\tconst config = value as Record<string, unknown>;\n\tif (config.formatVersion !== 1) throw new Error(\"Experience promotion configuration formatVersion must be 1.\");\n\tfor (const field of [\"application\", \"issuer\", \"keyId\", \"assembly\", \"release\"] as const) {\n\t\tif (typeof config[field] !== \"string\" || !config[field]) {\n\t\t\tthrow new Error(`Experience promotion configuration ${field} must be a non-empty string.`);\n\t\t}\n\t}\n\t// The application name is interpolated into the default output path and\n\t// signed into the release body, so \"../../x\" would escape the configuration\n\t// directory and \"/etc/x\" would ignore it entirely.\n\tif (!/^[a-z][a-z0-9-]*$/.test(config.application as string)) {\n\t\tthrow new Error(\"Experience promotion configuration application must be lowercase letters, numbers, and hyphens.\");\n\t}\n\tif (!Array.isArray(config.contracts) || !config.contracts.every((entry) => typeof entry === \"string\" && entry)) {\n\t\tthrow new Error(\"Experience promotion configuration contracts must be an array of file paths.\");\n\t}\n\t// A signing key in a checked-in configuration file is a key in version\n\t// control. Enumerating two spellings only catches two spellings, so reject\n\t// anything that reads like one, and reject unknown fields so a future\n\t// spelling cannot arrive unnoticed.\n\tconst known = new Set([\"formatVersion\", \"application\", \"issuer\", \"keyId\", \"assembly\", \"release\", \"contracts\"]);\n\tfor (const field of Object.keys(config)) {\n\t\tif (/key|secret|credential|token|pem|password/i.test(field) && field !== \"keyId\") {\n\t\t\tthrow new Error(`Experience promotion configuration must not carry \"${field}\"; pass the signing key with --key.`);\n\t\t}\n\t\tif (!known.has(field)) {\n\t\t\tthrow new Error(`Experience promotion configuration has an unknown field \"${field}\".`);\n\t\t}\n\t}\n}\n\n/**\n * Turn a validated release into a signed one.\n *\n * Promotion is where a granted `capability://` reference becomes a concrete\n * action id and version, so it is also where that mapping has to be bound to\n * the assembly that approved it. The signing key is a command-line argument\n * rather than a configuration field, because a configuration file is the kind\n * of thing that ends up committed.\n */\nexport async function promoteExperience(\n\toptions: PromoteExperienceOptions,\n): Promise<PromoteExperienceResult> {\n\tconst configValue = await readJson(options.configPath);\n\tassertExperiencePromotionConfig(configValue);\n\tconst base = path.dirname(options.configPath);\n\tconst resolve = (file: string): string => path.resolve(base, file);\n\n\tconst assembly = await readJson(resolve(configValue.assembly)) as AssemblyLockfile;\n\tassertAssemblyLockfile(assembly);\n\tconst release = await readJson(resolve(configValue.release)) as SduiRelease;\n\tassertSduiReleaseIntegrity(release);\n\tconst contracts = await Promise.all(\n\t\tconfigValue.contracts.map(async (file) => await readJson(resolve(file)) as UsageContractDocument),\n\t);\n\n\tconst privateKey = createPrivateKey(await readFile(options.privateKeyPath, \"utf8\"));\n\tconst promoted = await promoteExperienceRelease({\n\t\tapplication: configValue.application,\n\t\trelease,\n\t\tcontracts,\n\t\tassembly,\n\t\tissuer: configValue.issuer,\n\t\tsigner: createEs256ReleaseSigner({ keyId: configValue.keyId, privateKey }),\n\t});\n\n\tconst outputPath = options.outputPath\n\t\t? path.resolve(options.outputPath)\n\t\t: resolve(`${configValue.application}.experience-release.jws`);\n\tawait mkdir(path.dirname(outputPath), { recursive: true });\n\tawait writeFile(outputPath, `${promoted.compactJws}\\n`, \"utf8\");\n\n\treturn {\n\t\tapplication: configValue.application,\n\t\treleaseDigest: release.releaseDigest,\n\t\tassemblyDigest: assembly.assemblyDigest,\n\t\troutes: {\n\t\t\tviews: promoted.release.routes.views.length,\n\t\t\tintents: promoted.release.routes.intents.length,\n\t\t},\n\t\toutputPath,\n\t};\n}\n","#!/usr/bin/env node\nimport { fabricGenCliExitCode, runFabricGenCommand } from \"./index\";\n\nconst args = process.argv.slice(2);\nrunFabricGenCommand(args)\n\t.then((message) => console.log(message))\n\t.catch((error: unknown) => {\n\t\tconsole.error(error instanceof Error ? error.message : String(error));\n\t\tprocess.exitCode = fabricGenCliExitCode(error);\n\t});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sBAAgE;AAChE,yBAAiC;AACjC,uBAAiB;AACjB,sBAA8B;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
6
6
 
7
7
  // cli.ts
8
8
  var args = process.argv.slice(2);