@final-commerce/command-frame 0.1.6 → 0.1.8

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 (36) hide show
  1. package/README.md +86 -373
  2. package/dist/actions/add-custom-sale/mock.js +3 -0
  3. package/dist/actions/add-custom-sale/types.d.ts +1 -0
  4. package/dist/actions/add-product-discount/mock.js +1 -0
  5. package/dist/actions/add-product-discount/types.d.ts +2 -0
  6. package/dist/actions/add-product-fee/mock.js +1 -0
  7. package/dist/actions/add-product-fee/types.d.ts +2 -0
  8. package/dist/actions/add-product-note/mock.js +1 -0
  9. package/dist/actions/add-product-note/types.d.ts +2 -0
  10. package/dist/actions/add-product-to-cart/mock.js +20 -16
  11. package/dist/actions/add-product-to-cart/types.d.ts +6 -1
  12. package/dist/actions/adjust-inventory/types.d.ts +1 -0
  13. package/dist/actions/calculate-refund-total/mock.js +2 -2
  14. package/dist/actions/calculate-refund-total/types.d.ts +4 -1
  15. package/dist/actions/get-final-context/mock.d.ts +2 -0
  16. package/dist/actions/get-final-context/mock.js +6 -0
  17. package/dist/actions/get-remaining-refundable-quantities/mock.js +2 -2
  18. package/dist/actions/get-remaining-refundable-quantities/types.d.ts +4 -1
  19. package/dist/actions/process-partial-refund/mock.js +1 -1
  20. package/dist/actions/process-partial-refund/types.d.ts +6 -0
  21. package/dist/actions/select-all-refund-items/mock.js +2 -2
  22. package/dist/actions/select-all-refund-items/types.d.ts +4 -1
  23. package/dist/actions/set-refund-stock-action/mock.js +1 -0
  24. package/dist/actions/set-refund-stock-action/types.d.ts +2 -0
  25. package/dist/actions/trigger-webhook/types.d.ts +3 -2
  26. package/dist/actions/trigger-webhook/types.js +1 -0
  27. package/dist/demo/registry.js +2 -2
  28. package/dist/index.d.ts +5 -6
  29. package/dist/index.js +2 -2
  30. package/package.json +1 -1
  31. package/dist/actions/set-product-active/action.d.ts +0 -6
  32. package/dist/actions/set-product-active/action.js +0 -8
  33. package/dist/actions/set-product-active/mock.d.ts +0 -2
  34. package/dist/actions/set-product-active/mock.js +0 -8
  35. package/dist/actions/set-product-active/types.d.ts +0 -9
  36. package/dist/actions/set-product-active/types.js +0 -1
package/README.md CHANGED
@@ -14,7 +14,8 @@ This package is available on the public NPM registry.
14
14
 
