@open-mercato/cli 0.11.1-develop.8593.1.50784dae35 → 0.11.1-develop.8687.1.adb16f62b3
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 +6 -2
- package/AGENTS.md +2 -0
- package/dist/agentic/guides/architecture.md +2 -2
- package/dist/agentic/guides/extensions.md +7 -2
- package/dist/agentic/guides/framework-extension-points.md +1 -0
- package/dist/agentic/guides/infrastructure-providers.md +20 -0
- package/dist/agentic/guides/integrations.md +2 -2
- package/dist/agentic/guides/module-facts.json +11067 -7122
- package/dist/agentic/guides/module-facts.v2.json +11055 -7094
- package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
- package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
- package/dist/agentic/guides/modules/api_docs/index.md +1 -1
- package/dist/agentic/guides/modules/api_keys/index.md +1 -1
- package/dist/agentic/guides/modules/assisted_selling/acl-features.md +16 -0
- package/dist/agentic/guides/modules/assisted_selling/contribution-resolutions.md +21 -0
- package/dist/agentic/guides/modules/assisted_selling/domain-commands.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/entities.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/events.md +22 -0
- package/dist/agentic/guides/modules/assisted_selling/exact-override-targets.md +17 -0
- package/dist/agentic/guides/modules/assisted_selling/index.md +21 -0
- package/dist/agentic/guides/modules/assisted_selling/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/setup.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/umes-contributions.md +21 -0
- package/dist/agentic/guides/modules/assisted_selling/umes-hosts.md +23 -0
- package/dist/agentic/guides/modules/attachments/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/attachments/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/workers.md +1 -1
- package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
- package/dist/agentic/guides/modules/auth/index.md +1 -1
- package/dist/agentic/guides/modules/availability/index.md +1 -1
- package/dist/agentic/guides/modules/backups/di-registrations-rich.md +11 -0
- package/dist/agentic/guides/modules/backups/di-service-tokens.md +11 -0
- package/dist/agentic/guides/modules/backups/exact-override-targets.md +11 -0
- package/dist/agentic/guides/modules/backups/index.md +5 -2
- package/dist/agentic/guides/modules/business_rules/index.md +1 -1
- package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
- package/dist/agentic/guides/modules/cart/index.md +1 -1
- package/dist/agentic/guides/modules/catalog/acl-features.md +2 -1
- package/dist/agentic/guides/modules/catalog/active-extension-bindings.md +2 -0
- package/dist/agentic/guides/modules/catalog/backend-pages.md +1 -0
- package/dist/agentic/guides/modules/catalog/contribution-resolutions.md +5 -0
- package/dist/agentic/guides/modules/catalog/di-registrations-rich.md +8 -7
- package/dist/agentic/guides/modules/catalog/di-service-tokens.md +5 -4
- package/dist/agentic/guides/modules/catalog/domain-commands.md +2 -0
- package/dist/agentic/guides/modules/catalog/entities.md +1 -0
- package/dist/agentic/guides/modules/catalog/events.md +4 -1
- package/dist/agentic/guides/modules/catalog/exact-override-targets.md +13 -7
- package/dist/agentic/guides/modules/catalog/index.md +9 -9
- package/dist/agentic/guides/modules/catalog/umes-contributions.md +5 -0
- package/dist/agentic/guides/modules/catalog/umes-hosts.md +4 -0
- package/dist/agentic/guides/modules/catalog/workers.md +1 -0
- package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
- package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
- package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
- package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
- package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
- package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/workers.md +1 -1
- package/dist/agentic/guides/modules/configs/index.md +1 -1
- package/dist/agentic/guides/modules/content/index.md +1 -1
- package/dist/agentic/guides/modules/currencies/active-extension-bindings.md +11 -0
- package/dist/agentic/guides/modules/currencies/di-registrations-rich.md +1 -1
- package/dist/agentic/guides/modules/currencies/di-service-tokens.md +1 -1
- package/dist/agentic/guides/modules/currencies/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/currencies/index.md +3 -2
- package/dist/agentic/guides/modules/customer_accounts/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/exact-override-targets.md +2 -0
- package/dist/agentic/guides/modules/customer_accounts/index.md +2 -2
- package/dist/agentic/guides/modules/customer_accounts/workers.md +2 -0
- package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
- package/dist/agentic/guides/modules/customers/active-extension-bindings.md +2 -1
- package/dist/agentic/guides/modules/customers/incoming-installed-contributions.md +1 -0
- package/dist/agentic/guides/modules/customers/index.md +3 -3
- package/dist/agentic/guides/modules/customers/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/dashboards/active-extension-bindings.md +0 -1
- package/dist/agentic/guides/modules/dashboards/cli-commands.md +1 -0
- package/dist/agentic/guides/modules/dashboards/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/dashboards/index.md +2 -3
- package/dist/agentic/guides/modules/data_sync/index.md +1 -1
- package/dist/agentic/guides/modules/design_system/index.md +1 -1
- package/dist/agentic/guides/modules/devices/index.md +1 -1
- package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
- package/dist/agentic/guides/modules/directory/index.md +1 -1
- package/dist/agentic/guides/modules/documents/index.md +1 -1
- package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
- package/dist/agentic/guides/modules/entities/index.md +1 -1
- package/dist/agentic/guides/modules/eudr/index.md +1 -1
- package/dist/agentic/guides/modules/events/index.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
- package/dist/agentic/guides/modules/forms/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
- package/dist/agentic/guides/modules/generators/index.md +1 -1
- package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
- package/dist/agentic/guides/modules/integrations/di-registrations-rich.md +8 -8
- package/dist/agentic/guides/modules/integrations/di-service-tokens.md +4 -4
- package/dist/agentic/guides/modules/integrations/exact-override-targets.md +14 -12
- package/dist/agentic/guides/modules/integrations/index.md +2 -2
- package/dist/agentic/guides/modules/integrations/setup.md +1 -1
- package/dist/agentic/guides/modules/integrations/workers.md +3 -1
- package/dist/agentic/guides/modules/ledger/acl-features.md +16 -0
- package/dist/agentic/guides/modules/ledger/active-extension-bindings.md +11 -0
- package/dist/agentic/guides/modules/ledger/backend-pages.md +21 -0
- package/dist/agentic/guides/modules/ledger/domain-commands.md +22 -0
- package/dist/agentic/guides/modules/ledger/encryption.md +11 -0
- package/dist/agentic/guides/modules/ledger/entities.md +17 -0
- package/dist/agentic/guides/modules/ledger/events.md +19 -0
- package/dist/agentic/guides/modules/ledger/exact-override-targets.md +30 -0
- package/dist/agentic/guides/modules/ledger/index.md +22 -0
- package/dist/agentic/guides/modules/ledger/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/ledger/setup.md +11 -0
- package/dist/agentic/guides/modules/ledger/umes-hosts.md +26 -0
- package/dist/agentic/guides/modules/messages/index.md +1 -1
- package/dist/agentic/guides/modules/notifications/index.md +1 -1
- package/dist/agentic/guides/modules/onboarding/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
- package/dist/agentic/guides/modules/perspectives/index.md +1 -1
- package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
- package/dist/agentic/guides/modules/planner/index.md +1 -1
- package/dist/agentic/guides/modules/portal/index.md +1 -1
- package/dist/agentic/guides/modules/progress/index.md +1 -1
- package/dist/agentic/guides/modules/promotions/index.md +1 -1
- package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
- package/dist/agentic/guides/modules/query_index/index.md +1 -1
- package/dist/agentic/guides/modules/record_locks/index.md +1 -1
- package/dist/agentic/guides/modules/resources/exact-override-targets.md +3 -3
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/resources/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/resources/setup.md +1 -1
- package/dist/agentic/guides/modules/sales/contribution-resolutions.md +1 -0
- package/dist/agentic/guides/modules/sales/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/sales/index.md +3 -3
- package/dist/agentic/guides/modules/sales/umes-contributions.md +1 -0
- package/dist/agentic/guides/modules/scheduler/index.md +1 -1
- package/dist/agentic/guides/modules/search/index.md +1 -1
- package/dist/agentic/guides/modules/security/index.md +1 -1
- package/dist/agentic/guides/modules/seeds/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/contribution-resolutions.md +1 -1
- package/dist/agentic/guides/modules/staff/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/staff/index.md +1 -1
- package/dist/agentic/guides/modules/staff/workers.md +1 -1
- package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
- package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
- package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
- package/dist/agentic/guides/modules/telemetry/index.md +1 -1
- package/dist/agentic/guides/modules/tillio/index.md +1 -1
- package/dist/agentic/guides/modules/translations/index.md +1 -1
- package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
- package/dist/agentic/guides/modules/webhooks/index.md +1 -1
- package/dist/agentic/guides/modules/wms/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/reference-module-facts.json +811 -21
- package/dist/agentic/guides/reference-modules/example/active-extension-bindings.md +1 -0
- package/dist/agentic/guides/reference-modules/example/backend-pages.md +2 -0
- package/dist/agentic/guides/reference-modules/example/contribution-resolutions.md +3 -1
- package/dist/agentic/guides/reference-modules/example/di-registrations-rich.md +3 -3
- package/dist/agentic/guides/reference-modules/example/di-service-tokens.md +1 -1
- package/dist/agentic/guides/reference-modules/example/entities.md +2 -0
- package/dist/agentic/guides/reference-modules/example/events.md +2 -1
- package/dist/agentic/guides/reference-modules/example/exact-override-targets.md +25 -8
- package/dist/agentic/guides/reference-modules/example/index.md +7 -7
- package/dist/agentic/guides/reference-modules/example/notifications.md +1 -0
- package/dist/agentic/guides/reference-modules/example/setup.md +1 -1
- package/dist/agentic/guides/reference-modules/example/umes-contributions.md +3 -1
- package/dist/agentic/guides/reference-modules/example/umes-hosts.md +4 -0
- package/dist/agentic/guides/upstream/AGENTS.md +5 -4
- package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +37 -20
- package/dist/agentic/guides/upstream/manifest.json +3 -3
- package/dist/agentic/shared/AGENTS.md.template +12 -16
- package/dist/agentic/shared/ai/harness/README.md +4 -2
- package/dist/agentic/shared/ai/harness/RELEASE.md +4 -4
- package/dist/agentic/shared/ai/harness/cases.json +1420 -41
- package/dist/agentic/shared/ai/harness/cases.schema.json +4 -4
- package/dist/agentic/shared/ai/harness/design-system-inventory.json +640 -142
- package/dist/agentic/shared/ai/harness/source-link-inventory.json +223 -16
- package/dist/agentic/shared/ai/harness/validators.json +1 -1
- package/dist/agentic/shared/ai/skills/om-system-extension/SKILL.md +1 -1
- package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +25 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/mechanism-selector.md +1 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +2 -0
- package/dist/agentic/shared/scripts/run-agent-harness-release.mjs +21 -1
- package/dist/lib/cache-provider-manifest.js +9 -0
- package/dist/lib/cache-provider-manifest.js.map +7 -0
- package/dist/lib/generate-watch-plan.js +4 -0
- package/dist/lib/generate-watch-plan.js.map +2 -2
- package/dist/lib/generate-watch-runner.js +1 -0
- package/dist/lib/generate-watch-runner.js.map +2 -2
- package/dist/lib/generate-watch-structure.js +2 -0
- package/dist/lib/generate-watch-structure.js.map +2 -2
- package/dist/lib/generators/ast/writers.js +5 -1
- package/dist/lib/generators/ast/writers.js.map +2 -2
- package/dist/lib/generators/cache-providers.js +80 -0
- package/dist/lib/generators/cache-providers.js.map +7 -0
- package/dist/lib/generators/form-section-ast.js +156 -0
- package/dist/lib/generators/form-section-ast.js.map +7 -0
- package/dist/lib/generators/form-section-extension-compiler.js +568 -0
- package/dist/lib/generators/form-section-extension-compiler.js.map +7 -0
- package/dist/lib/generators/form-section-extension-source.js +245 -0
- package/dist/lib/generators/form-section-extension-source.js.map +7 -0
- package/dist/lib/generators/form-section-runtime-revisions.js +184 -0
- package/dist/lib/generators/form-section-runtime-revisions.js.map +7 -0
- package/dist/lib/generators/form-sections.js +773 -0
- package/dist/lib/generators/form-sections.js.map +7 -0
- package/dist/lib/generators/index.js +2 -0
- package/dist/lib/generators/index.js.map +2 -2
- package/dist/lib/generators/module-entities.js +21 -2
- package/dist/lib/generators/module-entities.js.map +2 -2
- package/dist/lib/generators/module-extension-facts.js +2 -1
- package/dist/lib/generators/module-extension-facts.js.map +2 -2
- package/dist/lib/generators/module-facts.js +30 -1
- package/dist/lib/generators/module-facts.js.map +2 -2
- package/dist/lib/generators/module-override-targets.js +24 -2
- package/dist/lib/generators/module-override-targets.js.map +2 -2
- package/dist/lib/generators/module-registry.js +75 -3
- package/dist/lib/generators/module-registry.js.map +2 -2
- package/dist/lib/generators/openapi.js +27 -17
- package/dist/lib/generators/openapi.js.map +2 -2
- package/dist/lib/post-generate-invalidation.js +20 -1
- package/dist/lib/post-generate-invalidation.js.map +2 -2
- package/dist/lib/resolver.js +195 -1
- package/dist/lib/resolver.js.map +3 -3
- package/dist/lib/scaffold/field-dsl.js +393 -0
- package/dist/lib/scaffold/field-dsl.js.map +7 -0
- package/dist/lib/scaffold/index.js +412 -0
- package/dist/lib/scaffold/index.js.map +7 -0
- package/dist/lib/scaffold/targets.js +42 -0
- package/dist/lib/scaffold/targets.js.map +7 -0
- package/dist/lib/scaffold/templates/create-page.js +52 -0
- package/dist/lib/scaffold/templates/create-page.js.map +7 -0
- package/dist/lib/scaffold/templates/detail-page.js +186 -0
- package/dist/lib/scaffold/templates/detail-page.js.map +7 -0
- package/dist/lib/scaffold/templates/form-config.js +42 -0
- package/dist/lib/scaffold/templates/form-config.js.map +7 -0
- package/dist/lib/scaffold/templates/index.js +27 -0
- package/dist/lib/scaffold/templates/index.js.map +7 -0
- package/dist/lib/scaffold/templates/list-page.js +190 -0
- package/dist/lib/scaffold/templates/list-page.js.map +7 -0
- package/dist/lib/scaffold/templates/metas.js +47 -0
- package/dist/lib/scaffold/templates/metas.js.map +7 -0
- package/dist/lib/scaffold/templates/module-files.js +85 -0
- package/dist/lib/scaffold/templates/module-files.js.map +7 -0
- package/dist/lib/single-instance-strategy-guard.js +26 -3
- package/dist/lib/single-instance-strategy-guard.js.map +2 -2
- package/dist/lib/testing/integration-discovery.js +32 -3
- package/dist/lib/testing/integration-discovery.js.map +2 -2
- package/dist/lib/testing/integration.js +232 -8
- package/dist/lib/testing/integration.js.map +2 -2
- package/dist/mercato.js +40 -7
- package/dist/mercato.js.map +2 -2
- package/jest.config.cjs +2 -0
- package/package.json +7 -7
- package/src/__tests__/mercato.test.ts +18 -0
- package/src/__tests__/rotation-json-output.test.ts +52 -0
- package/src/lib/__tests__/agentic-workflows-ownership.test.ts +79 -0
- package/src/lib/__tests__/cache-provider-manifest.test.ts +76 -0
- package/src/lib/__tests__/generate-watch-plan.test.ts +3 -2
- package/src/lib/__tests__/generate-watch-runner.test.ts +13 -1
- package/src/lib/__tests__/generate-watch-structure.test.ts +34 -0
- package/src/lib/__tests__/post-generate-invalidation.test.ts +108 -0
- package/src/lib/__tests__/resolver.form-section-gates.test.ts +82 -0
- package/src/lib/__tests__/single-instance-strategy-guard.test.ts +129 -0
- package/src/lib/cache-provider-manifest.ts +8 -0
- package/src/lib/generate-watch-plan.ts +6 -3
- package/src/lib/generate-watch-runner.ts +1 -0
- package/src/lib/generate-watch-structure.ts +5 -1
- package/src/lib/generators/__tests__/cache-providers.test.ts +102 -0
- package/src/lib/generators/__tests__/derived-crud-route-collisions.test.ts +85 -0
- package/src/lib/generators/__tests__/form-section-outbox.test.ts +53 -0
- package/src/lib/generators/__tests__/form-sections.test.ts +896 -0
- package/src/lib/generators/__tests__/module-extension-facts.test.ts +1 -0
- package/src/lib/generators/__tests__/module-facts.bc-guard.test.ts +8 -6
- package/src/lib/generators/__tests__/module-facts.example-fact-coverage.test.ts +37 -13
- package/src/lib/generators/__tests__/module-facts.local-reference.test.ts +13 -0
- package/src/lib/generators/__tests__/module-override-targets.test.ts +2 -3
- package/src/lib/generators/__tests__/module-subset.test.ts +1 -1
- package/src/lib/generators/__tests__/openapi.test.ts +60 -13
- package/src/lib/generators/__tests__/structural-contracts.test.ts +2 -2
- package/src/lib/generators/ast/writers.ts +6 -1
- package/src/lib/generators/cache-providers.ts +111 -0
- package/src/lib/generators/form-section-ast.ts +166 -0
- package/src/lib/generators/form-section-extension-compiler.ts +632 -0
- package/src/lib/generators/form-section-extension-source.ts +308 -0
- package/src/lib/generators/form-section-runtime-revisions.ts +211 -0
- package/src/lib/generators/form-sections.ts +896 -0
- package/src/lib/generators/index.ts +1 -0
- package/src/lib/generators/module-entities.ts +22 -4
- package/src/lib/generators/module-extension-facts.ts +1 -0
- package/src/lib/generators/module-facts.ts +40 -0
- package/src/lib/generators/module-override-targets.ts +19 -0
- package/src/lib/generators/module-registry.ts +80 -4
- package/src/lib/generators/openapi.ts +31 -20
- package/src/lib/post-generate-invalidation.ts +28 -1
- package/src/lib/resolver.ts +218 -0
- package/src/lib/scaffold/__tests__/__snapshots__/scaffold-golden.test.ts.snap +1742 -0
- package/src/lib/scaffold/__tests__/helpers.ts +75 -0
- package/src/lib/scaffold/__tests__/scaffold-ds-contract.test.ts +248 -0
- package/src/lib/scaffold/__tests__/scaffold-golden.test.ts +267 -0
- package/src/lib/scaffold/__tests__/scaffold-runtime.test.tsx +193 -0
- package/src/lib/scaffold/field-dsl.ts +491 -0
- package/src/lib/scaffold/index.ts +531 -0
- package/src/lib/scaffold/targets.ts +68 -0
- package/src/lib/scaffold/templates/create-page.ts +52 -0
- package/src/lib/scaffold/templates/detail-page.ts +190 -0
- package/src/lib/scaffold/templates/form-config.ts +42 -0
- package/src/lib/scaffold/templates/index.ts +27 -0
- package/src/lib/scaffold/templates/list-page.ts +190 -0
- package/src/lib/scaffold/templates/metas.ts +48 -0
- package/src/lib/scaffold/templates/module-files.ts +87 -0
- package/src/lib/single-instance-strategy-guard.ts +51 -1
- package/src/lib/testing/__tests__/integration-app-only-playwright.test.ts +225 -0
- package/src/lib/testing/__tests__/integration-app-only.test.ts +320 -0
- package/src/lib/testing/__tests__/integration-discovery.test.ts +45 -1
- package/src/lib/testing/integration-discovery.ts +32 -2
- package/src/lib/testing/integration.ts +293 -11
- package/src/mercato.ts +39 -5
- package/dist/agentic/guides/modules/dashboards/incoming-installed-contributions.md +0 -11
|
@@ -11,3 +11,4 @@ export { generateModuleDi, type ModuleDiOptions } from './module-di'
|
|
|
11
11
|
export { generateModulePackageSources, type ModulePackageSourcesOptions } from './module-package-sources'
|
|
12
12
|
export { generateOpenApi, type GenerateOpenApiOptions } from './openapi'
|
|
13
13
|
export { generateWebResearchAdapters, type WebResearchAdaptersOptions } from './web-research-adapters'
|
|
14
|
+
export { generateCacheProviders, type CacheProvidersOptions } from './cache-providers'
|
|
@@ -41,6 +41,10 @@ import {
|
|
|
41
41
|
variableStatement,
|
|
42
42
|
} from './ast'
|
|
43
43
|
|
|
44
|
+
function namespaceEntityLookup(namespace: string, name: string) {
|
|
45
|
+
return propertyAccess(asExpression(identifier(namespace), 'Record<string, unknown>'), name)
|
|
46
|
+
}
|
|
47
|
+
|
|
44
48
|
export interface ModuleEntitiesOptions {
|
|
45
49
|
resolver: PackageResolver
|
|
46
50
|
quiet?: boolean
|
|
@@ -57,7 +61,7 @@ export async function generateModuleEntities(options: ModuleEntitiesOptions): Pr
|
|
|
57
61
|
const mods = resolver.loadEnabledModules()
|
|
58
62
|
getEnabledModuleIdentities(resolver, mods)
|
|
59
63
|
const imports: Array<{ name: string; moduleSpecifier: string }> = []
|
|
60
|
-
const entitySources: Array<{ importName: string; moduleId: string }> = []
|
|
64
|
+
const entitySources: Array<{ importName: string; moduleId: string; classNames: string[] }> = []
|
|
61
65
|
const classNameEntries: EntityClassNameEntry[] = []
|
|
62
66
|
let n = 0
|
|
63
67
|
|
|
@@ -102,10 +106,10 @@ export async function generateModuleEntities(options: ModuleEntitiesOptions): Pr
|
|
|
102
106
|
relImport = `${baseImport}/${sub}/${stripModuleCodeExtension(found.file)}`
|
|
103
107
|
}
|
|
104
108
|
imports.push({ name: importName, moduleSpecifier: relImport })
|
|
105
|
-
entitySources.push({ importName, moduleId: modId })
|
|
106
|
-
|
|
107
109
|
const entityFilePath = resolveEntitySourceFile(resolver, entry, found, fromApp)
|
|
108
|
-
|
|
110
|
+
const classNames = parseEntityClassNames(entityFilePath)
|
|
111
|
+
entitySources.push({ importName, moduleId: modId, classNames })
|
|
112
|
+
for (const className of classNames) {
|
|
109
113
|
classNameEntries.push({ className, moduleId: modId, sourcePath: entityFilePath })
|
|
110
114
|
}
|
|
111
115
|
}
|
|
@@ -211,6 +215,20 @@ export async function generateModuleEntities(options: ModuleEntitiesOptions): Pr
|
|
|
211
215
|
},
|
|
212
216
|
],
|
|
213
217
|
})
|
|
218
|
+
sourceFile.addVariableStatement({
|
|
219
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
220
|
+
isExported: true,
|
|
221
|
+
declarations: [{
|
|
222
|
+
name: 'ormEntityExportNamespaces',
|
|
223
|
+
type: 'readonly { moduleId: string; entities: Record<string, unknown> }[]',
|
|
224
|
+
initializer: arrayLiteral(entitySources.map(({ importName, moduleId, classNames }) => objectLiteral([
|
|
225
|
+
{ name: 'moduleId', value: moduleId },
|
|
226
|
+
{ name: 'entities', value: objectLiteral(classNames.map((name) => ({
|
|
227
|
+
name, value: namespaceEntityLookup(importName, name),
|
|
228
|
+
}))) },
|
|
229
|
+
])), (writer, entry) => entry(writer)),
|
|
230
|
+
}],
|
|
231
|
+
})
|
|
214
232
|
const output = getSourceText(sourceFile)
|
|
215
233
|
|
|
216
234
|
writeGeneratedFile({
|
|
@@ -213,6 +213,7 @@ const FRAMEWORK_OVERRIDE_HOSTS = [
|
|
|
213
213
|
frameworkOverrideHost('di', 'disable-replace'),
|
|
214
214
|
frameworkOverrideHost('encryption.maps', 'disable-replace'),
|
|
215
215
|
frameworkOverrideHost('nav.groupOrder', 'additive'),
|
|
216
|
+
frameworkOverrideHost('forms.sections', 'disable-replace'),
|
|
216
217
|
] as const
|
|
217
218
|
|
|
218
219
|
function allFrameworkHosts(): ModuleExtensionHostFact[] {
|
|
@@ -48,6 +48,8 @@ import {
|
|
|
48
48
|
type ModuleOverrideTarget,
|
|
49
49
|
type ModuleOverrideTargetDiagnostic,
|
|
50
50
|
} from './module-override-targets'
|
|
51
|
+
import { prepareCrudFormSectionRegistries, projectCrudFormSectionContributions, type CrudFormSectionContributionProjection } from './form-sections'
|
|
52
|
+
import { resolveModuleFile } from './scanner'
|
|
51
53
|
import { buildFactSourceLookup, type FactSourceLookup } from './module-fact-sources'
|
|
52
54
|
import { appendLocalReferenceModuleSource } from './module-facts-discovery'
|
|
53
55
|
|
|
@@ -283,11 +285,19 @@ export interface ModuleFacts {
|
|
|
283
285
|
factSources?: ModuleFactSourceEntry[]
|
|
284
286
|
ownedContracts?: ModuleOwnedContracts
|
|
285
287
|
factDiagnostics?: ModuleFactDiagnostic[]
|
|
288
|
+
formSectionContributions?: ModuleFormSectionContributionFact[]
|
|
286
289
|
overrideTargets?: ModuleOverrideTarget[]
|
|
287
290
|
overrideTargetDiagnostics?: ModuleOverrideTargetDiagnostic[]
|
|
288
291
|
warnings: string[]
|
|
289
292
|
}
|
|
290
293
|
|
|
294
|
+
export type ModuleFormSectionContributionFact = {
|
|
295
|
+
id: string
|
|
296
|
+
key: string
|
|
297
|
+
operation: CrudFormSectionContributionProjection['operation']
|
|
298
|
+
source: ModuleFactSourceRef
|
|
299
|
+
}
|
|
300
|
+
|
|
291
301
|
export interface ExtractModuleFactsOptions {
|
|
292
302
|
moduleId: string
|
|
293
303
|
/**
|
|
@@ -313,6 +323,7 @@ export interface ExtractModuleFactsOptions {
|
|
|
313
323
|
sourceKind?: ModuleFactProjectionSourceKind
|
|
314
324
|
/** Generated-facts compatibility projection. Omitted means the corrected v2 contract. */
|
|
315
325
|
factsContractVersion?: 1 | 2
|
|
326
|
+
formSectionContributions?: readonly CrudFormSectionContributionProjection[]
|
|
316
327
|
}
|
|
317
328
|
|
|
318
329
|
/** A discovered module and the source directory its facts are extracted from. */
|
|
@@ -2339,6 +2350,10 @@ export function extractModuleFacts(options: ExtractModuleFactsOptions): ModuleFa
|
|
|
2339
2350
|
left.id.localeCompare(right.id),
|
|
2340
2351
|
)
|
|
2341
2352
|
|
|
2353
|
+
const formSectionContributions = options.factsContractVersion === 1 ? [] :
|
|
2354
|
+
(options.formSectionContributions ?? []).map(({ id, key, operation, sourceFileName, exportName }) => ({
|
|
2355
|
+
id, key, operation, source: { sourcePath: path.posix.join(sourceRoot, sourceFileName), exportName },
|
|
2356
|
+
}))
|
|
2342
2357
|
const facts: ModuleFacts = {
|
|
2343
2358
|
module: moduleId,
|
|
2344
2359
|
title,
|
|
@@ -2365,6 +2380,7 @@ export function extractModuleFacts(options: ExtractModuleFactsOptions): ModuleFa
|
|
|
2365
2380
|
extensionSurfaces,
|
|
2366
2381
|
...(provenance.factSources.length > 0 ? { factSources: provenance.factSources } : {}),
|
|
2367
2382
|
...(ownedContracts ? { ownedContracts } : {}),
|
|
2383
|
+
...(formSectionContributions.length ? { formSectionContributions } : {}),
|
|
2368
2384
|
...(factDiagnostics.length > 0 ? { factDiagnostics } : {}),
|
|
2369
2385
|
warnings,
|
|
2370
2386
|
}
|
|
@@ -2414,6 +2430,7 @@ export interface ModuleFactsJsonEntry {
|
|
|
2414
2430
|
factSources?: ModuleFactSourceEntry[]
|
|
2415
2431
|
ownedContracts?: ModuleOwnedContracts
|
|
2416
2432
|
factDiagnostics?: ModuleFactDiagnostic[]
|
|
2433
|
+
formSectionContributions?: ModuleFormSectionContributionFact[]
|
|
2417
2434
|
overrideTargets?: ModuleOverrideTarget[]
|
|
2418
2435
|
overrideTargetDiagnostics?: ModuleOverrideTargetDiagnostic[]
|
|
2419
2436
|
}
|
|
@@ -3159,6 +3176,7 @@ export function toModuleFactsJsonEntry(facts: ModuleFacts): ModuleFactsJsonEntry
|
|
|
3159
3176
|
...(facts.factDiagnostics && facts.factDiagnostics.length > 0
|
|
3160
3177
|
? { factDiagnostics: facts.factDiagnostics }
|
|
3161
3178
|
: {}),
|
|
3179
|
+
...(facts.formSectionContributions?.length ? { formSectionContributions: facts.formSectionContributions } : {}),
|
|
3162
3180
|
...(facts.overrideTargets && facts.overrideTargets.length > 0
|
|
3163
3181
|
? { overrideTargets: facts.overrideTargets }
|
|
3164
3182
|
: {}),
|
|
@@ -3384,6 +3402,19 @@ export interface LocalReferenceModuleFactsResult {
|
|
|
3384
3402
|
unresolvedTargets: string[]
|
|
3385
3403
|
}
|
|
3386
3404
|
|
|
3405
|
+
export function prepareReferenceFormSectionContributions(
|
|
3406
|
+
reference: ModuleFactSource,
|
|
3407
|
+
): ReadonlyMap<string, readonly CrudFormSectionContributionProjection[]> {
|
|
3408
|
+
const roots = { appBase: reference.moduleRoot, pkgBase: reference.moduleRoot }
|
|
3409
|
+
const sourceRoot = reference.portableSourceRoot ?? toPortableSourceRoot(reference.moduleId, reference.from ?? null)
|
|
3410
|
+
const imports = { appBase: sourceRoot, pkgBase: sourceRoot }
|
|
3411
|
+
return projectCrudFormSectionContributions(prepareCrudFormSectionRegistries({
|
|
3412
|
+
modules: [{ modId: reference.moduleId, roots, resolve: (relativePath) => resolveModuleFile(roots, imports, relativePath) }],
|
|
3413
|
+
identities: [{ id: reference.moduleId }],
|
|
3414
|
+
requiresByModule: new Map(),
|
|
3415
|
+
}))
|
|
3416
|
+
}
|
|
3417
|
+
|
|
3387
3418
|
/**
|
|
3388
3419
|
* Produces the reference projection of an app-local module from an explicitly activated,
|
|
3389
3420
|
* disposable selection context: the local source is appended to the package sources and
|
|
@@ -3412,6 +3443,7 @@ export function extractLocalReferenceModuleFacts(
|
|
|
3412
3443
|
const sources = appendLocalReferenceModuleSource(options.packageSources, reference)
|
|
3413
3444
|
const activated = extractAllModuleFacts({
|
|
3414
3445
|
sources,
|
|
3446
|
+
formSectionContributions: prepareReferenceFormSectionContributions(reference),
|
|
3415
3447
|
registryPath: options.registryPath ?? null,
|
|
3416
3448
|
registrySource: options.registrySource ?? null,
|
|
3417
3449
|
coreVersion: options.coreVersion ?? null,
|
|
@@ -3473,6 +3505,7 @@ export interface ExtractAllModuleFactsOptions {
|
|
|
3473
3505
|
* so a disposable projection can publish the gap instead of silently dropping it.
|
|
3474
3506
|
*/
|
|
3475
3507
|
unresolvedFirstPartyTargets?: 'throw' | 'collect'
|
|
3508
|
+
formSectionContributions?: ReadonlyMap<string, readonly CrudFormSectionContributionProjection[]>
|
|
3476
3509
|
/** Generated-facts compatibility projection. Omitted means the corrected v2 contract. */
|
|
3477
3510
|
factsContractVersion?: 1 | 2
|
|
3478
3511
|
}
|
|
@@ -3542,6 +3575,7 @@ function extractAllModuleFactsWithCache(options: ExtractAllModuleFactsOptions):
|
|
|
3542
3575
|
...(source.portableSourceRoot ? { portableSourceRoot: source.portableSourceRoot } : {}),
|
|
3543
3576
|
...(source.sourceKind ? { sourceKind: source.sourceKind } : {}),
|
|
3544
3577
|
factsContractVersion: options.factsContractVersion ?? 2,
|
|
3578
|
+
formSectionContributions: options.formSectionContributions?.get(source.moduleId),
|
|
3545
3579
|
})
|
|
3546
3580
|
factsByModule[source.moduleId] = facts
|
|
3547
3581
|
warnings.push(...facts.warnings)
|
|
@@ -3758,6 +3792,12 @@ const OVERRIDE_DOMAIN_COVERAGE: Readonly<Record<string, ModuleFactCoverageRow>>
|
|
|
3758
3792
|
status: 'framework-only',
|
|
3759
3793
|
note: 'nav.groupOrder is an app-level framework setting; no module target is ever emitted for it',
|
|
3760
3794
|
},
|
|
3795
|
+
forms: {
|
|
3796
|
+
value: 'forms',
|
|
3797
|
+
status: 'emitted-example',
|
|
3798
|
+
requiresGeneratedRegistry: true,
|
|
3799
|
+
note: 'exact forms.sections targets projected from generated section contributions',
|
|
3800
|
+
},
|
|
3761
3801
|
}
|
|
3762
3802
|
|
|
3763
3803
|
const OVERRIDE_MODE_COVERAGE: Readonly<Record<string, ModuleFactCoverageRow>> = {
|
|
@@ -807,6 +807,23 @@ const navAdapter: InternalAdapter = {
|
|
|
807
807
|
},
|
|
808
808
|
}
|
|
809
809
|
|
|
810
|
+
const formsAdapter: InternalAdapter = {
|
|
811
|
+
domain: 'forms',
|
|
812
|
+
run(facts) {
|
|
813
|
+
const moduleId = moduleIdOf(facts)
|
|
814
|
+
const targets: ModuleOverrideTarget[] = []
|
|
815
|
+
const diagnostics: ModuleOverrideTargetDiagnostic[] = []
|
|
816
|
+
for (const { id, key, source } of facts.formSectionContributions ?? []) {
|
|
817
|
+
pushTarget(targets, diagnostics, {
|
|
818
|
+
moduleId, domain: 'forms', key, path: ['forms', 'sections', key], dottedHost: 'forms.sections',
|
|
819
|
+
factRef: { factSection: 'formSectionContributions', factKey: id },
|
|
820
|
+
source,
|
|
821
|
+
})
|
|
822
|
+
}
|
|
823
|
+
return { targets, diagnostics }
|
|
824
|
+
},
|
|
825
|
+
}
|
|
826
|
+
|
|
810
827
|
const INTERNAL_ADAPTERS: InternalAdapter[] = [
|
|
811
828
|
aiAdapter,
|
|
812
829
|
routesAdapter,
|
|
@@ -824,6 +841,7 @@ const INTERNAL_ADAPTERS: InternalAdapter[] = [
|
|
|
824
841
|
diAdapter,
|
|
825
842
|
encryptionAdapter,
|
|
826
843
|
navAdapter,
|
|
844
|
+
formsAdapter,
|
|
827
845
|
]
|
|
828
846
|
|
|
829
847
|
/**
|
|
@@ -850,6 +868,7 @@ const OVERRIDE_DOMAIN_PRESENCE: Record<ModuleOverrideDomain, true> = {
|
|
|
850
868
|
di: true,
|
|
851
869
|
encryption: true,
|
|
852
870
|
nav: true,
|
|
871
|
+
forms: true,
|
|
853
872
|
}
|
|
854
873
|
|
|
855
874
|
export const ALL_OVERRIDE_DOMAINS = Object.keys(OVERRIDE_DOMAIN_PRESENCE) as ModuleOverrideDomain[]
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { matchRoutePattern } from '@open-mercato/shared/modules/registry'
|
|
1
2
|
import { sourceHasDefaultExport, sourceExportedHttpMethods } from './source-exports'
|
|
2
3
|
import fs from 'node:fs'
|
|
3
4
|
import path from 'node:path'
|
|
@@ -79,6 +80,7 @@ import {
|
|
|
79
80
|
resolveStandaloneSourceMirrorBase,
|
|
80
81
|
} from './scanner'
|
|
81
82
|
import { loadGeneratorExtensions } from './extensions'
|
|
83
|
+
import { prepareCrudFormSectionRegistries, writeCrudFormSectionRegistries, writeDerivedCrudFormSectionRoutes } from './form-sections'
|
|
82
84
|
import type { ModuleScanContext, StandaloneConfigOptions } from './extension'
|
|
83
85
|
import {
|
|
84
86
|
renderRouteManifestShardOutputs,
|
|
@@ -101,6 +103,7 @@ interface ModuleRegistryDiscovery {
|
|
|
101
103
|
modules: ModuleRegistryDiscoveryEntry[]
|
|
102
104
|
identities: ReturnType<typeof getEnabledModuleIdentities>
|
|
103
105
|
getStructureChecksum: () => string
|
|
106
|
+
getCrudFormSections: () => ReturnType<typeof prepareCrudFormSectionRegistries>
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
type DiscoveredSubscriber = {
|
|
@@ -127,6 +130,7 @@ type ModuleRegistryDiscoveryEntry = {
|
|
|
127
130
|
imps: ModuleImports
|
|
128
131
|
appImportBase: string
|
|
129
132
|
isAppModule: boolean
|
|
133
|
+
formSectionOverrides?: ModuleEntry['formSectionOverrides']
|
|
130
134
|
resolve: (relativePath: string) => ResolvedFile | null
|
|
131
135
|
frontendFiles: ScannedFile[]
|
|
132
136
|
backendFiles: ScannedFile[]
|
|
@@ -1923,6 +1927,7 @@ function buildManifestRouteLoader(importPath: string): WriterFunction {
|
|
|
1923
1927
|
function buildManifestApiLoader(importPath: string): WriterFunction {
|
|
1924
1928
|
return arrowFunction({
|
|
1925
1929
|
async: true,
|
|
1930
|
+
returnType: "ReturnType<ApiRouteManifestEntry['load']>",
|
|
1926
1931
|
body: importExpression(sanitizeGeneratedModuleSpecifier(importPath)),
|
|
1927
1932
|
})
|
|
1928
1933
|
}
|
|
@@ -2190,6 +2195,7 @@ async function createModuleRegistryDiscovery(
|
|
|
2190
2195
|
imps,
|
|
2191
2196
|
appImportBase,
|
|
2192
2197
|
isAppModule: entry.from === '@app',
|
|
2198
|
+
formSectionOverrides: entry.formSectionOverrides,
|
|
2193
2199
|
resolve,
|
|
2194
2200
|
frontendFiles: scanModuleDir(roots, SCAN_CONFIGS.frontendPages),
|
|
2195
2201
|
backendFiles: scanModuleDir(roots, SCAN_CONFIGS.backendPages),
|
|
@@ -2207,11 +2213,22 @@ async function createModuleRegistryDiscovery(
|
|
|
2207
2213
|
}
|
|
2208
2214
|
|
|
2209
2215
|
let structureChecksum: string | undefined
|
|
2216
|
+
let crudFormSections: ReturnType<typeof prepareCrudFormSectionRegistries> | undefined
|
|
2217
|
+
function getCrudFormSections() {
|
|
2218
|
+
if (crudFormSections) return crudFormSections
|
|
2219
|
+
const requiresByModule = new Map<string, string[]>()
|
|
2220
|
+
for (const module of modules) {
|
|
2221
|
+
const index = module.resolve('index.ts')
|
|
2222
|
+
if (index) collectDeclaredModuleRequires(module.modId, index.absolutePath, requiresByModule, quiet)
|
|
2223
|
+
}
|
|
2224
|
+
return crudFormSections = prepareCrudFormSectionRegistries({ modules, identities, requiresByModule })
|
|
2225
|
+
}
|
|
2210
2226
|
return {
|
|
2211
2227
|
enabled,
|
|
2212
2228
|
modules,
|
|
2213
2229
|
identities,
|
|
2214
2230
|
getStructureChecksum: () => structureChecksum ??= calculateStructureChecksum(Array.from(trackedRoots)),
|
|
2231
|
+
getCrudFormSections,
|
|
2215
2232
|
}
|
|
2216
2233
|
}
|
|
2217
2234
|
|
|
@@ -2718,6 +2735,7 @@ function buildModuleCustomFieldSetsValue(options: {
|
|
|
2718
2735
|
fieldsImportName?: string | null
|
|
2719
2736
|
customEntitiesImportName?: string | null
|
|
2720
2737
|
moduleId: string
|
|
2738
|
+
compiledFields?: readonly import('@open-mercato/shared/modules/entities').CustomFieldSet[]
|
|
2721
2739
|
}): WriterFunction {
|
|
2722
2740
|
const parts: WriterFunction[] = []
|
|
2723
2741
|
|
|
@@ -2772,9 +2790,14 @@ function buildModuleCustomFieldSetsValue(options: {
|
|
|
2772
2790
|
parts.push(spreadExpression(mappedEntities))
|
|
2773
2791
|
}
|
|
2774
2792
|
|
|
2793
|
+
if (options.compiledFields?.length) parts.push(spreadExpression(identifier(compiledFieldSetsExpression(options.compiledFields))))
|
|
2775
2794
|
return arrayLiteral(parts, writeValue)
|
|
2776
2795
|
}
|
|
2777
2796
|
|
|
2797
|
+
function compiledFieldSetsExpression(fields: readonly import('@open-mercato/shared/modules/entities').CustomFieldSet[]): string {
|
|
2798
|
+
return `(${JSON.stringify(fields)} satisfies import('@open-mercato/shared/modules/entities').CustomFieldSet[])`
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2778
2801
|
function buildModuleDashboardWidgetsValue(entries: DashboardWidgetEntry[]): WriterFunction {
|
|
2779
2802
|
return arrayLiteral(
|
|
2780
2803
|
entries.map((entry) =>
|
|
@@ -3769,6 +3792,22 @@ async function generateModuleRegistryFromDiscovery(options: ModuleRegistryRender
|
|
|
3769
3792
|
const backendRouteMetadataEntries: RouteManifestShardEntry[] = []
|
|
3770
3793
|
const apiRouteShardEntries: RouteManifestShardEntry[] = []
|
|
3771
3794
|
const apiRouteMetadataEntries: RouteManifestShardEntry[] = []
|
|
3795
|
+
const needsDerivedRoutes = ['main', 'runtime', 'api-routes'].some((group) => selectsRegistryOutput(options, group))
|
|
3796
|
+
const derivedCrudRoutes = needsDerivedRoutes ? writeDerivedCrudFormSectionRoutes({
|
|
3797
|
+
modules: discovery.modules,
|
|
3798
|
+
identities: discovery.identities,
|
|
3799
|
+
requiresByModule: new Map(),
|
|
3800
|
+
outputDir,
|
|
3801
|
+
structureChecksum: discovery.getStructureChecksum(),
|
|
3802
|
+
result,
|
|
3803
|
+
quiet,
|
|
3804
|
+
}) : []
|
|
3805
|
+
for (const { routePath } of derivedCrudRoutes) {
|
|
3806
|
+
if (!/^(?:\/[A-Za-z0-9_.-]+)+$/.test(routePath) || routePath.split('/').some((segment) => segment === '.' || segment === '..')) {
|
|
3807
|
+
throw new Error(`[generate] Derived CrudForm route requires a literal API path without parameters: "${routePath}"`)
|
|
3808
|
+
}
|
|
3809
|
+
}
|
|
3810
|
+
|
|
3772
3811
|
// Mutable ref so extracted helper functions can increment the shared counter
|
|
3773
3812
|
const importIdRef = { value: 0 }
|
|
3774
3813
|
const requiresByModule = new Map<string, string[]>()
|
|
@@ -4012,6 +4051,25 @@ async function generateModuleRegistryFromDiscovery(options: ModuleRegistryRender
|
|
|
4012
4051
|
apiRouteManifestDecls.push(...generatedApis.manifestApis)
|
|
4013
4052
|
apiRouteShardEntries.push(...generatedApis.manifestShardApis)
|
|
4014
4053
|
apiRouteMetadataEntries.push(...generatedApis.metadataApis)
|
|
4054
|
+
for (const derived of derivedCrudRoutes.filter((route) => route.moduleId === modId)) {
|
|
4055
|
+
const importPath = `./${stripModuleCodeExtension(derived.fileName)}`
|
|
4056
|
+
const importName = `DERIVED_CRUD_${importIdRef.value++}`
|
|
4057
|
+
imports.push(buildImportStatement(`* as ${importName}`, importPath))
|
|
4058
|
+
runtimeImports.push(buildImportStatement(`* as ${importName}`, importPath))
|
|
4059
|
+
const entry = `{ path: ${toLiteral(derived.routePath)}, metadata: ${importName}.metadata, handlers: ${importName}, docs: ${importName}.openApi }`
|
|
4060
|
+
apis.push(entry)
|
|
4061
|
+
runtimeApis.push(entry)
|
|
4062
|
+
const entries: GeneratedObjectEntry[] = [
|
|
4063
|
+
{ name: 'moduleId', value: modId },
|
|
4064
|
+
{ name: 'kind', value: 'route-file' },
|
|
4065
|
+
{ name: 'path', value: derived.routePath },
|
|
4066
|
+
{ name: 'methods', value: arrayLiteral(derived.methods, writeValue) },
|
|
4067
|
+
]
|
|
4068
|
+
const manifestEntry = objectLiteral([...entries, { name: 'load', value: buildManifestApiLoader(importPath) }])
|
|
4069
|
+
apiRouteManifestDecls.push(manifestEntry)
|
|
4070
|
+
apiRouteShardEntries.push({ path: derived.routePath, declaration: renderGeneratedValue(manifestEntry) })
|
|
4071
|
+
apiRouteMetadataEntries.push({ path: derived.routePath, declaration: renderGeneratedValue(objectLiteral(entries)) })
|
|
4072
|
+
}
|
|
4015
4073
|
}
|
|
4016
4074
|
|
|
4017
4075
|
// 15. CLI
|
|
@@ -4051,6 +4109,8 @@ async function generateModuleRegistryFromDiscovery(options: ModuleRegistryRender
|
|
|
4051
4109
|
parts.push(
|
|
4052
4110
|
`((( ${customEntitiesImportName}.default ?? ${customEntitiesImportName}.entities) as any) || []).filter((e: any) => Array.isArray(e.fields) && e.fields.length).map((e: any) => ({ entity: e.id, fields: e.fields, source: ${toLiteral(modId)} }))`
|
|
4053
4111
|
)
|
|
4112
|
+
const compiledFields = discovery.getCrudFormSections().compiled.customFieldSetsByModule.get(modId)
|
|
4113
|
+
if (compiledFields?.length) parts.push(compiledFieldSetsExpression(compiledFields))
|
|
4054
4114
|
customFieldSetsExpr = parts.length ? `[...${parts.join(', ...')}]` : '[]'
|
|
4055
4115
|
}
|
|
4056
4116
|
|
|
@@ -4330,6 +4390,11 @@ async function generateModuleRegistryFromDiscovery(options: ModuleRegistryRender
|
|
|
4330
4390
|
imports: backendRouteManifestImports,
|
|
4331
4391
|
entries: backendRouteManifestDecls,
|
|
4332
4392
|
}))
|
|
4393
|
+
for (const derived of derivedCrudRoutes) {
|
|
4394
|
+
if (apiRouteMetadataEntries.filter(({ path: routePath }) => matchRoutePattern(routePath, derived.routePath) !== undefined).length !== 1) {
|
|
4395
|
+
throw new Error(`[generate] Derived CrudForm route conflicts with an existing API route "${derived.routePath}"`)
|
|
4396
|
+
}
|
|
4397
|
+
}
|
|
4333
4398
|
writeOutput('api-routes', 'api-routes.generated.ts', () => renderAstManifestFile({
|
|
4334
4399
|
fileName: 'api-routes.generated.ts',
|
|
4335
4400
|
typeName: 'ApiRouteManifestEntry',
|
|
@@ -4638,7 +4703,7 @@ async function generateModuleRegistryAppFromDiscovery(options: ModuleRegistryRen
|
|
|
4638
4703
|
|
|
4639
4704
|
const moduleEntries: GeneratedObjectEntry[] = [
|
|
4640
4705
|
{ name: 'id', value: modId },
|
|
4641
|
-
{ name: 'customFieldSets', value: buildModuleCustomFieldSetsValue({ fieldsImportName, customEntitiesImportName, moduleId: modId }) },
|
|
4706
|
+
{ name: 'customFieldSets', value: buildModuleCustomFieldSetsValue({ fieldsImportName, customEntitiesImportName, moduleId: modId, compiledFields: discovery.getCrudFormSections().compiled.customFieldSetsByModule.get(modId) }) },
|
|
4642
4707
|
]
|
|
4643
4708
|
const i18nModuleEntries: GeneratedObjectEntry[] = [
|
|
4644
4709
|
{ name: 'id', value: modId },
|
|
@@ -4759,9 +4824,21 @@ async function generateModuleRegistryAppFromDiscovery(options: ModuleRegistryRen
|
|
|
4759
4824
|
i18nModuleDecls.push(objectLiteral(i18nModuleEntries))
|
|
4760
4825
|
}
|
|
4761
4826
|
|
|
4762
|
-
|
|
4763
4827
|
exitOnMissingModuleRequires(discovery.identities, requiresByModule)
|
|
4764
4828
|
|
|
4829
|
+
if (selectsRegistryOutput(options, 'app')) {
|
|
4830
|
+
writeCrudFormSectionRegistries({
|
|
4831
|
+
prepared: discovery.getCrudFormSections(),
|
|
4832
|
+
modules: discovery.modules,
|
|
4833
|
+
identities: discovery.identities,
|
|
4834
|
+
requiresByModule,
|
|
4835
|
+
outputDir,
|
|
4836
|
+
structureChecksum: discovery.getStructureChecksum(),
|
|
4837
|
+
result,
|
|
4838
|
+
quiet,
|
|
4839
|
+
})
|
|
4840
|
+
}
|
|
4841
|
+
|
|
4765
4842
|
writeOutput('app', 'modules.app.generated.ts', () => renderAstModuleRegistryFile({
|
|
4766
4843
|
fileName: 'modules.app.generated.ts',
|
|
4767
4844
|
generator: 'registry (app version)',
|
|
@@ -4991,7 +5068,7 @@ async function generateModuleRegistryCliFromDiscovery(options: ModuleRegistryRen
|
|
|
4991
5068
|
|
|
4992
5069
|
const moduleEntries: GeneratedObjectEntry[] = [
|
|
4993
5070
|
{ name: 'id', value: modId },
|
|
4994
|
-
{ name: 'customFieldSets', value: buildModuleCustomFieldSetsValue({ fieldsImportName, customEntitiesImportName, moduleId: modId }) },
|
|
5071
|
+
{ name: 'customFieldSets', value: buildModuleCustomFieldSetsValue({ fieldsImportName, customEntitiesImportName, moduleId: modId, compiledFields: discovery.getCrudFormSections().compiled.customFieldSetsByModule.get(modId) }) },
|
|
4995
5072
|
]
|
|
4996
5073
|
|
|
4997
5074
|
if (infoImportName) {
|
|
@@ -5110,7 +5187,6 @@ async function generateModuleRegistryCliFromDiscovery(options: ModuleRegistryRen
|
|
|
5110
5187
|
moduleDecls.push(objectLiteral(moduleEntries))
|
|
5111
5188
|
}
|
|
5112
5189
|
|
|
5113
|
-
|
|
5114
5190
|
exitOnMissingModuleRequires(discovery.identities, requiresByModule)
|
|
5115
5191
|
|
|
5116
5192
|
writeOutput('cli', 'modules.cli.generated.ts', () => renderAstModuleRegistryFile({
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as fs from 'node:fs'
|
|
10
|
-
import { randomBytes } from 'node:crypto'
|
|
11
10
|
import * as path from 'node:path'
|
|
12
11
|
import type { ModuleEntry, PackageResolver } from '../resolver'
|
|
13
12
|
import { getEnabledModuleIdentities } from '../module-identity'
|
|
14
13
|
import { isModuleRouteFile } from './scanner'
|
|
14
|
+
import { resolveNamedObjectExport } from './module-registry'
|
|
15
|
+
import { generatedDerivedCrudRouteIndex, readDerivedCrudFormSectionRouteIndex } from './form-sections'
|
|
15
16
|
import {
|
|
16
17
|
calculateChecksum,
|
|
17
18
|
calculateStructureChecksum,
|
|
@@ -31,12 +32,13 @@ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
|
|
|
31
32
|
|
|
32
33
|
interface ApiRouteInfo {
|
|
33
34
|
path: string
|
|
35
|
+
moduleId: string
|
|
34
36
|
methods: HttpMethod[]
|
|
35
37
|
openApiPath: string
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
interface OpenApiInputManifest {
|
|
39
|
-
version:
|
|
41
|
+
version: 2
|
|
40
42
|
inputPaths: string[]
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -54,9 +56,10 @@ interface OpenApiInputContext {
|
|
|
54
56
|
interface OpenApiBundleResult {
|
|
55
57
|
doc: Record<string, any> | null
|
|
56
58
|
inputPaths: string[]
|
|
59
|
+
qualifierFailure?: string
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
const OPENAPI_INPUT_MANIFEST_VERSION =
|
|
62
|
+
const OPENAPI_INPUT_MANIFEST_VERSION = 2
|
|
60
63
|
|
|
61
64
|
function createOpenApiInputContext(resolver: PackageResolver): OpenApiInputContext {
|
|
62
65
|
const enabled = resolver.loadEnabledModules()
|
|
@@ -149,6 +152,7 @@ function calculateOpenApiInputFingerprint(
|
|
|
149
152
|
const appDir = resolver.getAppDir()
|
|
150
153
|
const configPaths = [
|
|
151
154
|
resolver.getModulesConfigPath(),
|
|
155
|
+
path.join(resolver.getOutputDir(), generatedDerivedCrudRouteIndex),
|
|
152
156
|
path.join(rootDir, 'package.json'),
|
|
153
157
|
path.join(rootDir, 'yarn.lock'),
|
|
154
158
|
path.join(rootDir, 'package-lock.json'),
|
|
@@ -229,18 +233,30 @@ async function findApiRoutes(
|
|
|
229
233
|
|
|
230
234
|
// Build API path
|
|
231
235
|
const routeSegs = relativePath ? relativePath.split('/') : []
|
|
232
|
-
const
|
|
236
|
+
const metadataPath = resolveNamedObjectExport(fullPath, 'metadata')?.path
|
|
237
|
+
const routePath = typeof metadataPath === 'string' && metadataPath
|
|
238
|
+
? metadataPath
|
|
239
|
+
: `/${modId}${routeSegs.length ? '/' + routeSegs.join('/') : ''}`
|
|
240
|
+
const apiPath = `/api/${routePath.replace(/^\/+/, '')}`
|
|
233
241
|
// Convert [param] to {param} for OpenAPI format
|
|
234
242
|
.replace(/\[([^\]]+)\]/g, '{$1}')
|
|
235
243
|
|
|
236
244
|
routes.push({
|
|
237
245
|
path: fullPath,
|
|
246
|
+
moduleId: modId,
|
|
238
247
|
methods: await detectMethods(fullPath),
|
|
239
248
|
openApiPath: apiPath,
|
|
240
249
|
})
|
|
241
250
|
}
|
|
242
251
|
}
|
|
243
252
|
|
|
253
|
+
const enabledIds = new Set(enabled.map(({ id }) => id))
|
|
254
|
+
const derived = readDerivedCrudFormSectionRouteIndex(resolver.getOutputDir())
|
|
255
|
+
routes.push(...derived.filter(({ moduleId }) => enabledIds.has(moduleId)).map(({ moduleId, routePath, methods, fileName }) => ({
|
|
256
|
+
moduleId, methods,
|
|
257
|
+
path: path.join(resolver.getOutputDir(), fileName),
|
|
258
|
+
openApiPath: `/api${routePath}`.replace(/\[([^\]]+)\]/g, '{$1}'),
|
|
259
|
+
})))
|
|
244
260
|
return routes
|
|
245
261
|
}
|
|
246
262
|
|
|
@@ -372,13 +388,6 @@ async function generateOpenApiViaBundle(
|
|
|
372
388
|
return { doc: null, inputPaths: [] }
|
|
373
389
|
}
|
|
374
390
|
|
|
375
|
-
const cacheDir = path.join(rootDir, 'node_modules', '.cache')
|
|
376
|
-
if (!fs.existsSync(cacheDir)) fs.mkdirSync(cacheDir, { recursive: true })
|
|
377
|
-
|
|
378
|
-
// Per-run file: `yarn dev`'s watcher and a CLI `generate` (e.g. after
|
|
379
|
-
// create-mercato-module init) can bundle concurrently, and a shared path let
|
|
380
|
-
// one process execute the other's half-written bundle ("Unexpected end of input").
|
|
381
|
-
const bundlePath = path.join(cacheDir, `_openapi-bundle-${process.pid}-${randomBytes(6).toString('hex')}.mjs`)
|
|
382
391
|
let inputPaths: string[] = []
|
|
383
392
|
|
|
384
393
|
// Build the entry script that imports all routes and calls buildOpenApiDocument
|
|
@@ -392,7 +401,7 @@ async function generateOpenApiViaBundle(
|
|
|
392
401
|
importLines.push(`import * as R${i} from ${JSON.stringify(route.path)};`)
|
|
393
402
|
// Use [param] format so normalizePath in buildOpenApiDocument extracts path params
|
|
394
403
|
const bracketPath = route.openApiPath.replace(/\{([^}]+)\}/g, '[$1]')
|
|
395
|
-
routeMapLines.push(` [${JSON.stringify(bracketPath)}, R${i}],`)
|
|
404
|
+
routeMapLines.push(` [${JSON.stringify(bracketPath)}, ${JSON.stringify(route.moduleId)}, R${i}],`)
|
|
396
405
|
}
|
|
397
406
|
|
|
398
407
|
const entryScript = `${importLines.join('\n')}
|
|
@@ -402,8 +411,7 @@ ${routeMapLines.join('\n')}
|
|
|
402
411
|
];
|
|
403
412
|
|
|
404
413
|
const modules = new Map();
|
|
405
|
-
for (const [apiPath, mod] of routeEntries) {
|
|
406
|
-
const moduleId = apiPath.replace(/^\\/api\\//, '').split('/')[0];
|
|
414
|
+
for (const [apiPath, moduleId, mod] of routeEntries) {
|
|
407
415
|
if (!modules.has(moduleId)) modules.set(moduleId, { id: moduleId, apis: [] });
|
|
408
416
|
modules.get(moduleId).apis.push({
|
|
409
417
|
path: apiPath,
|
|
@@ -565,6 +573,8 @@ process.stdout.write(JSON.stringify(deepClone(doc), (_, v) =>
|
|
|
565
573
|
},
|
|
566
574
|
}
|
|
567
575
|
|
|
576
|
+
const bundleDir = fs.mkdtempSync(path.join(resolver.getOutputDir(), '.openapi-'))
|
|
577
|
+
const bundlePath = path.join(bundleDir, 'bundle.mjs')
|
|
568
578
|
try {
|
|
569
579
|
const buildResult = await esbuild.build({
|
|
570
580
|
stdin: {
|
|
@@ -639,16 +649,13 @@ process.stdout.write(JSON.stringify(deepClone(doc), (_, v) =>
|
|
|
639
649
|
}
|
|
640
650
|
}
|
|
641
651
|
}
|
|
642
|
-
|
|
652
|
+
const qualifierFailure = /Cannot derive CrudForm section host: [^\r\n]+/.exec(`${errMsg}\n${String(stderr ?? '')}`)?.[0]
|
|
653
|
+
return { doc: null, inputPaths, qualifierFailure }
|
|
643
654
|
} finally {
|
|
644
655
|
// Shut down esbuild's persistent Go service so it does not deadlock at
|
|
645
656
|
// process exit when a plugin request is still in flight.
|
|
646
657
|
try { await esbuild.stop() } catch {}
|
|
647
|
-
|
|
648
|
-
try { fs.unlinkSync(bundlePath) } catch {}
|
|
649
|
-
for (const file of ['_openapi-bundle.mjs', '_openapi-register.mjs', '_openapi-loader.mjs', '_next-stub.cjs']) {
|
|
650
|
-
try { fs.unlinkSync(path.join(cacheDir, file)) } catch {}
|
|
651
|
-
}
|
|
658
|
+
try { fs.rmSync(bundleDir, { recursive: true, force: true }) } catch {}
|
|
652
659
|
}
|
|
653
660
|
}
|
|
654
661
|
|
|
@@ -748,6 +755,10 @@ export async function generateOpenApi(options: GenerateOpenApiOptions): Promise<
|
|
|
748
755
|
const bundleResult = await generateOpenApiViaBundle(routes, resolver, quiet)
|
|
749
756
|
let doc: Record<string, any> | null = bundleResult.doc
|
|
750
757
|
|
|
758
|
+
if (!doc && readDerivedCrudFormSectionRouteIndex(outputDir).length) {
|
|
759
|
+
throw new Error(bundleResult.qualifierFailure ?? '[generate] Could not validate generated CrudForm section-policy OpenAPI schemas')
|
|
760
|
+
}
|
|
761
|
+
|
|
751
762
|
// Fallback to static regex approach (extracts operationId/summary/tags but no schemas)
|
|
752
763
|
if (!doc) {
|
|
753
764
|
if (!quiet) {
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
import { purgeConfiguredCachePatternsAcrossTenantScopes } from '@open-mercato/shared/lib/cache/maintenance'
|
|
4
|
+
import {
|
|
5
|
+
CacheProviderError,
|
|
6
|
+
isCacheProviderError,
|
|
7
|
+
prepareCacheProviderSelection,
|
|
8
|
+
readSelectedCacheProviderId,
|
|
9
|
+
} from '@open-mercato/shared/lib/cache/providers'
|
|
10
|
+
import { loadCacheProviderManifest } from './cache-provider-manifest'
|
|
4
11
|
|
|
5
12
|
const STRUCTURAL_CACHE_PATTERNS = [
|
|
6
13
|
'nav:*',
|
|
@@ -36,6 +43,26 @@ function touchGeneratedFiles(appDir: string): string[] {
|
|
|
36
43
|
return touched
|
|
37
44
|
}
|
|
38
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Purge the structural patterns through the effective cache selection. With a registered
|
|
48
|
+
* provider (`CACHE_PROVIDER`) the generated manifest is loaded and the same provider the app
|
|
49
|
+
* resolves is prepared first; the purge closes its maintenance client itself. Provider
|
|
50
|
+
* failures are reduced to a `CacheProviderError` so driver messages (which may embed
|
|
51
|
+
* endpoints or credentials) never reach the CLI diagnostics.
|
|
52
|
+
*/
|
|
53
|
+
async function purgeStructuralCacheEntries(appDir: string): Promise<number> {
|
|
54
|
+
const providerId = readSelectedCacheProviderId(process.env)
|
|
55
|
+
if (!providerId) return purgeConfiguredCachePatternsAcrossTenantScopes(STRUCTURAL_CACHE_PATTERNS)
|
|
56
|
+
try {
|
|
57
|
+
await loadCacheProviderManifest(appDir)
|
|
58
|
+
await prepareCacheProviderSelection()
|
|
59
|
+
return await purgeConfiguredCachePatternsAcrossTenantScopes(STRUCTURAL_CACHE_PATTERNS)
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (isCacheProviderError(error)) throw error
|
|
62
|
+
throw new CacheProviderError('unavailable', 'Cache provider structural purge failed', { cause: error })
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
39
66
|
export async function runPostGenerateStructuralInvalidation(
|
|
40
67
|
appDir: string,
|
|
41
68
|
): Promise<PostGenerateStructuralInvalidationResult> {
|
|
@@ -51,7 +78,7 @@ export async function runPostGenerateStructuralInvalidation(
|
|
|
51
78
|
}
|
|
52
79
|
|
|
53
80
|
try {
|
|
54
|
-
cacheEntriesDeleted = await
|
|
81
|
+
cacheEntriesDeleted = await purgeStructuralCacheEntries(appDir)
|
|
55
82
|
} catch (error) {
|
|
56
83
|
cacheError = error
|
|
57
84
|
}
|