@final-commerce/command-frame 0.1.15 → 0.1.17

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 (44) hide show
  1. package/README.md +42 -449
  2. package/dist/CommonTypes.d.ts +4 -7
  3. package/dist/actions/add-cart-discount/mock.js +5 -1
  4. package/dist/actions/add-product-to-cart/mock.js +3 -1
  5. package/dist/actions/assign-customer/mock.js +3 -1
  6. package/dist/actions/cash-payment/mock.js +3 -1
  7. package/dist/actions/clear-cart/mock.js +3 -1
  8. package/dist/actions/get-products/mock.js +3 -3
  9. package/dist/client.d.ts +4 -1
  10. package/dist/client.js +24 -4
  11. package/dist/demo/database.d.ts +10 -0
  12. package/dist/demo/database.js +77 -17
  13. package/dist/index.d.ts +4 -0
  14. package/dist/index.js +6 -0
  15. package/dist/projects/manage/client.d.ts +13 -0
  16. package/dist/projects/manage/client.js +13 -0
  17. package/dist/projects/manage/index.d.ts +4 -0
  18. package/dist/projects/manage/index.js +4 -0
  19. package/dist/projects/manage/mocks.d.ts +2 -0
  20. package/dist/projects/manage/mocks.js +6 -0
  21. package/dist/projects/manage/provider.d.ts +8 -0
  22. package/dist/projects/manage/provider.js +6 -0
  23. package/dist/projects/manage/types.d.ts +5 -0
  24. package/dist/projects/manage/types.js +1 -0
  25. package/dist/projects/render/client.d.ts +13 -0
  26. package/dist/projects/render/client.js +13 -0
  27. package/dist/projects/render/index.d.ts +4 -0
  28. package/dist/projects/render/index.js +4 -0
  29. package/dist/projects/render/mocks.d.ts +2 -0
  30. package/dist/projects/render/mocks.js +94 -0
  31. package/dist/projects/render/provider.d.ts +8 -0
  32. package/dist/projects/render/provider.js +6 -0
  33. package/dist/projects/render/types.d.ts +49 -0
  34. package/dist/projects/render/types.js +1 -0
  35. package/dist/provider.d.ts +19 -0
  36. package/dist/provider.js +178 -0
  37. package/dist/pubsub/subscriber.d.ts +4 -0
  38. package/dist/pubsub/subscriber.js +53 -5
  39. package/dist/pubsub/topics/types.d.ts +14 -0
  40. package/dist/pubsub/topics/types.js +1 -0
  41. package/dist/pubsub/types.d.ts +9 -0
  42. package/package.json +1 -1
  43. package/dist/demo/registry.d.ts +0 -5
  44. package/dist/demo/registry.js +0 -94
