@final-commerce/command-frame 0.14.1-online.1 → 0.14.1-online.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 (55) hide show
  1. package/dist/actions/attach-checkout-contact/types.d.ts +14 -2
  2. package/dist/actions/get-address-details/action.d.ts +6 -0
  3. package/dist/actions/get-address-details/action.js +8 -0
  4. package/dist/actions/get-address-details/mock.d.ts +2 -0
  5. package/dist/actions/get-address-details/mock.js +7 -0
  6. package/dist/actions/get-address-details/types.d.ts +22 -0
  7. package/dist/actions/get-address-details/types.js +3 -0
  8. package/dist/actions/get-checkout-status/types.d.ts +9 -0
  9. package/dist/actions/get-shopper-account/action.d.ts +6 -0
  10. package/dist/actions/get-shopper-account/action.js +8 -0
  11. package/dist/actions/get-shopper-account/mock.d.ts +3 -0
  12. package/dist/actions/get-shopper-account/mock.js +12 -0
  13. package/dist/actions/get-shopper-account/types.d.ts +46 -0
  14. package/dist/actions/get-shopper-account/types.js +6 -0
  15. package/dist/actions/get-shopper-order/action.d.ts +6 -0
  16. package/dist/actions/get-shopper-order/action.js +8 -0
  17. package/dist/actions/get-shopper-order/mock.d.ts +2 -0
  18. package/dist/actions/get-shopper-order/mock.js +24 -0
  19. package/dist/actions/get-shopper-order/types.d.ts +32 -0
  20. package/dist/actions/get-shopper-order/types.js +6 -0
  21. package/dist/actions/get-shopper-orders/action.d.ts +6 -0
  22. package/dist/actions/get-shopper-orders/action.js +8 -0
  23. package/dist/actions/get-shopper-orders/mock.d.ts +2 -0
  24. package/dist/actions/get-shopper-orders/mock.js +18 -0
  25. package/dist/actions/get-shopper-orders/types.d.ts +29 -0
  26. package/dist/actions/get-shopper-orders/types.js +6 -0
  27. package/dist/actions/request-shopper-code/action.d.ts +6 -0
  28. package/dist/actions/request-shopper-code/action.js +8 -0
  29. package/dist/actions/request-shopper-code/mock.d.ts +2 -0
  30. package/dist/actions/request-shopper-code/mock.js +4 -0
  31. package/dist/actions/request-shopper-code/types.d.ts +17 -0
  32. package/dist/actions/request-shopper-code/types.js +6 -0
  33. package/dist/actions/search-addresses/action.d.ts +6 -0
  34. package/dist/actions/search-addresses/action.js +8 -0
  35. package/dist/actions/search-addresses/mock.d.ts +3 -0
  36. package/dist/actions/search-addresses/mock.js +24 -0
  37. package/dist/actions/search-addresses/types.d.ts +31 -0
  38. package/dist/actions/search-addresses/types.js +5 -0
  39. package/dist/actions/sign-in-shopper/action.d.ts +6 -0
  40. package/dist/actions/sign-in-shopper/action.js +8 -0
  41. package/dist/actions/sign-in-shopper/mock.d.ts +2 -0
  42. package/dist/actions/sign-in-shopper/mock.js +7 -0
  43. package/dist/actions/sign-in-shopper/types.d.ts +19 -0
  44. package/dist/actions/sign-in-shopper/types.js +6 -0
  45. package/dist/actions/sign-out-shopper/action.d.ts +6 -0
  46. package/dist/actions/sign-out-shopper/action.js +8 -0
  47. package/dist/actions/sign-out-shopper/mock.d.ts +2 -0
  48. package/dist/actions/sign-out-shopper/mock.js +4 -0
  49. package/dist/actions/sign-out-shopper/types.d.ts +7 -0
  50. package/dist/actions/sign-out-shopper/types.js +6 -0
  51. package/dist/index.d.ts +16 -0
  52. package/dist/index.js +17 -0
  53. package/dist/projects/render/mocks.js +16 -0
  54. package/dist/projects/render/types.d.ts +10 -1
  55. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Guest contact for the order. There is no shopper account, so this is the only
3
- * way to reach them — `email` is where the receipt goes and is required.
2
+ * Contact for the order. `email` is where the receipt goes and is required. The two boxes are the
3
+ * shopper account's (see `getShopperAccount`); a box never stops the payment, whatever happens to it.
4
4
  */