15
15
  - [API Overview](#api-overview)
16
16
  - [Quick Start](#quick-start)
17
- - [Actions Documentation](#actions-documentation)
17
+ - [Commands Documentation](#commands-documentation)
18
+ - [Pub/Sub System](#pubsub-system)
18
19
  - [Examples](#examples)
19
20
  - [Debugging](#debugging)
20
21
  - [Type Safety](#type-safety)
@@ -22,9 +23,9 @@ This package is available on the public NPM registry.
22
23
 
23
24
  ## API Overview
24
25
 
25
- The library provides a `command` namespace object containing all available actions. Each action is a typed function that communicates with the parent window via postMessage.
26
+ The library provides a `command` namespace object containing all available commands. Each command is a typed function that communicates with the parent window via postMessage.
26
27
 
27
- ### Available Actions
28
+ ### Available Commands
28
29
 
29
30
  #### Data Retrieval
30
31
  - **[getCustomers](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-customers/README.md)** - Retrieve a list of customers from the parent application
@@ -37,12 +38,11 @@ The library provides a `command` namespace object containing all available actio
37
38
  - **[getFinalContext](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-final-context/README.md)** - Get final context information (project name)
38
39
 
39
40
  #### Product Actions
40
- - **[setProductActive](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/set-product-active/README.md)** - Set a product variant as the active product
41
- - **[addProductDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-discount/README.md)** - Add a discount to the currently active product
42
- - **[addProductToCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-to-cart/README.md)** - Add the currently active product to the cart
43
- - **[addProductNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-note/README.md)** - Add a note to the currently active product
44
- - **[addProductFee](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-fee/README.md)** - Add a fee to the currently active product
45
- - **[adjustInventory](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/adjust-inventory/README.md)** - Adjust inventory/stock level for the currently active product
41
+ - **[addProductToCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-to-cart/README.md)** - Add a product to the cart with optional discounts, fees, and notes
42
+ - **[addProductDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-discount/README.md)** - Add a discount to a specific product in the cart (using `cartItemId`)
43
+ - **[addProductNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-note/README.md)** - Add a note to a specific product in the cart (using `cartItemId`)
44
+ - **[addProductFee](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-fee/README.md)** - Add a fee to a specific product in the cart (using `cartItemId`)
45
+ - **[adjustInventory](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/adjust-inventory/README.md)** - Adjust inventory/stock level for a specific product variant
46
46
 
47
47
  #### Order Actions
48
48
  - **[addCustomSale](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-custom-sale/README.md)** - Add a custom sale item to the cart
@@ -94,7 +94,7 @@ The library provides a `command` namespace object containing all available actio
94
94
  #### Reference
95
95
  - **[exampleFunction](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/example-function/README.md)** - Example/template function (for reference only)
96
96
 
97
- For detailed documentation on each action, including parameter descriptions, response structures, and usage examples, see the [Actions Documentation](#actions-documentation) section below.
97
+ For detailed documentation on each command, including parameter descriptions, response structures, and usage examples, see the [Commands Documentation](#commands-documentation) section below.
98
98
 
99
99
  ## Quick Start
100
100
 
@@ -115,19 +115,24 @@ const variants = await command.getProductVariants({
115
115
  productId: '691df9c6c478bada1fb23d31'
116
116
  });
117
117
 
118
- // Set a variant as active, add discount, then add to cart
119
- await command.setProductActive({
120
- variantId: '691df9c6c478bada1fb23d55'
118
+ // Add product to cart with optional discounts and fees
119
+ const addedProduct = await command.addProductToCart({
120
+ variantId: '691df9c6c478bada1fb23d55',
121
+ quantity: 1,
122
+ discounts: [{
123
+ amount: 10,
124
+ isPercent: false,
125
+ label: 'Discount'
126
+ }],
127
+ notes: 'No onions'
121
128
  });
122
129
 
130
+ // Add a discount to the specific item just added (if you didn't add it during creation)
123
131
  await command.addProductDiscount({
124
- amount: 10,
125
- isPercent: false,
126
- label: 'Discount'
127
- });
128
-
129
- await command.addProductToCart({
130
- quantity: 1
132
+ cartItemId: addedProduct.internalId,
133
+ amount: 5,
134
+ isPercent: true,
135
+ label: 'Extra 5% Off'
131
136
  });
132
137
 
133
138
  // Add cart discount
@@ -144,347 +149,12 @@ console.log('Current company:', context.companyName);
144
149
  console.log('Current build:', context.buildName);
145
150
  ```
146
151
 
147
- For complete usage examples and detailed parameter descriptions, see the documentation for each action in the [Actions Documentation](#actions-documentation) section.
148
-
149
- ## Pub/Sub System
150
-
151
- The library includes a pub/sub system that allows iframe apps to subscribe to topics and receive events published by the host application (Render).
152
-
153
- ### Quick Start - Pub/Sub
154
-
155
- ```typescript
156
- import { topics } from '@final-commerce/command-frame';
157
-
158
- // Get available topics
159
- const availableTopics = await topics.getTopics();
160
- console.log('Available topics:', availableTopics);
161
-
162
- // Subscribe to a topic with a callback
163
- const subscriptionId = topics.subscribe('customers', (event) => {
164
- if (event.type === 'customer-created') {
165
- console.log('New customer created:', event.data);
166
- // Handle the event
167
- }
168
- });
169
-
170
- // Later, unsubscribe when done
171
- topics.unsubscribe('customers', subscriptionId);
172
- ```
173
-
174
- ### Pub/Sub API
175
-
176
- #### `topics.getTopics()`
177
-
178
- Retrieves the list of available topics from the host application.
179
-
180
- **Returns:** `Promise<TopicDefinition[]>`
181
-
182
- **Example:**
183
- ```typescript
184
- const topics = await topics.getTopics();
185
- topics.forEach(topic => {
186
- console.log(`Topic: ${topic.name} (${topic.id})`);
187
- console.log(`Event types: ${topic.eventTypes.map(et => et.id).join(', ')}`);
188
- });
189
- ```
190
-
191
- #### `topics.subscribe(topic, callback)`
152
+ For complete usage examples and detailed parameter descriptions, see the documentation for each command in the [Commands Documentation](#commands-documentation) section.
192
153
 
193
- Subscribes to a topic and receives events via the callback function.
194
154
 
195
- **Parameters:**
196
- - `topic: string` - The topic ID to subscribe to
197
- - `callback: (event: TopicEvent) => void` - Function called when an event is received
155
+ ## Commands Documentation
198
156
 
199
- **Returns:** `string` - Subscription ID (use this to unsubscribe)
200
-
201
- **Example:**
202
- ```typescript
203
- const subscriptionId = topics.subscribe('customers', (event) => {
204
- console.log('Received event:', event.type);
205
- console.log('Event data:', event.data);
206
- console.log('Timestamp:', event.timestamp);
207
- });
208
- ```
209
-
210
- #### `topics.unsubscribe(topic, subscriptionId)`
211
-
212
- Unsubscribes from a topic using the subscription ID returned from `subscribe()`.
213
-
214
- **Parameters:**
215
- - `topic: string` - The topic ID
216
- - `subscriptionId: string` - The subscription ID returned from `subscribe()`
217
-
218
- **Returns:** `boolean` - `true` if successfully unsubscribed
219
-
220
- **Example:**
221
- ```typescript
222
- const success = topics.unsubscribe('customers', subscriptionId);
223
- ```
224
-
225
- #### `topics.unsubscribeAll(topic)`
226
-
227
- Unsubscribes all callbacks for a specific topic.
228
-
229
- **Parameters:**
230
- - `topic: string` - The topic ID
231
-
232
- **Returns:** `number` - Number of subscriptions removed
233
-
234
- **Example:**
235
- ```typescript
236
- const removed = topics.unsubscribeAll('customers');
237
- console.log(`Removed ${removed} subscriptions`);
238
- ```
239
-
240
- ### Topic and Event Types
241
-
242
- ```typescript
243
- interface TopicDefinition {
244
- id: string;
245
- name: string;
246
- description?: string;
247
- eventTypes: TopicEventType[];
248
- }
249
-
250
- interface TopicEvent<T = any> {
251
- topic: string;
252
- type: string;
253
- data: T;
254
- timestamp: string;
255
- }
256
- ```
257
-
258
- ### Example: React Component with Pub/Sub
259
-
260
- ```typescript
261
- import { useEffect, useState } from 'react';
262
- import { topics, type TopicEvent } from '@final-commerce/command-frame';
263
-
264
- function CustomerEvents() {
265
- const [events, setEvents] = useState<TopicEvent[]>([]);
266
-
267
- useEffect(() => {
268
- // Subscribe on mount
269
- const subscriptionId = topics.subscribe('customers', (event) => {
270
- if (event.type === 'customer-created') {
271
- setEvents(prev => [event, ...prev]);
272
- }
273
- });
274
-
275
- // Unsubscribe on unmount
276
- return () => {
277
- topics.unsubscribe('customers', subscriptionId);
278
- };
279
- }, []);
280
-
281
- return (
282
- <div>
283
- <h2>Customer Events ({events.length})</h2>
284
- {events.map((event, index) => (
285
- <div key={index}>
286
- <p>Type: {event.type}</p>
287
- <pre>{JSON.stringify(event.data, null, 2)}</pre>
288
- </div>
289
- ))}
290
- </div>
291
- );
292
- }
293
- ```
294
-
295
- ### Available Topics
296
-
297
- #### Customers Topic (`customers`)
298
-
299
- The customers topic provides events related to customer lifecycle and cart assignment.
300
-
301
- **Event Types:**
302
-
303
- 1. **`customer-created`** - Fired when a new customer is created
304
- - **Event Data:**
305
- ```typescript
306
- {
307
- customer: {
308
- _id: string;
309
- companyId: string;
310
- email: string;
311
- firstName: string;
312
- lastName: string;
313
- phone?: string;
314
- tags?: string[];
315
- metadata?: Record<string, string>[];
316
- notes?: CustomerNote[];
317
- billing: Address | null;
318
- shipping: Address | null;
319
- createdAt: string;
320
- updatedAt: string;
321
- // ... other customer fields
322
- }
323
- }
324
- ```
325
-
326
- 2. **`customer-updated`** - Fired when a customer's information is updated
327
- - **Event Data:**
328
- ```typescript
329
- {
330
- customer: {
331
- // Updated customer object with all fields
332
- }
333
- }
334
- ```
335
-
336
- 3. **`customer-note-added`** - Fired when a note is added to a customer
337
- - **Event Data:**
338
- ```typescript
339
- {
340
- customer: {
341
- // Customer object with updated notes array
342
- },
343
- note: {
344
- createdAt: string;
345
- message: string;
346
- }
347
- }
348
- ```
349
-
350
- 4. **`customer-note-deleted`** - Fired when a note is deleted from a customer
351
- - **Event Data:**
352
- ```typescript
353
- {
354
- customer: {
355
- // Customer object with updated notes array
356
- },
357
- note: {
358
- createdAt: string;
359
- message: string;
360
- }
361
- }
362
- ```
363
-
364
- 5. **`customer-assigned`** - Fired when a customer is assigned to the cart
365
- - **Event Data:**
366
- ```typescript
367
- {
368
- customer: {
369
- // Full customer object
370
- }
371
- }
372
- ```
373
-
374
- 6. **`customer-unassigned`** - Fired when a customer is unassigned from the cart
375
- - **Event Data:**
376
- ```typescript
377
- {
378
- customer: {
379
- // Full customer object (before removal)
380
- }
381
- }
382
- ```
383
-
384
- **Example: Subscribing to Customer Events**
385
-
386
- ```typescript
387
- import { topics, type TopicEvent } from '@final-commerce/command-frame';
388
-
389
- // Subscribe to all customer events
390
- const subscriptionId = topics.subscribe('customers', (event: TopicEvent) => {
391
- switch (event.type) {
392
- case 'customer-created':
393
- console.log('New customer created:', event.data.customer);
394
- // Update your customer list, show notification, etc.
395
- break;
396
-
397
- case 'customer-updated':
398
- console.log('Customer updated:', event.data.customer);
399
- // Refresh customer details in your UI
400
- break;
401
-
402
- case 'customer-note-added':
403
- console.log('Note added to customer:', event.data.customer._id);
404
- console.log('Note:', event.data.note);
405
- // Update customer notes display
406
- break;
407
-
408
- case 'customer-note-deleted':
409
- console.log('Note deleted from customer:', event.data.customer._id);
410
- // Update customer notes display
411
- break;
412
-
413
- case 'customer-assigned':
414
- console.log('Customer assigned to cart:', event.data.customer);
415
- // Update cart UI to show customer info
416
- break;
417
-
418
- case 'customer-unassigned':
419
- console.log('Customer unassigned from cart:', event.data.customer);
420
- // Clear customer info from cart UI
421
- break;
422
- }
423
- });
424
-
425
- // Later, unsubscribe
426
- topics.unsubscribe('customers', subscriptionId);
427
- ```
428
-
429
- **Example: Filtering Specific Event Types**
430
-
431
- ```typescript
432
- import { topics, type TopicEvent } from '@final-commerce/command-frame';
433
-
434
- // Only listen for customer assignment/unassignment
435
- const subscriptionId = topics.subscribe('customers', (event: TopicEvent) => {
436
- if (event.type === 'customer-assigned' || event.type === 'customer-unassigned') {
437
- console.log(`Customer ${event.type}:`, event.data.customer);
438
- // Update your cart UI accordingly
439
- }
440
- });
441
- ```
442
-
443
- ### Host Application (Render) - Publishing Events
444
-
445
- In the Render application, use the `topicPublisher` to publish events:
446
-
447
- ```typescript
448
- import { topicPublisher } from '@render/command-frame';
449
-
450
- // When a customer is created
451
- topicPublisher.publish('customers', 'customer-created', {
452
- customer: newCustomer
453
- });
454
-
455
- // When a customer is updated
456
- topicPublisher.publish('customers', 'customer-updated', {
457
- customer: updatedCustomer
458
- });
459
-
460
- // When a note is added to a customer
461
- topicPublisher.publish('customers', 'customer-note-added', {
462
- customer: updatedCustomer,
463
- note: newNote
464
- });
465
-
466
- // When a note is deleted from a customer
467
- topicPublisher.publish('customers', 'customer-note-deleted', {
468
- customer: updatedCustomer,
469
- note: deletedNote
470
- });
471
-
472
- // When a customer is assigned to the cart
473
- topicPublisher.publish('customers', 'customer-assigned', {
474
- customer: customer
475
- });
476
-
477
- // When a customer is unassigned from the cart
478
- topicPublisher.publish('customers', 'customer-unassigned', {
479
- customer: customer
480
- });
481
- ```
482
-
483
- The host application must register topics before they can be used. Topics are registered automatically when the `TopicPublisher` is initialized. See the Render application's pub/sub implementation for details on topic registration.
484
-
485
- ## Actions Documentation
486
-
487
- Each action has detailed documentation with complete parameter descriptions, response structures, and multiple usage examples:
157
+ Each command has detailed documentation with complete parameter descriptions, response structures, and multiple usage examples:
488
158
 
489
159
  ### [getCustomers](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-customers/README.md)
490
160
 
@@ -522,17 +192,13 @@ Retrieves the current cart object with all its contents including products, cust
522
192
 
523
193
  Adds a custom sale item to the cart in the parent window. Useful for adding non-product items like service fees, discounts, or custom charges.
524
194
 
525
- ### [setProductActive](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/set-product-active/README.md)
195
+ ### [addProductToCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-to-cart/README.md)
526
196
 
527
- Sets a product variant as the active product in the parent application. Required before adding discounts or adding products to cart.
197
+ Adds a product to the cart. Supports specifying quantity, applying discounts, fees, and notes in a single atomic operation.
528
198
 
529
199
  ### [addProductDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-discount/README.md)
530
200
 
531
- Adds a discount to the currently active product. Supports both fixed amount and percentage discounts. The product must be set as active first.
532
-
533
- ### [addProductToCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-to-cart/README.md)
534
-
535
- Adds the currently active product to the cart. Supports specifying quantity. The product must be set as active first.
201
+ Adds a discount to a specific product in the cart (identified by `cartItemId`). Supports both fixed amount and percentage discounts.
536
202
 
537
203
  ### [addCartDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-cart-discount/README.md)
538
204
 
@@ -546,15 +212,15 @@ Retrieves the current environment/context information from the parent applicatio
546
212
 
547
213
  ### [addProductNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-note/README.md)
548
214
 
549
- Adds a note to the currently active product in the cart. Requires a product to be set as active first.
215
+ Adds a note to a specific product in the cart (identified by `cartItemId`).
550
216
 
551
217
  ### [addProductFee](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-fee/README.md)
552
218
 
553
- Adds a fee to the currently active product. Supports both fixed amount and percentage-based fees. Requires a product to be set as active first.
219
+ Adds a fee to a specific product in the cart (identified by `cartItemId`). Supports both fixed amount and percentage-based fees.
554
220
 
555
221
  ### [adjustInventory](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/adjust-inventory/README.md)
556
222
 
557
- Adjusts the inventory/stock level for the currently active product. Supports adding, subtracting, or setting stock to a specific value.
223
+ Adjusts the inventory/stock level for a specific product variant. Supports adding, subtracting, or setting stock to a specific value.
558
224
 
559
225
  ### Order Actions
560
226
 
@@ -702,7 +368,55 @@ Triggers a Zapier webhook with the current context data (cart, customer, order,
702
368
 
703
369
  ### [exampleFunction](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/example-function/README.md)
704
370
 
705
- An example/template function for reference. See the documentation for the structure to follow when creating new actions.
371
+ An example/template function for reference. See the documentation for the structure to follow when creating new commands.
372
+
373
+ ## Pub/Sub System
374
+
375
+ The library includes a pub/sub system that allows iframe apps to subscribe to topics and receive events published by the host application (Render).
376
+
377
+ ### Available Topics
378
+
379
+ #### Customer Events
380
+ - **[customers](https://github.com/Final-Commerce/command-frame/blob/main/src/pubsub/topics/customers/README.md)** - Customer lifecycle events
381
+ - `customer-created` - Fired when a new customer is created
382
+ - `customer-updated` - Fired when a customer's information is updated
383
+ - `customer-note-added` - Fired when a note is added to a customer
384
+ - `customer-note-deleted` - Fired when a note is deleted from a customer
385
+ - `customer-assigned` - Fired when a customer is assigned to the cart
386
+ - `customer-unassigned` - Fired when a customer is unassigned from the cart
387
+
388
+ #### Order Events
389
+ - **[orders](https://github.com/Final-Commerce/command-frame/blob/main/src/pubsub/topics/orders/README.md)** - Order lifecycle events
390
+ - `order-created` - Fired when a new order is created
391
+ - `order-updated` - Fired when an order is updated
392
+
393
+ #### Refund Events
394
+ - **[refunds](https://github.com/Final-Commerce/command-frame/blob/main/src/pubsub/topics/refunds/README.md)** - Refund lifecycle events
395
+ - `refund-created` - Fired when a refund is created
396
+ - `refund-updated` - Fired when a refund is updated
397
+
398
+ #### Product Events
399
+ - **[products](https://github.com/Final-Commerce/command-frame/blob/main/src/pubsub/topics/products/README.md)** - Product sync events
400
+ - `product-created` - Fired when a product is created
401
+ - `product-updated` - Fired when a product is updated
402
+
403
+ #### Cart Events
404
+ - **[cart](https://github.com/Final-Commerce/command-frame/blob/main/src/pubsub/topics/cart/README.md)** - Cart operation events
405
+ - `cart-created` - Fired when a cart is created
406
+ - `customer-assigned` - Fired when a customer is assigned to the cart
407
+ - `product-added` - Fired when a product is added to the cart
408
+ - `product-deleted` - Fired when a product is removed from the cart
409
+ - `cart-discount-added` - Fired when a discount is added to the cart
410
+ - `cart-discount-removed` - Fired when a discount is removed from the cart
411
+ - `cart-fee-added` - Fired when a fee is added to the cart
412
+ - `cart-fee-removed` - Fired when a fee is removed from the cart
413
+
414
+ #### Payment Events
415
+ - **[payments](https://github.com/Final-Commerce/command-frame/blob/main/src/pubsub/topics/payments/README.md)** - Payment processing events
416
+ - `payment-done` - Fired when a payment is successfully completed
417
+ - `payment-err` - Fired when a payment fails
418
+
419
+ For detailed documentation on each topic and its events, including payload structures and usage examples, see the [Pub/Sub Documentation](https://github.com/Final-Commerce/command-frame/blob/main/src/pubsub/README.md).
706
420
 
707
421
  ## Examples
708
422
 
@@ -733,7 +447,7 @@ This will log all postMessage communication to the console, including:
733
447
 
734
448
  ## Type Safety
735
449
 
736
- All actions are fully typed with TypeScript. Import types for use in your code:
450
+ All commands are fully typed with TypeScript. Import types for use in your code:
737
451
 
738
452
  ```typescript
739
453
  import type {
@@ -747,7 +461,6 @@ import type {
747
461
  GetFinalContext, GetFinalContextResponse,
748
462
  GetCurrentCart, GetCurrentCartResponse,
749
463
  // Product Actions
750
- SetProductActiveParams, SetProductActiveResponse, SetProductActive,
751
464
  AddProductDiscountParams, AddProductDiscountResponse, AddProductDiscount,
752
465
  AddProductToCartParams, AddProductToCartResponse, AddProductToCart,
753
466
  AddProductNoteParams, AddProductNoteResponse, AddProductNote,
@@ -786,12 +499,12 @@ import type {
786
499
  SwitchUserParams, SwitchUserResponse, SwitchUser,
787
500
  // Refund Actions
788
501
  GetLineItemsByOrderParams, GetLineItemsByOrderResponse, GetLineItemsByOrder,
789
- SelectAllRefundItemsResponse, SelectAllRefundItems,
502
+ SelectAllRefundItemsParams, SelectAllRefundItemsResponse, SelectAllRefundItems,
790
503
  ResetRefundDetailsResponse, ResetRefundDetails,
791
504
  SetRefundStockActionParams, SetRefundStockActionResponse, SetRefundStockAction,
792
505
  CalculateRefundTotalResponse, CalculateRefundTotal,
793
506
  ProcessPartialRefundParams, ProcessPartialRefundResponse, ProcessPartialRefund,
794
- GetRemainingRefundableQuantitiesResponse, GetRemainingRefundableQuantities,
507
+ GetRemainingRefundableQuantitiesParams, GetRemainingRefundableQuantitiesResponse, GetRemainingRefundableQuantities,
795
508
  // Integration Actions
796
509
  TriggerWebhookParams, TriggerWebhookResponse, TriggerWebhook,
797
510
  TriggerZapierWebhookParams, TriggerZapierWebhookResponse, TriggerZapierWebhook,
@@ -2,8 +2,11 @@ export const mockAddCustomSale = async (params) => {
2
2
  console.log("[Mock] addCustomSale called", params);
3
3
  if (!params)
4
4
  throw new Error("Params required");
5
+ // Simple mock ID generation
6
+ const mockId = 'sale_' + Math.random().toString(36).substr(2, 9);
5
7
  return {
6
8
  success: true,
9
+ customSaleId: mockId,
7
10
  label: params.label,
8
11
  price: Number(params.price),
9
12
  applyTaxes: params.applyTaxes ?? false,
@@ -5,6 +5,7 @@ export interface AddCustomSaleParams {
5
5
  }
6
6
  export interface AddCustomSaleResponse {
7
7
  success: boolean;
8
+ customSaleId: string;
8
9
  label: string;
9
10
  price: number;
10
11
  applyTaxes: boolean;
@@ -5,6 +5,7 @@ export const mockAddProductDiscount = async (params) => {
5
5
  amount: params?.amount || 0,
6
6
  isPercent: params?.isPercent || false,
7
7
  label: params?.label || "",
8
+ cartItemId: params?.cartItemId,
8
9
  timestamp: new Date().toISOString()
9
10
  };
10
11
  };
@@ -2,12 +2,14 @@ export interface AddProductDiscountParams {
2
2
  amount: number;
3
3
  isPercent?: boolean;
4
4
  label?: string;
5
+ cartItemId?: string;
5
6
  }
6
7
  export interface AddProductDiscountResponse {
7
8
  success: boolean;
8
9
  amount: number;
9
10
  isPercent: boolean;
10
11
  label: string;
12
+ cartItemId?: string;
11
13
  timestamp: string;
12
14
  }
13
15
  export type AddProductDiscount = (params?: AddProductDiscountParams) => Promise<AddProductDiscountResponse>;
@@ -6,6 +6,7 @@ export const mockAddProductFee = async (params) => {
6
6
  isPercent: params?.isPercent || false,
7
7
  label: params?.label || "",
8
8
  applyTaxes: params?.applyTaxes || false,
9
+ cartItemId: params?.cartItemId,
9
10
  timestamp: new Date().toISOString()
10
11
  };
11
12
  };
@@ -4,6 +4,7 @@ export interface AddProductFeeParams {
4
4
  label?: string;
5
5
  applyTaxes?: boolean;
6
6
  taxTableId?: string;
7
+ cartItemId?: string;
7
8
  }
8
9
  export interface AddProductFeeResponse {
9
10
  success: boolean;
@@ -11,6 +12,7 @@ export interface AddProductFeeResponse {
11
12
  isPercent: boolean;
12
13
  label: string;
13
14
  applyTaxes: boolean;
15
+ cartItemId?: string;
14
16
  timestamp: string;
15
17
  }
16
18
  export type AddProductFee = (params?: AddProductFeeParams) => Promise<AddProductFeeResponse>;
@@ -3,6 +3,7 @@ export const mockAddProductNote = async (params) => {
3
3
  return {
4
4
  success: true,
5
5
  note: params?.note || "",
6
+ cartItemId: params?.cartItemId,
6
7
  timestamp: new Date().toISOString()
7
8
  };
8
9
  };
@@ -1,9 +1,11 @@
1
1
  export interface AddProductNoteParams {
2
2
  note: string;
3
+ cartItemId?: string;
3
4
  }
4
5
  export interface AddProductNoteResponse {
5
6
  success: boolean;
6
7
  note: string;
8
+ cartItemId?: string;
7
9
  timestamp: string;
8
10
  }
9
11
  export type AddProductNote = (params?: AddProductNoteParams) => Promise<AddProductNoteResponse>;
@@ -1,32 +1,33 @@
1
1
  import { MOCK_CART, MOCK_PRODUCTS } from "../../demo/database";
2
2
  export const mockAddProductToCart = async (params) => {
3
3
  console.log("[Mock] addProductToCart called", params);
4
- const productId = params?.productId;
5
4
  const variantId = params?.variantId;
6
5
  const quantity = params?.quantity || 1;
7
6
  let product = MOCK_PRODUCTS[0]; // Default fallback
8
- if (productId) {
9
- const found = MOCK_PRODUCTS.find(p => p._id === productId);
10
- if (found) {
11
- product = found;
12
- }
13
- else {
14
- console.warn(`[Mock] Product with ID ${productId} not found, using default.`);
15
- }
16
- }
17
- // Determine variant
18
7
  let variant = product.variants[0];
8
+ // Determine variant and product from variantId
19
9
  if (variantId) {
20
- const foundVariant = product.variants.find(v => v._id === variantId);
21
- if (foundVariant) {
22
- variant = foundVariant;
10
+ // Search through all products to find the one containing this variant
11
+ for (const p of MOCK_PRODUCTS) {
12
+ const foundVariant = p.variants.find(v => v._id === variantId);
13
+ if (foundVariant) {
14
+ product = p;
15
+ variant = foundVariant;
16
+ break;
17
+ }
23
18
  }
24
19
  }
25
20
  // Add to MOCK_CART
21
+ const internalId = product._id + "_" + Date.now();
22
+ // Process optional fields for mock
23
+ let note = undefined;
24
+ if (params?.notes) {
25
+ note = Array.isArray(params.notes) ? params.notes.join(", ") : params.notes;
26
+ }
26
27
  const activeProduct = {
27
28
  ...product,
28
29
  id: product._id,
29
- internalId: product._id + "_" + Date.now(), // unique ID for cart item
30
+ internalId: internalId, // unique ID for cart item
30
31
  variantId: variant._id,
31
32
  quantity: quantity,
32
33
  price: Number(variant.price),
@@ -35,7 +36,9 @@ export const mockAddProductToCart = async (params) => {
35
36
  images: product.images || [],
36
37
  localQuantity: quantity,
37
38
  sku: variant.sku,
38
- attributes: variant.attributes.map(a => `${a.name}: ${a.value}`).join(", ")
39
+ attributes: variant.attributes.map(a => `${a.name}: ${a.value}`).join(", "),
40
+ note: note
41
+ // discount/fee could be added here to mock object if CFActiveProduct supports it
39
42
  };
40
43
  MOCK_CART.products.push(activeProduct);
41
44
  // Recalculate totals
@@ -49,6 +52,7 @@ export const mockAddProductToCart = async (params) => {
49
52
  success: true,
50
53
  productId: activeProduct.id,
51
54
  variantId: activeProduct.variantId,
55
+ internalId: activeProduct.internalId,
52
56
  name: activeProduct.name,
53
57
  quantity: quantity,
54
58
  timestamp: new Date().toISOString()
@@ -1,12 +1,17 @@
1
+ import type { AddProductDiscountParams } from "../add-product-discount/types";
2
+ import type { AddProductFeeParams } from "../add-product-fee/types";
1
3
  export interface AddProductToCartParams {
2
- productId?: string;
3
4
  variantId?: string;
4
5
  quantity?: number;
6
+ discounts?: AddProductDiscountParams[];
7
+ fees?: AddProductFeeParams[];
8
+ notes?: string | string[];
5
9
  }
6
10
  export interface AddProductToCartResponse {
7
11
  success: boolean;
8
12
  productId: string;
9
13
  variantId: string;
14
+ internalId: string;
10
15
  name: string;
11
16
  quantity: number;
12
17
  timestamp: string;
@@ -1,6 +1,7 @@
1
1
  export interface AdjustInventoryParams {
2
2
  amount: string;
3
3
  stockType: 'add' | 'subtract' | 'set';
4
+ variantId?: string;
4
5
  }
5
6
  export interface AdjustInventoryResponse {
6
7
  success: boolean;
@@ -1,5 +1,5 @@
1
- export const mockCalculateRefundTotal = async () => {
2
- console.log("[Mock] calculateRefundTotal called");
1
+ export const mockCalculateRefundTotal = async (_params) => {
2
+ console.log("[Mock] calculateRefundTotal called", _params);
3
3
  return {
4
4
  success: true,
5
5
  summary: {
@@ -1,4 +1,7 @@
1
1
  import { CFRefundedLineItem, CFRefundedCustomSale } from "../../CommonTypes";
2
+ export interface CalculateRefundTotalParams {
3
+ orderId?: string;
4
+ }
2
5
  export interface CalculateRefundTotalResponse {
3
6
  success: boolean;
4
7
  summary: {
@@ -10,4 +13,4 @@ export interface CalculateRefundTotalResponse {
10
13
  refundedCustomSales: CFRefundedCustomSale[];
11
14
  timestamp: string;
12
15
  }
13
- export type CalculateRefundTotal = () => Promise<CalculateRefundTotalResponse>;
16
+ export type CalculateRefundTotal = (params?: CalculateRefundTotalParams) => Promise<CalculateRefundTotalResponse>;
@@ -0,0 +1,2 @@
1
+ import { GetFinalContext } from "./types";
2
+ export declare const mockGetFinalContext: GetFinalContext;
@@ -0,0 +1,6 @@
1
+ export const mockGetFinalContext = async () => {
2
+ console.log("[Mock] getFinalContext called");
3
+ return {
4
+ projectName: "Mock Project"
5
+ };
6
+ };
@@ -1,5 +1,5 @@
1
- export const mockGetRemainingRefundableQuantities = async () => {
2
- console.log("[Mock] getRemainingRefundableQuantities called");
1
+ export const mockGetRemainingRefundableQuantities = async (_params) => {
2
+ console.log("[Mock] getRemainingRefundableQuantities called", _params);
3
3
  return {
4
4
  success: true,
5
5
  lineItems: {},
@@ -1,7 +1,10 @@
1
+ export interface GetRemainingRefundableQuantitiesParams {
2
+ orderId?: string;
3
+ }
1
4
  export interface GetRemainingRefundableQuantitiesResponse {
2
5
  success: boolean;
3
6
  lineItems: Record<string, number>;
4
7
  customSales: Record<string, number>;
5
8
  timestamp: string;
6
9
  }
7
- export type GetRemainingRefundableQuantities = () => Promise<GetRemainingRefundableQuantitiesResponse>;
10
+ export type GetRemainingRefundableQuantities = (params?: GetRemainingRefundableQuantitiesParams) => Promise<GetRemainingRefundableQuantitiesResponse>;
@@ -2,7 +2,7 @@ export const mockProcessPartialRefund = async (params) => {
2
2
  console.log("[Mock] processPartialRefund called", params);
3
3
  return {
4
4
  success: true,
5
- refundId: "mock_refund_id",
5
+ refundId: 'mock_refund_' + Date.now(),
6
6
  timestamp: new Date().toISOString()
7
7
  };
8
8
  };
@@ -1,5 +1,11 @@
1
1
  export interface ProcessPartialRefundParams {
2
2
  reason?: string;
3
+ orderId?: string;
4
+ items?: {
5
+ itemKey: string;
6
+ quantity: number;
7
+ type?: 'product' | 'customSale' | 'fee' | 'tip';
8
+ }[];
3
9
  }
4
10
  export interface ProcessPartialRefundResponse {
5
11
  success: boolean;
@@ -1,5 +1,5 @@
1
- export const mockSelectAllRefundItems = async () => {
2
- console.log("[Mock] selectAllRefundItems called");
1
+ export const mockSelectAllRefundItems = async (_params) => {
2
+ console.log("[Mock] selectAllRefundItems called", _params);
3
3
  return {
4
4
  success: true,
5
5
  selectedItemsCount: 5,
@@ -1,6 +1,9 @@
1
+ export interface SelectAllRefundItemsParams {
2
+ orderId?: string;
3
+ }
1
4
  export interface SelectAllRefundItemsResponse {
2
5
  success: boolean;
3
6
  selectedItemsCount: number;
4
7
  timestamp: string;
5
8
  }
6
- export type SelectAllRefundItems = () => Promise<SelectAllRefundItemsResponse>;
9
+ export type SelectAllRefundItems = (params?: SelectAllRefundItemsParams) => Promise<SelectAllRefundItemsResponse>;
@@ -2,6 +2,7 @@ export const mockSetRefundStockAction = async (params) => {
2
2
  console.log("[Mock] setRefundStockAction called", params);
3
3
  return {
4
4
  success: true,
5
+ orderId: params?.orderId,
5
6
  itemKey: params?.itemKey || "",
6
7
  action: params?.action || "RESTOCK",
7
8
  timestamp: new Date().toISOString()
@@ -1,9 +1,11 @@
1
1
  export interface SetRefundStockActionParams {
2
+ orderId?: string;
2
3
  itemKey: string;
3
4
  action: 'RESTOCK' | 'REFUND_DAMAGE';
4
5
  }
5
6
  export interface SetRefundStockActionResponse {
6
7
  success: boolean;
8
+ orderId?: string;
7
9
  itemKey: string;
8
10
  action: string;
9
11
  timestamp: string;
@@ -1,12 +1,13 @@
1
+ export type TriggerWebhookPresetType = 'product' | 'cart' | 'order' | 'customer';
1
2
  export interface TriggerWebhookParams {
2
3
  webhookUrl: string;
3
4
  publicKey?: string;
4
5
  presetData?: boolean;
5
- presetType?: string;
6
+ presetType?: TriggerWebhookPresetType;
6
7
  isCustomHook?: boolean;
7
8
  customHookData?: string;
8
9
  payloadType?: string;
9
- dynamicDataFields?: any[];
10
+ dynamicDataFields?: unknown[];
10
11
  }
11
12
  export interface TriggerWebhookResponse {
12
13
  success: boolean;
@@ -1 +1,2 @@
1
+ // Trigger Webhook Types
1
2
  export {};
@@ -38,7 +38,6 @@ import { mockRemoveCustomerFromCart } from "../actions/remove-customer-from-cart
38
38
  import { mockResetRefundDetails } from "../actions/reset-refund-details/mock";
39
39
  import { mockResumeParkedOrder } from "../actions/resume-parked-order/mock";
40
40
  import { mockSelectAllRefundItems } from "../actions/select-all-refund-items/mock";
41
- import { mockSetProductActive } from "../actions/set-product-active/mock";
42
41
  import { mockSetRefundStockAction } from "../actions/set-refund-stock-action/mock";
43
42
  import { mockShowConfirmation } from "../actions/show-confirmation/mock";
44
43
  import { mockShowNotification } from "../actions/show-notification/mock";
@@ -50,6 +49,7 @@ import { mockTriggerWebhook } from "../actions/trigger-webhook/mock";
50
49
  import { mockTriggerZapierWebhook } from "../actions/trigger-zapier-webhook/mock";
51
50
  import { mockUpdateCustomerFacingDisplay } from "../actions/update-customer-facing-display/mock";
52
51
  import { mockVendaraPayment } from "../actions/vendara-payment/mock";
52
+ import { mockGetFinalContext } from "../actions/get-final-context/mock";
53
53
  export const MOCK_REGISTRY = {
54
54
  "addCartDiscount": mockAddCartDiscount,
55
55
  "addCartFee": mockAddCartFee,
@@ -91,7 +91,6 @@ export const MOCK_REGISTRY = {
91
91
  "resetRefundDetails": mockResetRefundDetails,
92
92
  "resumeParkedOrder": mockResumeParkedOrder,
93
93
  "selectAllRefundItems": mockSelectAllRefundItems,
94
- "setProductActive": mockSetProductActive,
95
94
  "setRefundStockAction": mockSetRefundStockAction,
96
95
  "showConfirmation": mockShowConfirmation,
97
96
  "showNotification": mockShowNotification,
@@ -103,4 +102,5 @@ export const MOCK_REGISTRY = {
103
102
  "triggerZapierWebhook": mockTriggerZapierWebhook,
104
103
  "updateCustomerFacingDisplay": mockUpdateCustomerFacingDisplay,
105
104
  "vendaraPayment": mockVendaraPayment,
105
+ "getFinalContext": mockGetFinalContext,
106
106
  };
package/dist/index.d.ts CHANGED
@@ -9,11 +9,11 @@ export declare const command: {
9
9
  readonly getProductVariants: import("./actions/get-product-variants/types").GetProductVariants;
10
10
  readonly getOrders: import("./actions/get-orders/types").GetOrders;
11
11
  readonly getRefunds: import("./actions/get-refunds/types").GetRefunds;
12
- readonly setProductActive: import("./actions/set-product-active/types").SetProductActive;
13
12
  readonly addProductDiscount: import("./actions/add-product-discount/types").AddProductDiscount;
14
13
  readonly addProductToCart: import("./actions/add-product-to-cart/types").AddProductToCart;
15
14
  readonly addCartDiscount: import("./actions/add-cart-discount/types").AddCartDiscount;
16
15
  readonly getContext: import("./actions/get-context/types").GetContext;
16
+ readonly getFinalContext: import("./actions/get-final-context/types").GetFinalContext;
17
17
  readonly addProductNote: import("./actions/add-product-note/types").AddProductNote;
18
18
  readonly addProductFee: import("./actions/add-product-fee/types").AddProductFee;
19
19
  readonly adjustInventory: import("./actions/adjust-inventory/types").AdjustInventory;
@@ -64,13 +64,12 @@ export type { GetOrders, GetOrdersParams, GetOrdersResponse } from "./actions/ge
64
64
  export type { GetRefunds, GetRefundsParams, GetRefundsResponse } from "./actions/get-refunds/types";
65
65
  export type { GetLineItemsByOrder, GetLineItemsByOrderParams, GetLineItemsByOrderResponse } from "./actions/get-line-items-by-order/types";
66
66
  export type { SetRefundStockAction, SetRefundStockActionParams, SetRefundStockActionResponse } from "./actions/set-refund-stock-action/types";
67
- export type { SelectAllRefundItems, SelectAllRefundItemsResponse } from "./actions/select-all-refund-items/types";
67
+ export type { SelectAllRefundItems, SelectAllRefundItemsParams, SelectAllRefundItemsResponse } from "./actions/select-all-refund-items/types";
68
68
  export type { ResetRefundDetails, ResetRefundDetailsResponse } from "./actions/reset-refund-details/types";
69
- export type { CalculateRefundTotal, CalculateRefundTotalResponse } from "./actions/calculate-refund-total/types";
70
- export type { GetRemainingRefundableQuantities, GetRemainingRefundableQuantitiesResponse } from "./actions/get-remaining-refundable-quantities/types";
69
+ export type { CalculateRefundTotal, CalculateRefundTotalParams, CalculateRefundTotalResponse } from "./actions/calculate-refund-total/types";
70
+ export type { GetRemainingRefundableQuantities, GetRemainingRefundableQuantitiesParams, GetRemainingRefundableQuantitiesResponse } from "./actions/get-remaining-refundable-quantities/types";
71
71
  export type { ProcessPartialRefund, ProcessPartialRefundParams, ProcessPartialRefundResponse } from "./actions/process-partial-refund/types";
72
72
  export type { GetCurrentCart, GetCurrentCartResponse } from "./actions/get-current-cart/types";
73
- export type { SetProductActive, SetProductActiveParams, SetProductActiveResponse } from "./actions/set-product-active/types";
74
73
  export type { AddProductDiscount, AddProductDiscountParams, AddProductDiscountResponse } from "./actions/add-product-discount/types";
75
74
  export type { AddProductToCart, AddProductToCartParams, AddProductToCartResponse } from "./actions/add-product-to-cart/types";
76
75
  export type { AddCartDiscount, AddCartDiscountParams, AddCartDiscountResponse } from "./actions/add-cart-discount/types";
@@ -103,7 +102,7 @@ export type { AuthenticateUser, AuthenticateUserParams, AuthenticateUserResponse
103
102
  export type { UpdateCustomerFacingDisplay, UpdateCustomerFacingDisplayParams, UpdateCustomerFacingDisplayResponse } from "./actions/update-customer-facing-display/types";
104
103
  export type { PartialPayment, PartialPaymentParams, PartialPaymentResponse } from "./actions/partial-payment/types";
105
104
  export type { SwitchUser, SwitchUserParams, SwitchUserResponse } from "./actions/switch-user/types";
106
- export type { TriggerWebhook, TriggerWebhookParams, TriggerWebhookResponse } from "./actions/trigger-webhook/types";
105
+ export type { TriggerWebhook, TriggerWebhookPresetType, TriggerWebhookParams, TriggerWebhookResponse } from "./actions/trigger-webhook/types";
107
106
  export type { TriggerZapierWebhook, TriggerZapierWebhookParams, TriggerZapierWebhookResponse } from "./actions/trigger-zapier-webhook/types";
108
107
  export * from "./CommonTypes";
109
108
  export { commandFrameClient, CommandFrameClient } from "./client";
package/dist/index.js CHANGED
@@ -10,8 +10,8 @@ import { getProductVariants } from "./actions/get-product-variants/action";
10
10
  import { getOrders } from "./actions/get-orders/action";
11
11
  import { getRefunds } from "./actions/get-refunds/action";
12
12
  import { addCartDiscount } from "./actions/add-cart-discount/action";
13
- import { setProductActive } from "./actions/set-product-active/action";
14
13
  import { getContext } from "./actions/get-context/action";
14
+ import { getFinalContext } from "./actions/get-final-context/action";
15
15
  import { addProductDiscount } from "./actions/add-product-discount/action";
16
16
  import { addProductToCart } from "./actions/add-product-to-cart/action";
17
17
  // Product Actions
@@ -68,11 +68,11 @@ export const command = {
68
68
  getProductVariants,
69
69
  getOrders,
70
70
  getRefunds,
71
- setProductActive,
72
71
  addProductDiscount,
73
72
  addProductToCart,
74
73
  addCartDiscount,
75
74
  getContext,
75
+ getFinalContext,
76
76
  // Product Actions
77
77
  addProductNote,
78
78
  addProductFee,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,6 +0,0 @@
1
- /**
2
- * Set product active action
3
- * Calls the setProductActive action on the parent window
4
- */
5
- import type { SetProductActive } from "./types";
6
- export declare const setProductActive: SetProductActive;
@@ -1,8 +0,0 @@
1
- /**
2
- * Set product active action
3
- * Calls the setProductActive action on the parent window
4
- */
5
- import { commandFrameClient } from "../../client";
6
- export const setProductActive = async (params) => {
7
- return await commandFrameClient.call("setProductActive", params);
8
- };
@@ -1,2 +0,0 @@
1
- import { SetProductActive } from "./types";
2
- export declare const mockSetProductActive: SetProductActive;
@@ -1,8 +0,0 @@
1
- export const mockSetProductActive = async (params) => {
2
- console.log("[Mock] setProductActive called", params);
3
- return {
4
- success: true,
5
- variantId: params?.variantId || "",
6
- timestamp: new Date().toISOString()
7
- };
8
- };
@@ -1,9 +0,0 @@
1
- export interface SetProductActiveParams {
2
- variantId: string;
3
- }
4
- export interface SetProductActiveResponse {
5
- success: boolean;
6
- variantId: string;
7
- timestamp: string;
8
- }
9
- export type SetProductActive = (params?: SetProductActiveParams) => Promise<SetProductActiveResponse>;
@@ -1 +0,0 @@
1
- export {};