create-mercato-app 0.7.1-develop.7136.1.0f76137a1d → 0.7.1-develop.7148.1.3076e5ccf7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/agentic/shared/ai/review-checklist.md +1 -0
  2. package/agentic/shared/ai/skills/om-data-model-design/references/migration-workflow.md +30 -2
  3. package/dist/agentic/guides/module-facts.json +128 -128
  4. package/dist/agentic/guides/module-facts.v2.json +128 -128
  5. package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
  6. package/dist/agentic/guides/modules/api_docs/index.md +1 -1
  7. package/dist/agentic/guides/modules/api_keys/index.md +1 -1
  8. package/dist/agentic/guides/modules/attachments/index.md +1 -1
  9. package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
  10. package/dist/agentic/guides/modules/auth/index.md +1 -1
  11. package/dist/agentic/guides/modules/business_rules/index.md +1 -1
  12. package/dist/agentic/guides/modules/catalog/index.md +1 -1
  13. package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
  14. package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
  15. package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
  16. package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
  17. package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
  18. package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
  19. package/dist/agentic/guides/modules/checkout/index.md +1 -1
  20. package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
  21. package/dist/agentic/guides/modules/configs/index.md +1 -1
  22. package/dist/agentic/guides/modules/content/index.md +1 -1
  23. package/dist/agentic/guides/modules/currencies/index.md +1 -1
  24. package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
  25. package/dist/agentic/guides/modules/customers/index.md +1 -1
  26. package/dist/agentic/guides/modules/dashboards/index.md +1 -1
  27. package/dist/agentic/guides/modules/data_sync/index.md +1 -1
  28. package/dist/agentic/guides/modules/design_system/index.md +1 -1
  29. package/dist/agentic/guides/modules/devices/index.md +1 -1
  30. package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
  31. package/dist/agentic/guides/modules/directory/index.md +1 -1
  32. package/dist/agentic/guides/modules/documents/index.md +1 -1
  33. package/dist/agentic/guides/modules/entities/index.md +1 -1
  34. package/dist/agentic/guides/modules/eudr/index.md +1 -1
  35. package/dist/agentic/guides/modules/events/index.md +1 -1
  36. package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
  37. package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
  38. package/dist/agentic/guides/modules/generators/index.md +1 -1
  39. package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
  40. package/dist/agentic/guides/modules/integrations/index.md +1 -1
  41. package/dist/agentic/guides/modules/messages/index.md +1 -1
  42. package/dist/agentic/guides/modules/notifications/index.md +1 -1
  43. package/dist/agentic/guides/modules/onboarding/index.md +1 -1
  44. package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
  45. package/dist/agentic/guides/modules/perspectives/index.md +1 -1
  46. package/dist/agentic/guides/modules/planner/index.md +1 -1
  47. package/dist/agentic/guides/modules/portal/index.md +1 -1
  48. package/dist/agentic/guides/modules/progress/index.md +1 -1
  49. package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
  50. package/dist/agentic/guides/modules/query_index/index.md +1 -1
  51. package/dist/agentic/guides/modules/record_locks/index.md +1 -1
  52. package/dist/agentic/guides/modules/resources/index.md +1 -1
  53. package/dist/agentic/guides/modules/sales/index.md +1 -1
  54. package/dist/agentic/guides/modules/scheduler/index.md +1 -1
  55. package/dist/agentic/guides/modules/search/index.md +1 -1
  56. package/dist/agentic/guides/modules/security/index.md +1 -1
  57. package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
  58. package/dist/agentic/guides/modules/sso/index.md +1 -1
  59. package/dist/agentic/guides/modules/staff/index.md +1 -1
  60. package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
  61. package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
  62. package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
  63. package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
  64. package/dist/agentic/guides/modules/translations/index.md +1 -1
  65. package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
  66. package/dist/agentic/guides/modules/webhooks/index.md +1 -1
  67. package/dist/agentic/guides/modules/wms/index.md +1 -1
  68. package/dist/agentic/guides/modules/workflows/index.md +1 -1
  69. package/dist/agentic/guides/reference-module-facts.json +1 -1
  70. package/dist/agentic/guides/upstream/manifest.json +1 -1
  71. package/dist/agentic/shared/ai/review-checklist.md +1 -0
  72. package/dist/agentic/shared/ai/skills/om-data-model-design/references/migration-workflow.md +30 -2
  73. package/dist/index.js +11 -2
  74. package/package.json +3 -3
  75. package/template/.env.example +15 -0
  76. package/template/src/components/ClientBootstrap.tsx +98 -2
  77. package/template/src/components/__tests__/ClientBootstrap.moduleOverrides.test.ts +147 -0
@@ -12,6 +12,7 @@ Apply this checklist in addition to the installed `om-code-review` checklist whe
12
12
  ## Data, commands, API, and safety
13
13
 
14
14
  - Editable scoped entities use UUIDs, snake_case storage, tenant/org and standard timestamp/soft-delete columns, plus `updated_at`; migrations and the module snapshot contain only intended changes, and `yarn db:generate` is rerun as a no-op probe without applying migrations.
