@open-mercato/cli 0.10.1-develop.7809.1.ea24461aeb → 0.10.1-develop.7811.1.66050c1838

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 (99) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/agentic/guides/module-facts.json +162 -162
  3. package/dist/agentic/guides/module-facts.v2.json +162 -162
  4. package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
  5. package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
  6. package/dist/agentic/guides/modules/api_docs/index.md +1 -1
  7. package/dist/agentic/guides/modules/api_keys/index.md +1 -1
  8. package/dist/agentic/guides/modules/attachments/index.md +1 -1
  9. package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
  10. package/dist/agentic/guides/modules/auth/index.md +1 -1
  11. package/dist/agentic/guides/modules/availability/index.md +1 -1
  12. package/dist/agentic/guides/modules/business_rules/index.md +1 -1
  13. package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
  14. package/dist/agentic/guides/modules/cart/index.md +1 -1
  15. package/dist/agentic/guides/modules/catalog/index.md +1 -1
  16. package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
  17. package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
  18. package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
  19. package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
  20. package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
  21. package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
  22. package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
  23. package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
  24. package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
  25. package/dist/agentic/guides/modules/checkout/index.md +1 -1
  26. package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
  27. package/dist/agentic/guides/modules/configs/index.md +1 -1
  28. package/dist/agentic/guides/modules/content/index.md +1 -1
  29. package/dist/agentic/guides/modules/currencies/index.md +1 -1
  30. package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
  31. package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
  32. package/dist/agentic/guides/modules/customers/index.md +1 -1
  33. package/dist/agentic/guides/modules/dashboards/index.md +1 -1
  34. package/dist/agentic/guides/modules/data_sync/index.md +1 -1
  35. package/dist/agentic/guides/modules/design_system/index.md +1 -1
  36. package/dist/agentic/guides/modules/devices/index.md +1 -1
  37. package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
  38. package/dist/agentic/guides/modules/directory/index.md +1 -1
  39. package/dist/agentic/guides/modules/documents/index.md +1 -1
  40. package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
  41. package/dist/agentic/guides/modules/entities/index.md +1 -1
  42. package/dist/agentic/guides/modules/eudr/index.md +1 -1
  43. package/dist/agentic/guides/modules/events/index.md +1 -1
  44. package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
  45. package/dist/agentic/guides/modules/forms/index.md +1 -1
  46. package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
  47. package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
  48. package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
  49. package/dist/agentic/guides/modules/generators/index.md +1 -1
  50. package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
  51. package/dist/agentic/guides/modules/integrations/index.md +1 -1
  52. package/dist/agentic/guides/modules/messages/index.md +1 -1
  53. package/dist/agentic/guides/modules/notifications/index.md +1 -1
  54. package/dist/agentic/guides/modules/onboarding/index.md +1 -1
  55. package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
  56. package/dist/agentic/guides/modules/perspectives/index.md +1 -1
  57. package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
  58. package/dist/agentic/guides/modules/planner/index.md +1 -1
  59. package/dist/agentic/guides/modules/portal/index.md +1 -1
  60. package/dist/agentic/guides/modules/progress/index.md +1 -1
  61. package/dist/agentic/guides/modules/promotions/index.md +1 -1
  62. package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
  63. package/dist/agentic/guides/modules/query_index/index.md +1 -1
  64. package/dist/agentic/guides/modules/record_locks/index.md +1 -1
  65. package/dist/agentic/guides/modules/resources/index.md +1 -1
  66. package/dist/agentic/guides/modules/sales/index.md +1 -1
  67. package/dist/agentic/guides/modules/scheduler/index.md +1 -1
  68. package/dist/agentic/guides/modules/search/index.md +1 -1
  69. package/dist/agentic/guides/modules/security/index.md +1 -1
  70. package/dist/agentic/guides/modules/seeds/index.md +1 -1
  71. package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
  72. package/dist/agentic/guides/modules/sso/index.md +1 -1
  73. package/dist/agentic/guides/modules/staff/index.md +1 -1
  74. package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
  75. package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
  76. package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
  77. package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
  78. package/dist/agentic/guides/modules/telemetry/index.md +1 -1
  79. package/dist/agentic/guides/modules/tillio/index.md +1 -1
  80. package/dist/agentic/guides/modules/translations/index.md +1 -1
  81. package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
  82. package/dist/agentic/guides/modules/webhooks/index.md +1 -1
  83. package/dist/agentic/guides/modules/wms/index.md +1 -1
  84. package/dist/agentic/guides/modules/workflows/index.md +1 -1
  85. package/dist/agentic/guides/reference-module-facts.json +1 -1
  86. package/dist/agentic/guides/upstream/manifest.json +1 -1
  87. package/dist/lib/generators/ast/imports.js +9 -4
  88. package/dist/lib/generators/ast/imports.js.map +2 -2
  89. package/dist/lib/generators/entity-ids.js +10 -12
  90. package/dist/lib/generators/entity-ids.js.map +2 -2
  91. package/dist/lib/generators/module-di.js +6 -9
  92. package/dist/lib/generators/module-di.js.map +2 -2
  93. package/dist/lib/generators/module-entities.js +6 -9
  94. package/dist/lib/generators/module-entities.js.map +2 -2
  95. package/package.json +7 -7
  96. package/src/lib/generators/ast/imports.ts +14 -4
  97. package/src/lib/generators/entity-ids.ts +10 -12
  98. package/src/lib/generators/module-di.ts +6 -9
  99. package/src/lib/generators/module-entities.ts +6 -9
@@ -1,5 +1,5 @@
1
1
  # staff — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/staff
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # storage_s3 — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/storage-s3 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/storage-s3 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/storage-s3/src/modules/storage_s3
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # sync_akeneo — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/sync-akeneo 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/sync-akeneo 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/sync-akeneo/src/modules/sync_akeneo
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # sync_excel — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/sync_excel
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # system_status_overlays — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/enterprise 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/enterprise 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/enterprise/src/modules/system_status_overlays
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # telemetry — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/telemetry 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/telemetry 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/telemetry/src/modules/telemetry
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # tillio — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/tillio 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/tillio 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/tillio/src/modules/tillio
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # translations — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/translations
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # warranty_claims — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/warranty_claims
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # webhooks — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/webhooks 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/webhooks 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/webhooks/src/modules/webhooks
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # wms — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/wms
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # workflows — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.7809.1.ea24461aeb; core 0.10.1-develop.7809.1.ea24461aeb — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.7811.1.66050c1838; core 0.10.1-develop.7811.1.66050c1838 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/workflows
4
4
 
5
5
  ## Sections
@@ -1185,7 +1185,7 @@
1185
1185
  "facts": {
1186
1186
  "title": "Example Module",
1187
1187
  "description": "Demonstrates pages, APIs, entities and DI.",
1188
- "coreVersion": "0.10.1-develop.7809.1.ea24461aeb",
1188
+ "coreVersion": "0.10.1-develop.7811.1.66050c1838",
1189
1189
  "sourcePackage": null,
1190
1190
  "sourceVersion": null,
1191
1191
  "sourceRoot": "src/modules/example",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 1,
3
- "generator": "@open-mercato/cli@0.10.1-develop.7809.1.ea24461aeb",
3
+ "generator": "@open-mercato/cli@0.10.1-develop.7811.1.66050c1838",
4
4
  "files": {
5
5
  "AGENTS.md": "b27342ee5f61e805ba52703fdb7ec822b030490f734b4d80f48dfd1e05fa4cf5",
6
6
  "BACKWARD_COMPATIBILITY.md": "e4b53767506d7ff4628c6cc7e38956792b32eb606749f8f4ba3f67dd2c9e86da"
@@ -45,9 +45,11 @@ function addImportSpec(sourceFile, spec) {
45
45
  });
46
46
  }
47
47
  function addImportSpecs(sourceFile, specs) {
48
- for (const spec of specs) {
49
- addImportSpec(sourceFile, spec);
50
- }
48
+ if (specs.length === 0) return;
49
+ sourceFile.addImportDeclarations(specs.map((spec) => ({
50
+ kind: StructureKind.ImportDeclaration,
51
+ ...spec
52
+ })));
51
53
  }
