@open-mercato/cli 0.6.7 → 0.6.8-develop.6875.1.871a4afc94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -4
- package/build.mjs +24 -7
- package/dist/agentic/claude-code/hooks/entity-migration-check.ts +32 -88
- package/dist/agentic/codex/enforcement-rules.md +2 -16
- package/dist/agentic/cursor/hooks/entity-migration-check.mjs +19 -50
- package/dist/agentic/cursor/rules/entity-guard.mdc +9 -21
- package/dist/agentic/cursor/rules/generated-guard.mdc +3 -5
- package/dist/agentic/cursor/rules/open-mercato.mdc +3 -29
- package/dist/agentic/guides/ai-workflows.md +76 -0
- package/dist/agentic/guides/architecture.md +107 -0
- package/dist/agentic/guides/backend-ui.md +80 -0
- package/dist/agentic/guides/contracts.md +92 -0
- package/dist/agentic/guides/extensions.md +121 -0
- package/dist/agentic/guides/framework-extension-points.md +36 -0
- package/dist/agentic/guides/integrations.md +81 -0
- package/dist/agentic/guides/module-facts.json +115537 -3951
- package/dist/agentic/guides/module-system.md +12 -127
- package/dist/agentic/guides/modules/ai_assistant.md +227 -28
- package/dist/agentic/guides/modules/api_docs.md +58 -2
- package/dist/agentic/guides/modules/api_keys.md +92 -7
- package/dist/agentic/guides/modules/attachments.md +119 -14
- package/dist/agentic/guides/modules/audit_logs.md +131 -10
- package/dist/agentic/guides/modules/auth.md +276 -33
- package/dist/agentic/guides/modules/business_rules.md +149 -14
- package/dist/agentic/guides/modules/catalog.md +475 -43
- package/dist/agentic/guides/modules/channel_gmail.md +82 -3
- package/dist/agentic/guides/modules/channel_imap.md +82 -3
- package/dist/agentic/guides/modules/checkout.md +299 -27
- package/dist/agentic/guides/modules/communication_channels.md +315 -33
- package/dist/agentic/guides/modules/configs.md +104 -8
- package/dist/agentic/guides/modules/content.md +57 -2
- package/dist/agentic/guides/modules/currencies.md +152 -17
- package/dist/agentic/guides/modules/customer_accounts.md +387 -45
- package/dist/agentic/guides/modules/customers.md +746 -85
- package/dist/agentic/guides/modules/dashboards.md +155 -10
- package/dist/agentic/guides/modules/data_sync.md +149 -16
- package/dist/agentic/guides/modules/design_system.md +102 -0
- package/dist/agentic/guides/modules/dictionaries.md +107 -12
- package/dist/agentic/guides/modules/directory.md +148 -15
- package/dist/agentic/guides/modules/entities.md +145 -13
- package/dist/agentic/guides/modules/events.md +59 -2
- package/dist/agentic/guides/modules/feature_toggles.md +119 -9
- package/dist/agentic/guides/modules/gateway_stripe.md +92 -4
- package/dist/agentic/guides/modules/generators.md +45 -2
- package/dist/agentic/guides/modules/inbox_ops.md +207 -27
- package/dist/agentic/guides/modules/integrations.md +146 -16
- package/dist/agentic/guides/modules/messages.md +223 -24
- package/dist/agentic/guides/modules/notifications.md +96 -8
- package/dist/agentic/guides/modules/onboarding.md +77 -6
- package/dist/agentic/guides/modules/payment_gateways.md +164 -21
- package/dist/agentic/guides/modules/perspectives.md +77 -7
- package/dist/agentic/guides/modules/planner.md +136 -18
- package/dist/agentic/guides/modules/portal.md +93 -2
- package/dist/agentic/guides/modules/progress.md +104 -14
- package/dist/agentic/guides/modules/query_index.md +154 -15
- package/dist/agentic/guides/modules/record_locks.md +206 -21
- package/dist/agentic/guides/modules/resources.md +197 -30
- package/dist/agentic/guides/modules/sales.md +678 -84
- package/dist/agentic/guides/modules/scheduler.md +133 -14
- package/dist/agentic/guides/modules/search.md +170 -6
- package/dist/agentic/guides/modules/security.md +294 -35
- package/dist/agentic/guides/modules/shipping_carriers.md +134 -18
- package/dist/agentic/guides/modules/sso.md +151 -26
- package/dist/agentic/guides/modules/staff.md +369 -57
- package/dist/agentic/guides/modules/storage_s3.md +95 -5
- package/dist/agentic/guides/modules/sync_akeneo.md +85 -3
- package/dist/agentic/guides/modules/sync_excel.md +75 -6
- package/dist/agentic/guides/modules/system_status_overlays.md +60 -2
- package/dist/agentic/guides/modules/translations.md +104 -10
- package/dist/agentic/guides/modules/webhooks.md +203 -24
- package/dist/agentic/guides/modules/wms.md +441 -46
- package/dist/agentic/guides/modules/workflows.md +302 -43
- package/dist/agentic/guides/spec-delivery.md +22 -0
- package/dist/agentic/guides/testing-debugging.md +80 -0
- package/dist/agentic/guides/upstream/AGENTS.md +299 -0
- package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +316 -0
- package/dist/agentic/guides/upstream/manifest.json +8 -0
- package/dist/agentic/shared/AGENTS.md.template +124 -311
- package/dist/agentic/shared/ai/agentic.config.json +2 -0
- package/dist/agentic/shared/ai/harness/README.md +50 -0
- package/dist/agentic/shared/ai/harness/RELEASE.md +57 -0
- package/dist/agentic/shared/ai/harness/cases.json +13680 -0
- package/dist/agentic/shared/ai/harness/cases.schema.json +133 -0
- package/dist/agentic/shared/ai/harness/fixtures/index.json +49 -0
- package/dist/agentic/shared/ai/harness/fixtures/seeds.json +162 -0
- package/dist/agentic/shared/ai/harness/generated-code-review-policy.md +21 -0
- package/dist/agentic/shared/ai/harness/generated-code-review-response.schema.json +96 -0
- package/dist/agentic/shared/ai/harness/generated-code-review-result.schema.json +172 -0
- package/dist/agentic/shared/ai/harness/release-matrix.json +158 -0
- package/dist/agentic/shared/ai/harness/release-result.schema.json +219 -0
- package/dist/agentic/shared/ai/harness/result.schema.json +76 -0
- package/dist/agentic/shared/ai/harness/routing-response.schema.json +12 -0
- package/dist/agentic/shared/ai/harness/target-validation-result.schema.json +73 -0
- package/dist/agentic/shared/ai/harness/validators.json +78 -0
- package/dist/agentic/shared/ai/harness/writable-ast-oracles.mjs +2121 -0
- package/dist/agentic/shared/ai/harness/writable-behavior-oracles.mjs +1096 -0
- package/dist/agentic/shared/ai/lessons/_template.md +16 -0
- package/dist/agentic/shared/ai/lessons.md +26 -3
- package/dist/agentic/shared/ai/review-checklist.md +36 -0
- package/dist/agentic/shared/ai/skills/om-auto-implement-spec/SKILL.md +21 -0
- package/dist/agentic/shared/ai/skills/om-auto-review-pr/SKILL.md +4 -0
- package/dist/agentic/shared/ai/skills/om-auto-upgrade-0.6.6-to-0.6.7/SKILL.md +98 -0
- package/dist/agentic/shared/ai/skills/om-backend-ui-design/SKILL.md +20 -241
- package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/crud-surfaces.md +16 -0
- package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/frontend-and-design-system.md +53 -0
- package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/page-and-navigation.md +13 -0
- package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/quality-states.md +11 -0
- package/dist/agentic/shared/ai/skills/om-build-workflow/SKILL.md +30 -0
- package/dist/agentic/shared/ai/skills/om-build-workflow/references/activity-contracts.md +12 -0
- package/dist/agentic/shared/ai/skills/om-build-workflow/references/durability-and-progress.md +13 -0
- package/dist/agentic/shared/ai/skills/om-build-workflow/references/workflow-design.md +14 -0
- package/dist/agentic/shared/ai/skills/om-create-ai-agent/SKILL.md +28 -0
- package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/attachments-and-overrides.md +12 -0
- package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/module-agents-and-tools.md +22 -0
- package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/orchestrator-agents.md +12 -0
- package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/surface-selector.md +19 -0
- package/dist/agentic/shared/ai/skills/om-data-model-design/SKILL.md +16 -601
- package/dist/agentic/shared/ai/skills/om-data-model-design/references/integrity-and-concurrency.md +19 -0
- package/dist/agentic/shared/ai/skills/om-data-model-design/references/migration-workflow.md +13 -0
- package/dist/agentic/shared/ai/skills/om-data-model-design/references/schema-design.md +14 -0
- package/dist/agentic/shared/ai/skills/om-data-model-design/references/sensitive-data.md +10 -0
- package/dist/agentic/shared/ai/skills/om-eject-and-customize/SKILL.md +14 -310
- package/dist/agentic/shared/ai/skills/om-eject-and-customize/references/decision-and-procedure.md +17 -0
- package/dist/agentic/shared/ai/skills/om-evolve-harness/SKILL.md +29 -0
- package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-template.md +100 -0
- package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-workflow.md +16 -0
- package/dist/agentic/shared/ai/skills/om-evolve-harness/references/owner-selection.md +17 -0
- package/dist/agentic/shared/ai/skills/om-framework-context/SKILL.md +25 -0
- package/dist/agentic/shared/ai/skills/om-framework-context/references/resolver-procedure.md +11 -0
- package/dist/agentic/shared/ai/skills/om-framework-context/references/skew-and-escalation.md +13 -0
- package/dist/agentic/shared/ai/skills/om-help/SKILL.md +15 -97
- package/dist/agentic/shared/ai/skills/om-help/references/delivery-workflows.md +18 -0
- package/dist/agentic/shared/ai/skills/om-help/references/task-families.md +20 -0
- package/dist/agentic/shared/ai/skills/om-implement-spec/SKILL.md +33 -152
- package/dist/agentic/shared/ai/skills/om-implement-spec/references/phases-and-gates.md +33 -0
- package/dist/agentic/shared/ai/skills/om-implement-spec/references/planning-and-progress.md +40 -0
- package/dist/agentic/shared/ai/skills/om-implement-spec/references/report-templates.md +27 -0
- package/dist/agentic/shared/ai/skills/om-implement-spec/references/spec-resolution.md +24 -0
- package/dist/agentic/shared/ai/skills/om-integration-builder/SKILL.md +24 -708
- package/dist/agentic/shared/ai/skills/om-integration-builder/references/package-and-activation.md +16 -0
- package/dist/agentic/shared/ai/skills/om-integration-builder/references/provider-families.md +14 -0
- package/dist/agentic/shared/ai/skills/om-integration-builder/references/security-and-reliability.md +15 -0
- package/dist/agentic/shared/ai/skills/om-integration-builder/references/sync-and-files.md +12 -0
- package/dist/agentic/shared/ai/skills/om-judge-agent-session/SKILL.md +34 -0
- package/dist/agentic/shared/ai/skills/om-judge-agent-session/agents/openai.yaml +4 -0
- package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/agentic-setup.md +11 -0
- package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/input-normalization.md +31 -0
- package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/judge-workflow.md +39 -0
- package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/report-template.md +43 -0
- package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/rules.md +11 -0
- package/dist/agentic/shared/ai/skills/om-module-scaffold/SKILL.md +20 -820
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/api-and-domain.md +19 -0
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/business-one-shot-blueprints.md +172 -0
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/data-and-migrations.md +12 -0
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/discovery-surface-catalog.md +83 -0
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/module-surfaces.md +21 -0
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/planning.md +11 -0
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/runtime-cache-and-queues.md +22 -0
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/verification.md +13 -0
- package/dist/agentic/shared/ai/skills/om-share-this-session/SKILL.md +41 -0
- package/dist/agentic/shared/ai/skills/om-share-this-session/references/agentic-setup.md +19 -0
- package/dist/agentic/shared/ai/skills/om-share-this-session/references/bundle-preparation.md +44 -0
- package/dist/agentic/shared/ai/skills/om-share-this-session/references/consent-and-review.md +39 -0
- package/dist/agentic/shared/ai/skills/om-share-this-session/references/publication.md +20 -0
- package/dist/agentic/shared/ai/skills/om-share-this-session/references/report-templates.md +57 -0
- package/dist/agentic/shared/ai/skills/om-share-this-session/references/rules.md +11 -0
- package/dist/agentic/shared/ai/skills/om-share-this-session/scripts/prepare-share-bundle.mjs +486 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/SKILL.md +19 -843
- package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +18 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/mechanism-selector.md +27 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/read-write-roundtrip.md +13 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +41 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/verification.md +11 -0
- package/dist/agentic/shared/ai/skills/om-trim-unused-modules/SKILL.md +15 -63
- package/dist/agentic/shared/ai/skills/om-trim-unused-modules/references/dependency-and-redirect.md +15 -0
- package/dist/agentic/shared/ai/skills/om-troubleshooter/SKILL.md +16 -467
- package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnosis-map.md +16 -0
- package/dist/agentic/shared/ai/skills/om-troubleshooter/references/regression-oracles.md +14 -0
- package/dist/agentic/shared/ai/skills/tiers.json +143 -21
- package/dist/agentic/shared/ai/skills/tiers.schema.json +52 -40
- package/dist/agentic/shared/ai/specs/README.md +4 -3
- package/dist/agentic/shared/ai/specs/SPEC-000-template.md +226 -10
- package/dist/agentic/shared/ai/trackers/github.md +108 -4
- package/dist/agentic/shared/scripts/agent-harness-tool-server.mjs +187 -0
- package/dist/agentic/shared/scripts/check-lessons.mjs +178 -0
- package/dist/agentic/shared/scripts/evaluate-agent-harness.mjs +2958 -0
- package/dist/agentic/shared/scripts/execution-sandbox.mjs +329 -0
- package/dist/agentic/shared/scripts/framework-context.mjs +888 -0
- package/dist/agentic/shared/scripts/install-skills.mjs +1029 -0
- package/dist/agentic/shared/scripts/install-skills.sh +4 -694
- package/dist/agentic/shared/scripts/prepare-agent-harness-fixture.mjs +222 -0
- package/dist/agentic/shared/scripts/run-agent-harness-release.mjs +1774 -0
- package/dist/bin.js +13 -1
- package/dist/bin.js.map +2 -2
- package/dist/lib/__integration__/TC-INT-008.spec.js +88 -8
- package/dist/lib/__integration__/TC-INT-008.spec.js.map +2 -2
- package/dist/lib/agentic-init.js +13 -3
- package/dist/lib/agentic-init.js.map +2 -2
- package/dist/lib/agentic-setup.js +434 -186
- package/dist/lib/agentic-setup.js.map +2 -2
- package/dist/lib/generators/extensions/injection-widgets.js +20 -0
- package/dist/lib/generators/extensions/injection-widgets.js.map +2 -2
- package/dist/lib/generators/module-extension-facts.js +1840 -0
- package/dist/lib/generators/module-extension-facts.js.map +7 -0
- package/dist/lib/generators/module-fact-sources.js +70 -0
- package/dist/lib/generators/module-fact-sources.js.map +7 -0
- package/dist/lib/generators/module-facts-discovery.js +41 -7
- package/dist/lib/generators/module-facts-discovery.js.map +2 -2
- package/dist/lib/generators/module-facts.js +1387 -45
- package/dist/lib/generators/module-facts.js.map +3 -3
- package/dist/lib/generators/module-override-targets.js +688 -0
- package/dist/lib/generators/module-override-targets.js.map +7 -0
- package/dist/lib/generators/module-registry.js +11 -5
- package/dist/lib/generators/module-registry.js.map +2 -2
- package/dist/lib/load-env.js +24 -0
- package/dist/lib/load-env.js.map +7 -0
- package/dist/lib/resolver.js +2 -0
- package/dist/lib/resolver.js.map +2 -2
- package/dist/lib/telemetry-init.js +358 -0
- package/dist/lib/telemetry-init.js.map +7 -0
- package/dist/lib/testing/integration.js +5 -0
- package/dist/lib/testing/integration.js.map +2 -2
- package/dist/mercato.js +23 -1
- package/dist/mercato.js.map +2 -2
- package/package.json +13 -11
- package/src/bin.ts +33 -1
- package/src/lib/__integration__/TC-INT-008.spec.ts +107 -9
- package/src/lib/__tests__/agentic-init.test.ts +41 -5
- package/src/lib/__tests__/agentic-setup.ownership.test.ts +386 -0
- package/src/lib/__tests__/injection-widget-id-validation.test.ts +184 -0
- package/src/lib/__tests__/load-env.test.ts +65 -0
- package/src/lib/__tests__/telemetry-init.test.ts +298 -0
- package/src/lib/agentic-init.ts +15 -3
- package/src/lib/agentic-setup.ts +573 -222
- package/src/lib/generators/__tests__/activation-adapter-coverage.test.ts +92 -0
- package/src/lib/generators/__tests__/module-extension-activations.test.ts +762 -0
- package/src/lib/generators/__tests__/module-extension-facts.test.ts +404 -0
- package/src/lib/generators/__tests__/module-facts.bc-guard.test.ts +88 -2
- package/src/lib/generators/__tests__/module-facts.customers.fixture.test.ts +1 -0
- package/src/lib/generators/__tests__/module-facts.discovery.test.ts +54 -10
- package/src/lib/generators/__tests__/module-facts.extension-hosts.test.ts +108 -0
- package/src/lib/generators/__tests__/module-facts.owned-contracts.test.ts +561 -0
- package/src/lib/generators/__tests__/module-facts.source-links.test.ts +119 -0
- package/src/lib/generators/__tests__/module-override-targets.roundtrip.test.ts +149 -0
- package/src/lib/generators/__tests__/module-override-targets.test.ts +304 -0
- package/src/lib/generators/__tests__/module-subset.test.ts +18 -0
- package/src/lib/generators/extensions/injection-widgets.ts +51 -0
- package/src/lib/generators/module-extension-facts.ts +2365 -0
- package/src/lib/generators/module-fact-sources.ts +108 -0
- package/src/lib/generators/module-facts-discovery.ts +58 -7
- package/src/lib/generators/module-facts.ts +1851 -46
- package/src/lib/generators/module-override-targets.ts +863 -0
- package/src/lib/generators/module-registry.ts +16 -6
- package/src/lib/load-env.ts +30 -0
- package/src/lib/resolver.ts +3 -0
- package/src/lib/telemetry-init.ts +461 -0
- package/src/lib/testing/__tests__/integration.test.ts +4 -0
- package/src/lib/testing/integration.ts +5 -0
- package/src/mercato.ts +26 -1
- package/dist/agentic/guides/cache.md +0 -45
- package/dist/agentic/guides/core.md +0 -453
- package/dist/agentic/guides/events.md +0 -117
- package/dist/agentic/guides/queue.md +0 -53
- package/dist/agentic/guides/search.md +0 -115
- package/dist/agentic/guides/shared.md +0 -108
- package/dist/agentic/guides/ui.md +0 -347
- package/dist/agentic/shared/ai/skills/om-auto-continue-pr-loop/SKILL.md +0 -27
- package/dist/agentic/shared/ai/skills/om-auto-create-pr-loop/SKILL.md +0 -27
- package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/ui-components.md +0 -260
- package/dist/agentic/shared/ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md +0 -146
- package/dist/agentic/shared/ai/skills/om-help/references/skills-catalog.md +0 -84
- package/dist/agentic/shared/ai/skills/om-help/references/workflow-sequences.md +0 -193
- package/dist/agentic/shared/ai/skills/om-integration-builder/STANDALONE.md +0 -34
- package/dist/agentic/shared/ai/skills/om-integration-builder/references/adapter-contracts.md +0 -762
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/naming-conventions.md +0 -50
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/navigation-patterns.md +0 -97
- package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-contracts.md +0 -271
- package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnostic-commands.md +0 -101
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/generators/module-extension-facts.ts"],
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport ts from 'typescript-js'\nimport {\n CRUD_FORM_EXTENSION_SURFACES,\n CRUD_FORM_LIFECYCLE_PHASES,\n DATA_TABLE_EXTENSION_SURFACES,\n} from '@open-mercato/shared/modules/widgets/extension-points'\nimport type {\n ExtensionHostCapability,\n ExtensionHostFamily,\n ModuleContributionResolution,\n ModuleExtensionActivation,\n ModuleExtensionActivationKind,\n ModuleExtensionContributionFact,\n ModuleExtensionContributionBase,\n ModuleExtensionContributionKind,\n ModuleExtensionHostFact,\n ModuleExtensionResolution,\n ModuleExtensionSurfaceFacts,\n ModuleExtensionTargetFact,\n ModuleExtensionTargetRef,\n ModuleExtensionUnresolvedFact,\n ModuleFactSourceRef,\n ModuleIncomingExtensionRef,\n} from '@open-mercato/shared/modules/widgets/extension-points'\nimport { extractCommandIdsFromSource } from './module-registry'\nimport { scanModuleDir, SCAN_CONFIGS } from './scanner'\n\ntype StaticScalar = string | number | boolean | null\ntype StaticValue = StaticScalar | StaticValue[] | { [key: string]: StaticValue }\ntype StaticObject = { [key: string]: StaticValue }\ntype SpecializedRegistry = Extract<ModuleExtensionContributionFact, {\n kind: 'specialized-registry'\n}>['details']['registry']\n\nexport interface ExtensionFactEntityRef {\n id: string\n}\n\nexport interface ExtensionFactEventRef {\n id: string\n clientBroadcast?: boolean\n portalBroadcast?: boolean\n}\n\nexport interface ExtensionFactApiRouteRef {\n path: string\n methods: string[]\n}\n\nexport interface ExtractModuleExtensionFactsOptions {\n moduleId: string\n moduleRoot: string\n sourceRoot: string\n entities: readonly ExtensionFactEntityRef[]\n events: readonly ExtensionFactEventRef[]\n apiRoutes: readonly ExtensionFactApiRouteRef[]\n searchEntities: readonly string[]\n notifications?: readonly string[]\n aiTools?: ReadonlyArray<{ name: string; sourcePath: string }>\n aiAgents?: ReadonlyArray<{ id: string; sourcePath: string }>\n}\n\nexport interface CorrelateExtensionFactsOptions {\n surfacesByModule: Readonly<Record<string, ModuleExtensionSurfaceFacts>>\n entityIds: ReadonlySet<string>\n eventIds: ReadonlySet<string>\n apiRoutes: ReadonlySet<string>\n commandIds?: ReadonlySet<string>\n contributingModuleId?: string\n}\n\ntype StaticContext = {\n initializers: Map<string, ts.Expression | ts.FunctionDeclaration>\n sourceFile: ts.SourceFile\n resolving: Set<string>\n}\n\ntype ApiExtensionHostIds = {\n entityIds: string[]\n /** Declaring `api/**` file per entity host id, so the host links to a real source. */\n entitySourceFiles: Record<string, string>\n commandIds: string[]\n routeIds: string[]\n}\n\ntype ModuleExtensionFactExtractionCache = {\n sourceFiles: Map<string, ts.SourceFile | null>\n sourceFilesBelow: Map<string, string[]>\n apiExtensionHostIds: Map<string, ApiExtensionHostIds>\n}\n\nlet activeExtractionCache: ModuleExtensionFactExtractionCache | null = null\n\n/** @internal */\nexport function withModuleExtensionFactExtractionCache<Result>(operation: () => Result): Result {\n if (activeExtractionCache) return operation()\n activeExtractionCache = {\n sourceFiles: new Map(),\n sourceFilesBelow: new Map(),\n apiExtensionHostIds: new Map(),\n }\n try {\n return operation()\n } finally {\n activeExtractionCache = null\n }\n}\n\nconst FRAMEWORK_PREFIXES = [\n 'dashboard:',\n 'menu:',\n 'notification:',\n 'integration:',\n 'integrations.detail:',\n 'system-status:',\n 'topbar:',\n]\n\nconst FRAMEWORK_HOSTS: ModuleExtensionHostFact[] = [\n frameworkHost('framework.backend.sidebar', 'menu:backend.sidebar', 'menu', ['menu-item']),\n frameworkHost('framework.settings.sidebar', 'menu:settings.sidebar', 'menu', ['menu-item']),\n frameworkHost('framework.profile.sidebar', 'menu:profile.sidebar', 'menu', ['menu-item']),\n frameworkHost('framework.portal.sidebar', 'menu:portal.sidebar', 'menu', ['menu-item']),\n frameworkHost('framework.dashboard', 'dashboard:*', 'dashboard', ['registry-contribution']),\n frameworkHost('framework.notifications', 'notification:*', 'notification', ['registry-contribution']),\n frameworkHost('framework.integration-detail', 'integrations.detail:{integrationId}', 'integration', ['render-widget']),\n frameworkHost('framework.integration-detail-fallback', 'integrations.detail:tabs', 'integration', ['render-widget']),\n frameworkHost('framework.backend-mutation', 'backend-mutation:global', 'generic', ['headless-widget']),\n frameworkHost('framework.crud-form-wildcard', 'crud-form:*', 'crud-form', ['field-widget', 'lifecycle-handler']),\n]\n\nfunction frameworkHost(\n key: string,\n id: string,\n family: ExtensionHostFamily,\n capabilities: ExtensionHostCapability[],\n): ModuleExtensionHostFact {\n return {\n key,\n id,\n resolution: id.includes('*') || id.includes('{') ? 'pattern' : 'framework',\n family,\n ownerModule: 'framework',\n capabilities,\n bound: true,\n stability: 'frozen',\n source: { kind: 'framework', path: 'packages/ui/src', symbol: key },\n }\n}\n\nfunction frameworkOverrideHost(\n key: string,\n mode: 'disable-replace' | 'replace' | 'additive',\n): ModuleExtensionHostFact {\n return {\n key: `framework.module-override.${key}`,\n id: `module-override:${key}`,\n resolution: 'framework',\n family: 'module-override',\n ownerModule: 'framework',\n capabilities: ['module-override'],\n operations: [mode],\n bound: true,\n stability: 'stable',\n source: {\n kind: 'framework',\n path: 'packages/shared/src/modules/overrides.ts',\n symbol: `ModuleOverrides.${key}`,\n },\n }\n}\n\nconst FRAMEWORK_OVERRIDE_HOSTS = [\n frameworkOverrideHost('ai.agents', 'disable-replace'),\n frameworkOverrideHost('ai.tools', 'disable-replace'),\n frameworkOverrideHost('ai.extensions', 'additive'),\n frameworkOverrideHost('routes.api', 'disable-replace'),\n frameworkOverrideHost('routes.pages', 'disable-replace'),\n frameworkOverrideHost('events.subscribers', 'disable-replace'),\n frameworkOverrideHost('workers', 'disable-replace'),\n frameworkOverrideHost('widgets.injection', 'disable-replace'),\n frameworkOverrideHost('widgets.components', 'disable-replace'),\n frameworkOverrideHost('widgets.dashboard', 'disable-replace'),\n frameworkOverrideHost('notifications.types', 'disable-replace'),\n frameworkOverrideHost('notifications.handlers', 'disable-replace'),\n frameworkOverrideHost('interceptors', 'disable-replace'),\n frameworkOverrideHost('commandInterceptors', 'disable-replace'),\n frameworkOverrideHost('enrichers', 'disable-replace'),\n frameworkOverrideHost('guards', 'disable-replace'),\n frameworkOverrideHost('cli', 'disable-replace'),\n frameworkOverrideHost('setup', 'replace'),\n frameworkOverrideHost('acl.features', 'disable-replace'),\n frameworkOverrideHost('di', 'disable-replace'),\n frameworkOverrideHost('encryption.maps', 'disable-replace'),\n frameworkOverrideHost('nav.groupOrder', 'additive'),\n] as const\n\nfunction allFrameworkHosts(): ModuleExtensionHostFact[] {\n return [...FRAMEWORK_HOSTS, ...FRAMEWORK_OVERRIDE_HOSTS]\n}\n\nfunction sourceFile(filePath: string): ts.SourceFile | null {\n const cached = activeExtractionCache?.sourceFiles.get(filePath)\n if (cached !== undefined) return cached\n if (!fs.existsSync(filePath)) return null\n const scriptKind = filePath.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS\n const parsed = ts.createSourceFile(filePath, fs.readFileSync(filePath, 'utf8'), ts.ScriptTarget.ES2020, true, scriptKind)\n activeExtractionCache?.sourceFiles.set(filePath, parsed)\n return parsed\n}\n\nfunction unwrap(expression: ts.Expression): ts.Expression {\n let current = expression\n while (\n ts.isAsExpression(current)\n || ts.isTypeAssertionExpression(current)\n || ts.isParenthesizedExpression(current)\n || ts.isSatisfiesExpression(current)\n ) {\n current = current.expression\n }\n return current\n}\n\nfunction propertyName(node: ts.PropertyName): string | null {\n if (ts.isIdentifier(node) || ts.isStringLiteralLike(node) || ts.isNumericLiteral(node)) return node.text\n return null\n}\n\nfunction buildStaticContext(file: ts.SourceFile): StaticContext {\n const initializers = new Map<string, ts.Expression | ts.FunctionDeclaration>()\n const visit = (node: ts.Node): void => {\n if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {\n initializers.set(node.name.text, node.initializer)\n }\n if (ts.isFunctionDeclaration(node) && node.name && node.body) {\n initializers.set(node.name.text, node)\n }\n node.forEachChild(visit)\n }\n file.forEachChild(visit)\n return { initializers, sourceFile: file, resolving: new Set() }\n}\n\nfunction entityRegistryValue(expression: ts.PropertyAccessExpression): string | null {\n const parts: string[] = []\n let current: ts.Expression = expression\n while (ts.isPropertyAccessExpression(current)) {\n parts.unshift(current.name.text)\n current = current.expression\n }\n return ts.isIdentifier(current) && current.text === 'E' && parts.length === 2\n ? `${parts[0]}:${parts[1]}`\n : null\n}\n\nfunction staticTemplate(expression: ts.TemplateExpression, context: StaticContext): string | null {\n let value = expression.head.text\n for (const span of expression.templateSpans) {\n const substitution = staticValue(span.expression, context)\n if (typeof substitution !== 'string' && typeof substitution !== 'number') return null\n value += `${substitution}${span.literal.text}`\n }\n return value\n}\n\nfunction staticObject(expression: ts.ObjectLiteralExpression, context: StaticContext): StaticObject {\n const result: StaticObject = {}\n for (const property of expression.properties) {\n if (ts.isPropertyAssignment(property)) {\n const name = propertyName(property.name)\n if (!name) continue\n const value = staticValue(property.initializer, context)\n if (value !== undefined) result[name] = value\n continue\n }\n if (ts.isShorthandPropertyAssignment(property)) {\n const value = staticValue(property.name, context)\n if (value !== undefined) result[property.name.text] = value\n continue\n }\n if (ts.isMethodDeclaration(property)) {\n const name = propertyName(property.name)\n if (name) result[name] = true\n continue\n }\n if (ts.isSpreadAssignment(property)) {\n const value = staticValue(property.expression, context)\n if (isStaticObject(value)) Object.assign(result, value)\n }\n }\n return result\n}\n\nfunction staticValue(expression: ts.Expression, context: StaticContext): StaticValue | undefined {\n const current = unwrap(expression)\n if (ts.isStringLiteralLike(current) || ts.isNumericLiteral(current)) return current.text\n if (current.kind === ts.SyntaxKind.TrueKeyword) return true\n if (current.kind === ts.SyntaxKind.FalseKeyword) return false\n if (current.kind === ts.SyntaxKind.NullKeyword) return null\n if (ts.isNoSubstitutionTemplateLiteral(current)) return current.text\n if (ts.isTemplateExpression(current)) return staticTemplate(current, context) ?? undefined\n if (ts.isArrayLiteralExpression(current)) {\n return current.elements.flatMap((element) => {\n if (ts.isSpreadElement(element)) {\n const spread = staticValue(element.expression, context)\n return Array.isArray(spread) ? spread : []\n }\n const value = staticValue(element, context)\n return value === undefined ? [] : [value]\n })\n }\n if (ts.isObjectLiteralExpression(current)) return staticObject(current, context)\n if (ts.isPropertyAccessExpression(current)) {\n return entityRegistryValue(current) ?? undefined\n }\n if (ts.isIdentifier(current)) {\n if (context.resolving.has(current.text)) return undefined\n const initializer = context.initializers.get(current.text)\n if (!initializer) return undefined\n context.resolving.add(current.text)\n const value = ts.isFunctionDeclaration(initializer) ? undefined : staticValue(initializer, context)\n context.resolving.delete(current.text)\n return value\n }\n if (ts.isCallExpression(current)) {\n if (ts.isIdentifier(current.expression)) {\n const callable = context.initializers.get(current.expression.text)\n if (callable && (ts.isArrowFunction(callable) || ts.isFunctionExpression(callable) || ts.isFunctionDeclaration(callable))) {\n const initializers = new Map(context.initializers)\n callable.parameters.forEach((parameter, index) => {\n if (ts.isIdentifier(parameter.name) && current.arguments[index]) {\n initializers.set(parameter.name.text, current.arguments[index])\n }\n })\n const childContext: StaticContext = {\n initializers,\n sourceFile: context.sourceFile,\n resolving: new Set(context.resolving),\n }\n if (callable.body && ts.isExpression(callable.body)) return staticValue(callable.body, childContext)\n const returnStatement = callable.body?.statements.find(ts.isReturnStatement)\n if (returnStatement?.expression) return staticValue(returnStatement.expression, childContext)\n }\n }\n const firstArgument = current.arguments[0]\n if (firstArgument) {\n const value = staticValue(firstArgument, context)\n if (!isStaticObject(value) || !ts.isIdentifier(current.expression)) return value\n if (current.expression.text === 'dataTableExtensionHost') return { family: 'data-table', ...value }\n if (current.expression.text === 'crudFormExtensionHost') return { family: 'crud-form', ...value }\n if (current.expression.text === 'componentExtensionHost') return { family: 'component-handle', ...value }\n return value\n }\n }\n if (ts.isConditionalExpression(current)) {\n const left = staticValue(current.whenTrue, context)\n const right = staticValue(current.whenFalse, context)\n return left !== undefined && JSON.stringify(left) === JSON.stringify(right) ? left : undefined\n }\n return undefined\n}\n\nfunction isStaticObject(value: StaticValue | undefined): value is StaticObject {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction strings(value: StaticValue | undefined): string[] {\n return Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : []\n}\n\nfunction stringValue(value: StaticValue | undefined): string | undefined {\n return typeof value === 'string' ? value : undefined\n}\n\nfunction numberValue(value: StaticValue | undefined): number | undefined {\n if (typeof value === 'number') return value\n if (typeof value === 'string' && /^\\d+$/.test(value)) return Number(value)\n return undefined\n}\n\nfunction booleanValue(value: StaticValue | undefined): boolean | undefined {\n return typeof value === 'boolean' ? value : undefined\n}\n\nfunction portablePath(moduleRoot: string, sourceRoot: string, filePath: string): string {\n return path.posix.join(sourceRoot, path.relative(moduleRoot, filePath).split(path.sep).join('/'))\n}\n\nfunction conventionPath(moduleRoot: string, relativePath: string): string | null {\n const direct = path.join(moduleRoot, relativePath)\n if (fs.existsSync(direct)) return direct\n if (relativePath.endsWith('.ts')) {\n const tsx = `${direct.slice(0, -3)}.tsx`\n if (fs.existsSync(tsx)) return tsx\n }\n return null\n}\n\nexport function readConventionObjectArray(filePath: string, exportName: string): StaticObject[] {\n const file = sourceFile(filePath)\n if (!file) return []\n const context = buildStaticContext(file)\n const initializer = context.initializers.get(exportName)\n if (!initializer || ts.isFunctionDeclaration(initializer)) return []\n const value = staticValue(initializer, context)\n return Array.isArray(value) ? value.filter(isStaticObject) : []\n}\n\nfunction readRootObject(filePath: string, variableName: string): StaticObject | null {\n const file = sourceFile(filePath)\n if (!file) return null\n const context = buildStaticContext(file)\n const initializer = context.initializers.get(variableName)\n if (!initializer || ts.isFunctionDeclaration(initializer)) return null\n const value = staticValue(initializer, context)\n return isStaticObject(value) ? value : null\n}\n\nfunction readCallObjectArguments(filePath: string, calleeNames: ReadonlySet<string>): Array<{\n callee: string\n value: StaticObject\n}> {\n const file = sourceFile(filePath)\n if (!file) return []\n const context = buildStaticContext(file)\n const result: Array<{ callee: string; value: StaticObject }> = []\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && calleeNames.has(node.expression.text)) {\n const firstArgument = node.arguments[0]\n const value = firstArgument ? staticValue(firstArgument, context) : undefined\n if (isStaticObject(value)) result.push({ callee: node.expression.text, value })\n }\n node.forEachChild(visit)\n }\n file.forEachChild(visit)\n return result\n}\n\nfunction sortHosts(hosts: ModuleExtensionHostFact[]): ModuleExtensionHostFact[] {\n const sourceKey = (host: ModuleExtensionHostFact): string => host.source.kind === 'fact-ref'\n ? `${host.source.factSection}:${host.source.factKey}`\n : `${host.source.path}:${host.source.symbol}`\n return hosts.sort((left, right) =>\n left.family.localeCompare(right.family)\n || left.id.localeCompare(right.id)\n || sourceKey(left).localeCompare(sourceKey(right))\n || left.key.localeCompare(right.key))\n}\n\nfunction sortContributions(contributions: ModuleExtensionContributionFact[]): ModuleExtensionContributionFact[] {\n const targetKey = (contribution: ModuleExtensionContributionFact): string => contribution.targets\n .map((entry) => entry.id)\n .join('\\u0000')\n const sourceKey = (contribution: ModuleExtensionContributionFact): string =>\n `${contribution.source.path}:${contribution.source.symbol ?? ''}`\n return contributions.sort((left, right) =>\n left.kind.localeCompare(right.kind)\n || left.id.localeCompare(right.id)\n || targetKey(left).localeCompare(targetKey(right))\n || sourceKey(left).localeCompare(sourceKey(right)))\n}\n\nfunction target(id: string, resolution: ModuleExtensionTargetFact['resolution'] = 'unresolved'): ModuleExtensionTargetFact {\n return { id, resolution }\n}\n\nfunction factTarget(id: string, factSection: string, factKey = id): ModuleExtensionTargetFact {\n return { id, resolution: 'fact-ref', factRef: { factSection, factKey } }\n}\n\nfunction openTarget(id: string): ModuleExtensionTargetFact {\n return target(id)\n}\n\nfunction declarationSource(sourceRoot: string, symbol: string): ModuleExtensionHostFact['source'] {\n return { kind: 'declaration', path: path.posix.join(sourceRoot, 'extension-points.ts'), symbol }\n}\n\nfunction hasDeclarationBinding(\n moduleRoot: string,\n hostKey: string,\n declaration: StaticObject,\n): boolean {\n const relativeSource = stringValue(declaration.source)\n if (!relativeSource) return false\n const bindingFile = sourceFile(path.join(moduleRoot, relativeSource))\n if (!bindingFile) return false\n const escapedHostKey = hostKey.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n const bindingPattern = new RegExp(\n `extensionPoints\\\\s*\\\\.\\\\s*hosts(?:\\\\s*\\\\.\\\\s*${escapedHostKey}|\\\\s*\\\\[\\\\s*['\\\"]${escapedHostKey}['\\\"]\\\\s*\\\\])`,\n )\n if (bindingPattern.test(bindingFile.text)) return true\n return declaration.family === 'integration'\n && typeof declaration.pattern === 'string'\n && /resolveIntegrationDetailWidgetSpotId\\s*\\(/.test(bindingFile.text)\n}\n\nfunction baseHost(options: {\n key: string\n id: string\n moduleId: string\n family: ExtensionHostFamily\n capabilities: ExtensionHostCapability[]\n sourceRoot: string\n declaration: StaticObject\n bound?: boolean\n resolution?: ModuleExtensionHostFact['resolution']\n}): ModuleExtensionHostFact {\n const { declaration } = options\n const aliases = strings(declaration.aliases)\n const fallbacks = strings(declaration.fallbacks)\n const fact: ModuleExtensionHostFact = {\n key: options.key,\n id: options.id,\n resolution: options.resolution ?? (options.id.includes('{') || options.id.includes('*') ? 'pattern' : 'exact'),\n family: options.family,\n ownerModule: options.moduleId,\n capabilities: options.capabilities,\n bound: options.bound ?? true,\n stability: 'frozen',\n source: declarationSource(options.sourceRoot, `extensionPoints.hosts.${options.key.split('.')[0]}`),\n }\n const contextContract = stringValue(declaration.contextContract)\n const dataContract = stringValue(declaration.dataContract)\n const scopeContract = stringValue(declaration.scopeContract)\n const runtimeContract = stringValue(declaration.runtimeContract)\n const activation = stringValue(declaration.activation) as ModuleExtensionHostFact['activation']\n if (contextContract) fact.contextContract = contextContract\n if (dataContract) fact.dataContract = dataContract\n if (scopeContract) fact.scopeContract = scopeContract\n if (runtimeContract) fact.runtimeContract = runtimeContract\n if (activation) fact.activation = activation\n if (aliases.length > 0) fact.aliases = aliases\n if (fallbacks.length > 0) fact.fallbacks = fallbacks\n return fact\n}\n\nfunction extractDeclaredHosts(options: ExtractModuleExtensionFactsOptions): {\n hosts: ModuleExtensionHostFact[]\n unresolved: ModuleExtensionUnresolvedFact[]\n} {\n const filePath = conventionPath(options.moduleRoot, 'extension-points.ts')\n if (!filePath) return { hosts: [], unresolved: [] }\n const declaration = readRootObject(filePath, 'extensionPoints')\n const hostsObject = declaration && isStaticObject(declaration.hosts) ? declaration.hosts : null\n if (!hostsObject) {\n return {\n hosts: [],\n unresolved: [{\n key: `${options.moduleId}.extension-points`,\n source: { path: portablePath(options.moduleRoot, options.sourceRoot, filePath), symbol: 'extensionPoints' },\n reason: 'unclassified-binding',\n }],\n }\n }\n\n const hosts: ModuleExtensionHostFact[] = []\n const unresolved: ModuleExtensionUnresolvedFact[] = []\n for (const hostKey of Object.keys(hostsObject).sort((left, right) => left.localeCompare(right))) {\n const host = hostsObject[hostKey]\n if (!isStaticObject(host)) continue\n const family = stringValue(host.family) as ExtensionHostFamily | undefined\n if (!family) continue\n const declarationBound = hasDeclarationBinding(options.moduleRoot, hostKey, host)\n if (!declarationBound) {\n unresolved.push({\n key: `${options.moduleId}.${hostKey}`,\n source: {\n path: stringValue(host.source) ?? portablePath(options.moduleRoot, options.sourceRoot, filePath),\n symbol: `extensionPoints.hosts.${hostKey}`,\n },\n reason: 'unbound-declaration',\n })\n }\n if (family === 'data-table') {\n const tableId = stringValue(host.tableId)\n if (!tableId) continue\n const baseSpotId = stringValue(host.baseSpotId) ?? `data-table:${tableId}`\n for (const surface of DATA_TABLE_EXTENSION_SURFACES) {\n const usesBase = ['header', 'footer', 'toolbar', 'searchTrailing', 'emptyState'].includes(surface.key)\n const id = surface.key === 'replacement'\n ? `data-table:${tableId}`\n : `${usesBase ? baseSpotId : `data-table:${tableId}`}:${surface.suffix}`\n hosts.push(baseHost({\n key: `${hostKey}.${surface.key}`,\n id,\n moduleId: options.moduleId,\n family,\n capabilities: [...surface.capabilities],\n sourceRoot: options.sourceRoot,\n declaration: host,\n bound: surface.bound && declarationBound,\n }))\n }\n continue\n }\n if (family === 'crud-form') {\n const entityId = stringValue(host.entityId)\n if (!entityId) continue\n const spotId = stringValue(host.spotId) ?? `crud-form:${entityId}`\n for (const surface of CRUD_FORM_EXTENSION_SURFACES) {\n const id = surface.suffix ? `${spotId}:${surface.suffix}` : spotId\n const fact = baseHost({\n key: `${hostKey}.${surface.key}`,\n id,\n moduleId: options.moduleId,\n family,\n capabilities: [...surface.capabilities],\n sourceRoot: options.sourceRoot,\n declaration: host,\n bound: surface.bound && declarationBound,\n })\n if (surface.key === 'base') fact.phases = [...CRUD_FORM_LIFECYCLE_PHASES]\n hosts.push(fact)\n }\n continue\n }\n const id = stringValue(host.spotId) ?? stringValue(host.pattern) ?? stringValue(host.componentId)\n if (!id) {\n unresolved.push({\n key: `${options.moduleId}.${hostKey}`,\n source: { path: portablePath(options.moduleRoot, options.sourceRoot, filePath), symbol: hostKey },\n reason: 'dynamic-without-pattern',\n })\n continue\n }\n const capabilities = family === 'component-handle'\n ? ['component-replacement'] as ExtensionHostCapability[]\n : strings(host.supported) as ExtensionHostCapability[]\n const fact = baseHost({\n key: hostKey,\n id,\n moduleId: options.moduleId,\n family,\n capabilities,\n sourceRoot: options.sourceRoot,\n declaration: host,\n bound: declarationBound,\n })\n if (isStaticObject(host.parameters)) {\n fact.patternParameters = Object.fromEntries(Object.entries(host.parameters).flatMap(([key, value]) => {\n if (!isStaticObject(value) || typeof value.source !== 'string') return []\n return [[key, {\n source: value.source,\n ...(typeof value.pattern === 'string' ? { pattern: value.pattern } : {}),\n }]]\n }))\n }\n hosts.push(fact)\n }\n return { hosts: sortHosts(hosts), unresolved }\n}\n\nfunction factRefHost(options: {\n key: string\n id: string\n moduleId: string\n family: ExtensionHostFamily\n capabilities: ExtensionHostCapability[]\n factSection: string\n /** Key inside `factSection`; defaults to the host id when the two coincide. */\n factKey?: string\n phases?: string[]\n activation?: ModuleExtensionHostFact['activation']\n scopeContract?: string\n}): ModuleExtensionHostFact {\n return {\n key: options.key,\n id: options.id,\n resolution: 'fact-ref',\n family: options.family,\n ownerModule: options.moduleId,\n capabilities: options.capabilities,\n ...(options.phases ? { phases: options.phases } : {}),\n ...(options.activation ? { activation: options.activation } : {}),\n ...(options.scopeContract ? { scopeContract: options.scopeContract } : {}),\n bound: true,\n stability: 'stable',\n source: { kind: 'fact-ref', factSection: options.factSection, factKey: options.factKey ?? options.id },\n }\n}\n\nfunction sourceFilesBelow(directory: string): string[] {\n const cached = activeExtractionCache?.sourceFilesBelow.get(directory)\n if (cached) return cached\n if (!fs.existsSync(directory)) return []\n const files: string[] = []\n const visit = (current: string): void => {\n for (const entry of fs.readdirSync(current, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {\n const entryPath = path.join(current, entry.name)\n if (entry.isDirectory()) {\n if (entry.name !== '__tests__' && entry.name !== '__integration__') visit(entryPath)\n continue\n }\n if (entry.isFile() && /\\.(?:ts|tsx)$/.test(entry.name) && !/\\.(?:test|spec)\\./.test(entry.name)) files.push(entryPath)\n }\n }\n visit(directory)\n activeExtractionCache?.sourceFilesBelow.set(directory, files)\n return files\n}\n\nfunction apiRouteId(moduleId: string, moduleRoot: string, filePath: string): string | null {\n const relative = path.relative(path.join(moduleRoot, 'api'), filePath).split(path.sep).join('/')\n if (relative === 'interceptors.ts' || relative === 'openapi.ts') return null\n const withoutExtension = relative.replace(/\\.tsx?$/, '')\n const suffix = withoutExtension.endsWith('/route') ? withoutExtension.slice(0, -6) : withoutExtension\n return suffix && !suffix.includes('__tests__') ? `${moduleId.replace(/_/g, '-')}/${suffix}` : null\n}\n\nfunction apiExtensionHostIds(moduleId: string, moduleRoot: string): ApiExtensionHostIds {\n const cacheKey = `${moduleId}\\0${moduleRoot}`\n const cached = activeExtractionCache?.apiExtensionHostIds.get(cacheKey)\n if (cached) return cached\n const entityIds = new Set<string>()\n const entitySourceFiles: Record<string, string> = {}\n const commandIds = new Set<string>()\n const routeIds = new Set<string>()\n for (const filePath of sourceFilesBelow(path.join(moduleRoot, 'api'))) {\n const routeId = apiRouteId(moduleId, moduleRoot, filePath)\n if (routeId) routeIds.add(routeId)\n const file = sourceFile(filePath)\n if (!file) continue\n const context = buildStaticContext(file)\n const visit = (node: ts.Node): void => {\n if (ts.isPropertyAssignment(node)) {\n const name = propertyName(node.name)\n if (name === 'commandId') {\n const id = stringValue(staticValue(node.initializer, context))\n if (id) commandIds.add(id)\n }\n if (name === 'enrichers') {\n const config = staticValue(node.initializer, context)\n const entityId = isStaticObject(config) ? stringValue(config.entityId) : undefined\n if (entityId) {\n entityIds.add(entityId)\n if (!entitySourceFiles[entityId]) entitySourceFiles[entityId] = filePath\n }\n }\n }\n if (\n ts.isCallExpression(node)\n && ts.isIdentifier(node.expression)\n && node.expression.text === 'validateCrudMutationGuard'\n ) {\n const input = node.arguments[1] ? staticValue(node.arguments[1], context) : undefined\n const entityId = isStaticObject(input) ? stringValue(input.resourceKind) : undefined\n if (entityId) {\n entityIds.add(entityId)\n if (!entitySourceFiles[entityId]) entitySourceFiles[entityId] = filePath\n }\n }\n node.forEachChild(visit)\n }\n file.forEachChild(visit)\n }\n const result = {\n entityIds: [...entityIds].sort((left, right) => left.localeCompare(right)),\n entitySourceFiles,\n commandIds: [...commandIds].sort((left, right) => left.localeCompare(right)),\n routeIds: [...routeIds].sort((left, right) => left.localeCompare(right)),\n }\n activeExtractionCache?.apiExtensionHostIds.set(cacheKey, result)\n return result\n}\n\nfunction moduleCommandIds(moduleRoot: string, apiCommandIds: readonly string[]): string[] {\n const commandIds = new Set(apiCommandIds)\n for (const filePath of sourceFilesBelow(path.join(moduleRoot, 'commands'))) {\n if (path.basename(filePath).replace(/\\.(?:ts|tsx)$/, '') === 'interceptors') continue\n for (const id of extractCommandIdsFromSource(filePath)) commandIds.add(id)\n }\n return [...commandIds].sort((left, right) => left.localeCompare(right))\n}\n\nexport function extractKnownApiRouteIds(moduleId: string, moduleRoot: string): string[] {\n return apiExtensionHostIds(moduleId, moduleRoot).routeIds\n}\n\nexport function extractKnownCommandIds(moduleId: string, moduleRoot: string): string[] {\n const apiHosts = apiExtensionHostIds(moduleId, moduleRoot)\n return moduleCommandIds(moduleRoot, apiHosts.commandIds)\n}\n\nconst HTTP_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'] as const\nexport type ApiInterceptorPhase = 'before' | 'after'\nexport type ApiRouteInterceptorBridge = {\n method: (typeof HTTP_METHODS)[number]\n phases: ApiInterceptorPhase[]\n}\n\nconst API_INTERCEPTOR_BRIDGE_CALLS: Record<string, ApiInterceptorPhase> = {\n runApiInterceptorsBefore: 'before',\n runApiInterceptorsAfter: 'after',\n}\n\nfunction isHttpMethodName(value: string): value is (typeof HTTP_METHODS)[number] {\n return (HTTP_METHODS as readonly string[]).includes(value)\n}\n\n/** HTTP method handlers a route file actually exports. */\nfunction exportedHttpMethods(file: ts.SourceFile): Array<(typeof HTTP_METHODS)[number]> {\n const methods = new Set<(typeof HTTP_METHODS)[number]>()\n const consider = (name: string | undefined): void => {\n if (name && isHttpMethodName(name)) methods.add(name)\n }\n const considerBindingName = (name: ts.BindingName): void => {\n if (ts.isIdentifier(name)) {\n consider(name.text)\n return\n }\n for (const element of name.elements) {\n if (ts.isBindingElement(element)) considerBindingName(element.name)\n }\n }\n const visit = (node: ts.Node): void => {\n if (ts.isVariableStatement(node) && node.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)) {\n for (const declaration of node.declarationList.declarations) {\n considerBindingName(declaration.name)\n }\n }\n if (\n ts.isFunctionDeclaration(node)\n && node.name\n && node.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)\n ) {\n consider(node.name.text)\n }\n if (ts.isExportDeclaration(node) && node.exportClause && ts.isNamedExports(node.exportClause)) {\n for (const element of node.exportClause.elements) consider(element.name.text)\n }\n node.forEachChild(visit)\n }\n file.forEachChild(visit)\n return [...methods].sort((left, right) => left.localeCompare(right))\n}\n\n/**\n * The interceptor pipeline runs only where a route wires it: `makeCrudRoute` runs\n * both phases for every method it handles, and a hand-written route runs whichever\n * of `runApiInterceptorsBefore` / `runApiInterceptorsAfter` it calls. A custom route\n * that calls neither has no bridge, so an interceptor targeting it is never bound.\n */\nfunction extractApiRouteInterceptorBridges(file: ts.SourceFile, context: StaticContext): ApiRouteInterceptorBridge[] {\n const exportedMethods = exportedHttpMethods(file)\n const phasesByMethod = new Map<(typeof HTTP_METHODS)[number], Set<ApiInterceptorPhase>>()\n const addPhase = (method: (typeof HTTP_METHODS)[number], phase: ApiInterceptorPhase): void => {\n const phases = phasesByMethod.get(method) ?? new Set<ApiInterceptorPhase>()\n phases.add(phase)\n phasesByMethod.set(method, phases)\n }\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {\n const calleeName = node.expression.text\n if (calleeName === 'makeCrudRoute') {\n for (const method of exportedMethods) {\n addPhase(method, 'before')\n addPhase(method, 'after')\n }\n }\n const phase = API_INTERCEPTOR_BRIDGE_CALLS[calleeName]\n if (phase) {\n const callOptions = node.arguments[0] ? staticValue(node.arguments[0], context) : undefined\n const declaredMethod = isStaticObject(callOptions) ? stringValue(callOptions.method) : undefined\n const methods = declaredMethod && isHttpMethodName(declaredMethod) ? [declaredMethod] : exportedMethods\n for (const method of methods) addPhase(method, phase)\n }\n }\n node.forEachChild(visit)\n }\n file.forEachChild(visit)\n return [...phasesByMethod.entries()]\n .map(([method, phases]) => ({\n method,\n phases: [...phases].sort((left, right) => left.localeCompare(right)),\n }))\n .sort((left, right) => left.method.localeCompare(right.method))\n}\n\n/**\n * Concrete runtime-id owners a module contributes as activation targets: its real\n * `api/**` route ids (with the interceptor bridges each route actually wires) and\n * its `commands/**` command ids (dispatched through the command bus). Used\n * post-selection to synthesize `host-reference`/`owner-reference` bindings with a\n * portable source.\n */\nexport function extractActivationTargetOwners(options: {\n moduleId: string\n moduleRoot: string\n sourceRoot: string\n}): {\n apiRoutes: Array<{ id: string; source: ModuleFactSourceRef; bridges: ApiRouteInterceptorBridge[] }>\n commands: Array<{ id: string; source: ModuleFactSourceRef }>\n} {\n const apiRoutes: Array<{ id: string; source: ModuleFactSourceRef; bridges: ApiRouteInterceptorBridge[] }> = []\n for (const filePath of sourceFilesBelow(path.join(options.moduleRoot, 'api'))) {\n const routeId = apiRouteId(options.moduleId, options.moduleRoot, filePath)\n if (!routeId) continue\n const file = sourceFile(filePath)\n const bridges = file ? extractApiRouteInterceptorBridges(file, buildStaticContext(file)) : []\n apiRoutes.push({\n id: routeId,\n source: { sourcePath: portablePath(options.moduleRoot, options.sourceRoot, filePath) },\n bridges,\n })\n }\n const commands: Array<{ id: string; source: ModuleFactSourceRef }> = []\n const seenCommands = new Set<string>()\n for (const filePath of sourceFilesBelow(path.join(options.moduleRoot, 'commands'))) {\n if (path.basename(filePath).replace(/\\.(?:ts|tsx)$/, '') === 'interceptors') continue\n const source: ModuleFactSourceRef = { sourcePath: portablePath(options.moduleRoot, options.sourceRoot, filePath) }\n for (const id of extractCommandIdsFromSource(filePath)) {\n if (seenCommands.has(id)) continue\n seenCommands.add(id)\n commands.push({ id, source })\n }\n }\n return { apiRoutes, commands }\n}\n\nfunction extractFactRefHosts(options: ExtractModuleExtensionFactsOptions): ModuleExtensionHostFact[] {\n const hosts: ModuleExtensionHostFact[] = []\n for (const entity of options.entities) {\n hosts.push(factRefHost({\n key: `entity.${entity.id}`,\n id: entity.id,\n moduleId: options.moduleId,\n family: 'entity',\n capabilities: ['response-enricher', 'query-enricher', 'mutation-guard', 'entity-extension'],\n factSection: 'entities',\n activation: 'host-opt-in',\n scopeContract: 'tenant-and-organization',\n }))\n }\n for (const route of options.apiRoutes) {\n hosts.push(factRefHost({\n key: `api-route.${route.path}`,\n id: route.path,\n moduleId: options.moduleId,\n family: 'api-route',\n capabilities: ['api-interceptor', 'mutation-guard'],\n factSection: 'apiRoutes',\n phases: ['before', 'after'],\n activation: 'host-opt-in',\n scopeContract: 'request-auth-scope',\n }))\n }\n for (const event of options.events) {\n const capabilities: ExtensionHostCapability[] = ['async-subscriber', 'sync-subscriber']\n if (event.clientBroadcast) capabilities.push('browser-client')\n if (event.portalBroadcast) capabilities.push('browser-portal')\n hosts.push(factRefHost({\n key: `event.${event.id}`,\n id: event.id,\n moduleId: options.moduleId,\n family: 'event',\n capabilities,\n factSection: 'events',\n scopeContract: 'tenant-organization-and-audience',\n }))\n }\n for (const entityId of options.searchEntities) {\n const eventStem = entityId.replace(':', '.')\n for (const phase of ['querying', 'queried'] as const) {\n hosts.push(factRefHost({\n key: `query-lifecycle.${eventStem}.${phase}`,\n id: `${eventStem}.${phase}`,\n moduleId: options.moduleId,\n family: 'query-lifecycle',\n capabilities: ['sync-subscriber'],\n factSection: 'searchEntities',\n factKey: entityId,\n phases: phase === 'querying' ? ['block', 'query-transform'] : ['result-transform', 'scope-reapply'],\n activation: 'caller-opt-in',\n scopeContract: 'tenant-and-organization-reapplied-after-result',\n }))\n }\n }\n const apiHosts = apiExtensionHostIds(options.moduleId, options.moduleRoot)\n for (const entityId of apiHosts.entityIds) {\n const declaringFile = apiHosts.entitySourceFiles[entityId]\n const host = factRefHost({\n key: `api-entity.${entityId}`,\n id: entityId,\n moduleId: options.moduleId,\n family: 'entity',\n capabilities: ['response-enricher', 'query-enricher', 'mutation-guard'],\n factSection: 'apiRoutes',\n activation: 'host-opt-in',\n scopeContract: 'tenant-and-organization',\n })\n hosts.push(declaringFile\n ? {\n ...host,\n source: {\n kind: 'declaration',\n path: portablePath(options.moduleRoot, options.sourceRoot, declaringFile),\n symbol: entityId,\n },\n }\n : host)\n }\n return sortHosts([...new Map(hosts.map((host) => [`${host.family}:${host.id}`, host])).values()])\n}\n\nfunction contributionBase(\n id: string,\n sourcePath: string,\n sourceSymbol?: string,\n): ModuleExtensionContributionBase {\n return {\n id,\n targets: [],\n scopeContract: 'tenant-and-organization',\n source: { path: sourcePath, ...(sourceSymbol ? { symbol: sourceSymbol } : {}) },\n }\n}\n\nfunction extractInjectionTable(options: ExtractModuleExtensionFactsOptions): ModuleExtensionContributionFact[] {\n const filePath = conventionPath(options.moduleRoot, 'widgets/injection-table.ts')\n if (!filePath) return []\n const table = readRootObject(filePath, 'injectionTable')\n if (!table) return []\n const sourcePath = portablePath(options.moduleRoot, options.sourceRoot, filePath)\n const facts: ModuleExtensionContributionFact[] = []\n for (const targetId of Object.keys(table).sort((left, right) => left.localeCompare(right))) {\n const entries = table[targetId]\n if (!Array.isArray(entries)) continue\n for (const entry of entries) {\n if (!isStaticObject(entry)) continue\n const widgetId = stringValue(entry.widgetId)\n if (!widgetId) continue\n const payload = targetId.endsWith(':columns') ? 'column'\n : targetId.endsWith(':row-actions') ? 'row-action'\n : targetId.endsWith(':bulk-actions') ? 'bulk-action'\n : targetId.endsWith(':filters') ? 'filter'\n : targetId.endsWith(':fields') ? 'field'\n : 'render'\n const base = contributionBase(`${widgetId}@${targetId}`, sourcePath, 'injectionTable')\n const shared = {\n ...base,\n targets: [target(targetId)],\n features: strings(entry.features),\n placement: numberValue(entry.priority) !== undefined ? { priority: numberValue(entry.priority) } : undefined,\n }\n if (targetId.startsWith('data-table:')) {\n facts.push({\n ...shared,\n kind: 'data-table',\n details: {\n payload: payload === 'field' ? 'render' : payload,\n tableId: targetId.replace(/^data-table:/, '').replace(/:(?:columns|row-actions|bulk-actions|filters|toolbar|header|footer|search-trailing)$/, ''),\n executionGuard: strings(entry.features).length > 0 ? 'both' : 'host',\n },\n })\n } else if (targetId.startsWith('crud-form:')) {\n facts.push({\n ...shared,\n kind: 'crud-form',\n details: {\n payload: payload === 'field' ? 'field' : 'render',\n entityId: targetId.replace(/^crud-form:/, '').replace(/:(?:fields|header)$/, ''),\n requestHeaderCapability: payload === 'field',\n },\n })\n } else {\n facts.push({\n ...shared,\n kind: 'widget',\n details: {\n payload: 'render',\n registryKey: widgetId,\n executionGuard: strings(entry.features).length > 0 ? 'both' : 'host',\n },\n })\n }\n }\n }\n return facts\n}\n\nfunction extractObjectConvention(options: {\n module: ExtractModuleExtensionFactsOptions\n relativePath: string\n exportName: string\n exportAliases?: string[]\n build: (entry: StaticObject, sourcePath: string, index: number) => ModuleExtensionContributionFact | null\n}): ModuleExtensionContributionFact[] {\n const filePath = conventionPath(options.module.moduleRoot, options.relativePath)\n if (!filePath) return []\n const exportNames = [options.exportName, ...(options.exportAliases ?? [])]\n const entries = exportNames.reduce<StaticObject[]>((found, exportName) =>\n found.length > 0 ? found : readConventionObjectArray(filePath, exportName), [])\n const sourcePath = portablePath(options.module.moduleRoot, options.module.sourceRoot, filePath)\n return entries.flatMap((entry, index) => options.build(entry, sourcePath, index) ?? [])\n}\n\nfunction methodPhases(entry: StaticObject, map: ReadonlyArray<[string, string]>): string[] {\n return map.flatMap(([property, phase]) => entry[property] === true ? [phase] : [])\n}\n\nfunction extractEnrichers(options: ExtractModuleExtensionFactsOptions): ModuleExtensionContributionFact[] {\n return extractObjectConvention({\n module: options,\n relativePath: 'data/enrichers.ts',\n exportName: 'enrichers',\n build(entry, sourcePath, index) {\n const id = stringValue(entry.id) ?? `${options.moduleId}.enricher.${index}`\n const targetEntity = stringValue(entry.targetEntity)\n if (!targetEntity) return null\n const timeoutMs = numberValue(entry.timeout) ?? 2000\n const queryEngineConfig = isStaticObject(entry.queryEngine) ? entry.queryEngine : null\n // `enricher-registry` selects query-engine enrichers by `queryEngine.enabled === true`,\n // so a config object that omits it (or sets it false) is NOT query-enabled.\n const queryEngine = queryEngineConfig && booleanValue(queryEngineConfig.enabled) === true\n ? queryEngineConfig\n : null\n const surfaces = [entry.enrichMany === true ? 'list' : null, entry.enrichOne === true ? 'detail' : null]\n .filter((value): value is 'list' | 'detail' => value !== null)\n const base = contributionBase(id, sourcePath, id)\n return {\n ...base,\n kind: 'response-enricher',\n targets: [openTarget(targetEntity)],\n features: strings(entry.features),\n phases: surfaces,\n activation: queryEngine ? 'caller-opt-in' : 'host-opt-in',\n roundTripId: `${targetEntity}:read`,\n details: {\n targetEntity,\n surfaces,\n timeoutMs,\n fallback: entry.fallback === undefined ? 'none' : 'configured',\n critical: booleanValue(entry.critical) ?? false,\n cachePosture: 'rerun-on-list-cache-hit',\n ...(queryEngine ? { queryEngine: {\n engines: strings(queryEngine.engines),\n applyOn: (strings(queryEngine.applyOn).length > 0 ? strings(queryEngine.applyOn) : ['list', 'detail'])\n .filter((value): value is 'list' | 'detail' => value === 'list' || value === 'detail'),\n activation: 'caller-opt-in' as const,\n } } : {}),\n },\n }\n },\n })\n}\n\nfunction extractApiInterceptors(options: ExtractModuleExtensionFactsOptions): ModuleExtensionContributionFact[] {\n return extractObjectConvention({\n module: options,\n relativePath: 'api/interceptors.ts',\n exportName: 'interceptors',\n build(entry, sourcePath, index) {\n const id = stringValue(entry.id) ?? `${options.moduleId}.api-interceptor.${index}`\n const targetRoute = stringValue(entry.targetRoute)\n if (!targetRoute) return null\n const phases = methodPhases(entry, [['before', 'before'], ['after', 'after']])\n .filter((phase): phase is 'before' | 'after' => phase === 'before' || phase === 'after')\n const methods = strings(entry.methods)\n const base = contributionBase(id, sourcePath, id)\n return {\n ...base,\n kind: 'api-interceptor',\n targets: [openTarget(targetRoute)],\n phases,\n features: strings(entry.features),\n details: {\n route: targetRoute,\n methods,\n phases,\n activation: targetRoute.startsWith('/') ? 'custom-route-bridge' : 'crud-pipeline',\n timeoutMs: numberValue(entry.timeout) ?? 2000,\n failurePosture: booleanValue(entry.critical) ? 'fail-closed' : 'fallback',\n },\n }\n },\n })\n}\n\nfunction extractCommandInterceptors(options: ExtractModuleExtensionFactsOptions): ModuleExtensionContributionFact[] {\n return extractObjectConvention({\n module: options,\n relativePath: 'commands/interceptors.ts',\n exportName: 'interceptors',\n build(entry, sourcePath, index) {\n const id = stringValue(entry.id) ?? `${options.moduleId}.command-interceptor.${index}`\n const targetCommand = stringValue(entry.targetCommand)\n if (!targetCommand) return null\n const phases = methodPhases(entry, [\n ['beforeExecute', 'before-execute'],\n ['afterExecute', 'after-execute'],\n ['beforeUndo', 'before-undo'],\n ['afterUndo', 'after-undo'],\n ]).filter((phase): phase is 'before-execute' | 'after-execute' | 'before-undo' | 'after-undo' =>\n phase === 'before-execute' || phase === 'after-execute' || phase === 'before-undo' || phase === 'after-undo')\n const base = contributionBase(id, sourcePath, id)\n return {\n ...base,\n kind: 'command-interceptor',\n targets: [openTarget(targetCommand)],\n phases,\n features: strings(entry.features),\n details: { targetCommand, phases },\n }\n },\n })\n}\n\nfunction extractGuards(options: ExtractModuleExtensionFactsOptions): ModuleExtensionContributionFact[] {\n return extractObjectConvention({\n module: options,\n relativePath: 'data/guards.ts',\n exportName: 'guards',\n build(entry, sourcePath, index) {\n const id = stringValue(entry.id) ?? `${options.moduleId}.guard.${index}`\n const targetEntity = stringValue(entry.targetEntity)\n if (!targetEntity) return null\n const operations = strings(entry.operations)\n .filter((operation): operation is 'create' | 'update' | 'delete' =>\n operation === 'create' || operation === 'update' || operation === 'delete')\n const capabilities = [entry.validate === true ? 'block' : null, entry.validate === true ? 'rewrite' : null, entry.afterSuccess === true ? 'after-success' : null]\n .filter((value): value is 'block' | 'rewrite' | 'after-success' => value !== null)\n const base = contributionBase(id, sourcePath, id)\n return {\n ...base,\n kind: 'mutation-guard',\n targets: [openTarget(targetEntity)],\n operations,\n features: strings(entry.features),\n roundTripId: `${targetEntity}:write`,\n details: { entityId: targetEntity, operations, capabilities, optimisticLock: 'preserved' },\n }\n },\n })\n}\n\nfunction extractEntityExtensions(options: ExtractModuleExtensionFactsOptions): ModuleExtensionContributionFact[] {\n return extractObjectConvention({\n module: options,\n relativePath: 'data/extensions.ts',\n exportName: 'entityExtensions',\n exportAliases: ['extensions'],\n build(entry, sourcePath, index) {\n const baseEntity = stringValue(entry.base)\n const extensionEntity = stringValue(entry.extension)\n const join = isStaticObject(entry.join) ? entry.join : null\n if (!baseEntity || !extensionEntity || !join) return null\n const id = `${options.moduleId}.entity-extension.${index}:${baseEntity}->${extensionEntity}`\n const contribution = contributionBase(id, sourcePath, 'extensions')\n return {\n ...contribution,\n kind: 'entity-extension',\n targets: [openTarget(baseEntity)],\n details: {\n hostEntityId: baseEntity,\n extensionEntityId: extensionEntity,\n linkId: `${stringValue(join.baseKey) ?? 'id'}:${stringValue(join.extensionKey) ?? 'id'}`,\n scopeContract: 'tenant-and-organization',\n orphanContract: booleanValue(entry.required) ? 'required' : 'optional',\n },\n }\n },\n })\n}\n\nfunction extractSubscribers(options: ExtractModuleExtensionFactsOptions): ModuleExtensionContributionFact[] {\n const directory = path.join(options.moduleRoot, 'subscribers')\n if (!fs.existsSync(directory)) return []\n const facts: ModuleExtensionContributionFact[] = []\n for (const filePath of sourceFilesBelow(directory)) {\n const metadata = readRootObject(filePath, 'metadata')\n if (!metadata) continue\n const event = stringValue(metadata.event)\n if (!event) continue\n const relativeStem = path.relative(directory, filePath).replace(/\\.tsx?$/, '').split(path.sep).join('/')\n const subscriberId = stringValue(metadata.id) ?? `${options.moduleId}:${relativeStem}`\n const persistent = booleanValue(metadata.persistent) ?? false\n const sync = booleanValue(metadata.sync) ?? !persistent\n const contribution = contributionBase(subscriberId, portablePath(options.moduleRoot, options.sourceRoot, filePath), 'metadata')\n facts.push({\n ...contribution,\n kind: 'subscriber',\n targets: [openTarget(event)],\n phases: sync ? ['before-or-after'] : ['async-delivery'],\n details: {\n event,\n subscriberId,\n persistent,\n sync,\n ...(numberValue(metadata.priority) !== undefined ? { priority: numberValue(metadata.priority) as number } : {}),\n },\n })\n }\n return facts\n}\n\nfunction extractBrowserReactions(options: ExtractModuleExtensionFactsOptions): ModuleExtensionContributionFact[] {\n return options.events.flatMap((event) => {\n const transports = [event.clientBroadcast ? 'client' : null, event.portalBroadcast ? 'portal' : null]\n .filter((value): value is 'client' | 'portal' => value !== null)\n if (transports.length === 0) return []\n const contribution = contributionBase(`${event.id}.browser`, path.posix.join(options.sourceRoot, 'events.ts'), 'events')\n return [{\n ...contribution,\n kind: 'browser-reaction' as const,\n targets: [factTarget(event.id, 'events')],\n details: {\n transports,\n hooks: transports.flatMap((transport) => transport === 'client' ? ['useAppEvent', 'useOperationProgress'] : ['usePortalAppEvent']),\n audienceScopeContract: 'tenant-organization-user-role-and-customer',\n },\n }]\n })\n}\n\nfunction extractNotificationReactions(options: ExtractModuleExtensionFactsOptions): ModuleExtensionContributionFact[] {\n return extractObjectConvention({\n module: options,\n relativePath: 'notifications.handlers.ts',\n exportName: 'notificationHandlers',\n build(entry, sourcePath, index) {\n const notificationType = stringValue(entry.notificationType)\n if (!notificationType) return null\n const declaredId = stringValue(entry.id)\n const id = declaredId ?? `${options.moduleId}.notification-handler.${index}`\n const contribution = contributionBase(id, sourcePath, 'notificationHandlers')\n return {\n ...contribution,\n kind: 'browser-reaction',\n targets: [factTarget(notificationType, 'notifications')],\n features: strings(entry.features),\n placement: numberValue(entry.priority) !== undefined ? { priority: numberValue(entry.priority) } : undefined,\n details: {\n transports: ['notification-effect'],\n hooks: ['useNotificationEffect'],\n audienceScopeContract: 'tenant-organization-user-role-and-customer',\n ...(declaredId ? { overrideKey: declaredId } : {}),\n },\n }\n },\n })\n}\n\nfunction extractComponentOverrides(options: ExtractModuleExtensionFactsOptions): ModuleExtensionContributionFact[] {\n return extractObjectConvention({\n module: options,\n relativePath: 'widgets/components.ts',\n exportName: 'componentOverrides',\n build(entry, sourcePath, index) {\n const targetDefinition = isStaticObject(entry.target) ? entry.target : null\n const handle = targetDefinition ? stringValue(targetDefinition.componentId) : undefined\n if (!handle) return null\n const mode = entry.wrapper !== undefined ? 'wrapper' : entry.props !== undefined ? 'props' : 'replace'\n const id = `${options.moduleId}.component-override.${index}:${handle}`\n const contribution = contributionBase(id, sourcePath, 'componentOverrides')\n return {\n ...contribution,\n kind: 'component-override',\n targets: [target(handle)],\n details: {\n handle,\n mode,\n propsContract: stringValue(entry.propsContract) ?? 'component-props-schema',\n },\n }\n },\n })\n}\n\nfunction extractSpecializedRegistries(options: ExtractModuleExtensionFactsOptions): ModuleExtensionContributionFact[] {\n const facts: ModuleExtensionContributionFact[] = []\n const add = (\n id: string,\n registry: SpecializedRegistry,\n sourcePath: string,\n specialistRoute: string,\n symbol = id,\n ): void => {\n const contributionId = `${registry}:${id}`\n const contribution = contributionBase(contributionId, sourcePath, id)\n const fact: ModuleExtensionContributionFact = {\n ...contribution,\n kind: 'specialized-registry',\n targets: [factTarget(id, specialistRoute)],\n source: { path: sourcePath, symbol },\n details: { registry, registryId: id, specialistRoute },\n }\n const existingIndex = facts.findIndex((entry) => entry.id === contributionId)\n if (existingIndex >= 0) facts[existingIndex] = fact\n else facts.push(fact)\n }\n for (const id of options.notifications ?? []) add(id, 'notification', path.posix.join(options.sourceRoot, 'notifications.ts'), 'notifications')\n for (const id of options.searchEntities) add(id, 'search', path.posix.join(options.sourceRoot, 'search.ts'), 'search')\n for (const tool of options.aiTools ?? []) add(tool.name, 'ai', tool.sourcePath, 'aiTools')\n for (const agent of options.aiAgents ?? []) add(agent.id, 'ai', agent.sourcePath, 'aiAgents')\n\n const vectorPath = conventionPath(options.moduleRoot, 'vector.ts')\n if (vectorPath) {\n const vectorConfig = readRootObject(vectorPath, 'vectorConfig') ?? readRootObject(vectorPath, 'config')\n const sourcePath = portablePath(options.moduleRoot, options.sourceRoot, vectorPath)\n if (vectorConfig && Array.isArray(vectorConfig.entities)) {\n for (const entity of vectorConfig.entities) {\n if (!isStaticObject(entity)) continue\n const entityId = stringValue(entity.entityId)\n if (entityId) add(entityId, 'vector', sourcePath, 'vector', 'vectorConfig')\n }\n }\n }\n\n const integrationPath = conventionPath(options.moduleRoot, 'integration.ts')\n if (integrationPath) {\n const sourcePath = portablePath(options.moduleRoot, options.sourceRoot, integrationPath)\n const addIntegration = (integration: StaticObject, symbol: string, bundleId?: string): void => {\n const integrationId = stringValue(integration.id)\n if (integrationId) {\n add(integrationId, 'integration', sourcePath, 'integrations', bundleId ? `${symbol}[${bundleId}]` : symbol)\n }\n const providerKey = stringValue(integration.providerKey)\n const category = stringValue(integration.category)\n const categoryRegistry = category === 'payment' ? 'payment'\n : category === 'shipping' ? 'shipping'\n : category === 'currency' ? 'currency'\n : null\n if (providerKey && categoryRegistry) {\n const specialistRoute = categoryRegistry === 'payment' ? 'paymentGateways'\n : categoryRegistry === 'shipping' ? 'shippingCarriers'\n : 'currencies'\n add(providerKey, categoryRegistry, sourcePath, specialistRoute, `${symbol}.providerKey`)\n }\n }\n const singular = readRootObject(integrationPath, 'integration')\n if (singular) addIntegration(singular, 'integration')\n for (const integration of readConventionObjectArray(integrationPath, 'integrations')) {\n addIntegration(integration, 'integrations')\n }\n const bundle = readRootObject(integrationPath, 'integrationBundle') ?? readRootObject(integrationPath, 'bundle')\n if (bundle) {\n const bundleId = stringValue(bundle.id) ?? 'bundle'\n const members = Array.isArray(bundle.integrations) ? bundle.integrations : []\n for (const member of members) {\n if (isStaticObject(member)) addIntegration(member, 'integrationBundle', bundleId)\n }\n }\n }\n\n const workflowsPath = conventionPath(options.moduleRoot, 'workflows.ts')\n if (workflowsPath) {\n const config = readRootObject(workflowsPath, 'workflowsConfig')\n const sourcePath = portablePath(options.moduleRoot, options.sourceRoot, workflowsPath)\n if (config && Array.isArray(config.workflows)) {\n for (const workflow of config.workflows) {\n if (!isStaticObject(workflow)) continue\n const workflowId = stringValue(workflow.workflowId)\n if (workflowId) add(workflowId, 'workflow', sourcePath, 'workflows', 'workflowsConfig')\n }\n }\n }\n\n const diPath = conventionPath(options.moduleRoot, 'di.ts')\n if (diPath) {\n const sourcePath = portablePath(options.moduleRoot, options.sourceRoot, diPath)\n const registrations = readCallObjectArguments(diPath, new Set([\n 'registerPaymentGatewayDescriptor',\n 'registerShippingAdapter',\n 'registerCurrencyProvider',\n ]))\n for (const registration of registrations) {\n const registry = registration.callee === 'registerPaymentGatewayDescriptor' ? 'payment'\n : registration.callee === 'registerShippingAdapter' ? 'shipping'\n : 'currency'\n const registryId = stringValue(registration.value.providerKey)\n ?? stringValue(registration.value.key)\n ?? stringValue(registration.value.id)\n if (!registryId) continue\n const specialistRoute = registry === 'payment' ? 'paymentGateways'\n : registry === 'shipping' ? 'shippingCarriers'\n : 'currencies'\n add(registryId, registry, sourcePath, specialistRoute, registration.callee)\n }\n }\n\n const dashboardRoots = { appBase: path.join(options.moduleRoot, '__app__'), pkgBase: options.moduleRoot }\n for (const widgetFile of scanModuleDir(dashboardRoots, SCAN_CONFIGS.dashboardWidgets)) {\n const filePath = path.join(options.moduleRoot, 'widgets', 'dashboard', widgetFile.relPath)\n const widget = readRootObject(filePath, 'widget')\n const metadata = widget && isStaticObject(widget.metadata) ? widget.metadata : null\n if (!metadata) continue\n const widgetId = stringValue(metadata.id)\n if (!widgetId) continue\n const sourcePath = portablePath(options.moduleRoot, options.sourceRoot, filePath)\n const contribution = contributionBase(`dashboard:${widgetId}`, sourcePath, 'widget.metadata')\n facts.push({\n ...contribution,\n kind: 'widget',\n targets: [target(`dashboard:${widgetId}`)],\n features: strings(metadata.features),\n details: {\n payload: 'dashboard',\n registryKey: widgetId,\n executionGuard: strings(metadata.features).length > 0 ? 'both' : 'host',\n },\n })\n }\n return facts\n}\n\n/**\n * Closed activation-adapter registry (Spec 2). Each `ModuleExtensionActivationKind`\n * maps to the contribution kinds it can bind and to the mode by which a `bound`\n * resolution is proven:\n *\n * - `call-site-object` \u2014 the host module owns a distinct opt-in call site (a\n * `makeCrudRoute` option or a mutation-guard bridge). Presence of the option \u2014\n * NOT mere entity/route existence \u2014 produces an emitted `ModuleExtensionActivation`\n * object. This is what makes \"the entity could host X\" (capability-only) different\n * from \"this route actually activates X\" (bound).\n * - `host-reference` \u2014 the runtime bridge is universal for any matching host\n * (every api route runs the interceptor pipeline; a bound widget/component host\n * proves consumption). No object is duplicated; `bound` is derived from the\n * existing bound host fact and the incoming row carries no `activationId`.\n * - `owner-reference` \u2014 like host-reference but proven by the target module owning\n * the concrete runtime id (command ids have no host fact of their own).\n *\n * The registry is exhaustive by construction: the `Record` key set is the full\n * `ModuleExtensionActivationKind` union, so adding a kind fails the typecheck until\n * it is classified. `activation-adapter-coverage.test.ts` re-checks this at runtime.\n */\ntype ActivationAdapterMode = 'call-site-object' | 'host-reference' | 'owner-reference'\n\nexport const ACTIVATION_ADAPTERS: Record<ModuleExtensionActivationKind, {\n contributionKinds: ModuleExtensionContributionKind[]\n mode: ActivationAdapterMode\n}> = {\n 'crud-response-enricher': { contributionKinds: ['response-enricher'], mode: 'call-site-object' },\n 'query-enricher': { contributionKinds: ['response-enricher'], mode: 'call-site-object' },\n 'mutation-guard': { contributionKinds: ['mutation-guard'], mode: 'call-site-object' },\n 'api-interceptor-bridge': { contributionKinds: ['api-interceptor'], mode: 'host-reference' },\n 'command-interceptor-bridge': { contributionKinds: ['command-interceptor'], mode: 'owner-reference' },\n 'widget-injection-consumer': { contributionKinds: ['widget', 'data-table', 'crud-form'], mode: 'host-reference' },\n 'component-extension-consumer': { contributionKinds: ['component-override'], mode: 'host-reference' },\n 'dashboard-host-consumer': { contributionKinds: ['widget'], mode: 'host-reference' },\n}\n\n/**\n * Every UMES contribution kind classified against the activation registry: either\n * the ordered set of activation kinds that can bind it, or `capability-only` for\n * contributions that are always active by declaration/registration and never gain\n * a route/entity activation. Exhaustive by `Record` construction \u2014 a new kind fails\n * the typecheck until classified.\n */\nexport const CONTRIBUTION_ACTIVATION_CLASSIFICATION: Record<\n ModuleExtensionContributionKind,\n ModuleExtensionActivationKind[] | 'capability-only'\n> = {\n 'response-enricher': ['crud-response-enricher', 'query-enricher'],\n 'mutation-guard': ['mutation-guard'],\n 'api-interceptor': ['api-interceptor-bridge'],\n 'command-interceptor': ['command-interceptor-bridge'],\n 'widget': ['widget-injection-consumer', 'dashboard-host-consumer'],\n 'data-table': ['widget-injection-consumer'],\n 'crud-form': ['widget-injection-consumer'],\n 'component-override': ['component-extension-consumer'],\n 'entity-extension': 'capability-only',\n 'subscriber': 'capability-only',\n 'browser-reaction': 'capability-only',\n 'specialized-registry': 'capability-only',\n 'module-override': 'capability-only',\n}\n\nexport const ALL_ACTIVATION_KINDS = Object.keys(ACTIVATION_ADAPTERS) as ModuleExtensionActivationKind[]\nexport const ALL_CONTRIBUTION_KINDS = Object.keys(CONTRIBUTION_ACTIVATION_CLASSIFICATION) as ModuleExtensionContributionKind[]\n\n/**\n * Verified mutation-guard bridge shapes. The canonical route helper nests the\n * resource under `input` (`runRouteMutationGuards({ \u2026, input: { resourceKind } })`),\n * while the legacy helpers take the resource object directly. Module wrappers around\n * the canonical helper live under `lib/` as often as under `api/`, so both trees are\n * scanned.\n */\nconst MUTATION_GUARD_BRIDGE_ADAPTERS: Record<string, { resourceArgument: 'input-property' | 'any-argument' }> = {\n runRouteMutationGuards: { resourceArgument: 'input-property' },\n validateCrudMutationGuard: { resourceArgument: 'any-argument' },\n runMutationGuards: { resourceArgument: 'any-argument' },\n}\n\nconst MUTATION_GUARD_SOURCE_DIRECTORIES = ['api', 'lib'] as const\n\nconst MUTATION_GUARD_OPERATIONS = new Set(['create', 'update', 'delete', 'custom'])\n\n/**\n * `'custom'` action endpoints are mapped by `toRegistryMutationOperation` onto the\n * closest registry operation, `'update'`.\n */\nfunction toRegistryGuardOperation(operation: string): string {\n return operation === 'custom' ? 'update' : operation\n}\n\nfunction readMutationGuardBridge(\n node: ts.CallExpression,\n context: StaticContext,\n): { entityId: string; operations: string[] } | null {\n const callee = node.expression\n const calleeName = ts.isIdentifier(callee)\n ? callee.text\n : ts.isPropertyAccessExpression(callee)\n ? callee.name.text\n : null\n const adapter = calleeName ? MUTATION_GUARD_BRIDGE_ADAPTERS[calleeName] : undefined\n if (!adapter) return null\n\n const argumentObjects = node.arguments\n .map((argument) => staticValue(argument, context))\n .filter(isStaticObject)\n const resourceObjects = adapter.resourceArgument === 'input-property'\n ? argumentObjects.flatMap((argumentObject) => (isStaticObject(argumentObject.input) ? [argumentObject.input] : []))\n : argumentObjects\n for (const resourceObject of resourceObjects) {\n const entityId = stringValue(resourceObject.resourceKind) ?? stringValue(resourceObject.entityId)\n if (!entityId) continue\n const declaredOperation = stringValue(resourceObject.operation)\n const operations = declaredOperation && MUTATION_GUARD_OPERATIONS.has(declaredOperation)\n ? [toRegistryGuardOperation(declaredOperation)]\n : []\n return { entityId, operations }\n }\n return null\n}\n\nfunction nodeLine(file: ts.SourceFile, node: ts.Node): number {\n return file.getLineAndCharacterOfPosition(node.getStart(file)).line + 1\n}\n\nfunction activationId(host: ModuleExtensionTargetRef, kind: ModuleExtensionActivationKind): string {\n const method = host.method ? `:${host.method}` : ''\n return `${host.kind}:${host.id}${method}:${kind}`\n}\n\nfunction sortActivations(activations: ModuleExtensionActivation[]): ModuleExtensionActivation[] {\n return [...activations].sort((left, right) => left.id.localeCompare(right.id))\n}\n\n/**\n * Extract the `call-site-object` activations (CRUD response/query enrichers and\n * mutation guards) from a module's real `api/**` opt-in sites. Entity or route\n * presence alone never lands here \u2014 only a literal `enrichers: { entityId }`\n * option or a mutation-guard bridge call with a static `resourceKind`/`entityId`.\n */\n/**\n * `<engine>.query(entityId, { \u2026, extensions })` \u2014 the only call shape that enables the\n * query-engine enricher and sync query-lifecycle stages.\n */\nfunction isQueryWithExtensionsCall(node: ts.Node, context: StaticContext): node is ts.CallExpression {\n if (!ts.isCallExpression(node)) return false\n const callee = node.expression\n const calleeName = ts.isPropertyAccessExpression(callee)\n ? callee.name.text\n : ts.isIdentifier(callee)\n ? callee.text\n : null\n if (calleeName !== 'query') return false\n const queryOptions = node.arguments[1] ? staticValue(node.arguments[1], context) : undefined\n return isStaticObject(queryOptions) && queryOptions.extensions !== undefined\n}\n\nfunction extractCallSiteActivations(options: ExtractModuleExtensionFactsOptions): ModuleExtensionActivation[] {\n const activations: ModuleExtensionActivation[] = []\n const byId = new Map<string, ModuleExtensionActivation>()\n const push = (activation: ModuleExtensionActivation): void => {\n const existing = byId.get(activation.id)\n if (existing) {\n if (!existing.operations || !activation.operations) {\n delete existing.operations\n } else {\n existing.operations = [...new Set([...existing.operations, ...activation.operations])]\n .sort((left, right) => left.localeCompare(right))\n }\n return\n }\n byId.set(activation.id, activation)\n activations.push(activation)\n }\n const scannedFiles = MUTATION_GUARD_SOURCE_DIRECTORIES\n .flatMap((directory) => sourceFilesBelow(path.join(options.moduleRoot, directory)))\n for (const filePath of scannedFiles) {\n const file = sourceFile(filePath)\n if (!file) continue\n const context = buildStaticContext(file)\n const sourcePath = portablePath(options.moduleRoot, options.sourceRoot, filePath)\n const visit = (node: ts.Node): void => {\n // `enrichers: { entityId }` on a CRUD route runs `applyResponseEnrichers` after the\n // list/detail hook. It does NOT enable the query-engine enricher stage.\n if (ts.isPropertyAssignment(node) && propertyName(node.name) === 'enrichers') {\n const config = staticValue(node.initializer, context)\n const entityId = isStaticObject(config) ? stringValue(config.entityId) : undefined\n if (entityId) {\n const host: ModuleExtensionTargetRef = { kind: 'entity', id: entityId, moduleId: options.moduleId }\n push({\n id: activationId(host, 'crud-response-enricher'),\n kind: 'crud-response-enricher',\n host,\n contributionKinds: ['response-enricher'],\n source: { sourcePath, line: nodeLine(file, node) },\n })\n }\n }\n // The query-engine enricher stage runs only for a query that passes `extensions`,\n // so the bound call site is `queryEngine.query('<entityId>', { \u2026, extensions })`.\n if (isQueryWithExtensionsCall(node, context)) {\n const entityId = stringValue(staticValue(node.arguments[0], context))\n if (entityId) {\n const host: ModuleExtensionTargetRef = { kind: 'entity', id: entityId, moduleId: options.moduleId }\n push({\n id: activationId(host, 'query-enricher'),\n kind: 'query-enricher',\n host,\n contributionKinds: ['response-enricher'],\n source: { sourcePath, line: nodeLine(file, node) },\n })\n }\n }\n if (ts.isCallExpression(node)) {\n const bridge = readMutationGuardBridge(node, context)\n if (bridge) {\n const host: ModuleExtensionTargetRef = { kind: 'entity', id: bridge.entityId, moduleId: options.moduleId }\n push({\n id: activationId(host, 'mutation-guard'),\n kind: 'mutation-guard',\n host,\n contributionKinds: ['mutation-guard'],\n ...(bridge.operations.length > 0 ? { operations: bridge.operations } : {}),\n source: { sourcePath, line: nodeLine(file, node) },\n })\n }\n }\n node.forEachChild(visit)\n }\n file.forEachChild(visit)\n }\n return sortActivations(activations)\n}\n\nexport function extractModuleExtensionFacts(options: ExtractModuleExtensionFactsOptions): ModuleExtensionSurfaceFacts {\n const declared = extractDeclaredHosts(options)\n const hosts = sortHosts([...declared.hosts, ...extractFactRefHosts(options)])\n const contributions = sortContributions([\n ...extractInjectionTable(options),\n ...extractEnrichers(options),\n ...extractApiInterceptors(options),\n ...extractCommandInterceptors(options),\n ...extractGuards(options),\n ...extractEntityExtensions(options),\n ...extractSubscribers(options),\n ...extractBrowserReactions(options),\n ...extractNotificationReactions(options),\n ...extractComponentOverrides(options),\n ...extractSpecializedRegistries(options),\n ])\n return {\n hosts,\n contributions,\n unresolved: declared.unresolved,\n activations: extractCallSiteActivations(options),\n }\n}\n\nfunction patternMatches(pattern: string, targetId: string): boolean {\n const escaped = pattern\n .replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/\\\\\\{[^}]+\\\\\\}/g, '[^:]+')\n .replace(/\\*/g, '.*')\n return new RegExp(`^${escaped}$`).test(targetId)\n}\n\nfunction targetModuleId(targetId: string): string | null {\n const withoutPrefix = targetId.replace(/^(?:data-table|crud-form|detail|portal-page):/, '')\n const match = /^([a-z][a-z0-9_]*)[.:]/.exec(withoutPrefix)\n return match?.[1] ?? null\n}\n\nexport function correlateExtensionTarget(\n targetFact: ModuleExtensionTargetFact,\n options: CorrelateExtensionFactsOptions,\n): ModuleExtensionTargetFact {\n if (targetFact.resolution !== 'unresolved') return targetFact\n const allHosts = Object.values(options.surfacesByModule).flatMap((surface) => surface.hosts)\n if (targetFact.id.includes('*') || targetFact.id.includes('{')) {\n const knownIds = [\n ...allHosts.filter((host) => host.bound).map((host) => host.id),\n ...options.entityIds,\n ...options.eventIds,\n ...options.apiRoutes,\n ...(options.commandIds ?? []),\n ]\n if (targetFact.id === '*' || knownIds.some((knownId) => patternMatches(targetFact.id, knownId))) {\n return { id: targetFact.id, resolution: 'pattern' }\n }\n }\n const exact = allHosts.find((host) => host.bound && (\n host.id === targetFact.id\n || host.aliases?.includes(targetFact.id)\n || (host.family === 'api-route' && host.id.endsWith(`/${targetFact.id}`))\n ))\n if (exact) {\n return exact.source.kind === 'fact-ref'\n ? factTarget(targetFact.id, exact.source.factSection, exact.source.factKey)\n : { id: targetFact.id, resolution: 'exact' }\n }\n const patterned = allHosts.find((host) => host.bound && host.resolution === 'pattern' && patternMatches(host.id, targetFact.id))\n if (patterned) return { id: targetFact.id, resolution: 'pattern' }\n const framework = allFrameworkHosts().find((host) => patternMatches(host.id, targetFact.id))\n ?? (FRAMEWORK_PREFIXES.some((prefix) => targetFact.id.startsWith(prefix)) ? FRAMEWORK_HOSTS[0] : undefined)\n if (framework) return { id: targetFact.id, resolution: 'framework' }\n if (options.entityIds.has(targetFact.id)) {\n return { id: targetFact.id, resolution: 'fact-ref', factRef: { factSection: 'entities', factKey: targetFact.id } }\n }\n if (options.eventIds.has(targetFact.id)) {\n return { id: targetFact.id, resolution: 'fact-ref', factRef: { factSection: 'events', factKey: targetFact.id } }\n }\n if (options.commandIds?.has(targetFact.id)) {\n return factTarget(targetFact.id, 'ownedContracts.command')\n }\n const route = [...options.apiRoutes].find((apiRoute) => apiRoute === targetFact.id || apiRoute.endsWith(`/${targetFact.id}`))\n if (route) return { id: targetFact.id, resolution: 'fact-ref', factRef: { factSection: 'apiRoutes', factKey: route } }\n const ownerModule = targetModuleId(targetFact.id)\n if (ownerModule && !options.surfacesByModule[ownerModule]) {\n return { id: targetFact.id, resolution: 'optional-external', optionalOwnerPackage: `module:${ownerModule}` }\n }\n if (ownerModule && options.contributingModuleId && ownerModule !== options.contributingModuleId) {\n return { id: targetFact.id, resolution: 'optional-external', optionalOwnerPackage: `module:${ownerModule}` }\n }\n return targetFact\n}\n\nexport function correlateModuleExtensionFacts(options: CorrelateExtensionFactsOptions): Record<string, ModuleExtensionSurfaceFacts> {\n const result: Record<string, ModuleExtensionSurfaceFacts> = {}\n for (const moduleId of Object.keys(options.surfacesByModule).sort((left, right) => left.localeCompare(right))) {\n const surface = options.surfacesByModule[moduleId]\n const unresolved: ModuleExtensionUnresolvedFact[] = [...surface.unresolved]\n const contributions = surface.contributions.map((contribution) => {\n const targets = contribution.targets.map((entry) => correlateExtensionTarget(entry, {\n ...options,\n contributingModuleId: moduleId,\n }))\n for (const entry of targets) {\n if (entry.resolution !== 'unresolved') continue\n unresolved.push({\n key: `${contribution.id}:${entry.id}`,\n source: contribution.source,\n reason: 'unresolved-first-party-target',\n })\n }\n return { ...contribution, targets }\n })\n result[moduleId] = {\n hosts: sortHosts([...surface.hosts]),\n contributions: sortContributions(contributions),\n unresolved: unresolved.sort((left, right) => left.key.localeCompare(right.key)),\n activations: sortActivations([...(surface.activations ?? [])]),\n }\n }\n return result\n}\n\ntype IncomingTargetOwner = {\n moduleId: string\n source: ModuleFactSourceRef\n /** Interceptor bridges the owning api route wires (api-route owners only). */\n bridges?: ApiRouteInterceptorBridge[]\n}\n\nexport interface CorrelateIncomingExtensionsOptions {\n surfacesByModule: Readonly<Record<string, ModuleExtensionSurfaceFacts>>\n /** Concrete runtime-id owner maps derived from the fully-selected module set. */\n apiRouteOwners?: ReadonlyMap<string, IncomingTargetOwner>\n commandOwners?: ReadonlyMap<string, IncomingTargetOwner>\n}\n\nfunction normalizeRouteId(routeId: string): string {\n return routeId.replace(/^\\//, '')\n}\n\n/**\n * Owner marker for a contribution bound to a framework host (dashboard, menus,\n * notifications, \u2026). Framework hosts have no module surface of their own, so the\n * activation is recorded on the contributor and never produces an incoming row.\n */\nconst FRAMEWORK_HOST_OWNER = 'framework'\n\n/**\n * Framework host families each host-reference adapter may bind, so a dashboard\n * contribution resolves through `dashboard-host-consumer` rather than being claimed\n * by the generic widget-injection adapter that runs first.\n */\nconst FRAMEWORK_HOST_FAMILIES_BY_ACTIVATION: Partial<Record<ModuleExtensionActivationKind, ExtensionHostFamily[]>> = {\n 'dashboard-host-consumer': ['dashboard'],\n 'widget-injection-consumer': ['menu', 'generic', 'crud-form', 'data-table', 'notification', 'integration'],\n 'component-extension-consumer': ['component-handle'],\n}\n\n/**\n * Resolves a target id against the framework host catalog \u2014 exact ids first, then\n * the patterned entries (`dashboard:*`, `crud-form:*`, `integrations.detail:{id}`),\n * so a concrete `dashboard:<widget>` contribution reaches `framework.dashboard`.\n */\nfunction findFrameworkHost(\n targetId: string,\n activationKind: ModuleExtensionActivationKind,\n): ModuleExtensionHostFact | null {\n const families = FRAMEWORK_HOST_FAMILIES_BY_ACTIVATION[activationKind]\n if (!families) return null\n const candidates = FRAMEWORK_HOSTS.filter((host) => families.includes(host.family))\n const exact = candidates.find((host) => host.id === targetId)\n if (exact) return exact\n return candidates.find((host) => host.resolution === 'pattern' && patternMatches(host.id, targetId)) ?? null\n}\n\n/**\n * A call site that guards only some operations does not activate a contribution\n * declaring none of them. Either side leaving operations undeclared means \"any\".\n */\nfunction operationsIntersect(\n activationOperations: readonly string[] | undefined,\n contributionOperations: readonly string[] | undefined,\n): boolean {\n if (!activationOperations || activationOperations.length === 0) return true\n if (!contributionOperations || contributionOperations.length === 0) return true\n return contributionOperations.some((operation) => activationOperations.includes(operation))\n}\n\nfunction contributionSourceRef(contribution: ModuleExtensionContributionFact): ModuleFactSourceRef {\n return {\n sourcePath: contribution.source.path,\n ...(contribution.source.symbol ? { exportName: contribution.source.symbol } : {}),\n }\n}\n\nfunction targetRefKindFor(\n contribution: ModuleExtensionContributionFact,\n targetId: string,\n): ModuleExtensionTargetRef['kind'] {\n if (targetId === '*' || targetId.includes('*') || targetId.includes('{')) return 'wildcard'\n switch (contribution.kind) {\n case 'response-enricher':\n case 'mutation-guard':\n case 'entity-extension':\n return 'entity'\n case 'api-interceptor':\n return 'api-route'\n case 'command-interceptor':\n return 'command'\n case 'component-override':\n return 'component'\n case 'subscriber':\n return 'event'\n case 'browser-reaction':\n return contribution.details.transports.includes('notification-effect') ? 'notification' : 'event'\n case 'widget':\n case 'data-table':\n case 'crud-form':\n return 'widget-spot'\n case 'specialized-registry':\n case 'module-override':\n return 'module'\n default:\n return 'module'\n }\n}\n\n/**\n * Builds the bidirectional incoming/resolution index after every module fact is\n * extracted and target-correlated. For each contribution target it records one\n * contributor-owned `ModuleContributionResolution` and, when a concrete target\n * owner exists, one target-owned `ModuleIncomingExtensionRef` per matching\n * activation. It never duplicates contribution behavior metadata \u2014 incoming rows\n * point back to the source-owned contribution by `contributorModuleId + contributionId`.\n */\nexport function correlateIncomingExtensions(\n options: CorrelateIncomingExtensionsOptions,\n): Record<string, ModuleExtensionSurfaceFacts> {\n const moduleIds = Object.keys(options.surfacesByModule).sort((left, right) => left.localeCompare(right))\n const apiRouteOwners = options.apiRouteOwners ?? new Map<string, IncomingTargetOwner>()\n const commandOwners = options.commandOwners ?? new Map<string, IncomingTargetOwner>()\n\n // Index call-site activations by (kind, normalized host id).\n const activationIndex = new Map<string, Array<{ moduleId: string; activation: ModuleExtensionActivation }>>()\n const activationKey = (kind: ModuleExtensionActivationKind, hostKind: ModuleExtensionTargetRef['kind'], id: string): string => {\n const normId = hostKind === 'api-route' ? normalizeRouteId(id) : id\n return JSON.stringify([kind, hostKind, normId])\n }\n // Index bound hosts by their runtime id for host-reference resolution.\n const boundHostIndex = new Map<string, { moduleId: string; host: ModuleExtensionHostFact }>()\n\n for (const moduleId of moduleIds) {\n const surface = options.surfacesByModule[moduleId]\n for (const activation of surface.activations ?? []) {\n const key = activationKey(activation.kind, activation.host.kind, activation.host.id)\n const bucket = activationIndex.get(key)\n if (bucket) bucket.push({ moduleId, activation })\n else activationIndex.set(key, [{ moduleId, activation }])\n }\n for (const host of surface.hosts) {\n if (!host.bound) continue\n if (!boundHostIndex.has(host.id)) boundHostIndex.set(host.id, { moduleId, host })\n }\n }\n\n const incomingByModule: Record<string, ModuleIncomingExtensionRef[]> = {}\n const resolutionsByModule: Record<string, ModuleContributionResolution[]> = {}\n const syntheticActivations: Record<string, ModuleExtensionActivation[]> = {}\n for (const moduleId of moduleIds) {\n incomingByModule[moduleId] = []\n resolutionsByModule[moduleId] = []\n syntheticActivations[moduleId] = []\n }\n const registerSyntheticActivation = (ownerModule: string, activation: ModuleExtensionActivation): void => {\n if (!syntheticActivations[ownerModule]) syntheticActivations[ownerModule] = []\n if (!syntheticActivations[ownerModule].some((entry) => entry.id === activation.id)) {\n syntheticActivations[ownerModule].push(activation)\n }\n }\n\n const findCallSiteActivations = (\n contributionKind: ModuleExtensionContributionKind,\n activationKinds: ModuleExtensionActivationKind[],\n targetRef: ModuleExtensionTargetRef,\n contributionOperations: readonly string[] | undefined,\n ): Array<{ moduleId: string; activation: ModuleExtensionActivation }> => {\n const matches: Array<{ moduleId: string; activation: ModuleExtensionActivation }> = []\n for (const kind of activationKinds) {\n if (ACTIVATION_ADAPTERS[kind].mode !== 'call-site-object') continue\n const bucket = activationIndex.get(activationKey(kind, targetRef.kind, targetRef.id)) ?? []\n for (const entry of bucket) {\n if (!entry.activation.contributionKinds.includes(contributionKind)) continue\n if (!operationsIntersect(entry.activation.operations, contributionOperations)) continue\n matches.push(entry)\n }\n }\n return matches.sort((left, right) => left.activation.id.localeCompare(right.activation.id))\n }\n\n for (const contributorModuleId of moduleIds) {\n const surface = options.surfacesByModule[contributorModuleId]\n for (const contribution of surface.contributions) {\n const classification = CONTRIBUTION_ACTIVATION_CLASSIFICATION[contribution.kind]\n for (const resolvedTarget of contribution.targets) {\n const targetKind = targetRefKindFor(contribution, resolvedTarget.id)\n const baseTarget: ModuleExtensionTargetRef = { kind: targetKind, id: resolvedTarget.id }\n\n let resolution: ModuleExtensionResolution\n let ownerModule: string | null = null\n let boundActivationIds: string[] = []\n\n if (targetKind === 'wildcard' || resolvedTarget.resolution === 'pattern') {\n resolution = 'wildcard'\n } else if (resolvedTarget.resolution === 'optional-external') {\n resolution = 'optional-target-missing'\n } else if (resolvedTarget.resolution === 'unresolved') {\n resolution = 'unresolved'\n } else {\n const activationKinds = classification === 'capability-only' ? [] : classification\n const callSiteMatches = findCallSiteActivations(\n contribution.kind,\n activationKinds,\n baseTarget,\n contribution.operations,\n )\n if (callSiteMatches.length > 0) {\n resolution = 'bound'\n ownerModule = callSiteMatches[0].moduleId\n boundActivationIds = callSiteMatches.map((entry) => entry.activation.id)\n } else {\n const referenceBinding = resolveReferenceBinding({\n contribution,\n activationKinds,\n targetRef: baseTarget,\n boundHostIndex,\n apiRouteOwners,\n commandOwners,\n })\n if (referenceBinding) {\n resolution = 'bound'\n // A framework host owns no module surface: record the activation on the\n // contributor and leave `ownerModule` unset so no incoming row is emitted.\n const isFrameworkHost = referenceBinding.ownerModule === FRAMEWORK_HOST_OWNER\n ownerModule = isFrameworkHost ? null : referenceBinding.ownerModule\n const activationOwner = isFrameworkHost ? contributorModuleId : referenceBinding.ownerModule\n for (const activation of referenceBinding.activations) {\n registerSyntheticActivation(activationOwner, activation)\n }\n boundActivationIds = referenceBinding.activations.map((activation) => activation.id)\n } else {\n const hostOwner = boundHostIndex.get(resolvedTarget.id)\n if (hostOwner) {\n resolution = 'capability-only'\n ownerModule = hostOwner.moduleId\n } else {\n resolution = 'capability-only'\n ownerModule = null\n }\n }\n }\n }\n\n const resolutionTarget: ModuleExtensionTargetRef = ownerModule\n ? { ...baseTarget, moduleId: ownerModule }\n : baseTarget\n resolutionsByModule[contributorModuleId].push({\n contributionId: contribution.id,\n target: resolutionTarget,\n resolution,\n activationIds: [...boundActivationIds].sort((left, right) => left.localeCompare(right)),\n })\n\n // Incoming rows document contributions installed by OTHER modules onto a\n // target module's surface (cross-module discovery). Same-module targets are\n // already fully covered by the contributor-owned resolution row above, so\n // emitting a self-incoming row would only duplicate that fact and bloat the\n // generated context.\n if (ownerModule && ownerModule !== contributorModuleId && (resolution === 'bound' || resolution === 'capability-only')) {\n const source = contributionSourceRef(contribution)\n const incomingTarget: ModuleExtensionTargetRef = { ...baseTarget, moduleId: ownerModule }\n if (resolution === 'bound' && boundActivationIds.length > 0) {\n for (const activationRefId of boundActivationIds) {\n incomingByModule[ownerModule].push({\n contributionId: contribution.id,\n contributionKind: contribution.kind,\n contributorModuleId,\n target: incomingTarget,\n activationId: activationRefId,\n resolution: 'bound',\n source,\n })\n }\n } else {\n incomingByModule[ownerModule].push({\n contributionId: contribution.id,\n contributionKind: contribution.kind,\n contributorModuleId,\n target: incomingTarget,\n resolution,\n source,\n })\n }\n }\n }\n }\n }\n\n const result: Record<string, ModuleExtensionSurfaceFacts> = {}\n for (const moduleId of moduleIds) {\n const surface = options.surfacesByModule[moduleId]\n result[moduleId] = {\n ...surface,\n activations: sortActivations([...(surface.activations ?? []), ...syntheticActivations[moduleId]]),\n incoming: dedupeIncoming(incomingByModule[moduleId]),\n contributionResolutions: sortResolutions(resolutionsByModule[moduleId]),\n }\n }\n return result\n}\n\n/**\n * Intersects an api-interceptor contribution's declared methods and phases with the\n * bridges its target route actually wires. A route with no bridge, a phase the route\n * never runs, or a method the route does not handle yields no binding, so the\n * contribution stays `capability-only` instead of being reported as active.\n */\nfunction matchApiInterceptorBridges(\n contribution: ModuleExtensionContributionFact,\n owner: IncomingTargetOwner,\n): ApiRouteInterceptorBridge[] {\n if (contribution.kind !== 'api-interceptor') return []\n const bridges = owner.bridges ?? []\n const declaredMethods = contribution.details.methods ?? []\n const declaredPhases = contribution.phases ?? []\n const matched: ApiRouteInterceptorBridge[] = []\n for (const bridge of bridges) {\n if (declaredMethods.length > 0 && !declaredMethods.includes(bridge.method)) continue\n const phases = declaredPhases.length > 0\n ? bridge.phases.filter((phase) => declaredPhases.includes(phase))\n : bridge.phases\n if (phases.length === 0) continue\n matched.push({ method: bridge.method, phases })\n }\n return matched\n}\n\nfunction resolveReferenceBinding(input: {\n contribution: ModuleExtensionContributionFact\n activationKinds: ModuleExtensionActivationKind[]\n targetRef: ModuleExtensionTargetRef\n boundHostIndex: ReadonlyMap<string, { moduleId: string; host: ModuleExtensionHostFact }>\n apiRouteOwners: ReadonlyMap<string, IncomingTargetOwner>\n commandOwners: ReadonlyMap<string, IncomingTargetOwner>\n}): { ownerModule: string; activations: ModuleExtensionActivation[] } | null {\n for (const kind of input.activationKinds) {\n const adapter = ACTIVATION_ADAPTERS[kind]\n if (adapter.mode === 'call-site-object') continue\n if (!adapter.contributionKinds.includes(input.contribution.kind)) continue\n\n if (adapter.mode === 'host-reference' && kind === 'api-interceptor-bridge') {\n const routeId = normalizeRouteId(input.targetRef.id)\n const owner = input.apiRouteOwners.get(routeId)\n if (!owner) continue\n const matchedBridges = matchApiInterceptorBridges(input.contribution, owner)\n if (matchedBridges.length === 0) continue\n return {\n ownerModule: owner.moduleId,\n activations: matchedBridges.map((bridge) => {\n const host: ModuleExtensionTargetRef = {\n kind: 'api-route',\n id: routeId,\n moduleId: owner.moduleId,\n method: bridge.method,\n }\n return {\n id: activationId(host, kind),\n kind,\n host,\n contributionKinds: ['api-interceptor'],\n phases: bridge.phases,\n source: owner.source,\n bridge: { factSection: 'apiRoutes', factKey: `/${routeId}` },\n }\n }),\n }\n }\n\n if (adapter.mode === 'owner-reference' && kind === 'command-interceptor-bridge') {\n const owner = input.commandOwners.get(input.targetRef.id)\n if (!owner) continue\n const host: ModuleExtensionTargetRef = { kind: 'command', id: input.targetRef.id, moduleId: owner.moduleId }\n return {\n ownerModule: owner.moduleId,\n activations: [{\n id: activationId(host, kind),\n kind,\n host,\n contributionKinds: ['command-interceptor'],\n source: owner.source,\n bridge: { factSection: 'ownedContracts.command', factKey: input.targetRef.id },\n }],\n }\n }\n\n if (adapter.mode === 'host-reference' && (kind === 'widget-injection-consumer' || kind === 'component-extension-consumer' || kind === 'dashboard-host-consumer')) {\n const frameworkHostFact = input.boundHostIndex.has(input.targetRef.id)\n ? null\n : findFrameworkHost(input.targetRef.id, kind)\n const hostEntry = input.boundHostIndex.get(input.targetRef.id)\n ?? (frameworkHostFact ? { moduleId: FRAMEWORK_HOST_OWNER, host: frameworkHostFact } : undefined)\n if (!hostEntry) continue\n const hostSource = hostReferenceSource(hostEntry.host)\n if (!hostSource) continue\n const host: ModuleExtensionTargetRef = { ...input.targetRef, moduleId: hostEntry.moduleId }\n return {\n ownerModule: hostEntry.moduleId,\n activations: [{\n id: activationId(host, kind),\n kind,\n host,\n contributionKinds: adapter.contributionKinds,\n source: hostSource,\n bridge: { factSection: 'hosts', factKey: hostEntry.host.key },\n }],\n }\n }\n }\n return null\n}\n\nfunction hostReferenceSource(host: ModuleExtensionHostFact): ModuleFactSourceRef | null {\n if (host.source.kind === 'declaration' || host.source.kind === 'framework') {\n return { sourcePath: host.source.path, exportName: host.source.symbol }\n }\n return null\n}\n\nfunction incomingIdentity(entry: ModuleIncomingExtensionRef): string {\n const target = JSON.stringify([entry.target.kind, entry.target.id])\n return JSON.stringify([entry.contributorModuleId, entry.contributionId, target, entry.activationId ?? entry.resolution])\n}\n\nfunction dedupeIncoming(entries: ModuleIncomingExtensionRef[]): ModuleIncomingExtensionRef[] {\n const seen = new Set<string>()\n const unique: ModuleIncomingExtensionRef[] = []\n for (const entry of entries) {\n const identity = incomingIdentity(entry)\n if (seen.has(identity)) continue\n seen.add(identity)\n unique.push(entry)\n }\n return unique.sort((left, right) => incomingIdentity(left).localeCompare(incomingIdentity(right)))\n}\n\nfunction resolutionIdentity(entry: ModuleContributionResolution): string {\n return JSON.stringify([entry.contributionId, entry.target.kind, entry.target.id, entry.resolution])\n}\n\nfunction sortResolutions(entries: ModuleContributionResolution[]): ModuleContributionResolution[] {\n const seen = new Set<string>()\n const unique: ModuleContributionResolution[] = []\n for (const entry of entries) {\n const identity = resolutionIdentity(entry)\n if (seen.has(identity)) continue\n seen.add(identity)\n unique.push(entry)\n }\n return unique.sort((left, right) => resolutionIdentity(left).localeCompare(resolutionIdentity(right)))\n}\n\nexport function assertNoUnresolvedExtensionTargets(\n surfacesByModule: Readonly<Record<string, ModuleExtensionSurfaceFacts>>,\n): void {\n const unresolved = Object.entries(surfacesByModule).flatMap(([moduleId, surface]) =>\n surface.unresolved\n .filter((entry) => entry.reason === 'unresolved-first-party-target')\n .map((entry) => `${moduleId}:${entry.key}`),\n ).sort((left, right) => left.localeCompare(right))\n if (unresolved.length > 0) {\n throw new Error(`[module-facts] unresolved first-party extension targets: ${unresolved.join(', ')}`)\n }\n}\n\n/**\n * Supported merge/replace/disable modes for each dotted unified-override host,\n * derived from {@link FRAMEWORK_OVERRIDE_HOSTS} (the framework catalog authority\n * \u2014 spec 2026-08-02-module-facts-exact-override-targets). Keyed by the dotted\n * host id (e.g. `routes.api`, `ai.extensions`, `nav.groupOrder`) so the module\n * override-target adapters share one mode source of truth with the catalog.\n */\nexport function getFrameworkOverrideModes(): Record<string, 'disable-replace' | 'replace' | 'additive'> {\n const modes: Record<string, 'disable-replace' | 'replace' | 'additive'> = {}\n for (const host of FRAMEWORK_OVERRIDE_HOSTS) {\n const dotted = host.key.replace(/^framework\\.module-override\\./, '')\n const mode = host.operations?.[0]\n if (mode === 'disable-replace' || mode === 'replace' || mode === 'additive') modes[dotted] = mode\n }\n return modes\n}\n\nexport function getFrameworkExtensionHosts(): ModuleExtensionHostFact[] {\n return sortHosts(allFrameworkHosts().map((host) => ({\n ...host,\n capabilities: [...host.capabilities],\n ...(host.operations ? { operations: [...host.operations] } : {}),\n })))\n}\n\nexport function renderFrameworkExtensionPointsMarkdown(): string {\n const rows = getFrameworkExtensionHosts().map((host) =>\n `| ${host.id} | ${host.family} | ${[...host.capabilities, ...(host.operations ?? [])].join(', ')} | ${host.stability.toUpperCase()} |`,\n )\n return [\n '# Framework extension points (generated, do not edit)',\n '',\n '| ID / pattern | Family | Supports | Stability |',\n '|---|---|---|---|',\n ...rows,\n '',\n ].join('\\n')\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAmBP,SAAS,mCAAmC;AAC5C,SAAS,eAAe,oBAAoB;AAkE5C,IAAI,wBAAmE;AAGhE,SAAS,uCAA+C,WAAiC;AAC9F,MAAI,sBAAuB,QAAO,UAAU;AAC5C,0BAAwB;AAAA,IACtB,aAAa,oBAAI,IAAI;AAAA,IACrB,k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
+
"names": ["id", "fact", "target"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function identityKey(left, right) {
|
|
2
|
+
return JSON.stringify([left, right]);
|
|
3
|
+
}
|
|
4
|
+
const SECTION_FACT_KINDS = {
|
|
5
|
+
entities: "entity",
|
|
6
|
+
events: "event",
|
|
7
|
+
aclFeatures: "acl-feature",
|
|
8
|
+
notifications: "notification",
|
|
9
|
+
searchEntities: "search"
|
|
10
|
+
};
|
|
11
|
+
function buildFactSourceLookup(facts) {
|
|
12
|
+
const bySection = /* @__PURE__ */ new Map();
|
|
13
|
+
const register = (factSection, factKey, source) => {
|
|
14
|
+
bySection.set(identityKey(factSection, factKey), source);
|
|
15
|
+
};
|
|
16
|
+
for (const route of facts.apiRoutes ?? []) {
|
|
17
|
+
if (route.sourcePath) register("apiRoutes", route.path, { sourcePath: route.sourcePath });
|
|
18
|
+
}
|
|
19
|
+
for (const command of facts.cliCommands ?? []) {
|
|
20
|
+
register("cliCommands", command.command, { sourcePath: command.sourcePath });
|
|
21
|
+
}
|
|
22
|
+
for (const page of facts.backendPages ?? []) register("backendPages", page.path, { sourcePath: page.sourcePath });
|
|
23
|
+
for (const page of facts.frontendPages ?? []) register("frontendPages", page.path, { sourcePath: page.sourcePath });
|
|
24
|
+
for (const tool of facts.aiTools ?? []) register("aiTools", tool.name, { sourcePath: tool.sourcePath });
|
|
25
|
+
for (const agent of facts.aiAgents ?? []) register("aiAgents", agent.id, { sourcePath: agent.sourcePath });
|
|
26
|
+
for (const [kind, ownedFacts] of Object.entries(facts.ownedContracts ?? {})) {
|
|
27
|
+
for (const fact of ownedFacts ?? []) register(`ownedContracts.${kind}`, fact.id, fact.source);
|
|
28
|
+
}
|
|
29
|
+
for (const contribution of facts.extensionSurfaces?.contributions ?? []) {
|
|
30
|
+
register("extensionSurfaces.contributions", contribution.id, { sourcePath: contribution.source.path });
|
|
31
|
+
}
|
|
32
|
+
const factRefHostTargets = /* @__PURE__ */ new Map();
|
|
33
|
+
for (const host of facts.extensionSurfaces?.hosts ?? []) {
|
|
34
|
+
if (host.source.kind === "fact-ref") {
|
|
35
|
+
factRefHostTargets.set(host.key, { factSection: host.source.factSection, factKey: host.source.factKey });
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
register("extensionSurfaces.hosts", host.key, { sourcePath: host.source.path });
|
|
39
|
+
}
|
|
40
|
+
const entries = /* @__PURE__ */ new Map();
|
|
41
|
+
for (const entry of facts.factSources ?? []) {
|
|
42
|
+
entries.set(identityKey(entry.kind, entry.id), {
|
|
43
|
+
...entry.source ? { source: entry.source } : {},
|
|
44
|
+
...entry.factRef ? { factSection: entry.factRef.factSection, factKey: entry.factRef.factKey } : {}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const resolve = (kind, id, depth) => {
|
|
48
|
+
if (depth > 2) return null;
|
|
49
|
+
const entry = entries.get(identityKey(kind, id));
|
|
50
|
+
if (!entry) return null;
|
|
51
|
+
if (entry.source) return entry.source;
|
|
52
|
+
if (entry.factSection === void 0) return null;
|
|
53
|
+
const factKey = entry.factKey ?? id;
|
|
54
|
+
const direct = bySection.get(identityKey(entry.factSection, factKey));
|
|
55
|
+
if (direct) return direct;
|
|
56
|
+
if (entry.factSection === "extensionSurfaces.hosts") {
|
|
57
|
+
const hostTarget = factRefHostTargets.get(factKey);
|
|
58
|
+
const hostKind = hostTarget ? SECTION_FACT_KINDS[hostTarget.factSection] : void 0;
|
|
59
|
+
if (hostTarget && hostKind) return resolve(hostKind, hostTarget.factKey, depth + 1);
|
|
60
|
+
if (hostTarget) return bySection.get(identityKey(hostTarget.factSection, hostTarget.factKey)) ?? null;
|
|
61
|
+
}
|
|
62
|
+
const sectionKind = SECTION_FACT_KINDS[entry.factSection];
|
|
63
|
+
return sectionKind ? resolve(sectionKind, factKey, depth + 1) : null;
|
|
64
|
+
};
|
|
65
|
+
return (kind, id) => resolve(kind, id, 0);
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
buildFactSourceLookup
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=module-fact-sources.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/generators/module-fact-sources.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n ModuleFactSourceKind,\n ModuleFactSourceRef,\n ModuleFactsJsonEntry,\n} from './module-facts'\n\n/**\n * The subset of a module's facts needed to resolve the provenance index. Both\n * the in-memory `ModuleFacts` and the emitted `ModuleFactsJsonEntry` satisfy it.\n */\nexport type FactSourceLookupInput = Pick<\n ModuleFactsJsonEntry,\n | 'apiRoutes'\n | 'cliCommands'\n | 'backendPages'\n | 'frontendPages'\n | 'aiTools'\n | 'aiAgents'\n | 'ownedContracts'\n | 'extensionSurfaces'\n | 'factSources'\n>\n\nexport type FactSourceLookup = (kind: ModuleFactSourceKind, id: string) => ModuleFactSourceRef | null\n\nfunction identityKey(left: string, right: string): string {\n return JSON.stringify([left, right])\n}\n\n/**\n * Fact sections that do not serialize a source inline: their provenance lives in\n * `factSources` under the mapped kind, so a `factRef` into them resolves with one\n * extra hop. Used by `fact-ref` extension hosts, which reference the fact they\n * expose rather than a declaration of their own.\n */\nconst SECTION_FACT_KINDS: Record<string, ModuleFactSourceKind> = {\n entities: 'entity',\n events: 'event',\n aclFeatures: 'acl-feature',\n notifications: 'notification',\n searchEntities: 'search',\n}\n\n/**\n * Builds the single provenance lookup every consumer uses. `factSources` entries\n * carrying an inline `source` resolve directly; `factRef` entries are followed\n * into the fact section that already serializes the declaration site, so every\n * proven `(kind, id)` resolves deterministically without duplicated payloads.\n */\nexport function buildFactSourceLookup(facts: FactSourceLookupInput): FactSourceLookup {\n const bySection = new Map<string, ModuleFactSourceRef>()\n const register = (factSection: string, factKey: string, source: ModuleFactSourceRef): void => {\n bySection.set(identityKey(factSection, factKey), source)\n }\n for (const route of facts.apiRoutes ?? []) {\n if (route.sourcePath) register('apiRoutes', route.path, { sourcePath: route.sourcePath })\n }\n for (const command of facts.cliCommands ?? []) {\n register('cliCommands', command.command, { sourcePath: command.sourcePath })\n }\n for (const page of facts.backendPages ?? []) register('backendPages', page.path, { sourcePath: page.sourcePath })\n for (const page of facts.frontendPages ?? []) register('frontendPages', page.path, { sourcePath: page.sourcePath })\n for (const tool of facts.aiTools ?? []) register('aiTools', tool.name, { sourcePath: tool.sourcePath })\n for (const agent of facts.aiAgents ?? []) register('aiAgents', agent.id, { sourcePath: agent.sourcePath })\n for (const [kind, ownedFacts] of Object.entries(facts.ownedContracts ?? {})) {\n for (const fact of ownedFacts ?? []) register(`ownedContracts.${kind}`, fact.id, fact.source)\n }\n for (const contribution of facts.extensionSurfaces?.contributions ?? []) {\n register('extensionSurfaces.contributions', contribution.id, { sourcePath: contribution.source.path })\n }\n const factRefHostTargets = new Map<string, { factSection: string; factKey: string }>()\n for (const host of facts.extensionSurfaces?.hosts ?? []) {\n if (host.source.kind === 'fact-ref') {\n factRefHostTargets.set(host.key, { factSection: host.source.factSection, factKey: host.source.factKey })\n continue\n }\n register('extensionSurfaces.hosts', host.key, { sourcePath: host.source.path })\n }\n\n const entries = new Map<string, { source?: ModuleFactSourceRef; factSection?: string; factKey?: string }>()\n for (const entry of facts.factSources ?? []) {\n entries.set(identityKey(entry.kind, entry.id), {\n ...(entry.source ? { source: entry.source } : {}),\n ...(entry.factRef ? { factSection: entry.factRef.factSection, factKey: entry.factRef.factKey } : {}),\n })\n }\n\n const resolve = (kind: ModuleFactSourceKind, id: string, depth: number): ModuleFactSourceRef | null => {\n if (depth > 2) return null\n const entry = entries.get(identityKey(kind, id))\n if (!entry) return null\n if (entry.source) return entry.source\n if (entry.factSection === undefined) return null\n const factKey = entry.factKey ?? id\n const direct = bySection.get(identityKey(entry.factSection, factKey))\n if (direct) return direct\n if (entry.factSection === 'extensionSurfaces.hosts') {\n const hostTarget = factRefHostTargets.get(factKey)\n const hostKind = hostTarget ? SECTION_FACT_KINDS[hostTarget.factSection] : undefined\n if (hostTarget && hostKind) return resolve(hostKind, hostTarget.factKey, depth + 1)\n if (hostTarget) return bySection.get(identityKey(hostTarget.factSection, hostTarget.factKey)) ?? null\n }\n const sectionKind = SECTION_FACT_KINDS[entry.factSection]\n return sectionKind ? resolve(sectionKind, factKey, depth + 1) : null\n }\n\n return (kind, id) => resolve(kind, id, 0)\n}\n"],
|
|
5
|
+
"mappings": "AAyBA,SAAS,YAAY,MAAc,OAAuB;AACxD,SAAO,KAAK,UAAU,CAAC,MAAM,KAAK,CAAC;AACrC;AAQA,MAAM,qBAA2D;AAAA,EAC/D,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,eAAe;AAAA,EACf,gBAAgB;AAClB;AAQO,SAAS,sBAAsB,OAAgD;AACpF,QAAM,YAAY,oBAAI,IAAiC;AACvD,QAAM,WAAW,CAAC,aAAqB,SAAiB,WAAsC;AAC5F,cAAU,IAAI,YAAY,aAAa,OAAO,GAAG,MAAM;AAAA,EACzD;AACA,aAAW,SAAS,MAAM,aAAa,CAAC,GAAG;AACzC,QAAI,MAAM,WAAY,UAAS,aAAa,MAAM,MAAM,EAAE,YAAY,MAAM,WAAW,CAAC;AAAA,EAC1F;AACA,aAAW,WAAW,MAAM,eAAe,CAAC,GAAG;AAC7C,aAAS,eAAe,QAAQ,SAAS,EAAE,YAAY,QAAQ,WAAW,CAAC;AAAA,EAC7E;AACA,aAAW,QAAQ,MAAM,gBAAgB,CAAC,EAAG,UAAS,gBAAgB,KAAK,MAAM,EAAE,YAAY,KAAK,WAAW,CAAC;AAChH,aAAW,QAAQ,MAAM,iBAAiB,CAAC,EAAG,UAAS,iBAAiB,KAAK,MAAM,EAAE,YAAY,KAAK,WAAW,CAAC;AAClH,aAAW,QAAQ,MAAM,WAAW,CAAC,EAAG,UAAS,WAAW,KAAK,MAAM,EAAE,YAAY,KAAK,WAAW,CAAC;AACtG,aAAW,SAAS,MAAM,YAAY,CAAC,EAAG,UAAS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BAAgB,OAAW,QAAO;AAC5C,UAAM,UAAU,MAAM,WAAW;AACjC,UAAM,SAAS,UAAU,IAAI,YAAY,MAAM,aAAa,OAAO,CAAC;AACpE,QAAI,OAAQ,QAAO;AACnB,QAAI,MAAM,gBAAgB,2BAA2B;AACnD,YAAM,aAAa,mBAAmB,IAAI,OAAO;AACjD,YAAM,WAAW,aAAa,mBAAmB,WAAW,WAAW,IAAI;AAC3E,UAAI,cAAc,SAAU,QAAO,QAAQ,UAAU,WAAW,SAAS,QAAQ,CAAC;AAClF,UAAI,WAAY,QAAO,UAAU,IAAI,YAAY,WAAW,aAAa,WAAW,OAAO,CAAC,KAAK;AAAA,IACnG;AACA,UAAM,cAAc,mBAAmB,MAAM,WAAW;AACxD,WAAO,cAAc,QAAQ,aAAa,SAAS,QAAQ,CAAC,IAAI;AAAA,EAClE;AAEA,SAAO,CAAC,MAAM,OAAO,QAAQ,MAAM,IAAI,CAAC;AAC1C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -18,13 +18,42 @@ function hasReadableModuleSource(moduleRoot) {
|
|
|
18
18
|
}
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const
|
|
21
|
+
function resolveDuplicateModuleIds(sources, resolver) {
|
|
22
|
+
const sourcesByModule = /* @__PURE__ */ new Map();
|
|
23
|
+
for (const source of sources) {
|
|
24
|
+
const matches = sourcesByModule.get(source.moduleId) ?? [];
|
|
25
|
+
matches.push(source);
|
|
26
|
+
sourcesByModule.set(source.moduleId, matches);
|
|
27
|
+
}
|
|
28
|
+
const duplicates = [...sourcesByModule.entries()].filter(([, matches]) => matches.length > 1);
|
|
29
|
+
if (duplicates.length === 0) return sources;
|
|
30
|
+
const selectedProviders = /* @__PURE__ */ new Map();
|
|
31
|
+
const implicitCoreSelections = /* @__PURE__ */ new Set();
|
|
32
|
+
for (const entry of resolver.loadEnabledModules()) {
|
|
33
|
+
const providers = selectedProviders.get(entry.id) ?? /* @__PURE__ */ new Set();
|
|
34
|
+
providers.add(entry.from ?? "@open-mercato/core");
|
|
35
|
+
selectedProviders.set(entry.id, providers);
|
|
36
|
+
if (entry.from === void 0) implicitCoreSelections.add(entry.id);
|
|
37
|
+
}
|
|
38
|
+
const selectedSources = /* @__PURE__ */ new Map();
|
|
39
|
+
for (const [moduleId, matches] of duplicates) {
|
|
40
|
+
const providers = [...new Set(matches.map((source) => source.from ?? "<unknown>"))].sort((left, right) => left.localeCompare(right));
|
|
41
|
+
const configuredProviders = [...selectedProviders.get(moduleId) ?? []].sort((left, right) => left.localeCompare(right));
|
|
42
|
+
const selected = configuredProviders.length === 1 ? matches.filter((source) => source.from === configuredProviders[0]) : [];
|
|
43
|
+
if (selected.length !== 1) {
|
|
44
|
+
const configured = configuredProviders.length > 0 ? implicitCoreSelections.has(moduleId) ? '; src/modules.ts omits "from", which defaults to @open-mercato/core' : `; src/modules.ts selects ${configuredProviders.join(", ")}` : "; src/modules.ts does not select a provider";
|
|
45
|
+
throw new Error(
|
|
46
|
+
`[module-facts] duplicate module id "${moduleId}" is provided by ${providers.join(", ")}${configured}. Select exactly one matching provider in src/modules.ts.`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
selectedSources.set(moduleId, selected[0]);
|
|
50
|
+
}
|
|
51
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
23
52
|
const result = [];
|
|
24
53
|
for (const source of sources) {
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
result.push(source);
|
|
54
|
+
if (emitted.has(source.moduleId)) continue;
|
|
55
|
+
emitted.add(source.moduleId);
|
|
56
|
+
result.push(selectedSources.get(source.moduleId) ?? source);
|
|
28
57
|
}
|
|
29
58
|
return result;
|
|
30
59
|
}
|
|
@@ -34,10 +63,15 @@ function discoverPackageModuleSources(resolver) {
|
|
|
34
63
|
for (const discovered of discoverModulesInPackage(pkg.path)) {
|
|
35
64
|
const moduleRoot = path.join(pkg.modulesPath, discovered.moduleId);
|
|
36
65
|
if (!hasReadableModuleSource(moduleRoot)) continue;
|
|
37
|
-
sources.push({
|
|
66
|
+
sources.push({
|
|
67
|
+
moduleId: discovered.moduleId,
|
|
68
|
+
moduleRoot,
|
|
69
|
+
from: pkg.name,
|
|
70
|
+
packageVersion: pkg.version ?? null
|
|
71
|
+
});
|
|
38
72
|
}
|
|
39
73
|
}
|
|
40
|
-
return
|
|
74
|
+
return resolveDuplicateModuleIds(sources, resolver);
|
|
41
75
|
}
|
|
42
76
|
export {
|
|
43
77
|
discoverPackageModuleSources,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/generators/module-facts-discovery.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { PackageResolver } from '../resolver'\nimport { discoverModulesInPackage } from '../module-package'\nimport type { ModuleFactSource } from './module-facts'\n\nconst READABLE_CONVENTION_FILES = [\n 'index',\n 'acl',\n 'events',\n 'di',\n path.join('data', 'entities'),\n path.join('db', 'entities'),\n]\n\n/**\n * True when the module directory exposes at least one recognised convention file as\n * TypeScript source. This is the auto-discovery boundary that skips `.js`-only\n * installs (standalone `node_modules/@open-mercato/<pkg>/dist/modules`) \u2014 the extractor's\n * ts-morph reader only parses `.ts`/`.tsx`, so a `.js`-only root would yield empty facts.\n */\nexport function hasReadableModuleSource(moduleRoot: string): boolean {\n if (!fs.existsSync(moduleRoot)) return false\n for (const basename of READABLE_CONVENTION_FILES) {\n for (const extension of ['.ts', '.tsx']) {\n if (fs.existsSync(path.join(moduleRoot, `${basename}${extension}`))) return true\n }\n }\n return false\n}\n\nfunction
|
|
5
|
-
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,SAAS,gCAAgC;AAGzC,MAAM,4BAA4B;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,KAAK,KAAK,QAAQ,UAAU;AAAA,EAC5B,KAAK,KAAK,MAAM,UAAU;AAC5B;AAQO,SAAS,wBAAwB,YAA6B;AACnE,MAAI,CAAC,GAAG,WAAW,UAAU,EAAG,QAAO;AACvC,aAAW,YAAY,2BAA2B;AAChD,eAAW,aAAa,CAAC,OAAO,MAAM,GAAG;AACvC,UAAI,GAAG,WAAW,KAAK,KAAK,YAAY,GAAG,QAAQ,GAAG,SAAS,EAAE,CAAC,EAAG,QAAO;AAAA,IAC9E;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,WAAW,
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { PackageResolver } from '../resolver'\nimport { discoverModulesInPackage } from '../module-package'\nimport type { ModuleFactSource } from './module-facts'\n\nconst READABLE_CONVENTION_FILES = [\n 'index',\n 'acl',\n 'events',\n 'di',\n path.join('data', 'entities'),\n path.join('db', 'entities'),\n]\n\n/**\n * True when the module directory exposes at least one recognised convention file as\n * TypeScript source. This is the auto-discovery boundary that skips `.js`-only\n * installs (standalone `node_modules/@open-mercato/<pkg>/dist/modules`) \u2014 the extractor's\n * ts-morph reader only parses `.ts`/`.tsx`, so a `.js`-only root would yield empty facts.\n */\nexport function hasReadableModuleSource(moduleRoot: string): boolean {\n if (!fs.existsSync(moduleRoot)) return false\n for (const basename of READABLE_CONVENTION_FILES) {\n for (const extension of ['.ts', '.tsx']) {\n if (fs.existsSync(path.join(moduleRoot, `${basename}${extension}`))) return true\n }\n }\n return false\n}\n\nfunction resolveDuplicateModuleIds(\n sources: ModuleFactSource[],\n resolver: PackageResolver,\n): ModuleFactSource[] {\n const sourcesByModule = new Map<string, ModuleFactSource[]>()\n for (const source of sources) {\n const matches = sourcesByModule.get(source.moduleId) ?? []\n matches.push(source)\n sourcesByModule.set(source.moduleId, matches)\n }\n\n const duplicates = [...sourcesByModule.entries()].filter(([, matches]) => matches.length > 1)\n if (duplicates.length === 0) return sources\n\n const selectedProviders = new Map<string, Set<string>>()\n const implicitCoreSelections = new Set<string>()\n for (const entry of resolver.loadEnabledModules()) {\n const providers = selectedProviders.get(entry.id) ?? new Set<string>()\n providers.add(entry.from ?? '@open-mercato/core')\n selectedProviders.set(entry.id, providers)\n if (entry.from === undefined) implicitCoreSelections.add(entry.id)\n }\n\n const selectedSources = new Map<string, ModuleFactSource>()\n for (const [moduleId, matches] of duplicates) {\n const providers = [...new Set(matches.map((source) => source.from ?? '<unknown>'))]\n .sort((left, right) => left.localeCompare(right))\n const configuredProviders = [...(selectedProviders.get(moduleId) ?? [])]\n .sort((left, right) => left.localeCompare(right))\n const selected = configuredProviders.length === 1\n ? matches.filter((source) => source.from === configuredProviders[0])\n : []\n\n if (selected.length !== 1) {\n const configured = configuredProviders.length > 0\n ? implicitCoreSelections.has(moduleId)\n ? '; src/modules.ts omits \"from\", which defaults to @open-mercato/core'\n : `; src/modules.ts selects ${configuredProviders.join(', ')}`\n : '; src/modules.ts does not select a provider'\n throw new Error(\n `[module-facts] duplicate module id \"${moduleId}\" is provided by ${providers.join(', ')}${configured}. `\n + 'Select exactly one matching provider in src/modules.ts.',\n )\n }\n selectedSources.set(moduleId, selected[0])\n }\n\n const emitted = new Set<string>()\n const result: ModuleFactSource[] = []\n for (const source of sources) {\n if (emitted.has(source.moduleId)) continue\n emitted.add(source.moduleId)\n result.push(selectedSources.get(source.moduleId) ?? source)\n }\n return result\n}\n\n/**\n * Package-scan discovery for the create-app build: every package-provided module\n * across `@open-mercato/*` workspace packages (core plus others), never `apps/*`\n * demo modules. Routes through the resolver rather than hardcoded paths.\n */\nexport function discoverPackageModuleSources(resolver: PackageResolver): ModuleFactSource[] {\n const sources: ModuleFactSource[] = []\n for (const pkg of resolver.discoverPackages()) {\n for (const discovered of discoverModulesInPackage(pkg.path)) {\n const moduleRoot = path.join(pkg.modulesPath, discovered.moduleId)\n if (!hasReadableModuleSource(moduleRoot)) continue\n sources.push({\n moduleId: discovered.moduleId,\n moduleRoot,\n from: pkg.name,\n packageVersion: pkg.version ?? null,\n })\n }\n }\n return res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