@final-commerce/command-frame 0.1.72 → 0.1.74
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/README.md +50 -28
- package/dist/CommonTypes.d.ts +143 -7
- package/dist/CommonTypes.js +112 -0
- package/dist/actions/apply-transition/action.d.ts +2 -0
- package/dist/actions/apply-transition/action.js +4 -0
- package/dist/actions/apply-transition/mock.d.ts +6 -0
- package/dist/actions/apply-transition/mock.js +33 -0
- package/dist/actions/apply-transition/types.d.ts +17 -0
- package/dist/actions/apply-transition/types.js +1 -0
- package/dist/actions/can-transition/action.d.ts +2 -0
- package/dist/actions/can-transition/action.js +4 -0
- package/dist/actions/can-transition/mock.d.ts +6 -0
- package/dist/actions/can-transition/mock.js +28 -0
- package/dist/actions/can-transition/types.d.ts +11 -0
- package/dist/actions/can-transition/types.js +1 -0
- package/dist/actions/cash-payment/types.d.ts +5 -0
- package/dist/actions/delete-parked-order/types.d.ts +3 -0
- package/dist/actions/extension-payment/types.d.ts +5 -0
- package/dist/actions/get-available-transitions/action.d.ts +2 -0
- package/dist/actions/get-available-transitions/action.js +4 -0
- package/dist/actions/get-available-transitions/mock.d.ts +6 -0
- package/dist/actions/get-available-transitions/mock.js +26 -0
- package/dist/actions/get-available-transitions/types.d.ts +9 -0
- package/dist/actions/get-available-transitions/types.js +1 -0
- package/dist/actions/get-smart-grid-layout/action.d.ts +2 -0
- package/dist/actions/get-smart-grid-layout/action.js +4 -0
- package/dist/actions/get-smart-grid-layout/mock.d.ts +2 -0
- package/dist/actions/get-smart-grid-layout/mock.js +9 -0
- package/dist/actions/get-smart-grid-layout/types.d.ts +10 -0
- package/dist/actions/get-smart-grid-layout/types.js +1 -0
- package/dist/actions/initiate-refund/types.d.ts +3 -0
- package/dist/actions/open-extension-overlay/mock.d.ts +2 -0
- package/dist/actions/open-extension-overlay/mock.js +1 -0
- package/dist/actions/open-extension-overlay/types.d.ts +9 -0
- package/dist/actions/open-extension-overlay/types.js +1 -0
- package/dist/actions/park-order/types.d.ts +3 -0
- package/dist/actions/partial-payment/types.d.ts +5 -0
- package/dist/actions/process-partial-refund/types.d.ts +3 -0
- package/dist/actions/remove-product-from-cart/mock.js +5 -5
- package/dist/actions/resolve-extension-overlay/mock.d.ts +2 -0
- package/dist/actions/resolve-extension-overlay/mock.js +1 -0
- package/dist/actions/resolve-extension-overlay/types.d.ts +9 -0
- package/dist/actions/resolve-extension-overlay/types.js +1 -0
- package/dist/actions/resume-parked-order/types.d.ts +3 -0
- package/dist/actions/save-smart-grid-layout/action.d.ts +2 -0
- package/dist/actions/save-smart-grid-layout/action.js +4 -0
- package/dist/actions/save-smart-grid-layout/mock.d.ts +2 -0
- package/dist/actions/save-smart-grid-layout/mock.js +10 -0
- package/dist/actions/save-smart-grid-layout/types.d.ts +10 -0
- package/dist/actions/save-smart-grid-layout/types.js +1 -0
- package/dist/actions/tap-to-pay-payment/types.d.ts +5 -0
- package/dist/actions/terminal-payment/types.d.ts +5 -0
- package/dist/actions/update-cart-item-quantity/mock.js +9 -9
- package/dist/actions/vendara-payment/types.d.ts +5 -0
- package/dist/common-types/index.d.ts +1 -0
- package/dist/common-types/index.js +1 -0
- package/dist/common-types/order-state.d.ts +32 -0
- package/dist/common-types/order-state.js +6 -0
- package/dist/common-types/state-fragment.d.ts +77 -0
- package/dist/common-types/state-fragment.js +10 -0
- package/dist/demo/database.d.ts +2 -1
- package/dist/demo/database.js +13 -0
- package/dist/fragments/index.d.ts +1 -0
- package/dist/fragments/index.js +1 -0
- package/dist/fragments/preorder-no-deposit.d.ts +26 -0
- package/dist/fragments/preorder-no-deposit.js +166 -0
- package/dist/index.d.ts +18 -4
- package/dist/index.js +19 -3
- package/dist/interceptors/index.d.ts +21 -0
- package/dist/interceptors/index.js +53 -0
- package/dist/interceptors/types.d.ts +26 -0
- package/dist/interceptors/types.js +1 -0
- package/dist/projects/render/mocks.js +13 -1
- package/dist/projects/render/types.d.ts +9 -1
- package/dist/pubsub/topics/orders/index.js +10 -0
- package/dist/pubsub/topics/orders/state-transition-blocked/types.d.ts +16 -0
- package/dist/pubsub/topics/orders/state-transition-blocked/types.js +1 -0
- package/dist/pubsub/topics/orders/state-transition-completed/types.d.ts +15 -0
- package/dist/pubsub/topics/orders/state-transition-completed/types.js +1 -0
- package/dist/pubsub/topics/orders/types.d.ts +6 -2
- package/dist/pubsub/topics/orders/types.js +2 -0
- package/package.json +1 -1
- package/dist/actions/extension-refund/constants.d.ts +0 -2
- package/dist/actions/extension-refund/constants.js +0 -2
- package/dist/actions/extension-refund/extension-refund-listener.d.ts +0 -11
- package/dist/actions/extension-refund/extension-refund-listener.js +0 -60
- package/dist/actions/extension-refund/types.d.ts +0 -32
- package/dist/actions/extension-refund/types.js +0 -5
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { EXTENSION_REFUND_REQUEST_ACTION } from "./constants";
|
|
2
|
-
function isRecord(value) {
|
|
3
|
-
return typeof value === "object" && value !== null;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Install a message listener in the **extension iframe** so the host can request refunds.
|
|
7
|
-
* Validates `event.source === window.top` before handling.
|
|
8
|
-
*
|
|
9
|
-
* Replies with {@link PostMessageResponse}, using `event.origin` as the target origin when posting back to the host.
|
|
10
|
-
*
|
|
11
|
-
* @param handler - Perform the extension-side refund (API call, etc.)
|
|
12
|
-
* @returns Unsubscribe function
|
|
13
|
-
*/
|
|
14
|
-
export function installExtensionRefundListener(handler) {
|
|
15
|
-
const onMessage = async (event) => {
|
|
16
|
-
const raw = event.data;
|
|
17
|
-
if (!isRecord(raw) || raw.action !== EXTENSION_REFUND_REQUEST_ACTION) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const requestId = raw.requestId;
|
|
21
|
-
if (typeof requestId !== "string") {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (event.source !== window.top || !event.source) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const source = event.source;
|
|
28
|
-
const replyOrigin = typeof event.origin === "string" ? event.origin : "*";
|
|
29
|
-
const params = raw.params;
|
|
30
|
-
try {
|
|
31
|
-
if (!params || typeof params.paymentType !== "string" || typeof params.amount !== "number" || typeof params.saleId !== "string") {
|
|
32
|
-
const errPayload = {
|
|
33
|
-
requestId,
|
|
34
|
-
success: false,
|
|
35
|
-
error: "Invalid extension refund params"
|
|
36
|
-
};
|
|
37
|
-
source.postMessage(errPayload, replyOrigin);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const result = await handler(params);
|
|
41
|
-
const payload = {
|
|
42
|
-
requestId,
|
|
43
|
-
success: true,
|
|
44
|
-
data: result
|
|
45
|
-
};
|
|
46
|
-
source.postMessage(payload, replyOrigin);
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
50
|
-
const errPayload = {
|
|
51
|
-
requestId,
|
|
52
|
-
success: false,
|
|
53
|
-
error: message
|
|
54
|
-
};
|
|
55
|
-
source.postMessage(errPayload, replyOrigin);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
window.addEventListener("message", onMessage);
|
|
59
|
-
return () => window.removeEventListener("message", onMessage);
|
|
60
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host-initiated refund request for extension-controlled payments (e.g. redeem / gift card).
|
|
3
|
-
* The host (Render) postMessages the iframe; the extension performs the provider refund and replies.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Parameters sent from host to extension for a refund.
|
|
7
|
-
*
|
|
8
|
-
* **`amount` uses major currency units** (e.g. dollars), consistent with the string amount
|
|
9
|
-
* passed through `sendRefundPaymentRequest` in Render (parsed with `parseFloat` / `+amount`).
|
|
10
|
-
*/
|
|
11
|
-
export interface ExtensionRefundParams {
|
|
12
|
-
/** e.g. `"redeem"` — matches order paymentMethods[].paymentType */
|
|
13
|
-
paymentType: string;
|
|
14
|
-
processor?: string;
|
|
15
|
-
/** Major currency units (same as refund flow amount string, not cents). */
|
|
16
|
-
amount: number;
|
|
17
|
-
/** Local sale transaction id (Mongo-style id from paymentMethods[].transactionId). */
|
|
18
|
-
saleId: string;
|
|
19
|
-
orderId?: string;
|
|
20
|
-
referenceId?: string;
|
|
21
|
-
metadata?: Record<string, unknown>;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Business result from the extension after attempting the refund.
|
|
25
|
-
* Transport success/failure uses {@link import("../../client").PostMessageResponse}.
|
|
26
|
-
*/
|
|
27
|
-
export interface ExtensionRefundResponse {
|
|
28
|
-
success: boolean;
|
|
29
|
-
error?: string;
|
|
30
|
-
/** Provider/extension reference for the refund transaction, stored in local DB paymentData when present. */
|
|
31
|
-
extensionTransactionId?: string;
|
|
32
|
-
}
|