@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,1742 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): acl.ts 1`] = `
|
|
4
|
+
"export const features = [
|
|
5
|
+
{ id: 'inventory_items.view', title: 'View inventory items', module: 'inventory_items' },
|
|
6
|
+
{
|
|
7
|
+
id: 'inventory_items.create',
|
|
8
|
+
title: 'Create inventory items',
|
|
9
|
+
module: 'inventory_items',
|
|
10
|
+
dependsOn: ['inventory_items.view'],
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: 'inventory_items.edit',
|
|
14
|
+
title: 'Edit inventory items',
|
|
15
|
+
module: 'inventory_items',
|
|
16
|
+
dependsOn: ['inventory_items.view'],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 'inventory_items.delete',
|
|
20
|
+
title: 'Delete inventory items',
|
|
21
|
+
module: 'inventory_items',
|
|
22
|
+
dependsOn: ['inventory_items.view'],
|
|
23
|
+
},
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
export default features
|
|
27
|
+
"
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): backend/inventory_items/[id]/page.meta.ts 1`] = `
|
|
31
|
+
"export const metadata = {
|
|
32
|
+
requireAuth: true,
|
|
33
|
+
requireFeatures: ['inventory_items.view'],
|
|
34
|
+
pageTitle: 'Stock item details',
|
|
35
|
+
pageTitleKey: 'inventory_items.detail.title',
|
|
36
|
+
pageGroup: 'Inventory items',
|
|
37
|
+
pageGroupKey: 'inventory_items.nav.group',
|
|
38
|
+
navHidden: true,
|
|
39
|
+
breadcrumb: [
|
|
40
|
+
{ label: 'Inventory items', labelKey: 'inventory_items.nav.title', href: '/backend/inventory_items' },
|
|
41
|
+
{ label: 'Details', labelKey: 'inventory_items.detail.title' },
|
|
42
|
+
],
|
|
43
|
+
}
|
|
44
|
+
"
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): backend/inventory_items/[id]/page.tsx 1`] = `
|
|
48
|
+
""use client"
|
|
49
|
+
|
|
50
|
+
import * as React from 'react'
|
|
51
|
+
import { useRouter } from 'next/navigation'
|
|
52
|
+
import { Page, PageBody } from '@open-mercato/ui/backend/Page'
|
|
53
|
+
import { CrudForm } from '@open-mercato/ui/backend/CrudForm'
|
|
54
|
+
import { FormHeader } from '@open-mercato/ui/backend/forms/FormHeader'
|
|
55
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@open-mercato/ui/primitives/tabs'
|
|
56
|
+
import { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'
|
|
57
|
+
import { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'
|
|
58
|
+
import { updateCrud, deleteCrud } from '@open-mercato/ui/backend/utils/crud'
|
|
59
|
+
import { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'
|
|
60
|
+
import { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'
|
|
61
|
+
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
62
|
+
import { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'
|
|
63
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
64
|
+
import { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'
|
|
65
|
+
import { stockItemUpdateSchema, type StockItemUpdateInput } from '../../../data/validators'
|
|
66
|
+
import { StatusBadge } from '@open-mercato/ui/primitives/status-badge'
|
|
67
|
+
import { stockItemStatusMap, type StockItemStatus } from '../../../components/statusMap'
|
|
68
|
+
import {
|
|
69
|
+
STOCK_ITEM_ENTITY_ID,
|
|
70
|
+
createStockItemFormFields,
|
|
71
|
+
createStockItemFormGroups,
|
|
72
|
+
} from '../../../components/formConfig'
|
|
73
|
+
|
|
74
|
+
type StockItemRecord = {
|
|
75
|
+
id: string
|
|
76
|
+
updatedAt?: string | null
|
|
77
|
+
name: string
|
|
78
|
+
summary?: string | null
|
|
79
|
+
quantity: number
|
|
80
|
+
status?: StockItemStatus | null
|
|
81
|
+
severity: 'low' | 'high'
|
|
82
|
+
archived?: boolean | null
|
|
83
|
+
dueDate: string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type StockItemListResponse = {
|
|
87
|
+
items: StockItemRecord[]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default function StockItemDetailPage({ params }: { params?: { id?: string } }) {
|
|
91
|
+
const t = useT()
|
|
92
|
+
const router = useRouter()
|
|
93
|
+
const id = typeof params?.id === 'string' ? params.id : null
|
|
94
|
+
const { confirm, ConfirmDialogElement } = useConfirmDialog()
|
|
95
|
+
const { runMutation, retryLastMutation } = useGuardedMutation({ contextId: 'inventory_items.detail' })
|
|
96
|
+
const [record, setRecord] = React.useState<StockItemRecord | null>(null)
|
|
97
|
+
const [isLoading, setIsLoading] = React.useState(true)
|
|
98
|
+
const [loadError, setLoadError] = React.useState<string | null>(null)
|
|
99
|
+
const [reloadToken, setReloadToken] = React.useState(0)
|
|
100
|
+
|
|
101
|
+
React.useEffect(() => {
|
|
102
|
+
let cancelled = false
|
|
103
|
+
async function load() {
|
|
104
|
+
if (!id) {
|
|
105
|
+
setLoadError(t('inventory_items.detail.notFound', 'Stock item not found'))
|
|
106
|
+
setIsLoading(false)
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
setIsLoading(true)
|
|
110
|
+
setLoadError(null)
|
|
111
|
+
try {
|
|
112
|
+
const query = new URLSearchParams({ ids: id, pageSize: '1' })
|
|
113
|
+
const call = await apiCall<StockItemListResponse>('/api/inventory_items?' + query.toString())
|
|
114
|
+
if (cancelled) return
|
|
115
|
+
if (!call.ok) {
|
|
116
|
+
setLoadError(t('inventory_items.detail.loadError', 'Failed to load stock item'))
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
const item = call.result?.items?.[0] ?? null
|
|
120
|
+
if (!item) {
|
|
121
|
+
setLoadError(t('inventory_items.detail.notFound', 'Stock item not found'))
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
setRecord(item)
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (cancelled) return
|
|
127
|
+
getTelemetryRuntime()?.reportError(error, { module: 'inventory_items', code: 'inventory_items.detail_load_failed' })
|
|
128
|
+
setLoadError(t('inventory_items.detail.loadError', 'Failed to load stock item'))
|
|
129
|
+
} finally {
|
|
130
|
+
if (!cancelled) setIsLoading(false)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
void load()
|
|
134
|
+
return () => { cancelled = true }
|
|
135
|
+
}, [id, reloadToken, t])
|
|
136
|
+
|
|
137
|
+
const fields = React.useMemo(() => createStockItemFormFields(t), [t])
|
|
138
|
+
const groups = React.useMemo(() => createStockItemFormGroups(t), [t])
|
|
139
|
+
|
|
140
|
+
// updatedAt MUST stay in initialValues: CrudForm auto-derives the
|
|
141
|
+
// x-om-ext-optimistic-lock-expected-updated-at header from it on submit AND delete.
|
|
142
|
+
const initialValues = React.useMemo<Partial<StockItemUpdateInput> | undefined>(() => {
|
|
143
|
+
if (!record) return undefined
|
|
144
|
+
return {
|
|
145
|
+
id: record.id,
|
|
146
|
+
updatedAt: record.updatedAt ?? undefined,
|
|
147
|
+
name: record.name,
|
|
148
|
+
summary: record.summary ?? undefined,
|
|
149
|
+
quantity: record.quantity,
|
|
150
|
+
status: record.status ?? undefined,
|
|
151
|
+
severity: record.severity,
|
|
152
|
+
archived: record.archived ?? undefined,
|
|
153
|
+
dueDate: record.dueDate,
|
|
154
|
+
}
|
|
155
|
+
}, [record])
|
|
156
|
+
|
|
157
|
+
const handleDelete = React.useCallback(async () => {
|
|
158
|
+
if (!record) return
|
|
159
|
+
const confirmed = await confirm({
|
|
160
|
+
title: t('inventory_items.delete.confirmTitle', 'Delete stock item?'),
|
|
161
|
+
description: t('inventory_items.delete.confirmDescription', 'This action cannot be undone.'),
|
|
162
|
+
variant: 'destructive',
|
|
163
|
+
})
|
|
164
|
+
if (!confirmed) return
|
|
165
|
+
try {
|
|
166
|
+
await runMutation({
|
|
167
|
+
operation: () =>
|
|
168
|
+
withScopedApiRequestHeaders(
|
|
169
|
+
buildOptimisticLockHeader(record.updatedAt ?? undefined),
|
|
170
|
+
() => deleteCrud('inventory_items', record.id),
|
|
171
|
+
),
|
|
172
|
+
context: {
|
|
173
|
+
formId: 'inventory_items.detail',
|
|
174
|
+
resourceKind: 'inventory_items.stock_item',
|
|
175
|
+
resourceId: record.id,
|
|
176
|
+
retryLastMutation,
|
|
177
|
+
},
|
|
178
|
+
mutationPayload: { id: record.id },
|
|
179
|
+
})
|
|
180
|
+
flash(t('inventory_items.delete.success', 'Stock item deleted'), 'success')
|
|
181
|
+
router.push('/backend/inventory_items')
|
|
182
|
+
} catch {
|
|
183
|
+
flash(t('inventory_items.delete.error', 'Failed to delete stock item'), 'error')
|
|
184
|
+
}
|
|
185
|
+
}, [confirm, record, retryLastMutation, router, runMutation, t])
|
|
186
|
+
|
|
187
|
+
if (isLoading) {
|
|
188
|
+
return (
|
|
189
|
+
<Page>
|
|
190
|
+
<PageBody>
|
|
191
|
+
<LoadingMessage label={t('inventory_items.detail.loading', 'Loading stock item')} />
|
|
192
|
+
</PageBody>
|
|
193
|
+
</Page>
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (loadError || !record) {
|
|
198
|
+
return (
|
|
199
|
+
<Page>
|
|
200
|
+
<PageBody>
|
|
201
|
+
<ErrorMessage label={loadError ?? t('inventory_items.detail.notFound', 'Stock item not found')} />
|
|
202
|
+
</PageBody>
|
|
203
|
+
</Page>
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<Page>
|
|
209
|
+
<PageBody>
|
|
210
|
+
<FormHeader
|
|
211
|
+
mode="detail"
|
|
212
|
+
backHref="/backend/inventory_items"
|
|
213
|
+
title={record.name}
|
|
214
|
+
statusBadge={record.status ? (
|
|
215
|
+
<StatusBadge variant={stockItemStatusMap[record.status] ?? 'neutral'} dot>
|
|
216
|
+
{t('inventory_items.fields.status.options.' + record.status, record.status)}
|
|
217
|
+
</StatusBadge>
|
|
218
|
+
) : undefined}
|
|
219
|
+
onDelete={() => { void handleDelete() }}
|
|
220
|
+
deleteLabel={t('inventory_items.detail.actions.delete', 'Delete')}
|
|
221
|
+
/>
|
|
222
|
+
<Tabs defaultValue="overview" variant="underline" className="mt-4">
|
|
223
|
+
<TabsList aria-label={t('inventory_items.detail.tabs.label', 'Stock item sections')}>
|
|
224
|
+
<TabsTrigger value="overview">{t('inventory_items.detail.tabs.overview', 'Overview')}</TabsTrigger>
|
|
225
|
+
{/* Extension point: add related-entity tabs here (activity, attachments, ...). */}
|
|
226
|
+
</TabsList>
|
|
227
|
+
<TabsContent value="overview">
|
|
228
|
+
<CrudForm<StockItemUpdateInput>
|
|
229
|
+
schema={stockItemUpdateSchema}
|
|
230
|
+
fields={fields}
|
|
231
|
+
groups={groups}
|
|
232
|
+
initialValues={initialValues}
|
|
233
|
+
entityIds={[STOCK_ITEM_ENTITY_ID]}
|
|
234
|
+
submitLabel={t('inventory_items.form.submit', 'Save')}
|
|
235
|
+
onSubmit={async (values) => {
|
|
236
|
+
await updateCrud('inventory_items', values)
|
|
237
|
+
flash(t('inventory_items.detail.updateSuccess', 'Stock item updated'), 'success')
|
|
238
|
+
setReloadToken((token) => token + 1)
|
|
239
|
+
}}
|
|
240
|
+
/>
|
|
241
|
+
</TabsContent>
|
|
242
|
+
</Tabs>
|
|
243
|
+
</PageBody>
|
|
244
|
+
{ConfirmDialogElement}
|
|
245
|
+
</Page>
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
"
|
|
249
|
+
`;
|
|
250
|
+
|
|
251
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): backend/inventory_items/create/page.meta.ts 1`] = `
|
|
252
|
+
"export const metadata = {
|
|
253
|
+
requireAuth: true,
|
|
254
|
+
requireFeatures: ['inventory_items.create'],
|
|
255
|
+
pageTitle: 'Create stock item',
|
|
256
|
+
pageTitleKey: 'inventory_items.create.title',
|
|
257
|
+
pageGroup: 'Inventory items',
|
|
258
|
+
pageGroupKey: 'inventory_items.nav.group',
|
|
259
|
+
pageOrder: 101,
|
|
260
|
+
icon: 'plus',
|
|
261
|
+
breadcrumb: [
|
|
262
|
+
{ label: 'Inventory items', labelKey: 'inventory_items.nav.title', href: '/backend/inventory_items' },
|
|
263
|
+
{ label: 'Create', labelKey: 'inventory_items.create.title' },
|
|
264
|
+
],
|
|
265
|
+
}
|
|
266
|
+
"
|
|
267
|
+
`;
|
|
268
|
+
|
|
269
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): backend/inventory_items/create/page.tsx 1`] = `
|
|
270
|
+
""use client"
|
|
271
|
+
|
|
272
|
+
import * as React from 'react'
|
|
273
|
+
import { useRouter } from 'next/navigation'
|
|
274
|
+
import { Page, PageBody } from '@open-mercato/ui/backend/Page'
|
|
275
|
+
import { CrudForm } from '@open-mercato/ui/backend/CrudForm'
|
|
276
|
+
import { createCrud } from '@open-mercato/ui/backend/utils/crud'
|
|
277
|
+
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
278
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
279
|
+
import {
|
|
280
|
+
STOCK_ITEM_ENTITY_ID,
|
|
281
|
+
createStockItemFormFields,
|
|
282
|
+
createStockItemFormGroups,
|
|
283
|
+
createStockItemFormSchema,
|
|
284
|
+
type StockItemFormValues,
|
|
285
|
+
} from '../../../components/formConfig'
|
|
286
|
+
|
|
287
|
+
export default function StockItemCreatePage() {
|
|
288
|
+
const t = useT()
|
|
289
|
+
const router = useRouter()
|
|
290
|
+
const schema = React.useMemo(() => createStockItemFormSchema(), [])
|
|
291
|
+
const fields = React.useMemo(() => createStockItemFormFields(t), [t])
|
|
292
|
+
const groups = React.useMemo(() => createStockItemFormGroups(t), [t])
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
<Page>
|
|
296
|
+
<PageBody>
|
|
297
|
+
<CrudForm<StockItemFormValues>
|
|
298
|
+
title={t('inventory_items.create.title', 'Create stock item')}
|
|
299
|
+
backHref="/backend/inventory_items"
|
|
300
|
+
cancelHref="/backend/inventory_items"
|
|
301
|
+
schema={schema}
|
|
302
|
+
fields={fields}
|
|
303
|
+
groups={groups}
|
|
304
|
+
entityIds={[STOCK_ITEM_ENTITY_ID]}
|
|
305
|
+
submitLabel={t('inventory_items.form.submit', 'Save')}
|
|
306
|
+
onSubmit={async (values) => {
|
|
307
|
+
const call = await createCrud<{ id?: string }>('inventory_items', values)
|
|
308
|
+
const createdId = typeof call.result?.id === 'string' ? call.result.id : null
|
|
309
|
+
flash(t('inventory_items.create.success', 'Stock item created'), 'success')
|
|
310
|
+
router.push(createdId ? '/backend/inventory_items/' + createdId : '/backend/inventory_items')
|
|
311
|
+
}}
|
|
312
|
+
/>
|
|
313
|
+
</PageBody>
|
|
314
|
+
</Page>
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
"
|
|
318
|
+
`;
|
|
319
|
+
|
|
320
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): backend/inventory_items/page.meta.ts 1`] = `
|
|
321
|
+
"export const metadata = {
|
|
322
|
+
requireAuth: true,
|
|
323
|
+
requireFeatures: ['inventory_items.view'],
|
|
324
|
+
pageTitle: 'Inventory items',
|
|
325
|
+
pageTitleKey: 'inventory_items.nav.title',
|
|
326
|
+
pageGroup: 'Inventory items',
|
|
327
|
+
pageGroupKey: 'inventory_items.nav.group',
|
|
328
|
+
pageOrder: 100,
|
|
329
|
+
icon: 'list',
|
|
330
|
+
breadcrumb: [{ label: 'Inventory items', labelKey: 'inventory_items.nav.title' }],
|
|
331
|
+
}
|
|
332
|
+
"
|
|
333
|
+
`;
|
|
334
|
+
|
|
335
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): backend/inventory_items/page.tsx 1`] = `
|
|
336
|
+
""use client"
|
|
337
|
+
|
|
338
|
+
import * as React from 'react'
|
|
339
|
+
import Link from 'next/link'
|
|
340
|
+
import { useRouter } from 'next/navigation'
|
|
341
|
+
import { Page, PageBody } from '@open-mercato/ui/backend/Page'
|
|
342
|
+
import { DataTable, type DataTableExportFormat } from '@open-mercato/ui/backend/DataTable'
|
|
343
|
+
import type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'
|
|
344
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
345
|
+
import { EmptyState } from '@open-mercato/ui/primitives/empty-state'
|
|
346
|
+
import { RowActions } from '@open-mercato/ui/backend/RowActions'
|
|
347
|
+
import { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'
|
|
348
|
+
import { buildCrudExportUrl, deleteCrud } from '@open-mercato/ui/backend/utils/crud'
|
|
349
|
+
import { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'
|
|
350
|
+
import { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'
|
|
351
|
+
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
352
|
+
import { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'
|
|
353
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
354
|
+
import { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'
|
|
355
|
+
import { parseISO } from 'date-fns/parseISO'
|
|
356
|
+
import type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterOverlay'
|
|
357
|
+
import { StatusBadge } from '@open-mercato/ui/primitives/status-badge'
|
|
358
|
+
import { stockItemStatusMap, type StockItemStatus } from '../../components/statusMap'
|
|
359
|
+
|
|
360
|
+
type StockItemRow = {
|
|
361
|
+
id: string
|
|
362
|
+
updatedAt?: string | null
|
|
363
|
+
name: string
|
|
364
|
+
summary?: string | null
|
|
365
|
+
quantity: number
|
|
366
|
+
status?: StockItemStatus | null
|
|
367
|
+
severity: 'low' | 'high'
|
|
368
|
+
archived?: boolean | null
|
|
369
|
+
dueDate: string
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
type StockItemListResponse = {
|
|
373
|
+
items: StockItemRow[]
|
|
374
|
+
total: number
|
|
375
|
+
totalPages: number
|
|
376
|
+
totalIsCapped?: boolean
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// DS guardrail: keep pageSize at or below 100.
|
|
380
|
+
const PAGE_SIZE = 25
|
|
381
|
+
|
|
382
|
+
export default function StockItemListPage() {
|
|
383
|
+
const t = useT()
|
|
384
|
+
const router = useRouter()
|
|
385
|
+
const { confirm, ConfirmDialogElement } = useConfirmDialog()
|
|
386
|
+
const { runMutation, retryLastMutation } = useGuardedMutation({ contextId: 'inventory_items.list' })
|
|
387
|
+
const [rows, setRows] = React.useState<StockItemRow[]>([])
|
|
388
|
+
const [isLoading, setIsLoading] = React.useState(true)
|
|
389
|
+
const [loadError, setLoadError] = React.useState<string | null>(null)
|
|
390
|
+
const [page, setPage] = React.useState(1)
|
|
391
|
+
const [total, setTotal] = React.useState(0)
|
|
392
|
+
const [totalPages, setTotalPages] = React.useState(1)
|
|
393
|
+
const [totalIsCapped, setTotalIsCapped] = React.useState(false)
|
|
394
|
+
const [search, setSearch] = React.useState('')
|
|
395
|
+
const [filterValues, setFilterValues] = React.useState<FilterValues>({})
|
|
396
|
+
const [reloadToken, setReloadToken] = React.useState(0)
|
|
397
|
+
|
|
398
|
+
const listParams = React.useMemo(() => {
|
|
399
|
+
const params: Record<string, string | number> = { page, pageSize: PAGE_SIZE }
|
|
400
|
+
if (search) params.search = search
|
|
401
|
+
if (typeof filterValues.status === 'string' && filterValues.status) params.status = filterValues.status
|
|
402
|
+
if (typeof filterValues.severity === 'string' && filterValues.severity) params.severity = filterValues.severity
|
|
403
|
+
return params
|
|
404
|
+
}, [filterValues, page, search])
|
|
405
|
+
|
|
406
|
+
React.useEffect(() => {
|
|
407
|
+
let cancelled = false
|
|
408
|
+
async function load() {
|
|
409
|
+
setIsLoading(true)
|
|
410
|
+
setLoadError(null)
|
|
411
|
+
try {
|
|
412
|
+
const query = new URLSearchParams()
|
|
413
|
+
for (const [key, value] of Object.entries(listParams)) query.set(key, String(value))
|
|
414
|
+
const fallback: StockItemListResponse = { items: [], total: 0, totalPages: 1 }
|
|
415
|
+
const call = await apiCall<StockItemListResponse>('/api/inventory_items?' + query.toString(), undefined, { fallback })
|
|
416
|
+
if (cancelled) return
|
|
417
|
+
if (!call.ok) {
|
|
418
|
+
setLoadError(t('inventory_items.list.loadError', 'Failed to load inventory items'))
|
|
419
|
+
flash(t('inventory_items.list.loadError', 'Failed to load inventory items'), 'error')
|
|
420
|
+
return
|
|
421
|
+
}
|
|
422
|
+
const result = call.result ?? fallback
|
|
423
|
+
setRows(result.items)
|
|
424
|
+
setTotal(result.total)
|
|
425
|
+
setTotalPages(result.totalPages)
|
|
426
|
+
setTotalIsCapped(result.totalIsCapped === true)
|
|
427
|
+
} catch (error) {
|
|
428
|
+
if (cancelled) return
|
|
429
|
+
getTelemetryRuntime()?.reportError(error, { module: 'inventory_items', code: 'inventory_items.list_load_failed' })
|
|
430
|
+
setLoadError(t('inventory_items.list.loadError', 'Failed to load inventory items'))
|
|
431
|
+
} finally {
|
|
432
|
+
if (!cancelled) setIsLoading(false)
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
void load()
|
|
436
|
+
return () => { cancelled = true }
|
|
437
|
+
}, [listParams, reloadToken, t])
|
|
438
|
+
|
|
439
|
+
const handleDelete = React.useCallback(async (row: StockItemRow) => {
|
|
440
|
+
const confirmed = await confirm({
|
|
441
|
+
title: t('inventory_items.delete.confirmTitle', 'Delete stock item?'),
|
|
442
|
+
description: t('inventory_items.delete.confirmDescription', 'This action cannot be undone.'),
|
|
443
|
+
variant: 'destructive',
|
|
444
|
+
})
|
|
445
|
+
if (!confirmed) return
|
|
446
|
+
try {
|
|
447
|
+
// Optimistic locking is ON by default: derive the expected-updated-at
|
|
448
|
+
// header from the row the user acted on.
|
|
449
|
+
await runMutation({
|
|
450
|
+
operation: () =>
|
|
451
|
+
withScopedApiRequestHeaders(
|
|
452
|
+
buildOptimisticLockHeader(row.updatedAt ?? undefined),
|
|
453
|
+
() => deleteCrud('inventory_items', row.id),
|
|
454
|
+
),
|
|
455
|
+
context: {
|
|
456
|
+
formId: 'inventory_items.list',
|
|
457
|
+
resourceKind: 'inventory_items.stock_item',
|
|
458
|
+
resourceId: row.id,
|
|
459
|
+
retryLastMutation,
|
|
460
|
+
},
|
|
461
|
+
mutationPayload: { id: row.id },
|
|
462
|
+
})
|
|
463
|
+
flash(t('inventory_items.delete.success', 'Stock item deleted'), 'success')
|
|
464
|
+
setReloadToken((token) => token + 1)
|
|
465
|
+
} catch {
|
|
466
|
+
flash(t('inventory_items.delete.error', 'Failed to delete stock item'), 'error')
|
|
467
|
+
}
|
|
468
|
+
}, [confirm, retryLastMutation, runMutation, t])
|
|
469
|
+
|
|
470
|
+
const columns = React.useMemo<ColumnDef<StockItemRow>[]>(() => [
|
|
471
|
+
{ accessorKey: 'name', header: t('inventory_items.fields.name', 'Name') },
|
|
472
|
+
{
|
|
473
|
+
accessorKey: 'quantity',
|
|
474
|
+
header: t('inventory_items.fields.quantity', 'Quantity'),
|
|
475
|
+
cell: ({ row }) => <div className="text-right tabular-nums">{row.original.quantity ?? null}</div>,
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
accessorKey: 'status',
|
|
479
|
+
header: t('inventory_items.fields.status', 'Status'),
|
|
480
|
+
cell: ({ row }) => {
|
|
481
|
+
const status = row.original.status
|
|
482
|
+
if (!status) return null
|
|
483
|
+
return (
|
|
484
|
+
<StatusBadge variant={stockItemStatusMap[status] ?? 'neutral'} dot>
|
|
485
|
+
{t('inventory_items.fields.status.options.' + status, status)}
|
|
486
|
+
</StatusBadge>
|
|
487
|
+
)
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
accessorKey: 'severity',
|
|
492
|
+
header: t('inventory_items.fields.severity', 'Severity'),
|
|
493
|
+
cell: ({ row }) => (row.original.severity ? t('inventory_items.fields.severity.options.' + row.original.severity, row.original.severity) : null),
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
accessorKey: 'archived',
|
|
497
|
+
header: t('inventory_items.fields.archived', 'Archived'),
|
|
498
|
+
cell: ({ row }) => (row.original.archived ? t('inventory_items.list.boolean.yes', 'Yes') : t('inventory_items.list.boolean.no', 'No')),
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
accessorKey: 'dueDate',
|
|
502
|
+
header: t('inventory_items.fields.dueDate', 'Due date'),
|
|
503
|
+
cell: ({ row }) => (row.original.dueDate ? parseISO(row.original.dueDate).toLocaleDateString() : null),
|
|
504
|
+
},
|
|
505
|
+
], [t])
|
|
506
|
+
|
|
507
|
+
const filters = React.useMemo<FilterDef[]>(() => [
|
|
508
|
+
{
|
|
509
|
+
id: 'status',
|
|
510
|
+
label: t('inventory_items.fields.status', 'Status'),
|
|
511
|
+
type: 'select',
|
|
512
|
+
options: [
|
|
513
|
+
{ value: 'open', label: t('inventory_items.fields.status.options.open', 'Open') },
|
|
514
|
+
{ value: 'in_progress', label: t('inventory_items.fields.status.options.in_progress', 'In progress') },
|
|
515
|
+
{ value: 'closed', label: t('inventory_items.fields.status.options.closed', 'Closed') },
|
|
516
|
+
],
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
id: 'severity',
|
|
520
|
+
label: t('inventory_items.fields.severity', 'Severity'),
|
|
521
|
+
type: 'select',
|
|
522
|
+
options: [
|
|
523
|
+
{ value: 'low', label: t('inventory_items.fields.severity.options.low', 'Low') },
|
|
524
|
+
{ value: 'high', label: t('inventory_items.fields.severity.options.high', 'High') },
|
|
525
|
+
],
|
|
526
|
+
},
|
|
527
|
+
], [t])
|
|
528
|
+
|
|
529
|
+
const exporter = React.useMemo(() => ({
|
|
530
|
+
getUrl: (format: DataTableExportFormat) => buildCrudExportUrl('inventory_items', { ...listParams, exportScope: 'view' }, format),
|
|
531
|
+
filename: (format: DataTableExportFormat) => 'inventory_items.' + format,
|
|
532
|
+
}), [listParams])
|
|
533
|
+
|
|
534
|
+
return (
|
|
535
|
+
<Page>
|
|
536
|
+
<PageBody>
|
|
537
|
+
<DataTable<StockItemRow>
|
|
538
|
+
title={t('inventory_items.list.title', 'Inventory items')}
|
|
539
|
+
actions={(
|
|
540
|
+
<Button asChild>
|
|
541
|
+
<Link href="/backend/inventory_items/create">{t('inventory_items.list.actions.create', 'Create stock item')}</Link>
|
|
542
|
+
</Button>
|
|
543
|
+
)}
|
|
544
|
+
columns={columns}
|
|
545
|
+
data={rows}
|
|
546
|
+
isLoading={isLoading}
|
|
547
|
+
error={loadError}
|
|
548
|
+
searchValue={search}
|
|
549
|
+
onSearchChange={(value) => { setSearch(value); setPage(1) }}
|
|
550
|
+
searchPlaceholder={t('inventory_items.list.searchPlaceholder', 'Search inventory items')}
|
|
551
|
+
filters={filters}
|
|
552
|
+
filterValues={filterValues}
|
|
553
|
+
onFiltersApply={(values) => { setFilterValues(values); setPage(1) }}
|
|
554
|
+
onFiltersClear={() => { setFilterValues({}); setPage(1) }}
|
|
555
|
+
exporter={exporter}
|
|
556
|
+
extensionTableId="inventory_items.list"
|
|
557
|
+
onRowClick={(row) => router.push('/backend/inventory_items/' + row.id)}
|
|
558
|
+
rowActions={(row) => (
|
|
559
|
+
<RowActions
|
|
560
|
+
items={[
|
|
561
|
+
{
|
|
562
|
+
id: 'edit',
|
|
563
|
+
label: t('inventory_items.list.actions.edit', 'Edit'),
|
|
564
|
+
onSelect: () => { router.push('/backend/inventory_items/' + row.id) },
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
id: 'delete',
|
|
568
|
+
label: t('inventory_items.list.actions.delete', 'Delete'),
|
|
569
|
+
destructive: true,
|
|
570
|
+
onSelect: () => { void handleDelete(row) },
|
|
571
|
+
},
|
|
572
|
+
]}
|
|
573
|
+
/>
|
|
574
|
+
)}
|
|
575
|
+
emptyState={(
|
|
576
|
+
<EmptyState
|
|
577
|
+
title={t('inventory_items.list.empty.title', 'No inventory items yet')}
|
|
578
|
+
description={t('inventory_items.list.empty.description', 'Create your first stock item to get started.')}
|
|
579
|
+
actions={(
|
|
580
|
+
<Button asChild>
|
|
581
|
+
<Link href="/backend/inventory_items/create">{t('inventory_items.list.actions.create', 'Create stock item')}</Link>
|
|
582
|
+
</Button>
|
|
583
|
+
)}
|
|
584
|
+
/>
|
|
585
|
+
)}
|
|
586
|
+
pagination={{ page, pageSize: PAGE_SIZE, total, totalPages, totalIsCapped, onPageChange: setPage }}
|
|
587
|
+
/>
|
|
588
|
+
</PageBody>
|
|
589
|
+
{ConfirmDialogElement}
|
|
590
|
+
</Page>
|
|
591
|
+
)
|
|
592
|
+
}
|
|
593
|
+
"
|
|
594
|
+
`;
|
|
595
|
+
|
|
596
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): components/formConfig.ts 1`] = `
|
|
597
|
+
"import { z } from 'zod'
|
|
598
|
+
import type { CrudField, CrudFormGroup } from '@open-mercato/ui/backend/CrudForm'
|
|
599
|
+
import type { TranslateFn } from '@open-mercato/shared/lib/i18n/context'
|
|
600
|
+
import { stockItemCreateSchema } from '../data/validators'
|
|
601
|
+
|
|
602
|
+
/** Entity id used to load custom-field sets once the module declares \`ce.ts\`. */
|
|
603
|
+
export const STOCK_ITEM_ENTITY_ID = 'inventory_items:stock_item'
|
|
604
|
+
|
|
605
|
+
export type StockItemFormValues = z.infer<typeof stockItemCreateSchema>
|
|
606
|
+
|
|
607
|
+
export function createStockItemFormSchema() {
|
|
608
|
+
return stockItemCreateSchema
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
export function createStockItemFormFields(t: TranslateFn): CrudField[] {
|
|
612
|
+
return [
|
|
613
|
+
{ id: 'name', label: t('inventory_items.fields.name', 'Name'), type: 'text', required: true },
|
|
614
|
+
{ id: 'summary', label: t('inventory_items.fields.summary', 'Summary'), type: 'textarea' },
|
|
615
|
+
{ id: 'quantity', label: t('inventory_items.fields.quantity', 'Quantity'), type: 'number', required: true },
|
|
616
|
+
{
|
|
617
|
+
id: 'status',
|
|
618
|
+
label: t('inventory_items.fields.status', 'Status'),
|
|
619
|
+
type: 'select',
|
|
620
|
+
options: [
|
|
621
|
+
{ value: 'open', label: t('inventory_items.fields.status.options.open', 'Open') },
|
|
622
|
+
{ value: 'in_progress', label: t('inventory_items.fields.status.options.in_progress', 'In progress') },
|
|
623
|
+
{ value: 'closed', label: t('inventory_items.fields.status.options.closed', 'Closed') },
|
|
624
|
+
],
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
id: 'severity',
|
|
628
|
+
label: t('inventory_items.fields.severity', 'Severity'),
|
|
629
|
+
type: 'select',
|
|
630
|
+
required: true,
|
|
631
|
+
options: [
|
|
632
|
+
{ value: 'low', label: t('inventory_items.fields.severity.options.low', 'Low') },
|
|
633
|
+
{ value: 'high', label: t('inventory_items.fields.severity.options.high', 'High') },
|
|
634
|
+
],
|
|
635
|
+
},
|
|
636
|
+
{ id: 'archived', label: t('inventory_items.fields.archived', 'Archived'), type: 'checkbox' },
|
|
637
|
+
{ id: 'dueDate', label: t('inventory_items.fields.dueDate', 'Due date'), type: 'date', required: true },
|
|
638
|
+
]
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export function createStockItemFormGroups(t: TranslateFn): CrudFormGroup[] {
|
|
642
|
+
return [
|
|
643
|
+
{
|
|
644
|
+
id: 'details',
|
|
645
|
+
title: t('inventory_items.form.groups.details', 'Details'),
|
|
646
|
+
column: 1,
|
|
647
|
+
fields: ['name', 'summary', 'quantity', 'status', 'severity', 'archived', 'dueDate'],
|
|
648
|
+
},
|
|
649
|
+
// Custom-field sets registered for STOCK_ITEM_ENTITY_ID render here.
|
|
650
|
+
{
|
|
651
|
+
id: 'attributes',
|
|
652
|
+
title: t('inventory_items.form.groups.attributes', 'Attributes'),
|
|
653
|
+
column: 2,
|
|
654
|
+
kind: 'customFields',
|
|
655
|
+
},
|
|
656
|
+
]
|
|
657
|
+
}
|
|
658
|
+
"
|
|
659
|
+
`;
|
|
660
|
+
|
|
661
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): components/statusMap.ts 1`] = `
|
|
662
|
+
"import type { StatusMap } from '@open-mercato/ui/primitives/status-badge'
|
|
663
|
+
|
|
664
|
+
export type StockItemStatus = 'open' | 'in_progress' | 'closed'
|
|
665
|
+
|
|
666
|
+
// Shared status → semantic-variant mapping (DS rule: status colors come from
|
|
667
|
+
// StatusBadge variants, never hardcoded palette classes).
|
|
668
|
+
export const stockItemStatusMap: StatusMap<StockItemStatus> = {
|
|
669
|
+
open: 'info',
|
|
670
|
+
in_progress: 'info',
|
|
671
|
+
closed: 'neutral',
|
|
672
|
+
}
|
|
673
|
+
"
|
|
674
|
+
`;
|
|
675
|
+
|
|
676
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): data/validators.ts 1`] = `
|
|
677
|
+
"import { z } from 'zod'
|
|
678
|
+
|
|
679
|
+
// Optimistic locking is ON by default for CrudForm edit flows: the stock item
|
|
680
|
+
// API responses MUST return \`updatedAt\` and the backing table MUST carry an
|
|
681
|
+
// \`updated_at\` column so \`initialValues.updatedAt\` can drive the
|
|
682
|
+
// x-om-ext-optimistic-lock-expected-updated-at header on update and delete.
|
|
683
|
+
export const stockItemCreateSchema = z.object({
|
|
684
|
+
name: z.string().min(1),
|
|
685
|
+
summary: z.string().optional(),
|
|
686
|
+
quantity: z.coerce.number(),
|
|
687
|
+
status: z.enum(['open', 'in_progress', 'closed']).optional(),
|
|
688
|
+
severity: z.enum(['low', 'high']),
|
|
689
|
+
archived: z.boolean().optional(),
|
|
690
|
+
dueDate: z.string().date(),
|
|
691
|
+
})
|
|
692
|
+
|
|
693
|
+
export const stockItemUpdateSchema = stockItemCreateSchema.extend({
|
|
694
|
+
id: z.string().uuid(),
|
|
695
|
+
updatedAt: z.string().optional(),
|
|
696
|
+
})
|
|
697
|
+
|
|
698
|
+
export type StockItemCreateInput = z.infer<typeof stockItemCreateSchema>
|
|
699
|
+
export type StockItemUpdateInput = z.infer<typeof stockItemUpdateSchema>
|
|
700
|
+
"
|
|
701
|
+
`;
|
|
702
|
+
|
|
703
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): i18n/de.json 1`] = `
|
|
704
|
+
"{
|
|
705
|
+
"inventory_items.create.success": "Stock item created",
|
|
706
|
+
"inventory_items.create.title": "Create stock item",
|
|
707
|
+
"inventory_items.delete.confirmDescription": "This action cannot be undone.",
|
|
708
|
+
"inventory_items.delete.confirmTitle": "Delete stock item?",
|
|
709
|
+
"inventory_items.delete.error": "Failed to delete stock item",
|
|
710
|
+
"inventory_items.delete.success": "Stock item deleted",
|
|
711
|
+
"inventory_items.detail.actions.delete": "Delete",
|
|
712
|
+
"inventory_items.detail.loadError": "Failed to load stock item",
|
|
713
|
+
"inventory_items.detail.loading": "Loading stock item",
|
|
714
|
+
"inventory_items.detail.notFound": "Stock item not found",
|
|
715
|
+
"inventory_items.detail.tabs.label": "Stock item sections",
|
|
716
|
+
"inventory_items.detail.tabs.overview": "Overview",
|
|
717
|
+
"inventory_items.detail.title": "Stock item details",
|
|
718
|
+
"inventory_items.detail.updateSuccess": "Stock item updated",
|
|
719
|
+
"inventory_items.fields.archived": "Archived",
|
|
720
|
+
"inventory_items.fields.dueDate": "Due date",
|
|
721
|
+
"inventory_items.fields.name": "Name",
|
|
722
|
+
"inventory_items.fields.quantity": "Quantity",
|
|
723
|
+
"inventory_items.fields.severity": "Severity",
|
|
724
|
+
"inventory_items.fields.severity.options.high": "High",
|
|
725
|
+
"inventory_items.fields.severity.options.low": "Low",
|
|
726
|
+
"inventory_items.fields.status": "Status",
|
|
727
|
+
"inventory_items.fields.status.options.closed": "Closed",
|
|
728
|
+
"inventory_items.fields.status.options.in_progress": "In progress",
|
|
729
|
+
"inventory_items.fields.status.options.open": "Open",
|
|
730
|
+
"inventory_items.fields.summary": "Summary",
|
|
731
|
+
"inventory_items.form.groups.attributes": "Attributes",
|
|
732
|
+
"inventory_items.form.groups.details": "Details",
|
|
733
|
+
"inventory_items.form.submit": "Save",
|
|
734
|
+
"inventory_items.list.actions.create": "Create stock item",
|
|
735
|
+
"inventory_items.list.actions.delete": "Delete",
|
|
736
|
+
"inventory_items.list.actions.edit": "Edit",
|
|
737
|
+
"inventory_items.list.boolean.no": "No",
|
|
738
|
+
"inventory_items.list.boolean.yes": "Yes",
|
|
739
|
+
"inventory_items.list.empty.description": "Create your first stock item to get started.",
|
|
740
|
+
"inventory_items.list.empty.title": "No inventory items yet",
|
|
741
|
+
"inventory_items.list.loadError": "Failed to load inventory items",
|
|
742
|
+
"inventory_items.list.searchPlaceholder": "Search inventory items",
|
|
743
|
+
"inventory_items.list.title": "Inventory items",
|
|
744
|
+
"inventory_items.nav.group": "Inventory items",
|
|
745
|
+
"inventory_items.nav.title": "Inventory items"
|
|
746
|
+
}
|
|
747
|
+
"
|
|
748
|
+
`;
|
|
749
|
+
|
|
750
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): i18n/en.json 1`] = `
|
|
751
|
+
"{
|
|
752
|
+
"inventory_items.create.success": "Stock item created",
|
|
753
|
+
"inventory_items.create.title": "Create stock item",
|
|
754
|
+
"inventory_items.delete.confirmDescription": "This action cannot be undone.",
|
|
755
|
+
"inventory_items.delete.confirmTitle": "Delete stock item?",
|
|
756
|
+
"inventory_items.delete.error": "Failed to delete stock item",
|
|
757
|
+
"inventory_items.delete.success": "Stock item deleted",
|
|
758
|
+
"inventory_items.detail.actions.delete": "Delete",
|
|
759
|
+
"inventory_items.detail.loadError": "Failed to load stock item",
|
|
760
|
+
"inventory_items.detail.loading": "Loading stock item",
|
|
761
|
+
"inventory_items.detail.notFound": "Stock item not found",
|
|
762
|
+
"inventory_items.detail.tabs.label": "Stock item sections",
|
|
763
|
+
"inventory_items.detail.tabs.overview": "Overview",
|
|
764
|
+
"inventory_items.detail.title": "Stock item details",
|
|
765
|
+
"inventory_items.detail.updateSuccess": "Stock item updated",
|
|
766
|
+
"inventory_items.fields.archived": "Archived",
|
|
767
|
+
"inventory_items.fields.dueDate": "Due date",
|
|
768
|
+
"inventory_items.fields.name": "Name",
|
|
769
|
+
"inventory_items.fields.quantity": "Quantity",
|
|
770
|
+
"inventory_items.fields.severity": "Severity",
|
|
771
|
+
"inventory_items.fields.severity.options.high": "High",
|
|
772
|
+
"inventory_items.fields.severity.options.low": "Low",
|
|
773
|
+
"inventory_items.fields.status": "Status",
|
|
774
|
+
"inventory_items.fields.status.options.closed": "Closed",
|
|
775
|
+
"inventory_items.fields.status.options.in_progress": "In progress",
|
|
776
|
+
"inventory_items.fields.status.options.open": "Open",
|
|
777
|
+
"inventory_items.fields.summary": "Summary",
|
|
778
|
+
"inventory_items.form.groups.attributes": "Attributes",
|
|
779
|
+
"inventory_items.form.groups.details": "Details",
|
|
780
|
+
"inventory_items.form.submit": "Save",
|
|
781
|
+
"inventory_items.list.actions.create": "Create stock item",
|
|
782
|
+
"inventory_items.list.actions.delete": "Delete",
|
|
783
|
+
"inventory_items.list.actions.edit": "Edit",
|
|
784
|
+
"inventory_items.list.boolean.no": "No",
|
|
785
|
+
"inventory_items.list.boolean.yes": "Yes",
|
|
786
|
+
"inventory_items.list.empty.description": "Create your first stock item to get started.",
|
|
787
|
+
"inventory_items.list.empty.title": "No inventory items yet",
|
|
788
|
+
"inventory_items.list.loadError": "Failed to load inventory items",
|
|
789
|
+
"inventory_items.list.searchPlaceholder": "Search inventory items",
|
|
790
|
+
"inventory_items.list.title": "Inventory items",
|
|
791
|
+
"inventory_items.nav.group": "Inventory items",
|
|
792
|
+
"inventory_items.nav.title": "Inventory items"
|
|
793
|
+
}
|
|
794
|
+
"
|
|
795
|
+
`;
|
|
796
|
+
|
|
797
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): i18n/es.json 1`] = `
|
|
798
|
+
"{
|
|
799
|
+
"inventory_items.create.success": "Stock item created",
|
|
800
|
+
"inventory_items.create.title": "Create stock item",
|
|
801
|
+
"inventory_items.delete.confirmDescription": "This action cannot be undone.",
|
|
802
|
+
"inventory_items.delete.confirmTitle": "Delete stock item?",
|
|
803
|
+
"inventory_items.delete.error": "Failed to delete stock item",
|
|
804
|
+
"inventory_items.delete.success": "Stock item deleted",
|
|
805
|
+
"inventory_items.detail.actions.delete": "Delete",
|
|
806
|
+
"inventory_items.detail.loadError": "Failed to load stock item",
|
|
807
|
+
"inventory_items.detail.loading": "Loading stock item",
|
|
808
|
+
"inventory_items.detail.notFound": "Stock item not found",
|
|
809
|
+
"inventory_items.detail.tabs.label": "Stock item sections",
|
|
810
|
+
"inventory_items.detail.tabs.overview": "Overview",
|
|
811
|
+
"inventory_items.detail.title": "Stock item details",
|
|
812
|
+
"inventory_items.detail.updateSuccess": "Stock item updated",
|
|
813
|
+
"inventory_items.fields.archived": "Archived",
|
|
814
|
+
"inventory_items.fields.dueDate": "Due date",
|
|
815
|
+
"inventory_items.fields.name": "Name",
|
|
816
|
+
"inventory_items.fields.quantity": "Quantity",
|
|
817
|
+
"inventory_items.fields.severity": "Severity",
|
|
818
|
+
"inventory_items.fields.severity.options.high": "High",
|
|
819
|
+
"inventory_items.fields.severity.options.low": "Low",
|
|
820
|
+
"inventory_items.fields.status": "Status",
|
|
821
|
+
"inventory_items.fields.status.options.closed": "Closed",
|
|
822
|
+
"inventory_items.fields.status.options.in_progress": "In progress",
|
|
823
|
+
"inventory_items.fields.status.options.open": "Open",
|
|
824
|
+
"inventory_items.fields.summary": "Summary",
|
|
825
|
+
"inventory_items.form.groups.attributes": "Attributes",
|
|
826
|
+
"inventory_items.form.groups.details": "Details",
|
|
827
|
+
"inventory_items.form.submit": "Save",
|
|
828
|
+
"inventory_items.list.actions.create": "Create stock item",
|
|
829
|
+
"inventory_items.list.actions.delete": "Delete",
|
|
830
|
+
"inventory_items.list.actions.edit": "Edit",
|
|
831
|
+
"inventory_items.list.boolean.no": "No",
|
|
832
|
+
"inventory_items.list.boolean.yes": "Yes",
|
|
833
|
+
"inventory_items.list.empty.description": "Create your first stock item to get started.",
|
|
834
|
+
"inventory_items.list.empty.title": "No inventory items yet",
|
|
835
|
+
"inventory_items.list.loadError": "Failed to load inventory items",
|
|
836
|
+
"inventory_items.list.searchPlaceholder": "Search inventory items",
|
|
837
|
+
"inventory_items.list.title": "Inventory items",
|
|
838
|
+
"inventory_items.nav.group": "Inventory items",
|
|
839
|
+
"inventory_items.nav.title": "Inventory items"
|
|
840
|
+
}
|
|
841
|
+
"
|
|
842
|
+
`;
|
|
843
|
+
|
|
844
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): i18n/ko.json 1`] = `
|
|
845
|
+
"{
|
|
846
|
+
"inventory_items.create.success": "Stock item created",
|
|
847
|
+
"inventory_items.create.title": "Create stock item",
|
|
848
|
+
"inventory_items.delete.confirmDescription": "This action cannot be undone.",
|
|
849
|
+
"inventory_items.delete.confirmTitle": "Delete stock item?",
|
|
850
|
+
"inventory_items.delete.error": "Failed to delete stock item",
|
|
851
|
+
"inventory_items.delete.success": "Stock item deleted",
|
|
852
|
+
"inventory_items.detail.actions.delete": "Delete",
|
|
853
|
+
"inventory_items.detail.loadError": "Failed to load stock item",
|
|
854
|
+
"inventory_items.detail.loading": "Loading stock item",
|
|
855
|
+
"inventory_items.detail.notFound": "Stock item not found",
|
|
856
|
+
"inventory_items.detail.tabs.label": "Stock item sections",
|
|
857
|
+
"inventory_items.detail.tabs.overview": "Overview",
|
|
858
|
+
"inventory_items.detail.title": "Stock item details",
|
|
859
|
+
"inventory_items.detail.updateSuccess": "Stock item updated",
|
|
860
|
+
"inventory_items.fields.archived": "Archived",
|
|
861
|
+
"inventory_items.fields.dueDate": "Due date",
|
|
862
|
+
"inventory_items.fields.name": "Name",
|
|
863
|
+
"inventory_items.fields.quantity": "Quantity",
|
|
864
|
+
"inventory_items.fields.severity": "Severity",
|
|
865
|
+
"inventory_items.fields.severity.options.high": "High",
|
|
866
|
+
"inventory_items.fields.severity.options.low": "Low",
|
|
867
|
+
"inventory_items.fields.status": "Status",
|
|
868
|
+
"inventory_items.fields.status.options.closed": "Closed",
|
|
869
|
+
"inventory_items.fields.status.options.in_progress": "In progress",
|
|
870
|
+
"inventory_items.fields.status.options.open": "Open",
|
|
871
|
+
"inventory_items.fields.summary": "Summary",
|
|
872
|
+
"inventory_items.form.groups.attributes": "Attributes",
|
|
873
|
+
"inventory_items.form.groups.details": "Details",
|
|
874
|
+
"inventory_items.form.submit": "Save",
|
|
875
|
+
"inventory_items.list.actions.create": "Create stock item",
|
|
876
|
+
"inventory_items.list.actions.delete": "Delete",
|
|
877
|
+
"inventory_items.list.actions.edit": "Edit",
|
|
878
|
+
"inventory_items.list.boolean.no": "No",
|
|
879
|
+
"inventory_items.list.boolean.yes": "Yes",
|
|
880
|
+
"inventory_items.list.empty.description": "Create your first stock item to get started.",
|
|
881
|
+
"inventory_items.list.empty.title": "No inventory items yet",
|
|
882
|
+
"inventory_items.list.loadError": "Failed to load inventory items",
|
|
883
|
+
"inventory_items.list.searchPlaceholder": "Search inventory items",
|
|
884
|
+
"inventory_items.list.title": "Inventory items",
|
|
885
|
+
"inventory_items.nav.group": "Inventory items",
|
|
886
|
+
"inventory_items.nav.title": "Inventory items"
|
|
887
|
+
}
|
|
888
|
+
"
|
|
889
|
+
`;
|
|
890
|
+
|
|
891
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): i18n/pl.json 1`] = `
|
|
892
|
+
"{
|
|
893
|
+
"inventory_items.create.success": "Stock item created",
|
|
894
|
+
"inventory_items.create.title": "Create stock item",
|
|
895
|
+
"inventory_items.delete.confirmDescription": "This action cannot be undone.",
|
|
896
|
+
"inventory_items.delete.confirmTitle": "Delete stock item?",
|
|
897
|
+
"inventory_items.delete.error": "Failed to delete stock item",
|
|
898
|
+
"inventory_items.delete.success": "Stock item deleted",
|
|
899
|
+
"inventory_items.detail.actions.delete": "Delete",
|
|
900
|
+
"inventory_items.detail.loadError": "Failed to load stock item",
|
|
901
|
+
"inventory_items.detail.loading": "Loading stock item",
|
|
902
|
+
"inventory_items.detail.notFound": "Stock item not found",
|
|
903
|
+
"inventory_items.detail.tabs.label": "Stock item sections",
|
|
904
|
+
"inventory_items.detail.tabs.overview": "Overview",
|
|
905
|
+
"inventory_items.detail.title": "Stock item details",
|
|
906
|
+
"inventory_items.detail.updateSuccess": "Stock item updated",
|
|
907
|
+
"inventory_items.fields.archived": "Archived",
|
|
908
|
+
"inventory_items.fields.dueDate": "Due date",
|
|
909
|
+
"inventory_items.fields.name": "Name",
|
|
910
|
+
"inventory_items.fields.quantity": "Quantity",
|
|
911
|
+
"inventory_items.fields.severity": "Severity",
|
|
912
|
+
"inventory_items.fields.severity.options.high": "High",
|
|
913
|
+
"inventory_items.fields.severity.options.low": "Low",
|
|
914
|
+
"inventory_items.fields.status": "Status",
|
|
915
|
+
"inventory_items.fields.status.options.closed": "Closed",
|
|
916
|
+
"inventory_items.fields.status.options.in_progress": "In progress",
|
|
917
|
+
"inventory_items.fields.status.options.open": "Open",
|
|
918
|
+
"inventory_items.fields.summary": "Summary",
|
|
919
|
+
"inventory_items.form.groups.attributes": "Attributes",
|
|
920
|
+
"inventory_items.form.groups.details": "Details",
|
|
921
|
+
"inventory_items.form.submit": "Save",
|
|
922
|
+
"inventory_items.list.actions.create": "Create stock item",
|
|
923
|
+
"inventory_items.list.actions.delete": "Delete",
|
|
924
|
+
"inventory_items.list.actions.edit": "Edit",
|
|
925
|
+
"inventory_items.list.boolean.no": "No",
|
|
926
|
+
"inventory_items.list.boolean.yes": "Yes",
|
|
927
|
+
"inventory_items.list.empty.description": "Create your first stock item to get started.",
|
|
928
|
+
"inventory_items.list.empty.title": "No inventory items yet",
|
|
929
|
+
"inventory_items.list.loadError": "Failed to load inventory items",
|
|
930
|
+
"inventory_items.list.searchPlaceholder": "Search inventory items",
|
|
931
|
+
"inventory_items.list.title": "Inventory items",
|
|
932
|
+
"inventory_items.nav.group": "Inventory items",
|
|
933
|
+
"inventory_items.nav.title": "Inventory items"
|
|
934
|
+
}
|
|
935
|
+
"
|
|
936
|
+
`;
|
|
937
|
+
|
|
938
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): index.ts 1`] = `
|
|
939
|
+
"import type { ModuleInfo } from '@open-mercato/shared/modules/registry'
|
|
940
|
+
|
|
941
|
+
export const metadata: ModuleInfo = {
|
|
942
|
+
name: 'inventory_items',
|
|
943
|
+
title: 'Inventory items',
|
|
944
|
+
version: '0.1.0',
|
|
945
|
+
description: 'Inventory items module scaffolded with mercato module scaffold.',
|
|
946
|
+
author: 'Open Mercato Team',
|
|
947
|
+
license: 'MIT',
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
export { features } from './acl'
|
|
951
|
+
"
|
|
952
|
+
`;
|
|
953
|
+
|
|
954
|
+
exports[`scaffold golden files emits the full DS-compliant UI slice for every field type (app target): setup.ts 1`] = `
|
|
955
|
+
"import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
|
|
956
|
+
|
|
957
|
+
export const setup: ModuleSetupConfig = {
|
|
958
|
+
defaultRoleFeatures: {
|
|
959
|
+
superadmin: ['inventory_items.*'],
|
|
960
|
+
admin: ['inventory_items.*'],
|
|
961
|
+
employee: ['inventory_items.view'],
|
|
962
|
+
},
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
export default setup
|
|
966
|
+
"
|
|
967
|
+
`;
|
|
968
|
+
|
|
969
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status acl.ts 1`] = `
|
|
970
|
+
"export const features = [
|
|
971
|
+
{ id: 'notes.view', title: 'View notes', module: 'notes' },
|
|
972
|
+
{
|
|
973
|
+
id: 'notes.create',
|
|
974
|
+
title: 'Create notes',
|
|
975
|
+
module: 'notes',
|
|
976
|
+
dependsOn: ['notes.view'],
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
id: 'notes.edit',
|
|
980
|
+
title: 'Edit notes',
|
|
981
|
+
module: 'notes',
|
|
982
|
+
dependsOn: ['notes.view'],
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
id: 'notes.delete',
|
|
986
|
+
title: 'Delete notes',
|
|
987
|
+
module: 'notes',
|
|
988
|
+
dependsOn: ['notes.view'],
|
|
989
|
+
},
|
|
990
|
+
]
|
|
991
|
+
|
|
992
|
+
export default features
|
|
993
|
+
"
|
|
994
|
+
`;
|
|
995
|
+
|
|
996
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status backend/notes/[id]/page.meta.ts 1`] = `
|
|
997
|
+
"export const metadata = {
|
|
998
|
+
requireAuth: true,
|
|
999
|
+
requireFeatures: ['notes.view'],
|
|
1000
|
+
pageTitle: 'Note details',
|
|
1001
|
+
pageTitleKey: 'notes.detail.title',
|
|
1002
|
+
pageGroup: 'Notes',
|
|
1003
|
+
pageGroupKey: 'notes.nav.group',
|
|
1004
|
+
navHidden: true,
|
|
1005
|
+
breadcrumb: [
|
|
1006
|
+
{ label: 'Notes', labelKey: 'notes.nav.title', href: '/backend/notes' },
|
|
1007
|
+
{ label: 'Details', labelKey: 'notes.detail.title' },
|
|
1008
|
+
],
|
|
1009
|
+
}
|
|
1010
|
+
"
|
|
1011
|
+
`;
|
|
1012
|
+
|
|
1013
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status backend/notes/[id]/page.tsx 1`] = `
|
|
1014
|
+
""use client"
|
|
1015
|
+
|
|
1016
|
+
import * as React from 'react'
|
|
1017
|
+
import { useRouter } from 'next/navigation'
|
|
1018
|
+
import { Page, PageBody } from '@open-mercato/ui/backend/Page'
|
|
1019
|
+
import { CrudForm } from '@open-mercato/ui/backend/CrudForm'
|
|
1020
|
+
import { FormHeader } from '@open-mercato/ui/backend/forms/FormHeader'
|
|
1021
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@open-mercato/ui/primitives/tabs'
|
|
1022
|
+
import { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'
|
|
1023
|
+
import { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'
|
|
1024
|
+
import { updateCrud, deleteCrud } from '@open-mercato/ui/backend/utils/crud'
|
|
1025
|
+
import { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'
|
|
1026
|
+
import { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'
|
|
1027
|
+
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
1028
|
+
import { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'
|
|
1029
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
1030
|
+
import { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'
|
|
1031
|
+
import { noteUpdateSchema, type NoteUpdateInput } from '../../../data/validators'
|
|
1032
|
+
import {
|
|
1033
|
+
NOTE_ENTITY_ID,
|
|
1034
|
+
createNoteFormFields,
|
|
1035
|
+
createNoteFormGroups,
|
|
1036
|
+
} from '../../../components/formConfig'
|
|
1037
|
+
|
|
1038
|
+
type NoteRecord = {
|
|
1039
|
+
id: string
|
|
1040
|
+
updatedAt?: string | null
|
|
1041
|
+
title: string
|
|
1042
|
+
body?: string | null
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
type NoteListResponse = {
|
|
1046
|
+
items: NoteRecord[]
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
export default function NoteDetailPage({ params }: { params?: { id?: string } }) {
|
|
1050
|
+
const t = useT()
|
|
1051
|
+
const router = useRouter()
|
|
1052
|
+
const id = typeof params?.id === 'string' ? params.id : null
|
|
1053
|
+
const { confirm, ConfirmDialogElement } = useConfirmDialog()
|
|
1054
|
+
const { runMutation, retryLastMutation } = useGuardedMutation({ contextId: 'notes.detail' })
|
|
1055
|
+
const [record, setRecord] = React.useState<NoteRecord | null>(null)
|
|
1056
|
+
const [isLoading, setIsLoading] = React.useState(true)
|
|
1057
|
+
const [loadError, setLoadError] = React.useState<string | null>(null)
|
|
1058
|
+
const [reloadToken, setReloadToken] = React.useState(0)
|
|
1059
|
+
|
|
1060
|
+
React.useEffect(() => {
|
|
1061
|
+
let cancelled = false
|
|
1062
|
+
async function load() {
|
|
1063
|
+
if (!id) {
|
|
1064
|
+
setLoadError(t('notes.detail.notFound', 'Note not found'))
|
|
1065
|
+
setIsLoading(false)
|
|
1066
|
+
return
|
|
1067
|
+
}
|
|
1068
|
+
setIsLoading(true)
|
|
1069
|
+
setLoadError(null)
|
|
1070
|
+
try {
|
|
1071
|
+
const query = new URLSearchParams({ ids: id, pageSize: '1' })
|
|
1072
|
+
const call = await apiCall<NoteListResponse>('/api/notes?' + query.toString())
|
|
1073
|
+
if (cancelled) return
|
|
1074
|
+
if (!call.ok) {
|
|
1075
|
+
setLoadError(t('notes.detail.loadError', 'Failed to load note'))
|
|
1076
|
+
return
|
|
1077
|
+
}
|
|
1078
|
+
const item = call.result?.items?.[0] ?? null
|
|
1079
|
+
if (!item) {
|
|
1080
|
+
setLoadError(t('notes.detail.notFound', 'Note not found'))
|
|
1081
|
+
return
|
|
1082
|
+
}
|
|
1083
|
+
setRecord(item)
|
|
1084
|
+
} catch (error) {
|
|
1085
|
+
if (cancelled) return
|
|
1086
|
+
getTelemetryRuntime()?.reportError(error, { module: 'notes', code: 'notes.detail_load_failed' })
|
|
1087
|
+
setLoadError(t('notes.detail.loadError', 'Failed to load note'))
|
|
1088
|
+
} finally {
|
|
1089
|
+
if (!cancelled) setIsLoading(false)
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
void load()
|
|
1093
|
+
return () => { cancelled = true }
|
|
1094
|
+
}, [id, reloadToken, t])
|
|
1095
|
+
|
|
1096
|
+
const fields = React.useMemo(() => createNoteFormFields(t), [t])
|
|
1097
|
+
const groups = React.useMemo(() => createNoteFormGroups(t), [t])
|
|
1098
|
+
|
|
1099
|
+
// updatedAt MUST stay in initialValues: CrudForm auto-derives the
|
|
1100
|
+
// x-om-ext-optimistic-lock-expected-updated-at header from it on submit AND delete.
|
|
1101
|
+
const initialValues = React.useMemo<Partial<NoteUpdateInput> | undefined>(() => {
|
|
1102
|
+
if (!record) return undefined
|
|
1103
|
+
return {
|
|
1104
|
+
id: record.id,
|
|
1105
|
+
updatedAt: record.updatedAt ?? undefined,
|
|
1106
|
+
title: record.title,
|
|
1107
|
+
body: record.body ?? undefined,
|
|
1108
|
+
}
|
|
1109
|
+
}, [record])
|
|
1110
|
+
|
|
1111
|
+
const handleDelete = React.useCallback(async () => {
|
|
1112
|
+
if (!record) return
|
|
1113
|
+
const confirmed = await confirm({
|
|
1114
|
+
title: t('notes.delete.confirmTitle', 'Delete note?'),
|
|
1115
|
+
description: t('notes.delete.confirmDescription', 'This action cannot be undone.'),
|
|
1116
|
+
variant: 'destructive',
|
|
1117
|
+
})
|
|
1118
|
+
if (!confirmed) return
|
|
1119
|
+
try {
|
|
1120
|
+
await runMutation({
|
|
1121
|
+
operation: () =>
|
|
1122
|
+
withScopedApiRequestHeaders(
|
|
1123
|
+
buildOptimisticLockHeader(record.updatedAt ?? undefined),
|
|
1124
|
+
() => deleteCrud('notes', record.id),
|
|
1125
|
+
),
|
|
1126
|
+
context: {
|
|
1127
|
+
formId: 'notes.detail',
|
|
1128
|
+
resourceKind: 'notes.note',
|
|
1129
|
+
resourceId: record.id,
|
|
1130
|
+
retryLastMutation,
|
|
1131
|
+
},
|
|
1132
|
+
mutationPayload: { id: record.id },
|
|
1133
|
+
})
|
|
1134
|
+
flash(t('notes.delete.success', 'Note deleted'), 'success')
|
|
1135
|
+
router.push('/backend/notes')
|
|
1136
|
+
} catch {
|
|
1137
|
+
flash(t('notes.delete.error', 'Failed to delete note'), 'error')
|
|
1138
|
+
}
|
|
1139
|
+
}, [confirm, record, retryLastMutation, router, runMutation, t])
|
|
1140
|
+
|
|
1141
|
+
if (isLoading) {
|
|
1142
|
+
return (
|
|
1143
|
+
<Page>
|
|
1144
|
+
<PageBody>
|
|
1145
|
+
<LoadingMessage label={t('notes.detail.loading', 'Loading note')} />
|
|
1146
|
+
</PageBody>
|
|
1147
|
+
</Page>
|
|
1148
|
+
)
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
if (loadError || !record) {
|
|
1152
|
+
return (
|
|
1153
|
+
<Page>
|
|
1154
|
+
<PageBody>
|
|
1155
|
+
<ErrorMessage label={loadError ?? t('notes.detail.notFound', 'Note not found')} />
|
|
1156
|
+
</PageBody>
|
|
1157
|
+
</Page>
|
|
1158
|
+
)
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
return (
|
|
1162
|
+
<Page>
|
|
1163
|
+
<PageBody>
|
|
1164
|
+
<FormHeader
|
|
1165
|
+
mode="detail"
|
|
1166
|
+
backHref="/backend/notes"
|
|
1167
|
+
title={record.title}
|
|
1168
|
+
onDelete={() => { void handleDelete() }}
|
|
1169
|
+
deleteLabel={t('notes.detail.actions.delete', 'Delete')}
|
|
1170
|
+
/>
|
|
1171
|
+
<Tabs defaultValue="overview" variant="underline" className="mt-4">
|
|
1172
|
+
<TabsList aria-label={t('notes.detail.tabs.label', 'Note sections')}>
|
|
1173
|
+
<TabsTrigger value="overview">{t('notes.detail.tabs.overview', 'Overview')}</TabsTrigger>
|
|
1174
|
+
{/* Extension point: add related-entity tabs here (activity, attachments, ...). */}
|
|
1175
|
+
</TabsList>
|
|
1176
|
+
<TabsContent value="overview">
|
|
1177
|
+
<CrudForm<NoteUpdateInput>
|
|
1178
|
+
schema={noteUpdateSchema}
|
|
1179
|
+
fields={fields}
|
|
1180
|
+
groups={groups}
|
|
1181
|
+
initialValues={initialValues}
|
|
1182
|
+
entityIds={[NOTE_ENTITY_ID]}
|
|
1183
|
+
submitLabel={t('notes.form.submit', 'Save')}
|
|
1184
|
+
onSubmit={async (values) => {
|
|
1185
|
+
await updateCrud('notes', values)
|
|
1186
|
+
flash(t('notes.detail.updateSuccess', 'Note updated'), 'success')
|
|
1187
|
+
setReloadToken((token) => token + 1)
|
|
1188
|
+
}}
|
|
1189
|
+
/>
|
|
1190
|
+
</TabsContent>
|
|
1191
|
+
</Tabs>
|
|
1192
|
+
</PageBody>
|
|
1193
|
+
{ConfirmDialogElement}
|
|
1194
|
+
</Page>
|
|
1195
|
+
)
|
|
1196
|
+
}
|
|
1197
|
+
"
|
|
1198
|
+
`;
|
|
1199
|
+
|
|
1200
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status backend/notes/create/page.meta.ts 1`] = `
|
|
1201
|
+
"export const metadata = {
|
|
1202
|
+
requireAuth: true,
|
|
1203
|
+
requireFeatures: ['notes.create'],
|
|
1204
|
+
pageTitle: 'Create note',
|
|
1205
|
+
pageTitleKey: 'notes.create.title',
|
|
1206
|
+
pageGroup: 'Notes',
|
|
1207
|
+
pageGroupKey: 'notes.nav.group',
|
|
1208
|
+
pageOrder: 101,
|
|
1209
|
+
icon: 'plus',
|
|
1210
|
+
breadcrumb: [
|
|
1211
|
+
{ label: 'Notes', labelKey: 'notes.nav.title', href: '/backend/notes' },
|
|
1212
|
+
{ label: 'Create', labelKey: 'notes.create.title' },
|
|
1213
|
+
],
|
|
1214
|
+
}
|
|
1215
|
+
"
|
|
1216
|
+
`;
|
|
1217
|
+
|
|
1218
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status backend/notes/create/page.tsx 1`] = `
|
|
1219
|
+
""use client"
|
|
1220
|
+
|
|
1221
|
+
import * as React from 'react'
|
|
1222
|
+
import { useRouter } from 'next/navigation'
|
|
1223
|
+
import { Page, PageBody } from '@open-mercato/ui/backend/Page'
|
|
1224
|
+
import { CrudForm } from '@open-mercato/ui/backend/CrudForm'
|
|
1225
|
+
import { createCrud } from '@open-mercato/ui/backend/utils/crud'
|
|
1226
|
+
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
1227
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
1228
|
+
import {
|
|
1229
|
+
NOTE_ENTITY_ID,
|
|
1230
|
+
createNoteFormFields,
|
|
1231
|
+
createNoteFormGroups,
|
|
1232
|
+
createNoteFormSchema,
|
|
1233
|
+
type NoteFormValues,
|
|
1234
|
+
} from '../../../components/formConfig'
|
|
1235
|
+
|
|
1236
|
+
export default function NoteCreatePage() {
|
|
1237
|
+
const t = useT()
|
|
1238
|
+
const router = useRouter()
|
|
1239
|
+
const schema = React.useMemo(() => createNoteFormSchema(), [])
|
|
1240
|
+
const fields = React.useMemo(() => createNoteFormFields(t), [t])
|
|
1241
|
+
const groups = React.useMemo(() => createNoteFormGroups(t), [t])
|
|
1242
|
+
|
|
1243
|
+
return (
|
|
1244
|
+
<Page>
|
|
1245
|
+
<PageBody>
|
|
1246
|
+
<CrudForm<NoteFormValues>
|
|
1247
|
+
title={t('notes.create.title', 'Create note')}
|
|
1248
|
+
backHref="/backend/notes"
|
|
1249
|
+
cancelHref="/backend/notes"
|
|
1250
|
+
schema={schema}
|
|
1251
|
+
fields={fields}
|
|
1252
|
+
groups={groups}
|
|
1253
|
+
entityIds={[NOTE_ENTITY_ID]}
|
|
1254
|
+
submitLabel={t('notes.form.submit', 'Save')}
|
|
1255
|
+
onSubmit={async (values) => {
|
|
1256
|
+
const call = await createCrud<{ id?: string }>('notes', values)
|
|
1257
|
+
const createdId = typeof call.result?.id === 'string' ? call.result.id : null
|
|
1258
|
+
flash(t('notes.create.success', 'Note created'), 'success')
|
|
1259
|
+
router.push(createdId ? '/backend/notes/' + createdId : '/backend/notes')
|
|
1260
|
+
}}
|
|
1261
|
+
/>
|
|
1262
|
+
</PageBody>
|
|
1263
|
+
</Page>
|
|
1264
|
+
)
|
|
1265
|
+
}
|
|
1266
|
+
"
|
|
1267
|
+
`;
|
|
1268
|
+
|
|
1269
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status backend/notes/page.meta.ts 1`] = `
|
|
1270
|
+
"export const metadata = {
|
|
1271
|
+
requireAuth: true,
|
|
1272
|
+
requireFeatures: ['notes.view'],
|
|
1273
|
+
pageTitle: 'Notes',
|
|
1274
|
+
pageTitleKey: 'notes.nav.title',
|
|
1275
|
+
pageGroup: 'Notes',
|
|
1276
|
+
pageGroupKey: 'notes.nav.group',
|
|
1277
|
+
pageOrder: 100,
|
|
1278
|
+
icon: 'list',
|
|
1279
|
+
breadcrumb: [{ label: 'Notes', labelKey: 'notes.nav.title' }],
|
|
1280
|
+
}
|
|
1281
|
+
"
|
|
1282
|
+
`;
|
|
1283
|
+
|
|
1284
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status backend/notes/page.tsx 1`] = `
|
|
1285
|
+
""use client"
|
|
1286
|
+
|
|
1287
|
+
import * as React from 'react'
|
|
1288
|
+
import Link from 'next/link'
|
|
1289
|
+
import { useRouter } from 'next/navigation'
|
|
1290
|
+
import { Page, PageBody } from '@open-mercato/ui/backend/Page'
|
|
1291
|
+
import { DataTable, type DataTableExportFormat } from '@open-mercato/ui/backend/DataTable'
|
|
1292
|
+
import type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'
|
|
1293
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
1294
|
+
import { EmptyState } from '@open-mercato/ui/primitives/empty-state'
|
|
1295
|
+
import { RowActions } from '@open-mercato/ui/backend/RowActions'
|
|
1296
|
+
import { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'
|
|
1297
|
+
import { buildCrudExportUrl, deleteCrud } from '@open-mercato/ui/backend/utils/crud'
|
|
1298
|
+
import { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'
|
|
1299
|
+
import { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'
|
|
1300
|
+
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
1301
|
+
import { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'
|
|
1302
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
1303
|
+
import { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'
|
|
1304
|
+
|
|
1305
|
+
type NoteRow = {
|
|
1306
|
+
id: string
|
|
1307
|
+
updatedAt?: string | null
|
|
1308
|
+
title: string
|
|
1309
|
+
body?: string | null
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
type NoteListResponse = {
|
|
1313
|
+
items: NoteRow[]
|
|
1314
|
+
total: number
|
|
1315
|
+
totalPages: number
|
|
1316
|
+
totalIsCapped?: boolean
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
// DS guardrail: keep pageSize at or below 100.
|
|
1320
|
+
const PAGE_SIZE = 25
|
|
1321
|
+
|
|
1322
|
+
export default function NoteListPage() {
|
|
1323
|
+
const t = useT()
|
|
1324
|
+
const router = useRouter()
|
|
1325
|
+
const { confirm, ConfirmDialogElement } = useConfirmDialog()
|
|
1326
|
+
const { runMutation, retryLastMutation } = useGuardedMutation({ contextId: 'notes.list' })
|
|
1327
|
+
const [rows, setRows] = React.useState<NoteRow[]>([])
|
|
1328
|
+
const [isLoading, setIsLoading] = React.useState(true)
|
|
1329
|
+
const [loadError, setLoadError] = React.useState<string | null>(null)
|
|
1330
|
+
const [page, setPage] = React.useState(1)
|
|
1331
|
+
const [total, setTotal] = React.useState(0)
|
|
1332
|
+
const [totalPages, setTotalPages] = React.useState(1)
|
|
1333
|
+
const [totalIsCapped, setTotalIsCapped] = React.useState(false)
|
|
1334
|
+
const [search, setSearch] = React.useState('')
|
|
1335
|
+
const [reloadToken, setReloadToken] = React.useState(0)
|
|
1336
|
+
|
|
1337
|
+
const listParams = React.useMemo(() => {
|
|
1338
|
+
const params: Record<string, string | number> = { page, pageSize: PAGE_SIZE }
|
|
1339
|
+
if (search) params.search = search
|
|
1340
|
+
return params
|
|
1341
|
+
}, [page, search])
|
|
1342
|
+
|
|
1343
|
+
React.useEffect(() => {
|
|
1344
|
+
let cancelled = false
|
|
1345
|
+
async function load() {
|
|
1346
|
+
setIsLoading(true)
|
|
1347
|
+
setLoadError(null)
|
|
1348
|
+
try {
|
|
1349
|
+
const query = new URLSearchParams()
|
|
1350
|
+
for (const [key, value] of Object.entries(listParams)) query.set(key, String(value))
|
|
1351
|
+
const fallback: NoteListResponse = { items: [], total: 0, totalPages: 1 }
|
|
1352
|
+
const call = await apiCall<NoteListResponse>('/api/notes?' + query.toString(), undefined, { fallback })
|
|
1353
|
+
if (cancelled) return
|
|
1354
|
+
if (!call.ok) {
|
|
1355
|
+
setLoadError(t('notes.list.loadError', 'Failed to load notes'))
|
|
1356
|
+
flash(t('notes.list.loadError', 'Failed to load notes'), 'error')
|
|
1357
|
+
return
|
|
1358
|
+
}
|
|
1359
|
+
const result = call.result ?? fallback
|
|
1360
|
+
setRows(result.items)
|
|
1361
|
+
setTotal(result.total)
|
|
1362
|
+
setTotalPages(result.totalPages)
|
|
1363
|
+
setTotalIsCapped(result.totalIsCapped === true)
|
|
1364
|
+
} catch (error) {
|
|
1365
|
+
if (cancelled) return
|
|
1366
|
+
getTelemetryRuntime()?.reportError(error, { module: 'notes', code: 'notes.list_load_failed' })
|
|
1367
|
+
setLoadError(t('notes.list.loadError', 'Failed to load notes'))
|
|
1368
|
+
} finally {
|
|
1369
|
+
if (!cancelled) setIsLoading(false)
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
void load()
|
|
1373
|
+
return () => { cancelled = true }
|
|
1374
|
+
}, [listParams, reloadToken, t])
|
|
1375
|
+
|
|
1376
|
+
const handleDelete = React.useCallback(async (row: NoteRow) => {
|
|
1377
|
+
const confirmed = await confirm({
|
|
1378
|
+
title: t('notes.delete.confirmTitle', 'Delete note?'),
|
|
1379
|
+
description: t('notes.delete.confirmDescription', 'This action cannot be undone.'),
|
|
1380
|
+
variant: 'destructive',
|
|
1381
|
+
})
|
|
1382
|
+
if (!confirmed) return
|
|
1383
|
+
try {
|
|
1384
|
+
// Optimistic locking is ON by default: derive the expected-updated-at
|
|
1385
|
+
// header from the row the user acted on.
|
|
1386
|
+
await runMutation({
|
|
1387
|
+
operation: () =>
|
|
1388
|
+
withScopedApiRequestHeaders(
|
|
1389
|
+
buildOptimisticLockHeader(row.updatedAt ?? undefined),
|
|
1390
|
+
() => deleteCrud('notes', row.id),
|
|
1391
|
+
),
|
|
1392
|
+
context: {
|
|
1393
|
+
formId: 'notes.list',
|
|
1394
|
+
resourceKind: 'notes.note',
|
|
1395
|
+
resourceId: row.id,
|
|
1396
|
+
retryLastMutation,
|
|
1397
|
+
},
|
|
1398
|
+
mutationPayload: { id: row.id },
|
|
1399
|
+
})
|
|
1400
|
+
flash(t('notes.delete.success', 'Note deleted'), 'success')
|
|
1401
|
+
setReloadToken((token) => token + 1)
|
|
1402
|
+
} catch {
|
|
1403
|
+
flash(t('notes.delete.error', 'Failed to delete note'), 'error')
|
|
1404
|
+
}
|
|
1405
|
+
}, [confirm, retryLastMutation, runMutation, t])
|
|
1406
|
+
|
|
1407
|
+
const columns = React.useMemo<ColumnDef<NoteRow>[]>(() => [
|
|
1408
|
+
{ accessorKey: 'title', header: t('notes.fields.title', 'Title') },
|
|
1409
|
+
], [t])
|
|
1410
|
+
|
|
1411
|
+
const exporter = React.useMemo(() => ({
|
|
1412
|
+
getUrl: (format: DataTableExportFormat) => buildCrudExportUrl('notes', { ...listParams, exportScope: 'view' }, format),
|
|
1413
|
+
filename: (format: DataTableExportFormat) => 'notes.' + format,
|
|
1414
|
+
}), [listParams])
|
|
1415
|
+
|
|
1416
|
+
return (
|
|
1417
|
+
<Page>
|
|
1418
|
+
<PageBody>
|
|
1419
|
+
<DataTable<NoteRow>
|
|
1420
|
+
title={t('notes.list.title', 'Notes')}
|
|
1421
|
+
actions={(
|
|
1422
|
+
<Button asChild>
|
|
1423
|
+
<Link href="/backend/notes/create">{t('notes.list.actions.create', 'Create note')}</Link>
|
|
1424
|
+
</Button>
|
|
1425
|
+
)}
|
|
1426
|
+
columns={columns}
|
|
1427
|
+
data={rows}
|
|
1428
|
+
isLoading={isLoading}
|
|
1429
|
+
error={loadError}
|
|
1430
|
+
searchValue={search}
|
|
1431
|
+
onSearchChange={(value) => { setSearch(value); setPage(1) }}
|
|
1432
|
+
searchPlaceholder={t('notes.list.searchPlaceholder', 'Search notes')}
|
|
1433
|
+
exporter={exporter}
|
|
1434
|
+
extensionTableId="notes.list"
|
|
1435
|
+
onRowClick={(row) => router.push('/backend/notes/' + row.id)}
|
|
1436
|
+
rowActions={(row) => (
|
|
1437
|
+
<RowActions
|
|
1438
|
+
items={[
|
|
1439
|
+
{
|
|
1440
|
+
id: 'edit',
|
|
1441
|
+
label: t('notes.list.actions.edit', 'Edit'),
|
|
1442
|
+
onSelect: () => { router.push('/backend/notes/' + row.id) },
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
id: 'delete',
|
|
1446
|
+
label: t('notes.list.actions.delete', 'Delete'),
|
|
1447
|
+
destructive: true,
|
|
1448
|
+
onSelect: () => { void handleDelete(row) },
|
|
1449
|
+
},
|
|
1450
|
+
]}
|
|
1451
|
+
/>
|
|
1452
|
+
)}
|
|
1453
|
+
emptyState={(
|
|
1454
|
+
<EmptyState
|
|
1455
|
+
title={t('notes.list.empty.title', 'No notes yet')}
|
|
1456
|
+
description={t('notes.list.empty.description', 'Create your first note to get started.')}
|
|
1457
|
+
actions={(
|
|
1458
|
+
<Button asChild>
|
|
1459
|
+
<Link href="/backend/notes/create">{t('notes.list.actions.create', 'Create note')}</Link>
|
|
1460
|
+
</Button>
|
|
1461
|
+
)}
|
|
1462
|
+
/>
|
|
1463
|
+
)}
|
|
1464
|
+
pagination={{ page, pageSize: PAGE_SIZE, total, totalPages, totalIsCapped, onPageChange: setPage }}
|
|
1465
|
+
/>
|
|
1466
|
+
</PageBody>
|
|
1467
|
+
{ConfirmDialogElement}
|
|
1468
|
+
</Page>
|
|
1469
|
+
)
|
|
1470
|
+
}
|
|
1471
|
+
"
|
|
1472
|
+
`;
|
|
1473
|
+
|
|
1474
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status components/formConfig.ts 1`] = `
|
|
1475
|
+
"import { z } from 'zod'
|
|
1476
|
+
import type { CrudField, CrudFormGroup } from '@open-mercato/ui/backend/CrudForm'
|
|
1477
|
+
import type { TranslateFn } from '@open-mercato/shared/lib/i18n/context'
|
|
1478
|
+
import { noteCreateSchema } from '../data/validators'
|
|
1479
|
+
|
|
1480
|
+
/** Entity id used to load custom-field sets once the module declares \`ce.ts\`. */
|
|
1481
|
+
export const NOTE_ENTITY_ID = 'notes:note'
|
|
1482
|
+
|
|
1483
|
+
export type NoteFormValues = z.infer<typeof noteCreateSchema>
|
|
1484
|
+
|
|
1485
|
+
export function createNoteFormSchema() {
|
|
1486
|
+
return noteCreateSchema
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
export function createNoteFormFields(t: TranslateFn): CrudField[] {
|
|
1490
|
+
return [
|
|
1491
|
+
{ id: 'title', label: t('notes.fields.title', 'Title'), type: 'text', required: true },
|
|
1492
|
+
{ id: 'body', label: t('notes.fields.body', 'Body'), type: 'textarea' },
|
|
1493
|
+
]
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
export function createNoteFormGroups(t: TranslateFn): CrudFormGroup[] {
|
|
1497
|
+
return [
|
|
1498
|
+
{
|
|
1499
|
+
id: 'details',
|
|
1500
|
+
title: t('notes.form.groups.details', 'Details'),
|
|
1501
|
+
column: 1,
|
|
1502
|
+
fields: ['title', 'body'],
|
|
1503
|
+
},
|
|
1504
|
+
// Custom-field sets registered for NOTE_ENTITY_ID render here.
|
|
1505
|
+
{
|
|
1506
|
+
id: 'attributes',
|
|
1507
|
+
title: t('notes.form.groups.attributes', 'Attributes'),
|
|
1508
|
+
column: 2,
|
|
1509
|
+
kind: 'customFields',
|
|
1510
|
+
},
|
|
1511
|
+
]
|
|
1512
|
+
}
|
|
1513
|
+
"
|
|
1514
|
+
`;
|
|
1515
|
+
|
|
1516
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status data/validators.ts 1`] = `
|
|
1517
|
+
"import { z } from 'zod'
|
|
1518
|
+
|
|
1519
|
+
// Optimistic locking is ON by default for CrudForm edit flows: the note
|
|
1520
|
+
// API responses MUST return \`updatedAt\` and the backing table MUST carry an
|
|
1521
|
+
// \`updated_at\` column so \`initialValues.updatedAt\` can drive the
|
|
1522
|
+
// x-om-ext-optimistic-lock-expected-updated-at header on update and delete.
|
|
1523
|
+
export const noteCreateSchema = z.object({
|
|
1524
|
+
title: z.string().min(1),
|
|
1525
|
+
body: z.string().optional(),
|
|
1526
|
+
})
|
|
1527
|
+
|
|
1528
|
+
export const noteUpdateSchema = noteCreateSchema.extend({
|
|
1529
|
+
id: z.string().uuid(),
|
|
1530
|
+
updatedAt: z.string().optional(),
|
|
1531
|
+
})
|
|
1532
|
+
|
|
1533
|
+
export type NoteCreateInput = z.infer<typeof noteCreateSchema>
|
|
1534
|
+
export type NoteUpdateInput = z.infer<typeof noteUpdateSchema>
|
|
1535
|
+
"
|
|
1536
|
+
`;
|
|
1537
|
+
|
|
1538
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status i18n/de.json 1`] = `
|
|
1539
|
+
"{
|
|
1540
|
+
"notes.create.success": "Note created",
|
|
1541
|
+
"notes.create.title": "Create note",
|
|
1542
|
+
"notes.delete.confirmDescription": "This action cannot be undone.",
|
|
1543
|
+
"notes.delete.confirmTitle": "Delete note?",
|
|
1544
|
+
"notes.delete.error": "Failed to delete note",
|
|
1545
|
+
"notes.delete.success": "Note deleted",
|
|
1546
|
+
"notes.detail.actions.delete": "Delete",
|
|
1547
|
+
"notes.detail.loadError": "Failed to load note",
|
|
1548
|
+
"notes.detail.loading": "Loading note",
|
|
1549
|
+
"notes.detail.notFound": "Note not found",
|
|
1550
|
+
"notes.detail.tabs.label": "Note sections",
|
|
1551
|
+
"notes.detail.tabs.overview": "Overview",
|
|
1552
|
+
"notes.detail.title": "Note details",
|
|
1553
|
+
"notes.detail.updateSuccess": "Note updated",
|
|
1554
|
+
"notes.fields.body": "Body",
|
|
1555
|
+
"notes.fields.title": "Title",
|
|
1556
|
+
"notes.form.groups.attributes": "Attributes",
|
|
1557
|
+
"notes.form.groups.details": "Details",
|
|
1558
|
+
"notes.form.submit": "Save",
|
|
1559
|
+
"notes.list.actions.create": "Create note",
|
|
1560
|
+
"notes.list.actions.delete": "Delete",
|
|
1561
|
+
"notes.list.actions.edit": "Edit",
|
|
1562
|
+
"notes.list.empty.description": "Create your first note to get started.",
|
|
1563
|
+
"notes.list.empty.title": "No notes yet",
|
|
1564
|
+
"notes.list.loadError": "Failed to load notes",
|
|
1565
|
+
"notes.list.searchPlaceholder": "Search notes",
|
|
1566
|
+
"notes.list.title": "Notes",
|
|
1567
|
+
"notes.nav.group": "Notes",
|
|
1568
|
+
"notes.nav.title": "Notes"
|
|
1569
|
+
}
|
|
1570
|
+
"
|
|
1571
|
+
`;
|
|
1572
|
+
|
|
1573
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status i18n/en.json 1`] = `
|
|
1574
|
+
"{
|
|
1575
|
+
"notes.create.success": "Note created",
|
|
1576
|
+
"notes.create.title": "Create note",
|
|
1577
|
+
"notes.delete.confirmDescription": "This action cannot be undone.",
|
|
1578
|
+
"notes.delete.confirmTitle": "Delete note?",
|
|
1579
|
+
"notes.delete.error": "Failed to delete note",
|
|
1580
|
+
"notes.delete.success": "Note deleted",
|
|
1581
|
+
"notes.detail.actions.delete": "Delete",
|
|
1582
|
+
"notes.detail.loadError": "Failed to load note",
|
|
1583
|
+
"notes.detail.loading": "Loading note",
|
|
1584
|
+
"notes.detail.notFound": "Note not found",
|
|
1585
|
+
"notes.detail.tabs.label": "Note sections",
|
|
1586
|
+
"notes.detail.tabs.overview": "Overview",
|
|
1587
|
+
"notes.detail.title": "Note details",
|
|
1588
|
+
"notes.detail.updateSuccess": "Note updated",
|
|
1589
|
+
"notes.fields.body": "Body",
|
|
1590
|
+
"notes.fields.title": "Title",
|
|
1591
|
+
"notes.form.groups.attributes": "Attributes",
|
|
1592
|
+
"notes.form.groups.details": "Details",
|
|
1593
|
+
"notes.form.submit": "Save",
|
|
1594
|
+
"notes.list.actions.create": "Create note",
|
|
1595
|
+
"notes.list.actions.delete": "Delete",
|
|
1596
|
+
"notes.list.actions.edit": "Edit",
|
|
1597
|
+
"notes.list.empty.description": "Create your first note to get started.",
|
|
1598
|
+
"notes.list.empty.title": "No notes yet",
|
|
1599
|
+
"notes.list.loadError": "Failed to load notes",
|
|
1600
|
+
"notes.list.searchPlaceholder": "Search notes",
|
|
1601
|
+
"notes.list.title": "Notes",
|
|
1602
|
+
"notes.nav.group": "Notes",
|
|
1603
|
+
"notes.nav.title": "Notes"
|
|
1604
|
+
}
|
|
1605
|
+
"
|
|
1606
|
+
`;
|
|
1607
|
+
|
|
1608
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status i18n/es.json 1`] = `
|
|
1609
|
+
"{
|
|
1610
|
+
"notes.create.success": "Note created",
|
|
1611
|
+
"notes.create.title": "Create note",
|
|
1612
|
+
"notes.delete.confirmDescription": "This action cannot be undone.",
|
|
1613
|
+
"notes.delete.confirmTitle": "Delete note?",
|
|
1614
|
+
"notes.delete.error": "Failed to delete note",
|
|
1615
|
+
"notes.delete.success": "Note deleted",
|
|
1616
|
+
"notes.detail.actions.delete": "Delete",
|
|
1617
|
+
"notes.detail.loadError": "Failed to load note",
|
|
1618
|
+
"notes.detail.loading": "Loading note",
|
|
1619
|
+
"notes.detail.notFound": "Note not found",
|
|
1620
|
+
"notes.detail.tabs.label": "Note sections",
|
|
1621
|
+
"notes.detail.tabs.overview": "Overview",
|
|
1622
|
+
"notes.detail.title": "Note details",
|
|
1623
|
+
"notes.detail.updateSuccess": "Note updated",
|
|
1624
|
+
"notes.fields.body": "Body",
|
|
1625
|
+
"notes.fields.title": "Title",
|
|
1626
|
+
"notes.form.groups.attributes": "Attributes",
|
|
1627
|
+
"notes.form.groups.details": "Details",
|
|
1628
|
+
"notes.form.submit": "Save",
|
|
1629
|
+
"notes.list.actions.create": "Create note",
|
|
1630
|
+
"notes.list.actions.delete": "Delete",
|
|
1631
|
+
"notes.list.actions.edit": "Edit",
|
|
1632
|
+
"notes.list.empty.description": "Create your first note to get started.",
|
|
1633
|
+
"notes.list.empty.title": "No notes yet",
|
|
1634
|
+
"notes.list.loadError": "Failed to load notes",
|
|
1635
|
+
"notes.list.searchPlaceholder": "Search notes",
|
|
1636
|
+
"notes.list.title": "Notes",
|
|
1637
|
+
"notes.nav.group": "Notes",
|
|
1638
|
+
"notes.nav.title": "Notes"
|
|
1639
|
+
}
|
|
1640
|
+
"
|
|
1641
|
+
`;
|
|
1642
|
+
|
|
1643
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status i18n/ko.json 1`] = `
|
|
1644
|
+
"{
|
|
1645
|
+
"notes.create.success": "Note created",
|
|
1646
|
+
"notes.create.title": "Create note",
|
|
1647
|
+
"notes.delete.confirmDescription": "This action cannot be undone.",
|
|
1648
|
+
"notes.delete.confirmTitle": "Delete note?",
|
|
1649
|
+
"notes.delete.error": "Failed to delete note",
|
|
1650
|
+
"notes.delete.success": "Note deleted",
|
|
1651
|
+
"notes.detail.actions.delete": "Delete",
|
|
1652
|
+
"notes.detail.loadError": "Failed to load note",
|
|
1653
|
+
"notes.detail.loading": "Loading note",
|
|
1654
|
+
"notes.detail.notFound": "Note not found",
|
|
1655
|
+
"notes.detail.tabs.label": "Note sections",
|
|
1656
|
+
"notes.detail.tabs.overview": "Overview",
|
|
1657
|
+
"notes.detail.title": "Note details",
|
|
1658
|
+
"notes.detail.updateSuccess": "Note updated",
|
|
1659
|
+
"notes.fields.body": "Body",
|
|
1660
|
+
"notes.fields.title": "Title",
|
|
1661
|
+
"notes.form.groups.attributes": "Attributes",
|
|
1662
|
+
"notes.form.groups.details": "Details",
|
|
1663
|
+
"notes.form.submit": "Save",
|
|
1664
|
+
"notes.list.actions.create": "Create note",
|
|
1665
|
+
"notes.list.actions.delete": "Delete",
|
|
1666
|
+
"notes.list.actions.edit": "Edit",
|
|
1667
|
+
"notes.list.empty.description": "Create your first note to get started.",
|
|
1668
|
+
"notes.list.empty.title": "No notes yet",
|
|
1669
|
+
"notes.list.loadError": "Failed to load notes",
|
|
1670
|
+
"notes.list.searchPlaceholder": "Search notes",
|
|
1671
|
+
"notes.list.title": "Notes",
|
|
1672
|
+
"notes.nav.group": "Notes",
|
|
1673
|
+
"notes.nav.title": "Notes"
|
|
1674
|
+
}
|
|
1675
|
+
"
|
|
1676
|
+
`;
|
|
1677
|
+
|
|
1678
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status i18n/pl.json 1`] = `
|
|
1679
|
+
"{
|
|
1680
|
+
"notes.create.success": "Note created",
|
|
1681
|
+
"notes.create.title": "Create note",
|
|
1682
|
+
"notes.delete.confirmDescription": "This action cannot be undone.",
|
|
1683
|
+
"notes.delete.confirmTitle": "Delete note?",
|
|
1684
|
+
"notes.delete.error": "Failed to delete note",
|
|
1685
|
+
"notes.delete.success": "Note deleted",
|
|
1686
|
+
"notes.detail.actions.delete": "Delete",
|
|
1687
|
+
"notes.detail.loadError": "Failed to load note",
|
|
1688
|
+
"notes.detail.loading": "Loading note",
|
|
1689
|
+
"notes.detail.notFound": "Note not found",
|
|
1690
|
+
"notes.detail.tabs.label": "Note sections",
|
|
1691
|
+
"notes.detail.tabs.overview": "Overview",
|
|
1692
|
+
"notes.detail.title": "Note details",
|
|
1693
|
+
"notes.detail.updateSuccess": "Note updated",
|
|
1694
|
+
"notes.fields.body": "Body",
|
|
1695
|
+
"notes.fields.title": "Title",
|
|
1696
|
+
"notes.form.groups.attributes": "Attributes",
|
|
1697
|
+
"notes.form.groups.details": "Details",
|
|
1698
|
+
"notes.form.submit": "Save",
|
|
1699
|
+
"notes.list.actions.create": "Create note",
|
|
1700
|
+
"notes.list.actions.delete": "Delete",
|
|
1701
|
+
"notes.list.actions.edit": "Edit",
|
|
1702
|
+
"notes.list.empty.description": "Create your first note to get started.",
|
|
1703
|
+
"notes.list.empty.title": "No notes yet",
|
|
1704
|
+
"notes.list.loadError": "Failed to load notes",
|
|
1705
|
+
"notes.list.searchPlaceholder": "Search notes",
|
|
1706
|
+
"notes.list.title": "Notes",
|
|
1707
|
+
"notes.nav.group": "Notes",
|
|
1708
|
+
"notes.nav.title": "Notes"
|
|
1709
|
+
}
|
|
1710
|
+
"
|
|
1711
|
+
`;
|
|
1712
|
+
|
|
1713
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status index.ts 1`] = `
|
|
1714
|
+
"import type { ModuleInfo } from '@open-mercato/shared/modules/registry'
|
|
1715
|
+
|
|
1716
|
+
export const metadata: ModuleInfo = {
|
|
1717
|
+
name: 'notes',
|
|
1718
|
+
title: 'Notes',
|
|
1719
|
+
version: '0.1.0',
|
|
1720
|
+
description: 'Notes module scaffolded with mercato module scaffold.',
|
|
1721
|
+
author: 'Open Mercato Team',
|
|
1722
|
+
license: 'MIT',
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
export { features } from './acl'
|
|
1726
|
+
"
|
|
1727
|
+
`;
|
|
1728
|
+
|
|
1729
|
+
exports[`scaffold golden files omits statusMap and StatusBadge when no select field is named status: no-status setup.ts 1`] = `
|
|
1730
|
+
"import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
|
|
1731
|
+
|
|
1732
|
+
export const setup: ModuleSetupConfig = {
|
|
1733
|
+
defaultRoleFeatures: {
|
|
1734
|
+
superadmin: ['notes.*'],
|
|
1735
|
+
admin: ['notes.*'],
|
|
1736
|
+
employee: ['notes.view'],
|
|
1737
|
+
},
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
export default setup
|
|
1741
|
+
"
|
|
1742
|
+
`;
|