52
54
  function addImportStatement(sourceFile, statement) {
53
55
  const trimmed = statement.trim();
@@ -55,9 +57,12 @@ function addImportStatement(sourceFile, statement) {
55
57
  addImportSpec(sourceFile, toImportSpec(trimmed));
56
58
  }
57
59
  function addImportStatements(sourceFile, statements) {
60
+ const specs = [];
58
61
  for (const statement of statements) {
59
- addImportStatement(sourceFile, statement);
62
+ const trimmed = statement.trim();
63
+ if (trimmed) specs.push(toImportSpec(trimmed));
60
64
  }
65
+ addImportSpecs(sourceFile, specs);
61
66
  }
62
67
  export {
63
68
  addImportSpec,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/generators/ast/imports.ts"],
4
- "sourcesContent": ["import ts from 'typescript-js'\nimport {\n StructureKind,\n type ImportDeclarationStructure,\n type OptionalKind,\n type SourceFile,\n} from 'ts-morph'\n\nexport type GeneratedImportSpec = OptionalKind<ImportDeclarationStructure>\n\nfunction toImportSpec(statement: string): GeneratedImportSpec {\n const trimmed = statement.trim()\n const sourceFile = ts.createSourceFile('import.ts', trimmed, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)\n const importDeclaration = sourceFile.statements.find(ts.isImportDeclaration)\n if (!importDeclaration) {\n throw new Error(`Expected import declaration, received: ${statement}`)\n }\n\n const moduleSpecifier = importDeclaration.moduleSpecifier\n if (!ts.isStringLiteral(moduleSpecifier)) {\n throw new Error(`Unsupported import declaration: ${statement}`)\n }\n\n const spec: GeneratedImportSpec = {\n kind: StructureKind.ImportDeclaration,\n moduleSpecifier: moduleSpecifier.text,\n }\n\n const clause = importDeclaration.importClause\n if (!clause) {\n return spec\n }\n\n spec.isTypeOnly = clause.isTypeOnly\n\n if (clause.name) {\n spec.defaultImport = clause.name.text\n }\n\n if (clause.namedBindings && ts.isNamespaceImport(clause.namedBindings)) {\n spec.namespaceImport = clause.namedBindings.name.text\n }\n\n if (clause.namedBindings && ts.isNamedImports(clause.namedBindings)) {\n spec.namedImports = clause.namedBindings.elements.map((element) => ({\n kind: StructureKind.ImportSpecifier,\n name: element.propertyName?.text ?? element.name.text,\n alias: element.propertyName ? element.name.text : undefined,\n isTypeOnly: element.isTypeOnly,\n }))\n }\n\n return spec\n}\n\nexport function addImportSpec(sourceFile: SourceFile, spec: GeneratedImportSpec): void {\n sourceFile.addImportDeclaration({\n kind: StructureKind.ImportDeclaration,\n ...spec,\n })\n}\n\nexport function addImportSpecs(sourceFile: SourceFile, specs: GeneratedImportSpec[]): void {\n for (const spec of specs) {\n addImportSpec(sourceFile, spec)\n }\n}\n\nexport function addImportStatement(sourceFile: SourceFile, statement: string): void {\n const trimmed = statement.trim()\n if (!trimmed) return\n addImportSpec(sourceFile, toImportSpec(trimmed))\n}\n\nexport function addImportStatements(sourceFile: SourceFile, statements: string[]): void {\n for (const statement of statements) {\n addImportStatement(sourceFile, statement)\n }\n}\n"],
5
- "mappings": "AAAA,OAAO,QAAQ;AACf;AAAA,EACE;AAAA,OAIK;AAIP,SAAS,aAAa,WAAwC;AAC5D,QAAM,UAAU,UAAU,KAAK;AAC/B,QAAM,aAAa,GAAG,iBAAiB,aAAa,SAAS,GAAG,aAAa,QAAQ,MAAM,GAAG,WAAW,EAAE;AAC3G,QAAM,oBAAoB,WAAW,WAAW,KAAK,GAAG,mBAAmB;AAC3E,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,MAAM,0CAA0C,SAAS,EAAE;AAAA,EACvE;AAEA,QAAM,kBAAkB,kBAAkB;AAC1C,MAAI,CAAC,GAAG,gBAAgB,eAAe,GAAG;AACxC,UAAM,IAAI,MAAM,mCAAmC,SAAS,EAAE;AAAA,EAChE;AAEA,QAAM,OAA4B;AAAA,IAChC,MAAM,cAAc;AAAA,IACpB,iBAAiB,gBAAgB;AAAA,EACnC;AAEA,QAAM,SAAS,kBAAkB;AACjC,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,OAAK,aAAa,OAAO;AAEzB,MAAI,OAAO,MAAM;AACf,SAAK,gBAAgB,OAAO,KAAK;AAAA,EACnC;AAEA,MAAI,OAAO,iBAAiB,GAAG,kBAAkB,OAAO,aAAa,GAAG;AACtE,SAAK,kBAAkB,OAAO,cAAc,KAAK;AAAA,EACnD;AAEA,MAAI,OAAO,iBAAiB,GAAG,eAAe,OAAO,aAAa,GAAG;AACnE,SAAK,eAAe,OAAO,cAAc,SAAS,IAAI,CAAC,aAAa;AAAA,MAClE,MAAM,cAAc;AAAA,MACpB,MAAM,QAAQ,cAAc,QAAQ,QAAQ,KAAK;AAAA,MACjD,OAAO,QAAQ,eAAe,QAAQ,KAAK,OAAO;AAAA,MAClD,YAAY,QAAQ;AAAA,IACtB,EAAE;AAAA,EACJ;AAEA,SAAO;AACT;AAEO,SAAS,cAAc,YAAwB,MAAiC;AACrF,aAAW,qBAAqB;AAAA,IAC9B,MAAM,cAAc;AAAA,IACpB,GAAG;AAAA,EACL,CAAC;AACH;AAEO,SAAS,eAAe,YAAwB,OAAoC;AACzF,aAAW,QAAQ,OAAO;AACxB,kBAAc,YAAY,IAAI;AAAA,EAChC;AACF;AAEO,SAAS,mBAAmB,YAAwB,WAAyB;AAClF,QAAM,UAAU,UAAU,KAAK;AAC/B,MAAI,CAAC,QAAS;AACd,gBAAc,YAAY,aAAa,OAAO,CAAC;AACjD;AAEO,SAAS,oBAAoB,YAAwB,YAA4B;AACtF,aAAW,aAAa,YAAY;AAClC,uBAAmB,YAAY,SAAS;AAAA,EAC1C;AACF;",
4
+ "sourcesContent": ["import ts from 'typescript-js'\nimport {\n StructureKind,\n type ImportDeclarationStructure,\n type OptionalKind,\n type SourceFile,\n} from 'ts-morph'\n\nexport type GeneratedImportSpec = OptionalKind<ImportDeclarationStructure>\n\nfunction toImportSpec(statement: string): GeneratedImportSpec {\n const trimmed = statement.trim()\n const sourceFile = ts.createSourceFile('import.ts', trimmed, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)\n const importDeclaration = sourceFile.statements.find(ts.isImportDeclaration)\n if (!importDeclaration) {\n throw new Error(`Expected import declaration, received: ${statement}`)\n }\n\n const moduleSpecifier = importDeclaration.moduleSpecifier\n if (!ts.isStringLiteral(moduleSpecifier)) {\n throw new Error(`Unsupported import declaration: ${statement}`)\n }\n\n const spec: GeneratedImportSpec = {\n kind: StructureKind.ImportDeclaration,\n moduleSpecifier: moduleSpecifier.text,\n }\n\n const clause = importDeclaration.importClause\n if (!clause) {\n return spec\n }\n\n spec.isTypeOnly = clause.isTypeOnly\n\n if (clause.name) {\n spec.defaultImport = clause.name.text\n }\n\n if (clause.namedBindings && ts.isNamespaceImport(clause.namedBindings)) {\n spec.namespaceImport = clause.namedBindings.name.text\n }\n\n if (clause.namedBindings && ts.isNamedImports(clause.namedBindings)) {\n spec.namedImports = clause.namedBindings.elements.map((element) => ({\n kind: StructureKind.ImportSpecifier,\n name: element.propertyName?.text ?? element.name.text,\n alias: element.propertyName ? element.name.text : undefined,\n isTypeOnly: element.isTypeOnly,\n }))\n }\n\n return spec\n}\n\nexport function addImportSpec(sourceFile: SourceFile, spec: GeneratedImportSpec): void {\n sourceFile.addImportDeclaration({\n kind: StructureKind.ImportDeclaration,\n ...spec,\n })\n}\n\n/**\n * Inserts every import in one ts-morph manipulation. Each `addImportDeclaration` call\n * re-prints and re-parses the whole source file, so adding registry imports one by one is\n * quadratic in the import count and dominated `mercato generate` peak memory.\n */\nexport function addImportSpecs(sourceFile: SourceFile, specs: GeneratedImportSpec[]): void {\n if (specs.length === 0) return\n sourceFile.addImportDeclarations(specs.map((spec) => ({\n kind: StructureKind.ImportDeclaration,\n ...spec,\n })))\n}\n\nexport function addImportStatement(sourceFile: SourceFile, statement: string): void {\n const trimmed = statement.trim()\n if (!trimmed) return\n addImportSpec(sourceFile, toImportSpec(trimmed))\n}\n\nexport function addImportStatements(sourceFile: SourceFile, statements: string[]): void {\n const specs: GeneratedImportSpec[] = []\n for (const statement of statements) {\n const trimmed = statement.trim()\n if (trimmed) specs.push(toImportSpec(trimmed))\n }\n addImportSpecs(sourceFile, specs)\n}\n"],
5
+ "mappings": "AAAA,OAAO,QAAQ;AACf;AAAA,EACE;AAAA,OAIK;AAIP,SAAS,aAAa,WAAwC;AAC5D,QAAM,UAAU,UAAU,KAAK;AAC/B,QAAM,aAAa,GAAG,iBAAiB,aAAa,SAAS,GAAG,aAAa,QAAQ,MAAM,GAAG,WAAW,EAAE;AAC3G,QAAM,oBAAoB,WAAW,WAAW,KAAK,GAAG,mBAAmB;AAC3E,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,MAAM,0CAA0C,SAAS,EAAE;AAAA,EACvE;AAEA,QAAM,kBAAkB,kBAAkB;AAC1C,MAAI,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QAA+B,CAAC;AACtC,aAAW,aAAa,YAAY;AAClC,UAAM,UAAU,UAAU,KAAK;AAC/B,QAAI,QAAS,OAAM,KAAK,aAAa,OAAO,CAAC;AAAA,EAC/C;AACA,iBAAe,YAAY,KAAK;AAClC;",
6
6
  "names": []
7
7
  }
@@ -181,18 +181,16 @@ function writePerEntityFieldFiles(outRoot, fieldsByEntity, result) {
181
181
  const entDir = path.join(outRoot, entity);
182
182
  fs.mkdirSync(entDir, { recursive: true });
183
183
  const sourceFile = createGeneratedSourceFile(`${entity}/index.ts`);
184
- for (const field of fields) {
185
- sourceFile.addVariableStatement({
186
- declarationKind: VariableDeclarationKind.Const,
187
- isExported: true,
188
- declarations: [
189
- {
190
- name: toVar(field),
191
- initializer: JSON.stringify(field)
192
- }
193
- ]
194
- });
195
- }
184
+ sourceFile.addVariableStatements(fields.map((field) => ({
185
+ declarationKind: VariableDeclarationKind.Const,
186
+ isExported: true,
187
+ declarations: [
188
+ {
189
+ name: toVar(field),
190
+ initializer: JSON.stringify(field)
191
+ }
192
+ ]
193
+ })));
196
194
  writeTrackedFile(path.join(entDir, "index.ts"), getSourceText(sourceFile), result);
197
195
  }
198
196
  const existingEntries = fs.existsSync(outRoot) ? fs.readdirSync(outRoot, { withFileTypes: true }) : [];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/generators/entity-ids.ts"],
4
- "sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport ts from 'typescript-js'\nimport { VariableDeclarationKind } from 'ts-morph'\nimport type { PackageResolver, ModuleEntry } from '../resolver'\nimport { MODULE_CODE_EXTENSIONS } from './scanner'\nimport {\n toVar,\n toSnake,\n rimrafDir,\n type GeneratorResult,\n createGeneratorResult,\n writeGeneratedFile,\n writeIfChanged,\n} from '../utils'\nimport { addAutoGeneratedComment, createGeneratedSourceFile, elementAccess, getSourceText, identifier, returnStatement } from './ast'\n\ntype GroupKey = '@app' | '@open-mercato/core' | string\ntype EntityFieldMap = Record<string, string[]>\n\nexport interface EntityIdsOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\n/**\n * Extract exported class names from a TypeScript source file without dynamic import.\n * This is used for @app modules since Node.js can't import TypeScript files directly.\n */\nfunction parseExportedClassNamesFromFile(filePath: string): string[] {\n const src = fs.readFileSync(filePath, 'utf8')\n const sf = ts.createSourceFile(filePath, src, ts.ScriptTarget.ES2020, true, ts.ScriptKind.TS)\n const classNames: string[] = []\n\n sf.forEachChild((node) => {\n // Check for exported class declarations\n if (ts.isClassDeclaration(node) && node.name) {\n const hasExport = node.modifiers?.some(\n (m) => m.kind === ts.SyntaxKind.ExportKeyword\n )\n if (hasExport) {\n classNames.push(node.name.text)\n }\n }\n })\n\n return classNames\n}\n\nfunction unwrapObjectLiteralExpression(\n expression: ts.Expression | undefined,\n): ts.ObjectLiteralExpression | undefined {\n if (!expression) return undefined\n if (ts.isObjectLiteralExpression(expression)) return expression\n if (ts.isAsExpression(expression) || ts.isTypeAssertionExpression(expression)) {\n return unwrapObjectLiteralExpression(expression.expression)\n }\n if (ts.isParenthesizedExpression(expression)) {\n return unwrapObjectLiteralExpression(expression.expression)\n }\n return undefined\n}\n\nfunction readPropertyInitializer(\n objectLiteral: ts.ObjectLiteralExpression,\n propertyName: string,\n): ts.Expression | undefined {\n for (const property of objectLiteral.properties) {\n if (!ts.isPropertyAssignment(property)) continue\n const name = ts.isIdentifier(property.name)\n ? property.name.text\n : ts.isStringLiteralLike(property.name)\n ? property.name.text\n : undefined\n if (name === propertyName) {\n return property.initializer\n }\n }\n return undefined\n}\n\nfunction parseGeneratedModuleEntityNames(filePath: string, moduleId: string): string[] {\n if (!fs.existsSync(filePath)) return []\n\n const source = fs.readFileSync(filePath, 'utf8')\n const scriptKind = filePath.endsWith('.js') ? ts.ScriptKind.JS : ts.ScriptKind.TS\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.ES2020, true, scriptKind)\n\n for (const statement of sf.statements) {\n if (!ts.isVariableStatement(statement)) continue\n const declaration = statement.declarationList.declarations.find((candidate) =>\n ts.isIdentifier(candidate.name) && candidate.name.text === 'E')\n if (!declaration) continue\n\n const eObject = unwrapObjectLiteralExpression(declaration.initializer)\n if (!eObject) continue\n\n const moduleObject = unwrapObjectLiteralExpression(readPropertyInitializer(eObject, moduleId))\n if (!moduleObject) return []\n\n const names: string[] = []\n for (const property of moduleObject.properties) {\n if (!ts.isPropertyAssignment(property)) continue\n const name = ts.isIdentifier(property.name)\n ? property.name.text\n : ts.isStringLiteralLike(property.name)\n ? property.name.text\n : undefined\n if (name) names.push(name)\n }\n return names\n }\n\n return []\n}\n\nfunction parseGeneratedEntityFieldsFile(filePath: string): string[] {\n if (!fs.existsSync(filePath)) return []\n\n const source = fs.readFileSync(filePath, 'utf8')\n const scriptKind = filePath.endsWith('.js') ? ts.ScriptKind.JS : ts.ScriptKind.TS\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.ES2020, true, scriptKind)\n const fields: string[] = []\n\n for (const statement of sf.statements) {\n if (!ts.isVariableStatement(statement)) continue\n for (const declaration of statement.declarationList.declarations) {\n if (!ts.isIdentifier(declaration.name) || !declaration.initializer) continue\n if (!ts.isStringLiteralLike(declaration.initializer)) continue\n fields.push(declaration.initializer.text)\n }\n }\n\n return Array.from(new Set(fields))\n}\n\nfunction resolveExistingFile(candidates: string[]): string | null {\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n\nfunction loadStandaloneGeneratedPackageEntities(\n resolver: PackageResolver,\n entry: ModuleEntry,\n): { entityNames: string[]; entityFieldMap: EntityFieldMap } | null {\n if (resolver.isMonorepo() || !entry.from || entry.from === '@app') return null\n\n const packageRoot = resolver.getPackageRoot(entry.from)\n const generatedRoot = fs.existsSync(path.join(packageRoot, 'generated'))\n ? path.join(packageRoot, 'generated')\n : path.join(packageRoot, 'dist', 'generated')\n const idsFile = resolveExistingFile([\n path.join(generatedRoot, 'entities.ids.generated.ts'),\n path.join(generatedRoot, 'entities.ids.generated.js'),\n ])\n if (!idsFile) return null\n const entityNames = parseGeneratedModuleEntityNames(idsFile, entry.id)\n\n if (entityNames.length === 0) return null\n\n const entityFieldMap: EntityFieldMap = {}\n for (const entityName of entityNames) {\n const fieldsFile = resolveExistingFile([\n path.join(generatedRoot, 'entities', entityName, 'index.ts'),\n path.join(generatedRoot, 'entities', entityName, 'index.js'),\n ])\n if (!fieldsFile) continue\n const fields = parseGeneratedEntityFieldsFile(fieldsFile)\n entityFieldMap[entityName] = fields\n }\n\n return { entityNames, entityFieldMap }\n}\n\nfunction parseEntityFieldsFromFile(filePath: string, exportedClassNames: string[]): EntityFieldMap {\n const src = fs.readFileSync(filePath, 'utf8')\n const sf = ts.createSourceFile(filePath, src, ts.ScriptTarget.ES2020, true, ts.ScriptKind.TS)\n\n const exported = new Set(exportedClassNames)\n const result: EntityFieldMap = {}\n\n function getDecoratorArgNameLiteral(dec: ts.Decorator | undefined): string | undefined {\n if (!dec) return undefined\n const expr = dec.expression\n if (!ts.isCallExpression(expr)) return undefined\n if (!expr.arguments.length) return undefined\n const first = expr.arguments[0]\n if (!ts.isObjectLiteralExpression(first)) return undefined\n for (const prop of first.properties) {\n if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name) && prop.name.text === 'name') {\n if (ts.isStringLiteral(prop.initializer)) return prop.initializer.text\n }\n }\n return undefined\n }\n\n function normalizeDbName(propertyName: string, _decoratorName?: string, nameOverride?: string): string {\n if (nameOverride) return nameOverride\n return toSnake(propertyName)\n }\n\n sf.forEachChild((node) => {\n if (!ts.isClassDeclaration(node) || !node.name) return\n const clsName = node.name.text\n if (!exported.has(clsName)) return\n const entityKey = toSnake(clsName)\n const fields: string[] = []\n\n for (const member of node.members) {\n if (!ts.isPropertyDeclaration(member) || !member.name) continue\n const name = ts.isIdentifier(member.name)\n ? member.name.text\n : ts.isStringLiteral(member.name)\n ? member.name.text\n : undefined\n if (!name) continue\n if (member.modifiers?.some((m) => m.kind === ts.SyntaxKind.StaticKeyword)) continue\n const decorators = ts.canHaveDecorators(member)\n ? ts.getDecorators(member) ?? []\n : []\n let dbName: string | undefined\n if (decorators && decorators.length) {\n for (const d of decorators) {\n const nameOverride = getDecoratorArgNameLiteral(d)\n dbName = normalizeDbName(name, undefined, nameOverride)\n if (dbName) break\n }\n }\n if (!dbName) dbName = normalizeDbName(name)\n fields.push(dbName)\n }\n result[entityKey] = Array.from(new Set(fields))\n })\n\n return result\n}\n\nfunction writeTrackedFile(\n filePath: string,\n content: string,\n result: GeneratorResult,\n): void {\n if (writeIfChanged(filePath, content)) {\n result.filesWritten.push(filePath)\n } else {\n result.filesUnchanged.push(filePath)\n }\n}\n\nfunction writePerEntityFieldFiles(\n outRoot: string,\n fieldsByEntity: EntityFieldMap,\n result: GeneratorResult,\n): void {\n fs.mkdirSync(outRoot, { recursive: true })\n const desiredEntities = new Set(Object.keys(fieldsByEntity))\n for (const [entity, fields] of Object.entries(fieldsByEntity)) {\n const entDir = path.join(outRoot, entity)\n fs.mkdirSync(entDir, { recursive: true })\n const sourceFile = createGeneratedSourceFile(`${entity}/index.ts`)\n for (const field of fields) {\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: toVar(field),\n initializer: JSON.stringify(field),\n },\n ],\n })\n }\n writeTrackedFile(path.join(entDir, 'index.ts'), getSourceText(sourceFile), result)\n }\n\n const existingEntries = fs.existsSync(outRoot) ? fs.readdirSync(outRoot, { withFileTypes: true }) : []\n for (const entry of existingEntries) {\n if (!entry.isDirectory()) continue\n if (desiredEntities.has(entry.name)) continue\n const staleDirectory = path.join(outRoot, entry.name)\n rimrafDir(staleDirectory)\n result.filesWritten.push(staleDirectory)\n }\n}\n\nfunction writeEntityFieldsRegistry(\n generatedRoot: string,\n fieldsByEntity: EntityFieldMap,\n result: GeneratorResult,\n): void {\n const entities = Object.keys(fieldsByEntity).sort((a, b) => a.localeCompare(b))\n const registry: Record<string, Record<string, string>> = {}\n for (const entity of entities) {\n registry[toVar(entity)] = {}\n for (const field of fieldsByEntity[entity] ?? []) {\n registry[toVar(entity)][toVar(field)] = field\n }\n }\n\n const sourceFile = createGeneratedSourceFile('entity-fields-registry.ts')\n addAutoGeneratedComment(sourceFile, 'entity-ids')\n sourceFile.insertText(sourceFile.getFullText().length, '// Static registry for entity fields - eliminates dynamic imports for Turbopack compatibility\\n')\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: 'entityFieldsRegistry',\n type: 'Record<string, Record<string, string>>',\n initializer: JSON.stringify(registry, null, 2),\n },\n ],\n })\n sourceFile.addFunction({\n name: 'getEntityFields',\n isExported: true,\n parameters: [{ name: 'slug', type: 'string' }],\n returnType: 'Record<string, string> | undefined',\n statements: [returnStatement(elementAccess(identifier('entityFieldsRegistry'), identifier('slug')))],\n })\n const outPath = path.join(generatedRoot, 'entity-fields-registry.ts')\n writeTrackedFile(outPath, getSourceText(sourceFile), result)\n}\n\nexport async function generateEntityIds(options: EntityIdsOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'entities.ids.generated.ts')\n const checksumFile = path.join(outputDir, 'entities.ids.generated.checksum')\n\n const entries = resolver.loadEnabledModules()\n\n const consolidated: Record<string, Record<string, string>> = {}\n const grouped: Record<GroupKey, Record<string, Record<string, string>>> = {}\n const modulesDict: Record<string, string> = {}\n const groupedModulesDict: Record<GroupKey, Record<string, string>> = {}\n\n const fieldsByGroup: Record<GroupKey, Record<string, EntityFieldMap>> = {}\n\n for (const entry of entries) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imps = resolver.getModuleImportBase(entry)\n const group: GroupKey = (entry.from as GroupKey) || '@open-mercato/core'\n\n const standaloneGeneratedPackageEntities = loadStandaloneGeneratedPackageEntities(resolver, entry)\n\n // Locate entities definition file (prefer app override)\n const appData = path.join(roots.appBase, 'data')\n const pkgData = path.join(roots.pkgBase, 'data')\n const appDb = path.join(roots.appBase, 'db')\n const pkgDb = path.join(roots.pkgBase, 'db')\n const bases = [appData, pkgData, appDb, pkgDb]\n const candidates = ['entities.override', 'entities', 'schema']\n let importPath: string | null = null\n let filePath: string | null = null\n\n for (const base of bases) {\n for (const f of candidates) {\n const p = resolveConventionFile(base, f)\n if (p) {\n const fromApp = base.startsWith(roots.appBase)\n const sub = path.basename(base) // 'data' | 'db'\n importPath = `${fromApp ? imps.appBase : imps.pkgBase}/${sub}/${f}`\n filePath = p\n break\n }\n }\n if (importPath) break\n }\n\n // No entities file found -> still register module id\n if (!filePath && !standaloneGeneratedPackageEntities) {\n modulesDict[modId] = modId\n groupedModulesDict[group] = groupedModulesDict[group] || {}\n groupedModulesDict[group][modId] = modId\n continue\n }\n\n const exportNames = filePath ? parseExportedClassNamesFromFile(filePath) : []\n\n const entityNames = standaloneGeneratedPackageEntities\n ? standaloneGeneratedPackageEntities.entityNames\n : exportNames\n .map((k) => toSnake(k))\n .filter((k, idx, arr) => arr.indexOf(k) === idx)\n\n // Build dictionaries\n modulesDict[modId] = modId\n groupedModulesDict[group] = groupedModulesDict[group] || {}\n groupedModulesDict[group][modId] = modId\n\n consolidated[modId] = consolidated[modId] || {}\n grouped[group] = grouped[group] || {}\n grouped[group][modId] = grouped[group][modId] || {}\n\n for (const en of entityNames) {\n consolidated[modId][en] = `${modId}:${en}`\n grouped[group][modId][en] = `${modId}:${en}`\n }\n\n // Parse entity fields from TypeScript source\n const entityFieldMap = standaloneGeneratedPackageEntities\n ? standaloneGeneratedPackageEntities.entityFieldMap\n : parseEntityFieldsFromFile(filePath!, exportNames)\n fieldsByGroup[group] = fieldsByGroup[group] || {}\n fieldsByGroup[group][modId] = entityFieldMap\n }\n\n // Write consolidated output\n const consolidatedSourceFile = createGeneratedSourceFile('entities.ids.generated.ts')\n addAutoGeneratedComment(consolidatedSourceFile, 'entity-ids')\n consolidatedSourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'M', initializer: `${JSON.stringify(modulesDict, null, 2)} as const` },\n { name: 'E', initializer: `${JSON.stringify(consolidated, null, 2)} as const` },\n ],\n })\n consolidatedSourceFile.addTypeAlias({\n name: 'KnownModuleId',\n isExported: true,\n type: 'keyof typeof M',\n })\n consolidatedSourceFile.addTypeAlias({\n name: 'KnownEntities',\n isExported: true,\n type: 'typeof E',\n })\n const consolidatedSrc = getSourceText(consolidatedSourceFile)\n\n writeGeneratedFile({\n outFile,\n checksumFile,\n content: consolidatedSrc,\n structureChecksum: '',\n result,\n quiet,\n })\n\n // Write per-group outputs\n const groups = Object.keys(grouped) as GroupKey[]\n for (const g of groups) {\n if (!resolver.isMonorepo() && g !== '@app') {\n continue\n }\n\n const pkgOutputDir = resolver.getPackageOutputDir(g)\n // Skip @app group since it writes to the same location as the consolidated output\n if (g === '@app' && pkgOutputDir === outputDir) {\n continue\n }\n const out = path.join(pkgOutputDir, 'entities.ids.generated.ts')\n\n const groupSourceFile = createGeneratedSourceFile(`${String(g)}/entities.ids.generated.ts`)\n addAutoGeneratedComment(groupSourceFile, 'entity-ids')\n groupSourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'M', initializer: `${JSON.stringify(groupedModulesDict[g] || {}, null, 2)} as const` },\n { name: 'E', initializer: `${JSON.stringify(grouped[g] || {}, null, 2)} as const` },\n ],\n })\n groupSourceFile.addTypeAlias({\n name: 'KnownModuleId',\n isExported: true,\n type: 'keyof typeof M',\n })\n groupSourceFile.addTypeAlias({\n name: 'KnownEntities',\n isExported: true,\n type: 'typeof E',\n })\n const src = getSourceText(groupSourceFile)\n writeTrackedFile(out, src, result)\n\n const fieldsRoot = path.join(pkgOutputDir, 'entities')\n const fieldsByModule = fieldsByGroup[g] || {}\n const combined: EntityFieldMap = {}\n for (const mId of Object.keys(fieldsByModule)) {\n const mMap = fieldsByModule[mId]\n for (const [entity, fields] of Object.entries(mMap)) {\n combined[entity] = Array.from(new Set([...(combined[entity] || []), ...fields]))\n }\n }\n writePerEntityFieldFiles(fieldsRoot, combined, result)\n\n // Generate static entity fields registry for Turbopack compatibility\n writeEntityFieldsRegistry(pkgOutputDir, combined, result)\n }\n\n // Write combined entity fields to root generated/ folder\n const combinedAll: EntityFieldMap = {}\n for (const groupFields of Object.values(fieldsByGroup)) {\n for (const mMap of Object.values(groupFields)) {\n for (const [entity, fields] of Object.entries(mMap)) {\n combinedAll[entity] = Array.from(new Set([...(combinedAll[entity] || []), ...fields]))\n }\n }\n }\n writePerEntityFieldFiles(path.join(outputDir, 'entities'), combinedAll, result)\n writeEntityFieldsRegistry(outputDir, combinedAll, result)\n\n return result\n}\n\nfunction resolveConventionFile(baseDir: string, basename: string): string | null {\n for (const extension of MODULE_CODE_EXTENSIONS) {\n const candidate = path.join(baseDir, `${basename}${extension}`)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n"],
5
- "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,+BAA+B;AAExC,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB,2BAA2B,eAAe,eAAe,YAAY,uBAAuB;AAc9H,SAAS,gCAAgC,UAA4B;AACnE,QAAM,MAAM,GAAG,aAAa,UAAU,MAAM;AAC5C,QAAM,KAAK,GAAG,iBAAiB,UAAU,KAAK,GAAG,aAAa,QAAQ,MAAM,GAAG,WAAW,EAAE;AAC5F,QAAM,aAAuB,CAAC;AAE9B,KAAG,aAAa,CAAC,SAAS;AAExB,QAAI,GAAG,mBAAmB,IAAI,KAAK,KAAK,MAAM;AAC5C,YAAM,YAAY,KAAK,WAAW;AAAA,QAChC,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW;AAAA,MAClC;AACA,UAA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-js'\nimport { VariableDeclarationKind } from 'ts-morph'\nimport type { PackageResolver, ModuleEntry } from '../resolver'\nimport { MODULE_CODE_EXTENSIONS } from './scanner'\nimport {\n toVar,\n toSnake,\n rimrafDir,\n type GeneratorResult,\n createGeneratorResult,\n writeGeneratedFile,\n writeIfChanged,\n} from '../utils'\nimport { addAutoGeneratedComment, createGeneratedSourceFile, elementAccess, getSourceText, identifier, returnStatement } from './ast'\n\ntype GroupKey = '@app' | '@open-mercato/core' | string\ntype EntityFieldMap = Record<string, string[]>\n\nexport interface EntityIdsOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\n/**\n * Extract exported class names from a TypeScript source file without dynamic import.\n * This is used for @app modules since Node.js can't import TypeScript files directly.\n */\nfunction parseExportedClassNamesFromFile(filePath: string): string[] {\n const src = fs.readFileSync(filePath, 'utf8')\n const sf = ts.createSourceFile(filePath, src, ts.ScriptTarget.ES2020, true, ts.ScriptKind.TS)\n const classNames: string[] = []\n\n sf.forEachChild((node) => {\n // Check for exported class declarations\n if (ts.isClassDeclaration(node) && node.name) {\n const hasExport = node.modifiers?.some(\n (m) => m.kind === ts.SyntaxKind.ExportKeyword\n )\n if (hasExport) {\n classNames.push(node.name.text)\n }\n }\n })\n\n return classNames\n}\n\nfunction unwrapObjectLiteralExpression(\n expression: ts.Expression | undefined,\n): ts.ObjectLiteralExpression | undefined {\n if (!expression) return undefined\n if (ts.isObjectLiteralExpression(expression)) return expression\n if (ts.isAsExpression(expression) || ts.isTypeAssertionExpression(expression)) {\n return unwrapObjectLiteralExpression(expression.expression)\n }\n if (ts.isParenthesizedExpression(expression)) {\n return unwrapObjectLiteralExpression(expression.expression)\n }\n return undefined\n}\n\nfunction readPropertyInitializer(\n objectLiteral: ts.ObjectLiteralExpression,\n propertyName: string,\n): ts.Expression | undefined {\n for (const property of objectLiteral.properties) {\n if (!ts.isPropertyAssignment(property)) continue\n const name = ts.isIdentifier(property.name)\n ? property.name.text\n : ts.isStringLiteralLike(property.name)\n ? property.name.text\n : undefined\n if (name === propertyName) {\n return property.initializer\n }\n }\n return undefined\n}\n\nfunction parseGeneratedModuleEntityNames(filePath: string, moduleId: string): string[] {\n if (!fs.existsSync(filePath)) return []\n\n const source = fs.readFileSync(filePath, 'utf8')\n const scriptKind = filePath.endsWith('.js') ? ts.ScriptKind.JS : ts.ScriptKind.TS\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.ES2020, true, scriptKind)\n\n for (const statement of sf.statements) {\n if (!ts.isVariableStatement(statement)) continue\n const declaration = statement.declarationList.declarations.find((candidate) =>\n ts.isIdentifier(candidate.name) && candidate.name.text === 'E')\n if (!declaration) continue\n\n const eObject = unwrapObjectLiteralExpression(declaration.initializer)\n if (!eObject) continue\n\n const moduleObject = unwrapObjectLiteralExpression(readPropertyInitializer(eObject, moduleId))\n if (!moduleObject) return []\n\n const names: string[] = []\n for (const property of moduleObject.properties) {\n if (!ts.isPropertyAssignment(property)) continue\n const name = ts.isIdentifier(property.name)\n ? property.name.text\n : ts.isStringLiteralLike(property.name)\n ? property.name.text\n : undefined\n if (name) names.push(name)\n }\n return names\n }\n\n return []\n}\n\nfunction parseGeneratedEntityFieldsFile(filePath: string): string[] {\n if (!fs.existsSync(filePath)) return []\n\n const source = fs.readFileSync(filePath, 'utf8')\n const scriptKind = filePath.endsWith('.js') ? ts.ScriptKind.JS : ts.ScriptKind.TS\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.ES2020, true, scriptKind)\n const fields: string[] = []\n\n for (const statement of sf.statements) {\n if (!ts.isVariableStatement(statement)) continue\n for (const declaration of statement.declarationList.declarations) {\n if (!ts.isIdentifier(declaration.name) || !declaration.initializer) continue\n if (!ts.isStringLiteralLike(declaration.initializer)) continue\n fields.push(declaration.initializer.text)\n }\n }\n\n return Array.from(new Set(fields))\n}\n\nfunction resolveExistingFile(candidates: string[]): string | null {\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n\nfunction loadStandaloneGeneratedPackageEntities(\n resolver: PackageResolver,\n entry: ModuleEntry,\n): { entityNames: string[]; entityFieldMap: EntityFieldMap } | null {\n if (resolver.isMonorepo() || !entry.from || entry.from === '@app') return null\n\n const packageRoot = resolver.getPackageRoot(entry.from)\n const generatedRoot = fs.existsSync(path.join(packageRoot, 'generated'))\n ? path.join(packageRoot, 'generated')\n : path.join(packageRoot, 'dist', 'generated')\n const idsFile = resolveExistingFile([\n path.join(generatedRoot, 'entities.ids.generated.ts'),\n path.join(generatedRoot, 'entities.ids.generated.js'),\n ])\n if (!idsFile) return null\n const entityNames = parseGeneratedModuleEntityNames(idsFile, entry.id)\n\n if (entityNames.length === 0) return null\n\n const entityFieldMap: EntityFieldMap = {}\n for (const entityName of entityNames) {\n const fieldsFile = resolveExistingFile([\n path.join(generatedRoot, 'entities', entityName, 'index.ts'),\n path.join(generatedRoot, 'entities', entityName, 'index.js'),\n ])\n if (!fieldsFile) continue\n const fields = parseGeneratedEntityFieldsFile(fieldsFile)\n entityFieldMap[entityName] = fields\n }\n\n return { entityNames, entityFieldMap }\n}\n\nfunction parseEntityFieldsFromFile(filePath: string, exportedClassNames: string[]): EntityFieldMap {\n const src = fs.readFileSync(filePath, 'utf8')\n const sf = ts.createSourceFile(filePath, src, ts.ScriptTarget.ES2020, true, ts.ScriptKind.TS)\n\n const exported = new Set(exportedClassNames)\n const result: EntityFieldMap = {}\n\n function getDecoratorArgNameLiteral(dec: ts.Decorator | undefined): string | undefined {\n if (!dec) return undefined\n const expr = dec.expression\n if (!ts.isCallExpression(expr)) return undefined\n if (!expr.arguments.length) return undefined\n const first = expr.arguments[0]\n if (!ts.isObjectLiteralExpression(first)) return undefined\n for (const prop of first.properties) {\n if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name) && prop.name.text === 'name') {\n if (ts.isStringLiteral(prop.initializer)) return prop.initializer.text\n }\n }\n return undefined\n }\n\n function normalizeDbName(propertyName: string, _decoratorName?: string, nameOverride?: string): string {\n if (nameOverride) return nameOverride\n return toSnake(propertyName)\n }\n\n sf.forEachChild((node) => {\n if (!ts.isClassDeclaration(node) || !node.name) return\n const clsName = node.name.text\n if (!exported.has(clsName)) return\n const entityKey = toSnake(clsName)\n const fields: string[] = []\n\n for (const member of node.members) {\n if (!ts.isPropertyDeclaration(member) || !member.name) continue\n const name = ts.isIdentifier(member.name)\n ? member.name.text\n : ts.isStringLiteral(member.name)\n ? member.name.text\n : undefined\n if (!name) continue\n if (member.modifiers?.some((m) => m.kind === ts.SyntaxKind.StaticKeyword)) continue\n const decorators = ts.canHaveDecorators(member)\n ? ts.getDecorators(member) ?? []\n : []\n let dbName: string | undefined\n if (decorators && decorators.length) {\n for (const d of decorators) {\n const nameOverride = getDecoratorArgNameLiteral(d)\n dbName = normalizeDbName(name, undefined, nameOverride)\n if (dbName) break\n }\n }\n if (!dbName) dbName = normalizeDbName(name)\n fields.push(dbName)\n }\n result[entityKey] = Array.from(new Set(fields))\n })\n\n return result\n}\n\nfunction writeTrackedFile(\n filePath: string,\n content: string,\n result: GeneratorResult,\n): void {\n if (writeIfChanged(filePath, content)) {\n result.filesWritten.push(filePath)\n } else {\n result.filesUnchanged.push(filePath)\n }\n}\n\nfunction writePerEntityFieldFiles(\n outRoot: string,\n fieldsByEntity: EntityFieldMap,\n result: GeneratorResult,\n): void {\n fs.mkdirSync(outRoot, { recursive: true })\n const desiredEntities = new Set(Object.keys(fieldsByEntity))\n for (const [entity, fields] of Object.entries(fieldsByEntity)) {\n const entDir = path.join(outRoot, entity)\n fs.mkdirSync(entDir, { recursive: true })\n const sourceFile = createGeneratedSourceFile(`${entity}/index.ts`)\n sourceFile.addVariableStatements(fields.map((field) => ({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: toVar(field),\n initializer: JSON.stringify(field),\n },\n ],\n })))\n writeTrackedFile(path.join(entDir, 'index.ts'), getSourceText(sourceFile), result)\n }\n\n const existingEntries = fs.existsSync(outRoot) ? fs.readdirSync(outRoot, { withFileTypes: true }) : []\n for (const entry of existingEntries) {\n if (!entry.isDirectory()) continue\n if (desiredEntities.has(entry.name)) continue\n const staleDirectory = path.join(outRoot, entry.name)\n rimrafDir(staleDirectory)\n result.filesWritten.push(staleDirectory)\n }\n}\n\nfunction writeEntityFieldsRegistry(\n generatedRoot: string,\n fieldsByEntity: EntityFieldMap,\n result: GeneratorResult,\n): void {\n const entities = Object.keys(fieldsByEntity).sort((a, b) => a.localeCompare(b))\n const registry: Record<string, Record<string, string>> = {}\n for (const entity of entities) {\n registry[toVar(entity)] = {}\n for (const field of fieldsByEntity[entity] ?? []) {\n registry[toVar(entity)][toVar(field)] = field\n }\n }\n\n const sourceFile = createGeneratedSourceFile('entity-fields-registry.ts')\n addAutoGeneratedComment(sourceFile, 'entity-ids')\n sourceFile.insertText(sourceFile.getFullText().length, '// Static registry for entity fields - eliminates dynamic imports for Turbopack compatibility\\n')\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: 'entityFieldsRegistry',\n type: 'Record<string, Record<string, string>>',\n initializer: JSON.stringify(registry, null, 2),\n },\n ],\n })\n sourceFile.addFunction({\n name: 'getEntityFields',\n isExported: true,\n parameters: [{ name: 'slug', type: 'string' }],\n returnType: 'Record<string, string> | undefined',\n statements: [returnStatement(elementAccess(identifier('entityFieldsRegistry'), identifier('slug')))],\n })\n const outPath = path.join(generatedRoot, 'entity-fields-registry.ts')\n writeTrackedFile(outPath, getSourceText(sourceFile), result)\n}\n\nexport async function generateEntityIds(options: EntityIdsOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'entities.ids.generated.ts')\n const checksumFile = path.join(outputDir, 'entities.ids.generated.checksum')\n\n const entries = resolver.loadEnabledModules()\n\n const consolidated: Record<string, Record<string, string>> = {}\n const grouped: Record<GroupKey, Record<string, Record<string, string>>> = {}\n const modulesDict: Record<string, string> = {}\n const groupedModulesDict: Record<GroupKey, Record<string, string>> = {}\n\n const fieldsByGroup: Record<GroupKey, Record<string, EntityFieldMap>> = {}\n\n for (const entry of entries) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imps = resolver.getModuleImportBase(entry)\n const group: GroupKey = (entry.from as GroupKey) || '@open-mercato/core'\n\n const standaloneGeneratedPackageEntities = loadStandaloneGeneratedPackageEntities(resolver, entry)\n\n // Locate entities definition file (prefer app override)\n const appData = path.join(roots.appBase, 'data')\n const pkgData = path.join(roots.pkgBase, 'data')\n const appDb = path.join(roots.appBase, 'db')\n const pkgDb = path.join(roots.pkgBase, 'db')\n const bases = [appData, pkgData, appDb, pkgDb]\n const candidates = ['entities.override', 'entities', 'schema']\n let importPath: string | null = null\n let filePath: string | null = null\n\n for (const base of bases) {\n for (const f of candidates) {\n const p = resolveConventionFile(base, f)\n if (p) {\n const fromApp = base.startsWith(roots.appBase)\n const sub = path.basename(base) // 'data' | 'db'\n importPath = `${fromApp ? imps.appBase : imps.pkgBase}/${sub}/${f}`\n filePath = p\n break\n }\n }\n if (importPath) break\n }\n\n // No entities file found -> still register module id\n if (!filePath && !standaloneGeneratedPackageEntities) {\n modulesDict[modId] = modId\n groupedModulesDict[group] = groupedModulesDict[group] || {}\n groupedModulesDict[group][modId] = modId\n continue\n }\n\n const exportNames = filePath ? parseExportedClassNamesFromFile(filePath) : []\n\n const entityNames = standaloneGeneratedPackageEntities\n ? standaloneGeneratedPackageEntities.entityNames\n : exportNames\n .map((k) => toSnake(k))\n .filter((k, idx, arr) => arr.indexOf(k) === idx)\n\n // Build dictionaries\n modulesDict[modId] = modId\n groupedModulesDict[group] = groupedModulesDict[group] || {}\n groupedModulesDict[group][modId] = modId\n\n consolidated[modId] = consolidated[modId] || {}\n grouped[group] = grouped[group] || {}\n grouped[group][modId] = grouped[group][modId] || {}\n\n for (const en of entityNames) {\n consolidated[modId][en] = `${modId}:${en}`\n grouped[group][modId][en] = `${modId}:${en}`\n }\n\n // Parse entity fields from TypeScript source\n const entityFieldMap = standaloneGeneratedPackageEntities\n ? standaloneGeneratedPackageEntities.entityFieldMap\n : parseEntityFieldsFromFile(filePath!, exportNames)\n fieldsByGroup[group] = fieldsByGroup[group] || {}\n fieldsByGroup[group][modId] = entityFieldMap\n }\n\n // Write consolidated output\n const consolidatedSourceFile = createGeneratedSourceFile('entities.ids.generated.ts')\n addAutoGeneratedComment(consolidatedSourceFile, 'entity-ids')\n consolidatedSourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'M', initializer: `${JSON.stringify(modulesDict, null, 2)} as const` },\n { name: 'E', initializer: `${JSON.stringify(consolidated, null, 2)} as const` },\n ],\n })\n consolidatedSourceFile.addTypeAlias({\n name: 'KnownModuleId',\n isExported: true,\n type: 'keyof typeof M',\n })\n consolidatedSourceFile.addTypeAlias({\n name: 'KnownEntities',\n isExported: true,\n type: 'typeof E',\n })\n const consolidatedSrc = getSourceText(consolidatedSourceFile)\n\n writeGeneratedFile({\n outFile,\n checksumFile,\n content: consolidatedSrc,\n structureChecksum: '',\n result,\n quiet,\n })\n\n // Write per-group outputs\n const groups = Object.keys(grouped) as GroupKey[]\n for (const g of groups) {\n if (!resolver.isMonorepo() && g !== '@app') {\n continue\n }\n\n const pkgOutputDir = resolver.getPackageOutputDir(g)\n // Skip @app group since it writes to the same location as the consolidated output\n if (g === '@app' && pkgOutputDir === outputDir) {\n continue\n }\n const out = path.join(pkgOutputDir, 'entities.ids.generated.ts')\n\n const groupSourceFile = createGeneratedSourceFile(`${String(g)}/entities.ids.generated.ts`)\n addAutoGeneratedComment(groupSourceFile, 'entity-ids')\n groupSourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'M', initializer: `${JSON.stringify(groupedModulesDict[g] || {}, null, 2)} as const` },\n { name: 'E', initializer: `${JSON.stringify(grouped[g] || {}, null, 2)} as const` },\n ],\n })\n groupSourceFile.addTypeAlias({\n name: 'KnownModuleId',\n isExported: true,\n type: 'keyof typeof M',\n })\n groupSourceFile.addTypeAlias({\n name: 'KnownEntities',\n isExported: true,\n type: 'typeof E',\n })\n const src = getSourceText(groupSourceFile)\n writeTrackedFile(out, src, result)\n\n const fieldsRoot = path.join(pkgOutputDir, 'entities')\n const fieldsByModule = fieldsByGroup[g] || {}\n const combined: EntityFieldMap = {}\n for (const mId of Object.keys(fieldsByModule)) {\n const mMap = fieldsByModule[mId]\n for (const [entity, fields] of Object.entries(mMap)) {\n combined[entity] = Array.from(new Set([...(combined[entity] || []), ...fields]))\n }\n }\n writePerEntityFieldFiles(fieldsRoot, combined, result)\n\n // Generate static entity fields registry for Turbopack compatibility\n writeEntityFieldsRegistry(pkgOutputDir, combined, result)\n }\n\n // Write combined entity fields to root generated/ folder\n const combinedAll: EntityFieldMap = {}\n for (const groupFields of Object.values(fieldsByGroup)) {\n for (const mMap of Object.values(groupFields)) {\n for (const [entity, fields] of Object.entries(mMap)) {\n combinedAll[entity] = Array.from(new Set([...(combinedAll[entity] || []), ...fields]))\n }\n }\n }\n writePerEntityFieldFiles(path.join(outputDir, 'entities'), combinedAll, result)\n writeEntityFieldsRegistry(outputDir, combinedAll, result)\n\n return result\n}\n\nfunction resolveConventionFile(baseDir: string, basename: string): string | null {\n for (const extension of MODULE_CODE_EXTENSIONS) {\n const candidate = path.join(baseDir, `${basename}${extension}`)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n"],
5
+ "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,+BAA+B;AAExC,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB,2BAA2B,eAAe,eAAe,YAAY,uBAAuB;AAc9H,SAAS,gCAAgC,UAA4B;AACnE,QAAM,MAAM,GAAG,aAAa,UAAU,MAA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Aa,MAAM;AAExD,SAAO;AACT;AAEA,SAAS,sBAAsB,SAAiB,UAAiC;AAC/E,aAAW,aAAa,wBAAwB;AAC9C,UAAM,YAAY,KAAK,KAAK,SAAS,GAAG,QAAQ,GAAG,SAAS,EAAE;AAC9D,QAAI,GAAG,WAAW,SAAS,EAAG,QAAO;AAAA,EACvC;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { StructureKind, VariableDeclarationKind } from "ts-morph";
3
+ import { VariableDeclarationKind } from "ts-morph";
4
4
  import { MODULE_CODE_EXTENSIONS } from "./scanner.js";
