@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
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import os from 'node:os'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { readEnabledModulesFromConfig } from '../resolver'
|
|
5
|
+
|
|
6
|
+
const entry = "{ id: 'example', overrides: { forms: { sections: { 'example.todo/default/update/details': null } } } }"
|
|
7
|
+
const original = process.env.NEXT_PUBLIC_OM_CUSTOM_FORM
|
|
8
|
+
|
|
9
|
+
let directory: string
|
|
10
|
+
|
|
11
|
+
function configure(source: string) {
|
|
12
|
+
const filename = path.join(directory, 'modules.ts')
|
|
13
|
+
fs.writeFileSync(filename, source)
|
|
14
|
+
return readEnabledModulesFromConfig(filename)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
directory = fs.mkdtempSync(path.join(os.tmpdir(), 'crudform-gating-'))
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
fs.rmSync(directory, { recursive: true, force: true })
|
|
23
|
+
if (original === undefined) delete process.env.NEXT_PUBLIC_OM_CUSTOM_FORM
|
|
24
|
+
else process.env.NEXT_PUBLIC_OM_CUSTOM_FORM = original
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('honors both public branches and accepts ungated form section overrides', () => {
|
|
28
|
+
expect(configure(`export const enabledModules = [${entry}]`).map(({ id }) => id)).toEqual(['example'])
|
|
29
|
+
const source = `
|
|
30
|
+
export const enabledModules = [];
|
|
31
|
+
if (process.env.NEXT_PUBLIC_OM_CUSTOM_FORM) enabledModules.push(${entry});
|
|
32
|
+
`
|
|
33
|
+
delete process.env.NEXT_PUBLIC_OM_CUSTOM_FORM
|
|
34
|
+
expect(configure(source)).toEqual([])
|
|
35
|
+
process.env.NEXT_PUBLIC_OM_CUSTOM_FORM = 'yes'
|
|
36
|
+
expect(configure(source).map(({ id }) => id)).toEqual(['example'])
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it.each([
|
|
40
|
+
`if (process.env.OM_PRIVATE_FORM) enabledModules.push(${entry});`,
|
|
41
|
+
`if (process.env.OM_PRIVATE_FORM) enabledModules.push({id:'normal'}); else enabledModules.push(${entry});`,
|
|
42
|
+
`const gated = process.env['OM_PRIVATE_FORM']; if (gated) { enabledModules.push(${entry}); }`,
|
|
43
|
+
`const definition = ${entry}; if (process.env.OM_PRIVATE_FORM) enabledModules.push(definition);`,
|
|
44
|
+
`process.env.OM_PRIVATE_FORM && enabledModules.push(${entry});`,
|
|
45
|
+
])('rejects a server-only form gate even when the branch is inactive (%s)', (branch) => {
|
|
46
|
+
expect(() => configure(`export const enabledModules = []; ${branch}`)).toThrow(/forms\.sections.*OM_PRIVATE_FORM/)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('rejects a gate derived from a dynamically read environment object', () => {
|
|
50
|
+
expect(() => configure(`
|
|
51
|
+
const { OM_PRIVATE_FORM } = process.env;
|
|
52
|
+
export const enabledModules = [];
|
|
53
|
+
if (OM_PRIVATE_FORM) enabledModules.push(${entry});
|
|
54
|
+
`)).toThrow(/forms\.sections.*dynamic process\.env/)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('leaves other override domains and legacy server-only gated modules alone', () => {
|
|
58
|
+
expect(configure(`
|
|
59
|
+
export const enabledModules = [{ id: 'example', overrides: {
|
|
60
|
+
forms: { sections: {} },
|
|
61
|
+
nav: process.env.OM_PRIVATE_FORM ? { groupOrder: [] } : undefined,
|
|
62
|
+
}}];
|
|
63
|
+
if (process.env.OM_PRIVATE_FORM) enabledModules.push({ id: 'normal' });
|
|
64
|
+
`).map(({ id }) => id)).toEqual(['example'])
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('retains a literal forms selector through a local alias, including the shared placement enum', () => {
|
|
68
|
+
expect(configure(`
|
|
69
|
+
const sections = { 'example.todo/default/update/extra': {
|
|
70
|
+
operation: 'add', contributionId: 'example.patch.extra',
|
|
71
|
+
placement: { position: InjectionPosition.After, relativeTo: 'details' },
|
|
72
|
+
} } as const;
|
|
73
|
+
const forms = { sections };
|
|
74
|
+
const overrides = { forms };
|
|
75
|
+
export const enabledModules = [{ id: 'example', overrides }];
|
|
76
|
+
`)[0].formSectionOverrides).toEqual({
|
|
77
|
+
'example.todo/default/update/extra': {
|
|
78
|
+
operation: 'add', contributionId: 'example.patch.extra',
|
|
79
|
+
placement: { position: 'after', relativeTo: 'details' },
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
})
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineCacheProvider,
|
|
3
|
+
defineCacheProviderRegistration,
|
|
4
|
+
resetCacheProviderSelectionForTests,
|
|
5
|
+
setCacheProviderRegistrations,
|
|
6
|
+
type CacheProviderPlacement,
|
|
7
|
+
} from '@open-mercato/cache/provider'
|
|
8
|
+
import { loadCacheProviderManifest } from '../cache-provider-manifest'
|
|
1
9
|
import {
|
|
2
10
|
assertSingleInstanceStrategies,
|
|
3
11
|
evaluateSingleInstanceGuard,
|
|
12
|
+
readInfraStrategySnapshot,
|
|
13
|
+
resolveEffectiveCacheProviderSnapshot,
|
|
4
14
|
SingleInstanceStrategyError,
|
|
5
15
|
type InfraStrategySnapshot,
|
|
6
16
|
} from '../single-instance-strategy-guard'
|
|
7
17
|
|
|
18
|
+
jest.mock('../cache-provider-manifest', () => ({ loadCacheProviderManifest: jest.fn() }))
|
|
19
|
+
|
|
20
|
+
const loadManifestMock = jest.mocked(loadCacheProviderManifest)
|
|
21
|
+
|
|
8
22
|
const singleInstanceSnapshot: InfraStrategySnapshot = {
|
|
9
23
|
cacheStrategy: 'memory',
|
|
10
24
|
queueStrategy: 'local',
|
|
@@ -94,6 +108,37 @@ describe('evaluateSingleInstanceGuard', () => {
|
|
|
94
108
|
})
|
|
95
109
|
})
|
|
96
110
|
|
|
111
|
+
describe('stock cache strategy characterization', () => {
|
|
112
|
+
it('reads CACHE_STRATEGY into the snapshot and defaults to memory', () => {
|
|
113
|
+
expect(readInfraStrategySnapshot({ CACHE_STRATEGY: 'redis' }).cacheStrategy).toBe('redis')
|
|
114
|
+
expect(readInfraStrategySnapshot({ CACHE_STRATEGY: ' sqlite ' }).cacheStrategy).toBe('sqlite')
|
|
115
|
+
expect(readInfraStrategySnapshot({}).cacheStrategy).toBe('memory')
|
|
116
|
+
expect(readInfraStrategySnapshot({ CACHE_STRATEGY: '' }).cacheStrategy).toBe('memory')
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('treats a redis cache as multi-instance safe', () => {
|
|
120
|
+
const result = evaluateSingleInstanceGuard(
|
|
121
|
+
{ ...multiInstanceSafeSnapshot, cacheStrategy: 'redis' },
|
|
122
|
+
{ NODE_ENV: 'production', OM_MULTI_INSTANCE: '1' },
|
|
123
|
+
)
|
|
124
|
+
expect(result.offenders.find((offender) => offender.component === 'cache')).toBeUndefined()
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it.each([['memory'], ['sqlite'], ['jsonfile']])(
|
|
128
|
+
'reports a %s cache as a CACHE_STRATEGY offender',
|
|
129
|
+
(cacheStrategy) => {
|
|
130
|
+
const result = evaluateSingleInstanceGuard(
|
|
131
|
+
{ ...multiInstanceSafeSnapshot, cacheStrategy },
|
|
132
|
+
{ NODE_ENV: 'production', OM_MULTI_INSTANCE: '1' },
|
|
133
|
+
)
|
|
134
|
+
expect(result.action).toBe('fail')
|
|
135
|
+
expect(result.offenders).toEqual([
|
|
136
|
+
{ component: 'cache', envVar: 'CACHE_STRATEGY', configured: cacheStrategy, safeValues: ['redis'] },
|
|
137
|
+
])
|
|
138
|
+
},
|
|
139
|
+
)
|
|
140
|
+
})
|
|
141
|
+
|
|
97
142
|
describe('assertSingleInstanceStrategies', () => {
|
|
98
143
|
function createLogger() {
|
|
99
144
|
return {
|
|
@@ -136,3 +181,87 @@ describe('assertSingleInstanceStrategies', () => {
|
|
|
136
181
|
expect(logger.error).not.toHaveBeenCalled()
|
|
137
182
|
})
|
|
138
183
|
})
|
|
184
|
+
|
|
185
|
+
describe('single-instance guard with a registered cache provider', () => {
|
|
186
|
+
const productionMultiInstance = { NODE_ENV: 'production', OM_MULTI_INSTANCE: '1' }
|
|
187
|
+
|
|
188
|
+
it('treats a provider with shared placement as multi-instance safe regardless of CACHE_STRATEGY', () => {
|
|
189
|
+
const result = evaluateSingleInstanceGuard(
|
|
190
|
+
{ ...multiInstanceSafeSnapshot, cacheStrategy: 'memory', cacheProvider: { id: 'acme/shared', placement: 'shared' } },
|
|
191
|
+
productionMultiInstance,
|
|
192
|
+
)
|
|
193
|
+
expect(result.action).toBe('ok')
|
|
194
|
+
expect(result.offenders).toHaveLength(0)
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
it('reports a local provider as a CACHE_PROVIDER offender even when CACHE_STRATEGY=redis', () => {
|
|
198
|
+
const result = evaluateSingleInstanceGuard(
|
|
199
|
+
{ ...multiInstanceSafeSnapshot, cacheProvider: { id: 'acme/local', placement: 'local' } },
|
|
200
|
+
productionMultiInstance,
|
|
201
|
+
)
|
|
202
|
+
expect(result.action).toBe('fail')
|
|
203
|
+
expect(result.offenders).toEqual([
|
|
204
|
+
expect.objectContaining({ component: 'cache', envVar: 'CACHE_PROVIDER', configured: 'acme/local' }),
|
|
205
|
+
])
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
it('carries the provider snapshot through readInfraStrategySnapshot only when one is resolved', () => {
|
|
209
|
+
expect(readInfraStrategySnapshot({}, { cacheProvider: null })).not.toHaveProperty('cacheProvider')
|
|
210
|
+
expect(readInfraStrategySnapshot({}, { cacheProvider: { id: 'acme/x', placement: 'shared' } }).cacheProvider)
|
|
211
|
+
.toEqual({ id: 'acme/x', placement: 'shared' })
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
describe('resolveEffectiveCacheProviderSnapshot', () => {
|
|
216
|
+
function registerProvider(placement: CacheProviderPlacement) {
|
|
217
|
+
const definition = defineCacheProvider<Record<string, never>>({
|
|
218
|
+
id: 'acme/fake',
|
|
219
|
+
settings: { safeParse: () => ({ success: true, data: {} }) },
|
|
220
|
+
capability: () => ({ placement }),
|
|
221
|
+
create: () => { throw new Error('must not connect during the guard') },
|
|
222
|
+
})
|
|
223
|
+
setCacheProviderRegistrations([
|
|
224
|
+
defineCacheProviderRegistration({ id: 'acme/fake', load: async () => definition, settings: () => ({}) }),
|
|
225
|
+
])
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
beforeEach(() => {
|
|
229
|
+
resetCacheProviderSelectionForTests()
|
|
230
|
+
loadManifestMock.mockReset()
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
afterAll(() => {
|
|
234
|
+
resetCacheProviderSelectionForTests()
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
it('returns null without loading the manifest for stock deployments', async () => {
|
|
238
|
+
await expect(resolveEffectiveCacheProviderSnapshot('/app', { CACHE_STRATEGY: 'redis' })).resolves.toBeNull()
|
|
239
|
+
expect(loadManifestMock).not.toHaveBeenCalled()
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
it.each([['shared'], ['local']] as const)('loads the manifest and reports the %s placement', async (placement) => {
|
|
243
|
+
loadManifestMock.mockImplementation(async () => {
|
|
244
|
+
registerProvider(placement)
|
|
245
|
+
return []
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
const snapshot = await resolveEffectiveCacheProviderSnapshot('/app', {
|
|
249
|
+
CACHE_PROVIDER: 'acme/fake',
|
|
250
|
+
CACHE_PROVIDER_NAMESPACE: 'guard-ns',
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
expect(loadManifestMock).toHaveBeenCalledWith('/app')
|
|
254
|
+
expect(snapshot).toEqual({ id: 'acme/fake', placement })
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
it('propagates a provider selection error so the start aborts', async () => {
|
|
258
|
+
loadManifestMock.mockImplementation(async () => {
|
|
259
|
+
setCacheProviderRegistrations([])
|
|
260
|
+
return []
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
await expect(
|
|
264
|
+
resolveEffectiveCacheProviderSnapshot('/app', { CACHE_PROVIDER: 'acme/fake', CACHE_PROVIDER_NAMESPACE: 'guard-ns' }),
|
|
265
|
+
).rejects.toMatchObject({ name: 'CacheProviderError', code: 'not_registered' })
|
|
266
|
+
})
|
|
267
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CacheProviderRegistration } from '@open-mercato/shared/lib/cache/providers'
|
|
2
|
+
|
|
3
|
+
/** Load app provider registrations for CLI commands that do not bootstrap the full app. */
|
|
4
|
+
export async function loadCacheProviderManifest(appDir: string): Promise<CacheProviderRegistration[]> {
|
|
5
|
+
const { loadCacheProviderManifestFromAppRoot } = await import('@open-mercato/shared/lib/bootstrap/dynamicLoader')
|
|
6
|
+
const format = typeof process.env.JEST_WORKER_ID === 'string' ? 'cjs' : 'esm'
|
|
7
|
+
return loadCacheProviderManifestFromAppRoot(appDir, { format })
|
|
8
|
+
}
|
|
@@ -2,7 +2,7 @@ export type GenerateWatchCategory =
|
|
|
2
2
|
| 'api-route' | 'frontend-page' | 'backend-page' | 'commands' | 'di' | 'entities'
|
|
3
3
|
| 'search' | 'events' | 'subscribers' | 'workers' | 'dashboard-widgets'
|
|
4
4
|
| 'injection-widgets' | 'cli' | 'i18n' | 'registry-convention' | 'extension'
|
|
5
|
-
| 'openapi' | 'web-research-adapters' | 'generator-plugin' | 'configuration' | 'unknown'
|
|
5
|
+
| 'openapi' | 'web-research-adapters' | 'cache-providers' | 'generator-plugin' | 'configuration' | 'unknown'
|
|
6
6
|
|
|
7
7
|
export type GenerateWatchRecord = {
|
|
8
8
|
key: string
|
|
@@ -29,7 +29,7 @@ export type GenerateWatchChange = {
|
|
|
29
29
|
|
|
30
30
|
export type GenerateWatchGroup =
|
|
31
31
|
| 'entity-ids' | 'registry' | 'entities' | 'di' | 'package-sources'
|
|
32
|
-
| 'web-research-adapters' | 'openapi'
|
|
32
|
+
| 'web-research-adapters' | 'cache-providers' | 'openapi'
|
|
33
33
|
|
|
34
34
|
export type GenerateWatchPlan = {
|
|
35
35
|
mode: 'full' | 'incremental' | 'none'
|
|
@@ -40,7 +40,7 @@ export type GenerateWatchPlan = {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const GROUP_ORDER: readonly GenerateWatchGroup[] = [
|
|
43
|
-
'entity-ids', 'registry', 'entities', 'di', 'package-sources', 'web-research-adapters', 'openapi',
|
|
43
|
+
'entity-ids', 'registry', 'entities', 'di', 'package-sources', 'web-research-adapters', 'cache-providers', 'openapi',
|
|
44
44
|
]
|
|
45
45
|
|
|
46
46
|
const REGISTRY_ORDER = [
|
|
@@ -88,6 +88,9 @@ export function planGenerateWatchChanges(
|
|
|
88
88
|
case 'web-research-adapters':
|
|
89
89
|
groups.add('web-research-adapters')
|
|
90
90
|
break
|
|
91
|
+
case 'cache-providers':
|
|
92
|
+
groups.add('cache-providers')
|
|
93
|
+
break
|
|
91
94
|
case 'frontend-page':
|
|
92
95
|
registry('main', 'runtime', 'app', 'frontend-routes')
|
|
93
96
|
break
|
|
@@ -53,6 +53,7 @@ export async function runGenerateWatchSuite(
|
|
|
53
53
|
if (selected('di')) record(await generators.generateModuleDi({ resolver, quiet }))
|
|
54
54
|
if (selected('package-sources')) record(await generators.generateModulePackageSources({ resolver, quiet }))
|
|
55
55
|
if (selected('web-research-adapters')) record(await generators.generateWebResearchAdapters({ resolver, quiet }))
|
|
56
|
+
if (selected('cache-providers')) record(await generators.generateCacheProviders({ resolver, quiet }))
|
|
56
57
|
if (cascadeReason) {
|
|
57
58
|
if (onOpenApiCascade) onOpenApiCascade(cascadeReason)
|
|
58
59
|
else if (!quiet) console.log(`[generate:watch] Cascading; groups=openapi; reason=${cascadeReason}`)
|
|
@@ -25,6 +25,7 @@ export type GenerateWatchStructureOptions = {
|
|
|
25
25
|
additionalInputs?: string[]
|
|
26
26
|
/** Inputs consumed specifically by OpenAPI generation. */
|
|
27
27
|
openapiInputs?: string[]
|
|
28
|
+
cacheProviderInputs?: string[]
|
|
28
29
|
/** Candidate package manifests consumed specifically by web-research adapter discovery. */
|
|
29
30
|
webResearchAdapterInputs?: string[]
|
|
30
31
|
/** Adapter discovery failures that make this capture non-authoritative. */
|
|
@@ -534,6 +535,8 @@ function addModule(collector: SnapshotCollector, roots: WatchRoots, index: numbe
|
|
|
534
535
|
]))
|
|
535
536
|
const convention = (relativePath: string, kind: InputKind) => collector.pair(identity, roots, `${relativePath}.ts`, kind)
|
|
536
537
|
for (const relativePath of REGISTRY_CONVENTIONS) convention(relativePath, { category: 'registry-convention' })
|
|
538
|
+
// Section definitions can change shared field sets, route manifests, and OpenAPI together.
|
|
539
|
+
convention('form-sections', { category: 'configuration' })
|
|
537
540
|
for (const [relativePath, extensionId] of Object.entries(EXTENSION_CONVENTIONS)) {
|
|
538
541
|
convention(relativePath, { category: 'extension', extensionId })
|
|
539
542
|
}
|
|
@@ -651,7 +654,7 @@ export function collectGenerateWatchStructureSnapshot(
|
|
|
651
654
|
inputs: readonly string[] | undefined,
|
|
652
655
|
kind: InputKind,
|
|
653
656
|
keyPrefix: string,
|
|
654
|
-
mode: 'content' | 'stat' = 'content',
|
|
657
|
+
mode: 'content' | 'stat' | 'membership' = 'content',
|
|
655
658
|
) => {
|
|
656
659
|
for (const input of ordered(inputs)) {
|
|
657
660
|
const stat = collector.stat(input)
|
|
@@ -666,6 +669,7 @@ export function collectGenerateWatchStructureSnapshot(
|
|
|
666
669
|
'web-research-adapter-input',
|
|
667
670
|
'stat',
|
|
668
671
|
)
|
|
672
|
+
addSpecializedInputs(options.cacheProviderInputs, { category: 'cache-providers' }, 'cache-provider-input', 'membership')
|
|
669
673
|
collector.supervisor(path.dirname(options.modulesFile))
|
|
670
674
|
collector.dependencies(path.dirname(options.modulesFile))
|
|
671
675
|
// A dynamic descriptor is valid source, not a transient failed capture. Until
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import os from 'node:os'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import type { PackageResolver } from '../../resolver'
|
|
5
|
+
import {
|
|
6
|
+
CACHE_PROVIDERS_CHECKSUM_FILE,
|
|
7
|
+
CACHE_PROVIDERS_GENERATED_FILE,
|
|
8
|
+
generateCacheProviders,
|
|
9
|
+
} from '../cache-providers'
|
|
10
|
+
|
|
11
|
+
let appDir: string
|
|
12
|
+
let outputDir: string
|
|
13
|
+
|
|
14
|
+
function createMockResolver(): PackageResolver {
|
|
15
|
+
return {
|
|
16
|
+
getAppDir: () => appDir,
|
|
17
|
+
getOutputDir: () => outputDir,
|
|
18
|
+
} as unknown as PackageResolver
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function readGenerated(): string {
|
|
22
|
+
return fs.readFileSync(path.join(outputDir, CACHE_PROVIDERS_GENERATED_FILE), 'utf8')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
appDir = fs.mkdtempSync(path.join(os.tmpdir(), 'om-cache-providers-'))
|
|
27
|
+
fs.mkdirSync(path.join(appDir, 'src/providers'), { recursive: true })
|
|
28
|
+
outputDir = path.join(appDir, '.mercato', 'generated')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
fs.rmSync(appDir, { recursive: true, force: true })
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('generateCacheProviders', () => {
|
|
36
|
+
it('emits an empty typed manifest when the app has no src/providers/cache file', async () => {
|
|
37
|
+
const result = await generateCacheProviders({ resolver: createMockResolver(), quiet: true })
|
|
38
|
+
|
|
39
|
+
const content = readGenerated()
|
|
40
|
+
expect(result.filesWritten).toEqual([path.join(outputDir, CACHE_PROVIDERS_GENERATED_FILE)])
|
|
41
|
+
expect(content).toContain("import type { CacheProviderRegistration } from '@open-mercato/cache/provider'")
|
|
42
|
+
expect(content).toContain('export const cacheProviders: CacheProviderRegistration[] = []')
|
|
43
|
+
expect(content).not.toContain('src/providers/cache\'')
|
|
44
|
+
expect(fs.existsSync(path.join(outputDir, CACHE_PROVIDERS_CHECKSUM_FILE))).toBe(true)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('re-exports the app manifest through a literal extensionless relative import', async () => {
|
|
48
|
+
fs.writeFileSync(path.join(appDir, 'src/providers/cache.ts'), 'throw new Error("must not be evaluated")\n')
|
|
49
|
+
|
|
50
|
+
await generateCacheProviders({ resolver: createMockResolver(), quiet: true })
|
|
51
|
+
|
|
52
|
+
const content = readGenerated()
|
|
53
|
+
expect(content).toContain("import { cacheProviders as appCacheProviders } from '../../src/providers/cache'")
|
|
54
|
+
expect(content).toContain('export const cacheProviders: CacheProviderRegistration[] = appCacheProviders')
|
|
55
|
+
expect(path.resolve(outputDir, '../../src/providers/cache.ts')).toBe(path.join(appDir, 'src/providers/cache.ts'))
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('accepts a JavaScript manifest', async () => {
|
|
59
|
+
fs.writeFileSync(path.join(appDir, 'src/providers/cache.js'), 'export const cacheProviders = []\n')
|
|
60
|
+
|
|
61
|
+
await generateCacheProviders({ resolver: createMockResolver(), quiet: true })
|
|
62
|
+
|
|
63
|
+
expect(readGenerated()).toContain("from '../../src/providers/cache'")
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('rejects ambiguous and unsupported manifest files', async () => {
|
|
67
|
+
fs.writeFileSync(path.join(appDir, 'src/providers/cache.ts'), '')
|
|
68
|
+
fs.writeFileSync(path.join(appDir, 'src/providers/cache.js'), '')
|
|
69
|
+
await expect(generateCacheProviders({ resolver: createMockResolver(), quiet: true })).rejects.toThrow(
|
|
70
|
+
/Multiple cache provider manifests/,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
fs.rmSync(path.join(appDir, 'src/providers/cache.js'))
|
|
74
|
+
fs.writeFileSync(path.join(appDir, 'src/providers/cache.mts'), '')
|
|
75
|
+
await expect(generateCacheProviders({ resolver: createMockResolver(), quiet: true })).rejects.toThrow(
|
|
76
|
+
/Unsupported cache provider manifest src\/providers\/cache\.mts/,
|
|
77
|
+
)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('is deterministic and leaves the output untouched on rerun', async () => {
|
|
81
|
+
fs.writeFileSync(path.join(appDir, 'src/providers/cache.ts'), 'export const cacheProviders = []\n')
|
|
82
|
+
await generateCacheProviders({ resolver: createMockResolver(), quiet: true })
|
|
83
|
+
const first = readGenerated()
|
|
84
|
+
|
|
85
|
+
const rerun = await generateCacheProviders({ resolver: createMockResolver(), quiet: true })
|
|
86
|
+
|
|
87
|
+
expect(rerun.filesWritten).toEqual([])
|
|
88
|
+
expect(rerun.filesUnchanged).toEqual([path.join(outputDir, CACHE_PROVIDERS_GENERATED_FILE)])
|
|
89
|
+
expect(readGenerated()).toBe(first)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('switches back to the empty manifest when the app file is removed', async () => {
|
|
93
|
+
fs.writeFileSync(path.join(appDir, 'src/providers/cache.ts'), 'export const cacheProviders = []\n')
|
|
94
|
+
await generateCacheProviders({ resolver: createMockResolver(), quiet: true })
|
|
95
|
+
fs.rmSync(path.join(appDir, 'src/providers/cache.ts'))
|
|
96
|
+
|
|
97
|
+
const result = await generateCacheProviders({ resolver: createMockResolver(), quiet: true })
|
|
98
|
+
|
|
99
|
+
expect(result.filesWritten).toHaveLength(1)
|
|
100
|
+
expect(readGenerated()).toContain('export const cacheProviders: CacheProviderRegistration[] = []')
|
|
101
|
+
})
|
|
102
|
+
})
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import os from 'node:os'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import type { PackageResolver } from '../../resolver'
|
|
5
|
+
import { generateModuleRegistries } from '../module-registry'
|
|
6
|
+
|
|
7
|
+
const modulePath = 'app/src/modules/example'
|
|
8
|
+
const originalRoute = `
|
|
9
|
+
import { makeCrudRoute } from '@open-mercato/shared/lib/crud/factory'
|
|
10
|
+
export const crudRoute = makeCrudRoute({
|
|
11
|
+
metadata: { PUT: { requireAuth: true } },
|
|
12
|
+
orm: { entity: ExampleRecord },
|
|
13
|
+
actions: { update: { commandId: 'example.records.update' } },
|
|
14
|
+
})
|
|
15
|
+
export const { metadata, PUT } = crudRoute
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
let root: string
|
|
19
|
+
|
|
20
|
+
function write(file: string, source: string): void {
|
|
21
|
+
const target = path.join(root, modulePath, file)
|
|
22
|
+
fs.mkdirSync(path.dirname(target), { recursive: true })
|
|
23
|
+
fs.writeFileSync(target, source)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function generate() {
|
|
27
|
+
const appRoot = path.join(root, 'app')
|
|
28
|
+
const output = path.join(appRoot, '.mercato', 'generated')
|
|
29
|
+
const resolver: PackageResolver = {
|
|
30
|
+
isMonorepo: () => true,
|
|
31
|
+
getRootDir: () => root,
|
|
32
|
+
getAppDir: () => appRoot,
|
|
33
|
+
getOutputDir: () => output,
|
|
34
|
+
getModulesConfigPath: () => path.join(appRoot, 'src/modules.ts'),
|
|
35
|
+
discoverPackages: () => [],
|
|
36
|
+
loadEnabledModules: () => [{ id: 'example', from: '@app' }],
|
|
37
|
+
getModulePaths: () => ({ appBase: path.join(root, modulePath), pkgBase: path.join(root, 'package') }),
|
|
38
|
+
getModuleImportBase: () => ({ appBase: '@/modules/example', pkgBase: '@open-mercato/core/modules/example' }),
|
|
39
|
+
getPackageOutputDir: () => output,
|
|
40
|
+
getPackageRoot: () => path.join(root, 'package'),
|
|
41
|
+
}
|
|
42
|
+
return generateModuleRegistries({ resolver, quiet: true })
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function addDerivedHost(routePath: string): void {
|
|
46
|
+
write(`api/${routePath}/route.ts`, originalRoute)
|
|
47
|
+
write('descriptor.client.ts', "export const crudFormSectionRuntime = { id: 'example.edit', roundTripId: 'example.edit@v1' }")
|
|
48
|
+
write('form-sections.ts', `
|
|
49
|
+
import { defineCrudFormSections, lazyCrudFormSectionRuntime } from '@open-mercato/shared/modules/form-sections'
|
|
50
|
+
import { defineCrudRouteSectionHost } from '@open-mercato/shared/lib/crud/form-sections/derived-route-host'
|
|
51
|
+
import { crudRoute } from './api/${routePath}/route'
|
|
52
|
+
export const crudFormSections = defineCrudFormSections({
|
|
53
|
+
hostFacts: [{ id: 'example.edit', roundTripId: 'example.edit@v1', hostResourceKind: 'example.records' }],
|
|
54
|
+
derivedHosts: [defineCrudRouteSectionHost({
|
|
55
|
+
hostId: 'example.record', formVariant: 'default', formOperation: 'update', hostDescriptorId: 'example.edit',
|
|
56
|
+
route: crudRoute, sections: [{ id: 'details', writes: 'parent' }],
|
|
57
|
+
})],
|
|
58
|
+
runtimes: [{ id: 'example.edit', roundTripId: 'example.edit@v1',
|
|
59
|
+
load: lazyCrudFormSectionRuntime(() => import('./descriptor.client')),
|
|
60
|
+
}],
|
|
61
|
+
})
|
|
62
|
+
`)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
beforeEach(() => {
|
|
66
|
+
root = fs.mkdtempSync(path.join(os.tmpdir(), 'crud-form-section-route-'))
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
afterEach(() => {
|
|
70
|
+
fs.rmSync(root, { recursive: true, force: true })
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it.each(['Records/section-policy', 'records/[id]', 'records/[...rest]'])('rejects overlapping API path %s', async (pathPattern) => {
|
|
74
|
+
addDerivedHost('records')
|
|
75
|
+
write(`api/${pathPattern}/route.ts`, `
|
|
76
|
+
export const metadata = { PUT: { requireAuth: true } }
|
|
77
|
+
export async function PUT() { return new Response() }
|
|
78
|
+
`)
|
|
79
|
+
await expect(generate()).rejects.toThrow(/conflicts with an existing API route/)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it('rejects a parameterized original host route', async () => {
|
|
83
|
+
addDerivedHost('records/[id]')
|
|
84
|
+
await expect(generate()).rejects.toThrow(/literal API path without parameters/)
|
|
85
|
+
})
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import os from 'node:os'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { createGeneratorResult } from '../../utils'
|
|
5
|
+
import { writeCrudFormSectionRegistries } from '../form-sections'
|
|
6
|
+
|
|
7
|
+
const externalFact = {
|
|
8
|
+
integrationId: 'example.erp',
|
|
9
|
+
contractId: 'example.brand_mirror@v1',
|
|
10
|
+
maxAttempts: 3,
|
|
11
|
+
preCommitValidation: 'read-only',
|
|
12
|
+
coalesce: 'latest-state',
|
|
13
|
+
fencing: 'remote-monotonic-revision/v1',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function fixture(atomicity: string, externalDelivery?: Record<string, unknown>) {
|
|
17
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'form-section-outbox-'))
|
|
18
|
+
const source = path.join(root, 'form-sections.ts')
|
|
19
|
+
const fact = {
|
|
20
|
+
id: 'example.brand', roundTripId: 'example.brand@v1', ownerModuleId: 'example',
|
|
21
|
+
targetEntityId: 'example.brand_mirror', atomicity, externalDelivery,
|
|
22
|
+
}
|
|
23
|
+
fs.writeFileSync(source, `
|
|
24
|
+
export const crudFormSections = defineCrudFormSections({
|
|
25
|
+
sinks: [defineCrudFormSectionSink({ fact: ${JSON.stringify(fact)}, schema: serverSchema })],
|
|
26
|
+
})
|
|
27
|
+
`)
|
|
28
|
+
const build = () => writeCrudFormSectionRegistries({
|
|
29
|
+
modules: [{
|
|
30
|
+
modId: 'example', roots: { appBase: root, pkgBase: root },
|
|
31
|
+
resolve: (relative) => relative === 'form-sections.ts'
|
|
32
|
+
? { fromApp: true, absolutePath: source, importPath: '@/modules/example/form-sections' } : null,
|
|
33
|
+
}],
|
|
34
|
+
identities: [{ id: 'example' }], requiresByModule: new Map(), outputDir: root,
|
|
35
|
+
structureChecksum: 'test', result: createGeneratorResult(), quiet: true,
|
|
36
|
+
})
|
|
37
|
+
return { build, clean: () => fs.rmSync(root, { force: true, recursive: true }) }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
it.each([
|
|
41
|
+
['outbox', undefined, /requires a literal externalDelivery/],
|
|
42
|
+
['outbox', { ...externalFact, fencing: 'lease-only' }, /remote-monotonic-revision\/v1/],
|
|
43
|
+
['outbox', { ...externalFact, contractId: 'example.other@v1' }, /requires contractId/],
|
|
44
|
+
['host-transaction', externalFact, /invalid atomicity or externalDelivery/],
|
|
45
|
+
] as const)('rejects %s declarations with invalid delivery facts', (atomicity, external, error) => {
|
|
46
|
+
const { build, clean } = fixture(atomicity, external)
|
|
47
|
+
try { expect(build).toThrow(error) } finally { clean() }
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('accepts a literal monotonic outbox provider contract', () => {
|
|
51
|
+
const { build, clean } = fixture('outbox', externalFact)
|
|
52
|
+
try { expect(build).not.toThrow() } finally { clean() }
|
|
53
|
+
})
|