@final-commerce/command-frame 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -344
- package/dist/index.d.ts +10 -0
- package/dist/index.js +5 -0
- package/dist/pubsub/topics/cart/cart-created/types.d.ts +12 -0
- package/dist/pubsub/topics/cart/cart-created/types.js +1 -0
- package/dist/pubsub/topics/cart/cart-discount-added/types.d.ts +12 -0
- package/dist/pubsub/topics/cart/cart-discount-added/types.js +1 -0
- package/dist/pubsub/topics/cart/cart-discount-removed/types.d.ts +10 -0
- package/dist/pubsub/topics/cart/cart-discount-removed/types.js +1 -0
- package/dist/pubsub/topics/cart/cart-fee-added/types.d.ts +12 -0
- package/dist/pubsub/topics/cart/cart-fee-added/types.js +1 -0
- package/dist/pubsub/topics/cart/cart-fee-removed/types.d.ts +11 -0
- package/dist/pubsub/topics/cart/cart-fee-removed/types.js +1 -0
- package/dist/pubsub/topics/cart/customer-assigned/types.d.ts +12 -0
- package/dist/pubsub/topics/cart/customer-assigned/types.js +1 -0
- package/dist/pubsub/topics/cart/index.d.ts +7 -0
- package/dist/pubsub/topics/cart/index.js +53 -0
- package/dist/pubsub/topics/cart/product-added/types.d.ts +12 -0
- package/dist/pubsub/topics/cart/product-added/types.js +1 -0
- package/dist/pubsub/topics/cart/product-deleted/types.d.ts +13 -0
- package/dist/pubsub/topics/cart/product-deleted/types.js +1 -0
- package/dist/pubsub/topics/cart/types.d.ts +22 -0
- package/dist/pubsub/topics/cart/types.js +13 -0
- package/dist/pubsub/topics/index.d.ts +5 -0
- package/dist/pubsub/topics/index.js +5 -0
- package/dist/pubsub/topics/orders/index.d.ts +7 -0
- package/dist/pubsub/topics/orders/index.js +23 -0
- package/dist/pubsub/topics/orders/order-created/types.d.ts +12 -0
- package/dist/pubsub/topics/orders/order-created/types.js +1 -0
- package/dist/pubsub/topics/orders/order-updated/types.d.ts +12 -0
- package/dist/pubsub/topics/orders/order-updated/types.js +1 -0
- package/dist/pubsub/topics/orders/types.d.ts +10 -0
- package/dist/pubsub/topics/orders/types.js +7 -0
- package/dist/pubsub/topics/payments/index.d.ts +7 -0
- package/dist/pubsub/topics/payments/index.js +23 -0
- package/dist/pubsub/topics/payments/payment-done/types.d.ts +14 -0
- package/dist/pubsub/topics/payments/payment-done/types.js +1 -0
- package/dist/pubsub/topics/payments/payment-err/types.d.ts +14 -0
- package/dist/pubsub/topics/payments/payment-err/types.js +1 -0
- package/dist/pubsub/topics/payments/types.d.ts +10 -0
- package/dist/pubsub/topics/payments/types.js +7 -0
- package/dist/pubsub/topics/products/index.d.ts +7 -0
- package/dist/pubsub/topics/products/index.js +23 -0
- package/dist/pubsub/topics/products/product-created/types.d.ts +12 -0
- package/dist/pubsub/topics/products/product-created/types.js +1 -0
- package/dist/pubsub/topics/products/product-updated/types.d.ts +12 -0
- package/dist/pubsub/topics/products/product-updated/types.js +1 -0
- package/dist/pubsub/topics/products/types.d.ts +10 -0
- package/dist/pubsub/topics/products/types.js +7 -0
- package/dist/pubsub/topics/refunds/index.d.ts +7 -0
- package/dist/pubsub/topics/refunds/index.js +23 -0
- package/dist/pubsub/topics/refunds/refund-created/types.d.ts +13 -0
- package/dist/pubsub/topics/refunds/refund-created/types.js +1 -0
- package/dist/pubsub/topics/refunds/refund-updated/types.d.ts +13 -0
- package/dist/pubsub/topics/refunds/refund-updated/types.js +1 -0
- package/dist/pubsub/topics/refunds/types.d.ts +10 -0
- package/dist/pubsub/topics/refunds/types.js +7 -0
- package/package.json +1 -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
|
-
- [
|
|
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
|
|
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
|
|
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
|
|
@@ -94,7 +95,7 @@ The library provides a `command` namespace object containing all available actio
|
|
|
94
95
|
#### Reference
|
|
95
96
|
- **[exampleFunction](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/example-function/README.md)** - Example/template function (for reference only)
|
|
96
97
|
|
|
97
|
-
For detailed documentation on each
|
|
98
|
+
For detailed documentation on each command, including parameter descriptions, response structures, and usage examples, see the [Commands Documentation](#commands-documentation) section below.
|
|
98
99
|
|
|
99
100
|
## Quick Start
|
|
100
101
|
|
|
@@ -144,347 +145,12 @@ console.log('Current company:', context.companyName);
|
|
|
144
145
|
console.log('Current build:', context.buildName);
|
|
145
146
|
```
|
|
146
147
|
|
|
147
|
-
For complete usage examples and detailed parameter descriptions, see the documentation for each
|
|
148
|
+
For complete usage examples and detailed parameter descriptions, see the documentation for each command in the [Commands Documentation](#commands-documentation) section.
|
|
148
149
|
|
|
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
150
|
|
|
178
|
-
|
|
151
|
+
## Commands Documentation
|
|
179
152
|
|
|
180
|
-
|
|
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)`
|
|
192
|
-
|
|
193
|
-
Subscribes to a topic and receives events via the callback function.
|
|
194
|
-
|
|
195
|
-
**Parameters:**
|
|
196
|
-
- `topic: string` - The topic ID to subscribe to
|
|
197
|
-
- `callback: (event: TopicEvent) => void` - Function called when an event is received
|
|
198
|
-
|
|
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:
|
|
153
|
+
Each command has detailed documentation with complete parameter descriptions, response structures, and multiple usage examples:
|
|
488
154
|
|
|
489
155
|
### [getCustomers](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-customers/README.md)
|
|
490
156
|
|
|
@@ -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
|
|
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
|
|
450
|
+
All commands are fully typed with TypeScript. Import types for use in your code:
|
|
737
451
|
|
|
738
452
|
```typescript
|
|
739
453
|
import type {
|
package/dist/index.d.ts
CHANGED
|
@@ -111,4 +111,14 @@ export type { PostMessageRequest, PostMessageResponse } from "./client";
|
|
|
111
111
|
export { topics } from "./pubsub/topic";
|
|
112
112
|
export type { TopicDefinition, TopicEvent, TopicEventType, TopicSubscriptionCallback, TopicSubscription } from "./pubsub/types";
|
|
113
113
|
export { customersTopic } from "./pubsub/topics/customers";
|
|
114
|
+
export { ordersTopic } from "./pubsub/topics/orders";
|
|
115
|
+
export { refundsTopic } from "./pubsub/topics/refunds";
|
|
116
|
+
export { productsTopic } from "./pubsub/topics/products";
|
|
117
|
+
export { cartTopic } from "./pubsub/topics/cart";
|
|
118
|
+
export { paymentsTopic } from "./pubsub/topics/payments";
|
|
114
119
|
export type { CustomerCreatedPayload, CustomerUpdatedPayload, CustomerNoteAddedPayload, CustomerNoteDeletedPayload, CustomerAssignedPayload, CustomerUnassignedPayload, CustomerCreatedEvent, CustomerUpdatedEvent, CustomerNoteAddedEvent, CustomerNoteDeletedEvent, CustomerAssignedEvent, CustomerUnassignedEvent, CustomersEventType, CustomersEventPayload } from "./pubsub/topics/customers/types";
|
|
120
|
+
export type { OrderCreatedPayload, OrderUpdatedPayload, OrderCreatedEvent, OrderUpdatedEvent, OrdersEventType, OrdersEventPayload } from "./pubsub/topics/orders/types";
|
|
121
|
+
export type { RefundCreatedPayload, RefundUpdatedPayload, RefundCreatedEvent, RefundUpdatedEvent, RefundsEventType, RefundsEventPayload } from "./pubsub/topics/refunds/types";
|
|
122
|
+
export type { ProductCreatedPayload, ProductUpdatedPayload, ProductCreatedEvent, ProductUpdatedEvent, ProductsEventType, ProductsEventPayload } from "./pubsub/topics/products/types";
|
|
123
|
+
export type { CartCreatedPayload, CartCustomerAssignedPayload, ProductAddedPayload, ProductDeletedPayload, CartDiscountAddedPayload, CartDiscountRemovedPayload, CartFeeAddedPayload, CartFeeRemovedPayload, CartCreatedEvent, CartCustomerAssignedEvent, ProductAddedEvent, ProductDeletedEvent, CartDiscountAddedEvent, CartDiscountRemovedEvent, CartFeeAddedEvent, CartFeeRemovedEvent, CartEventType, CartEventPayload } from "./pubsub/topics/cart/types";
|
|
124
|
+
export type { PaymentDonePayload, PaymentErrPayload, PaymentDoneEvent, PaymentErrEvent, PaymentsEventType, PaymentsEventPayload } from "./pubsub/topics/payments/types";
|
package/dist/index.js
CHANGED
|
@@ -125,3 +125,8 @@ export { commandFrameClient, CommandFrameClient } from "./client";
|
|
|
125
125
|
export { topics } from "./pubsub/topic";
|
|
126
126
|
// Export Pub/Sub Topics
|
|
127
127
|
export { customersTopic } from "./pubsub/topics/customers";
|
|
128
|
+
export { ordersTopic } from "./pubsub/topics/orders";
|
|
129
|
+
export { refundsTopic } from "./pubsub/topics/refunds";
|
|
130
|
+
export { productsTopic } from "./pubsub/topics/products";
|
|
131
|
+
export { cartTopic } from "./pubsub/topics/cart";
|
|
132
|
+
export { paymentsTopic } from "./pubsub/topics/payments";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CFActiveCart } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for cart-created event
|
|
5
|
+
*/
|
|
6
|
+
export interface CartCreatedPayload {
|
|
7
|
+
cart: CFActiveCart;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Typed event for cart-created
|
|
11
|
+
*/
|
|
12
|
+
export type CartCreatedEvent = TopicEvent<CartCreatedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CFDiscount } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for cart-discount-added event
|
|
5
|
+
*/
|
|
6
|
+
export interface CartDiscountAddedPayload {
|
|
7
|
+
discount: CFDiscount;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Typed event for cart-discount-added
|
|
11
|
+
*/
|
|
12
|
+
export type CartDiscountAddedEvent = TopicEvent<CartDiscountAddedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TopicEvent } from "../../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Payload for cart-discount-removed event
|
|
4
|
+
*/
|
|
5
|
+
export interface CartDiscountRemovedPayload {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Typed event for cart-discount-removed
|
|
9
|
+
*/
|
|
10
|
+
export type CartDiscountRemovedEvent = TopicEvent<CartDiscountRemovedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CFCustomFee } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for cart-fee-added event
|
|
5
|
+
*/
|
|
6
|
+
export interface CartFeeAddedPayload {
|
|
7
|
+
fee: CFCustomFee;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Typed event for cart-fee-added
|
|
11
|
+
*/
|
|
12
|
+
export type CartFeeAddedEvent = TopicEvent<CartFeeAddedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TopicEvent } from "../../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Payload for cart-fee-removed event
|
|
4
|
+
*/
|
|
5
|
+
export interface CartFeeRemovedPayload {
|
|
6
|
+
feeIndex: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Typed event for cart-fee-removed
|
|
10
|
+
*/
|
|
11
|
+
export type CartFeeRemovedEvent = TopicEvent<CartFeeRemovedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CFCustomer } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for customer-assigned event (in cart context)
|
|
5
|
+
*/
|
|
6
|
+
export interface CartCustomerAssignedPayload {
|
|
7
|
+
customer: CFCustomer;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Typed event for customer-assigned (in cart context)
|
|
11
|
+
*/
|
|
12
|
+
export type CartCustomerAssignedEvent = TopicEvent<CartCustomerAssignedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cart Topic Definition
|
|
3
|
+
* Defines the cart topic and its available event types
|
|
4
|
+
*/
|
|
5
|
+
export const cartTopic = {
|
|
6
|
+
id: "cart",
|
|
7
|
+
name: "Cart",
|
|
8
|
+
description: "Topic for cart-related events",
|
|
9
|
+
eventTypes: [
|
|
10
|
+
{
|
|
11
|
+
id: "cart-created",
|
|
12
|
+
name: "Cart Created",
|
|
13
|
+
description: "Fired when a new cart is created"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "customer-assigned",
|
|
17
|
+
name: "Customer Assigned",
|
|
18
|
+
description: "Fired when a customer is assigned to the cart"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "product-added",
|
|
22
|
+
name: "Product Added",
|
|
23
|
+
description: "Fired when a product is added to the cart"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "product-deleted",
|
|
27
|
+
name: "Product Deleted",
|
|
28
|
+
description: "Fired when a product is removed from the cart"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "cart-discount-added",
|
|
32
|
+
name: "Cart Discount Added",
|
|
33
|
+
description: "Fired when a discount is added to the cart"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "cart-discount-removed",
|
|
37
|
+
name: "Cart Discount Removed",
|
|
38
|
+
description: "Fired when a discount is removed from the cart"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "cart-fee-added",
|
|
42
|
+
name: "Cart Fee Added",
|
|
43
|
+
description: "Fired when a fee is added to the cart"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "cart-fee-removed",
|
|
47
|
+
name: "Cart Fee Removed",
|
|
48
|
+
description: "Fired when a fee is removed from the cart"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
// Re-export types
|
|
53
|
+
export * from "./types";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CFActiveProduct } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for product-added event
|
|
5
|
+
*/
|
|
6
|
+
export interface ProductAddedPayload {
|
|
7
|
+
product: CFActiveProduct;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Typed event for product-added
|
|
11
|
+
*/
|
|
12
|
+
export type ProductAddedEvent = TopicEvent<ProductAddedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CFActiveProduct } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for product-deleted event
|
|
5
|
+
*/
|
|
6
|
+
export interface ProductDeletedPayload {
|
|
7
|
+
product: CFActiveProduct;
|
|
8
|
+
internalId: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Typed event for product-deleted
|
|
12
|
+
*/
|
|
13
|
+
export type ProductDeletedEvent = TopicEvent<ProductDeletedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cart Topic Types
|
|
3
|
+
* Aggregated types for all cart-related events
|
|
4
|
+
*/
|
|
5
|
+
export * from "./cart-created/types";
|
|
6
|
+
export * from "./customer-assigned/types";
|
|
7
|
+
export * from "./product-added/types";
|
|
8
|
+
export * from "./product-deleted/types";
|
|
9
|
+
export * from "./cart-discount-added/types";
|
|
10
|
+
export * from "./cart-discount-removed/types";
|
|
11
|
+
export * from "./cart-fee-added/types";
|
|
12
|
+
export * from "./cart-fee-removed/types";
|
|
13
|
+
import type { CartCreatedPayload } from "./cart-created/types";
|
|
14
|
+
import type { CartCustomerAssignedPayload } from "./customer-assigned/types";
|
|
15
|
+
import type { ProductAddedPayload } from "./product-added/types";
|
|
16
|
+
import type { ProductDeletedPayload } from "./product-deleted/types";
|
|
17
|
+
import type { CartDiscountAddedPayload } from "./cart-discount-added/types";
|
|
18
|
+
import type { CartDiscountRemovedPayload } from "./cart-discount-removed/types";
|
|
19
|
+
import type { CartFeeAddedPayload } from "./cart-fee-added/types";
|
|
20
|
+
import type { CartFeeRemovedPayload } from "./cart-fee-removed/types";
|
|
21
|
+
export type CartEventPayload = CartCreatedPayload | CartCustomerAssignedPayload | ProductAddedPayload | ProductDeletedPayload | CartDiscountAddedPayload | CartDiscountRemovedPayload | CartFeeAddedPayload | CartFeeRemovedPayload;
|
|
22
|
+
export type CartEventType = "cart-created" | "customer-assigned" | "product-added" | "product-deleted" | "cart-discount-added" | "cart-discount-removed" | "cart-fee-added" | "cart-fee-removed";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cart Topic Types
|
|
3
|
+
* Aggregated types for all cart-related events
|
|
4
|
+
*/
|
|
5
|
+
// Re-export all event types
|
|
6
|
+
export * from "./cart-created/types";
|
|
7
|
+
export * from "./customer-assigned/types";
|
|
8
|
+
export * from "./product-added/types";
|
|
9
|
+
export * from "./product-deleted/types";
|
|
10
|
+
export * from "./cart-discount-added/types";
|
|
11
|
+
export * from "./cart-discount-removed/types";
|
|
12
|
+
export * from "./cart-fee-added/types";
|
|
13
|
+
export * from "./cart-fee-removed/types";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orders Topic Definition
|
|
3
|
+
* Defines the orders topic and its available event types
|
|
4
|
+
*/
|
|
5
|
+
export const ordersTopic = {
|
|
6
|
+
id: "orders",
|
|
7
|
+
name: "Orders",
|
|
8
|
+
description: "Topic for order-related events",
|
|
9
|
+
eventTypes: [
|
|
10
|
+
{
|
|
11
|
+
id: "order-created",
|
|
12
|
+
name: "Order Created",
|
|
13
|
+
description: "Fired when a new order is created"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "order-updated",
|
|
17
|
+
name: "Order Updated",
|
|
18
|
+
description: "Fired when an order is updated"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
// Re-export types
|
|
23
|
+
export * from "./types";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CFOrder } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for order-created event
|
|
5
|
+
*/
|
|
6
|
+
export interface OrderCreatedPayload {
|
|
7
|
+
order: CFOrder;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Typed event for order-created
|
|
11
|
+
*/
|
|
12
|
+
export type OrderCreatedEvent = TopicEvent<OrderCreatedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CFOrder } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for order-updated event
|
|
5
|
+
*/
|
|
6
|
+
export interface OrderUpdatedPayload {
|
|
7
|
+
order: CFOrder;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Typed event for order-updated
|
|
11
|
+
*/
|
|
12
|
+
export type OrderUpdatedEvent = TopicEvent<OrderUpdatedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orders Topic Types
|
|
3
|
+
* Aggregated types for all order-related events
|
|
4
|
+
*/
|
|
5
|
+
export * from "./order-created/types";
|
|
6
|
+
export * from "./order-updated/types";
|
|
7
|
+
import type { OrderCreatedPayload } from "./order-created/types";
|
|
8
|
+
import type { OrderUpdatedPayload } from "./order-updated/types";
|
|
9
|
+
export type OrdersEventPayload = OrderCreatedPayload | OrderUpdatedPayload;
|
|
10
|
+
export type OrdersEventType = "order-created" | "order-updated";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payments Topic Definition
|
|
3
|
+
* Defines the payments topic and its available event types
|
|
4
|
+
*/
|
|
5
|
+
export const paymentsTopic = {
|
|
6
|
+
id: "payments",
|
|
7
|
+
name: "Payments",
|
|
8
|
+
description: "Topic for payment-related events",
|
|
9
|
+
eventTypes: [
|
|
10
|
+
{
|
|
11
|
+
id: "payment-done",
|
|
12
|
+
name: "Payment Done",
|
|
13
|
+
description: "Fired when a payment is successfully completed"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "payment-err",
|
|
17
|
+
name: "Payment Error",
|
|
18
|
+
description: "Fired when a payment error occurs"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
// Re-export types
|
|
23
|
+
export * from "./types";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CFPaymentMethod, CFOrder } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for payment-done event
|
|
5
|
+
*/
|
|
6
|
+
export interface PaymentDonePayload {
|
|
7
|
+
payment: CFPaymentMethod;
|
|
8
|
+
order: CFOrder;
|
|
9
|
+
amount: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Typed event for payment-done
|
|
13
|
+
*/
|
|
14
|
+
export type PaymentDoneEvent = TopicEvent<PaymentDonePayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TopicEvent } from "../../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Payload for payment-err event
|
|
4
|
+
*/
|
|
5
|
+
export interface PaymentErrPayload {
|
|
6
|
+
error: string;
|
|
7
|
+
errorCode?: string;
|
|
8
|
+
paymentType?: string;
|
|
9
|
+
amount?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Typed event for payment-err
|
|
13
|
+
*/
|
|
14
|
+
export type PaymentErrEvent = TopicEvent<PaymentErrPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payments Topic Types
|
|
3
|
+
* Aggregated types for all payment-related events
|
|
4
|
+
*/
|
|
5
|
+
export * from "./payment-done/types";
|
|
6
|
+
export * from "./payment-err/types";
|
|
7
|
+
import type { PaymentDonePayload } from "./payment-done/types";
|
|
8
|
+
import type { PaymentErrPayload } from "./payment-err/types";
|
|
9
|
+
export type PaymentsEventPayload = PaymentDonePayload | PaymentErrPayload;
|
|
10
|
+
export type PaymentsEventType = "payment-done" | "payment-err";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Products Topic Definition
|
|
3
|
+
* Defines the products topic and its available event types
|
|
4
|
+
*/
|
|
5
|
+
export const productsTopic = {
|
|
6
|
+
id: "products",
|
|
7
|
+
name: "Products",
|
|
8
|
+
description: "Topic for product-related events",
|
|
9
|
+
eventTypes: [
|
|
10
|
+
{
|
|
11
|
+
id: "product-created",
|
|
12
|
+
name: "Product Created",
|
|
13
|
+
description: "Fired when a new product is synced/created"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "product-updated",
|
|
17
|
+
name: "Product Updated",
|
|
18
|
+
description: "Fired when a product is synced/updated"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
// Re-export types
|
|
23
|
+
export * from "./types";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CFProduct } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for product-created event
|
|
5
|
+
*/
|
|
6
|
+
export interface ProductCreatedPayload {
|
|
7
|
+
product: CFProduct;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Typed event for product-created
|
|
11
|
+
*/
|
|
12
|
+
export type ProductCreatedEvent = TopicEvent<ProductCreatedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CFProduct } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for product-updated event
|
|
5
|
+
*/
|
|
6
|
+
export interface ProductUpdatedPayload {
|
|
7
|
+
product: CFProduct;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Typed event for product-updated
|
|
11
|
+
*/
|
|
12
|
+
export type ProductUpdatedEvent = TopicEvent<ProductUpdatedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Products Topic Types
|
|
3
|
+
* Aggregated types for all product-related events
|
|
4
|
+
*/
|
|
5
|
+
export * from "./product-created/types";
|
|
6
|
+
export * from "./product-updated/types";
|
|
7
|
+
import type { ProductCreatedPayload } from "./product-created/types";
|
|
8
|
+
import type { ProductUpdatedPayload } from "./product-updated/types";
|
|
9
|
+
export type ProductsEventPayload = ProductCreatedPayload | ProductUpdatedPayload;
|
|
10
|
+
export type ProductsEventType = "product-created" | "product-updated";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refunds Topic Definition
|
|
3
|
+
* Defines the refunds topic and its available event types
|
|
4
|
+
*/
|
|
5
|
+
export const refundsTopic = {
|
|
6
|
+
id: "refunds",
|
|
7
|
+
name: "Refunds",
|
|
8
|
+
description: "Topic for refund-related events",
|
|
9
|
+
eventTypes: [
|
|
10
|
+
{
|
|
11
|
+
id: "refund-created",
|
|
12
|
+
name: "Refund Created",
|
|
13
|
+
description: "Fired when a new refund is created"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "refund-updated",
|
|
17
|
+
name: "Refund Updated",
|
|
18
|
+
description: "Fired when a refund is updated"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
// Re-export types
|
|
23
|
+
export * from "./types";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CFRefundItem } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for refund-created event
|
|
5
|
+
*/
|
|
6
|
+
export interface RefundCreatedPayload {
|
|
7
|
+
refund: CFRefundItem;
|
|
8
|
+
orderId: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Typed event for refund-created
|
|
12
|
+
*/
|
|
13
|
+
export type RefundCreatedEvent = TopicEvent<RefundCreatedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CFRefundItem } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for refund-updated event
|
|
5
|
+
*/
|
|
6
|
+
export interface RefundUpdatedPayload {
|
|
7
|
+
refund: CFRefundItem;
|
|
8
|
+
orderId: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Typed event for refund-updated
|
|
12
|
+
*/
|
|
13
|
+
export type RefundUpdatedEvent = TopicEvent<RefundUpdatedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refunds Topic Types
|
|
3
|
+
* Aggregated types for all refund-related events
|
|
4
|
+
*/
|
|
5
|
+
export * from "./refund-created/types";
|
|
6
|
+
export * from "./refund-updated/types";
|
|
7
|
+
import type { RefundCreatedPayload } from "./refund-created/types";
|
|
8
|
+
import type { RefundUpdatedPayload } from "./refund-updated/types";
|
|
9
|
+
export type RefundsEventPayload = RefundCreatedPayload | RefundUpdatedPayload;
|
|
10
|
+
export type RefundsEventType = "refund-created" | "refund-updated";
|