@final-commerce/command-frame 0.4.2-preprod.1 → 0.5.0-preprod.10

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 (76) hide show
  1. package/README.md +4 -55
  2. package/dist/CommonTypes.d.ts +1 -1
  3. package/dist/actions/add-product-fee/types.d.ts +1 -2
  4. package/dist/actions/adjust-inventory/mock.js +25 -21
  5. package/dist/actions/adjust-inventory/types.d.ts +1 -1
  6. package/dist/actions/authenticate-user/mock.js +4 -0
  7. package/dist/actions/authenticate-user/types.d.ts +13 -0
  8. package/dist/actions/calculate-refund-total/action.js +2 -2
  9. package/dist/actions/can-transition/types.d.ts +1 -1
  10. package/dist/actions/cash-payment/mock.js +6 -2
  11. package/dist/actions/cash-payment/types.d.ts +11 -7
  12. package/dist/actions/delete-parked-order/types.d.ts +0 -3
  13. package/dist/actions/extension-payment/mock.js +5 -1
  14. package/dist/actions/extension-payment/types.d.ts +10 -5
  15. package/dist/actions/get-custom-table-data/types.d.ts +2 -4
  16. package/dist/actions/get-final-context/mock.js +1 -1
  17. package/dist/actions/get-refund-plan/mock.d.ts +5 -0
  18. package/dist/actions/get-refund-plan/mock.js +24 -0
  19. package/dist/actions/get-refund-plan/types.d.ts +92 -0
  20. package/dist/actions/get-refund-plan/types.js +6 -0
  21. package/dist/actions/get-refunds/types.d.ts +1 -1
  22. package/dist/actions/get-remaining-refundable-quantities/action.js +2 -2
  23. package/dist/actions/get-remaining-refundable-quantities/mock.js +2 -0
  24. package/dist/actions/get-remaining-refundable-quantities/types.d.ts +13 -0
  25. package/dist/actions/initiate-refund/types.d.ts +6 -3
  26. package/dist/actions/integration-payment/types.d.ts +5 -5
  27. package/dist/actions/park-order/types.d.ts +0 -3
  28. package/dist/actions/partial-payment/types.d.ts +0 -5
  29. package/dist/actions/print/mock.js +2 -0
  30. package/dist/actions/print/types.d.ts +7 -0
  31. package/dist/actions/process-partial-refund/mock.d.ts +1 -1
  32. package/dist/actions/process-partial-refund/mock.js +14 -5
  33. package/dist/actions/process-partial-refund/types.d.ts +65 -8
  34. package/dist/actions/redeem-payment/types.d.ts +2 -2
  35. package/dist/actions/remove-product-fee/types.d.ts +10 -1
  36. package/dist/actions/resume-parked-order/types.d.ts +0 -3
  37. package/dist/actions/select-all-refund-items/action.js +2 -2
  38. package/dist/actions/set-active-refund/types.d.ts +1 -1
  39. package/dist/actions/set-refund-stock-action/types.d.ts +1 -1
  40. package/dist/actions/tap-to-pay-payment/mock.js +5 -1
  41. package/dist/actions/tap-to-pay-payment/types.d.ts +15 -7
  42. package/dist/actions/terminal-payment/mock.js +5 -1
  43. package/dist/actions/terminal-payment/types.d.ts +11 -6
  44. package/dist/actions/upsert-custom-table-data/types.d.ts +11 -1
  45. package/dist/actions/void-order/types.d.ts +4 -6
  46. package/dist/index.d.ts +2 -10
  47. package/dist/index.js +0 -6
  48. package/dist/projects/render/mocks.js +0 -6
  49. package/dist/projects/render/types.d.ts +1 -6
  50. package/package.json +1 -1
  51. package/dist/actions/open-extension-overlay/action.d.ts +0 -2
  52. package/dist/actions/open-extension-overlay/action.js +0 -4
  53. package/dist/actions/open-extension-overlay/mock.d.ts +0 -2
  54. package/dist/actions/open-extension-overlay/mock.js +0 -1
  55. package/dist/actions/open-extension-overlay/types.d.ts +0 -9
  56. package/dist/actions/open-extension-overlay/types.js +0 -1
  57. package/dist/actions/resolve-extension-overlay/action.d.ts +0 -2
  58. package/dist/actions/resolve-extension-overlay/action.js +0 -4
  59. package/dist/actions/resolve-extension-overlay/mock.d.ts +0 -2
  60. package/dist/actions/resolve-extension-overlay/mock.js +0 -1
  61. package/dist/actions/resolve-extension-overlay/types.d.ts +0 -9
  62. package/dist/actions/resolve-extension-overlay/types.js +0 -1
  63. package/dist/actions/vendara-payment/action.d.ts +0 -6
  64. package/dist/actions/vendara-payment/action.js +0 -8
  65. package/dist/actions/vendara-payment/mock.d.ts +0 -2
  66. package/dist/actions/vendara-payment/mock.js +0 -11
  67. package/dist/actions/vendara-payment/types.d.ts +0 -26
  68. package/dist/actions/vendara-payment/types.js +0 -1
  69. package/dist/hooks/index.d.ts +0 -17
  70. package/dist/hooks/index.js +0 -39
  71. package/dist/hooks/types.d.ts +0 -15
  72. package/dist/hooks/types.js +0 -1
  73. package/dist/interceptors/index.d.ts +0 -21
  74. package/dist/interceptors/index.js +0 -53
  75. package/dist/interceptors/types.d.ts +0 -26
  76. package/dist/interceptors/types.js +0 -1
