@final-commerce/command-frame 0.2.0-beta.6 → 0.3.0-beta.3

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 (100) hide show
  1. package/README.md +28 -26
  2. package/dist/CommonTypes.d.ts +72 -622
  3. package/dist/CommonTypes.js +5 -65
  4. package/dist/actions/add-product/mock.js +1 -1
  5. package/dist/actions/add-product-discount/mock.js +5 -5
  6. package/dist/actions/add-product-fee/mock.js +6 -6
  7. package/dist/actions/cash-payment/types.d.ts +0 -5
  8. package/dist/actions/delete-parked-order/types.d.ts +0 -3
  9. package/dist/actions/edit-product/mock.js +1 -1
  10. package/dist/actions/extension-payment/types.d.ts +4 -5
  11. package/dist/actions/get-products/mock.js +3 -3
  12. package/dist/actions/get-roles/mock.js +35 -41
  13. package/dist/actions/get-smart-grid-layout/action.d.ts +2 -0
  14. package/dist/actions/get-smart-grid-layout/action.js +4 -0
  15. package/dist/actions/get-smart-grid-layout/mock.d.ts +2 -0
  16. package/dist/actions/get-smart-grid-layout/mock.js +7 -0
  17. package/dist/actions/get-smart-grid-layout/types.d.ts +12 -0
  18. package/dist/actions/get-users/mock.js +16 -25
  19. package/dist/actions/initiate-refund/types.d.ts +0 -3
  20. package/dist/actions/integration-payment/action.d.ts +5 -0
  21. package/dist/actions/integration-payment/action.js +7 -0
  22. package/dist/actions/integration-payment/mock.d.ts +2 -0
  23. package/dist/actions/integration-payment/mock.js +4 -0
  24. package/dist/actions/integration-payment/types.d.ts +16 -0
  25. package/dist/actions/open-extension-overlay/action.d.ts +2 -0
  26. package/dist/actions/open-extension-overlay/action.js +4 -0
  27. package/dist/actions/open-extension-overlay/mock.d.ts +2 -0
  28. package/dist/actions/open-extension-overlay/mock.js +1 -0
  29. package/dist/actions/open-extension-overlay/types.d.ts +9 -0
  30. package/dist/actions/park-order/types.d.ts +0 -3
  31. package/dist/actions/partial-payment/types.d.ts +0 -5
  32. package/dist/actions/process-partial-refund/types.d.ts +0 -3
  33. package/dist/actions/resolve-extension-overlay/action.d.ts +2 -0
  34. package/dist/actions/resolve-extension-overlay/action.js +4 -0
  35. package/dist/actions/resolve-extension-overlay/mock.d.ts +2 -0
  36. package/dist/actions/resolve-extension-overlay/mock.js +1 -0
  37. package/dist/actions/resolve-extension-overlay/types.d.ts +9 -0
  38. package/dist/actions/resume-parked-order/mock.js +1 -1
  39. package/dist/actions/resume-parked-order/types.d.ts +0 -3
  40. package/dist/actions/save-smart-grid-layout/action.d.ts +2 -0
  41. package/dist/actions/save-smart-grid-layout/action.js +4 -0
  42. package/dist/actions/save-smart-grid-layout/mock.d.ts +2 -0
  43. package/dist/actions/save-smart-grid-layout/mock.js +7 -0
  44. package/dist/actions/save-smart-grid-layout/types.d.ts +12 -0
  45. package/dist/actions/set-active-product-discount/mock.js +1 -1
  46. package/dist/actions/set-active-product-fee/mock.js +1 -1
  47. package/dist/actions/tap-to-pay-payment/types.d.ts +0 -5
  48. package/dist/actions/terminal-payment/types.d.ts +0 -5
  49. package/dist/actions/vendara-payment/types.d.ts +0 -5
  50. package/dist/common-types/index.d.ts +0 -1
  51. package/dist/common-types/index.js +0 -1
  52. package/dist/demo/database.d.ts +21 -21
  53. package/dist/demo/database.js +27 -27
  54. package/dist/index.d.ts +115 -115
  55. package/dist/index.js +15 -15
  56. package/dist/interceptors/types.d.ts +34 -0
  57. package/dist/interceptors/types.js +1 -0
  58. package/dist/projects/render/mocks.js +10 -8
  59. package/dist/projects/render/types.d.ts +6 -5
  60. package/dist/pubsub/topics/orders/index.js +0 -10
  61. package/dist/pubsub/topics/orders/types.d.ts +2 -6
  62. package/dist/pubsub/topics/orders/types.js +0 -2
  63. package/dist/pubsub/topics/products/product-get-active/types.d.ts +6 -2
  64. package/package.json +15 -12
  65. package/dist/actions/can-transition/action.d.ts +0 -2
  66. package/dist/actions/can-transition/action.js +0 -4
  67. package/dist/actions/can-transition/mock.d.ts +0 -6
  68. package/dist/actions/can-transition/mock.js +0 -28
  69. package/dist/actions/can-transition/types.d.ts +0 -11
  70. package/dist/actions/get-available-transitions/action.d.ts +0 -2
  71. package/dist/actions/get-available-transitions/action.js +0 -4
  72. package/dist/actions/get-available-transitions/mock.d.ts +0 -6
  73. package/dist/actions/get-available-transitions/mock.js +0 -26
  74. package/dist/actions/get-available-transitions/types.d.ts +0 -9
  75. package/dist/actions/trigger-webhook/action.d.ts +0 -6
  76. package/dist/actions/trigger-webhook/action.js +0 -8
  77. package/dist/actions/trigger-webhook/mock.d.ts +0 -2
  78. package/dist/actions/trigger-webhook/mock.js +0 -8
  79. package/dist/actions/trigger-webhook/types.d.ts +0 -21
  80. package/dist/actions/trigger-webhook/types.js +0 -2
  81. package/dist/actions/trigger-zapier-webhook/action.d.ts +0 -6
  82. package/dist/actions/trigger-zapier-webhook/action.js +0 -8
  83. package/dist/actions/trigger-zapier-webhook/mock.d.ts +0 -2
  84. package/dist/actions/trigger-zapier-webhook/mock.js +0 -8
  85. package/dist/actions/trigger-zapier-webhook/types.d.ts +0 -9
  86. package/dist/common-types/order-state.d.ts +0 -32
  87. package/dist/common-types/order-state.js +0 -6
  88. package/dist/common-types/state-fragment.d.ts +0 -77
  89. package/dist/common-types/state-fragment.js +0 -10
  90. package/dist/fragments/index.d.ts +0 -1
  91. package/dist/fragments/index.js +0 -1
  92. package/dist/fragments/preorder-no-deposit.d.ts +0 -26
  93. package/dist/fragments/preorder-no-deposit.js +0 -166
  94. package/dist/pubsub/topics/orders/state-transition-blocked/types.d.ts +0 -16
  95. package/dist/pubsub/topics/orders/state-transition-completed/types.d.ts +0 -15
  96. /package/dist/actions/{can-transition → get-smart-grid-layout}/types.js +0 -0
  97. /package/dist/actions/{get-available-transitions → integration-payment}/types.js +0 -0
  98. /package/dist/actions/{trigger-zapier-webhook → open-extension-overlay}/types.js +0 -0
  99. /package/dist/{pubsub/topics/orders/state-transition-blocked → actions/resolve-extension-overlay}/types.js +0 -0
  100. /package/dist/{pubsub/topics/orders/state-transition-completed → actions/save-smart-grid-layout}/types.js +0 -0