@@ -1,7 +1,9 @@
1
- import { resetMockCart } from "../../demo/database";
1
+ import { resetMockCart, mockPublishEvent } from "../../demo/database";
2
2
  export const mockClearCart = async () => {
3
3
  console.log("[Mock] clearCart called");
4
4
  resetMockCart();
5
+ // Publish cart-created event to simulate cart reset
6
+ mockPublishEvent('cart', 'cart-created', {});
5
7
  return {
6
8
  success: true,
7
9
  timestamp: new Date().toISOString()
@@ -13,15 +13,15 @@ export const mockGetProducts = async (params) => {
13
13
  // Handle categories filter: { $in: [...] } or direct string
14
14
  const catFilter = query.categories;
15
15
  if (typeof catFilter === 'string') {
16
- products = products.filter(p => p.categories?.externalId === catFilter);
16
+ products = products.filter(p => (p.categories || []).includes(catFilter));
17
17
  }
18
18
  else if (typeof catFilter === 'object' && '$in' in catFilter) {
19
19
  const inList = catFilter.$in;
20
- products = products.filter(p => inList.includes(p.categories?.externalId));
20
+ products = products.filter(p => (p.categories || []).some(c => inList.includes(c)));
21
21
  }
22
22
  else if (typeof catFilter === 'object' && '$contains' in catFilter) {
23
23
  const containsVal = catFilter.$contains;
24
- products = products.filter(p => p.categories?.externalId === containsVal);
24
+ products = products.filter(p => (p.categories || []).includes(containsVal));
25
25
  }
26
26
  }
27
27
  return {
package/dist/client.d.ts CHANGED
@@ -13,6 +13,7 @@ export interface PostMessageResponse<T = any> {
13
13
  data?: T;
14
14
  error?: string;
15
15
  }
16
+ export type MockHandler = (params?: any) => Promise<any>;
16
17
  export declare class CommandFrameClient {
17
18
  private pendingRequests;
18
19
  private defaultTimeout;
@@ -20,15 +21,17 @@ export declare class CommandFrameClient {
20
21
  private debug;
21
22
  private useGlobalDebug;
22
23
  private mockMode;
24
+ private mockRegistry;
23
25
  constructor(options?: {
24
26
  timeout?: number;
25
27
  origin?: string;
26
28
  debug?: boolean;
27
29
  mockMode?: boolean;
30
+ mockRegistry?: Record<string, MockHandler>;
28
31
  });
29
32
  private isDebugEnabled;
30
33
  call<TParams = any, TResponse = any>(action: string, params?: TParams, timeout?: number): Promise<TResponse>;
31
- private getFinalContext;
34
+ private detectContext;
32
35
  private handleMessage;
33
36
  private generateRequestId;
34
37
  destroy(): void;
package/dist/client.js CHANGED
@@ -2,7 +2,6 @@
2
2
  * Command Frame Client for iframe communication
3
3
  * Allows the iframe to call functions on the parent window via postMessage
4
4
  */
5
- import { MOCK_REGISTRY } from "./demo/registry";
6
5
  export class CommandFrameClient {
7
6
  constructor(options = {}) {
8
7
  this.pendingRequests = new Map();
@@ -12,11 +11,20 @@ export class CommandFrameClient {
12
11
  this.useGlobalDebug = options.debug === undefined;
13
12
  // Default to provided mockMode or false. Detection happens via getFinalContext.
14
13
  this.mockMode = options.mockMode ?? false;
14
+ this.mockRegistry = options.mockRegistry || {};
15
+ // If running standalone (no parent window), force Mock Mode immediately
16
+ // This prevents the 2s delay and ensures immediate response in dev/standalone mode
17
+ if (typeof window !== 'undefined' && (!window.parent || window.parent === window)) {
18
+ if (this.isDebugEnabled()) {
19
+ console.log("[ActionsClient] Standalone mode detected. Enabling Mock Mode immediately.");
20
+ }
21
+ this.mockMode = true;
22
+ }
15
23
  if (typeof window !== 'undefined') {
16
24
  window.addEventListener("message", this.handleMessage.bind(this));
17
25
  }
18
26
  // Auto-detect mock mode on initialization
19
- this.getFinalContext().then((context) => {
27
+ this.detectContext().then((context) => {
20
28
  if (!context) {
21
29
  if (this.isDebugEnabled()) {
22
30
  console.warn("[ActionsClient] Environment detection failed (timeout or error). Switching to Mock Mode.");
@@ -31,6 +39,18 @@ export class CommandFrameClient {
31
39
  mockMode: this.mockMode
32
40
  });
33
41
  }
42
+ // Return a Proxy to enable dynamic method calls
43
+ // This allows client.getProducts() to map to client.call('getProducts')
44
+ return new Proxy(this, {
45
+ get: (target, prop) => {
46
+ // If the property exists on the instance, return it
47
+ if (prop in target) {
48
+ return target[prop];
49
+ }
50
+ // Otherwise, assume it's an action name and return a wrapper function
51
+ return (params) => target.call(prop, params);
52
+ }
53
+ });
34
54
  }
35
55
  isDebugEnabled() {
36
56
  if (!this.useGlobalDebug) {
@@ -44,7 +64,7 @@ export class CommandFrameClient {
44
64
  if (this.isDebugEnabled()) {
45
65
  console.log("[ActionsClient] Mock Call", { action, params });
46
66
  }
47
- const mockHandler = MOCK_REGISTRY[action];
67
+ const mockHandler = this.mockRegistry[action];
48
68
  if (mockHandler) {
49
69
  // Simulate async delay
50
70
  await new Promise(resolve => setTimeout(resolve, 100));
@@ -111,7 +131,7 @@ export class CommandFrameClient {
111
131
  });
112
132
  }
113
133
  // Private check to determine environment
114
- getFinalContext() {
134
+ detectContext() {
115
135
  return new Promise((resolve) => {
116
136
  if (typeof window === 'undefined' || !window.parent || window.parent === window)
117
137
  return resolve(null);
@@ -17,6 +17,8 @@ export declare const MOCK_CUSTOMER_5: CFCustomer;
17
17
  export declare const MOCK_CATEGORY_PASTES: CFCategory;
18
18
  export declare const MOCK_CATEGORY_SPECIALTY: CFCategory;
19
19
  export declare const MOCK_CATEGORY_BASIC: CFCategory;
20
+ export declare const MOCK_CATEGORY_VEGAN: CFCategory;
21
+ export declare const MOCK_CATEGORY_SPICY: CFCategory;
20
22
  export declare const MOCK_PRODUCT_BASIL_ALMOND: CFProduct;
21
23
  export declare const MOCK_PRODUCT_BEER: CFProduct;
22
24
  export declare const MOCK_PRODUCT_BEET: CFProduct;
@@ -27,6 +29,10 @@ export declare const MOCK_PRODUCT_GINGER_LIME: CFProduct;
27
29
  export declare const MOCK_PRODUCT_LEMON: CFProduct;
28
30
  export declare const MOCK_PRODUCT_RED_PEPPER: CFProduct;
29
31
  export declare const MOCK_PRODUCT_ROASTED_TOMATO: CFProduct;
32
+ export declare const MOCK_PRODUCT_MINT_LEMON: CFProduct;
33
+ export declare const MOCK_PRODUCT_CHILI_GARLIC: CFProduct;
34
+ export declare const MOCK_PRODUCT_HABANERO: CFProduct;
35
+ export declare const MOCK_PRODUCT_BLACK_GARLIC: CFProduct;
30
36
  export declare const MOCK_ORDER_1: CFActiveOrder;
31
37
  export declare const MOCK_ORDER_2: CFActiveOrder;
32
38
  export declare const MOCK_USERS: CFActiveUser[];
@@ -43,4 +49,8 @@ export declare const MOCK_OUTLET: CFActiveOutlet;
43
49
  export declare let MOCK_CART: CFActiveCart;
44
50
  export declare const resetMockCart: () => void;
45
51
  export declare const safeSerialize: <T>(data: T) => T;
52
+ type MockEventCallback = (event: any) => void;
53
+ export declare const mockPublishEvent: (topic: string, eventType: string, data: any) => void;
54
+ export declare const mockSubscribeToTopic: (topic: string, callback: MockEventCallback) => void;
46
55
  export declare const createOrderFromCart: (paymentType: string, amount: number | string, processor?: string) => CFActiveOrder;
56
+ export {};
@@ -169,10 +169,24 @@ export const MOCK_CATEGORY_BASIC = {
169
169
  companyId: COMPANY_ID,
170
170
  parentId: "cat_pastes"
171
171
  };
172
+ export const MOCK_CATEGORY_VEGAN = {
173
+ _id: "cat_vegan",
174
+ name: "Vegan",
175
+ externalId: "ext_cat_vegan",
176
+ companyId: COMPANY_ID,
177
+ parentId: null
178
+ };
179
+ export const MOCK_CATEGORY_SPICY = {
180
+ _id: "cat_spicy",
181
+ name: "Spicy",
182
+ externalId: "ext_cat_spicy",
183
+ companyId: COMPANY_ID,
184
+ parentId: null
185
+ };
172
186
  // --- PRODUCTS ---
173
- const createInventory = (stock) => [{ warehouse: "main", outletId: MOCK_OUTLET_MAIN.id, stock }];
187
+ const createInventory = (stock) => [{ outletId: MOCK_OUTLET_MAIN.id, stock }];
174
188
  // Helper for Simple Product
175
- const createSimpleProduct = (id, name, price, image, category, description) => {
189
+ const createSimpleProduct = (id, name, price, image, categories, description) => {
176
190
  const sku = `SKU-${id.toUpperCase()}`;
177
191
  return {
178
192
  _id: id,
@@ -187,7 +201,8 @@ const createSimpleProduct = (id, name, price, image, category, description) => {
187
201
  taxTable: "tax_standard",
188
202
  description,
189
203
  images: [image],
190
- categories: { name: category.name, externalId: category.externalId },
204
+ // Render stores product categories as an array of category IDs
205
+ categories: categories.map(c => c._id),
191
206
  attributes: [],
192
207
  variants: [
193
208
  {
@@ -205,7 +220,7 @@ const createSimpleProduct = (id, name, price, image, category, description) => {
205
220
  };
206
221
  };
207
222
  // Helper for Variable Product (Size: Small, Large)
208
- const createVariableProduct = (id, name, basePrice, largePrice, image, category, description) => {
223
+ const createVariableProduct = (id, name, basePrice, largePrice, image, categories, description) => {
209
224
  const skuBase = `SKU-${id.toUpperCase()}`;
210
225
  return {
211
226
  _id: id,
@@ -220,7 +235,8 @@ const createVariableProduct = (id, name, basePrice, largePrice, image, category,
220
235
  taxTable: "tax_standard",
221
236
  description,
222
237
  images: [image],
223
- categories: { name: category.name, externalId: category.externalId },
238
+ // Render stores product categories as an array of category IDs
239
+ categories: categories.map(c => c._id),
224
240
  attributes: [{ name: "Size", values: ["Small", "Large"] }],
225
241
  variants: [
226
242
  {
@@ -248,16 +264,24 @@ const createVariableProduct = (id, name, basePrice, largePrice, image, category,
248
264
  ]
249
265
  };
250
266
  };
251
- export const MOCK_PRODUCT_BASIL_ALMOND = createSimpleProduct("prod_basil_almond", "Basil Almond Paste", "12.00", basilAlmondImg, MOCK_CATEGORY_SPECIALTY, "A rich blend of fresh basil and roasted almonds.");
252
- export const MOCK_PRODUCT_BEER = createVariableProduct("prod_beer", "Beer Paste", "15.00", "25.00", beerImg, MOCK_CATEGORY_SPECIALTY, "Unique paste infused with dark lager.");
253
- export const MOCK_PRODUCT_BEET = createSimpleProduct("prod_beet", "Beet Paste", "10.00", beetImg, MOCK_CATEGORY_BASIC, "Earthy and sweet beet paste, perfect for salads.");
254
- export const MOCK_PRODUCT_CARAMELIZED = createVariableProduct("prod_caramelized", "Caramelized Paste", "14.00", "22.00", caramelizedImg, MOCK_CATEGORY_SPECIALTY, "Slow-cooked caramelized onion paste.");
255
- export const MOCK_PRODUCT_GARLIC_ONION = createVariableProduct("prod_garlic_onion", "Garlic Onion Paste", "11.00", "18.00", garlicOnionImg, MOCK_CATEGORY_BASIC, "Classic savory base for any dish.");
256
- export const MOCK_PRODUCT_GARLIC = createSimpleProduct("prod_garlic", "Garlic Paste", "9.00", garlicImg, MOCK_CATEGORY_BASIC, "Pure, intense garlic paste.");
257
- export const MOCK_PRODUCT_GINGER_LIME = createVariableProduct("prod_ginger_lime", "Ginger Lime Paste", "13.00", "20.00", gingerLimeImg, MOCK_CATEGORY_SPECIALTY, "Zesty and spicy, great for asian cuisine.");
258
- export const MOCK_PRODUCT_LEMON = createSimpleProduct("prod_lemon", "Lemon Paste", "10.50", lemonImg, MOCK_CATEGORY_BASIC, "Bright citrus flavor concentrate.");
259
- export const MOCK_PRODUCT_RED_PEPPER = createVariableProduct("prod_red_pepper", "Red Pepper Paste", "12.50", "19.00", redPepperImg, MOCK_CATEGORY_BASIC, "Roasted red peppers with a hint of spice.");
260
- export const MOCK_PRODUCT_ROASTED_TOMATO = createVariableProduct("prod_roasted_tomato", "Roasted Tomato Paste", "11.50", "18.50", roastedTomatoImg, MOCK_CATEGORY_BASIC, "Deep, umami-rich tomato flavor.");
267
+ export const MOCK_PRODUCT_BASIL_ALMOND = createSimpleProduct("prod_basil_almond", "Basil Almond Paste", "12.00", basilAlmondImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_VEGAN], "A rich blend of fresh basil and roasted almonds.");
268
+ export const MOCK_PRODUCT_BEER = createVariableProduct("prod_beer", "Beer Paste", "15.00", "25.00", beerImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY], "Unique paste infused with dark lager.");
269
+ export const MOCK_PRODUCT_BEET = createSimpleProduct("prod_beet", "Beet Paste", "10.00", beetImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_VEGAN], "Earthy and sweet beet paste, perfect for salads.");
270
+ export const MOCK_PRODUCT_CARAMELIZED = createVariableProduct("prod_caramelized", "Caramelized Paste", "14.00", "22.00", caramelizedImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_VEGAN], "Slow-cooked caramelized onion paste.");
271
+ export const MOCK_PRODUCT_GARLIC_ONION = createVariableProduct("prod_garlic_onion", "Garlic Onion Paste", "11.00", "18.00", garlicOnionImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_VEGAN], "Classic savory base for any dish.");
272
+ export const MOCK_PRODUCT_GARLIC = createSimpleProduct("prod_garlic", "Garlic Paste", "9.00", garlicImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_VEGAN], "Pure, intense garlic paste.");
273
+ export const MOCK_PRODUCT_GINGER_LIME = createVariableProduct("prod_ginger_lime", "Ginger Lime Paste", "13.00", "20.00", gingerLimeImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_SPICY, MOCK_CATEGORY_VEGAN], "Zesty and spicy, great for asian cuisine.");
274
+ export const MOCK_PRODUCT_LEMON = createSimpleProduct("prod_lemon", "Lemon Paste", "10.50", lemonImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_VEGAN], "Bright citrus flavor concentrate.");
275
+ export const MOCK_PRODUCT_RED_PEPPER = createVariableProduct("prod_red_pepper", "Red Pepper Paste", "12.50", "19.00", redPepperImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_SPICY, MOCK_CATEGORY_VEGAN], "Roasted red peppers with a hint of spice.");
276
+ export const MOCK_PRODUCT_ROASTED_TOMATO = createVariableProduct("prod_roasted_tomato", "Roasted Tomato Paste", "11.50", "18.50", roastedTomatoImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_VEGAN], "Deep, umami-rich tomato flavor.");
277
+ export const MOCK_PRODUCT_MINT_LEMON = createSimpleProduct("prod_mint_lemon", "Mint Lemon Paste", "12.00", lemonImg, // Reusing lemon image for now
278
+ [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_VEGAN], "Refreshing mint and lemon blend.");
279
+ export const MOCK_PRODUCT_CHILI_GARLIC = createVariableProduct("prod_chili_garlic", "Chili Garlic Paste", "10.50", "16.50", redPepperImg, // Reusing red pepper image
280
+ [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_SPICY, MOCK_CATEGORY_VEGAN], "Spicy garlic paste with chili flakes.");
281
+ export const MOCK_PRODUCT_HABANERO = createSimpleProduct("prod_habanero", "Habanero Paste", "14.00", redPepperImg, // Reusing red pepper image
282
+ [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPICY, MOCK_CATEGORY_VEGAN], "Extremely spicy habanero concentrate.");
283
+ export const MOCK_PRODUCT_BLACK_GARLIC = createSimpleProduct("prod_black_garlic", "Black Garlic Paste", "18.00", garlicImg, // Reusing garlic image
284
+ [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_VEGAN], "Fermented black garlic paste, sweet and savory.");
261
285
  // --- ORDERS ---
262
286
  // Helper to create line item
263
287
  const createLineItem = (product, variantIndex = 0, quantity = 1) => {
@@ -389,7 +413,13 @@ export const MOCK_CUSTOMERS = [
389
413
  MOCK_CUSTOMER_4,
390
414
  MOCK_CUSTOMER_5
391
415
  ];
392
- export const MOCK_CATEGORIES = [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_BASIC];
416
+ export const MOCK_CATEGORIES = [
417
+ MOCK_CATEGORY_PASTES,
418
+ MOCK_CATEGORY_SPECIALTY,
419
+ MOCK_CATEGORY_BASIC,
420
+ MOCK_CATEGORY_VEGAN,
421
+ MOCK_CATEGORY_SPICY
422
+ ];
393
423
  export const MOCK_PRODUCTS = [
394
424
  MOCK_PRODUCT_BASIL_ALMOND,
395
425
  MOCK_PRODUCT_BEER,
@@ -400,7 +430,11 @@ export const MOCK_PRODUCTS = [
400
430
  MOCK_PRODUCT_GINGER_LIME,
401
431
  MOCK_PRODUCT_LEMON,
402
432
  MOCK_PRODUCT_RED_PEPPER,
403
- MOCK_PRODUCT_ROASTED_TOMATO
433
+ MOCK_PRODUCT_ROASTED_TOMATO,
434
+ MOCK_PRODUCT_MINT_LEMON,
435
+ MOCK_PRODUCT_CHILI_GARLIC,
436
+ MOCK_PRODUCT_HABANERO,
437
+ MOCK_PRODUCT_BLACK_GARLIC
404
438
  ];
405
439
  export const MOCK_ORDERS = [MOCK_ORDER_1, MOCK_ORDER_2];
406
440
  export const MOCK_PARKED_ORDERS = [];
@@ -433,6 +467,30 @@ export const resetMockCart = () => {
433
467
  export const safeSerialize = (data) => {
434
468
  return JSON.parse(JSON.stringify(data));
435
469
  };
470
+ const mockTopicSubscribers = {};
471
+ export const mockPublishEvent = (topic, eventType, data) => {
472
+ const subscribers = mockTopicSubscribers[topic] || [];
473
+ const event = {
474
+ topic,
475
+ type: eventType,
476
+ data,
477
+ timestamp: new Date().toISOString()
478
+ };
479
+ subscribers.forEach(callback => {
480
+ try {
481
+ callback(event);
482
+ }
483
+ catch (error) {
484
+ console.error(`[Mock] Error in topic callback for ${topic}:`, error);
485
+ }
486
+ });
487
+ };
488
+ export const mockSubscribeToTopic = (topic, callback) => {
489
+ if (!mockTopicSubscribers[topic]) {
490
+ mockTopicSubscribers[topic] = [];
491
+ }
492
+ mockTopicSubscribers[topic].push(callback);
493
+ };
436
494
  // Helper to create order from cart
437
495
  export const createOrderFromCart = (paymentType, amount, processor = "cash") => {
438
496
  // Generate new Order ID
@@ -511,5 +569,7 @@ export const createOrderFromCart = (paymentType, amount, processor = "cash") =>
511
569
  };
512
570
  MOCK_ORDERS.push(newOrder);
513
571
  resetMockCart();
572
+ // Publish cart-created event after cart is reset (simulates new empty cart)
573
+ mockPublishEvent('cart', 'cart-created', {});
514
574
  return newOrder;
515
575
  };
package/dist/index.d.ts CHANGED
@@ -93,6 +93,10 @@ export type { SwitchUser, SwitchUserParams, SwitchUserResponse } from "./actions
93
93
  export type { TriggerWebhook, TriggerWebhookPresetType, TriggerWebhookParams, TriggerWebhookResponse } from "./actions/trigger-webhook/types";
94
94
  export type { TriggerZapierWebhook, TriggerZapierWebhookParams, TriggerZapierWebhookResponse } from "./actions/trigger-zapier-webhook/types";
95
95
  export * from "./CommonTypes";
96
+ export { CommandFrameProvider } from "./provider";
97
+ export type { ActionHandler, ActionHandlers } from "./provider";
98
+ export * from "./projects/render";
99
+ export * from "./projects/manage";
96
100
  export { commandFrameClient, CommandFrameClient } from "./client";
97
101
  export type { PostMessageRequest, PostMessageResponse } from "./client";
98
102
  export { topics } from "./pubsub/topic";
package/dist/index.js CHANGED
@@ -107,6 +107,12 @@ export const command = {
107
107
  };
108
108
  // Export Common Types
109
109
  export * from "./CommonTypes";
110
+ // Export Provider
111
+ export { CommandFrameProvider } from "./provider";
112
+ // Export Render Project
113
+ export * from "./projects/render";
114
+ // Export Manage Project
115
+ export * from "./projects/manage";
110
116
  // Export client
111
117
  export { commandFrameClient, CommandFrameClient } from "./client";
112
118
  // Export Pub/Sub
@@ -0,0 +1,13 @@
1
+ import { CommandFrameClient } from "../../client";
2
+ import { ManageProviderActions } from "./types";
3
+ export interface ManageClient extends ManageProviderActions {
4
+ }
5
+ export declare class ManageClient extends CommandFrameClient {
6
+ constructor(options?: {
7
+ timeout?: number;
8
+ origin?: string;
9
+ debug?: boolean;
10
+ mockMode?: boolean;
11
+ });
12
+ }
13
+ export declare const manageClient: ManageClient;
@@ -0,0 +1,13 @@
1
+ import { CommandFrameClient } from "../../client";
2
+ import { MANAGE_MOCKS } from "./mocks";
3
+ export class ManageClient extends CommandFrameClient {
4
+ constructor(options = {}) {
5
+ super({
6
+ ...options,
7
+ mockRegistry: MANAGE_MOCKS
8
+ });
9
+ }
10
+ }
11
+ export const manageClient = new ManageClient({
12
+ debug: typeof window !== "undefined" && window.__POSTMESSAGE_DEBUG__ === true
13
+ });
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./mocks";
3
+ export * from "./provider";
4
+ export * from "./client";
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./mocks";
3
+ export * from "./provider";
4
+ export * from "./client";
@@ -0,0 +1,2 @@
1
+ import { ManageProviderActions } from "./types";
2
+ export declare const MANAGE_MOCKS: ManageProviderActions;
@@ -0,0 +1,6 @@
1
+ import { mockGetContext } from "../../actions/get-context/mock";
2
+ import { mockGetFinalContext } from "../../actions/get-final-context/mock";
3
+ export const MANAGE_MOCKS = {
4
+ getContext: mockGetContext,
5
+ getFinalContext: mockGetFinalContext
6
+ };
@@ -0,0 +1,8 @@
1
+ import { CommandFrameProvider } from "../../provider";
2
+ import { ManageProviderActions } from "./types";
3
+ export declare class ManageCommandFrameProvider extends CommandFrameProvider<ManageProviderActions> {
4
+ constructor(actions: ManageProviderActions, options?: {
5
+ origin?: string;
6
+ debug?: boolean;
7
+ });
8
+ }
@@ -0,0 +1,6 @@
1
+ import { CommandFrameProvider } from "../../provider";
2
+ export class ManageCommandFrameProvider extends CommandFrameProvider {
3
+ constructor(actions, options) {
4
+ super(actions, options);
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ import type { GetContext, GetFinalContext } from "../../index";
2
+ export interface ManageProviderActions {
3
+ getContext: GetContext;
4
+ getFinalContext: GetFinalContext;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { CommandFrameClient } from "../../client";
2
+ import { RenderProviderActions } from "./types";
3
+ export interface RenderClient extends RenderProviderActions {
4
+ }
5
+ export declare class RenderClient extends CommandFrameClient {
6
+ constructor(options?: {
7
+ timeout?: number;
8
+ origin?: string;
9
+ debug?: boolean;
10
+ mockMode?: boolean;
11
+ });
12
+ }
13
+ export declare const renderClient: RenderClient;
@@ -0,0 +1,13 @@
1
+ import { CommandFrameClient } from "../../client";
2
+ import { RENDER_MOCKS } from "./mocks";
3
+ export class RenderClient extends CommandFrameClient {
4
+ constructor(options = {}) {
5
+ super({
6
+ ...options,
7
+ mockRegistry: RENDER_MOCKS
8
+ });
9
+ }
10
+ }
11
+ export const renderClient = new RenderClient({
12
+ debug: typeof window !== "undefined" && window.__POSTMESSAGE_DEBUG__ === true
13
+ });
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./mocks";
3
+ export * from "./provider";
4
+ export * from "./client";
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./mocks";
3
+ export * from "./provider";
4
+ export * from "./client";
@@ -0,0 +1,2 @@
1
+ import { RenderProviderActions } from "./types";
2
+ export declare const RENDER_MOCKS: RenderProviderActions;
@@ -0,0 +1,94 @@
1
+ import { mockAddCartDiscount } from "../../actions/add-cart-discount/mock";
2
+ import { mockAddCartFee } from "../../actions/add-cart-fee/mock";
3
+ import { mockAddCustomSale } from "../../actions/add-custom-sale/mock";
4
+ import { mockAddCustomer } from "../../actions/add-customer/mock";
5
+ import { mockAddCustomerNote } from "../../actions/add-customer-note/mock";
6
+ import { mockAddOrderNote } from "../../actions/add-order-note/mock";
7
+ import { mockAddProductDiscount } from "../../actions/add-product-discount/mock";
8
+ import { mockAddProductFee } from "../../actions/add-product-fee/mock";
9
+ import { mockAddProductNote } from "../../actions/add-product-note/mock";
10
+ import { mockAddProductToCart } from "../../actions/add-product-to-cart/mock";
11
+ import { mockAdjustInventory } from "../../actions/adjust-inventory/mock";
12
+ import { mockAssignCustomer } from "../../actions/assign-customer/mock";
13
+ import { mockAuthenticateUser } from "../../actions/authenticate-user/mock";
14
+ import { mockCalculateRefundTotal } from "../../actions/calculate-refund-total/mock";
15
+ import { mockCashPayment } from "../../actions/cash-payment/mock";
16
+ import { mockClearCart } from "../../actions/clear-cart/mock";
17
+ import { mockDeleteParkedOrder } from "../../actions/delete-parked-order/mock";
18
+ import { mockExampleFunction } from "../../actions/example-function/mock";
19
+ import { mockGetCategories } from "../../actions/get-categories/mock";
20
+ import { mockGetContext } from "../../actions/get-context/mock";
21
+ import { mockGetCurrentCart } from "../../actions/get-current-cart/mock";
22
+ import { mockGetCustomers } from "../../actions/get-customers/mock";
23
+ import { mockGetOrders } from "../../actions/get-orders/mock";
24
+ import { mockGetProducts } from "../../actions/get-products/mock";
25
+ import { mockGetRefunds } from "../../actions/get-refunds/mock";
26
+ import { mockGetRemainingRefundableQuantities } from "../../actions/get-remaining-refundable-quantities/mock";
27
+ import { mockGoToStationHome } from "../../actions/go-to-station-home/mock";
28
+ import { mockInitiateRefund } from "../../actions/initiate-refund/mock";
29
+ import { mockOpenCashDrawer } from "../../actions/open-cash-drawer/mock";
30
+ import { mockParkOrder } from "../../actions/park-order/mock";
31
+ import { mockPartialPayment } from "../../actions/partial-payment/mock";
32
+ import { mockProcessPartialRefund } from "../../actions/process-partial-refund/mock";
33
+ import { mockRemoveCustomerFromCart } from "../../actions/remove-customer-from-cart/mock";
34
+ import { mockResetRefundDetails } from "../../actions/reset-refund-details/mock";
35
+ import { mockResumeParkedOrder } from "../../actions/resume-parked-order/mock";
36
+ import { mockSelectAllRefundItems } from "../../actions/select-all-refund-items/mock";
37
+ import { mockSetRefundStockAction } from "../../actions/set-refund-stock-action/mock";
38
+ import { mockShowConfirmation } from "../../actions/show-confirmation/mock";
39
+ import { mockShowNotification } from "../../actions/show-notification/mock";
40
+ import { mockSwitchUser } from "../../actions/switch-user/mock";
41
+ import { mockTapToPayPayment } from "../../actions/tap-to-pay-payment/mock";
42
+ import { mockTerminalPayment } from "../../actions/terminal-payment/mock";
43
+ import { mockTriggerWebhook } from "../../actions/trigger-webhook/mock";
44
+ import { mockTriggerZapierWebhook } from "../../actions/trigger-zapier-webhook/mock";
45
+ import { mockVendaraPayment } from "../../actions/vendara-payment/mock";
46
+ import { mockGetFinalContext } from "../../actions/get-final-context/mock";
47
+ export const RENDER_MOCKS = {
48
+ addCartDiscount: mockAddCartDiscount,
49
+ addCartFee: mockAddCartFee,
50
+ addCustomSale: mockAddCustomSale,
51
+ addCustomer: mockAddCustomer,
52
+ addCustomerNote: mockAddCustomerNote,
53
+ addOrderNote: mockAddOrderNote,
54
+ addProductDiscount: mockAddProductDiscount,
55
+ addProductFee: mockAddProductFee,
56
+ addProductNote: mockAddProductNote,
57
+ addProductToCart: mockAddProductToCart,
58
+ adjustInventory: mockAdjustInventory,
59
+ assignCustomer: mockAssignCustomer,
60
+ authenticateUser: mockAuthenticateUser,
61
+ calculateRefundTotal: mockCalculateRefundTotal,
62
+ cashPayment: mockCashPayment,
63
+ clearCart: mockClearCart,
64
+ deleteParkedOrder: mockDeleteParkedOrder,
65
+ exampleFunction: mockExampleFunction,
66
+ getCategories: mockGetCategories,
67
+ getContext: mockGetContext,
68
+ getCurrentCart: mockGetCurrentCart,
69
+ getCustomers: mockGetCustomers,
70
+ getOrders: mockGetOrders,
71
+ getProducts: mockGetProducts,
72
+ getRefunds: mockGetRefunds,
73
+ getRemainingRefundableQuantities: mockGetRemainingRefundableQuantities,
74
+ goToStationHome: mockGoToStationHome,
75
+ initiateRefund: mockInitiateRefund,
76
+ openCashDrawer: mockOpenCashDrawer,
77
+ parkOrder: mockParkOrder,
78
+ partialPayment: mockPartialPayment,
79
+ processPartialRefund: mockProcessPartialRefund,
80
+ removeCustomerFromCart: mockRemoveCustomerFromCart,
81
+ resetRefundDetails: mockResetRefundDetails,
82
+ resumeParkedOrder: mockResumeParkedOrder,
83
+ selectAllRefundItems: mockSelectAllRefundItems,
84
+ setRefundStockAction: mockSetRefundStockAction,
85
+ showConfirmation: mockShowConfirmation,
86
+ showNotification: mockShowNotification,
87
+ switchUser: mockSwitchUser,
88
+ tapToPayPayment: mockTapToPayPayment,
89
+ terminalPayment: mockTerminalPayment,
90
+ triggerWebhook: mockTriggerWebhook,
91
+ triggerZapierWebhook: mockTriggerZapierWebhook,
92
+ vendaraPayment: mockVendaraPayment,
93
+ getFinalContext: mockGetFinalContext,
94
+ };
@@ -0,0 +1,8 @@
1
+ import { CommandFrameProvider } from "../../provider";
2
+ import { RenderProviderActions } from "./types";
3
+ export declare class RenderCommandFrameProvider extends CommandFrameProvider<RenderProviderActions> {
4
+ constructor(actions: RenderProviderActions, options?: {
5
+ origin?: string;
6
+ debug?: boolean;
7
+ });
8
+ }
@@ -0,0 +1,6 @@
1
+ import { CommandFrameProvider } from "../../provider";
2
+ export class RenderCommandFrameProvider extends CommandFrameProvider {
3
+ constructor(actions, options) {
4
+ super(actions, options);
5
+ }
6
+ }
@@ -0,0 +1,49 @@
1
+ import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, GetCategories, GetOrders, GetRefunds, AddProductDiscount, AddProductToCart, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, InitiateRefund, CashPayment, TapToPayPayment, TerminalPayment, VendaraPayment, AddCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, TriggerWebhook, TriggerZapierWebhook, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart } from "../../index";
2
+ export interface RenderProviderActions {
3
+ exampleFunction: ExampleFunction;
4
+ getProducts: GetProducts;
5
+ addCustomSale: AddCustomSale;
6
+ getCustomers: GetCustomers;
7
+ assignCustomer: AssignCustomer;
8
+ addCustomer: AddCustomer;
9
+ getCategories: GetCategories;
10
+ getOrders: GetOrders;
11
+ getRefunds: GetRefunds;
12
+ addProductDiscount: AddProductDiscount;
13
+ addProductToCart: AddProductToCart;
14
+ addCartDiscount: AddCartDiscount;
15
+ getContext: GetContext;
16
+ getFinalContext: GetFinalContext;
17
+ addProductNote: AddProductNote;
18
+ addProductFee: AddProductFee;
19
+ adjustInventory: AdjustInventory;
20
+ addOrderNote: AddOrderNote;
21
+ addCartFee: AddCartFee;
22
+ clearCart: ClearCart;
23
+ parkOrder: ParkOrder;
24
+ resumeParkedOrder: ResumeParkedOrder;
25
+ deleteParkedOrder: DeleteParkedOrder;
26
+ initiateRefund: InitiateRefund;
27
+ cashPayment: CashPayment;
28
+ tapToPayPayment: TapToPayPayment;
29
+ terminalPayment: TerminalPayment;
30
+ vendaraPayment: VendaraPayment;
31
+ addCustomerNote: AddCustomerNote;
32
+ removeCustomerFromCart: RemoveCustomerFromCart;
33
+ goToStationHome: GoToStationHome;
34
+ openCashDrawer: OpenCashDrawer;
35
+ showNotification: ShowNotification;
36
+ showConfirmation: ShowConfirmation;
37
+ authenticateUser: AuthenticateUser;
38
+ partialPayment: PartialPayment;
39
+ switchUser: SwitchUser;
40
+ triggerWebhook: TriggerWebhook;
41
+ triggerZapierWebhook: TriggerZapierWebhook;
42
+ setRefundStockAction: SetRefundStockAction;
43
+ selectAllRefundItems: SelectAllRefundItems;
44
+ resetRefundDetails: ResetRefundDetails;
45
+ calculateRefundTotal: CalculateRefundTotal;
46
+ getRemainingRefundableQuantities: GetRemainingRefundableQuantities;
47
+ processPartialRefund: ProcessPartialRefund;
48
+ getCurrentCart: GetCurrentCart;
49
+ }
@@ -0,0 +1 @@
1
+ export {};