5
5
  export interface AttachCheckoutContactParams {
6
6
  email: string;
@@ -8,6 +8,18 @@ export interface AttachCheckoutContactParams {
8
8
  phone?: string;
9
9
  /** Defaults to the outlet the storefront booted against. */
10
10
  outletId?: string;
11
+ /**
12
+ * The checkout's account box ("Track this order and check out faster next time", from
13
+ * `getShopperAccount`): links this email to a shopper account at this store. Omitted = not ticked.
14
+ */
15
+ accountOptIn?: boolean;
16
+ /** The news box ("Email me news and offers"): this store's consent, true or false. Omitted = not asked. */
17
+ marketingOptIn?: boolean;
18
+ /**
19
+ * The "Save this address" box (signed-in shoppers): once the order is paid, its shipping address is
20
+ * saved to the shopper's account. Omitted = not ticked.
21
+ */
22
+ saveAddress?: boolean;
11
23
  }
12
24
  export interface AttachCheckoutContactResponse {
13
25
  /**
@@ -0,0 +1,6 @@
1
+ /**
2
+ * getAddressDetails action
3
+ * Calls the getAddressDetails action on the parent window
4
+ */
5
+ import type { GetAddressDetails } from './types';
6
+ export declare const getAddressDetails: GetAddressDetails;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * getAddressDetails action
3
+ * Calls the getAddressDetails action on the parent window
4
+ */
5
+ import { commandFrameClient } from '../../client';
6
+ export const getAddressDetails = async (params) => {
7
+ return await commandFrameClient.call('getAddressDetails', params);
8
+ };
@@ -0,0 +1,2 @@
1
+ import type { GetAddressDetails } from './types';
2
+ export declare const mockGetAddressDetails: GetAddressDetails;
@@ -0,0 +1,7 @@
1
+ export const mockGetAddressDetails = async (params) => {
2
+ console.log('[Mock] getAddressDetails called', params);
3
+ return {
4
+ success: true,
5
+ address: { address1: '12 Water St', city: "St. John's", state: 'NL', postCode: 'A1C 1A1', country: 'CA' },
6
+ };
7
+ };
@@ -0,0 +1,22 @@
1
+ /** In the cart's shape: country ISO 3166-1 alpha-2, province or state as its code. */
2
+ export interface AddressDetails {
3
+ address1: string;
4
+ address2?: string;
5
+ city?: string;
6
+ state?: string;
7
+ postCode?: string;
8
+ country: string;
9
+ }
10
+ export interface GetAddressDetailsParams {
11
+ /** A suggestion's `id`, from searchAddresses. */
12
+ id: string;
13
+ language?: string;
14
+ }
15
+ export interface GetAddressDetailsResponse {
16
+ success: boolean;
17
+ /** Ready for setOrderAddress. Add the shopper's name; keep anything they edit afterwards. */
18
+ address?: AddressDetails;
19
+ reason?: string;
20
+ }
21
+ /** The picked suggestion as a full address. Ends the lookup session the searches opened. */
22
+ export type GetAddressDetails = (params: GetAddressDetailsParams) => Promise<GetAddressDetailsResponse>;
@@ -0,0 +1,3 @@
1
+ // The second half of address autocomplete: the suggestion the shopper picked, as a full address.
2
+ // Served ONLY by the storefront runtime. Failures resolve with `success: false`; never throws.
3
+ export {};
@@ -21,6 +21,15 @@ export interface GetCheckoutStatusResponse {
21
21
  */
22
22
  cancelReason?: CheckoutCancelReason;
23
23
  receiptId: string | null;
24
+ /**
25
+ * The shopper account line for the confirmation page: "Added to your orders" when signed in, else
26
+ * (any guest who gave an email) a prompt to get a code; for `sign-in`, call requestShopperCode() with
27
+ * no params and it goes to that email. Ready to display.
28
+ */
29
+ account?: {
30
+ label: string;
31
+ action: 'none' | 'sign-in';
32
+ };
24
33
  timestamp: string;
25
34
  }
26
35
  /** Never throws for an unknown order: answers `status: null`. */
@@ -0,0 +1,6 @@
1
+ /**
2
+ * getShopperAccount action
3
+ * Calls the getShopperAccount action on the parent window
4
+ */
5
+ import type { GetShopperAccount } from './types';
6
+ export declare const getShopperAccount: GetShopperAccount;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * getShopperAccount action
3
+ * Calls the getShopperAccount action on the parent window
4
+ */
5
+ import { commandFrameClient } from '../../client';
6
+ export const getShopperAccount = async (params) => {
7
+ return await commandFrameClient.call('getShopperAccount', params ?? {});
8
+ };
@@ -0,0 +1,3 @@
1
+ import type { GetShopperAccount } from './types';
2
+ /** Standalone mock: a guest, with the two checkout boxes. */
3
+ export declare const mockGetShopperAccount: GetShopperAccount;
@@ -0,0 +1,12 @@
1
+ /** Standalone mock: a guest, with the two checkout boxes. */
2
+ export const mockGetShopperAccount = async () => {
3
+ console.log('[Mock] getShopperAccount called');
4
+ return {
5
+ success: true,
6
+ signedIn: false,
7
+ boxes: [
8
+ { id: 'accountOptIn', label: 'Track this order and check out faster next time', checked: false },
9
+ { id: 'marketingOptIn', label: 'Email me news and offers from this store', checked: false },
10
+ ],
11
+ };
12
+ };
@@ -0,0 +1,46 @@
1
+ /** A checkbox the checkout shows, with its wording and default. */
2
+ export interface ShopperCheckoutBox {
3
+ /** `saveAddress` is offered to a signed-in shopper only; send it with the shipping address step's contact. */
4
+ id: 'accountOptIn' | 'marketingOptIn' | 'saveAddress';
5
+ label: string;
6
+ checked: boolean;
7
+ }
8
+ export interface ShopperAccountView {
9
+ name: string;
10
+ /** null for an account made with a phone that has not added an email yet. */
11
+ email: string | null;
12
+ phone: string | null;
13
+ }
14
+ /** A saved address, as stored, plus one line to show it by. */
15
+ export interface ShopperAddressView {
16
+ id: string;
17
+ label: string | null;
18
+ /** "12 Water St, St. John's, NL A1C 1A1" */
19
+ line: string;
20
+ isDefault: boolean;
21
+ firstName?: string;
22
+ lastName?: string;
23
+ address1?: string;
24
+ address2?: string;
25
+ city?: string;
26
+ state?: string;
27
+ postCode?: string;
28
+ country?: string;
29
+ }
30
+ export type GetShopperAccountParams = Record<string, never>;
31
+ export interface GetShopperAccountResponse {
32
+ success: boolean;
33
+ signedIn: boolean;
34
+ /** Present when signed in. */
35
+ shopper?: ShopperAccountView;
36
+ /** Signed in only: the saved addresses, the default first. The checkout prefills the default itself. */
37
+ addresses?: ShopperAddressView[];
38
+ /**
39
+ * The account boxes for the checkout's contact step. A guest gets "Track this order" and the news
40
+ * box; a signed-in shopper gets the news box and "Save this address" (ticked).
41
+ */
42
+ boxes: ShopperCheckoutBox[];
43
+ reason?: string;
44
+ }
45
+ /** Who is signed in at this store, their saved addresses, and the checkout boxes to show. */
46
+ export type GetShopperAccount = (params?: GetShopperAccountParams) => Promise<GetShopperAccountResponse>;
@@ -0,0 +1,6 @@
1
+ // The shopper account on a store's website (My Account's store-scoped twin): sign in or sign up
2
+ // with a code by email or text, see this store's orders. Served ONLY by the storefront runtime; on a
3
+ // register it does not exist. Every value comes back READY TO DISPLAY (the runtime formats money,
4
+ // dates and labels), so a flow shows it as it is and computes nothing. Failures resolve with
5
+ // `success: false` and a `reason` written for the shopper; these never throw.
6
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * getShopperOrder action
3
+ * Calls the getShopperOrder action on the parent window
4
+ */
5
+ import type { GetShopperOrder } from './types';
6
+ export declare const getShopperOrder: GetShopperOrder;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * getShopperOrder action
3
+ * Calls the getShopperOrder action on the parent window
4
+ */
5
+ import { commandFrameClient } from '../../client';
6
+ export const getShopperOrder = async (params) => {
7
+ return await commandFrameClient.call('getShopperOrder', params ?? {});
8
+ };
@@ -0,0 +1,2 @@
1
+ import type { GetShopperOrder } from './types';
2
+ export declare const mockGetShopperOrder: GetShopperOrder;
@@ -0,0 +1,24 @@
1
+ export const mockGetShopperOrder = async (params) => {
2
+ console.log('[Mock] getShopperOrder called', params);
3
+ return {
4
+ success: true,
5
+ order: {
6
+ orderId: params.orderId,
7
+ receiptId: '#1042',
8
+ placedAtLabel: 'Nov 1, 2026',
9
+ status: 'paid',
10
+ statusLabel: 'Paid',
11
+ totalLabel: '$42.50',
12
+ itemsLabel: '2 items',
13
+ items: [{ name: 'Harbour mug', variant: 'Slate', quantity: 2, totalLabel: '$40.00' }],
14
+ totals: [
15
+ { label: 'Subtotal', amountLabel: '$40.00' },
16
+ { label: 'Tax', amountLabel: '$2.50' },
17
+ { label: 'Total', amountLabel: '$42.50' },
18
+ ],
19
+ paidWithLabel: 'Visa •••• 4242',
20
+ deliveryLabel: 'Pickup at Water St.',
21
+ returnLabel: null,
22
+ },
23
+ };
24
+ };
@@ -0,0 +1,32 @@
1
+ import type { ShopperOrderView } from '../get-shopper-orders/types';
2
+ export interface ShopperOrderItemView {
3
+ name: string;
4
+ /** e.g. "Slate", or null */
5
+ variant: string | null;
6
+ quantity: number;
7
+ totalLabel: string;
8
+ }
9
+ export interface ShopperOrderDetailView extends ShopperOrderView {
10
+ items: ShopperOrderItemView[];
11
+ /** Subtotal, Discount, Tax, Shipping, Refunded, Total: only the ones that apply. */
12
+ totals: {
13
+ label: string;
14
+ amountLabel: string;
15
+ }[];
16
+ /** "Visa •••• 4242", or null */
17
+ paidWithLabel: string | null;
18
+ /** "Pickup at Water St.", "Shipping", or null */
19
+ deliveryLabel: string | null;
20
+ /** "Return requested Nov 3, 2026", or null */
21
+ returnLabel: string | null;
22
+ }
23
+ export interface GetShopperOrderParams {
24
+ orderId: string;
25
+ }
26
+ export interface GetShopperOrderResponse {
27
+ success: boolean;
28
+ order?: ShopperOrderDetailView;
29
+ reason?: string;
30
+ }
31
+ /** One of the shopper's orders at this store. */
32
+ export type GetShopperOrder = (params: GetShopperOrderParams) => Promise<GetShopperOrderResponse>;
@@ -0,0 +1,6 @@
1
+ // The shopper account on a store's website (My Account's store-scoped twin): sign in or sign up
2
+ // with a code by email or text, see this store's orders. Served ONLY by the storefront runtime; on a
3
+ // register it does not exist. Every value comes back READY TO DISPLAY (the runtime formats money,
4
+ // dates and labels), so a flow shows it as it is and computes nothing. Failures resolve with
5
+ // `success: false` and a `reason` written for the shopper; these never throw.
6
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * getShopperOrders action
3
+ * Calls the getShopperOrders action on the parent window
4
+ */
5
+ import type { GetShopperOrders } from './types';
6
+ export declare const getShopperOrders: GetShopperOrders;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * getShopperOrders action
3
+ * Calls the getShopperOrders action on the parent window
4
+ */
5
+ import { commandFrameClient } from '../../client';
6
+ export const getShopperOrders = async (params) => {
7
+ return await commandFrameClient.call('getShopperOrders', params ?? {});
8
+ };
@@ -0,0 +1,2 @@
1
+ import type { GetShopperOrders } from './types';
2
+ export declare const mockGetShopperOrders: GetShopperOrders;
@@ -0,0 +1,18 @@
1
+ export const mockGetShopperOrders = async () => {
2
+ console.log('[Mock] getShopperOrders called');
3
+ return {
4
+ success: true,
5
+ orders: [
6
+ {
7
+ orderId: '6a2f1c7b1e35f9a4c67a1010',
8
+ receiptId: '#1042',
9
+ placedAtLabel: 'Nov 1, 2026',
10
+ status: 'paid',
11
+ statusLabel: 'Paid',
12
+ totalLabel: '$42.50',
13
+ itemsLabel: '3 items',
14
+ },
15
+ ],
16
+ nextCursor: null,
17
+ };
18
+ };
@@ -0,0 +1,29 @@
1
+ import type { ShopperOrderStatus } from '@final-commerce/common';
2
+ /** One order row, ready to display. */
3
+ export interface ShopperOrderView {
4
+ orderId: string;
5
+ receiptId: string;
6
+ /** e.g. "Nov 1, 2026" */
7
+ placedAtLabel: string;
8
+ /** For styling only: the label is what the shopper reads. */
9
+ status: ShopperOrderStatus;
10
+ /** "Paid", "Refunded", "Partially refunded", "Cancelled" */
11
+ statusLabel: string;
12
+ /** "$42.50" */
13
+ totalLabel: string;
14
+ /** "3 items" */
15
+ itemsLabel: string;
16
+ }
17
+ export interface GetShopperOrdersParams {
18
+ /** From the previous page's `nextCursor`. */
19
+ cursor?: string;
20
+ }
21
+ export interface GetShopperOrdersResponse {
22
+ success: boolean;
23
+ /** This store's orders placed with the shopper's verified emails, newest first. */
24
+ orders: ShopperOrderView[];
25
+ nextCursor: string | null;
26
+ reason?: string;
27
+ }
28
+ /** The signed-in shopper's orders at this store. */
29
+ export type GetShopperOrders = (params?: GetShopperOrdersParams) => Promise<GetShopperOrdersResponse>;
@@ -0,0 +1,6 @@
1
+ // The shopper account on a store's website (My Account's store-scoped twin): sign in or sign up
2
+ // with a code by email or text, see this store's orders. Served ONLY by the storefront runtime; on a
3
+ // register it does not exist. Every value comes back READY TO DISPLAY (the runtime formats money,
4
+ // dates and labels), so a flow shows it as it is and computes nothing. Failures resolve with
5
+ // `success: false` and a `reason` written for the shopper; these never throw.
6
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * requestShopperCode action
3
+ * Calls the requestShopperCode action on the parent window
4
+ */
5
+ import type { RequestShopperCode } from './types';
6
+ export declare const requestShopperCode: RequestShopperCode;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * requestShopperCode action
3
+ * Calls the requestShopperCode action on the parent window
4
+ */
5
+ import { commandFrameClient } from '../../client';
6
+ export const requestShopperCode = async (params) => {
7
+ return await commandFrameClient.call('requestShopperCode', params ?? {});
8
+ };
@@ -0,0 +1,2 @@
1
+ import type { RequestShopperCode } from './types';
2
+ export declare const mockRequestShopperCode: RequestShopperCode;
@@ -0,0 +1,4 @@
1
+ export const mockRequestShopperCode = async (params) => {
2
+ console.log('[Mock] requestShopperCode called', params);
3
+ return { success: true, message: `We sent a 6-digit code to ${params.email ?? params.phone ?? 'your email'}` };
4
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Where the code goes: an `email`, or a `phone` (a text message; any common spelling, the runtime
3
+ * makes it E.164 with +1 when no country is given). Give one, not both. Give neither right after a
4
+ * guest checkout to send it to the email that checkout used ("Email me a code" on the confirmation).
5
+ */
6
+ export interface RequestShopperCodeParams {
7
+ email?: string;
8
+ phone?: string;
9
+ }
10
+ export interface RequestShopperCodeResponse {
11
+ success: boolean;
12
+ /** "We sent a 6-digit code to s…@example.com" (or "…by text to ••• 0101"). Never says who has an account. */
13
+ message?: string;
14
+ reason?: string;
15
+ }
16
+ /** Send a 6-digit sign-in code by email or text. It works at this store only. Signing up is the same step. */
17
+ export type RequestShopperCode = (params: RequestShopperCodeParams) => Promise<RequestShopperCodeResponse>;
@@ -0,0 +1,6 @@
1
+ // The shopper account on a store's website (My Account's store-scoped twin): sign in or sign up
2
+ // with a code by email or text, see this store's orders. Served ONLY by the storefront runtime; on a
3
+ // register it does not exist. Every value comes back READY TO DISPLAY (the runtime formats money,
4
+ // dates and labels), so a flow shows it as it is and computes nothing. Failures resolve with
5
+ // `success: false` and a `reason` written for the shopper; these never throw.
6
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * searchAddresses action
3
+ * Calls the searchAddresses action on the parent window
4
+ */
5
+ import type { SearchAddresses } from './types';
6
+ export declare const searchAddresses: SearchAddresses;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * searchAddresses action
3
+ * Calls the searchAddresses action on the parent window
4
+ */
5
+ import { commandFrameClient } from '../../client';
6
+ export const searchAddresses = async (params) => {
7
+ return await commandFrameClient.call('searchAddresses', params);
8
+ };
@@ -0,0 +1,3 @@
1
+ import type { SearchAddresses } from './types';
2
+ /** Standalone mock: two Water Street addresses for anything typed. */
3
+ export declare const mockSearchAddresses: SearchAddresses;
@@ -0,0 +1,24 @@
1
+ /** Standalone mock: two Water Street addresses for anything typed. */
2
+ export const mockSearchAddresses = async (params) => {
3
+ console.log('[Mock] searchAddresses called', params);
4
+ if (params.query.trim().length < 3)
5
+ return { success: true, available: true, suggestions: [] };
6
+ return {
7
+ success: true,
8
+ available: true,
9
+ suggestions: [
10
+ {
11
+ id: 'mock-place-1',
12
+ label: "12 Water St, St. John's, NL, Canada",
13
+ main: '12 Water St',
14
+ secondary: "St. John's, NL, Canada",
15
+ },
16
+ {
17
+ id: 'mock-place-2',
18
+ label: "120 Water St, St. John's, NL, Canada",
19
+ main: '120 Water St',
20
+ secondary: "St. John's, NL, Canada",
21
+ },
22
+ ],
23
+ };
24
+ };
@@ -0,0 +1,31 @@
1
+ /** One line to show in the dropdown. Pass its `id` to getAddressDetails when the shopper picks it. */
2
+ export interface AddressSuggestion {
3
+ id: string;
4
+ /** The whole line: "12 Water St, St. John's, NL, Canada". */
5
+ label: string;
6
+ /** The street part, for a two-line row: "12 Water St". */
7
+ main: string;
8
+ /** The rest: "St. John's, NL, Canada". */
9
+ secondary: string;
10
+ }
11
+ export interface SearchAddressesParams {
12
+ /** What the shopper typed so far. Under 3 characters answers no suggestions without a lookup. */
13
+ query: string;
14
+ /** ISO 3166-1 alpha-2. Defaults to the store's own country. */
15
+ country?: string;
16
+ /** Language of the suggestions, e.g. `fr`. */
17
+ language?: string;
18
+ }
19
+ export interface SearchAddressesResponse {
20
+ success: boolean;
21
+ suggestions: AddressSuggestion[];
22
+ /** false when this site has no address lookup: keep the plain fields and stop asking. */
23
+ available: boolean;
24
+ reason?: string;
25
+ }
26
+ /**
27
+ * Addresses matching what the shopper typed, for an autocomplete dropdown. Call it as they type
28
+ * (wait ~250 ms after the last keystroke); the runtime groups the searches and the pick into one
29
+ * lookup session itself.
30
+ */
31
+ export type SearchAddresses = (params: SearchAddressesParams) => Promise<SearchAddressesResponse>;
@@ -0,0 +1,5 @@
1
+ // Address autocomplete for a store website's checkout: what the shopper typed in, matching
2
+ // addresses out, then the picked one as a full address (getAddressDetails). Served ONLY by the
3
+ // storefront runtime. Failures resolve with `success: false` and a `reason`; these never throw, and
4
+ // when lookup is not available the flow simply keeps its plain address fields.
5
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * signInShopper action
3
+ * Calls the signInShopper action on the parent window
4
+ */
5
+ import type { SignInShopper } from './types';
6
+ export declare const signInShopper: SignInShopper;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * signInShopper action
3
+ * Calls the signInShopper action on the parent window
4
+ */
5
+ import { commandFrameClient } from '../../client';
6
+ export const signInShopper = async (params) => {
7
+ return await commandFrameClient.call('signInShopper', params ?? {});
8
+ };
@@ -0,0 +1,2 @@
1
+ import type { SignInShopper } from './types';
2
+ export declare const mockSignInShopper: SignInShopper;
@@ -0,0 +1,7 @@
1
+ export const mockSignInShopper = async (params) => {
2
+ console.log('[Mock] signInShopper called', params);
3
+ const email = params.email ?? null;
4
+ return params.code === '000000'
5
+ ? { success: false, reason: 'That code is wrong' }
6
+ : { success: true, shopper: { name: email?.split('@')[0] ?? '', email, phone: params.phone ?? null } };
7
+ };
@@ -0,0 +1,19 @@
1
+ import type { ShopperAccountView } from '../get-shopper-account/types';
2
+ /** The same `email` or `phone` the code was sent to (or neither, after a guest checkout), and the code. */
3
+ export interface SignInShopperParams {
4
+ email?: string;
5
+ phone?: string;
6
+ code: string;
7
+ }
8
+ export interface SignInShopperResponse {
9
+ success: boolean;
10
+ shopper?: ShopperAccountView;
11
+ /** "That code is wrong", "Too many tries, get a new code", ... */
12
+ reason?: string;
13
+ }
14
+ /**
15
+ * Sign in (or up) with the code. The session is kept for this store only. Signing in fills the
16
+ * checkout's contact and default address when they are empty, and the payment step then offers the
17
+ * shopper's saved cards.
18
+ */
19
+ export type SignInShopper = (params: SignInShopperParams) => Promise<SignInShopperResponse>;
@@ -0,0 +1,6 @@
1
+ // The shopper account on a store's website (My Account's store-scoped twin): sign in or sign up
2
+ // with a code by email or text, see this store's orders. Served ONLY by the storefront runtime; on a
3
+ // register it does not exist. Every value comes back READY TO DISPLAY (the runtime formats money,
4
+ // dates and labels), so a flow shows it as it is and computes nothing. Failures resolve with
5
+ // `success: false` and a `reason` written for the shopper; these never throw.
6
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * signOutShopper action
3
+ * Calls the signOutShopper action on the parent window
4
+ */
5
+ import type { SignOutShopper } from './types';
6
+ export declare const signOutShopper: SignOutShopper;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * signOutShopper action
3
+ * Calls the signOutShopper action on the parent window
4
+ */
5
+ import { commandFrameClient } from '../../client';
6
+ export const signOutShopper = async (params) => {
7
+ return await commandFrameClient.call('signOutShopper', params ?? {});
8
+ };
@@ -0,0 +1,2 @@
1
+ import type { SignOutShopper } from './types';
2
+ export declare const mockSignOutShopper: SignOutShopper;
@@ -0,0 +1,4 @@
1
+ export const mockSignOutShopper = async () => {
2
+ console.log('[Mock] signOutShopper called');
3
+ return { success: true };
4
+ };
@@ -0,0 +1,7 @@
1
+ export type SignOutShopperParams = Record<string, never>;
2
+ export interface SignOutShopperResponse {
3
+ success: boolean;
4
+ reason?: string;
5
+ }
6
+ /** Ends this store's session on this device. */
7
+ export type SignOutShopper = (params?: SignOutShopperParams) => Promise<SignOutShopperResponse>;
@@ -0,0 +1,6 @@
1
+ // The shopper account on a store's website (My Account's store-scoped twin): sign in or sign up
2
+ // with a code by email or text, see this store's orders. Served ONLY by the storefront runtime; on a
3
+ // register it does not exist. Every value comes back READY TO DISPLAY (the runtime formats money,
4
+ // dates and labels), so a flow shows it as it is and computes nothing. Failures resolve with
5
+ // `success: false` and a `reason` written for the shopper; these never throw.
6
+ export {};
package/dist/index.d.ts CHANGED
@@ -68,12 +68,20 @@ export declare const command: {
68
68
  readonly startCheckout: import(".").StartCheckout;
69
69
  readonly attachCheckoutContact: import(".").AttachCheckoutContact;
70
70
  readonly getAddressOptions: import(".").GetAddressOptions;
71
+ readonly searchAddresses: import(".").SearchAddresses;
72
+ readonly getAddressDetails: import(".").GetAddressDetails;
71
73
  readonly setOrderAddress: import(".").SetOrderAddress;
72
74
  readonly getShippingOptions: import(".").GetShippingOptions;
73
75
  readonly selectShippingOption: import(".").SelectShippingOption;
74
76
  readonly setOutlet: import(".").SetOutlet;
75
77
  readonly resumeCheckout: import(".").ResumeCheckout;
76
78
  readonly getCheckoutStatus: import(".").GetCheckoutStatus;
79
+ readonly getShopperAccount: import(".").GetShopperAccount;
80
+ readonly requestShopperCode: import(".").RequestShopperCode;
81
+ readonly signInShopper: import(".").SignInShopper;
82
+ readonly signOutShopper: import(".").SignOutShopper;
83
+ readonly getShopperOrders: import(".").GetShopperOrders;
84
+ readonly getShopperOrder: import(".").GetShopperOrder;
77
85
  readonly getMotoConfig: import(".").GetMotoConfig;
78
86
  readonly addCustomerNote: import(".").AddCustomerNote;
79
87
  readonly removeCustomerNote: import(".").RemoveCustomerNote;
@@ -241,6 +249,14 @@ export type { SelectShippingOption, SelectShippingOptionParams, SelectShippingOp
241
249
  export type { SetOutlet, SetOutletParams, SetOutletResponse } from './actions/set-outlet/types';
242
250
  export type { ResumeCheckout, ResumeCheckoutParams, ResumeCheckoutResponse, ResumeCheckoutResult, } from './actions/resume-checkout/types';
243
251
  export type { GetCheckoutStatus, GetCheckoutStatusParams, GetCheckoutStatusResponse, CheckoutOrderStatus, CheckoutCancelReason, } from './actions/get-checkout-status/types';
252
+ export type { GetShopperAccount, GetShopperAccountParams, GetShopperAccountResponse, ShopperCheckoutBox, ShopperAccountView, ShopperAddressView, } from './actions/get-shopper-account/types';
253
+ export type { RequestShopperCode, RequestShopperCodeParams, RequestShopperCodeResponse, } from './actions/request-shopper-code/types';
254
+ export type { SignInShopper, SignInShopperParams, SignInShopperResponse } from './actions/sign-in-shopper/types';
255
+ export type { SignOutShopper, SignOutShopperParams, SignOutShopperResponse } from './actions/sign-out-shopper/types';
256
+ export type { SearchAddresses, SearchAddressesParams, SearchAddressesResponse, AddressSuggestion, } from './actions/search-addresses/types';
257
+ export type { GetAddressDetails, GetAddressDetailsParams, GetAddressDetailsResponse, AddressDetails, } from './actions/get-address-details/types';
258
+ export type { GetShopperOrders, GetShopperOrdersParams, GetShopperOrdersResponse, ShopperOrderView, } from './actions/get-shopper-orders/types';
259
+ export type { GetShopperOrder, GetShopperOrderParams, GetShopperOrderResponse, ShopperOrderDetailView, ShopperOrderItemView, } from './actions/get-shopper-order/types';
244
260
  export type { GetMotoConfig, GetMotoConfigResponse, MotoUnavailableReason } from './actions/get-moto-config/types';
245
261
  export type { AddCustomerNote, AddCustomerNoteParams, AddCustomerNoteResponse, } from './actions/add-customer-note/types';
246
262
  export type { RemoveCustomerNote, RemoveCustomerNoteParams, RemoveCustomerNoteResponse, } from './actions/remove-customer-note/types';
package/dist/index.js CHANGED
@@ -68,12 +68,21 @@ import { chargeMoto } from './actions/charge-moto/action';
68
68
  import { startCheckout } from './actions/start-checkout/action';
69
69
  import { attachCheckoutContact } from './actions/attach-checkout-contact/action';
70
70
  import { getAddressOptions } from './actions/get-address-options/action';
71
+ import { searchAddresses } from './actions/search-addresses/action';
72
+ import { getAddressDetails } from './actions/get-address-details/action';
71
73
  import { setOrderAddress } from './actions/set-order-address/action';
72
74
  import { getShippingOptions } from './actions/get-shipping-options/action';
73
75
  import { selectShippingOption } from './actions/select-shipping-option/action';
74
76
  import { setOutlet } from './actions/set-outlet/action';
75
77
  import { resumeCheckout } from './actions/resume-checkout/action';
76
78
  import { getCheckoutStatus } from './actions/get-checkout-status/action';
79
+ // Shopper account (store websites)
80
+ import { getShopperAccount } from './actions/get-shopper-account/action';
81
+ import { requestShopperCode } from './actions/request-shopper-code/action';
82
+ import { signInShopper } from './actions/sign-in-shopper/action';
83
+ import { signOutShopper } from './actions/sign-out-shopper/action';
84
+ import { getShopperOrders } from './actions/get-shopper-orders/action';
85
+ import { getShopperOrder } from './actions/get-shopper-order/action';
77
86
  import { getMotoConfig } from './actions/get-moto-config/action';
78
87
  // Customer Actions
79
88
  import { addCustomerNote } from './actions/add-customer-note/action';
@@ -237,12 +246,20 @@ export const command = {
237
246
  startCheckout,
238
247
  attachCheckoutContact,
239
248
  getAddressOptions,
249
+ searchAddresses,
250
+ getAddressDetails,
240
251
  setOrderAddress,
241
252
  getShippingOptions,
242
253
  selectShippingOption,
243
254
  setOutlet,
244
255
  resumeCheckout,
245
256
  getCheckoutStatus,
257
+ getShopperAccount,
258
+ requestShopperCode,
259
+ signInShopper,
260
+ signOutShopper,
261
+ getShopperOrders,
262
+ getShopperOrder,
246
263
  getMotoConfig,
247
264
  // Customer Actions
248
265
  addCustomerNote,
@@ -48,6 +48,14 @@ import { mockGetOutlets } from '../../actions/get-outlets/mock';
48
48
  import { mockSetOutlet } from '../../actions/set-outlet/mock';
49
49
  import { mockResumeCheckout } from '../../actions/resume-checkout/mock';
50
50
  import { mockGetCheckoutStatus } from '../../actions/get-checkout-status/mock';
51
+ import { mockGetShopperAccount } from '../../actions/get-shopper-account/mock';
52
+ import { mockRequestShopperCode } from '../../actions/request-shopper-code/mock';
53
+ import { mockSignInShopper } from '../../actions/sign-in-shopper/mock';
54
+ import { mockSignOutShopper } from '../../actions/sign-out-shopper/mock';
55
+ import { mockGetShopperOrders } from '../../actions/get-shopper-orders/mock';
56
+ import { mockSearchAddresses } from '../../actions/search-addresses/mock';
57
+ import { mockGetAddressDetails } from '../../actions/get-address-details/mock';
58
+ import { mockGetShopperOrder } from '../../actions/get-shopper-order/mock';
51
59
  import { mockGetMotoConfig } from '../../actions/get-moto-config/mock';
52
60
  import { mockGetTimeClockStatus } from '../../actions/get-time-clock-status/mock';
53
61
  import { mockClearCart } from '../../actions/clear-cart/mock';
@@ -171,6 +179,8 @@ export const RENDER_MOCKS = {
171
179
  startCheckout: mockStartCheckout,
172
180
  attachCheckoutContact: mockAttachCheckoutContact,
173
181
  getAddressOptions: mockGetAddressOptions,
182
+ searchAddresses: mockSearchAddresses,
183
+ getAddressDetails: mockGetAddressDetails,
174
184
  setOrderAddress: mockSetOrderAddress,
175
185
  getShippingOptions: mockGetShippingOptions,
176
186
  selectShippingOption: mockSelectShippingOption,
@@ -178,6 +188,12 @@ export const RENDER_MOCKS = {
178
188
  setOutlet: mockSetOutlet,
179
189
  resumeCheckout: mockResumeCheckout,
180
190
  getCheckoutStatus: mockGetCheckoutStatus,
191
+ getShopperAccount: mockGetShopperAccount,
192
+ requestShopperCode: mockRequestShopperCode,
193
+ signInShopper: mockSignInShopper,
194
+ signOutShopper: mockSignOutShopper,
195
+ getShopperOrders: mockGetShopperOrders,
196
+ getShopperOrder: mockGetShopperOrder,
181
197
  getMotoConfig: mockGetMotoConfig,
182
198
  clearCart: mockClearCart,
183
199
  deleteParkedOrder: mockDeleteParkedOrder,
@@ -1,4 +1,4 @@
1
- import type { ExampleFunction, GetProducts, AddCustomSale, EditCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, GetCustomStockActions, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, GetProductModifierSelections, GetCompositePrice, GetCompositeAvailability, SetProductModifierSelections, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, SetVariantUnavailable, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, ResumeOrder, SetOrderMetadata, AssignOrderUser, ReleaseFromCart, SetOrderType, SetScheduledFor, SetOrderStatus, GetOrderStatuses, DeleteParkedOrder, VoidOrder, InitiateRefund, CashPayment, RecordExternalPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, RedeemRefund, GetRefundPlan, CheckPermission, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, ApplyTransition, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout, SendEmail, SendSms, GetBookingResources, GetBookingAvailability, GetBookings, HoldBooking, AddBookingToCart, RemoveBookingFromCart, CancelBooking, CreatePaymentLink, ChargeMoto, StartCheckout, AttachCheckoutContact, GetAddressOptions, SetOrderAddress, GetShippingOptions, SelectShippingOption, GetOutlets, SetOutlet, ResumeCheckout, GetCheckoutStatus, GetMotoConfig, GetTimeClockStatus } from '../../index';
1
+ import type { ExampleFunction, GetProducts, AddCustomSale, EditCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, GetCustomStockActions, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, GetProductModifierSelections, GetCompositePrice, GetCompositeAvailability, SetProductModifierSelections, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, SetVariantUnavailable, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, ResumeOrder, SetOrderMetadata, AssignOrderUser, ReleaseFromCart, SetOrderType, SetScheduledFor, SetOrderStatus, GetOrderStatuses, DeleteParkedOrder, VoidOrder, InitiateRefund, CashPayment, RecordExternalPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, RedeemRefund, GetRefundPlan, CheckPermission, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, ApplyTransition, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout, SendEmail, SendSms, GetBookingResources, GetBookingAvailability, GetBookings, HoldBooking, AddBookingToCart, RemoveBookingFromCart, CancelBooking, CreatePaymentLink, ChargeMoto, StartCheckout, AttachCheckoutContact, GetAddressOptions, SetOrderAddress, GetShippingOptions, SelectShippingOption, GetOutlets, SetOutlet, ResumeCheckout, GetCheckoutStatus, GetShopperAccount, RequestShopperCode, SignInShopper, SignOutShopper, GetShopperOrders, GetShopperOrder, SearchAddresses, GetAddressDetails, GetMotoConfig, GetTimeClockStatus } from '../../index';
2
2
  export interface RenderProviderActions {
3
3
  exampleFunction: ExampleFunction;
4
4
  getProducts: GetProducts;
@@ -74,6 +74,8 @@ export interface RenderProviderActions {
74
74
  attachCheckoutContact: AttachCheckoutContact;
75
75
  /** Shipping, on the till (ship-to) and the website alike. The runtime prices; the flow renders. */
76
76
  getAddressOptions: GetAddressOptions;
77
+ searchAddresses: SearchAddresses;
78
+ getAddressDetails: GetAddressDetails;
77
79
  setOrderAddress: SetOrderAddress;
78
80
  getShippingOptions: GetShippingOptions;
79
81
  selectShippingOption: SelectShippingOption;
@@ -87,6 +89,13 @@ export interface RenderProviderActions {
87
89
  resumeCheckout: ResumeCheckout;
88
90
  /** Where an online order stands now, by its order password. Storefront-only. */
89
91
  getCheckoutStatus: GetCheckoutStatus;
92
+ /** The shopper account on a store's website (sign in, this store's orders). Storefront-only. */
93
+ getShopperAccount: GetShopperAccount;
94
+ requestShopperCode: RequestShopperCode;
95
+ signInShopper: SignInShopper;
96
+ signOutShopper: SignOutShopper;
97
+ getShopperOrders: GetShopperOrders;
98
+ getShopperOrder: GetShopperOrder;
90
99
  getMotoConfig: GetMotoConfig;
91
100
  addNonRevenueItem: AddNonRevenueItem;
92
101
  addCustomerNote: AddCustomerNote;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.14.1-online.1",
3
+ "version": "0.14.1-online.3",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  "ignoreBranchesMissingTickets": true
58
58
  },
59
59
  "dependencies": {
60
- "@final-commerce/common": "2.11.1-online.1"
60
+ "@final-commerce/common": "2.11.1-online.3"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@commitlint/cli": "^19.0.0",