@final-commerce/command-frame 0.1.0 → 0.1.5

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 (37) hide show
  1. package/dist/demo/database.js +13 -12
  2. package/dist/index.d.ts +3 -1
  3. package/dist/index.js +3 -1
  4. package/dist/pubsub/topics/customers/customer-assigned/types.d.ts +12 -0
  5. package/dist/pubsub/topics/customers/customer-assigned/types.js +1 -0
  6. package/dist/pubsub/topics/customers/customer-created/types.d.ts +12 -0
  7. package/dist/pubsub/topics/customers/customer-created/types.js +1 -0
  8. package/dist/pubsub/topics/customers/customer-note-added/types.d.ts +13 -0
  9. package/dist/pubsub/topics/customers/customer-note-added/types.js +1 -0
  10. package/dist/pubsub/topics/customers/customer-note-deleted/types.d.ts +13 -0
  11. package/dist/pubsub/topics/customers/customer-note-deleted/types.js +1 -0
  12. package/dist/pubsub/topics/customers/customer-unassigned/types.d.ts +12 -0
  13. package/dist/pubsub/topics/customers/customer-unassigned/types.js +1 -0
  14. package/dist/pubsub/topics/customers/customer-updated/types.d.ts +12 -0
  15. package/dist/pubsub/topics/customers/customer-updated/types.js +1 -0
  16. package/dist/pubsub/topics/customers/index.d.ts +7 -0
  17. package/dist/pubsub/topics/customers/index.js +43 -0
  18. package/dist/pubsub/topics/customers/types.d.ts +18 -0
  19. package/dist/pubsub/topics/customers/types.js +11 -0
  20. package/dist/pubsub/topics/index.d.ts +5 -0
  21. package/dist/pubsub/topics/index.js +5 -0
  22. package/dist/pubsub/topics.d.ts +36 -0
  23. package/dist/pubsub/topics.js +52 -0
  24. package/package.json +2 -2
  25. package/dist/demo/assets/assets/basil-almond-paste.png +0 -0
  26. package/dist/demo/assets/assets/beer-paste.png +0 -0
  27. package/dist/demo/assets/assets/beet-paste.png +0 -0
  28. package/dist/demo/assets/assets/caramelized-paste.png +0 -0
  29. package/dist/demo/assets/assets/garlic-onion-paste.png +0 -0
  30. package/dist/demo/assets/assets/garlic-paste.png +0 -0
  31. package/dist/demo/assets/assets/ginger-lime-paste.png +0 -0
  32. package/dist/demo/assets/assets/lemon-paste.png +0 -0
  33. package/dist/demo/assets/assets/logo.png +0 -0
  34. package/dist/demo/assets/assets/red-pepper-paste.png +0 -0
  35. package/dist/demo/assets/assets/roasted-tomato-paste.png +0 -0
  36. /package/dist/pubsub/{index.d.ts → topic.d.ts} +0 -0
  37. /package/dist/pubsub/{index.js → topic.js} +0 -0
@@ -3,18 +3,19 @@
3
3
  * Stores mock data that mimics the Render environment
4
4
  */
5
5
  import { CFProductType, CFUserTypes, } from "../CommonTypes";
6
- // Asset Imports
7
- import logo from "./assets/logo.png";
8
- import basilAlmondImg from "./assets/basil-almond-paste.png";
9
- import beerImg from "./assets/beer-paste.png";
10
- import beetImg from "./assets/beet-paste.png";
11
- import caramelizedImg from "./assets/caramelized-paste.png";
12
- import garlicOnionImg from "./assets/garlic-onion-paste.png";
13
- import garlicImg from "./assets/garlic-paste.png";
14
- import gingerLimeImg from "./assets/ginger-lime-paste.png";
15
- import lemonImg from "./assets/lemon-paste.png";
16
- import redPepperImg from "./assets/red-pepper-paste.png";
17
- import roastedTomatoImg from "./assets/roasted-tomato-paste.png";
6
+ // Asset Imports - Using Remote URLs to avoid build complexity with asset copying
7
+ const ASSETS_BASE_URL = "https://raw.githubusercontent.com/Final-Commerce/command-frame/refs/heads/main/src/demo/assets";
8
+ const logo = `${ASSETS_BASE_URL}/logo.png`;
9
+ const basilAlmondImg = `${ASSETS_BASE_URL}/basil-almond-paste.png`;
10
+ const beerImg = `${ASSETS_BASE_URL}/beer-paste.png`;
11
+ const beetImg = `${ASSETS_BASE_URL}/beet-paste.png`;
12
+ const caramelizedImg = `${ASSETS_BASE_URL}/caramelized-paste.png`;
13
+ const garlicOnionImg = `${ASSETS_BASE_URL}/garlic-onion-paste.png`;
14
+ const garlicImg = `${ASSETS_BASE_URL}/garlic-paste.png`;
15
+ const gingerLimeImg = `${ASSETS_BASE_URL}/ginger-lime-paste.png`;
16
+ const lemonImg = `${ASSETS_BASE_URL}/lemon-paste.png`;
17
+ const redPepperImg = `${ASSETS_BASE_URL}/red-pepper-paste.png`;
18
+ const roastedTomatoImg = `${ASSETS_BASE_URL}/roasted-tomato-paste.png`;
18
19
  // --- COMPANY ---
