@pattern-stack/codegen 0.18.0 → 0.19.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 (75) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +51 -0
  3. package/consumer-skills/codegen/SKILL.md +32 -0
  4. package/consumer-skills/entities/SKILL.md +2 -0
  5. package/dist/{chunk-X6BP6LI5.js → chunk-235ZMMJR.js} +3 -3
  6. package/dist/{chunk-BK5ICA2F.js → chunk-4MVGAMUA.js} +4 -4
  7. package/dist/{chunk-2VGVSL2D.js → chunk-65MO75WM.js} +8 -8
  8. package/dist/{chunk-NXHL5YII.js → chunk-7LKAMLV4.js} +4 -4
  9. package/dist/{chunk-5RT7JGKT.js → chunk-7OVCARTQ.js} +4 -4
  10. package/dist/{chunk-EWYI5GGJ.js → chunk-AZLUWG5S.js} +13 -13
  11. package/dist/{chunk-RKNW56RU.js → chunk-B34G6PHD.js} +8 -8
  12. package/dist/{chunk-IN3EWFB4.js → chunk-BHZP6LOV.js} +4 -4
  13. package/dist/{chunk-W2UIDI3R.js → chunk-CLWBNXKF.js} +4 -4
  14. package/dist/{chunk-7MMS36AN.js → chunk-E6PLM6QG.js} +9 -9
  15. package/dist/{chunk-CFFTPWHM.js → chunk-F7KN3U6U.js} +44 -5
  16. package/dist/chunk-F7KN3U6U.js.map +1 -0
  17. package/dist/{chunk-VHAR2BGH.js → chunk-GM3RMJIJ.js} +4 -4
  18. package/dist/{chunk-R4BPUUB5.js → chunk-OZEPJGMA.js} +4 -4
  19. package/dist/{chunk-TBGTMALE.js → chunk-R6F6KFIL.js} +4 -4
  20. package/dist/{chunk-YZLBU6O2.js → chunk-SNH35CNA.js} +5 -5
  21. package/dist/{chunk-C5E7H553.js → chunk-VDL5CJ5C.js} +7 -7
  22. package/dist/{chunk-3A34R6CI.js → chunk-VNBC3VXM.js} +7 -7
  23. package/dist/{chunk-E45CSC33.js → chunk-XKWOJZZ4.js} +2 -2
  24. package/dist/{chunk-LQ6PYFU6.js → chunk-Z7PQCAVK.js} +4 -4
  25. package/dist/runtime/subsystems/auth/auth.module.js +4 -4
  26. package/dist/runtime/subsystems/auth/index.js +9 -9
  27. package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js +2 -2
  28. package/dist/runtime/subsystems/bridge/bridge-delivery.drizzle-backend.js +2 -2
  29. package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js +6 -6
  30. package/dist/runtime/subsystems/bridge/bridge.module.js +16 -16
  31. package/dist/runtime/subsystems/bridge/event-flow.service.js +2 -2
  32. package/dist/runtime/subsystems/bridge/index.js +19 -19
  33. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +3 -3
  34. package/dist/runtime/subsystems/events/event-bus.memory-backend.js +2 -2
  35. package/dist/runtime/subsystems/events/events.module.js +7 -7
  36. package/dist/runtime/subsystems/events/generated/bus.js +2 -2
  37. package/dist/runtime/subsystems/events/generated/index.js +2 -2
  38. package/dist/runtime/subsystems/events/index.js +10 -10
  39. package/dist/runtime/subsystems/index.js +78 -78
  40. package/dist/runtime/subsystems/jobs/index.js +29 -29
  41. package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js +5 -5
  42. package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js +3 -3
  43. package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js +3 -3
  44. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +2 -2
  45. package/dist/runtime/subsystems/jobs/job-worker.js +3 -3
  46. package/dist/runtime/subsystems/jobs/job-worker.module.js +10 -10
  47. package/dist/runtime/subsystems/jobs/jobs-domain.module.js +8 -8
  48. package/dist/runtime/subsystems/observability/index.js +3 -3
  49. package/dist/runtime/subsystems/observability/observability.module.js +3 -3
  50. package/dist/runtime/subsystems/observability/observability.service.js +2 -2
  51. package/dist/runtime/subsystems/storage/index.js +4 -4
  52. package/dist/runtime/subsystems/storage/storage.module.js +2 -2
  53. package/dist/src/cli/index.js +146 -11
  54. package/dist/src/cli/index.js.map +1 -1
  55. package/dist/src/index.js +1 -1
  56. package/package.json +1 -1
  57. package/dist/chunk-CFFTPWHM.js.map +0 -1
  58. /package/dist/{chunk-X6BP6LI5.js.map → chunk-235ZMMJR.js.map} +0 -0
  59. /package/dist/{chunk-BK5ICA2F.js.map → chunk-4MVGAMUA.js.map} +0 -0
  60. /package/dist/{chunk-2VGVSL2D.js.map → chunk-65MO75WM.js.map} +0 -0
  61. /package/dist/{chunk-NXHL5YII.js.map → chunk-7LKAMLV4.js.map} +0 -0
  62. /package/dist/{chunk-5RT7JGKT.js.map → chunk-7OVCARTQ.js.map} +0 -0
  63. /package/dist/{chunk-EWYI5GGJ.js.map → chunk-AZLUWG5S.js.map} +0 -0
  64. /package/dist/{chunk-RKNW56RU.js.map → chunk-B34G6PHD.js.map} +0 -0
  65. /package/dist/{chunk-IN3EWFB4.js.map → chunk-BHZP6LOV.js.map} +0 -0
  66. /package/dist/{chunk-W2UIDI3R.js.map → chunk-CLWBNXKF.js.map} +0 -0
  67. /package/dist/{chunk-7MMS36AN.js.map → chunk-E6PLM6QG.js.map} +0 -0
  68. /package/dist/{chunk-VHAR2BGH.js.map → chunk-GM3RMJIJ.js.map} +0 -0
  69. /package/dist/{chunk-R4BPUUB5.js.map → chunk-OZEPJGMA.js.map} +0 -0
  70. /package/dist/{chunk-TBGTMALE.js.map → chunk-R6F6KFIL.js.map} +0 -0
  71. /package/dist/{chunk-YZLBU6O2.js.map → chunk-SNH35CNA.js.map} +0 -0
  72. /package/dist/{chunk-C5E7H553.js.map → chunk-VDL5CJ5C.js.map} +0 -0
  73. /package/dist/{chunk-3A34R6CI.js.map → chunk-VNBC3VXM.js.map} +0 -0
  74. /package/dist/{chunk-E45CSC33.js.map → chunk-XKWOJZZ4.js.map} +0 -0
  75. /package/dist/{chunk-LQ6PYFU6.js.map → chunk-Z7PQCAVK.js.map} +0 -0