@@ -1,6 +0,0 @@
1
- import type { CanTransitionParams, CanTransitionResponse } from "./types";
2
- /**
3
- * Mock implementation: allows all transitions except a few known-invalid ones
4
- * so the demo app can show both allowed and blocked responses.
5
- */
6
- export declare const canTransitionMock: (params: CanTransitionParams) => Promise<CanTransitionResponse>;
@@ -1,28 +0,0 @@
1
- /**
2
- * Mock implementation: allows all transitions except a few known-invalid ones
3
- * so the demo app can show both allowed and blocked responses.
4
- */
5
- export const canTransitionMock = async (params) => {
6
- const to = params.to;
7
- if (to.payment === "refunded" && to.fulfillment === "draft") {
8
- return {
9
- result: {
10
- allowed: false,
11
- blockedBy: "financial_invariant",
12
- guard: "no-refund-in-draft",
13
- reason: "Cannot refund an order that is still in draft",
14
- },
15
- };
16
- }
17
- if (to.payment === "paid" && to.fulfillment === "cancelled") {
18
- return {
19
- result: {
20
- allowed: false,
21
- blockedBy: "cross_axis_rule",
22
- guard: "no-pay-cancelled",
23
- reason: "Cannot mark a cancelled order as paid",
24
- },
25
- };
26
- }
27
- return { result: { allowed: true } };
28
- };
@@ -1,11 +0,0 @@
1
- import type { CFStatePair, CFTransitionResult } from "../../common-types/order-state";
2
- export interface CanTransitionParams {
3
- /** Order to evaluate. If omitted, evaluates against a new order (from = null). */
4
- orderId?: string;
5
- /** Target state pair to transition to. */
6
- to: CFStatePair;
7
- }
8
- export interface CanTransitionResponse {
9
- result: CFTransitionResult;
10
- }
11
- export type CanTransition = (params: CanTransitionParams) => Promise<CanTransitionResponse>;
@@ -1,2 +0,0 @@
1
- import type { GetAvailableTransitions } from "./types";
2
- export declare const getAvailableTransitions: GetAvailableTransitions;
@@ -1,4 +0,0 @@
1
- import { commandFrameClient } from "../../client";
2
- export const getAvailableTransitions = async (params) => {
3
- return await commandFrameClient.call("getAvailableTransitions", params);
4
- };
@@ -1,6 +0,0 @@
1
- import type { GetAvailableTransitionsParams, GetAvailableTransitionsResponse } from "./types";
2
- /**
3
- * Mock implementation: returns a fixed set of plausible transitions
4
- * so the demo app has data to render.
5
- */
6
- export declare const getAvailableTransitionsMock: (_params: GetAvailableTransitionsParams) => Promise<GetAvailableTransitionsResponse>;
@@ -1,26 +0,0 @@
1
- /**
2
- * Mock implementation: returns a fixed set of plausible transitions
3
- * so the demo app has data to render.
4
- */
5
- export const getAvailableTransitionsMock = async (_params) => ({
6
- transitions: [
7
- {
8
- to: { payment: "refunded", fulfillment: "returned" },
9
- displayLabel: "Full Refund",
10
- conditions: [{ met: true, description: "Order is paid" }],
11
- },
12
- {
13
- to: { payment: "partially_refunded", fulfillment: "partially_returned" },
14
- displayLabel: "Partial Refund",
15
- conditions: [{ met: true, description: "Order is paid" }],
16
- },
17
- {
18
- to: { payment: "voided", fulfillment: "cancelled" },
19
- displayLabel: "Void Order",
20
- conditions: [
21
- { met: true, description: "Order exists" },
22
- { met: false, description: "No payments captured (mock: skipped)" },
23
- ],
24
- },
25
- ],
26
- });
@@ -1,9 +0,0 @@
1
- import type { CFAvailableTransition } from "../../common-types/order-state";
2
- export interface GetAvailableTransitionsParams {
3
- /** Order to evaluate. Required — we need the current state. */
4
- orderId: string;
5
- }
6
- export interface GetAvailableTransitionsResponse {
7
- transitions: CFAvailableTransition[];
8
- }
9
- export type GetAvailableTransitions = (params: GetAvailableTransitionsParams) => Promise<GetAvailableTransitionsResponse>;
@@ -1,6 +0,0 @@
1
- /**
2
- * Trigger webhook action
3
- * Calls the triggerWebhook action on the parent window
4
- */
5
- import type { TriggerWebhook } from "./types";
6
- export declare const triggerWebhook: TriggerWebhook;
@@ -1,8 +0,0 @@
1
- /**
2
- * Trigger webhook action
3
- * Calls the triggerWebhook action on the parent window
4
- */
5
- import { commandFrameClient } from "../../client";
6
- export const triggerWebhook = async (params) => {
7
- return await commandFrameClient.call("triggerWebhook", params);
8
- };
@@ -1,2 +0,0 @@
1
- import { TriggerWebhook } from "./types";
2
- export declare const mockTriggerWebhook: TriggerWebhook;
@@ -1,8 +0,0 @@
1
- export const mockTriggerWebhook = async (params) => {
2
- console.log("[Mock] triggerWebhook called", params);
3
- return {
4
- success: true,
5
- webhookUrl: params?.webhookUrl || "",
6
- timestamp: new Date().toISOString()
7
- };
8
- };
@@ -1,21 +0,0 @@
1
- export type TriggerWebhookPresetType = 'product' | 'cart' | 'order' | 'customer';
2
- export interface TriggerWebhookParams {
3
- webhookUrl: string;
4
- /** Public key for authentication. */
5
- publicKey?: string;
6
- /** Defaults to false. */
7
- presetData?: boolean;
8
- presetType?: TriggerWebhookPresetType;
9
- /** Defaults to false. */
10
- isCustomHook?: boolean;
11
- customHookData?: string;
12
- /** 'json' or 'form-urlencoded'. Defaults to 'json'. */
13
- payloadType?: string;
14
- dynamicDataFields?: unknown[];
15
- }
16
- export interface TriggerWebhookResponse {
17
- success: boolean;
18
- webhookUrl: string;
19
- timestamp: string;
20
- }
21
- export type TriggerWebhook = (params?: TriggerWebhookParams) => Promise<TriggerWebhookResponse>;
@@ -1,2 +0,0 @@
1
- // Trigger Webhook Types
2
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Trigger Zapier webhook action
3
- * Calls the triggerZapierWebhook action on the parent window
4
- */
5
- import type { TriggerZapierWebhook } from "./types";
6
- export declare const triggerZapierWebhook: TriggerZapierWebhook;
@@ -1,8 +0,0 @@
1
- /**
2
- * Trigger Zapier webhook action
3
- * Calls the triggerZapierWebhook action on the parent window
4
- */
5
- import { commandFrameClient } from "../../client";
6
- export const triggerZapierWebhook = async (params) => {
7
- return await commandFrameClient.call("triggerZapierWebhook", params);
8
- };
@@ -1,2 +0,0 @@
1
- import { TriggerZapierWebhook } from "./types";
2
- export declare const mockTriggerZapierWebhook: TriggerZapierWebhook;
@@ -1,8 +0,0 @@
1
- export const mockTriggerZapierWebhook = async (params) => {
2
- console.log("[Mock] triggerZapierWebhook called", params);
3
- return {
4
- success: true,
5
- triggerUrl: params?.triggerUrl || "",
6
- timestamp: new Date().toISOString()
7
- };
8
- };
@@ -1,9 +0,0 @@
1
- export interface TriggerZapierWebhookParams {
2
- triggerUrl: string;
3
- }
4
- export interface TriggerZapierWebhookResponse {
5
- success: boolean;
6
- triggerUrl: string;
7
- timestamp: string;
8
- }
9
- export type TriggerZapierWebhook = (params?: TriggerZapierWebhookParams) => Promise<TriggerZapierWebhookResponse>;
@@ -1,32 +0,0 @@
1
- /**
2
- * State machine protocol types for the command-frame boundary.
3
- * These mirror @final-commerce/common shapes but carry no logic.
4
- * command-frame must NOT depend on common.
5
- */
6
- export interface CFStatePair {
7
- payment: string;
8
- fulfillment: string;
9
- }
10
- export type CFBlockedBy = "financial_invariant" | "cross_axis_rule" | "path" | "condition";
11
- export interface CFTransitionResult {
12
- allowed: boolean;
13
- blockedBy?: CFBlockedBy;
14
- guard?: string;
15
- reason?: string;
16
- failedConditions?: CFFailedCondition[];
17
- }
18
- export interface CFFailedCondition {
19
- field: string;
20
- operator: string;
21
- value: unknown;
22
- reason?: string;
23
- }
24
- export interface CFConditionStatus {
25
- met: boolean;
26
- description: string;
27
- }
28
- export interface CFAvailableTransition {
29
- to: CFStatePair;
30
- displayLabel: string;
31
- conditions: CFConditionStatus[];
32
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * State machine protocol types for the command-frame boundary.
3
- * These mirror @final-commerce/common shapes but carry no logic.
4
- * command-frame must NOT depend on common.
5
- */
6
- export {};
@@ -1,77 +0,0 @@
1
- /**
2
- * State config fragment types for the command-frame boundary.
3
- * These mirror @final-commerce/common's StateConfigFragment shapes but carry no logic.
4
- * command-frame must NOT depend on common.
5
- *
6
- * Extensions pass a CFStateConfigFragment to Render, which merges it into the
7
- * running StoredStateConfig via mergeFragment(). All contributed entries are tagged
8
- * with the extension's id (_sourceExtensionId) so they can be cleaned up on unregister.
9
- */
10
- import type { CFStatePair } from "./order-state";
11
- export type CFConditionOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "notIn" | "isEmpty" | "isNotEmpty";
12
- export interface CFCondition {
13
- /** Dot-path into the OrderContext, e.g. "order.balance" or "computed.totalPaid". */
14
- field: string;
15
- operator: CFConditionOperator;
16
- value: unknown;
17
- }
18
- /** All conditions in a group are AND'd together. */
19
- export interface CFConditionGroup {
20
- conditions: CFCondition[];
21
- }
22
- /** Groups are OR'd — the first passing group satisfies the set. */
23
- export interface CFTransitionConditionSet {
24
- id: string;
25
- label: string;
26
- groups: CFConditionGroup[];
27
- }
28
- export interface CFPaymentTransitionPath {
29
- from: string;
30
- to: string;
31
- /** References a CFTransitionConditionSet.id in the same fragment. */
32
- conditionSetId?: string;
33
- }
34
- export interface CFFulfillmentTransitionPath {
35
- from: string;
36
- to: string;
37
- conditionSetId?: string;
38
- }
39
- export interface CFCrossAxisRule {
40
- id: string;
41
- label: string;
42
- description?: string;
43
- enabled: boolean;
44
- /** Which axis + target state(s) activate this rule. */
45
- trigger: {
46
- axis: "payment" | "fulfillment";
47
- to: string[];
48
- };
49
- /** Which axis + states must be present when the trigger fires. */
50
- requires: {
51
- axis: "payment" | "fulfillment";
52
- states: string[];
53
- };
54
- }
55
- export interface CFDisplayStateRule {
56
- paymentState?: string[];
57
- fulfillmentState?: string[];
58
- label: string;
59
- color?: string;
60
- icon?: string;
61
- }
62
- /**
63
- * Partial config contributed by an extension. Render merges this into the
64
- * running StoredStateConfig. All arrays are appended; display rules replace
65
- * on key collision.
66
- *
67
- * IDs (crossAxisRules, transitionConditions) must be unique across the merged
68
- * config — prefix them with your extension id to avoid collisions.
69
- */
70
- export interface CFStateConfigFragment {
71
- paymentPaths?: CFPaymentTransitionPath[];
72
- fulfillmentPaths?: CFFulfillmentTransitionPath[];
73
- crossAxisRules?: CFCrossAxisRule[];
74
- transitionConditions?: CFTransitionConditionSet[];
75
- validInitialStates?: CFStatePair[];
76
- displayStateMap?: CFDisplayStateRule[];
77
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * State config fragment types for the command-frame boundary.
3
- * These mirror @final-commerce/common's StateConfigFragment shapes but carry no logic.
4
- * command-frame must NOT depend on common.
5
- *
6
- * Extensions pass a CFStateConfigFragment to Render, which merges it into the
7
- * running StoredStateConfig via mergeFragment(). All contributed entries are tagged
8
- * with the extension's id (_sourceExtensionId) so they can be cleaned up on unregister.
9
- */
10
- export {};
@@ -1 +0,0 @@
1
- export { preorderNoDepositFragment } from "./preorder-no-deposit";
@@ -1 +0,0 @@
1
- export { preorderNoDepositFragment } from "./preorder-no-deposit";
@@ -1,26 +0,0 @@
1
- import type { CFStateConfigFragment } from "../common-types/state-fragment";
2
- /**
3
- * Pre-order fragment — no deposit required.
4
- *
5
- * Mirrors preorder-with-deposit but removes the cross-axis rule that gates
6
- * `on_hold` on payment state. An order can be placed on hold while still
7
- * `unpaid` — payment is collected later (pay-at-pickup, BOPIS, COD, etc.).
8
- *
9
- * State flow:
10
- *
11
- * unpaid|on_hold → (cashier collects payment) → paid|on_hold
12
- * ↓
13
- * (progress fulfillment)
14
- * ↓
15
- * paid|in_progress
16
- *
17
- * Key difference from preorder-with-deposit:
18
- * - No cross-axis rule blocking `on_hold` when unpaid. The cashier can
19
- * confirm the pre-order without collecting a deposit first.
20
- * - `unpaid|on_hold` is whitelisted as a valid first-save state pair.
21
- * - `in_progress` still requires at least a partial payment (you must pay
22
- * before the merchant starts fulfilling).
23
- *
24
- * Prefix all IDs with your extension id before merging to avoid collisions.
25
- */
26
- export declare const preorderNoDepositFragment: CFStateConfigFragment;
@@ -1,166 +0,0 @@
1
- /**
2
- * Pre-order fragment — no deposit required.
3
- *
4
- * Mirrors preorder-with-deposit but removes the cross-axis rule that gates
5
- * `on_hold` on payment state. An order can be placed on hold while still
6
- * `unpaid` — payment is collected later (pay-at-pickup, BOPIS, COD, etc.).
7
- *
8
- * State flow:
9
- *
10
- * unpaid|on_hold → (cashier collects payment) → paid|on_hold
11
- * ↓
12
- * (progress fulfillment)
13
- * ↓
14
- * paid|in_progress
15
- *
16
- * Key difference from preorder-with-deposit:
17
- * - No cross-axis rule blocking `on_hold` when unpaid. The cashier can
18
- * confirm the pre-order without collecting a deposit first.
19
- * - `unpaid|on_hold` is whitelisted as a valid first-save state pair.
20
- * - `in_progress` still requires at least a partial payment (you must pay
21
- * before the merchant starts fulfilling).
22
- *
23
- * Prefix all IDs with your extension id before merging to avoid collisions.
24
- */
25
- export const preorderNoDepositFragment = {
26
- paymentPaths: [
27
- {
28
- from: "unpaid",
29
- to: "partially_paid",
30
- conditionSetId: "require-payment-recorded"
31
- },
32
- {
33
- from: "unpaid",
34
- to: "paid",
35
- conditionSetId: "require-full-payment"
36
- },
37
- {
38
- from: "partially_paid",
39
- to: "paid",
40
- conditionSetId: "require-full-payment"
41
- }
42
- ],
43
- fulfillmentPaths: [
44
- {
45
- from: "draft",
46
- to: "on_hold",
47
- conditionSetId: "preorder-no-deposit-require-items"
48
- },
49
- {
50
- from: "on_hold",
51
- to: "cancelled",
52
- conditionSetId: "preorder-no-deposit-cancel-before-progress"
53
- }
54
- ],
55
- transitionConditions: [
56
- {
57
- id: "preorder-no-deposit-require-items",
58
- label: "Require at least one item to place pre-order",
59
- groups: [
60
- {
61
- conditions: [
62
- {
63
- field: "computed.itemCount",
64
- operator: "gte",
65
- value: 1
66
- }
67
- ]
68
- }
69
- ]
70
- },
71
- {
72
- id: "preorder-no-deposit-cancel-before-progress",
73
- label: "Can only cancel pre-order before fulfillment begins",
74
- groups: [
75
- {
76
- conditions: [
77
- {
78
- field: "computed.fulfilledItemCount",
79
- operator: "eq",
80
- value: 0
81
- }
82
- ]
83
- }
84
- ]
85
- },
86
- {
87
- id: "require-payment-recorded",
88
- label: "Require at least one payment before marking partially paid",
89
- groups: [
90
- {
91
- conditions: [
92
- {
93
- field: "computed.totalPaid",
94
- operator: "gt",
95
- value: 0
96
- }
97
- ]
98
- }
99
- ]
100
- },
101
- {
102
- id: "require-full-payment",
103
- label: "Require full payment before marking as paid",
104
- groups: [
105
- {
106
- conditions: [
107
- {
108
- field: "computed.totalPaid",
109
- operator: "gte",
110
- value: 1
111
- },
112
- {
113
- field: "computed.balance",
114
- operator: "lte",
115
- value: 0
116
- }
117
- ]
118
- }
119
- ]
120
- }
121
- ],
122
- crossAxisRules: [
123
- {
124
- id: "preorder-no-deposit-require-payment-before-confirm",
125
- label: "Require payment before starting fulfillment",
126
- description: "Fulfillment cannot move to in_progress unless at least a partial payment has been made",
127
- enabled: true,
128
- trigger: {
129
- axis: "fulfillment",
130
- to: ["in_progress"]
131
- },
132
- requires: {
133
- axis: "payment",
134
- states: ["partially_paid", "paid"]
135
- }
136
- }
137
- ],
138
- validInitialStates: [
139
- { payment: "unpaid", fulfillment: "on_hold" },
140
- { payment: "partially_paid", fulfillment: "on_hold" },
141
- { payment: "paid", fulfillment: "on_hold" }
142
- ],
143
- displayStateMap: [
144
- {
145
- paymentState: ["unpaid"],
146
- fulfillmentState: ["on_hold"],
147
- label: "Pre-Order",
148
- color: "#6366f1",
149
- icon: "clock"
150
- },
151
- {
152
- paymentState: ["partially_paid"],
153
- fulfillmentState: ["on_hold"],
154
- label: "Pre-Order (Deposit Received)",
155
- color: "#f59e0b",
156
- icon: "clock"
157
- },
158
- {
159
- paymentState: ["paid"],
160
- fulfillmentState: ["on_hold"],
161
- label: "Pre-Order (Fully Paid)",
162
- color: "#22c55e",
163
- icon: "check-circle"
164
- }
165
- ]
166
- };
@@ -1,16 +0,0 @@
1
- import type { TopicEvent } from "../../../types";
2
- import type { CFBlockedBy } from "../../../../common-types/order-state";
3
- export interface OrderStateTransitionBlockedPayload {
4
- orderId: string;
5
- from: {
6
- payment: string;
7
- fulfillment: string;
8
- };
9
- to: {
10
- payment: string;
11
- fulfillment: string;
12
- };
13
- blockedBy: CFBlockedBy;
14
- reason?: string;
15
- }
16
- export type OrderStateTransitionBlockedEvent = TopicEvent<OrderStateTransitionBlockedPayload>;
@@ -1,15 +0,0 @@
1
- import type { TopicEvent } from "../../../types";
2
- export interface OrderStateTransitionCompletedPayload {
3
- orderId: string;
4
- from: {
5
- payment: string;
6
- fulfillment: string;
7
- };
8
- to: {
9
- payment: string;
10
- fulfillment: string;
11
- };
12
- displayState: string;
13
- forced?: boolean;
14
- }
15
- export type OrderStateTransitionCompletedEvent = TopicEvent<OrderStateTransitionCompletedPayload>;