5
5
  import {
6
6
  toVar,
@@ -9,7 +9,7 @@ import {
9
9
  } from "../utils.js";
10
10
  import {
11
11
  addAutoGeneratedComment,
12
- addImportSpec,
12
+ addImportSpecs,
13
13
  arrayLiteral,
14
14
  createGeneratedSourceFile,
15
15
  getSourceText,
@@ -48,13 +48,10 @@ async function generateModuleDi(options) {
48
48
  }
49
49
  const sourceFile = createGeneratedSourceFile("di.generated.ts");
50
50
  addAutoGeneratedComment(sourceFile, "di");
51
- imports.forEach((entry) => {
52
- addImportSpec(sourceFile, {
53
- kind: StructureKind.ImportDeclaration,
54
- namespaceImport: entry.name,
55
- moduleSpecifier: entry.moduleSpecifier
56
- });
57
- });
51
+ addImportSpecs(sourceFile, imports.map((entry) => ({
52
+ namespaceImport: entry.name,
53
+ moduleSpecifier: entry.moduleSpecifier
54
+ })));
58
55
  sourceFile.addVariableStatement({
59
56
  declarationKind: VariableDeclarationKind.Const,
60
57
  declarations: [
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/generators/module-di.ts"],
4
- "sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport { StructureKind, VariableDeclarationKind } from 'ts-morph'\nimport type { PackageResolver } from '../resolver'\nimport { MODULE_CODE_EXTENSIONS } from './scanner'\nimport {\n toVar,\n type GeneratorResult,\n createGeneratorResult,\n writeGeneratedFile,\n} from '../utils'\nimport {\n addAutoGeneratedComment,\n addImportSpec,\n arrayLiteral,\n createGeneratedSourceFile,\n getSourceText,\n identifier,\n methodCall,\n parenthesized,\n} from './ast'\n\nexport interface ModuleDiOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\nexport async function generateModuleDi(options: ModuleDiOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'di.generated.ts')\n const checksumFile = path.join(outputDir, 'di.generated.checksum')\n\n const mods = resolver.loadEnabledModules()\n const imports: Array<{ name: string; moduleSpecifier: string }> = []\n const registrars: string[] = []\n let i = 0\n\n for (const entry of mods) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imp = resolver.getModuleImportBase(entry)\n const isAppModule = entry.from === '@app'\n\n const useApp = resolveModuleConventionFile(roots.appBase, 'di')\n const usePkg = resolveModuleConventionFile(roots.pkgBase, 'di')\n const importName = `D_${toVar(modId)}_${i++}`\n\n if (useApp) {\n warnIfDiMissingRegisterExport(findModuleConventionFilePath(roots.appBase, 'di'), quiet)\n // For @app modules, use relative path to work in both Next.js and Node.js CLI context\n // From .mercato/generated/, go up two levels (../..) to reach the app root, then into src/modules/\n const importPath = isAppModule ? `../../src/modules/${modId}/di` : `${imp.appBase}/di`\n imports.push({ name: importName, moduleSpecifier: importPath })\n registrars.push(`${importName}.register`)\n } else if (usePkg) {\n warnIfDiMissingRegisterExport(findModuleConventionFilePath(roots.pkgBase, 'di'), quiet)\n imports.push({ name: importName, moduleSpecifier: `${imp.pkgBase}/di` })\n registrars.push(`${importName}.register`)\n }\n }\n\n const sourceFile = createGeneratedSourceFile('di.generated.ts')\n addAutoGeneratedComment(sourceFile, 'di')\n imports.forEach((entry) => {\n addImportSpec(sourceFile, {\n kind: StructureKind.ImportDeclaration,\n namespaceImport: entry.name,\n moduleSpecifier: entry.moduleSpecifier,\n })\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'diRegistrars',\n type: '(((c: any) => void) | undefined)[]',\n initializer: methodCall(\n parenthesized(arrayLiteral(registrars, (currentWriter, registrar) => identifier(registrar)(currentWriter))),\n 'filter',\n [identifier('Boolean')],\n ),\n },\n ],\n })\n sourceFile.addExportDeclaration({\n namedExports: ['diRegistrars'],\n })\n sourceFile.addExportAssignment({\n isExportEquals: false,\n expression: 'diRegistrars',\n })\n const output = getSourceText(sourceFile)\n\n writeGeneratedFile({\n outFile,\n checksumFile,\n content: output,\n structureChecksum: '',\n result,\n quiet,\n })\n\n return result\n}\n\nfunction resolveModuleConventionFile(baseDir: string, basename: string): boolean {\n return MODULE_CODE_EXTENSIONS.some((extension) => fs.existsSync(path.join(baseDir, `${basename}${extension}`)))\n}\n\nfunction findModuleConventionFilePath(baseDir: string, basename: string): string | null {\n for (const extension of MODULE_CODE_EXTENSIONS) {\n const candidate = path.join(baseDir, `${basename}${extension}`)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n\n/**\n * Warns when a discovered `di.ts` exports no `register`.\n *\n * The generated registrar list is built from `<import>.register` for every module that has a\n * `di` file. A differently named export makes that entry `undefined`, so the module's DI\n * registrations silently never run and its services surface as missing at request time\n * instead of at generation time.\n */\nexport function warnIfDiMissingRegisterExport(diPath: string | null, quiet = false): void {\n if (!diPath || quiet) return\n let source = ''\n try {\n source = fs.readFileSync(diPath, 'utf8')\n } catch {\n return\n }\n const exportsRegister = /export\\s+(async\\s+)?function\\s+register\\b/.test(source)\n || /export\\s+(const|let|var)\\s+register\\b/.test(source)\n || /export\\s*\\{[^}]*\\bregister\\b[^}]*\\}/.test(source)\n if (exportsRegister) return\n console.warn(\n `[generate] \u26A0 di.ts exports no 'register' \u2014 this module's DI registrations will never run: ${diPath}`,\n )\n}\n"],
5
- "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,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T;AAUO,SAAS,8BAA8B,QAAuB,QAAQ,OAAa;AACxF,MAAI,CAAC,UAAU,MAAO;AACtB,MAAI,SAAS;AACb,MAAI;AACF,aAAS,GAAG,aAAa,QAAQ,MAAM;AAAA,EACzC,QAAQ;AACN;AAAA,EACF;AACA,QAAM,kBAAkB,4CAA4C,KAAK,MAAM,KAC1E,wCAAwC,KAAK,MAAM,KACnD,sCAAsC,KAAK,MAAM;AACtD,MAAI,gBAAiB;AACrB,UAAQ;AAAA,IACN,uGAA6F,MAAM;AAAA,EACrG;AACF;",
4
+ "sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport { VariableDeclarationKind } from 'ts-morph'\nimport type { PackageResolver } from '../resolver'\nimport { MODULE_CODE_EXTENSIONS } from './scanner'\nimport {\n toVar,\n type GeneratorResult,\n createGeneratorResult,\n writeGeneratedFile,\n} from '../utils'\nimport {\n addAutoGeneratedComment,\n addImportSpecs,\n arrayLiteral,\n createGeneratedSourceFile,\n getSourceText,\n identifier,\n methodCall,\n parenthesized,\n} from './ast'\n\nexport interface ModuleDiOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\nexport async function generateModuleDi(options: ModuleDiOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'di.generated.ts')\n const checksumFile = path.join(outputDir, 'di.generated.checksum')\n\n const mods = resolver.loadEnabledModules()\n const imports: Array<{ name: string; moduleSpecifier: string }> = []\n const registrars: string[] = []\n let i = 0\n\n for (const entry of mods) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imp = resolver.getModuleImportBase(entry)\n const isAppModule = entry.from === '@app'\n\n const useApp = resolveModuleConventionFile(roots.appBase, 'di')\n const usePkg = resolveModuleConventionFile(roots.pkgBase, 'di')\n const importName = `D_${toVar(modId)}_${i++}`\n\n if (useApp) {\n warnIfDiMissingRegisterExport(findModuleConventionFilePath(roots.appBase, 'di'), quiet)\n // For @app modules, use relative path to work in both Next.js and Node.js CLI context\n // From .mercato/generated/, go up two levels (../..) to reach the app root, then into src/modules/\n const importPath = isAppModule ? `../../src/modules/${modId}/di` : `${imp.appBase}/di`\n imports.push({ name: importName, moduleSpecifier: importPath })\n registrars.push(`${importName}.register`)\n } else if (usePkg) {\n warnIfDiMissingRegisterExport(findModuleConventionFilePath(roots.pkgBase, 'di'), quiet)\n imports.push({ name: importName, moduleSpecifier: `${imp.pkgBase}/di` })\n registrars.push(`${importName}.register`)\n }\n }\n\n const sourceFile = createGeneratedSourceFile('di.generated.ts')\n addAutoGeneratedComment(sourceFile, 'di')\n addImportSpecs(sourceFile, imports.map((entry) => ({\n namespaceImport: entry.name,\n moduleSpecifier: entry.moduleSpecifier,\n })))\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'diRegistrars',\n type: '(((c: any) => void) | undefined)[]',\n initializer: methodCall(\n parenthesized(arrayLiteral(registrars, (currentWriter, registrar) => identifier(registrar)(currentWriter))),\n 'filter',\n [identifier('Boolean')],\n ),\n },\n ],\n })\n sourceFile.addExportDeclaration({\n namedExports: ['diRegistrars'],\n })\n sourceFile.addExportAssignment({\n isExportEquals: false,\n expression: 'diRegistrars',\n })\n const output = getSourceText(sourceFile)\n\n writeGeneratedFile({\n outFile,\n checksumFile,\n content: output,\n structureChecksum: '',\n result,\n quiet,\n })\n\n return result\n}\n\nfunction resolveModuleConventionFile(baseDir: string, basename: string): boolean {\n return MODULE_CODE_EXTENSIONS.some((extension) => fs.existsSync(path.join(baseDir, `${basename}${extension}`)))\n}\n\nfunction findModuleConventionFilePath(baseDir: string, basename: string): string | null {\n for (const extension of MODULE_CODE_EXTENSIONS) {\n const candidate = path.join(baseDir, `${basename}${extension}`)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n\n/**\n * Warns when a discovered `di.ts` exports no `register`.\n *\n * The generated registrar list is built from `<import>.register` for every module that has a\n * `di` file. A differently named export makes that entry `undefined`, so the module's DI\n * registrations silently never run and its services surface as missing at request time\n * instead of at generation time.\n */\nexport function warnIfDiMissingRegisterExport(diPath: string | null, quiet = false): void {\n if (!diPath || quiet) return\n let source = ''\n try {\n source = fs.readFileSync(diPath, 'utf8')\n } catch {\n return\n }\n const exportsRegister = /export\\s+(async\\s+)?function\\s+register\\b/.test(source)\n || /export\\s+(const|let|var)\\s+register\\b/.test(source)\n || /export\\s*\\{[^}]*\\bregister\\b[^}]*\\}/.test(source)\n if (exportsRegister) return\n console.warn(\n `[generate] \u26A0 di.ts exports no 'register' \u2014 this module's DI registrations will never run: ${diPath}`,\n )\n}\n"],
5
+ "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,+BAA+B;AAExC,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP,eAAsB,iBAAiB,SAAoD;AACzF,QAAM,EAAE,UAAU,QAAQ,MAAM,IAAI;AACpC,QAAM,SAAS,sBAAsB;AAErC,QAAM,YAAY,SAAS,aAAa;AACxC,QAAM,UAAU,KAAK,KAAK,WAAW,iBAAiB;AACtD,QAAM,eAAe,KAAK,KAAK,WAAW,uBAAuB;AAEjE,QAAM,OAAO,SAAS,mBAAmB;AACzC,QAAM,UAA4D,CAAC;AACnE,QAAM,aAAuB,CAAC;AAC9B,MAAI,IAAI;AAER,aAAW,SAAS,MAAM;AACxB,UAAM,QAAQ,MAAM;AACpB,UAAM,QAAQ,SAAS,eAAe,KAAK;AAC3C,UAAM,MAAM,SAAS,oBAAoB,KAAK;AAC9C,UAAM,cAAc,MAAM,SAAS;AAEnC,UAAM,SAAS,4BAA4B,MAAM,SAAS,IAAI;AAC9D,UAAM,SAAS,4BAA4B,MAAM,SAAS,IAAI;AAC9D,UAAM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AAmB;AAAA,IACnB;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEA,SAAS,4BAA4B,SAAiB,UAA2B;AAC/E,SAAO,uBAAuB,KAAK,CAAC,cAAc,GAAG,WAAW,KAAK,KAAK,SAAS,GAAG,QAAQ,GAAG,SAAS,EAAE,CAAC,CAAC;AAChH;AAEA,SAAS,6BAA6B,SAAiB,UAAiC;AACtF,aAAW,aAAa,wBAAwB;AAC9C,UAAM,YAAY,KAAK,KAAK,SAAS,GAAG,QAAQ,GAAG,SAAS,EAAE;AAC9D,QAAI,GAAG,WAAW,SAAS,EAAG,QAAO;AAAA,EACvC;AACA,SAAO;AACT;AAUO,SAAS,8BAA8B,QAAuB,QAAQ,OAAa;AACxF,MAAI,CAAC,UAAU,MAAO;AACtB,MAAI,SAAS;AACb,MAAI;AACF,aAAS,GAAG,aAAa,QAAQ,MAAM;AAAA,EACzC,QAAQ;AACN;AAAA,EACF;AACA,QAAM,kBAAkB,4CAA4C,KAAK,MAAM,KAC1E,wCAAwC,KAAK,MAAM,KACnD,sCAAsC,KAAK,MAAM;AACtD,MAAI,gBAAiB;AACrB,UAAQ;AAAA,IACN,uGAA6F,MAAM;AAAA,EACrG;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { StructureKind, VariableDeclarationKind } from "ts-morph";
3
+ import { VariableDeclarationKind } from "ts-morph";
4
4
  import {
5
5
  findDuplicateEntityClassNames,
6
6
  formatDuplicateEntityClassNamesWarning
@@ -14,7 +14,7 @@ import {
14
14
  } from "../utils.js";
15
15
  import {
16
16
  addAutoGeneratedComment,
17
- addImportSpec,
17
+ addImportSpecs,
18
18
  asExpression,
19
19
  arrayLiteral,
20
20
  arrowFunction,
@@ -89,13 +89,10 @@ async function generateModuleEntities(options) {
89
89
  }
90
90
  const sourceFile = createGeneratedSourceFile("entities.generated.ts");
91
91
  addAutoGeneratedComment(sourceFile, "entities");
92
- imports.forEach((entry) => {
93
- addImportSpec(sourceFile, {
94
- kind: StructureKind.ImportDeclaration,
95
- namespaceImport: entry.name,
96
- moduleSpecifier: entry.moduleSpecifier
97
- });
98
- });
92
+ addImportSpecs(sourceFile, imports.map((entry) => ({
93
+ namespaceImport: entry.name,
94
+ moduleSpecifier: entry.moduleSpecifier
95
+ })));
99
96
  sourceFile.addFunction({
100
97
  name: "enhanceEntities",
101
98
  parameters: [
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/generators/module-entities.ts"],
4
- "sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport { StructureKind, VariableDeclarationKind } from 'ts-morph'\nimport {\n findDuplicateEntityClassNames,\n formatDuplicateEntityClassNamesWarning,\n type EntityClassNameEntry,\n} from '@open-mercato/shared/lib/db/duplicateEntityClassNames'\nimport type { ModuleEntry, PackageResolver } from '../resolver'\nimport { parseEntityClassNames } from './entity-class-declarations'\nimport { MODULE_CODE_EXTENSIONS, stripModuleCodeExtension } from './scanner'\nimport {\n toVar,\n type GeneratorResult,\n createGeneratorResult,\n writeGeneratedFile,\n} from '../utils'\nimport {\n addAutoGeneratedComment,\n addImportSpec,\n asExpression,\n arrayLiteral,\n arrowFunction,\n binaryExpression,\n callExpression,\n createGeneratedSourceFile,\n expressionStatement,\n getSourceText,\n identifier,\n ifStatement,\n logicalAnd,\n methodCall,\n objectEntries,\n objectLiteral,\n prefixExpression,\n propertyAccess,\n returnStatement,\n spreadExpression,\n templateLiteral,\n variableStatement,\n} from './ast'\n\nexport interface ModuleEntitiesOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\nexport async function generateModuleEntities(options: ModuleEntitiesOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'entities.generated.ts')\n const checksumFile = path.join(outputDir, 'entities.generated.checksum')\n\n const mods = resolver.loadEnabledModules()\n const imports: Array<{ name: string; moduleSpecifier: string }> = []\n const entitySources: Array<{ importName: string; moduleId: string }> = []\n const classNameEntries: EntityClassNameEntry[] = []\n let n = 0\n\n for (const entry of mods) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imp = resolver.getModuleImportBase(entry)\n const isAppModule = entry.from === '@app'\n\n // prefer app override data/, fallback to core data/, then legacy db/\n const appData = path.join(roots.appBase, 'data')\n const pkgData = path.join(roots.pkgBase, 'data')\n const appDb = path.join(roots.appBase, 'db')\n const pkgDb = path.join(roots.pkgBase, 'db')\n const bases = [appData, pkgData, appDb, pkgDb]\n const candidates = ['entities.override', 'entities', 'schema']\n\n let found: { base: string; file: string } | null = null\n for (const base of bases) {\n for (const f of candidates) {\n const p = resolveConventionFile(base, f)\n if (p) {\n found = { base, file: path.basename(p) }\n break\n }\n }\n if (found) break\n }\n if (!found) continue\n\n const importName = `E_${toVar(modId)}_${n++}`\n const sub = path.basename(found.base) // 'data' or 'db'\n const fromApp = found.base.startsWith(roots.appBase)\n // For @app modules, use relative path to ensure it works both in Next.js and Node.js CLI context\n // From .mercato/generated/, the relative path to src/modules/ is ../src/modules/\n let relImport: string\n if (isAppModule && fromApp) {\n // From .mercato/generated/, go up two levels (../..) to reach the app root, then into src/modules/\n relImport = `../../src/modules/${modId}/${sub}/${stripModuleCodeExtension(found.file)}`\n } else {\n const baseImport = fromApp ? imp.appBase : imp.pkgBase\n relImport = `${baseImport}/${sub}/${stripModuleCodeExtension(found.file)}`\n }\n imports.push({ name: importName, moduleSpecifier: relImport })\n entitySources.push({ importName, moduleId: modId })\n\n const entityFilePath = resolveEntitySourceFile(resolver, entry, found, fromApp)\n for (const className of parseEntityClassNames(entityFilePath)) {\n classNameEntries.push({ className, moduleId: modId, sourcePath: entityFilePath })\n }\n }\n\n const sourceFile = createGeneratedSourceFile('entities.generated.ts')\n addAutoGeneratedComment(sourceFile, 'entities')\n imports.forEach((entry) => {\n addImportSpec(sourceFile, {\n kind: StructureKind.ImportDeclaration,\n namespaceImport: entry.name,\n moduleSpecifier: entry.moduleSpecifier,\n })\n })\n sourceFile.addFunction({\n name: 'enhanceEntities',\n parameters: [\n { name: 'namespace', type: 'Record<string, unknown>' },\n { name: 'moduleId', type: 'string' },\n ],\n returnType: 'any[]',\n statements: [\n returnStatement(\n methodCall(\n methodCall(objectEntries(identifier('namespace')), 'filter', [\n arrowFunction({\n parameters: ['[, value]'],\n body: binaryExpression(\n prefixExpression('typeof ', identifier('value')),\n '===',\n 'function',\n ),\n }),\n ]),\n 'map',\n [\n arrowFunction({\n parameters: ['[exportName, value]'],\n body: (writer) => {\n writer.block(() => {\n variableStatement({\n name: 'entity',\n initializer: asExpression(identifier('value'), '{ entityName?: string }'),\n })(writer)\n writer.newLine()\n ifStatement({\n condition: logicalAnd([\n identifier('entity'),\n binaryExpression(\n prefixExpression('typeof ', identifier('entity')),\n '===',\n 'function',\n ),\n binaryExpression(\n methodCall(\n propertyAccess(\n propertyAccess(identifier('Object'), 'prototype'),\n 'hasOwnProperty',\n ),\n 'call',\n [identifier('entity'), 'entityName'],\n ),\n '===',\n false,\n ),\n ]),\n thenStatements: [\n expressionStatement(\n callExpression(propertyAccess(identifier('Object'), 'defineProperty'), [\n identifier('entity'),\n 'entityName',\n objectLiteral([\n {\n name: 'value',\n value: templateLiteral([\n identifier('moduleId'),\n '.',\n identifier('exportName'),\n ]),\n },\n { name: 'configurable', value: true },\n { name: 'enumerable', value: false },\n { name: 'writable', value: false },\n ]),\n ]),\n ),\n ],\n })(writer)\n writer.newLine()\n returnStatement(identifier('entity'))(writer)\n })\n },\n }),\n ],\n ),\n ),\n ],\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: 'entities',\n initializer: arrayLiteral(entitySources, (writer, entry) =>\n spreadExpression(callExpression(identifier('enhanceEntities'), [identifier(entry.importName), entry.moduleId]))(writer)),\n },\n ],\n })\n const output = getSourceText(sourceFile)\n\n writeGeneratedFile({\n outFile,\n checksumFile,\n content: output,\n structureChecksum: '',\n result,\n quiet,\n })\n\n warnOnDuplicateEntityClassNames(classNameEntries)\n\n return result\n}\n\n/**\n * A duplicate entity class name across modules silently corrupts entity resolution at\n * runtime and no build step otherwise catches it, so surface it here \u2014 where the\n * colliding registry is produced. Reported as a warning; generation still succeeds.\n */\nfunction warnOnDuplicateEntityClassNames(entries: readonly EntityClassNameEntry[]): void {\n try {\n const duplicates = findDuplicateEntityClassNames(entries)\n if (duplicates.length === 0) return\n console.warn(`\\x1b[33m[Entities Warning]\\x1b[0m ${formatDuplicateEntityClassNamesWarning(duplicates)}`)\n } catch {\n // This check is a diagnostic. It must never be the reason generation fails.\n }\n}\n\n/**\n * The file to read class names out of, which is not always the file the runtime imports.\n * A standalone install resolves a package module to its compiled `dist/modules` tree, and\n * published packages ship `src/modules` alongside it \u2014 so prefer the shipped source, the\n * way `eject` already does, and leave the runtime import pointing at `dist`. A package\n * that ships compiled output only falls back to the resolved base, which the parser also\n * understands. An app override wins over the package tree entirely: the registry imports\n * the app file, so that is the file whose class names are registered.\n */\nfunction resolveEntitySourceFile(\n resolver: PackageResolver,\n entry: ModuleEntry,\n found: { base: string; file: string },\n fromApp: boolean,\n): string {\n const resolved = path.join(found.base, found.file)\n const from = entry.from\n if (fromApp || !from || from === '@app') return resolved\n const sourceBase = path.join(resolver.getPackageRoot(from), 'src', 'modules', entry.id, path.basename(found.base))\n if (path.resolve(sourceBase) === path.resolve(found.base)) return resolved\n const sourceFile = resolveConventionFile(sourceBase, stripModuleCodeExtension(found.file))\n return sourceFile ?? resolved\n}\n\nfunction resolveConventionFile(baseDir: string, basename: string): string | null {\n for (const extension of MODULE_CODE_EXTENSIONS) {\n const candidate = path.join(baseDir, `${basename}${extension}`)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n"],
5
- "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,eAAe,+BAA+B;AACvD;AAAA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,QAAM,OAAO,MAAM;AACnB,MAAI,WAAW,CAAC,QAAQ,SAAS,OAAQ,QAAO;AAChD,QAAM,aAAa,KAAK,KAAK,SAAS,eAAe,IAAI,GAAG,OAAO,WAAW,MAAM,IAAI,KAAK,SAAS,MAAM,IAAI,CAAC;AACjH,MAAI,KAAK,QAAQ,UAAU,MAAM,KAAK,QAAQ,MAAM,IAAI,EAAG,QAAO;AAClE,QAAM,aAAa,sBAAsB,YAAY,yBAAyB,MAAM,IAAI,CAAC;AACzF,SAAO,cAAc;AACvB;AAEA,SAAS,sBAAsB,SAAiB,UAAiC;AAC/E,aAAW,aAAa,wBAAwB;AAC9C,UAAM,YAAY,KAAK,KAAK,SAAS,GAAG,QAAQ,GAAG,SAAS,EAAE;AAC9D,QAAI,GAAG,WAAW,SAAS,EAAG,QAAO;AAAA,EACvC;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport { VariableDeclarationKind } from 'ts-morph'\nimport {\n findDuplicateEntityClassNames,\n formatDuplicateEntityClassNamesWarning,\n type EntityClassNameEntry,\n} from '@open-mercato/shared/lib/db/duplicateEntityClassNames'\nimport type { ModuleEntry, PackageResolver } from '../resolver'\nimport { parseEntityClassNames } from './entity-class-declarations'\nimport { MODULE_CODE_EXTENSIONS, stripModuleCodeExtension } from './scanner'\nimport {\n toVar,\n type GeneratorResult,\n createGeneratorResult,\n writeGeneratedFile,\n} from '../utils'\nimport {\n addAutoGeneratedComment,\n addImportSpecs,\n asExpression,\n arrayLiteral,\n arrowFunction,\n binaryExpression,\n callExpression,\n createGeneratedSourceFile,\n expressionStatement,\n getSourceText,\n identifier,\n ifStatement,\n logicalAnd,\n methodCall,\n objectEntries,\n objectLiteral,\n prefixExpression,\n propertyAccess,\n returnStatement,\n spreadExpression,\n templateLiteral,\n variableStatement,\n} from './ast'\n\nexport interface ModuleEntitiesOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\nexport async function generateModuleEntities(options: ModuleEntitiesOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'entities.generated.ts')\n const checksumFile = path.join(outputDir, 'entities.generated.checksum')\n\n const mods = resolver.loadEnabledModules()\n const imports: Array<{ name: string; moduleSpecifier: string }> = []\n const entitySources: Array<{ importName: string; moduleId: string }> = []\n const classNameEntries: EntityClassNameEntry[] = []\n let n = 0\n\n for (const entry of mods) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imp = resolver.getModuleImportBase(entry)\n const isAppModule = entry.from === '@app'\n\n // prefer app override data/, fallback to core data/, then legacy db/\n const appData = path.join(roots.appBase, 'data')\n const pkgData = path.join(roots.pkgBase, 'data')\n const appDb = path.join(roots.appBase, 'db')\n const pkgDb = path.join(roots.pkgBase, 'db')\n const bases = [appData, pkgData, appDb, pkgDb]\n const candidates = ['entities.override', 'entities', 'schema']\n\n let found: { base: string; file: string } | null = null\n for (const base of bases) {\n for (const f of candidates) {\n const p = resolveConventionFile(base, f)\n if (p) {\n found = { base, file: path.basename(p) }\n break\n }\n }\n if (found) break\n }\n if (!found) continue\n\n const importName = `E_${toVar(modId)}_${n++}`\n const sub = path.basename(found.base) // 'data' or 'db'\n const fromApp = found.base.startsWith(roots.appBase)\n // For @app modules, use relative path to ensure it works both in Next.js and Node.js CLI context\n // From .mercato/generated/, the relative path to src/modules/ is ../src/modules/\n let relImport: string\n if (isAppModule && fromApp) {\n // From .mercato/generated/, go up two levels (../..) to reach the app root, then into src/modules/\n relImport = `../../src/modules/${modId}/${sub}/${stripModuleCodeExtension(found.file)}`\n } else {\n const baseImport = fromApp ? imp.appBase : imp.pkgBase\n relImport = `${baseImport}/${sub}/${stripModuleCodeExtension(found.file)}`\n }\n imports.push({ name: importName, moduleSpecifier: relImport })\n entitySources.push({ importName, moduleId: modId })\n\n const entityFilePath = resolveEntitySourceFile(resolver, entry, found, fromApp)\n for (const className of parseEntityClassNames(entityFilePath)) {\n classNameEntries.push({ className, moduleId: modId, sourcePath: entityFilePath })\n }\n }\n\n const sourceFile = createGeneratedSourceFile('entities.generated.ts')\n addAutoGeneratedComment(sourceFile, 'entities')\n addImportSpecs(sourceFile, imports.map((entry) => ({\n namespaceImport: entry.name,\n moduleSpecifier: entry.moduleSpecifier,\n })))\n sourceFile.addFunction({\n name: 'enhanceEntities',\n parameters: [\n { name: 'namespace', type: 'Record<string, unknown>' },\n { name: 'moduleId', type: 'string' },\n ],\n returnType: 'any[]',\n statements: [\n returnStatement(\n methodCall(\n methodCall(objectEntries(identifier('namespace')), 'filter', [\n arrowFunction({\n parameters: ['[, value]'],\n body: binaryExpression(\n prefixExpression('typeof ', identifier('value')),\n '===',\n 'function',\n ),\n }),\n ]),\n 'map',\n [\n arrowFunction({\n parameters: ['[exportName, value]'],\n body: (writer) => {\n writer.block(() => {\n variableStatement({\n name: 'entity',\n initializer: asExpression(identifier('value'), '{ entityName?: string }'),\n })(writer)\n writer.newLine()\n ifStatement({\n condition: logicalAnd([\n identifier('entity'),\n binaryExpression(\n prefixExpression('typeof ', identifier('entity')),\n '===',\n 'function',\n ),\n binaryExpression(\n methodCall(\n propertyAccess(\n propertyAccess(identifier('Object'), 'prototype'),\n 'hasOwnProperty',\n ),\n 'call',\n [identifier('entity'), 'entityName'],\n ),\n '===',\n false,\n ),\n ]),\n thenStatements: [\n expressionStatement(\n callExpression(propertyAccess(identifier('Object'), 'defineProperty'), [\n identifier('entity'),\n 'entityName',\n objectLiteral([\n {\n name: 'value',\n value: templateLiteral([\n identifier('moduleId'),\n '.',\n identifier('exportName'),\n ]),\n },\n { name: 'configurable', value: true },\n { name: 'enumerable', value: false },\n { name: 'writable', value: false },\n ]),\n ]),\n ),\n ],\n })(writer)\n writer.newLine()\n returnStatement(identifier('entity'))(writer)\n })\n },\n }),\n ],\n ),\n ),\n ],\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: 'entities',\n initializer: arrayLiteral(entitySources, (writer, entry) =>\n spreadExpression(callExpression(identifier('enhanceEntities'), [identifier(entry.importName), entry.moduleId]))(writer)),\n },\n ],\n })\n const output = getSourceText(sourceFile)\n\n writeGeneratedFile({\n outFile,\n checksumFile,\n content: output,\n structureChecksum: '',\n result,\n quiet,\n })\n\n warnOnDuplicateEntityClassNames(classNameEntries)\n\n return result\n}\n\n/**\n * A duplicate entity class name across modules silently corrupts entity resolution at\n * runtime and no build step otherwise catches it, so surface it here \u2014 where the\n * colliding registry is produced. Reported as a warning; generation still succeeds.\n */\nfunction warnOnDuplicateEntityClassNames(entries: readonly EntityClassNameEntry[]): void {\n try {\n const duplicates = findDuplicateEntityClassNames(entries)\n if (duplicates.length === 0) return\n console.warn(`\\x1b[33m[Entities Warning]\\x1b[0m ${formatDuplicateEntityClassNamesWarning(duplicates)}`)\n } catch {\n // This check is a diagnostic. It must never be the reason generation fails.\n }\n}\n\n/**\n * The file to read class names out of, which is not always the file the runtime imports.\n * A standalone install resolves a package module to its compiled `dist/modules` tree, and\n * published packages ship `src/modules` alongside it \u2014 so prefer the shipped source, the\n * way `eject` already does, and leave the runtime import pointing at `dist`. A package\n * that ships compiled output only falls back to the resolved base, which the parser also\n * understands. An app override wins over the package tree entirely: the registry imports\n * the app file, so that is the file whose class names are registered.\n */\nfunction resolveEntitySourceFile(\n resolver: PackageResolver,\n entry: ModuleEntry,\n found: { base: string; file: string },\n fromApp: boolean,\n): string {\n const resolved = path.join(found.base, found.file)\n const from = entry.from\n if (fromApp || !from || from === '@app') return resolved\n const sourceBase = path.join(resolver.getPackageRoot(from), 'src', 'modules', entry.id, path.basename(found.base))\n if (path.resolve(sourceBase) === path.resolve(found.base)) return resolved\n const sourceFile = resolveConventionFile(sourceBase, stripModuleCodeExtension(found.file))\n return sourceFile ?? resolved\n}\n\nfunction resolveConventionFile(baseDir: string, basename: string): string | null {\n for (const extension of MODULE_CODE_EXTENSIONS) {\n const candidate = path.join(baseDir, `${basename}${extension}`)\n if (fs.existsSync(candidate)) return candidate\n }\n return null\n}\n"],
5
+ "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,+BAA+B;AACxC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,6BAA6B;AACtC,SAAS,wBAAwB,gCAAgC;AACjE;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP,eAAsB,uBAAuB,SAA0D;AACrG,QAAM,EAAE,UAAU,QAAQ,MAAM,IAAI;AACpC,QAAM,SAAS,sBAAsB;AAErC,QAAM,YAAY,SAAS,aAAa;AACxC,QAAM,UAAU,KAAK,KAAK,WAAW,uBAAuB;AAC5D,QAAM,eAAe,KAAK,KAAK,WAAW,6BAA6B;AAEvE,QAAM,OAAO,SAAS,mBAAmB;AACzC,QAAM,UAA4D,CAAC;AACnE,QAAM,gBAAiE,CAAC;AACxE,QAAM,mBAA2C,CAAC;AAClD,MAAI,IAAI;AAER,aAAW,SAAS,MAAM;AACxB,UAAM,QAAQ,MAAM;AACpB,UAAM,QAAQ,SAAS,eAAe,KAAK;AAC3C,UAAM,MAAM,SAAS,oBAAoB,KAAK;AAC9C,UAAM,cAAc,MAAM,SAAS;AAGnC,UAAM,UAAU,KAAK,KAAK,MAAM,SAAS,MAAM;AAC/C,UAAM,UAAU,KAAK,KAAK,MAAM,SAAS,MAAM;AAC/C,UAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,IAAI;AAC3C,UAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,IAAI;AA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ACF;AAWA,SAAS,wBACP,UACA,OACA,OACA,SACQ;AACR,QAAM,WAAW,KAAK,KAAK,MAAM,MAAM,MAAM,IAAI;AACjD,QAAM,OAAO,MAAM;AACnB,MAAI,WAAW,CAAC,QAAQ,SAAS,OAAQ,QAAO;AAChD,QAAM,aAAa,KAAK,KAAK,SAAS,eAAe,IAAI,GAAG,OAAO,WAAW,MAAM,IAAI,KAAK,SAAS,MAAM,IAAI,CAAC;AACjH,MAAI,KAAK,QAAQ,UAAU,MAAM,KAAK,QAAQ,MAAM,IAAI,EAAG,QAAO;AAClE,QAAM,aAAa,sBAAsB,YAAY,yBAAyB,MAAM,IAAI,CAAC;AACzF,SAAO,cAAc;AACvB;AAEA,SAAS,sBAAsB,SAAiB,UAAiC;AAC/E,aAAW,aAAa,wBAAwB;AAC9C,UAAM,YAAY,KAAK,KAAK,SAAS,GAAG,QAAQ,GAAG,SAAS,EAAE;AAC9D,QAAI,GAAG,WAAW,SAAS,EAAG,QAAO;AAAA,EACvC;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/cli",
3
- "version": "0.10.1-develop.7809.1.ea24461aeb",
3
+ "version": "0.10.1-develop.7811.1.66050c1838",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -60,10 +60,10 @@
60
60
  "@mikro-orm/decorators": "^7.1.14",
61
61
  "@mikro-orm/migrations": "^7.1.14",
62
62
  "@mikro-orm/postgresql": "^7.1.14",
63
- "@open-mercato/events": "0.10.1-develop.7809.1.ea24461aeb",
64
- "@open-mercato/queue": "0.10.1-develop.7809.1.ea24461aeb",
65
- "@open-mercato/shared": "0.10.1-develop.7809.1.ea24461aeb",
66
- "@open-mercato/telemetry": "0.10.1-develop.7809.1.ea24461aeb",
63
+ "@open-mercato/events": "0.10.1-develop.7811.1.66050c1838",
64
+ "@open-mercato/queue": "0.10.1-develop.7811.1.66050c1838",
65
+ "@open-mercato/shared": "0.10.1-develop.7811.1.66050c1838",
66
+ "@open-mercato/telemetry": "0.10.1-develop.7811.1.66050c1838",
67
67
  "cross-spawn": "^7.0.6",
68
68
  "minisearch": "7.2.0",
69
69
  "pg": "8.23.0",
@@ -75,10 +75,10 @@
75
75
  "typescript-js": "npm:typescript@6.0.3"
76
76
  },
77
77
  "peerDependencies": {
78
- "@open-mercato/shared": "0.10.1-develop.7809.1.ea24461aeb"
78
+ "@open-mercato/shared": "0.10.1-develop.7811.1.66050c1838"
79
79
  },
80
80
  "devDependencies": {
81
- "@open-mercato/shared": "0.10.1-develop.7809.1.ea24461aeb",
81
+ "@open-mercato/shared": "0.10.1-develop.7811.1.66050c1838",
82
82
  "@types/jest": "^30.0.0",
83
83
  "jest": "^30.4.2",
84
84
  "ts-jest": "^29.4.12"