19
20
  export const MOCK_COMPANY = {
20
21
  id: "comp_paste_demo",
package/dist/index.d.ts CHANGED
@@ -108,5 +108,7 @@ export type { TriggerZapierWebhook, TriggerZapierWebhookParams, TriggerZapierWeb
108
108
  export * from "./CommonTypes";
109
109
  export { commandFrameClient, CommandFrameClient } from "./client";
110
110
  export type { PostMessageRequest, PostMessageResponse } from "./client";
111
- export { topics } from "./pubsub";
111
+ export { topics } from "./pubsub/topic";
112
112
  export type { TopicDefinition, TopicEvent, TopicEventType, TopicSubscriptionCallback, TopicSubscription } from "./pubsub/types";
113
+ export { customersTopic } from "./pubsub/topics/customers";
114
+ export type { CustomerCreatedPayload, CustomerUpdatedPayload, CustomerNoteAddedPayload, CustomerNoteDeletedPayload, CustomerAssignedPayload, CustomerUnassignedPayload, CustomerCreatedEvent, CustomerUpdatedEvent, CustomerNoteAddedEvent, CustomerNoteDeletedEvent, CustomerAssignedEvent, CustomerUnassignedEvent, CustomersEventType, CustomersEventPayload } from "./pubsub/topics/customers/types";
package/dist/index.js CHANGED
@@ -122,4 +122,6 @@ export * from "./CommonTypes";
122
122
  // Export client
123
123
  export { commandFrameClient, CommandFrameClient } from "./client";
124
124
  // Export Pub/Sub
125
- export { topics } from "./pubsub";
125
+ export { topics } from "./pubsub/topic";
126
+ // Export Pub/Sub Topics
127
+ export { customersTopic } from "./pubsub/topics/customers";
@@ -0,0 +1,12 @@
1
+ import type { CFCustomer } from "../../../../CommonTypes";
2
+ import type { TopicEvent } from "../../../types";
3
+ /**
4
+ * Payload for customer-assigned event
5
+ */
6
+ export interface CustomerAssignedPayload {
7
+ customer: CFCustomer;
8
+ }
9
+ /**
10
+ * Typed event for customer-assigned
11
+ */
12
+ export type CustomerAssignedEvent = TopicEvent<CustomerAssignedPayload>;
@@ -0,0 +1,12 @@
1
+ import type { CFCustomer } from "../../../../CommonTypes";
2
+ import type { TopicEvent } from "../../../types";
3
+ /**
4
+ * Payload for customer-created event
5
+ */
6
+ export interface CustomerCreatedPayload {
7
+ customer: CFCustomer;
8
+ }
9
+ /**
10
+ * Typed event for customer-created
11
+ */
12
+ export type CustomerCreatedEvent = TopicEvent<CustomerCreatedPayload>;
@@ -0,0 +1,13 @@
1
+ import type { CFCustomer, CFCustomerNote } from "../../../../CommonTypes";
2
+ import type { TopicEvent } from "../../../types";
3
+ /**
4
+ * Payload for customer-note-added event
5
+ */
6
+ export interface CustomerNoteAddedPayload {
7
+ customer: CFCustomer;
8
+ note: CFCustomerNote;
9
+ }
10
+ /**
11
+ * Typed event for customer-note-added
12
+ */
13
+ export type CustomerNoteAddedEvent = TopicEvent<CustomerNoteAddedPayload>;
@@ -0,0 +1,13 @@
1
+ import type { CFCustomer, CFCustomerNote } from "../../../../CommonTypes";
2
+ import type { TopicEvent } from "../../../types";
3
+ /**
4
+ * Payload for customer-note-deleted event
5
+ */
6
+ export interface CustomerNoteDeletedPayload {
7
+ customer: CFCustomer;
8
+ note: CFCustomerNote;
9
+ }
10
+ /**
11
+ * Typed event for customer-note-deleted
12
+ */
13
+ export type CustomerNoteDeletedEvent = TopicEvent<CustomerNoteDeletedPayload>;
@@ -0,0 +1,12 @@
1
+ import type { CFCustomer } from "../../../../CommonTypes";
2
+ import type { TopicEvent } from "../../../types";
3
+ /**
4
+ * Payload for customer-unassigned event
5
+ */
6
+ export interface CustomerUnassignedPayload {
7
+ customer: CFCustomer;
8
+ }
9
+ /**
10
+ * Typed event for customer-unassigned
11
+ */
12
+ export type CustomerUnassignedEvent = TopicEvent<CustomerUnassignedPayload>;
@@ -0,0 +1,12 @@
1
+ import type { CFCustomer } from "../../../../CommonTypes";
2
+ import type { TopicEvent } from "../../../types";
3
+ /**
4
+ * Payload for customer-updated event
5
+ */
6
+ export interface CustomerUpdatedPayload {
7
+ customer: CFCustomer;
8
+ }
9
+ /**
10
+ * Typed event for customer-updated
11
+ */
12
+ export type CustomerUpdatedEvent = TopicEvent<CustomerUpdatedPayload>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Customers Topic Definition
3
+ * Defines the customers topic and its available event types
4
+ */
5
+ import type { TopicDefinition } from "../../types";
6
+ export declare const customersTopic: TopicDefinition;
7
+ export * from "./types";
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Customers Topic Definition
3
+ * Defines the customers topic and its available event types
4
+ */
5
+ export const customersTopic = {
6
+ id: "customers",
7
+ name: "Customers",
8
+ description: "Topic for customer-related events",
9
+ eventTypes: [
10
+ {
11
+ id: "customer-created",
12
+ name: "Customer Created",
13
+ description: "Fired when a new customer is created"
14
+ },
15
+ {
16
+ id: "customer-updated",
17
+ name: "Customer Updated",
18
+ description: "Fired when a customer is updated"
19
+ },
20
+ {
21
+ id: "customer-note-added",
22
+ name: "Customer Note Added",
23
+ description: "Fired when a note is added to a customer"
24
+ },
25
+ {
26
+ id: "customer-note-deleted",
27
+ name: "Customer Note Deleted",
28
+ description: "Fired when a note is deleted from a customer"
29
+ },
30
+ {
31
+ id: "customer-assigned",
32
+ name: "Customer Assigned",
33
+ description: "Fired when a customer is assigned to the cart"
34
+ },
35
+ {
36
+ id: "customer-unassigned",
37
+ name: "Customer Unassigned",
38
+ description: "Fired when a customer is unassigned from the cart"
39
+ }
40
+ ]
41
+ };
42
+ // Re-export types
43
+ export * from "./types";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Customers Topic Types
3
+ * Aggregated types for all customer-related events
4
+ */
5
+ export * from "./customer-created/types";
6
+ export * from "./customer-updated/types";
7
+ export * from "./customer-note-added/types";
8
+ export * from "./customer-note-deleted/types";
9
+ export * from "./customer-assigned/types";
10
+ export * from "./customer-unassigned/types";
11
+ import type { CustomerCreatedPayload } from "./customer-created/types";
12
+ import type { CustomerUpdatedPayload } from "./customer-updated/types";
13
+ import type { CustomerNoteAddedPayload } from "./customer-note-added/types";
14
+ import type { CustomerNoteDeletedPayload } from "./customer-note-deleted/types";
15
+ import type { CustomerAssignedPayload } from "./customer-assigned/types";
16
+ import type { CustomerUnassignedPayload } from "./customer-unassigned/types";
17
+ export type CustomersEventPayload = CustomerCreatedPayload | CustomerUpdatedPayload | CustomerNoteAddedPayload | CustomerNoteDeletedPayload | CustomerAssignedPayload | CustomerUnassignedPayload;
18
+ export type CustomersEventType = "customer-created" | "customer-updated" | "customer-note-added" | "customer-note-deleted" | "customer-assigned" | "customer-unassigned";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Customers Topic Types
3
+ * Aggregated types for all customer-related events
4
+ */
5
+ // Re-export all event types
6
+ export * from "./customer-created/types";
7
+ export * from "./customer-updated/types";
8
+ export * from "./customer-note-added/types";
9
+ export * from "./customer-note-deleted/types";
10
+ export * from "./customer-assigned/types";
11
+ export * from "./customer-unassigned/types";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Pub/Sub Topics
3
+ * Export all available topics and their types
4
+ */
5
+ export * from "./customers";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Pub/Sub Topics
3
+ * Export all available topics and their types
4
+ */
5
+ export * from "./customers";
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Pub/Sub module for Command Frame
3
+ * Provides topic subscription functionality for iframe apps
4
+ */
5
+ export * from "./types";
6
+ export { TopicSubscriber } from "./subscriber";
7
+ import { TopicSubscriber } from "./subscriber";
8
+ /**
9
+ * Get or create the singleton TopicSubscriber instance
10
+ */
11
+ export declare function getTopicSubscriber(options?: {
12
+ origin?: string;
13
+ debug?: boolean;
14
+ }): TopicSubscriber;
15
+ /**
16
+ * Topics API for iframe apps
17
+ */
18
+ declare const topicsApi: {
19
+ /**
20
+ * Subscribe to a topic
21
+ */
22
+ subscribe: <T = any>(topic: string, callback: (event: import("./types").TopicEvent<T>) => void) => string;
23
+ /**
24
+ * Unsubscribe from a topic
25
+ */
26
+ unsubscribe: (topic: string, subscriptionId: string) => boolean;
27
+ /**
28
+ * Unsubscribe all callbacks for a topic
29
+ */
30
+ unsubscribeAll: (topic: string) => number;
31
+ /**
32
+ * Get available topics
33
+ */
34
+ getTopics: () => Promise<import("./types").TopicDefinition[]>;
35
+ };
36
+ export { topicsApi as topics };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Pub/Sub module for Command Frame
3
+ * Provides topic subscription functionality for iframe apps
4
+ */
5
+ export * from "./types";
6
+ export { TopicSubscriber } from "./subscriber";
7
+ // Singleton instance
8
+ import { TopicSubscriber } from "./subscriber";
9
+ let subscriberInstance = null;
10
+ /**
11
+ * Get or create the singleton TopicSubscriber instance
12
+ */
13
+ export function getTopicSubscriber(options) {
14
+ if (!subscriberInstance) {
15
+ subscriberInstance = new TopicSubscriber(options);
16
+ }
17
+ return subscriberInstance;
18
+ }
19
+ /**
20
+ * Topics API for iframe apps
21
+ */
22
+ const topicsApi = {
23
+ /**
24
+ * Subscribe to a topic
25
+ */
26
+ subscribe: (topic, callback) => {
27
+ const subscriber = getTopicSubscriber();
28
+ return subscriber.subscribe(topic, callback);
29
+ },
30
+ /**
31
+ * Unsubscribe from a topic
32
+ */
33
+ unsubscribe: (topic, subscriptionId) => {
34
+ const subscriber = getTopicSubscriber();
35
+ return subscriber.unsubscribe(topic, subscriptionId);
36
+ },
37
+ /**
38
+ * Unsubscribe all callbacks for a topic
39
+ */
40
+ unsubscribeAll: (topic) => {
41
+ const subscriber = getTopicSubscriber();
42
+ return subscriber.unsubscribeAll(topic);
43
+ },
44
+ /**
45
+ * Get available topics
46
+ */
47
+ getTopics: async () => {
48
+ const subscriber = getTopicSubscriber();
49
+ return await subscriber.getTopics();
50
+ }
51
+ };
52
+ export { topicsApi as topics };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.1.0",
3
+ "version": "0.1.5",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "package.json"
12
12
  ],
13
13
  "scripts": {
14
- "build": "tsc && mkdir -p dist/demo/assets && cp -R src/demo/assets/ dist/demo/assets/",
14
+ "build": "tsc",
15
15
  "build:clean": "rm -rf dist && npm run build",
16
16
  "dev": "tsc --watch",
17
17
  "prepublishOnly": "npm run build",
Binary file
File without changes
File without changes