15
+ - A migration that rewrites stored values (backfill, rename, normalization) on an entity whose CRUD route declares `indexer: { entityType }` exports `queryIndexReindexEntityTypes` via `declareQueryIndexReindex([...])`. Raw SQL bypasses the indexer helpers, so without the declaration `entity_indexes.doc` and its `search_tokens` rows keep the pre-migration value permanently, with no failing job to signal it.
15
16
  - Input validators cover every query/body trust boundary. Public request/OpenAPI schemas never accept or require runtime `tenantId`/`organizationId`; handlers derive scope from trusted context and ignore same-named payload fields. Anonymous public business intake uses an explicit trusted tenant+organization binding; missing, partial, or ambiguous binding fails closed, and no path selects or persists the first/oldest active tenant or organization. API routes use per-method auth/feature metadata, `makeCrudRoute`, scoped ORM keys, a separate `openApi` export, stable response keys including `updatedAt`, and `indexer: { entityType }` where searchable.
16
17
  - Domain writes go through commands. Each declared create/update/delete/action command independently reaches its required guard, merges the guard result's `modifiedPayload` into the validated input and revalidates it before command dispatch, and reaches its lock/transaction and undo seams; helper vocabulary elsewhere in the module is not evidence for that command. Custom actions prove the complete optimistic-lock path together: the client sends that record's version, the server enforces it, and the client surfaces the 409 conflict with a real retry path. Multi-phase entity/relation/custom-field changes use `withAtomicFlush(..., { transaction: true })` on one EntityManager; command actions keep events, cache invalidation, indexing, queues, and external effects after commit.
17
18
  - Availability/uniqueness decisions that race use a database constraint, lock, compare-and-swap, or one atomic claim seam; never a read/check followed by an unguarded create. Idempotency queries and database uniqueness include tenant+organization for scoped records. Concurrent contenders have one deterministic winner and an idempotent retry returns the original outcome.
@@ -7,9 +7,37 @@ Load this reference whenever entity metadata changes.
7
7
  3. Run `yarn db:generate` as a probe; inspect all SQL and snapshot changes.
8
8
  4. Remove unrelated generator churn. If scoped SQL must be written from known metadata, follow the module's existing migration style and update only its snapshot.
9
9
  5. Verify forward migration semantics, uniqueness/index names, nullable/default/backfill behavior, and safe rollback/compatibility strategy.
10
- 6. Never modify a shipped migration. Add a new one.
11
- 7. Ask before `yarn db:migrate`, greenfield reset, or changing a database target.
10
+ 6. Declare the query-index projections the migration invalidated (see below).
11
+ 7. Never modify a shipped migration. Add a new one.
12
+ 8. Ask before `yarn db:migrate`, greenfield reset, or changing a database target.
12
13
 
13
14
  Normal delivery stops after migration file/snapshot/tests; local applied state is not a PR artifact.
14
15
 
15
16
  Canonical example source — the shape `yarn db:generate` produces and diffs against: [`migrations/Migration20251030150038.ts`](../../../../src/modules/example/migrations/Migration20251030150038.ts), [`migrations/Migration20260226161000_example.ts`](../../../../src/modules/example/migrations/Migration20260226161000_example.ts), and the module-scoped [`migrations/.snapshot-open-mercato.json`](../../../../src/modules/example/migrations/.snapshot-open-mercato.json). Read them for style; never copy a migration into your own module.
17
+
18
+ ## Data migrations MUST declare the projections they invalidate
19
+
20
+ A migration that rewrites the VALUES of a column in raw SQL — a backfill, a rename, a
21
+ normalization — bypasses every CRUD/indexer helper that would emit `query_index.upsert_one`.
22
+ `entity_indexes.doc`, and every `search_tokens` row derived from it, then keeps the
23
+ pre-migration value permanently, with no failing job and no moved `updated_at` to signal it.
24
+ Global search and any `like`/`ilike` list filter routed through the token index then match the
25
+ record by its OLD text and miss its NEW text.
26
+
27
+ A migration cannot emit the refresh itself — it holds no DI container, and the projection must
28
+ only be rebuilt once its own transaction has committed. So it **declares**, and
29
+ `mercato db migrate` discharges the obligation after the run:
30
+
31
+ ```ts
32
+ import { declareQueryIndexReindex } from '@open-mercato/shared/lib/query/migration-reindex'
33
+
34
+ export const queryIndexReindexEntityTypes = declareQueryIndexReindex(['my_module:my_entity'])
35
+ ```
36
+
37
+ - Required whenever the migration changes stored values of a column on an entity whose CRUD route
38
+ sets `indexer: { entityType }`. Pure `ADD COLUMN`/`CREATE TABLE` DDL with no backfill needs nothing.
39
+ - Identifiers are `module:entity` (snake_case, exactly the `indexer.entityType` value). Use the
40
+ helper rather than a bare array literal — it throws on a malformed identifier at import time,
41
+ whereas a hand-written literal is only reported as a warning during `db migrate`.
42
+ - Both originals forward-only? A follow-up migration that carries **only** the declaration and
43
+ executes no SQL is the repair route for installs that already applied the original.