@open-mercato/cli 0.11.1-develop.8784.1.e9d95a72f5 → 0.11.1-develop.8843.1.b02f9b125d

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 (210) hide show
  1. package/.turbo/turbo-build.log +8 -2
  2. package/AGENTS.md +2 -0
  3. package/dist/agentic/guides/architecture.md +1 -0
  4. package/dist/agentic/guides/module-facts.json +2453 -1146
  5. package/dist/agentic/guides/module-facts.v2.json +2453 -1146
  6. package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
  7. package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
  8. package/dist/agentic/guides/modules/ai_assistant/owned-contract-module-metadata.md +1 -1
  9. package/dist/agentic/guides/modules/api_docs/index.md +1 -1
  10. package/dist/agentic/guides/modules/api_keys/index.md +1 -1
  11. package/dist/agentic/guides/modules/assisted_selling/index.md +1 -1
  12. package/dist/agentic/guides/modules/attachments/index.md +1 -1
  13. package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
  14. package/dist/agentic/guides/modules/auth/index.md +1 -1
  15. package/dist/agentic/guides/modules/auth/owned-contract-module-metadata.md +1 -1
  16. package/dist/agentic/guides/modules/availability/index.md +1 -1
  17. package/dist/agentic/guides/modules/backups/index.md +1 -1
  18. package/dist/agentic/guides/modules/business_rules/index.md +1 -1
  19. package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
  20. package/dist/agentic/guides/modules/cart/index.md +1 -1
  21. package/dist/agentic/guides/modules/cart/owned-contract-module-metadata.md +1 -1
  22. package/dist/agentic/guides/modules/catalog/di-registrations-rich.md +11 -8
  23. package/dist/agentic/guides/modules/catalog/di-service-tokens.md +5 -5
  24. package/dist/agentic/guides/modules/catalog/exact-override-targets.md +11 -8
  25. package/dist/agentic/guides/modules/catalog/index.md +2 -2
  26. package/dist/agentic/guides/modules/catalog/owned-contract-module-metadata.md +1 -1
  27. package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
  28. package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
  29. package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
  30. package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
  31. package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
  32. package/dist/agentic/guides/modules/channel_gmail/owned-contract-module-metadata.md +1 -1
  33. package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
  34. package/dist/agentic/guides/modules/channel_imap/owned-contract-module-metadata.md +1 -1
  35. package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
  36. package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
  37. package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
  38. package/dist/agentic/guides/modules/checkout/index.md +1 -1
  39. package/dist/agentic/guides/modules/communication_channels/exact-override-targets.md +2 -2
  40. package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
  41. package/dist/agentic/guides/modules/communication_channels/owned-contract-module-metadata.md +1 -1
  42. package/dist/agentic/guides/modules/communication_channels/workers.md +2 -2
  43. package/dist/agentic/guides/modules/configs/acl-features.md +2 -1
  44. package/dist/agentic/guides/modules/configs/backend-pages.md +1 -0
  45. package/dist/agentic/guides/modules/configs/entities.md +0 -1
  46. package/dist/agentic/guides/modules/configs/exact-override-targets.md +2 -0
  47. package/dist/agentic/guides/modules/configs/host-extension-points.md +10 -0
  48. package/dist/agentic/guides/modules/configs/index.md +5 -3
  49. package/dist/agentic/guides/modules/configs/owned-contract-module-metadata.md +1 -1
  50. package/dist/agentic/guides/modules/configs/setup.md +1 -1
  51. package/dist/agentic/guides/modules/configs/umes-diagnostics.md +9 -0
  52. package/dist/agentic/guides/modules/configs/umes-hosts.md +9 -1
  53. package/dist/agentic/guides/modules/content/index.md +1 -1
  54. package/dist/agentic/guides/modules/currencies/index.md +1 -1
  55. package/dist/agentic/guides/modules/customer_accounts/active-extension-bindings.md +1 -1
  56. package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
  57. package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
  58. package/dist/agentic/guides/modules/customers/acl-features.md +2 -1
  59. package/dist/agentic/guides/modules/customers/active-extension-bindings.md +2 -0
  60. package/dist/agentic/guides/modules/customers/contribution-resolutions.md +2 -0
  61. package/dist/agentic/guides/modules/customers/di-registrations-rich.md +8 -5
  62. package/dist/agentic/guides/modules/customers/domain-commands.md +1 -1
  63. package/dist/agentic/guides/modules/customers/exact-override-targets.md +11 -5
  64. package/dist/agentic/guides/modules/customers/index.md +5 -5
  65. package/dist/agentic/guides/modules/customers/owned-contract-module-metadata.md +1 -1
  66. package/dist/agentic/guides/modules/customers/umes-contributions.md +2 -0
  67. package/dist/agentic/guides/modules/dashboards/active-extension-bindings.md +0 -10
  68. package/dist/agentic/guides/modules/dashboards/contribution-resolutions.md +0 -10
  69. package/dist/agentic/guides/modules/dashboards/exact-override-targets.md +0 -10
  70. package/dist/agentic/guides/modules/dashboards/index.md +5 -5
  71. package/dist/agentic/guides/modules/dashboards/umes-contributions.md +0 -10
  72. package/dist/agentic/guides/modules/data_sync/index.md +1 -1
  73. package/dist/agentic/guides/modules/design_system/index.md +1 -1
  74. package/dist/agentic/guides/modules/devices/index.md +1 -1
  75. package/dist/agentic/guides/modules/devices/owned-contract-module-metadata.md +1 -1
  76. package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
  77. package/dist/agentic/guides/modules/directory/index.md +1 -1
  78. package/dist/agentic/guides/modules/documents/index.md +1 -1
  79. package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
  80. package/dist/agentic/guides/modules/ecommerce/owned-contract-module-metadata.md +1 -1
  81. package/dist/agentic/guides/modules/entities/index.md +1 -1
  82. package/dist/agentic/guides/modules/entities/owned-contract-module-metadata.md +1 -1
  83. package/dist/agentic/guides/modules/eudr/index.md +1 -1
  84. package/dist/agentic/guides/modules/events/index.md +1 -1
  85. package/dist/agentic/guides/modules/events/owned-contract-module-metadata.md +1 -1
  86. package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
  87. package/dist/agentic/guides/modules/forms/index.md +1 -1
  88. package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
  89. package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
  90. package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
  91. package/dist/agentic/guides/modules/generators/index.md +1 -1
  92. package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
  93. package/dist/agentic/guides/modules/integrations/index.md +1 -1
  94. package/dist/agentic/guides/modules/integrations/owned-contract-module-metadata.md +1 -1
  95. package/dist/agentic/guides/modules/ledger/index.md +1 -1
  96. package/dist/agentic/guides/modules/maintenance/contribution-resolutions.md +11 -0
  97. package/dist/agentic/guides/modules/maintenance/events.md +14 -0
  98. package/dist/agentic/guides/modules/maintenance/exact-override-targets.md +11 -0
  99. package/dist/agentic/guides/modules/maintenance/index.md +17 -0
  100. package/dist/agentic/guides/modules/maintenance/owned-contract-module-metadata.md +11 -0
  101. package/dist/agentic/guides/modules/maintenance/umes-contributions.md +11 -0
  102. package/dist/agentic/guides/modules/maintenance/umes-hosts.md +14 -0
  103. package/dist/agentic/guides/modules/messages/index.md +1 -1
  104. package/dist/agentic/guides/modules/notifications/index.md +1 -1
  105. package/dist/agentic/guides/modules/onboarding/index.md +1 -1
  106. package/dist/agentic/guides/modules/payment_gateways/exact-override-targets.md +3 -3
  107. package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
  108. package/dist/agentic/guides/modules/payment_gateways/setup.md +1 -1
  109. package/dist/agentic/guides/modules/perspectives/index.md +1 -1
  110. package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
  111. package/dist/agentic/guides/modules/phone_calls/owned-contract-module-metadata.md +1 -1
  112. package/dist/agentic/guides/modules/planner/index.md +1 -1
  113. package/dist/agentic/guides/modules/portal/index.md +1 -1
  114. package/dist/agentic/guides/modules/progress/index.md +1 -1
  115. package/dist/agentic/guides/modules/promotions/index.md +1 -1
  116. package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
  117. package/dist/agentic/guides/modules/query_index/index.md +1 -1
  118. package/dist/agentic/guides/modules/record_locks/index.md +1 -1
  119. package/dist/agentic/guides/modules/resources/index.md +1 -1
  120. package/dist/agentic/guides/modules/sales/active-extension-bindings.md +8 -0
  121. package/dist/agentic/guides/modules/sales/contribution-resolutions.md +8 -0
  122. package/dist/agentic/guides/modules/sales/di-registrations-rich.md +31 -30
  123. package/dist/agentic/guides/modules/sales/di-service-tokens.md +5 -5
  124. package/dist/agentic/guides/modules/sales/exact-override-targets.md +39 -30
  125. package/dist/agentic/guides/modules/sales/index.md +5 -5
  126. package/dist/agentic/guides/modules/sales/owned-contract-module-metadata.md +1 -1
  127. package/dist/agentic/guides/modules/sales/umes-contributions.md +8 -0
  128. package/dist/agentic/guides/modules/scheduler/index.md +1 -1
  129. package/dist/agentic/guides/modules/search/index.md +1 -1
  130. package/dist/agentic/guides/modules/search/owned-contract-module-metadata.md +1 -1
  131. package/dist/agentic/guides/modules/security/index.md +1 -1
  132. package/dist/agentic/guides/modules/seeds/index.md +1 -1
  133. package/dist/agentic/guides/modules/shipping_carriers/active-extension-bindings.md +1 -1
  134. package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
  135. package/dist/agentic/guides/modules/sso/index.md +1 -1
  136. package/dist/agentic/guides/modules/staff/active-extension-bindings.md +2 -1
  137. package/dist/agentic/guides/modules/staff/contribution-resolutions.md +1 -0
  138. package/dist/agentic/guides/modules/staff/exact-override-targets.md +1 -0
  139. package/dist/agentic/guides/modules/staff/index.md +8 -8
  140. package/dist/agentic/guides/modules/staff/umes-contributions.md +1 -0
  141. package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
  142. package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
  143. package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
  144. package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
  145. package/dist/agentic/guides/modules/telemetry/index.md +1 -1
  146. package/dist/agentic/guides/modules/tillio/index.md +1 -1
  147. package/dist/agentic/guides/modules/translations/index.md +1 -1
  148. package/dist/agentic/guides/modules/upgrade_actions/cli-commands.md +11 -0
  149. package/dist/agentic/guides/modules/upgrade_actions/contribution-resolutions.md +12 -0
  150. package/dist/agentic/guides/modules/upgrade_actions/entities.md +11 -0
  151. package/dist/agentic/guides/modules/upgrade_actions/exact-override-targets.md +12 -0
  152. package/dist/agentic/guides/modules/upgrade_actions/index.md +18 -0
  153. package/dist/agentic/guides/modules/upgrade_actions/owned-contract-module-metadata.md +11 -0
  154. package/dist/agentic/guides/modules/upgrade_actions/umes-contributions.md +12 -0
  155. package/dist/agentic/guides/modules/upgrade_actions/umes-hosts.md +11 -0
  156. package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
  157. package/dist/agentic/guides/modules/webhooks/index.md +1 -1
  158. package/dist/agentic/guides/modules/wms/index.md +1 -1
  159. package/dist/agentic/guides/modules/workflows/domain-commands.md +3 -0
  160. package/dist/agentic/guides/modules/workflows/index.md +1 -1
  161. package/dist/agentic/guides/production-deployment.md +6 -0
  162. package/dist/agentic/guides/reference-module-facts.json +1 -1
  163. package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +17 -9
  164. package/dist/agentic/guides/upstream/manifest.json +2 -2
  165. package/dist/agentic/shared/AGENTS.md.template +1 -1
  166. package/dist/agentic/shared/ai/harness/cases.json +7 -7
  167. package/dist/lib/generators/extensions/dashboard-widgets.js +46 -4
  168. package/dist/lib/generators/extensions/dashboard-widgets.js.map +2 -2
  169. package/dist/lib/generators/extensions/workflows.js +25 -2
  170. package/dist/lib/generators/extensions/workflows.js.map +2 -2
  171. package/dist/lib/generators/module-facts.js +2 -0
  172. package/dist/lib/generators/module-facts.js.map +2 -2
  173. package/dist/lib/generators/module-registry.js +35 -6
  174. package/dist/lib/generators/module-registry.js.map +2 -2
  175. package/dist/lib/module-coupling/analyze.js +391 -0
  176. package/dist/lib/module-coupling/analyze.js.map +7 -0
  177. package/dist/lib/module-diagnostics.js +160 -0
  178. package/dist/lib/module-diagnostics.js.map +7 -0
  179. package/dist/lib/module-index.js +103 -0
  180. package/dist/lib/module-index.js.map +7 -0
  181. package/dist/lib/testing/ephemeral-database-guard.js +89 -0
  182. package/dist/lib/testing/ephemeral-database-guard.js.map +7 -0
  183. package/dist/lib/testing/integration-discovery.js +20 -15
  184. package/dist/lib/testing/integration-discovery.js.map +3 -3
  185. package/dist/mercato.js +45 -5
  186. package/dist/mercato.js.map +2 -2
  187. package/package.json +7 -7
  188. package/src/__tests__/init-ephemeral-database.test.ts +112 -0
  189. package/src/__tests__/mercato.test.ts +15 -0
  190. package/src/__tests__/rotation-json-output.test.ts +13 -0
  191. package/src/lib/__tests__/module-diagnostics.test.ts +207 -0
  192. package/src/lib/__tests__/modules-config.test.ts +1 -0
  193. package/src/lib/generators/__tests__/module-facts.customers.fixture.test.ts +2 -1
  194. package/src/lib/generators/__tests__/module-facts.owned-contracts.test.ts +2 -2
  195. package/src/lib/generators/__tests__/module-registry-requires-enforcement.test.ts +18 -0
  196. package/src/lib/generators/__tests__/output-snapshots.test.ts +19 -0
  197. package/src/lib/generators/__tests__/registry-variant-parity.test.ts +95 -19
  198. package/src/lib/generators/__tests__/structural-contracts.test.ts +18 -0
  199. package/src/lib/generators/extensions/dashboard-widgets.ts +49 -3
  200. package/src/lib/generators/extensions/workflows.ts +26 -2
  201. package/src/lib/generators/module-facts.ts +2 -0
  202. package/src/lib/generators/module-registry.ts +55 -7
  203. package/src/lib/module-coupling/analyze.ts +464 -0
  204. package/src/lib/module-diagnostics.ts +182 -0
  205. package/src/lib/module-index.ts +133 -0
  206. package/src/lib/testing/__tests__/ephemeral-database-guard.test.ts +88 -0
  207. package/src/lib/testing/__tests__/integration-discovery.test.ts +26 -2
  208. package/src/lib/testing/ephemeral-database-guard.ts +105 -0
  209. package/src/lib/testing/integration-discovery.ts +19 -11
  210. package/src/mercato.ts +47 -5
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/module-diagnostics.ts"],
4
+ "sourcesContent": ["import path from 'node:path'\nimport { getModuleRequirementHint } from '@open-mercato/shared/modules/module-locators'\nimport { analyzeModuleCoupling, optionalCapabilityLabel, PLATFORM_KERNEL } from './module-coupling/analyze'\nimport { buildModuleIndex, inactiveModuleDependencies, missingModuleRequirements, resolveIndexedModule, type IndexedModule } from './module-index'\nimport { createResolver, type PackageResolver } from './resolver'\n\nconst GROUPS = [\n 'missing-kernel',\n 'missing-hard',\n 'inactive-optional',\n 'undeclared-or-upstream',\n 'missing-contributions',\n 'dangling',\n] as const\n\ntype Group = typeof GROUPS[number]\ntype Finding = {\n group: Group\n module: string\n target?: string\n kind?: string\n file?: string\n line?: number\n message: string\n}\n\nfunction cleanFileName(root: string, file: string): string {\n return path.relative(root, file).split(path.sep).join('/')\n}\n\nfunction printHelp(command: 'list' | 'doctor'): void {\n if (command === 'list') console.log('Usage: yarn mercato module list [--all] [--json]')\n else console.log('Usage: yarn mercato module doctor [--strict] [--json]')\n}\n\nfunction listModules(modules: IndexedModule[], json: boolean, all: boolean): void {\n const enabled = modules.filter((module) => module.enabled)\n const rows = modules.filter((module) => all || module.enabled).map((module) => ({\n id: module.id,\n package: module.packageName,\n version: module.version,\n enabled: module.enabled,\n requires: module.requires,\n optionalRequires: module.optionalRequires,\n requiredBy: enabled.filter((other) => other.requires.some((requirement) => resolveIndexedModule(requirement, modules) === module))\n .map((other) => other.id),\n ...(module.notAnalyzed ? { notAnalyzed: module.notAnalyzed } : {}),\n }))\n if (json) {\n console.log(JSON.stringify({ version: 1, modules: rows }, null, 2))\n return\n }\n for (const row of rows) {\n const status = row.enabled ? 'enabled' : 'installed'\n const version = row.version ? `@${row.version}` : ''\n console.log(`${row.id} ${row.package}${version} (${status})`)\n if (row.requires.length) console.log(` Requires: ${row.requires.join(', ')}`)\n if (row.optionalRequires.length) console.log(` Optional: ${row.optionalRequires.join(', ')}`)\n if (row.requiredBy.length) console.log(` Required by: ${row.requiredBy.join(', ')}`)\n if (row.notAnalyzed) console.log(` Not analyzed: ${row.notAnalyzed}`)\n }\n}\n\nfunction instructionFor(target: string, modules: IndexedModule[]): string {\n const installed = resolveIndexedModule(target, modules)\n if (installed?.packageName === '@app') return `Enable '${installed.id}' in src/modules.ts.`\n if (installed) return `yarn mercato module enable ${installed.packageName} --module ${installed.id}`\n return getModuleRequirementHint(target)\n}\n\nfunction doctorFindings(modules: IndexedModule[], root: string): Finding[] {\n const enabled = modules.filter((module) => module.enabled)\n const enabledIds = new Set(enabled.map((module) => module.id))\n const findings: Finding[] = PLATFORM_KERNEL.filter((id) => !enabledIds.has(id)).map((module) => ({\n group: 'missing-kernel',\n module,\n message: `Enable kernel module '${module}' in src/modules.ts.`,\n }))\n for (const module of enabled) {\n for (const { requirement, path: chain } of missingModuleRequirements(module, modules)) {\n findings.push({\n group: 'missing-hard',\n module: module.id,\n target: requirement,\n message: `${chain.join(' \u2192 ')} is required. ${instructionFor(requirement, modules)}`,\n })\n }\n }\n for (const { source, target } of inactiveModuleDependencies(modules)) {\n const label = optionalCapabilityLabel(source, resolveIndexedModule(target, modules)?.id ?? target)\n findings.push({\n group: 'inactive-optional',\n module: source.id,\n target,\n message: `${label ?? `Optional module '${target}'`} is inactive. ${instructionFor(target, modules)}`,\n })\n }\n const coupling = analyzeModuleCoupling(modules)\n for (const finding of coupling.findings) {\n if (finding.rule === 'R4' || (enabledIds.has(finding.target) && finding.rule !== 'R2')) continue\n findings.push({\n group: 'undeclared-or-upstream',\n module: finding.module,\n target: finding.target,\n kind: finding.kind,\n file: cleanFileName(root, finding.file),\n line: finding.line,\n message: finding.message,\n })\n }\n for (const finding of coupling.contributions) {\n findings.push({\n group: 'missing-contributions',\n module: finding.module,\n target: finding.spotId,\n file: cleanFileName(root, finding.file),\n line: finding.line,\n message: `Host '${finding.spotId}' needs ${finding.minimum} enabled contributions, found ${finding.count}.`,\n })\n }\n for (const reference of coupling.dangling) {\n findings.push({\n group: 'dangling',\n module: reference.module,\n target: reference.value,\n kind: reference.kind,\n file: cleanFileName(root, reference.file),\n line: reference.line,\n message: `No installed module owns '${reference.value}'.`,\n })\n }\n const seen = new Set<string>()\n return findings.filter((finding) => {\n const key = JSON.stringify(finding)\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n}\n\nexport function runModuleDiagnostics(\n command: 'list' | 'doctor',\n args: string[],\n resolver: PackageResolver = createResolver(),\n): number {\n if (args.includes('--help') || args.includes('-h')) {\n printHelp(command)\n return 0\n }\n const commandFlag = command === 'list' ? '--all' : '--strict'\n const invalid = args.find((arg) => arg !== '--json' && arg !== commandFlag)\n if (invalid) {\n console.error(`Unknown module ${command} option '${invalid}'.`)\n return 1\n }\n const json = args.includes('--json')\n const modules = buildModuleIndex(resolver, command === 'doctor' || args.includes('--all'))\n if (command === 'list') {\n listModules(modules, json, args.includes('--all'))\n return 0\n }\n const enabled = modules.filter((module) => module.enabled).map((module) => module.id)\n const notAnalyzed = modules.filter((module) => module.enabled && module.notAnalyzed)\n .map((module) => ({ module: module.id, reason: module.notAnalyzed }))\n const findings = doctorFindings(modules, resolver.getAppDir())\n if (json) console.log(JSON.stringify({ version: 1, enabled, findings, ...(notAnalyzed.length ? { notAnalyzed } : {}) }, null, 2))\n else {\n for (const group of GROUPS) {\n const rows = findings.filter((finding) => finding.group === group)\n console.log(`${group} (${rows.length})`)\n for (const row of rows) {\n const location = row.file ? ` (${row.file}${row.line ? `:${row.line}` : ''})` : ''\n console.log(` ${row.module}: ${row.message}${location}`)\n }\n }\n for (const row of notAnalyzed) console.log(`Not analyzed: ${row.module} (${row.reason})`)\n }\n const strict = args.includes('--strict')\n return findings.some((finding) =>\n finding.group === 'missing-kernel' || finding.group === 'missing-hard'\n || (strict && finding.group !== 'inactive-optional')) ? 1 : 0\n}\n"],
5
+ "mappings": "AAAA,OAAO,UAAU;AACjB,SAAS,gCAAgC;AACzC,SAAS,uBAAuB,yBAAyB,uBAAuB;AAChF,SAAS,kBAAkB,4BAA4B,2BAA2B,4BAAgD;A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AAO,CAAC,YAAY,QAAQ,UAAU,KAAK;AACjE,cAAQ,IAAI,GAAG,KAAK,KAAK,KAAK,MAAM,GAAG;AACvC,iBAAW,OAAO,MAAM;AACtB,cAAM,WAAW,IAAI,OAAO,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,IAAI,IAAI,IAAI,KAAK,EAAE,MAAM;AAChF,gBAAQ,IAAI,KAAK,IAAI,MAAM,KAAK,IAAI,OAAO,GAAG,QAAQ,EAAE;AAAA,MAC1D;AAAA,IACF;AACA,eAAW,OAAO,YAAa,SAAQ,IAAI,iBAAiB,IAAI,MAAM,KAAK,IAAI,MAAM,GAAG;AAAA,EAC1F;AACA,QAAM,SAAS,KAAK,SAAS,UAAU;AACvC,SAAO,SAAS,KAAK,CAAC,YACpB,QAAQ,UAAU,oBAAoB,QAAQ,UAAU,kBACpD,UAAU,QAAQ,UAAU,mBAAoB,IAAI,IAAI;AAChE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,103 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { resolveModuleIdentity } from "@open-mercato/shared/modules/module-locators";
4
+ import { extractModuleRequiresFromSource } from "./generators/module-registry.js";
5
+ import { MODULE_CODE_EXTENSIONS } from "./generators/scanner.js";
6
+ import { discoverModulesInPackage } from "./module-package.js";
7
+ import { createResolver } from "./resolver.js";
8
+ function existingDirectories(paths) {
9
+ return [...new Set(paths)].filter((candidate) => fs.existsSync(candidate) && fs.statSync(candidate).isDirectory());
10
+ }
11
+ function moduleIndexFile(roots) {
12
+ return roots.flatMap((root) => MODULE_CODE_EXTENSIONS.map((extension) => path.join(root, `index${extension}`))).find((candidate) => fs.existsSync(candidate));
13
+ }
14
+ function readModule(resolver, entry, enabled) {
15
+ const packageName = entry.from ?? "@open-mercato/core";
16
+ const packageRoot = resolver.getPackageRoot(packageName);
17
+ const { appBase, pkgBase } = resolver.getModulePaths(entry);
18
+ const roots = existingDirectories(packageName === "@app" ? [appBase] : [appBase, pkgBase]);
19
+ const indexFile = moduleIndexFile(roots);
20
+ const requires = indexFile ? extractModuleRequiresFromSource(indexFile) : null;
21
+ const optionalRequires = indexFile ? extractModuleRequiresFromSource(indexFile, "optionalRequires") : null;
22
+ const notAnalyzed = !indexFile ? "module index source is unavailable" : requires?.status === "unresolvable" ? requires.reason : optionalRequires?.status === "unresolvable" ? optionalRequires.reason : void 0;
23
+ let version = null;
24
+ try {
25
+ const manifest = JSON.parse(fs.readFileSync(path.join(
26
+ packageName === "@app" ? resolver.getAppDir() : packageRoot,
27
+ "package.json"
28
+ ), "utf8"));
29
+ if (typeof manifest.version === "string") version = manifest.version;
30
+ } catch {
31
+ }
32
+ return {
33
+ id: entry.id,
34
+ packageName,
35
+ version,
36
+ roots,
37
+ enabled,
38
+ locators: [...new Set([entry.locator, entry.packageName, packageName].filter((locator) => !!locator && locator !== "@app"))],
39
+ requires: requires?.status === "declared" ? requires.requires : [],
40
+ optionalRequires: optionalRequires?.status === "declared" ? optionalRequires.requires : [],
41
+ ...notAnalyzed ? { notAnalyzed } : {}
42
+ };
43
+ }
44
+ function buildModuleIndex(resolver = createResolver(), includeInactive = true) {
45
+ const enabled = resolver.loadEnabledModules();
46
+ const result = enabled.map((entry) => readModule(resolver, entry, true));
47
+ if (!includeInactive) return result;
48
+ const keys = new Set(result.map((entry) => `${entry.packageName}:${entry.id}`));
49
+ const appModules = path.join(resolver.getAppDir(), "src", "modules");
50
+ if (fs.existsSync(appModules)) {
51
+ const enabledIds = new Set(enabled.map((entry) => entry.id));
52
+ for (const entry of fs.readdirSync(appModules, { withFileTypes: true })) {
53
+ if (!entry.isDirectory() || entry.name.startsWith(".") || enabledIds.has(entry.name)) continue;
54
+ result.push(readModule(resolver, { id: entry.name, from: "@app" }, false));
55
+ }
56
+ }
57
+ const packages = new Map(resolver.discoverPackages().map((pkg) => [pkg.name, pkg.path]));
58
+ const appManifest = path.join(resolver.getAppDir(), "package.json");
59
+ try {
60
+ const manifest = JSON.parse(fs.readFileSync(appManifest, "utf8"));
61
+ for (const packageName of Object.keys({ ...manifest.dependencies, ...manifest.optionalDependencies })) {
62
+ if (!packages.has(packageName)) packages.set(packageName, resolver.getPackageRoot(packageName));
63
+ }
64
+ } catch {
65
+ }
66
+ for (const [packageName, packageRoot] of packages) {
67
+ for (const entry of discoverModulesInPackage(packageRoot)) {
68
+ if (keys.has(`${packageName}:${entry.moduleId}`)) continue;
69
+ result.push(readModule(resolver, { id: entry.moduleId, from: packageName }, false));
70
+ }
71
+ }
72
+ return result.sort((left, right) => left.id.localeCompare(right.id) || left.packageName.localeCompare(right.packageName));
73
+ }
74
+ function resolveIndexedModule(requirement, modules) {
75
+ const activeFirst = [...modules.filter((entry) => entry.enabled), ...modules.filter((entry) => !entry.enabled)];
76
+ return resolveModuleIdentity(requirement, activeFirst);
77
+ }
78
+ function missingModuleRequirements(entry, modules) {
79
+ const visited = /* @__PURE__ */ new Set([entry.id]);
80
+ const missing = /* @__PURE__ */ new Map();
81
+ function visit(source, trail) {
82
+ for (const requirement of source.requires) {
83
+ const target = resolveIndexedModule(requirement, modules);
84
+ const nextTrail = [...trail, target?.id ?? requirement];
85
+ if ((!target || !target.enabled) && !missing.has(requirement)) missing.set(requirement, nextTrail);
86
+ if (!target || visited.has(target.id)) continue;
87
+ visited.add(target.id);
88
+ visit(target, nextTrail);
89
+ }
90
+ }
91
+ visit(entry, [entry.id]);
92
+ return [...missing].map(([requirement, path2]) => ({ requirement, path: path2 }));
93
+ }
94
+ function inactiveModuleDependencies(modules) {
95
+ return modules.filter((module) => module.enabled).flatMap((source) => source.optionalRequires.filter((target) => !resolveIndexedModule(target, modules)?.enabled).map((target) => ({ source, target })));
96
+ }
97
+ export {
98
+ buildModuleIndex,
99
+ inactiveModuleDependencies,
100
+ missingModuleRequirements,
101
+ resolveIndexedModule
102
+ };
103
+ //# sourceMappingURL=module-index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/module-index.ts"],
4
+ "sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport { resolveModuleIdentity, type ModuleIdentity } from '@open-mercato/shared/modules/module-locators'\nimport { extractModuleRequiresFromSource } from './generators/module-registry'\nimport { MODULE_CODE_EXTENSIONS } from './generators/scanner'\nimport { discoverModulesInPackage } from './module-package'\nimport { createResolver, type ModuleEntry, type PackageResolver } from './resolver'\n\nexport type IndexedModule = ModuleIdentity & {\n packageName: string\n version: string | null\n roots: string[]\n enabled: boolean\n requires: string[]\n optionalRequires: string[]\n notAnalyzed?: string\n}\n\nfunction existingDirectories(paths: string[]): string[] {\n return [...new Set(paths)].filter((candidate) => fs.existsSync(candidate) && fs.statSync(candidate).isDirectory())\n}\n\nfunction moduleIndexFile(roots: string[]): string | undefined {\n return roots.flatMap((root) => MODULE_CODE_EXTENSIONS.map((extension) => path.join(root, `index${extension}`)))\n .find((candidate) => fs.existsSync(candidate))\n}\n\nfunction readModule(resolver: PackageResolver, entry: ModuleEntry, enabled: boolean): IndexedModule {\n const packageName = entry.from ?? '@open-mercato/core'\n const packageRoot = resolver.getPackageRoot(packageName)\n const { appBase, pkgBase } = resolver.getModulePaths(entry)\n const roots = existingDirectories(packageName === '@app' ? [appBase] : [appBase, pkgBase])\n const indexFile = moduleIndexFile(roots)\n const requires = indexFile ? extractModuleRequiresFromSource(indexFile) : null\n const optionalRequires = indexFile ? extractModuleRequiresFromSource(indexFile, 'optionalRequires') : null\n const notAnalyzed = !indexFile\n ? 'module index source is unavailable'\n : requires?.status === 'unresolvable'\n ? requires.reason\n : optionalRequires?.status === 'unresolvable'\n ? optionalRequires.reason\n : undefined\n let version: string | null = null\n try {\n const manifest: { version?: unknown } = JSON.parse(fs.readFileSync(path.join(\n packageName === '@app' ? resolver.getAppDir() : packageRoot, 'package.json',\n ), 'utf8'))\n if (typeof manifest.version === 'string') version = manifest.version\n } catch {\n // Module diagnostics remain available even if package version metadata is absent.\n }\n return {\n id: entry.id,\n packageName,\n version,\n roots,\n enabled,\n locators: [...new Set([entry.locator, entry.packageName, packageName].filter((locator): locator is string => !!locator && locator !== '@app'))],\n requires: requires?.status === 'declared' ? requires.requires : [],\n optionalRequires: optionalRequires?.status === 'declared' ? optionalRequires.requires : [],\n ...(notAnalyzed ? { notAnalyzed } : {}),\n }\n}\n\nexport function buildModuleIndex(resolver: PackageResolver = createResolver(), includeInactive = true): IndexedModule[] {\n const enabled = resolver.loadEnabledModules()\n const result = enabled.map((entry) => readModule(resolver, entry, true))\n if (!includeInactive) return result\n\n const keys = new Set(result.map((entry) => `${entry.packageName}:${entry.id}`))\n const appModules = path.join(resolver.getAppDir(), 'src', 'modules')\n if (fs.existsSync(appModules)) {\n const enabledIds = new Set(enabled.map((entry) => entry.id))\n for (const entry of fs.readdirSync(appModules, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name.startsWith('.') || enabledIds.has(entry.name)) continue\n result.push(readModule(resolver, { id: entry.name, from: '@app' }, false))\n }\n }\n\n const packages = new Map(resolver.discoverPackages().map((pkg) => [pkg.name, pkg.path]))\n const appManifest = path.join(resolver.getAppDir(), 'package.json')\n try {\n const manifest: { dependencies?: Record<string, string>; optionalDependencies?: Record<string, string> } =\n JSON.parse(fs.readFileSync(appManifest, 'utf8'))\n for (const packageName of Object.keys({ ...manifest.dependencies, ...manifest.optionalDependencies })) {\n if (!packages.has(packageName)) packages.set(packageName, resolver.getPackageRoot(packageName))\n }\n } catch {\n // Missing app package metadata does not prevent inspecting known installed packages.\n }\n\n for (const [packageName, packageRoot] of packages) {\n for (const entry of discoverModulesInPackage(packageRoot)) {\n if (keys.has(`${packageName}:${entry.moduleId}`)) continue\n result.push(readModule(resolver, { id: entry.moduleId, from: packageName }, false))\n }\n }\n return result.sort((left, right) => left.id.localeCompare(right.id) || left.packageName.localeCompare(right.packageName))\n}\n\nexport function resolveIndexedModule(requirement: string, modules: IndexedModule[]): IndexedModule | undefined {\n // The enabled instance takes precedence over any other installed provider for the same id.\n const activeFirst = [...modules.filter((entry) => entry.enabled), ...modules.filter((entry) => !entry.enabled)]\n return resolveModuleIdentity(requirement, activeFirst)\n}\n\nexport function missingModuleRequirements(\n entry: IndexedModule,\n modules: IndexedModule[],\n): Array<{ requirement: string; path: string[] }> {\n const visited = new Set([entry.id])\n const missing = new Map<string, string[]>()\n\n function visit(source: IndexedModule, trail: string[]): void {\n for (const requirement of source.requires) {\n const target = resolveIndexedModule(requirement, modules)\n const nextTrail = [...trail, target?.id ?? requirement]\n if ((!target || !target.enabled) && !missing.has(requirement)) missing.set(requirement, nextTrail)\n if (!target || visited.has(target.id)) continue\n visited.add(target.id)\n visit(target, nextTrail)\n }\n }\n\n visit(entry, [entry.id])\n return [...missing].map(([requirement, path]) => ({ requirement, path }))\n}\n\nexport function inactiveModuleDependencies(modules: IndexedModule[]): Array<{ source: IndexedModule; target: string }> {\n return modules.filter((module) => module.enabled).flatMap((source) => source.optionalRequires\n .filter((target) => !resolveIndexedModule(target, modules)?.enabled)\n .map((target) => ({ source, target })))\n}\n"],
5
+ "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,6BAAkD;AAC3D,SAAS,uCAAuC;AAChD,SAAS,8BAA8B;AACvC,SAAS,gCAAgC;AACzC,SAAS,sBAA8D;AAYvE,SAAS,oBAAoB,OAA2B;AACtD,SAAO,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,EAAE,OAAO,CAAC,cAAc,GAAG,WAAW,SAAS,KAAK,GAAG,SAAS,SAAS,EAAE,YAAY,CAAC;AACnH;AAEA,SAAS,gBAAgB,OAAqC;AAC5D,SAAO,MAAM,QAAQ,CAAC,SAAS,uBAAuB,IAAI,CAAC,cAAc,KAAK,KAAK,MAAM,QAAQ,SAAS,EAAE,CAAC,CAAC,EAC3G,KAAK,CAAC,cAAc,GAAG,WAAW,SAAS,CAAC;AACjD;AAEA,SAAS,WAAW,UAA2B,OAAoB,SAAiC;AAClG,QAAM,cAAc,MAAM,QAAQ;AAClC,QAAM,cAAc,SAAS,eAAe,WAAW;A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",
6
+ "names": ["path"]
7
+ }
@@ -0,0 +1,89 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { lstatSync, readFileSync } from "node:fs";
3
+ import { mkdir, writeFile } from "node:fs/promises";
4
+ import path from "node:path";
5
+ const identityQuery = "SELECT current_database() AS database_name, shobj_description(oid, 'pg_database') AS ownership_marker FROM pg_database WHERE datname = current_database()";
6
+ function connectionTarget(databaseUrl) {
7
+ if (!databaseUrl) throw new Error("[internal] Ephemeral initialization requires an explicit database connection.");
8
+ let parsed;
9
+ try {
10
+ parsed = new URL(databaseUrl);
11
+ } catch {
12
+ throw new Error("[internal] Ephemeral database connection is invalid.");
13
+ }
14
+ if (!["postgres:", "postgresql:"].includes(parsed.protocol) || !parsed.hostname || parsed.pathname.length < 2) {
15
+ throw new Error("[internal] Ephemeral database connection is invalid.");
16
+ }
17
+ const databaseName = decodeURIComponent(parsed.pathname.slice(1));
18
+ const port = parsed.port || "5432";
19
+ return `postgresql://${decodeURIComponent(parsed.username)}@${parsed.hostname.toLowerCase()}:${port}/${databaseName}`;
20
+ }
21
+ function connectionDigest(databaseUrl) {
22
+ return createHash("sha256").update(connectionTarget(databaseUrl)).digest("hex");
23
+ }
24
+ function readEphemeralDatabaseGuard(args) {
25
+ const prefix = "--ephemeral-database-guard=";
26
+ const values = args.filter((argument) => argument === "--ephemeral-database-guard" || argument.startsWith(prefix));
27
+ if (values.length === 0) return null;
28
+ if (values.length !== 1 || !values[0].startsWith(prefix) || !values[0].slice(prefix.length)) {
29
+ throw new Error("[internal] Ephemeral initialization requires one database ownership proof file.");
30
+ }
31
+ const proofPath = values[0].slice(prefix.length);
32
+ const metadata = lstatSync(proofPath);
33
+ if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size > 4096 || process.platform !== "win32" && ((metadata.mode & 63) !== 0 || metadata.uid !== process.getuid?.())) {
34
+ throw new Error("[internal] Ephemeral database ownership proof must be a private regular file.");
35
+ }
36
+ const value = JSON.parse(readFileSync(proofPath, "utf8"));
37
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
38
+ throw new Error("[internal] Ephemeral database ownership proof is invalid.");
39
+ }
40
+ const record = value;
41
+ if (record.version !== 1 || typeof record.databaseName !== "string" || !record.databaseName || typeof record.connectionDigest !== "string" || !/^[a-f0-9]{64}$/.test(record.connectionDigest) || typeof record.ownershipMarker !== "string" || !/^open-mercato-ephemeral:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/.test(record.ownershipMarker)) {
42
+ throw new Error("[internal] Ephemeral database ownership proof is invalid.");
43
+ }
44
+ return { version: 1, databaseName: record.databaseName, connectionDigest: record.connectionDigest, ownershipMarker: record.ownershipMarker };
45
+ }
46
+ function assertEphemeralDatabaseConnection(guard, databaseUrl) {
47
+ if (connectionDigest(databaseUrl) !== guard.connectionDigest) {
48
+ throw new Error("[internal] Refusing initialization: the effective database connection is not the owned disposable target.");
49
+ }
50
+ }
51
+ async function assertEphemeralDatabaseOwnership(guard, client) {
52
+ const identity = (await client.query(identityQuery)).rows[0];
53
+ if (identity?.database_name !== guard.databaseName || identity?.ownership_marker !== guard.ownershipMarker) {
54
+ throw new Error("[internal] Refusing initialization: database ownership could not be verified.");
55
+ }
56
+ }
57
+ async function createEphemeralDatabaseGuard(databaseUrl, databaseName, directory) {
58
+ const digest = connectionDigest(databaseUrl);
59
+ if (decodeURIComponent(new URL(databaseUrl).pathname.slice(1)) !== databaseName) {
60
+ throw new Error("[internal] Disposable database identity does not match its allocation.");
61
+ }
62
+ const { Client } = await import("pg");
63
+ const client = new Client({ connectionString: databaseUrl, connectionTimeoutMillis: 5e3 });
64
+ const ownershipMarker = `open-mercato-ephemeral:${randomUUID()}`;
65
+ try {
66
+ await client.connect();
67
+ const identity = (await client.query(identityQuery)).rows[0];
68
+ if (identity?.database_name !== databaseName) {
69
+ throw new Error("[internal] Connected database identity does not match its allocation.");
70
+ }
71
+ const quotedName = `"${databaseName.replace(/"/g, '""')}"`;
72
+ await client.query(`COMMENT ON DATABASE ${quotedName} IS '${ownershipMarker}'`);
73
+ const guard = { version: 1, databaseName, connectionDigest: digest, ownershipMarker };
74
+ await assertEphemeralDatabaseOwnership(guard, client);
75
+ await mkdir(directory, { recursive: true, mode: 448 });
76
+ const proofPath = path.join(directory, `${randomUUID()}.json`);
77
+ await writeFile(proofPath, JSON.stringify(guard), { mode: 384, flag: "wx" });
78
+ return proofPath;
79
+ } finally {
80
+ await client.end();
81
+ }
82
+ }
83
+ export {
84
+ assertEphemeralDatabaseConnection,
85
+ assertEphemeralDatabaseOwnership,
86
+ createEphemeralDatabaseGuard,
87
+ readEphemeralDatabaseGuard
88
+ };
89
+ //# sourceMappingURL=ephemeral-database-guard.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/testing/ephemeral-database-guard.ts"],
4
+ "sourcesContent": ["import { createHash, randomUUID } from 'node:crypto'\nimport { lstatSync, readFileSync } from 'node:fs'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport path from 'node:path'\n\ntype DatabaseIdentity = { database_name: unknown; ownership_marker: unknown }\n\nexport type EphemeralDatabaseConnection = {\n query: (statement: string) => Promise<{ rows: DatabaseIdentity[] }>\n}\n\nexport type EphemeralDatabaseGuard = {\n version: 1\n databaseName: string\n connectionDigest: string\n ownershipMarker: string\n}\n\nconst identityQuery = \"SELECT current_database() AS database_name, shobj_description(oid, 'pg_database') AS ownership_marker FROM pg_database WHERE datname = current_database()\"\n\nfunction connectionTarget(databaseUrl: string | undefined): string {\n if (!databaseUrl) throw new Error('[internal] Ephemeral initialization requires an explicit database connection.')\n let parsed: URL\n try {\n parsed = new URL(databaseUrl)\n } catch {\n throw new Error('[internal] Ephemeral database connection is invalid.')\n }\n if (!['postgres:', 'postgresql:'].includes(parsed.protocol) || !parsed.hostname || parsed.pathname.length < 2) {\n throw new Error('[internal] Ephemeral database connection is invalid.')\n }\n const databaseName = decodeURIComponent(parsed.pathname.slice(1))\n const port = parsed.port || '5432'\n return `postgresql://${decodeURIComponent(parsed.username)}@${parsed.hostname.toLowerCase()}:${port}/${databaseName}`\n}\n\nfunction connectionDigest(databaseUrl: string | undefined): string {\n return createHash('sha256').update(connectionTarget(databaseUrl)).digest('hex')\n}\n\nexport function readEphemeralDatabaseGuard(args: string[]): EphemeralDatabaseGuard | null {\n const prefix = '--ephemeral-database-guard='\n const values = args.filter((argument) => argument === '--ephemeral-database-guard' || argument.startsWith(prefix))\n if (values.length === 0) return null\n if (values.length !== 1 || !values[0].startsWith(prefix) || !values[0].slice(prefix.length)) {\n throw new Error('[internal] Ephemeral initialization requires one database ownership proof file.')\n }\n const proofPath = values[0].slice(prefix.length)\n const metadata = lstatSync(proofPath)\n if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size > 4096\n || (process.platform !== 'win32' && ((metadata.mode & 0o077) !== 0 || metadata.uid !== process.getuid?.()))) {\n throw new Error('[internal] Ephemeral database ownership proof must be a private regular file.')\n }\n const value: unknown = JSON.parse(readFileSync(proofPath, 'utf8'))\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n throw new Error('[internal] Ephemeral database ownership proof is invalid.')\n }\n const record = value as Record<string, unknown>\n if (record.version !== 1 || typeof record.databaseName !== 'string' || !record.databaseName\n || typeof record.connectionDigest !== 'string' || !/^[a-f0-9]{64}$/.test(record.connectionDigest)\n || typeof record.ownershipMarker !== 'string' || !/^open-mercato-ephemeral:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/.test(record.ownershipMarker)) {\n throw new Error('[internal] Ephemeral database ownership proof is invalid.')\n }\n return { version: 1, databaseName: record.databaseName, connectionDigest: record.connectionDigest, ownershipMarker: record.ownershipMarker }\n}\n\nexport function assertEphemeralDatabaseConnection(guard: EphemeralDatabaseGuard, databaseUrl: string | undefined): void {\n if (connectionDigest(databaseUrl) !== guard.connectionDigest) {\n throw new Error('[internal] Refusing initialization: the effective database connection is not the owned disposable target.')\n }\n}\n\nexport async function assertEphemeralDatabaseOwnership(guard: EphemeralDatabaseGuard, client: EphemeralDatabaseConnection): Promise<void> {\n const identity = (await client.query(identityQuery)).rows[0]\n if (identity?.database_name !== guard.databaseName || identity?.ownership_marker !== guard.ownershipMarker) {\n throw new Error('[internal] Refusing initialization: database ownership could not be verified.')\n }\n}\n\nexport async function createEphemeralDatabaseGuard(databaseUrl: string, databaseName: string, directory: string): Promise<string> {\n const digest = connectionDigest(databaseUrl)\n if (decodeURIComponent(new URL(databaseUrl).pathname.slice(1)) !== databaseName) {\n throw new Error('[internal] Disposable database identity does not match its allocation.')\n }\n const { Client } = await import('pg')\n const client = new Client({ connectionString: databaseUrl, connectionTimeoutMillis: 5000 })\n const ownershipMarker = `open-mercato-ephemeral:${randomUUID()}`\n try {\n await client.connect()\n const identity = (await client.query<DatabaseIdentity>(identityQuery)).rows[0]\n if (identity?.database_name !== databaseName) {\n throw new Error('[internal] Connected database identity does not match its allocation.')\n }\n const quotedName = `\"${databaseName.replace(/\"/g, '\"\"')}\"`\n await client.query(`COMMENT ON DATABASE ${quotedName} IS '${ownershipMarker}'`)\n const guard: EphemeralDatabaseGuard = { version: 1, databaseName, connectionDigest: digest, ownershipMarker }\n await assertEphemeralDatabaseOwnership(guard, client)\n await mkdir(directory, { recursive: true, mode: 0o700 })\n const proofPath = path.join(directory, `${randomUUID()}.json`)\n await writeFile(proofPath, JSON.stringify(guard), { mode: 0o600, flag: 'wx' })\n return proofPath\n } finally {\n await client.end()\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAY,kBAAkB;AACvC,SAAS,WAAW,oBAAoB;AACxC,SAAS,OAAO,iBAAiB;AACjC,OAAO,UAAU;AAejB,MAAM,gBAAgB;AAEtB,SAAS,iBAAiB,aAAyC;AACjE,MAAI,CAAC,YAAa,OAAM,IAAI,MAAM,+EAA+E;AACjH,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,WAAW;A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,GAAG,KAAK,CAAC;AAC7E,QAAI,UAAU,kBAAkB,cAAc;AAC5C,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;AACA,UAAM,aAAa,IAAI,aAAa,QAAQ,MAAM,IAAI,CAAC;AACvD,UAAM,OAAO,MAAM,uBAAuB,UAAU,QAAQ,eAAe,GAAG;AAC9E,UAAM,QAAgC,EAAE,SAAS,GAAG,cAAc,kBAAkB,QAAQ,gBAAgB;AAC5G,UAAM,iCAAiC,OAAO,MAAM;AACpD,UAAM,MAAM,WAAW,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AACvD,UAAM,YAAY,KAAK,KAAK,WAAW,GAAG,WAAW,CAAC,OAAO;AAC7D,UAAM,UAAU,WAAW,KAAK,UAAU,KAAK,GAAG,EAAE,MAAM,KAAO,MAAM,KAAK,CAAC;AAC7E,WAAO;AAAA,EACT,UAAE;AACA,UAAM,OAAO,IAAI;AAAA,EACnB;AACF;",
6
+ "names": []
7
+ }
@@ -19,6 +19,7 @@ const DISCOVERY_IGNORED_DIRS = /* @__PURE__ */ new Set([
19
19
  ]);
