@open-mercato/core 0.6.6-develop.6551.1.1511bfa890 → 0.6.7-develop.6552.1.5208a19369

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 (38) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/modules/workflows/frontend/checkout-demo/page.js +8 -1
  3. package/dist/modules/workflows/frontend/checkout-demo/page.js.map +2 -2
  4. package/dist/modules/workflows/lib/activity-executor.js +1 -1
  5. package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
  6. package/dist/modules/workflows/lib/find-definition.js +18 -2
  7. package/dist/modules/workflows/lib/find-definition.js.map +2 -2
  8. package/dist/modules/workflows/lib/signal-handler.js +3 -2
  9. package/dist/modules/workflows/lib/signal-handler.js.map +2 -2
  10. package/dist/modules/workflows/lib/step-handler.js +4 -8
  11. package/dist/modules/workflows/lib/step-handler.js.map +2 -2
  12. package/dist/modules/workflows/lib/task-handler.js +3 -5
  13. package/dist/modules/workflows/lib/task-handler.js.map +2 -2
  14. package/dist/modules/workflows/lib/timer-handler.js +2 -1
  15. package/dist/modules/workflows/lib/timer-handler.js.map +2 -2
  16. package/dist/modules/workflows/lib/transition-handler.js +5 -13
  17. package/dist/modules/workflows/lib/transition-handler.js.map +2 -2
  18. package/dist/modules/workflows/lib/workflow-executor.js +11 -9
  19. package/dist/modules/workflows/lib/workflow-executor.js.map +2 -2
  20. package/dist/modules/workflows/migrations/Migration20260715120000.js +68 -0
  21. package/dist/modules/workflows/migrations/Migration20260715120000.js.map +7 -0
  22. package/dist/modules/workflows/migrations/Migration20260716120000.js +24 -0
  23. package/dist/modules/workflows/migrations/Migration20260716120000.js.map +7 -0
  24. package/dist/modules/workflows/workflows.js +2 -0
  25. package/dist/modules/workflows/workflows.js.map +2 -2
  26. package/package.json +8 -8
  27. package/src/modules/workflows/frontend/checkout-demo/page.tsx +12 -1
  28. package/src/modules/workflows/lib/activity-executor.ts +22 -2
  29. package/src/modules/workflows/lib/find-definition.ts +53 -1
  30. package/src/modules/workflows/lib/signal-handler.ts +5 -4
  31. package/src/modules/workflows/lib/step-handler.ts +4 -8
  32. package/src/modules/workflows/lib/task-handler.ts +2 -4
  33. package/src/modules/workflows/lib/timer-handler.ts +3 -2
  34. package/src/modules/workflows/lib/transition-handler.ts +5 -13
  35. package/src/modules/workflows/lib/workflow-executor.ts +11 -8
  36. package/src/modules/workflows/migrations/Migration20260715120000.ts +114 -0
  37. package/src/modules/workflows/migrations/Migration20260716120000.ts +57 -0
  38. package/src/modules/workflows/workflows.ts +2 -0
@@ -0,0 +1,57 @@
1
+ import { Migration } from '@mikro-orm/migrations'
2
+
3
+ const CODE_WORKFLOW_ID = 'workflows.checkout-demo'
4
+
5
+ /**
6
+ * Retires the persisted checkout-demo seed rows so runtime resolves the
7
+ * maintained CODE definition instead (issue #4211).
8
+ *
9
+ * Background: `workflows.checkout-demo` is now code-defined
10
+ * (`packages/core/src/modules/workflows/workflows.ts`), and only the code
11
+ * definition forwards the cart's line items + shipping/tax adjustments to
12
+ * `POST /api/sales/orders`. But existing tenants still carry a persisted
13
+ * `workflow_definitions` row from the old seed — originally seeded under ids
14
+ * like `checkout_simple_v1` / names like `Simple Checkout Flow` and later
15
+ * `Checkout with Payment Webhook`, then renamed to `workflows.checkout-demo`
16
+ * by Migration20260428102318. Its `create_order` body never sent `lines`, and
17
+ * because `findWorkflowDefinition` resolves the DB row first, that stale row
18
+ * SHADOWS the code definition — so orders come out with zero line items and
19
+ * $0.00 totals. Patching the persisted body is unreliable: the seed's name and
20
+ * body shape vary across historical versions, so a fingerprint on either misses
21
+ * whole cohorts of tenants (the defect QA hit).
22
+ *
23
+ * Instead, soft-delete the seeded rows. This is body/name-agnostic, so it fixes
24
+ * every historical seed variant:
25
+ * - New instances: `findWorkflowDefinition` filters `deleted_at IS NULL`, so
26
+ * the retired row is skipped and the code definition is used (correct body).
27
+ * - In-flight instances: `findDefinitionForInstance` loads the definition by
28
+ * `id` with no soft-delete filter (WorkflowDefinition has no global filter),
29
+ * so instances that reference the row keep resolving and advancing.
30
+ *
31
+ * Scope is limited to `code_workflow_id IS NULL` rows — user customizations of
32
+ * the code definition set `code_workflow_id` and MUST NOT be retired. The
33
+ * `deleted_at IS NULL` guard makes the migration idempotent.
34
+ */
35
+ export function buildRetireSeededCheckoutDemoSql(): string {
36
+ return `
37
+ update "workflow_definitions" as "wf"
38
+ set "deleted_at" = current_timestamp,
39
+ "updated_at" = current_timestamp
40
+ where "wf"."workflow_id" = '${CODE_WORKFLOW_ID}'
41
+ and "wf"."code_workflow_id" is null
42
+ and "wf"."deleted_at" is null;
43
+ `.trim()
44
+ }
45
+
46
+ export class Migration20260716120000 extends Migration {
47
+ override async up(): Promise<void> {
48
+ this.addSql(buildRetireSeededCheckoutDemoSql())
49
+ }
50
+
51
+ override async down(): Promise<void> {
52
+ // Forward-only. Restoring `deleted_at = null` would re-shadow the maintained
53
+ // code definition with the stale seed body and re-introduce zero-line orders
54
+ // (#4211). The code definition supersedes the seed, so there is nothing to
55
+ // restore.
56
+ }
57
+ }
@@ -239,6 +239,8 @@ const checkoutDemo = defineWorkflow({
239
239
  customerEntityId: '{{context.customer.id}}',
240
240
  currencyCode: '{{context.cart.currency}}',
241
241
  placedAt: '{{now}}',
242
+ lines: '{{context.cart.orderLines}}',
243
+ adjustments: '{{context.cart.orderAdjustments}}',
242
244
  grandTotalGrossAmount: '{{context.cart.total}}',
243
245
  },
244
246
  validateTenantMatch: true,