@@ -17,6 +17,7 @@ import {
17
17
  getManifestDir,
18
18
  getOrchestrationPatternNames,
19
19
  getPendingSuggestions,
20
+ isActiveProvider,
20
21
  isManifestStale,
21
22
  loadAppPatterns,
22
23
  loadEntities,
@@ -37,7 +38,7 @@ import {
37
38
  validateOrchestrationProject,
38
39
  validateProviders,
39
40
  writeManifest
40
- } from "../../chunk-CFFTPWHM.js";
41
+ } from "../../chunk-F7KN3U6U.js";
41
42
  import "../../chunk-KVOWSC5S.js";
42
43
  import "../../chunk-PKDS6QIJ.js";
43
44
  import "../../chunk-PRWIX6UW.js";
@@ -65,7 +66,7 @@ import "../../chunk-2E224ZSN.js";
65
66
 
66
67
  // src/cli/index.ts
67
68
  import { readFileSync as readFileSync6 } from "fs";
68
- import { join as join17 } from "path";
69
+ import { join as join18 } from "path";
69
70
  import { Builtins, Cli, Command as Command13 } from "clipanion";
70
71
 
71
72
  // src/cli/noun-module.ts
@@ -4415,8 +4416,9 @@ function emitAdapters(opts) {
4415
4416
  };
4416
4417
  const entitiesBySurface = collectEntitiesBySurface(opts.entities);
4417
4418
  const entityByName = new Map(opts.entities.map((e) => [e.entity.name, e]));
4419
+ const activeProviders = opts.providers.filter((p) => isActiveProvider(p.definition));
4418
4420
  const bySurface = /* @__PURE__ */ new Map();