20
20
  const INTEGRATION_META_FILE_NAMES = ["meta.ts", "index.ts"];
21
21
  const INTEGRATION_META_DEPENDENCY_KEYS = ["dependsOnModules", "requiredModules", "requiresModules"];
22
+ const INTEGRATION_META_ALL_DEPENDENCY_KEYS = [...INTEGRATION_META_DEPENDENCY_KEYS, "optionalModules"];
22
23
  const INTEGRATION_META_REQUIRED_ENV_KEYS = ["requiredEnvVars", "requiresEnvVars"];
23
24
  const INTEGRATION_META_REQUIRED_ANY_ENV_KEYS = ["requiredAnyEnvVars", "requiresAnyEnvVars"];
24
25
  const DEFAULT_OVERLAY_ROOT = "packages/enterprise";
@@ -234,8 +235,9 @@ function extractStringArrayFromSource(source, keys) {
234
235
  }
235
236
  return Array.from(collected);
236
237
  }
237
- function extractDependencyListFromSource(source) {
238
- return extractStringArrayFromSource(source, INTEGRATION_META_DEPENDENCY_KEYS).map(normalizeModuleId);
238
+ function extractDependencyListFromSource(source, includeOptional) {
239
+ const keys = includeOptional ? INTEGRATION_META_ALL_DEPENDENCY_KEYS : INTEGRATION_META_DEPENDENCY_KEYS;
240
+ return extractStringArrayFromSource(source, keys).map(normalizeModuleId);
239
241
  }
240
242
  function extractRequiredEnvVarsFromSource(source) {
241
243
  return extractStringArrayFromSource(source, INTEGRATION_META_REQUIRED_ENV_KEYS);
@@ -243,9 +245,9 @@ function extractRequiredEnvVarsFromSource(source) {
243
245
  function extractRequiredAnyEnvVarsFromSource(source) {
244
246
  return extractStringArrayFromSource(source, INTEGRATION_META_REQUIRED_ANY_ENV_KEYS);
245
247
  }
246
- function readDependenciesFromMetadataFile(absolutePath) {
248
+ function readDependenciesFromMetadataFile(absolutePath, includeOptional) {
247
249
  try {
248
- return extractDependencyListFromSource(readFileSync(absolutePath, "utf8"));
250
+ return extractDependencyListFromSource(readFileSync(absolutePath, "utf8"), includeOptional);
249
251
  } catch {
250
252
  return [];
251
253
  }
@@ -272,7 +274,7 @@ function resolveIntegrationRootDirectory(relativeSpecPath) {
272
274
  }
273
275
  return segments.slice(0, integrationDirectoryIndex + 1).join("/");
274
276
  }
275
- function resolveRequiredModulesForSpec(projectRoot, relativeSpecPath) {
277
+ function resolveModuleDependenciesForSpec(projectRoot, relativeSpecPath, { includeOptional = false } = {}) {
276
278
  const requiredModules = /* @__PURE__ */ new Set();
277
279
  const normalizedSpecPath = normalizePath(relativeSpecPath);
278
280
  const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath);
@@ -291,14 +293,14 @@ function resolveRequiredModulesForSpec(projectRoot, relativeSpecPath) {
291
293
  for (const directoryPath of traversal) {
292
294
  for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {
293
295
  const metadataPath = path.join(directoryPath, metadataFileName);
294
- readDependenciesFromMetadataFile(metadataPath).forEach((dependency) => requiredModules.add(dependency));
296
+ readDependenciesFromMetadataFile(metadataPath, includeOptional).forEach((dependency) => requiredModules.add(dependency));
295
297
  }
296
298
  }
297
299
  }
298
- readDependenciesFromMetadataFile(absoluteSpecPath).forEach((dependency) => requiredModules.add(dependency));
300
+ readDependenciesFromMetadataFile(absoluteSpecPath, includeOptional).forEach((dependency) => requiredModules.add(dependency));
299
301
  const specFileName = path.basename(normalizedSpecPath, ".spec.ts");
300
302
  const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`);
301
- readDependenciesFromMetadataFile(perTestMetadataPath).forEach((dependency) => requiredModules.add(dependency));
303
+ readDependenciesFromMetadataFile(perTestMetadataPath, includeOptional).forEach((dependency) => requiredModules.add(dependency));
302
304
  return Array.from(requiredModules);
303
305
  }
304
306
  function resolveRequiredEnvVarsForSpec(projectRoot, relativeSpecPath) {
@@ -380,7 +382,7 @@ function discoverIntegrationSpecFiles(projectRoot, legacyIntegrationRoot) {
380
382
  path: relativePath,
381
383
  moduleName: extractModuleNameFromIntegrationPath(relativePath),
382
384
  isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),
383
- requiredModules: resolveRequiredModulesForSpec(projectRoot, relativePath),
385
+ requiredModules: resolveModuleDependenciesForSpec(projectRoot, relativePath),
384
386
  requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),
385
387
  requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath)
386
388
  });
@@ -393,7 +395,7 @@ function discoverIntegrationSpecFiles(projectRoot, legacyIntegrationRoot) {
393
395
  path: relativePath,
394
396
  moduleName: extractModuleNameFromIntegrationPath(relativePath),
395
397
  isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),
396
- requiredModules: resolveRequiredModulesForSpec(projectRoot, relativePath),
398
+ requiredModules: resolveModuleDependenciesForSpec(projectRoot, relativePath),
397
399
  requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),
398
400
  requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath)
399
401
  });
@@ -402,9 +404,9 @@ function discoverIntegrationSpecFiles(projectRoot, legacyIntegrationRoot) {
402
404
  }
403
405
  const discovered = Array.from(discoveredByPath.values()).filter((file) => !appOnly || isAppOwnedIntegrationSpecPath(file.path));
404
406
  if (isMetadataFilteringDisabled()) {
405
- const selected = discovered.sort((left, right) => left.path.localeCompare(right.path));
406
- writeDiscoverySelectionReport(projectRoot, selected);
407
- return selected;
407
+ const selected2 = discovered.sort((left, right) => left.path.localeCompare(right.path));
408
+ writeDiscoverySelectionReport(projectRoot, selected2);
409
+ return selected2;
408
410
  }
409
411
  const enabledModules = resolveEnabledModuleIds(projectRoot);
410
412
  const testAppRoot = resolveTestAppRoot();
@@ -415,7 +417,7 @@ function discoverIntegrationSpecFiles(projectRoot, legacyIntegrationRoot) {
415
417
  enabledModuleNames.add(file.moduleName);
416
418
  }
417
419
  }
418
- return discovered.filter((file) => {
420
+ const selected = discovered.filter((file) => {
419
421
  if (file.requiredModules.some((moduleId) => !enabledModules.has(normalizeModuleId(moduleId)))) {
420
422
  return false;
421
423
  }
@@ -445,6 +447,8 @@ function discoverIntegrationSpecFiles(projectRoot, legacyIntegrationRoot) {
445
447
  }
446
448
  return enabledModules.has(normalizeModuleId(file.moduleName));
447
449
  }).sort((left, right) => left.path.localeCompare(right.path));
450
+ writeDiscoverySelectionReport(projectRoot, selected);
451
+ return selected;
448
452
  }
449
453
  export {
450
454
  APP_ONLY_INTEGRATION_ENV_VAR,
@@ -452,6 +456,7 @@ export {
452
456
  SKIP_METADATA_FILTERS_INTEGRATION_ENV_VAR,
453
457
  discoverIntegrationSpecFiles,
454
458
  isAppOwnedIntegrationSpecPath,
455
- normalizePath
459
+ normalizePath,
460
+ resolveModuleDependenciesForSpec
456
461
  };
457
462
  //# sourceMappingURL=integration-discovery.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/testing/integration-discovery.ts"],
4
- "sourcesContent": ["import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'\nimport path from 'node:path'\nimport ts from 'typescript-js'\n\nexport type IntegrationSpecDiscoveryItem = {\n path: string\n moduleName: string | null\n isOverlay: boolean\n requiredModules: string[]\n requiredEnvVars: string[]\n requiredAnyEnvVars: string[]\n}\n\nconst MODULE_INTEGRATION_DIRECTORY_NAME = '__integration__'\nconst DISCOVERY_IGNORED_DIRS = new Set([\n 'node_modules',\n '.git',\n '.next',\n 'dist',\n '.turbo',\n 'coverage',\n 'test-results',\n '.yarn',\n '.cache',\n 'tmp',\n 'temp',\n '.claude',\n '.codex',\n])\nconst INTEGRATION_META_FILE_NAMES = ['meta.ts', 'index.ts'] as const\nconst INTEGRATION_META_DEPENDENCY_KEYS = ['dependsOnModules', 'requiredModules', 'requiresModules'] as const\nconst INTEGRATION_META_REQUIRED_ENV_KEYS = ['requiredEnvVars', 'requiresEnvVars'] as const\nconst INTEGRATION_META_REQUIRED_ANY_ENV_KEYS = ['requiredAnyEnvVars', 'requiresAnyEnvVars'] as const\nconst DEFAULT_OVERLAY_ROOT = 'packages/enterprise'\nexport const APP_ONLY_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_APP_ONLY'\nexport const SKIP_METADATA_FILTERS_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_SKIP_METADATA_FILTERS'\nexport const DISCOVERY_SELECTION_REPORT_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_DISCOVERY_SELECTION_REPORT'\n\nexport function normalizePath(filePath: string): string {\n return filePath.split(path.sep).join('/')\n}\n\nfunction normalizeModuleId(moduleId: string): string {\n return moduleId.trim().toLowerCase()\n}\n\nfunction isEnterpriseModulesEnabled(): boolean {\n const rawValue = process.env.OM_ENABLE_ENTERPRISE_MODULES?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nfunction isAppOnlyDiscoveryEnabled(): boolean {\n const rawValue = process.env[APP_ONLY_INTEGRATION_ENV_VAR]?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nfunction isMetadataFilteringDisabled(): boolean {\n const rawValue = process.env[SKIP_METADATA_FILTERS_INTEGRATION_ENV_VAR]?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nexport function isAppOwnedIntegrationSpecPath(relativePath: string): boolean {\n return !normalizePath(relativePath).split('/').includes('node_modules')\n}\n\nfunction writeDiscoverySelectionReport(projectRoot: string, files: readonly IntegrationSpecDiscoveryItem[]): void {\n const reportFile = process.env[DISCOVERY_SELECTION_REPORT_INTEGRATION_ENV_VAR]?.trim()\n if (!reportFile) return\n writeFileSync(reportFile, JSON.stringify({ projectRoot, paths: files.map((file) => file.path) }))\n}\n\nfunction collectNamedDirectories(rootPath: string, directoryName: string): string[] {\n let entries\n try {\n entries = readdirSync(rootPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n\n const collected: string[] = []\n for (const entry of entries) {\n if (!entry.isDirectory()) continue\n if (DISCOVERY_IGNORED_DIRS.has(entry.name)) continue\n const absolutePath = path.join(rootPath, entry.name)\n if (entry.name === directoryName) {\n collected.push(absolutePath)\n }\n collected.push(...collectNamedDirectories(absolutePath, directoryName))\n }\n return collected\n}\n\nfunction collectSpecFilesFromDirectory(directoryPath: string): string[] {\n let entries\n try {\n entries = readdirSync(directoryPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n\n const collected: string[] = []\n for (const entry of entries) {\n const absolutePath = path.join(directoryPath, entry.name)\n if (entry.isDirectory()) {\n collected.push(...collectSpecFilesFromDirectory(absolutePath))\n continue\n }\n if (entry.isFile() && entry.name.endsWith('.spec.ts')) {\n collected.push(absolutePath)\n }\n }\n return collected\n}\n\nfunction collectDirectDirectoryNames(directoryPath: string): string[] {\n let entries\n try {\n entries = readdirSync(directoryPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n return entries\n .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))\n .map((entry) => entry.name)\n}\n\nfunction collectModuleIdsFromModulesRoot(modulesRoot: string, enabledModules: Set<string>): void {\n for (const moduleName of collectDirectDirectoryNames(modulesRoot)) {\n enabledModules.add(normalizeModuleId(moduleName))\n }\n}\n\nfunction readModuleEntryId(element: ts.Expression): string[] {\n if (!ts.isObjectLiteralExpression(element)) return []\n const idProperty = element.properties.find((property): property is ts.PropertyAssignment =>\n ts.isPropertyAssignment(property)\n && (\n (ts.isIdentifier(property.name) && property.name.text === 'id')\n || (ts.isStringLiteralLike(property.name) && property.name.text === 'id')\n ),\n )\n return idProperty && ts.isStringLiteralLike(idProperty.initializer)\n ? [idProperty.initializer.text]\n : []\n}\n\nfunction isPushOntoVariable(node: ts.Node, variableName: string): node is ts.CallExpression {\n return ts.isCallExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && node.expression.name.text === 'push'\n && ts.isIdentifier(node.expression.expression)\n && node.expression.expression.text === variableName\n}\n\n/**\n * Module ids a registry file declares for `variableName`: the entries of its array\n * literal initializer and, with `includePushes`, every `variableName.push({ id })` call.\n * Pushes are usually conditional (enterprise or env-gated modules), so including them\n * yields an upper bound of what the app can register, never narrower than the runtime set.\n */\nfunction readDeclaredModuleIdsFromConfig(\n registryPath: string,\n options: { variableName?: string; includePushes?: boolean; optional?: boolean } = {},\n): string[] {\n const variableName = options.variableName ?? 'enabledModules'\n if (options.optional && !existsSync(registryPath)) return []\n const source = readFileSync(registryPath, 'utf8')\n const sourceFile = ts.createSourceFile(\n registryPath,\n source,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n )\n\n const declared: string[] = []\n const visit = (node: ts.Node): void => {\n if (\n ts.isVariableDeclaration(node)\n && ts.isVariableStatement(node.parent.parent)\n && node.parent.parent.parent === sourceFile\n && ts.isIdentifier(node.name)\n && node.name.text === variableName\n && node.initializer\n && ts.isArrayLiteralExpression(node.initializer)\n ) {\n declared.push(...node.initializer.elements.flatMap(readModuleEntryId))\n }\n if (options.includePushes && isPushOntoVariable(node, variableName)) {\n declared.push(...node.arguments.flatMap(readModuleEntryId))\n }\n ts.forEachChild(node, visit)\n }\n visit(sourceFile)\n return declared\n}\n\nfunction resolveTestAppRoot(): string | null {\n const configuredTestAppRoot = process.env.OM_TEST_APP_ROOT?.trim()\n return configuredTestAppRoot ? path.resolve(configuredTestAppRoot) : null\n}\n\n/**\n * Every module a standalone test app may register: its `enabledModules` literal, its\n * conditional `enabledModules.push(...)` entries, and its official-module activations.\n * Used to skip specs whose owning module the app does not ship at all.\n */\nfunction resolvePossiblyEnabledTestAppModuleIds(testAppRoot: string): Set<string> {\n return new Set(\n [\n ...readDeclaredModuleIdsFromConfig(path.join(testAppRoot, 'src', 'modules.ts'), { includePushes: true }),\n ...readDeclaredModuleIdsFromConfig(\n path.join(testAppRoot, 'src', 'official-modules.generated.ts'),\n { variableName: 'officialModuleEntries', includePushes: true, optional: true },\n ),\n ].map(normalizeModuleId),\n )\n}\n\nfunction resolveEnabledModuleIds(projectRoot: string): Set<string> {\n const testAppRoot = resolveTestAppRoot()\n if (testAppRoot) {\n return new Set(\n readDeclaredModuleIdsFromConfig(path.join(testAppRoot, 'src', 'modules.ts')).map(normalizeModuleId),\n )\n }\n\n const enabledModules = new Set<string>()\n const appModulesRoot = path.join(projectRoot, 'src', 'modules')\n const appsRoot = path.join(projectRoot, 'apps')\n const packagesRoot = path.join(projectRoot, 'packages')\n const installedPackagesRoot = path.join(projectRoot, 'node_modules', '@open-mercato')\n const enterpriseEnabled = isEnterpriseModulesEnabled()\n\n // Standalone app: src/modules at project root\n collectModuleIdsFromModulesRoot(appModulesRoot, enabledModules)\n\n for (const appName of collectDirectDirectoryNames(appsRoot)) {\n const moduleRoot = path.join(appsRoot, appName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n for (const packageName of collectDirectDirectoryNames(packagesRoot)) {\n if (packageName === 'enterprise' && !enterpriseEnabled) {\n continue\n }\n const moduleRoot = path.join(packagesRoot, packageName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n // Standalone app: installed @open-mercato packages in node_modules\n for (const packageName of collectDirectDirectoryNames(installedPackagesRoot)) {\n if (packageName === 'enterprise' && !enterpriseEnabled) {\n continue\n }\n const moduleRoot = path.join(installedPackagesRoot, packageName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n const createAppTemplateModulesRoot = path.join(projectRoot, 'packages', 'create-app', 'template', 'src', 'modules')\n collectModuleIdsFromModulesRoot(createAppTemplateModulesRoot, enabledModules)\n\n return enabledModules\n}\n\nfunction extractModuleNameFromIntegrationPath(relativePath: string): string | null {\n const segments = normalizePath(relativePath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex <= 0) {\n return null\n }\n const moduleSegment = segments[integrationDirectoryIndex - 1]\n return moduleSegment && moduleSegment.length > 0 ? moduleSegment : null\n}\n\n/**\n * The module a spec belongs to: the directory directly under the closest `modules/`\n * ancestor of `__integration__`, provided that directory is a real module (it ships an\n * `index.ts`/`index.js`). Returns null for specs outside a module, e.g. `packages/ui`.\n */\nfunction resolveOwningModuleId(projectRoot: string, relativeSpecPath: string): string | null {\n const segments = normalizePath(relativeSpecPath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex <= 0) return null\n const modulesSegmentIndex = segments.lastIndexOf('modules', integrationDirectoryIndex - 1)\n if (modulesSegmentIndex === -1 || modulesSegmentIndex + 1 >= integrationDirectoryIndex) return null\n const moduleRoot = path.join(projectRoot, ...segments.slice(0, modulesSegmentIndex + 2))\n const isRealModule = ['index.ts', 'index.js'].some((fileName) => existsSync(path.join(moduleRoot, fileName)))\n return isRealModule ? normalizeModuleId(segments[modulesSegmentIndex + 1]) : null\n}\n\nfunction resolveOverlayRootPath(): string {\n const configured = process.env.OM_INTEGRATION_OVERLAY_ROOT?.trim()\n if (!configured) {\n return DEFAULT_OVERLAY_ROOT\n }\n return configured.replace(/\\/+$/, '')\n}\n\nfunction isOverlayIntegrationPath(relativePath: string, overlayRoot: string): boolean {\n return normalizePath(relativePath).startsWith(`${normalizePath(overlayRoot)}/`)\n}\n\nfunction extractStringArrayFromSource(source: string, keys: readonly string[]): string[] {\n const collected = new Set<string>()\n for (const key of keys) {\n const keyPattern = new RegExp(`${key}\\\\s*:\\\\s*\\\\[([\\\\s\\\\S]*?)\\\\]`, 'm')\n const keyMatch = source.match(keyPattern)\n if (!keyMatch?.[1]) continue\n const valuesPattern = /['\"`]([a-zA-Z0-9_.-]+)['\"`]/g\n for (const valueMatch of keyMatch[1].matchAll(valuesPattern)) {\n const value = String(valueMatch[1] ?? '').trim()\n if (value) {\n collected.add(value)\n }\n }\n }\n return Array.from(collected)\n}\n\nfunction extractDependencyListFromSource(source: string): string[] {\n return extractStringArrayFromSource(source, INTEGRATION_META_DEPENDENCY_KEYS).map(normalizeModuleId)\n}\n\nfunction extractRequiredEnvVarsFromSource(source: string): string[] {\n return extractStringArrayFromSource(source, INTEGRATION_META_REQUIRED_ENV_KEYS)\n}\n\nfunction extractRequiredAnyEnvVarsFromSource(source: string): string[] {\n return extractStringArrayFromSource(source, INTEGRATION_META_REQUIRED_ANY_ENV_KEYS)\n}\n\nfunction readDependenciesFromMetadataFile(absolutePath: string): string[] {\n try {\n return extractDependencyListFromSource(readFileSync(absolutePath, 'utf8'))\n } catch {\n return []\n }\n}\n\nfunction readRequiredEnvVarsFromMetadataFile(absolutePath: string): string[] {\n try {\n return extractRequiredEnvVarsFromSource(readFileSync(absolutePath, 'utf8'))\n } catch {\n return []\n }\n}\n\nfunction readRequiredAnyEnvVarsFromMetadataFile(absolutePath: string): string[] {\n try {\n return extractRequiredAnyEnvVarsFromSource(readFileSync(absolutePath, 'utf8'))\n } catch {\n return []\n }\n}\n\nfunction resolveIntegrationRootDirectory(relativeSpecPath: string): string | null {\n const segments = normalizePath(relativeSpecPath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex === -1) {\n return null\n }\n return segments.slice(0, integrationDirectoryIndex + 1).join('/')\n}\n\nfunction resolveRequiredModulesForSpec(projectRoot: string, relativeSpecPath: string): string[] {\n const requiredModules = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readDependenciesFromMetadataFile(metadataPath).forEach((dependency) => requiredModules.add(dependency))\n }\n }\n }\n\n readDependenciesFromMetadataFile(absoluteSpecPath).forEach((dependency) => requiredModules.add(dependency))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readDependenciesFromMetadataFile(perTestMetadataPath).forEach((dependency) => requiredModules.add(dependency))\n\n return Array.from(requiredModules)\n}\n\nfunction resolveRequiredEnvVarsForSpec(projectRoot: string, relativeSpecPath: string): string[] {\n const requiredEnvVars = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readRequiredEnvVarsFromMetadataFile(metadataPath).forEach((envVar) => requiredEnvVars.add(envVar))\n }\n }\n }\n\n readRequiredEnvVarsFromMetadataFile(absoluteSpecPath).forEach((envVar) => requiredEnvVars.add(envVar))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readRequiredEnvVarsFromMetadataFile(perTestMetadataPath).forEach((envVar) => requiredEnvVars.add(envVar))\n\n return Array.from(requiredEnvVars)\n}\n\nfunction resolveRequiredAnyEnvVarsForSpec(projectRoot: string, relativeSpecPath: string): string[] {\n const requiredAnyEnvVars = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readRequiredAnyEnvVarsFromMetadataFile(metadataPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n }\n }\n }\n\n readRequiredAnyEnvVarsFromMetadataFile(absoluteSpecPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readRequiredAnyEnvVarsFromMetadataFile(perTestMetadataPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n\n return Array.from(requiredAnyEnvVars)\n}\n\nfunction isEnvironmentVariableConfigured(name: string): boolean {\n const value = process.env[name]\n return typeof value === 'string' && value.trim().length > 0\n}\n\nexport function discoverIntegrationSpecFiles(projectRoot: string, legacyIntegrationRoot: string): IntegrationSpecDiscoveryItem[] {\n const discoveredByPath = new Map<string, IntegrationSpecDiscoveryItem>()\n const overlayRoot = resolveOverlayRootPath()\n const enterpriseEnabled = isEnterpriseModulesEnabled()\n const appOnly = isAppOnlyDiscoveryEnabled()\n const discoveryRoots = [\n path.join(projectRoot, 'src', 'modules'),\n path.join(projectRoot, 'apps'),\n path.join(projectRoot, 'packages'),\n ...(appOnly ? [] : [path.join(projectRoot, 'node_modules', '@open-mercato')]),\n ]\n\n for (const specFile of collectSpecFilesFromDirectory(legacyIntegrationRoot)) {\n const relativePath = normalizePath(path.relative(projectRoot, specFile))\n discoveredByPath.set(relativePath, {\n path: relativePath,\n moduleName: extractModuleNameFromIntegrationPath(relativePath),\n isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),\n requiredModules: resolveRequiredModulesForSpec(projectRoot, relativePath),\n requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),\n requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath),\n })\n }\n\n for (const root of discoveryRoots) {\n for (const integrationDirectory of collectNamedDirectories(root, MODULE_INTEGRATION_DIRECTORY_NAME)) {\n for (const specFile of collectSpecFilesFromDirectory(integrationDirectory)) {\n const relativePath = normalizePath(path.relative(projectRoot, specFile))\n discoveredByPath.set(relativePath, {\n path: relativePath,\n moduleName: extractModuleNameFromIntegrationPath(relativePath),\n isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),\n requiredModules: resolveRequiredModulesForSpec(projectRoot, relativePath),\n requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),\n requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath),\n })\n }\n }\n }\n\n const discovered = Array.from(discoveredByPath.values())\n .filter((file) => !appOnly || isAppOwnedIntegrationSpecPath(file.path))\n if (isMetadataFilteringDisabled()) {\n const selected = discovered.sort((left, right) => left.path.localeCompare(right.path))\n writeDiscoverySelectionReport(projectRoot, selected)\n return selected\n }\n const enabledModules = resolveEnabledModuleIds(projectRoot)\n const testAppRoot = resolveTestAppRoot()\n const testAppModules = testAppRoot ? resolvePossiblyEnabledTestAppModuleIds(testAppRoot) : null\n const enabledModuleNames = new Set<string>()\n for (const file of discovered) {\n if (!file.isOverlay && file.moduleName) {\n enabledModuleNames.add(file.moduleName)\n }\n }\n\n return discovered\n .filter((file) => {\n if (file.requiredModules.some((moduleId) => !enabledModules.has(normalizeModuleId(moduleId)))) {\n return false\n }\n if (testAppModules && !file.isOverlay) {\n const owningModuleId = resolveOwningModuleId(projectRoot, file.path)\n if (owningModuleId && !testAppModules.has(owningModuleId)) {\n return false\n }\n }\n if (file.requiredEnvVars.some((envVar) => !isEnvironmentVariableConfigured(envVar))) {\n return false\n }\n if (\n file.requiredAnyEnvVars.length > 0 &&\n !file.requiredAnyEnvVars.some((envVar) => isEnvironmentVariableConfigured(envVar))\n ) {\n return false\n }\n if (!file.isOverlay) {\n return true\n }\n if (!enterpriseEnabled) {\n return false\n }\n if (!file.moduleName) {\n return true\n }\n if (enabledModuleNames.has(file.moduleName)) {\n return true\n }\n return enabledModules.has(normalizeModuleId(file.moduleName))\n })\n .sort((left, right) => left.path.localeCompare(right.path))\n}\n"],
5
- "mappings": "AAAA,SAAS,YAAY,cAAc,aAAa,qBAAqB;AACrE,OAAO,UAAU;AACjB,OAAO,QAAQ;AAWf,MAAM,oCAAoC;AAC1C,MAAM,yBAAyB,oBAAI,IAAI;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,MAAM,8BAA8B,CAAC,WAAW,UAAU;AAC1D,MAAM,mCAAmC,CAAC,oBAAoB,mBAAmB,iBAAiB;AAClG,MAAM,qCAAqC,CAAC,mBAAmB,iBAAiB;AAChF,MAAM,yCAAyC,CAAC,sBAAsB,oBAAoB;AAC1F,MAAM,uBAAuB;AACtB,MAAM,+BAA+B;AACrC,MAAM,4CAA4C;AAClD,MAAM,iDAAiD;AAEvD,SAAS,cAAc,UAA0B;AACtD,SAAO,SAAS,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG;AAC1C;AAEA,SAAS,kBAAkB,UAA0B;AACnD,SAAO,SAAS,KAAK,EAAE,YAAY;AACrC;AAEA,SAAS,6BAAsC;AAC7C,QAAM,WAAW,QAAQ,IAAI,8BAA8B,KAAK,EAAE,YAAY;AAC9E,SAAO,aAAa,UAAU,aAAa,OAAO,aAAa,SAAS,aAAa;AACvF;AAEA,SAAS,4BAAqC;AAC5C,QAAM,WAAW,QAAQ,IAAI,4BAA4B,GAAG,KAAK,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,CAAC;AAAA,EAC9D,CAAC,EACA,KAAK,CAAC,MAAM,UAAU,KAAK,KAAK,cAAc,MAAM,IAAI,CAAC;AAC9D;",
6
- "names": []
4
+ "sourcesContent": ["import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'\nimport path from 'node:path'\nimport ts from 'typescript-js'\n\nexport type IntegrationSpecDiscoveryItem = {\n path: string\n moduleName: string | null\n isOverlay: boolean\n requiredModules: string[]\n requiredEnvVars: string[]\n requiredAnyEnvVars: string[]\n}\n\nconst MODULE_INTEGRATION_DIRECTORY_NAME = '__integration__'\nconst DISCOVERY_IGNORED_DIRS = new Set([\n 'node_modules',\n '.git',\n '.next',\n 'dist',\n '.turbo',\n 'coverage',\n 'test-results',\n '.yarn',\n '.cache',\n 'tmp',\n 'temp',\n '.claude',\n '.codex',\n])\nconst INTEGRATION_META_FILE_NAMES = ['meta.ts', 'index.ts'] as const\nconst INTEGRATION_META_DEPENDENCY_KEYS = ['dependsOnModules', 'requiredModules', 'requiresModules'] as const\nconst INTEGRATION_META_ALL_DEPENDENCY_KEYS = [...INTEGRATION_META_DEPENDENCY_KEYS, 'optionalModules'] as const\nconst INTEGRATION_META_REQUIRED_ENV_KEYS = ['requiredEnvVars', 'requiresEnvVars'] as const\nconst INTEGRATION_META_REQUIRED_ANY_ENV_KEYS = ['requiredAnyEnvVars', 'requiresAnyEnvVars'] as const\nconst DEFAULT_OVERLAY_ROOT = 'packages/enterprise'\nexport const APP_ONLY_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_APP_ONLY'\nexport const SKIP_METADATA_FILTERS_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_SKIP_METADATA_FILTERS'\nexport const DISCOVERY_SELECTION_REPORT_INTEGRATION_ENV_VAR = 'OM_INTEGRATION_DISCOVERY_SELECTION_REPORT'\n\nexport function normalizePath(filePath: string): string {\n return filePath.split(path.sep).join('/')\n}\n\nfunction normalizeModuleId(moduleId: string): string {\n return moduleId.trim().toLowerCase()\n}\n\nfunction isEnterpriseModulesEnabled(): boolean {\n const rawValue = process.env.OM_ENABLE_ENTERPRISE_MODULES?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nfunction isAppOnlyDiscoveryEnabled(): boolean {\n const rawValue = process.env[APP_ONLY_INTEGRATION_ENV_VAR]?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nfunction isMetadataFilteringDisabled(): boolean {\n const rawValue = process.env[SKIP_METADATA_FILTERS_INTEGRATION_ENV_VAR]?.trim().toLowerCase()\n return rawValue === 'true' || rawValue === '1' || rawValue === 'yes' || rawValue === 'on'\n}\n\nexport function isAppOwnedIntegrationSpecPath(relativePath: string): boolean {\n return !normalizePath(relativePath).split('/').includes('node_modules')\n}\n\nfunction writeDiscoverySelectionReport(projectRoot: string, files: readonly IntegrationSpecDiscoveryItem[]): void {\n const reportFile = process.env[DISCOVERY_SELECTION_REPORT_INTEGRATION_ENV_VAR]?.trim()\n if (!reportFile) return\n writeFileSync(reportFile, JSON.stringify({ projectRoot, paths: files.map((file) => file.path) }))\n}\n\nfunction collectNamedDirectories(rootPath: string, directoryName: string): string[] {\n let entries\n try {\n entries = readdirSync(rootPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n\n const collected: string[] = []\n for (const entry of entries) {\n if (!entry.isDirectory()) continue\n if (DISCOVERY_IGNORED_DIRS.has(entry.name)) continue\n const absolutePath = path.join(rootPath, entry.name)\n if (entry.name === directoryName) {\n collected.push(absolutePath)\n }\n collected.push(...collectNamedDirectories(absolutePath, directoryName))\n }\n return collected\n}\n\nfunction collectSpecFilesFromDirectory(directoryPath: string): string[] {\n let entries\n try {\n entries = readdirSync(directoryPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n\n const collected: string[] = []\n for (const entry of entries) {\n const absolutePath = path.join(directoryPath, entry.name)\n if (entry.isDirectory()) {\n collected.push(...collectSpecFilesFromDirectory(absolutePath))\n continue\n }\n if (entry.isFile() && entry.name.endsWith('.spec.ts')) {\n collected.push(absolutePath)\n }\n }\n return collected\n}\n\nfunction collectDirectDirectoryNames(directoryPath: string): string[] {\n let entries\n try {\n entries = readdirSync(directoryPath, { withFileTypes: true, encoding: 'utf8' })\n } catch {\n return []\n }\n return entries\n .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))\n .map((entry) => entry.name)\n}\n\nfunction collectModuleIdsFromModulesRoot(modulesRoot: string, enabledModules: Set<string>): void {\n for (const moduleName of collectDirectDirectoryNames(modulesRoot)) {\n enabledModules.add(normalizeModuleId(moduleName))\n }\n}\n\nfunction readModuleEntryId(element: ts.Expression): string[] {\n if (!ts.isObjectLiteralExpression(element)) return []\n const idProperty = element.properties.find((property): property is ts.PropertyAssignment =>\n ts.isPropertyAssignment(property)\n && (\n (ts.isIdentifier(property.name) && property.name.text === 'id')\n || (ts.isStringLiteralLike(property.name) && property.name.text === 'id')\n ),\n )\n return idProperty && ts.isStringLiteralLike(idProperty.initializer)\n ? [idProperty.initializer.text]\n : []\n}\n\nfunction isPushOntoVariable(node: ts.Node, variableName: string): node is ts.CallExpression {\n return ts.isCallExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && node.expression.name.text === 'push'\n && ts.isIdentifier(node.expression.expression)\n && node.expression.expression.text === variableName\n}\n\n/**\n * Module ids a registry file declares for `variableName`: the entries of its array\n * literal initializer and, with `includePushes`, every `variableName.push({ id })` call.\n * Pushes are usually conditional (enterprise or env-gated modules), so including them\n * yields an upper bound of what the app can register, never narrower than the runtime set.\n */\nfunction readDeclaredModuleIdsFromConfig(\n registryPath: string,\n options: { variableName?: string; includePushes?: boolean; optional?: boolean } = {},\n): string[] {\n const variableName = options.variableName ?? 'enabledModules'\n if (options.optional && !existsSync(registryPath)) return []\n const source = readFileSync(registryPath, 'utf8')\n const sourceFile = ts.createSourceFile(\n registryPath,\n source,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n )\n\n const declared: string[] = []\n const visit = (node: ts.Node): void => {\n if (\n ts.isVariableDeclaration(node)\n && ts.isVariableStatement(node.parent.parent)\n && node.parent.parent.parent === sourceFile\n && ts.isIdentifier(node.name)\n && node.name.text === variableName\n && node.initializer\n && ts.isArrayLiteralExpression(node.initializer)\n ) {\n declared.push(...node.initializer.elements.flatMap(readModuleEntryId))\n }\n if (options.includePushes && isPushOntoVariable(node, variableName)) {\n declared.push(...node.arguments.flatMap(readModuleEntryId))\n }\n ts.forEachChild(node, visit)\n }\n visit(sourceFile)\n return declared\n}\n\nfunction resolveTestAppRoot(): string | null {\n const configuredTestAppRoot = process.env.OM_TEST_APP_ROOT?.trim()\n return configuredTestAppRoot ? path.resolve(configuredTestAppRoot) : null\n}\n\n/**\n * Every module a standalone test app may register: its `enabledModules` literal, its\n * conditional `enabledModules.push(...)` entries, and its official-module activations.\n * Used to skip specs whose owning module the app does not ship at all.\n */\nfunction resolvePossiblyEnabledTestAppModuleIds(testAppRoot: string): Set<string> {\n return new Set(\n [\n ...readDeclaredModuleIdsFromConfig(path.join(testAppRoot, 'src', 'modules.ts'), { includePushes: true }),\n ...readDeclaredModuleIdsFromConfig(\n path.join(testAppRoot, 'src', 'official-modules.generated.ts'),\n { variableName: 'officialModuleEntries', includePushes: true, optional: true },\n ),\n ].map(normalizeModuleId),\n )\n}\n\nfunction resolveEnabledModuleIds(projectRoot: string): Set<string> {\n const testAppRoot = resolveTestAppRoot()\n if (testAppRoot) {\n return new Set(\n readDeclaredModuleIdsFromConfig(path.join(testAppRoot, 'src', 'modules.ts')).map(normalizeModuleId),\n )\n }\n\n const enabledModules = new Set<string>()\n const appModulesRoot = path.join(projectRoot, 'src', 'modules')\n const appsRoot = path.join(projectRoot, 'apps')\n const packagesRoot = path.join(projectRoot, 'packages')\n const installedPackagesRoot = path.join(projectRoot, 'node_modules', '@open-mercato')\n const enterpriseEnabled = isEnterpriseModulesEnabled()\n\n // Standalone app: src/modules at project root\n collectModuleIdsFromModulesRoot(appModulesRoot, enabledModules)\n\n for (const appName of collectDirectDirectoryNames(appsRoot)) {\n const moduleRoot = path.join(appsRoot, appName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n for (const packageName of collectDirectDirectoryNames(packagesRoot)) {\n if (packageName === 'enterprise' && !enterpriseEnabled) {\n continue\n }\n const moduleRoot = path.join(packagesRoot, packageName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n // Standalone app: installed @open-mercato packages in node_modules\n for (const packageName of collectDirectDirectoryNames(installedPackagesRoot)) {\n if (packageName === 'enterprise' && !enterpriseEnabled) {\n continue\n }\n const moduleRoot = path.join(installedPackagesRoot, packageName, 'src', 'modules')\n collectModuleIdsFromModulesRoot(moduleRoot, enabledModules)\n }\n const createAppTemplateModulesRoot = path.join(projectRoot, 'packages', 'create-app', 'template', 'src', 'modules')\n collectModuleIdsFromModulesRoot(createAppTemplateModulesRoot, enabledModules)\n\n return enabledModules\n}\n\nfunction extractModuleNameFromIntegrationPath(relativePath: string): string | null {\n const segments = normalizePath(relativePath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex <= 0) {\n return null\n }\n const moduleSegment = segments[integrationDirectoryIndex - 1]\n return moduleSegment && moduleSegment.length > 0 ? moduleSegment : null\n}\n\n/**\n * The module a spec belongs to: the directory directly under the closest `modules/`\n * ancestor of `__integration__`, provided that directory is a real module (it ships an\n * `index.ts`/`index.js`). Returns null for specs outside a module, e.g. `packages/ui`.\n */\nfunction resolveOwningModuleId(projectRoot: string, relativeSpecPath: string): string | null {\n const segments = normalizePath(relativeSpecPath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex <= 0) return null\n const modulesSegmentIndex = segments.lastIndexOf('modules', integrationDirectoryIndex - 1)\n if (modulesSegmentIndex === -1 || modulesSegmentIndex + 1 >= integrationDirectoryIndex) return null\n const moduleRoot = path.join(projectRoot, ...segments.slice(0, modulesSegmentIndex + 2))\n const isRealModule = ['index.ts', 'index.js'].some((fileName) => existsSync(path.join(moduleRoot, fileName)))\n return isRealModule ? normalizeModuleId(segments[modulesSegmentIndex + 1]) : null\n}\n\nfunction resolveOverlayRootPath(): string {\n const configured = process.env.OM_INTEGRATION_OVERLAY_ROOT?.trim()\n if (!configured) {\n return DEFAULT_OVERLAY_ROOT\n }\n return configured.replace(/\\/+$/, '')\n}\n\nfunction isOverlayIntegrationPath(relativePath: string, overlayRoot: string): boolean {\n return normalizePath(relativePath).startsWith(`${normalizePath(overlayRoot)}/`)\n}\n\nfunction extractStringArrayFromSource(source: string, keys: readonly string[]): string[] {\n const collected = new Set<string>()\n for (const key of keys) {\n const keyPattern = new RegExp(`${key}\\\\s*:\\\\s*\\\\[([\\\\s\\\\S]*?)\\\\]`, 'm')\n const keyMatch = source.match(keyPattern)\n if (!keyMatch?.[1]) continue\n const valuesPattern = /['\"`]([a-zA-Z0-9_.-]+)['\"`]/g\n for (const valueMatch of keyMatch[1].matchAll(valuesPattern)) {\n const value = String(valueMatch[1] ?? '').trim()\n if (value) {\n collected.add(value)\n }\n }\n }\n return Array.from(collected)\n}\n\nfunction extractDependencyListFromSource(source: string, includeOptional: boolean): string[] {\n const keys = includeOptional ? INTEGRATION_META_ALL_DEPENDENCY_KEYS : INTEGRATION_META_DEPENDENCY_KEYS\n return extractStringArrayFromSource(source, keys).map(normalizeModuleId)\n}\n\nfunction extractRequiredEnvVarsFromSource(source: string): string[] {\n return extractStringArrayFromSource(source, INTEGRATION_META_REQUIRED_ENV_KEYS)\n}\n\nfunction extractRequiredAnyEnvVarsFromSource(source: string): string[] {\n return extractStringArrayFromSource(source, INTEGRATION_META_REQUIRED_ANY_ENV_KEYS)\n}\n\nfunction readDependenciesFromMetadataFile(absolutePath: string, includeOptional: boolean): string[] {\n try {\n return extractDependencyListFromSource(readFileSync(absolutePath, 'utf8'), includeOptional)\n } catch {\n return []\n }\n}\n\nfunction readRequiredEnvVarsFromMetadataFile(absolutePath: string): string[] {\n try {\n return extractRequiredEnvVarsFromSource(readFileSync(absolutePath, 'utf8'))\n } catch {\n return []\n }\n}\n\nfunction readRequiredAnyEnvVarsFromMetadataFile(absolutePath: string): string[] {\n try {\n return extractRequiredAnyEnvVarsFromSource(readFileSync(absolutePath, 'utf8'))\n } catch {\n return []\n }\n}\n\nfunction resolveIntegrationRootDirectory(relativeSpecPath: string): string | null {\n const segments = normalizePath(relativeSpecPath).split('/')\n const integrationDirectoryIndex = segments.indexOf(MODULE_INTEGRATION_DIRECTORY_NAME)\n if (integrationDirectoryIndex === -1) {\n return null\n }\n return segments.slice(0, integrationDirectoryIndex + 1).join('/')\n}\n\nexport function resolveModuleDependenciesForSpec(\n projectRoot: string,\n relativeSpecPath: string,\n { includeOptional = false }: { includeOptional?: boolean } = {},\n): string[] {\n const requiredModules = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readDependenciesFromMetadataFile(metadataPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))\n }\n }\n }\n\n readDependenciesFromMetadataFile(absoluteSpecPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readDependenciesFromMetadataFile(perTestMetadataPath, includeOptional).forEach((dependency) => requiredModules.add(dependency))\n\n return Array.from(requiredModules)\n}\n\nfunction resolveRequiredEnvVarsForSpec(projectRoot: string, relativeSpecPath: string): string[] {\n const requiredEnvVars = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readRequiredEnvVarsFromMetadataFile(metadataPath).forEach((envVar) => requiredEnvVars.add(envVar))\n }\n }\n }\n\n readRequiredEnvVarsFromMetadataFile(absoluteSpecPath).forEach((envVar) => requiredEnvVars.add(envVar))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readRequiredEnvVarsFromMetadataFile(perTestMetadataPath).forEach((envVar) => requiredEnvVars.add(envVar))\n\n return Array.from(requiredEnvVars)\n}\n\nfunction resolveRequiredAnyEnvVarsForSpec(projectRoot: string, relativeSpecPath: string): string[] {\n const requiredAnyEnvVars = new Set<string>()\n const normalizedSpecPath = normalizePath(relativeSpecPath)\n const absoluteSpecPath = path.join(projectRoot, normalizedSpecPath)\n const integrationRoot = resolveIntegrationRootDirectory(normalizedSpecPath)\n\n if (integrationRoot) {\n const relativeDirectory = normalizePath(path.dirname(normalizedSpecPath))\n const integrationRootAbsolute = path.join(projectRoot, integrationRoot)\n const directoryAbsolute = path.join(projectRoot, relativeDirectory)\n const relativeFromIntegrationRoot = normalizePath(path.relative(integrationRootAbsolute, directoryAbsolute))\n const pathSegments = relativeFromIntegrationRoot === '.'\n ? []\n : relativeFromIntegrationRoot.split('/').filter(Boolean)\n\n let currentDirectory = integrationRootAbsolute\n const traversal = [currentDirectory, ...pathSegments.map((segment) => {\n currentDirectory = path.join(currentDirectory, segment)\n return currentDirectory\n })]\n\n for (const directoryPath of traversal) {\n for (const metadataFileName of INTEGRATION_META_FILE_NAMES) {\n const metadataPath = path.join(directoryPath, metadataFileName)\n readRequiredAnyEnvVarsFromMetadataFile(metadataPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n }\n }\n }\n\n readRequiredAnyEnvVarsFromMetadataFile(absoluteSpecPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n const specFileName = path.basename(normalizedSpecPath, '.spec.ts')\n const perTestMetadataPath = path.join(path.dirname(absoluteSpecPath), `${specFileName}.meta.ts`)\n readRequiredAnyEnvVarsFromMetadataFile(perTestMetadataPath).forEach((envVar) => requiredAnyEnvVars.add(envVar))\n\n return Array.from(requiredAnyEnvVars)\n}\n\nfunction isEnvironmentVariableConfigured(name: string): boolean {\n const value = process.env[name]\n return typeof value === 'string' && value.trim().length > 0\n}\n\nexport function discoverIntegrationSpecFiles(projectRoot: string, legacyIntegrationRoot: string): IntegrationSpecDiscoveryItem[] {\n const discoveredByPath = new Map<string, IntegrationSpecDiscoveryItem>()\n const overlayRoot = resolveOverlayRootPath()\n const enterpriseEnabled = isEnterpriseModulesEnabled()\n const appOnly = isAppOnlyDiscoveryEnabled()\n const discoveryRoots = [\n path.join(projectRoot, 'src', 'modules'),\n path.join(projectRoot, 'apps'),\n path.join(projectRoot, 'packages'),\n ...(appOnly ? [] : [path.join(projectRoot, 'node_modules', '@open-mercato')]),\n ]\n\n for (const specFile of collectSpecFilesFromDirectory(legacyIntegrationRoot)) {\n const relativePath = normalizePath(path.relative(projectRoot, specFile))\n discoveredByPath.set(relativePath, {\n path: relativePath,\n moduleName: extractModuleNameFromIntegrationPath(relativePath),\n isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),\n requiredModules: resolveModuleDependenciesForSpec(projectRoot, relativePath),\n requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),\n requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath),\n })\n }\n\n for (const root of discoveryRoots) {\n for (const integrationDirectory of collectNamedDirectories(root, MODULE_INTEGRATION_DIRECTORY_NAME)) {\n for (const specFile of collectSpecFilesFromDirectory(integrationDirectory)) {\n const relativePath = normalizePath(path.relative(projectRoot, specFile))\n discoveredByPath.set(relativePath, {\n path: relativePath,\n moduleName: extractModuleNameFromIntegrationPath(relativePath),\n isOverlay: isOverlayIntegrationPath(relativePath, overlayRoot),\n requiredModules: resolveModuleDependenciesForSpec(projectRoot, relativePath),\n requiredEnvVars: resolveRequiredEnvVarsForSpec(projectRoot, relativePath),\n requiredAnyEnvVars: resolveRequiredAnyEnvVarsForSpec(projectRoot, relativePath),\n })\n }\n }\n }\n\n const discovered = Array.from(discoveredByPath.values())\n .filter((file) => !appOnly || isAppOwnedIntegrationSpecPath(file.path))\n if (isMetadataFilteringDisabled()) {\n const selected = discovered.sort((left, right) => left.path.localeCompare(right.path))\n writeDiscoverySelectionReport(projectRoot, selected)\n return selected\n }\n const enabledModules = resolveEnabledModuleIds(projectRoot)\n const testAppRoot = resolveTestAppRoot()\n const testAppModules = testAppRoot ? resolvePossiblyEnabledTestAppModuleIds(testAppRoot) : null\n const enabledModuleNames = new Set<string>()\n for (const file of discovered) {\n if (!file.isOverlay && file.moduleName) {\n enabledModuleNames.add(file.moduleName)\n }\n }\n\n const selected = discovered\n .filter((file) => {\n if (file.requiredModules.some((moduleId) => !enabledModules.has(normalizeModuleId(moduleId)))) {\n return false\n }\n if (testAppModules && !file.isOverlay) {\n const owningModuleId = resolveOwningModuleId(projectRoot, file.path)\n if (owningModuleId && !testAppModules.has(owningModuleId)) {\n return false\n }\n }\n if (file.requiredEnvVars.some((envVar) => !isEnvironmentVariableConfigured(envVar))) {\n return false\n }\n if (\n file.requiredAnyEnvVars.length > 0 &&\n !file.requiredAnyEnvVars.some((envVar) => isEnvironmentVariableConfigured(envVar))\n ) {\n return false\n }\n if (!file.isOverlay) {\n return true\n }\n if (!enterpriseEnabled) {\n return false\n }\n if (!file.moduleName) {\n return true\n }\n if (enabledModuleNames.has(file.moduleName)) {\n return true\n }\n return enabledModules.has(normalizeModuleId(file.moduleName))\n })\n .sort((left, right) => left.path.localeCompare(right.path))\n writeDiscoverySelectionReport(projectRoot, selected)\n return selected\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAY,cAAc,aAAa,qBAAqB;AACrE,OAAO,UAAU;AACjB,OAAO,QAAQ;AAWf,MAAM,oCAAoC;AAC1C,MAAM,yBAAyB,oBAAI,IAAI;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,MAAM,8BAA8B,CAAC,WAAW,UAAU;AAC1D,MAAM,mCAAmC,CAAC,oBAAoB,mBAAmB,iBAAiB;AAClG,MAAM,uCAAuC,CAAC,GAAG,kCAAkC,iBAAiB;AACpG,MAAM,qCAAqC,CAAC,mBAAmB,iBAAiB;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