@@ -1,9 +0,0 @@
1
- import type { InterceptorPoint, InterceptorReturn } from "../../interceptors/types";
2
- export interface OpenExtensionOverlayParams {
3
- point: InterceptorPoint;
4
- payload?: any;
5
- /** Owning extension id. Injected by the host for interceptor-originated calls; optional for direct calls. */
6
- extensionId?: string;
7
- }
8
- export type OpenExtensionOverlayResponse = InterceptorReturn;
9
- export type OpenExtensionOverlay = (params: OpenExtensionOverlayParams) => Promise<OpenExtensionOverlayResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import type { ResolveExtensionOverlay } from "./types";
2
- export declare const resolveExtensionOverlay: ResolveExtensionOverlay;
@@ -1,4 +0,0 @@
1
- import { commandFrameClient } from "../../client";
2
- export const resolveExtensionOverlay = async (params) => {
3
- return await commandFrameClient.call("resolveExtensionOverlay", params);
4
- };
@@ -1,2 +0,0 @@
1
- import type { ResolveExtensionOverlay } from "./types";
2
- export declare const mockResolveExtensionOverlay: ResolveExtensionOverlay;
@@ -1 +0,0 @@
1
- export const mockResolveExtensionOverlay = async (_params) => ({ success: true });
@@ -1,9 +0,0 @@
1
- import type { InterceptorReturn } from "../../interceptors/types";
2
- export interface ResolveExtensionOverlayParams {
3
- overlayId: string;
4
- result: InterceptorReturn;
5
- }
6
- export interface ResolveExtensionOverlayResponse {
7
- success: boolean;
8
- }
9
- export type ResolveExtensionOverlay = (params: ResolveExtensionOverlayParams) => Promise<ResolveExtensionOverlayResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Vendara payment action
3
- * Calls the vendaraPayment action on the parent window
4
- */
5
- import type { VendaraPayment } from "./types";
6
- export declare const vendaraPayment: VendaraPayment;
@@ -1,8 +0,0 @@
1
- /**
2
- * Vendara payment action
3
- * Calls the vendaraPayment action on the parent window
4
- */
5
- import { commandFrameClient } from "../../client";
6
- export const vendaraPayment = async (params) => {
7
- return await commandFrameClient.call("vendaraPayment", params);
8
- };
@@ -1,2 +0,0 @@
1
- import { VendaraPayment } from "./types";
2
- export declare const mockVendaraPayment: VendaraPayment;
@@ -1,11 +0,0 @@
1
- import { MOCK_ORDERS } from "../../demo/database";
2
- export const mockVendaraPayment = async (params) => {
3
- console.log("[Mock] vendaraPayment called", params);
4
- return {
5
- success: true,
6
- amount: params?.amount || null,
7
- paymentType: "vendara",
8
- order: MOCK_ORDERS[0],
9
- timestamp: new Date().toISOString()
10
- };
11
- };
@@ -1,26 +0,0 @@
1
- import { CFOrder } from "../../CommonTypes";
2
- import type { CFTransitionResult } from "../../common-types/order-state";
3
- export interface VendaraPaymentParams {
4
- /**
5
- * The amount to pay with this tender, in integer MINOR currency units
6
- * (e.g. 1575 = $15.75). Required. Semantics against the cart's balance due:
7
- * - missing → error
8
- * - less than balance → partial payment (the POS enters a fixed
9
- * split-payment leg for this amount)
10
- * - equal to balance → full payment
11
- * - more than balance → error
12
- */
13
- amount: number;
14
- /** Override the fulfillment state after full payment. Render resolves the cascade. */
15
- checkoutFulfillmentTarget?: string;
16
- }
17
- export interface VendaraPaymentResponse {
18
- success: boolean;
19
- amount: number | null;
20
- paymentType: string;
21
- order: CFOrder | null;
22
- timestamp: string;
23
- /** Present when the state machine blocked or forced the transition. */
24
- transitionResult?: CFTransitionResult;
25
- }
26
- export type VendaraPayment = (params?: VendaraPaymentParams) => Promise<VendaraPaymentResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- import type { HookFunction, HookRegisterOptions } from "./types";
2
- /**
3
- * Register a session-scoped hook. The callback is serialized and sent to the host (Render);
4
- * once registered, it runs in the host context even when the extension iframe is not on the current page.
5
- * The callback must be self-contained (only use event, hostCommands, callCommand).
6
- * Uses options.hookId as a stable dedup key: re-registering with the same hookId replaces the previous hook.
7
- */
8
- declare function register(topic: string, callback: HookFunction, options: HookRegisterOptions): string;
9
- /**
10
- * Unregister a hook by ID. Sends a message to the host to remove the hook.
11
- */
12
- declare function unregister(hookId: string): void;
13
- export declare const hooks: {
14
- register: typeof register;
15
- unregister: typeof unregister;
16
- };
17
- export type { HookFunction, HookRegisterOptions } from "./types";
@@ -1,39 +0,0 @@
1
- const DEFAULT_ORIGIN = "*";
2
- function getOrigin() {
3
- return typeof window !== "undefined" ? window.__COMMAND_FRAME_ORIGIN__ ?? DEFAULT_ORIGIN : DEFAULT_ORIGIN;
4
- }
5
- /**
6
- * Register a session-scoped hook. The callback is serialized and sent to the host (Render);
7
- * once registered, it runs in the host context even when the extension iframe is not on the current page.
8
- * The callback must be self-contained (only use event, hostCommands, callCommand).
9
- * Uses options.hookId as a stable dedup key: re-registering with the same hookId replaces the previous hook.
10
- */
11
- function register(topic, callback, options) {
12
- const hookId = options.hookId;
13
- const functionBody = callback.toString();
14
- if (typeof window !== "undefined" && window.top && window.top !== window) {
15
- window.top.postMessage({
16
- type: "hook-register",
17
- topic,
18
- functionBody,
19
- eventTypes: options.eventTypes,
20
- hookId
21
- }, getOrigin());
22
- }
23
- return hookId;
24
- }
25
- /**
26
- * Unregister a hook by ID. Sends a message to the host to remove the hook.
27
- */
28
- function unregister(hookId) {
29
- if (typeof window !== "undefined" && window.top && window.top !== window) {
30
- window.top.postMessage({
31
- type: "hook-unregister",
32
- hookId
33
- }, getOrigin());
34
- }
35
- }
36
- export const hooks = {
37
- register,
38
- unregister
39
- };
@@ -1,15 +0,0 @@
1
- import type { TopicEvent } from "../pubsub/types";
2
- /**
3
- * Function signature for extension hook callbacks.
4
- * The function is serialized and sent to the host; it receives event and hostCommands when executed.
5
- */
6
- export type HookFunction = (event: TopicEvent, hostCommands: Record<string, (params?: any) => Promise<any>>, callCommand: (action: string, params?: any) => Promise<any>) => void | Promise<void>;
7
- /**
8
- * Options when registering a hook from the extension iframe.
9
- */
10
- export interface HookRegisterOptions {
11
- /** Stable identifier for this hook. Used to deduplicate on reload. Must be unique per hook. */
12
- hookId: string;
13
- /** Only fire for these event types; omit to receive all events for the topic */
14
- eventTypes?: string[];
15
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- import type { InterceptorFunction, InterceptorPoint, InterceptorRegisterOptions, InterceptorOverlayContext } from "./types";
2
- /** Register a session-scoped interceptor for a named point. Callback is serialized to the host. */
3
- declare function register(point: InterceptorPoint, callback: InterceptorFunction, options: InterceptorRegisterOptions): string;
4
- declare function unregister(interceptorId: string): void;
5
- /** Register a handler invoked when this iframe is opened as an overlay by the host. */
6
- declare function onOverlay(handler: (ctx: InterceptorOverlayContext) => void): void;
7
- /** Continue the gated flow, merging `data` into the flow payload. */
8
- declare function resolve(data: Record<string, any>): Promise<void>;
9
- /** Continue the gated flow with no data. */
10
- declare function proceed(): Promise<void>;
11
- /** Stop the gated flow. */
12
- declare function cancel(): Promise<void>;
13
- export declare const interceptors: {
14
- register: typeof register;
15
- unregister: typeof unregister;
16
- onOverlay: typeof onOverlay;
17
- resolve: typeof resolve;
18
- proceed: typeof proceed;
19
- cancel: typeof cancel;
20
- };
21
- export type { InterceptorFunction, InterceptorPoint, InterceptorRegisterOptions, InterceptorReturn, InterceptorOverlayContext, InterceptorHostCommands } from "./types";
@@ -1,53 +0,0 @@
1
- import { commandFrameClient } from "../client";
2
- const DEFAULT_ORIGIN = "*";
3
- function getOrigin() {
4
- return typeof window !== "undefined" ? window.__COMMAND_FRAME_ORIGIN__ ?? DEFAULT_ORIGIN : DEFAULT_ORIGIN;
5
- }
6
- let overlayId = null;
7
- let overlayContext = null;
8
- let overlayHandler = null;
9
- if (typeof window !== "undefined") {
10
- window.addEventListener("message", (event) => {
11
- const data = event.data;
12
- if (data && data.type === "interceptor-overlay-init" && typeof data.overlayId === "string") {
13
- overlayId = data.overlayId;
14
- overlayContext = { point: data.point, payload: data.payload };
15
- if (overlayHandler)
16
- overlayHandler(overlayContext);
17
- }
18
- });
19
- }
20
- /** Register a session-scoped interceptor for a named point. Callback is serialized to the host. */
21
- function register(point, callback, options) {
22
- const interceptorId = options.interceptorId;
23
- const functionBody = callback.toString();
24
- if (typeof window !== "undefined" && window.top && window.top !== window) {
25
- window.top.postMessage({ type: "interceptor-register", point, functionBody, interceptorId, timeoutMs: options.timeoutMs }, getOrigin());
26
- }
27
- return interceptorId;
28
- }
29
- function unregister(interceptorId) {
30
- if (typeof window !== "undefined" && window.top && window.top !== window) {
31
- window.top.postMessage({ type: "interceptor-unregister", interceptorId }, getOrigin());
32
- }
33
- }
34
- /** Register a handler invoked when this iframe is opened as an overlay by the host. */
35
- function onOverlay(handler) {
36
- overlayHandler = handler;
37
- if (overlayContext)
38
- handler(overlayContext);
39
- }
40
- async function report(result) {
41
- if (!overlayId) {
42
- console.warn("[interceptors] report called outside an overlay context — ignored");
43
- return;
44
- }
45
- await commandFrameClient.call("resolveExtensionOverlay", { overlayId, result });
46
- }
47
- /** Continue the gated flow, merging `data` into the flow payload. */
48
- function resolve(data) { return report(data); }
49
- /** Continue the gated flow with no data. */
50
- function proceed() { return report(true); }
51
- /** Stop the gated flow. */
52
- function cancel() { return report(false); }
53
- export const interceptors = { register, unregister, onOverlay, resolve, proceed, cancel };
@@ -1,26 +0,0 @@
1
- /**
2
- * Interceptors let an installed extension gate a host flow at a named point.
3
- * Registration mirrors hooks: the callback is serialized and reconstructed on the host,
4
- * so it must be self-contained (use only its payload arg and the injected host commands).
5
- */
6
- export type InterceptorPoint = "refund_start";
7
- /** false = stop the flow; true = continue, no data; object = continue and merge into the flow payload. */
8
- export type InterceptorReturn<T extends Record<string, any> = Record<string, any>> = boolean | T;
9
- export interface InterceptorHostCommands {
10
- openExtensionOverlay: (params: {
11
- point: InterceptorPoint;
12
- payload?: any;
13
- }) => Promise<InterceptorReturn>;
14
- [command: string]: (params?: any) => Promise<any>;
15
- }
16
- export type InterceptorFunction = (payload: any, cmds: InterceptorHostCommands, callCommand: (action: string, params?: any) => Promise<any>) => InterceptorReturn | Promise<InterceptorReturn>;
17
- export interface InterceptorRegisterOptions {
18
- /** Stable id; re-registering with the same id replaces the previous one. */
19
- interceptorId: string;
20
- /** Per-interceptor timeout override (ms). */
21
- timeoutMs?: number;
22
- }
23
- export interface InterceptorOverlayContext {
24
- point: InterceptorPoint;
25
- payload: any;
26
- }
@@ -1 +0,0 @@
1
- export {};