4419
- for (const { definition } of opts.providers) {
4421
+ for (const { definition } of activeProviders) {
4420
4422
  for (const surface of definition.surfaces) {
4421
4423
  if (!SURFACE_REGISTRY[surface]) {
4422
4424
  result.skippedSurfaces.push({
@@ -4431,7 +4433,7 @@ function emitAdapters(opts) {
4431
4433
  bySurface.set(surface, list);
4432
4434
  }
4433
4435
  }
4434
- const defBySlug = new Map(opts.providers.map((p) => [p.definition.slug, p.definition]));
4436
+ const defBySlug = new Map(activeProviders.map((p) => [p.definition.slug, p.definition]));
4435
4437
  for (const [surface, slugs] of bySurface) {
4436
4438
  const surfaceDir = join8(opts.outputRoot, surface);
4437
4439
  const adaptersDir = join8(surfaceDir, "adapters");
@@ -4793,6 +4795,7 @@ function generateProviderModules(opts) {
4793
4795
  const mode = opts.mode ?? "package";
4794
4796
  const written = [];
4795
4797
  for (const { definition, filePath } of loaded) {
4798
+ if (!isActiveProvider(definition)) continue;
4796
4799
  const sourceYaml = relativeSource(filePath);
4797
4800
  const content = generateProviderModule(definition, sourceYaml, mode);
4798
4801
  const outPath = join9(
@@ -5671,8 +5674,105 @@ function emitFields(ctx, outDir) {
5671
5674
  return written;
5672
5675
  }
5673
5676
 
5674
- // src/emitters/frontend/emit-index.ts
5677
+ // src/emitters/frontend/emit-providers.ts
5675
5678
  import { join as join16 } from "path";
5679
+ var SOURCE_DESC2 = "definitions/providers";
5680
+ function vendorLiteral(p, indent) {
5681
+ const lines = [
5682
+ `${indent}{`,
5683
+ `${indent} provider: '${p.slug}',`,
5684
+ `${indent} name: '${(p.displayName ?? p.slug).replace(/'/g, "\\'")}',`,
5685
+ `${indent} planned: ${p.status === "planned"},`,
5686
+ `${indent} surfaces: [${p.surfaces.map((s) => `'${s}'`).join(", ")}],`
5687
+ ];
5688
+ if (p.display?.blurb) {
5689
+ lines.push(`${indent} blurb: '${p.display.blurb.replace(/'/g, "\\'")}',`);
5690
+ }
5691
+ if (p.display?.hint) {
5692
+ lines.push(`${indent} hint: '${p.display.hint.replace(/'/g, "\\'")}',`);
5693
+ }
5694
+ lines.push(`${indent}},`);
5695
+ return lines.join("\n");
5696
+ }
5697
+ function sortProviders(providers) {
5698
+ return [...providers].sort((a, b) => a.slug.localeCompare(b.slug));
5699
+ }
5700
+ function buildProvidersFile(ctx) {
5701
+ const providers = sortProviders(ctx.providers ?? []);
5702
+ const categories = ctx.config.catalogCategories;
5703
+ const flat = providers.map((p) => vendorLiteral(p, " ")).join("\n");
5704
+ const groups = categories.map((cat) => {
5705
+ const vendors = providers.filter((p) => p.display?.category === cat.id);
5706
+ const vendorBlock = vendors.map((p) => vendorLiteral(p, " ")).join("\n");
5707
+ return [
5708
+ " {",
5709
+ ` id: '${cat.id}',`,
5710
+ ` name: '${cat.name.replace(/'/g, "\\'")}',`,
5711
+ ` blurb: '${cat.blurb.replace(/'/g, "\\'")}',`,
5712
+ vendors.length > 0 ? ` vendors: [
5713
+ ${vendorBlock}
5714
+ ],` : " vendors: [],",
5715
+ " },"
5716
+ ].join("\n");
5717
+ }).join("\n");
5718
+ const body = `/**
5719
+ * Providers catalog \u2014 emitted from \`definitions/providers/*.yaml\` (slug,
5720
+ * display_name, surfaces, status, display) + \`frontend.catalog.categories\`
5721
+ * (codegen.config.yaml). Provider truth lives in the definitions; this file
5722
+ * is a projection \u2014 never hand-edit, never hand-duplicate.
5723
+ *
5724
+ * \`planned: true\` vendors are roadmap stubs (no backend integration yet) \u2014
5725
+ * render them as unconnectable tiles. Join live rows on \`provider\` (the
5726
+ * canonical slug, e.g. \`Connection.provider\`).
5727
+ */
5728
+
5729
+ export type ProviderStatus = 'active' | 'planned';
5730
+
5731
+ export interface CatalogVendor {
5732
+ /** Provider slug \u2014 joins to \`Connection.provider\` / STRATEGY_REGISTRY keys. */
5733
+ provider: string;
5734
+ name: string;
5735
+ /** True for roadmap stubs (\`status: planned\`) \u2014 no backend integration yet. */
5736
+ planned: boolean;
5737
+ /** Surfaces this provider serves (ADR-0006). */
5738
+ surfaces: string[];
5739
+ blurb?: string;
5740
+ /** Sub-line shown on an unconnected ("available") tile. */
5741
+ hint?: string;
5742
+ }
5743
+
5744
+ export interface CatalogCategory {
5745
+ id: string;
5746
+ name: string;
5747
+ blurb: string;
5748
+ vendors: CatalogVendor[];
5749
+ }
5750
+
5751
+ /** Every provider definition, flat (active + planned), slug-sorted. */
5752
+ export const PROVIDERS: CatalogVendor[] = [
5753
+ ${flat}
5754
+ ];
5755
+
5756
+ /**
5757
+ * Category-grouped catalog (\`frontend.catalog.categories\` order). Providers
5758
+ * join a group via \`display.category\`; uncategorized providers appear only
5759
+ * in \`PROVIDERS\`.
5760
+ */
5761
+ export const PROVIDER_CATALOG: CatalogCategory[] = [
5762
+ ${groups}
5763
+ ];
5764
+ `;
5765
+ return withBanner(SOURCE_DESC2, body);
5766
+ }
5767
+ function emitProviders(ctx, outDir) {
5768
+ if (!ctx.providers || ctx.providers.length === 0) return [];
5769
+ const path36 = join16(outDir, "providers.ts");
5770
+ writeFile2(path36, buildProvidersFile(ctx));
5771
+ return [path36];
5772
+ }
5773
+
5774
+ // src/emitters/frontend/emit-index.ts
5775
+ import { join as join17 } from "path";
5676
5776
 
5677
5777
  // src/emitters/frontend/deps.ts
5678
5778
  var FRONTEND_EMITTED_DEPS = {
@@ -5723,19 +5823,23 @@ export * from './entities/index';
5723
5823
 
5724
5824
  // Field metadata (DataGrid / forms / admin)
5725
5825
  export * from './fields/index';
5726
-
5826
+ ${ctx.providers && ctx.providers.length > 0 ? `
5827
+ // Providers catalog (definitions/providers + frontend.catalog.categories)
5828
+ export * from './providers';
5829
+ ` : ""}
5727
5830
  // Unified store (entities + collections + resolvers + lookups)
5728
5831
  export * from './store/module-index';
5729
5832
  `;
5730
5833
  return withBanner(SOURCE_DESC_SET6, body);
5731
5834
  }
5732
5835
  function emitIndex(ctx, outDir) {
5733
- const indexPath = join16(outDir, "index.ts");
5836
+ const indexPath = join17(outDir, "index.ts");
5734
5837
  writeFile2(indexPath, buildRootIndexFile(ctx));
5735
5838
  return [indexPath];
5736
5839
  }
5737
5840
 
5738
5841
  // src/emitters/frontend/load-context.ts
5842
+ import { existsSync as existsSync8, statSync as statSync5 } from "fs";
5739
5843
  import path12 from "path";
5740
5844
 
5741
5845
  // src/schema/codegen-config.schema.ts
@@ -5779,10 +5883,20 @@ var FrontendSyncConfigSchema = z.object({
5779
5883
  apiBaseUrlImport: z.string().nullable().default(null),
5780
5884
  apiUrl: z.string().default("/api")
5781
5885
  }).default({});
5886
+ var FrontendCatalogConfigSchema = z.object({
5887
+ categories: z.array(
5888
+ z.object({
5889
+ id: z.string(),
5890
+ name: z.string(),
5891
+ blurb: z.string().default("")
5892
+ }).strict()
5893
+ ).default([])
5894
+ }).default({});
5782
5895
  var FrontendConfigSchema = z.object({
5783
5896
  auth: FrontendAuthConfigSchema,
5784
5897
  parsers: z.record(z.string()).default({ timestamptz: "(date: string) => new Date(date)" }),
5785
- sync: FrontendSyncConfigSchema
5898
+ sync: FrontendSyncConfigSchema,
5899
+ catalog: FrontendCatalogConfigSchema
5786
5900
  }).strict().default({});
5787
5901
 
5788
5902
  // src/emitters/frontend/load-context.ts
@@ -5829,9 +5943,28 @@ function mapFrontendEmitConfig(config) {
5829
5943
  apiBaseUrlImport: fe.sync.apiBaseUrlImport,
5830
5944
  parsers: fe.parsers,
5831
5945
  architecture,
5832
- dbEntitiesImport: dbEntities.import
5946
+ dbEntitiesImport: dbEntities.import,
5947
+ catalogCategories: fe.catalog.categories
5833
5948
  };
5834
5949
  }
5950
+ function loadProviderCatalogInputs(cwd, config) {
5951
+ const providersDir = path12.resolve(
5952
+ cwd,
5953
+ config.paths?.providers ?? "definitions/providers"
5954
+ );
5955
+ if (!existsSync8(providersDir) || !statSync5(providersDir).isDirectory()) {
5956
+ return [];
5957
+ }
5958
+ const files = findYamlFiles(providersDir);
5959
+ if (files.length === 0) return [];
5960
+ return loadProvidersFromYaml(files).successes.map((s) => ({
5961
+ slug: s.definition.slug,
5962
+ displayName: s.definition.display_name,
5963
+ surfaces: s.definition.surfaces,
5964
+ status: s.definition.status,
5965
+ display: s.definition.display
5966
+ }));
5967
+ }
5835
5968
  function loadFrontendEmitContext(cwd, config, opts = {}) {
5836
5969
  const entitiesDir = opts.entitiesDir ?? path12.resolve(cwd, config.paths?.entities_dir ?? "entities");
5837
5970
  const { registry } = loadEntityRegistry(entitiesDir);
@@ -5846,6 +5979,7 @@ function loadFrontendEmitContext(cwd, config, opts = {}) {
5846
5979
  parsedList.map((p) => [p.name, p])
5847
5980
  );
5848
5981
  const emitConfig = mapFrontendEmitConfig(config);
5982
+ const providers = loadProviderCatalogInputs(cwd, config);
5849
5983
  const generated = resolveLocation(
5850
5984
  config,
5851
5985
  "frontendGenerated",
@@ -5854,7 +5988,7 @@ function loadFrontendEmitContext(cwd, config, opts = {}) {
5854
5988
  const outDir = path12.resolve(cwd, generated.path);
5855
5989
  return {
5856
5990
  skip: void 0,
5857
- ctx: { entities, parsed, config: emitConfig },
5991
+ ctx: { entities, parsed, config: emitConfig, providers },
5858
5992
  outDir
5859
5993
  };
5860
5994
  }
@@ -5868,6 +6002,7 @@ function emitFrontendSet(ctx, outDir) {
5868
6002
  ...emitEntities(ctx, outDir),
5869
6003
  ...emitStore(ctx, outDir),
5870
6004
  ...emitFields(ctx, outDir),
6005
+ ...emitProviders(ctx, outDir),
5871
6006
  ...emitIndex(ctx, outDir)
5872
6007
  ];
5873
6008
  }
@@ -12888,7 +13023,7 @@ var update_default = UpdateShortcut;
12888
13023
  // src/cli/index.ts
12889
13024
  function readVersion() {
12890
13025
  try {
12891
- const pkgPath = join17(import.meta.dirname, "..", "..", "package.json");
13026
+ const pkgPath = join18(import.meta.dirname, "..", "..", "package.json");
12892
13027
  const pkg = JSON.parse(readFileSync6(pkgPath, "utf-8"));
12893
13028
  return typeof pkg.version === "string" ? pkg.version : "0.0.0";
12894
13029
  } catch {