@fyul/embed-sdk 2.2.0 → 2.3.0
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/dist/cjs/helpers/messageLogger.d.ts +1 -0
- package/dist/cjs/helpers/messageLogger.js +2 -0
- package/dist/cjs/index.d.ts +3 -19
- package/dist/cjs/index.js +21 -86
- package/dist/cjs/modules/baseModule.d.ts +3 -0
- package/dist/cjs/modules/baseModule.js +5 -1
- package/dist/cjs/modules/catalog/catalogModule.d.ts +1 -0
- package/dist/cjs/modules/catalog/catalogModule.js +4 -0
- package/dist/cjs/modules/edm/broadcastEvents/baseEdmBroadcastEvent.d.ts +5 -0
- package/dist/cjs/modules/edm/broadcastEvents/baseEdmBroadcastEvent.js +10 -0
- package/dist/cjs/modules/edm/broadcastEvents/onDesignStatusUpdate.d.ts +5 -0
- package/dist/cjs/modules/edm/broadcastEvents/onDesignStatusUpdate.js +10 -0
- package/dist/cjs/modules/edm/broadcastEvents/onErrorUpdate.d.ts +5 -0
- package/dist/cjs/modules/edm/broadcastEvents/onErrorUpdate.js +10 -0
- package/dist/cjs/modules/edm/broadcastEvents/onFilePickerRequested.d.ts +5 -0
- package/dist/cjs/modules/edm/broadcastEvents/onFilePickerRequested.js +10 -0
- package/dist/cjs/modules/edm/broadcastEvents/onPricingStatusUpdate.d.ts +5 -0
- package/dist/cjs/modules/edm/broadcastEvents/onPricingStatusUpdate.js +10 -0
- package/dist/cjs/modules/edm/broadcastEvents/onStepStatusUpdate.d.ts +5 -0
- package/dist/cjs/modules/edm/broadcastEvents/onStepStatusUpdate.js +10 -0
- package/dist/cjs/modules/edm/edmBroadcastModule.d.ts +12 -0
- package/dist/cjs/modules/edm/edmBroadcastModule.js +35 -0
- package/dist/cjs/modules/edm/edmModule.d.ts +13 -0
- package/dist/cjs/modules/edm/edmModule.js +33 -0
- package/dist/cjs/modules/edm/events.d.ts +48 -0
- package/dist/cjs/modules/edm/events.js +36 -0
- package/dist/cjs/modules/edm/types/data.types.d.ts +204 -0
- package/dist/cjs/modules/edm/types/data.types.js +8 -0
- package/dist/cjs/modules/edm/types/event/actionEvent.types.d.ts +8 -0
- package/dist/cjs/modules/edm/types/event/actionEvent.types.js +2 -0
- package/dist/cjs/modules/edm/types/event/actionEventPayload.types.d.ts +15 -0
- package/dist/cjs/modules/edm/types/event/actionEventPayload.types.js +2 -0
- package/dist/cjs/modules/edm/types/event/broadcastEvent.types.d.ts +12 -0
- package/dist/cjs/modules/edm/types/event/broadcastEvent.types.js +2 -0
- package/dist/cjs/modules/edm/types/event/broadcastEventPayload.types.d.ts +9 -0
- package/dist/cjs/modules/edm/types/event/broadcastEventPayload.types.js +2 -0
- package/dist/cjs/modules/edm/types/event/resultEvent.types.d.ts +8 -0
- package/dist/cjs/modules/edm/types/event/resultEvent.types.js +2 -0
- package/dist/cjs/modules/edm/types/event/resultEventPayload.types.d.ts +17 -0
- package/dist/cjs/modules/edm/types/event/resultEventPayload.types.js +2 -0
- package/dist/cjs/modules/edm/types/index.d.ts +6 -0
- package/dist/cjs/modules/edm/types/index.js +25 -0
- package/dist/cjs/modules/eventTypes.d.ts +4 -2
- package/dist/cjs/modules/eventTypes.js +5 -0
- package/dist/cjs/modules/events.d.ts +40 -0
- package/dist/cjs/modules/events.js +9 -1
- package/dist/cjs/modules/mockup-generation/mockupGenerationModule.d.ts +1 -0
- package/dist/cjs/modules/mockup-generation/mockupGenerationModule.js +4 -0
- package/dist/cjs/modules/moduleNames.d.ts +7 -0
- package/dist/cjs/modules/moduleNames.js +10 -0
- package/dist/cjs/modules/modules.d.ts +11 -6
- package/dist/cjs/modules/modules.js +16 -11
- package/dist/cjs/modules/product-publish/productPublishModule.d.ts +1 -0
- package/dist/cjs/modules/product-publish/productPublishModule.js +4 -0
- package/dist/cjs/modules/product-publish/types/event/resultEventPayload.types.d.ts +5 -0
- package/dist/cjs/modules/sdk/sdkModule.d.ts +1 -0
- package/dist/cjs/modules/sdk/sdkModule.js +4 -0
- package/dist/cjs/services/broadcastEventDispatcher.d.ts +8 -0
- package/dist/cjs/services/broadcastEventDispatcher.js +24 -0
- package/dist/cjs/services/edm.d.ts +23 -0
- package/dist/cjs/services/edm.js +102 -0
- package/dist/cjs/services/embed.d.ts +19 -0
- package/dist/cjs/services/embed.js +83 -0
- package/dist/cjs/services/embedCommunicator.d.ts +10 -4
- package/dist/cjs/services/embedCommunicator.js +42 -10
- package/dist/cjs/services/iFrameManager.d.ts +3 -1
- package/dist/cjs/services/iFrameManager.js +6 -9
- package/dist/cjs/services/moduleLoaderService.d.ts +1 -2
- package/dist/cjs/services/moduleLoaderService.js +2 -1
- package/dist/cjs/types/event/action/actionEvent.types.d.ts +2 -1
- package/dist/cjs/types/event/action/actionEventPayload.types.d.ts +2 -1
- package/dist/cjs/types/event/broadcast/broadcastEvent.types.d.ts +8 -0
- package/dist/cjs/types/event/broadcast/broadcastEvent.types.js +2 -0
- package/dist/cjs/types/event/broadcast/broadcastEventHandler.d.ts +5 -0
- package/dist/cjs/types/event/broadcast/broadcastEventHandler.js +2 -0
- package/dist/cjs/types/event/broadcast/broadcastEventMap.d.ts +12 -0
- package/dist/cjs/types/event/broadcast/broadcastEventMap.js +16 -0
- package/dist/cjs/types/event/broadcast/broadcastEventPayload.types.d.ts +2 -0
- package/dist/cjs/types/event/broadcast/broadcastEventPayload.types.js +2 -0
- package/dist/cjs/types/event/event.types.d.ts +3 -2
- package/dist/cjs/types/event/eventPayload.types.d.ts +2 -1
- package/dist/cjs/types/event/result/resultEvent.types.d.ts +2 -1
- package/dist/cjs/types/event/result/resultEventPayload.types.d.ts +2 -1
- package/dist/cjs/types/module/module.types.d.ts +16 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/helpers/messageLogger.d.ts +1 -0
- package/dist/esm/helpers/messageLogger.js +2 -0
- package/dist/esm/index.d.ts +3 -19
- package/dist/esm/index.js +3 -69
- package/dist/esm/modules/baseModule.d.ts +3 -0
- package/dist/esm/modules/baseModule.js +5 -1
- package/dist/esm/modules/catalog/catalogModule.d.ts +1 -0
- package/dist/esm/modules/catalog/catalogModule.js +4 -0
- package/dist/esm/modules/edm/broadcastEvents/baseEdmBroadcastEvent.d.ts +5 -0
- package/dist/esm/modules/edm/broadcastEvents/baseEdmBroadcastEvent.js +6 -0
- package/dist/esm/modules/edm/broadcastEvents/onDesignStatusUpdate.d.ts +5 -0
- package/dist/esm/modules/edm/broadcastEvents/onDesignStatusUpdate.js +6 -0
- package/dist/esm/modules/edm/broadcastEvents/onErrorUpdate.d.ts +5 -0
- package/dist/esm/modules/edm/broadcastEvents/onErrorUpdate.js +6 -0
- package/dist/esm/modules/edm/broadcastEvents/onFilePickerRequested.d.ts +5 -0
- package/dist/esm/modules/edm/broadcastEvents/onFilePickerRequested.js +6 -0
- package/dist/esm/modules/edm/broadcastEvents/onPricingStatusUpdate.d.ts +5 -0
- package/dist/esm/modules/edm/broadcastEvents/onPricingStatusUpdate.js +6 -0
- package/dist/esm/modules/edm/broadcastEvents/onStepStatusUpdate.d.ts +5 -0
- package/dist/esm/modules/edm/broadcastEvents/onStepStatusUpdate.js +6 -0
- package/dist/esm/modules/edm/edmBroadcastModule.d.ts +12 -0
- package/dist/esm/modules/edm/edmBroadcastModule.js +31 -0
- package/dist/esm/modules/edm/edmModule.d.ts +13 -0
- package/dist/esm/modules/edm/edmModule.js +29 -0
- package/dist/esm/modules/edm/events.d.ts +48 -0
- package/dist/esm/modules/edm/events.js +33 -0
- package/dist/esm/modules/edm/types/data.types.d.ts +204 -0
- package/dist/esm/modules/edm/types/data.types.js +5 -0
- package/dist/esm/modules/edm/types/event/actionEvent.types.d.ts +8 -0
- package/dist/esm/modules/edm/types/event/actionEvent.types.js +1 -0
- package/dist/esm/modules/edm/types/event/actionEventPayload.types.d.ts +15 -0
- package/dist/esm/modules/edm/types/event/actionEventPayload.types.js +1 -0
- package/dist/esm/modules/edm/types/event/broadcastEvent.types.d.ts +12 -0
- package/dist/esm/modules/edm/types/event/broadcastEvent.types.js +1 -0
- package/dist/esm/modules/edm/types/event/broadcastEventPayload.types.d.ts +9 -0
- package/dist/esm/modules/edm/types/event/broadcastEventPayload.types.js +1 -0
- package/dist/esm/modules/edm/types/event/resultEvent.types.d.ts +8 -0
- package/dist/esm/modules/edm/types/event/resultEvent.types.js +1 -0
- package/dist/esm/modules/edm/types/event/resultEventPayload.types.d.ts +17 -0
- package/dist/esm/modules/edm/types/event/resultEventPayload.types.js +1 -0
- package/dist/esm/modules/edm/types/index.d.ts +6 -0
- package/dist/esm/modules/edm/types/index.js +9 -0
- package/dist/esm/modules/eventTypes.d.ts +4 -2
- package/dist/esm/modules/eventTypes.js +4 -0
- package/dist/esm/modules/events.d.ts +40 -0
- package/dist/esm/modules/events.js +8 -0
- package/dist/esm/modules/mockup-generation/mockupGenerationModule.d.ts +1 -0
- package/dist/esm/modules/mockup-generation/mockupGenerationModule.js +4 -0
- package/dist/esm/modules/moduleNames.d.ts +7 -0
- package/dist/esm/modules/moduleNames.js +7 -0
- package/dist/esm/modules/modules.d.ts +11 -6
- package/dist/esm/modules/modules.js +11 -6
- package/dist/esm/modules/product-publish/productPublishModule.d.ts +1 -0
- package/dist/esm/modules/product-publish/productPublishModule.js +4 -0
- package/dist/esm/modules/product-publish/types/event/resultEventPayload.types.d.ts +5 -0
- package/dist/esm/modules/sdk/sdkModule.d.ts +1 -0
- package/dist/esm/modules/sdk/sdkModule.js +4 -0
- package/dist/esm/services/broadcastEventDispatcher.d.ts +8 -0
- package/dist/esm/services/broadcastEventDispatcher.js +20 -0
- package/dist/esm/services/edm.d.ts +23 -0
- package/dist/esm/services/edm.js +98 -0
- package/dist/esm/services/embed.d.ts +19 -0
- package/dist/esm/services/embed.js +79 -0
- package/dist/esm/services/embedCommunicator.d.ts +10 -4
- package/dist/esm/services/embedCommunicator.js +43 -11
- package/dist/esm/services/iFrameManager.d.ts +3 -1
- package/dist/esm/services/iFrameManager.js +6 -9
- package/dist/esm/services/moduleLoaderService.d.ts +1 -2
- package/dist/esm/services/moduleLoaderService.js +3 -2
- package/dist/esm/types/event/action/actionEvent.types.d.ts +2 -1
- package/dist/esm/types/event/action/actionEventPayload.types.d.ts +2 -1
- package/dist/esm/types/event/broadcast/broadcastEvent.types.d.ts +8 -0
- package/dist/esm/types/event/broadcast/broadcastEvent.types.js +1 -0
- package/dist/esm/types/event/broadcast/broadcastEventHandler.d.ts +5 -0
- package/dist/esm/types/event/broadcast/broadcastEventHandler.js +1 -0
- package/dist/esm/types/event/broadcast/broadcastEventMap.d.ts +12 -0
- package/dist/esm/types/event/broadcast/broadcastEventMap.js +13 -0
- package/dist/esm/types/event/broadcast/broadcastEventPayload.types.d.ts +2 -0
- package/dist/esm/types/event/broadcast/broadcastEventPayload.types.js +1 -0
- package/dist/esm/types/event/event.types.d.ts +3 -2
- package/dist/esm/types/event/eventPayload.types.d.ts +2 -1
- package/dist/esm/types/event/result/resultEvent.types.d.ts +2 -1
- package/dist/esm/types/event/result/resultEventPayload.types.d.ts +2 -1
- package/dist/esm/types/module/module.types.d.ts +16 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -3,5 +3,6 @@ import { BaseModule } from '../../modules/baseModule';
|
|
|
3
3
|
import { InitializeSdkPayload } from './types';
|
|
4
4
|
import { NotificationEventPayload } from '../../types/event/notification/notificationEventPayload.types';
|
|
5
5
|
export declare class SdkModule extends BaseModule implements ISdkModule {
|
|
6
|
+
constructor();
|
|
6
7
|
setup(payload?: InitializeSdkPayload): Promise<NotificationEventPayload>;
|
|
7
8
|
}
|
|
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SdkModule = void 0;
|
|
4
4
|
const baseModule_1 = require("../../modules/baseModule");
|
|
5
5
|
const events_1 = require("./events");
|
|
6
|
+
const modules_1 = require("../../modules/modules");
|
|
6
7
|
class SdkModule extends baseModule_1.BaseModule {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(modules_1.MODULE_NAMES.SDK);
|
|
10
|
+
}
|
|
7
11
|
async setup(payload) {
|
|
8
12
|
return await this.sendRequest(events_1.EVENTS_ACTION.INITIALIZE_SDK, payload);
|
|
9
13
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BROADCAST_EVENT_MAP } from '../types/event/broadcast/broadcastEventMap';
|
|
2
|
+
import { BroadcastEventPayload } from '../types/event/broadcast/broadcastEventPayload.types';
|
|
3
|
+
export declare class BroadcastEventDispatcher {
|
|
4
|
+
private eventHandlers;
|
|
5
|
+
constructor();
|
|
6
|
+
do(eventName: keyof typeof BROADCAST_EVENT_MAP, payload: BroadcastEventPayload): void;
|
|
7
|
+
private initHandlers;
|
|
8
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BroadcastEventDispatcher = void 0;
|
|
4
|
+
const broadcastEventMap_1 = require("../types/event/broadcast/broadcastEventMap");
|
|
5
|
+
class BroadcastEventDispatcher {
|
|
6
|
+
eventHandlers = new Map();
|
|
7
|
+
constructor() {
|
|
8
|
+
this.initHandlers();
|
|
9
|
+
}
|
|
10
|
+
do(eventName, payload) {
|
|
11
|
+
const handler = this.eventHandlers.get(eventName);
|
|
12
|
+
if (!handler) {
|
|
13
|
+
throw new Error(`Fail [do]: No event handler for '${eventName}'!`);
|
|
14
|
+
}
|
|
15
|
+
return handler.handle(payload);
|
|
16
|
+
}
|
|
17
|
+
// Initializes the event handlers by iterating over the BROADCAST_EVENT_MAP and creating instances of each handler.
|
|
18
|
+
initHandlers() {
|
|
19
|
+
for (const [eventName, EventHandlerClass] of Object.entries(broadcastEventMap_1.BROADCAST_EVENT_MAP)) {
|
|
20
|
+
this.eventHandlers.set(eventName, new EventHandlerClass());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.BroadcastEventDispatcher = BroadcastEventDispatcher;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EDMConfig, EDMParams } from '../modules/edm/types/data.types';
|
|
2
|
+
import { EdmBroadcastModule } from '../modules/edm/edmBroadcastModule';
|
|
3
|
+
import { BroadcastListeners } from '../modules/edm/types/event/broadcastEvent.types';
|
|
4
|
+
import type { AddImagePayload, NavigateStepPayload, SetStylePayload } from '../modules/edm/types';
|
|
5
|
+
export declare class EDM {
|
|
6
|
+
private params;
|
|
7
|
+
private config?;
|
|
8
|
+
static BASE_URL: string;
|
|
9
|
+
static broadCastEventHandler: EdmBroadcastModule | null;
|
|
10
|
+
private nonce;
|
|
11
|
+
private iFrameManager;
|
|
12
|
+
private communicator;
|
|
13
|
+
private moduleLoader;
|
|
14
|
+
private initialized;
|
|
15
|
+
constructor(params: EDMParams, config?: EDMConfig | undefined, callbacks?: Partial<BroadcastListeners>);
|
|
16
|
+
init(): Promise<void>;
|
|
17
|
+
saveDesign(): Promise<import("..").HandledResponse<import("../modules/edm/types").SaveDesignResultPayload, Error>>;
|
|
18
|
+
setStyle(payload: SetStylePayload): Promise<import("..").HandledResponse<import("../modules/edm/types").SetStyleResultPayload, Error>>;
|
|
19
|
+
addImage(payload: AddImagePayload): Promise<import("..").HandledResponse<import("../modules/edm/types").AddImageResultPayload, Error>>;
|
|
20
|
+
navigateStep(payload: NavigateStepPayload): Promise<import("..").HandledResponse<import("../modules/edm/types").NavigateStepResultPayload, Error>>;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
static getBroadCastEventHandler(): EdmBroadcastModule;
|
|
23
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EDM = void 0;
|
|
4
|
+
const iFrameManager_1 = require("../services/iFrameManager");
|
|
5
|
+
const embedCommunicator_1 = require("../services/embedCommunicator");
|
|
6
|
+
const moduleLoaderService_1 = require("../services/moduleLoaderService");
|
|
7
|
+
const messageLogger_1 = require("../helpers/messageLogger");
|
|
8
|
+
const moduleNames_1 = require("../modules/moduleNames");
|
|
9
|
+
const version_1 = require("../version");
|
|
10
|
+
const edmBroadcastModule_1 = require("../modules/edm/edmBroadcastModule");
|
|
11
|
+
class EDM {
|
|
12
|
+
params;
|
|
13
|
+
config;
|
|
14
|
+
static BASE_URL = 'https://www.printful.com/embedded-designer';
|
|
15
|
+
static broadCastEventHandler;
|
|
16
|
+
nonce;
|
|
17
|
+
iFrameManager = null;
|
|
18
|
+
communicator = embedCommunicator_1.EmbedCommunicator.getInstance();
|
|
19
|
+
moduleLoader = moduleLoaderService_1.ModuleLoaderService.getInstance();
|
|
20
|
+
initialized = false;
|
|
21
|
+
constructor(params, config, callbacks) {
|
|
22
|
+
this.params = params;
|
|
23
|
+
this.config = config;
|
|
24
|
+
this.nonce = params.nonce;
|
|
25
|
+
EDM.broadCastEventHandler = new edmBroadcastModule_1.EdmBroadcastModule(callbacks);
|
|
26
|
+
(0, messageLogger_1.setLoggerState)(params?.debug ?? false, messageLogger_1.SOURCES.EDM);
|
|
27
|
+
}
|
|
28
|
+
async init() {
|
|
29
|
+
if (this.initialized) {
|
|
30
|
+
(0, messageLogger_1.logEmbedMessage)({
|
|
31
|
+
message: 'EDM already initialized',
|
|
32
|
+
logType: messageLogger_1.LOG_TYPES.WARN,
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const elementToBindTo = this.params.element ?? document.getElementById(this.params.elementId);
|
|
37
|
+
if (!elementToBindTo) {
|
|
38
|
+
(0, messageLogger_1.logEmbedMessage)({
|
|
39
|
+
message: 'Cant find element for EDM',
|
|
40
|
+
logType: messageLogger_1.LOG_TYPES.ERROR,
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.iFrameManager = new iFrameManager_1.iFrameManager({
|
|
45
|
+
baseUrl: EDM.BASE_URL,
|
|
46
|
+
urlParams: {
|
|
47
|
+
nonce: this.nonce,
|
|
48
|
+
sdkMode: true,
|
|
49
|
+
locale: this.config?.locale ?? '',
|
|
50
|
+
},
|
|
51
|
+
class: this.params.iframeClassName,
|
|
52
|
+
elementToAppendTo: elementToBindTo,
|
|
53
|
+
});
|
|
54
|
+
await this.iFrameManager.create();
|
|
55
|
+
this.communicator.setIFrameManager(moduleNames_1.MODULE_NAMES.EDM, this.iFrameManager);
|
|
56
|
+
this.communicator.setupListener();
|
|
57
|
+
const edmModule = this.moduleLoader.getModule(moduleNames_1.MODULE_NAMES.EDM);
|
|
58
|
+
const notification = await edmModule.setup({
|
|
59
|
+
...this.config,
|
|
60
|
+
...this.params,
|
|
61
|
+
clientVersion: version_1.VERSION,
|
|
62
|
+
});
|
|
63
|
+
(0, messageLogger_1.logEmbedMessage)({
|
|
64
|
+
message: ['EDM setup notification', notification],
|
|
65
|
+
logType: messageLogger_1.LOG_TYPES.LOG,
|
|
66
|
+
});
|
|
67
|
+
this.initialized = true;
|
|
68
|
+
}
|
|
69
|
+
saveDesign() {
|
|
70
|
+
const edmModule = this.moduleLoader.getModule(moduleNames_1.MODULE_NAMES.EDM);
|
|
71
|
+
return edmModule.saveDesign();
|
|
72
|
+
}
|
|
73
|
+
setStyle(payload) {
|
|
74
|
+
const edmModule = this.moduleLoader.getModule(moduleNames_1.MODULE_NAMES.EDM);
|
|
75
|
+
return edmModule.setStyle(payload);
|
|
76
|
+
}
|
|
77
|
+
addImage(payload) {
|
|
78
|
+
const edmModule = this.moduleLoader.getModule(moduleNames_1.MODULE_NAMES.EDM);
|
|
79
|
+
return edmModule.addImage(payload);
|
|
80
|
+
}
|
|
81
|
+
navigateStep(payload) {
|
|
82
|
+
const edmModule = this.moduleLoader.getModule(moduleNames_1.MODULE_NAMES.EDM);
|
|
83
|
+
return edmModule.navigateStep(payload);
|
|
84
|
+
}
|
|
85
|
+
destroy() {
|
|
86
|
+
if (this.iFrameManager) {
|
|
87
|
+
this.iFrameManager.destroy();
|
|
88
|
+
this.iFrameManager = null;
|
|
89
|
+
}
|
|
90
|
+
this.communicator.cleanup();
|
|
91
|
+
this.moduleLoader.clearCache();
|
|
92
|
+
this.initialized = false;
|
|
93
|
+
EDM.broadCastEventHandler = null;
|
|
94
|
+
}
|
|
95
|
+
static getBroadCastEventHandler() {
|
|
96
|
+
if (!EDM.broadCastEventHandler) {
|
|
97
|
+
throw new Error('No active EdmBroadcastModule instance');
|
|
98
|
+
}
|
|
99
|
+
return EDM.broadCastEventHandler;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.EDM = EDM;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CatalogService } from '../modules/catalog/catalogService';
|
|
2
|
+
import { MockupService } from '../modules/mockup-generation/mockupService';
|
|
3
|
+
import { ProductPublishService } from '../modules/product-publish/productPublishService';
|
|
4
|
+
import { SdkConfig } from '../modules/sdk/types';
|
|
5
|
+
export declare class Embed {
|
|
6
|
+
private config?;
|
|
7
|
+
static BASE_URL: string;
|
|
8
|
+
private nonce;
|
|
9
|
+
private iFrameManager;
|
|
10
|
+
private communicator;
|
|
11
|
+
private moduleLoader;
|
|
12
|
+
private initialized;
|
|
13
|
+
readonly catalog: CatalogService;
|
|
14
|
+
readonly mockup: MockupService;
|
|
15
|
+
readonly publish: ProductPublishService;
|
|
16
|
+
constructor(nonce: string, config?: SdkConfig | undefined);
|
|
17
|
+
init(): Promise<void>;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Embed = void 0;
|
|
4
|
+
const iFrameManager_1 = require("../services/iFrameManager");
|
|
5
|
+
const embedCommunicator_1 = require("../services/embedCommunicator");
|
|
6
|
+
const moduleLoaderService_1 = require("../services/moduleLoaderService");
|
|
7
|
+
const catalogService_1 = require("../modules/catalog/catalogService");
|
|
8
|
+
const mockupService_1 = require("../modules/mockup-generation/mockupService");
|
|
9
|
+
const productPublishService_1 = require("../modules/product-publish/productPublishService");
|
|
10
|
+
const messageLogger_1 = require("../helpers/messageLogger");
|
|
11
|
+
const modules_1 = require("../modules/modules");
|
|
12
|
+
const version_1 = require("../version");
|
|
13
|
+
class Embed {
|
|
14
|
+
config;
|
|
15
|
+
static BASE_URL = 'https://www.printful.com/embed-sdk';
|
|
16
|
+
nonce;
|
|
17
|
+
iFrameManager = null;
|
|
18
|
+
communicator = embedCommunicator_1.EmbedCommunicator.getInstance();
|
|
19
|
+
moduleLoader = moduleLoaderService_1.ModuleLoaderService.getInstance();
|
|
20
|
+
initialized = false;
|
|
21
|
+
// Service composition
|
|
22
|
+
catalog;
|
|
23
|
+
mockup;
|
|
24
|
+
publish;
|
|
25
|
+
constructor(nonce, config) {
|
|
26
|
+
this.config = config;
|
|
27
|
+
this.nonce = nonce;
|
|
28
|
+
(0, messageLogger_1.setLoggerState)(config?.debug ?? false, messageLogger_1.SOURCES.SDK);
|
|
29
|
+
// Initialize services
|
|
30
|
+
this.catalog = new catalogService_1.CatalogService();
|
|
31
|
+
this.mockup = new mockupService_1.MockupService();
|
|
32
|
+
this.publish = new productPublishService_1.ProductPublishService();
|
|
33
|
+
}
|
|
34
|
+
async init() {
|
|
35
|
+
if (this.initialized) {
|
|
36
|
+
(0, messageLogger_1.logEmbedMessage)({
|
|
37
|
+
message: 'Embed SDK already initialized',
|
|
38
|
+
logType: messageLogger_1.LOG_TYPES.WARN,
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// Client mode: Create iframe and setup communication
|
|
43
|
+
this.iFrameManager = new iFrameManager_1.iFrameManager({
|
|
44
|
+
baseUrl: Embed.BASE_URL,
|
|
45
|
+
urlParams: {
|
|
46
|
+
nonce: this.nonce,
|
|
47
|
+
},
|
|
48
|
+
style: {
|
|
49
|
+
display: 'none',
|
|
50
|
+
position: 'fixed',
|
|
51
|
+
width: '0',
|
|
52
|
+
height: '0',
|
|
53
|
+
border: 'none',
|
|
54
|
+
},
|
|
55
|
+
elementToAppendTo: document.body,
|
|
56
|
+
});
|
|
57
|
+
await this.iFrameManager.create();
|
|
58
|
+
// Setup communicator with iframe manager
|
|
59
|
+
this.communicator.setIFrameManager(modules_1.MODULE_NAMES.SDK, this.iFrameManager);
|
|
60
|
+
this.communicator.setupListener();
|
|
61
|
+
// Get SDK module and setup
|
|
62
|
+
const sdkModule = this.moduleLoader.getModule(modules_1.MODULE_NAMES.SDK);
|
|
63
|
+
const notification = await sdkModule.setup({
|
|
64
|
+
...this.config,
|
|
65
|
+
clientVersion: version_1.VERSION,
|
|
66
|
+
});
|
|
67
|
+
(0, messageLogger_1.logEmbedMessage)({
|
|
68
|
+
message: ['SDK (Main) module setup notification', notification],
|
|
69
|
+
logType: messageLogger_1.LOG_TYPES.LOG,
|
|
70
|
+
});
|
|
71
|
+
this.initialized = true;
|
|
72
|
+
}
|
|
73
|
+
destroy() {
|
|
74
|
+
if (this.iFrameManager) {
|
|
75
|
+
this.iFrameManager.destroy();
|
|
76
|
+
this.iFrameManager = null;
|
|
77
|
+
}
|
|
78
|
+
this.communicator.cleanup();
|
|
79
|
+
this.moduleLoader.clearCache();
|
|
80
|
+
this.initialized = false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.Embed = Embed;
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { iFrameManager } from './iFrameManager';
|
|
2
2
|
import { ActionEvent, ActionEventName } from '../types/event/action/actionEvent.types';
|
|
3
3
|
import { ActionEventPayload } from '../types/event/action/actionEventPayload.types';
|
|
4
|
+
import { BroadcastEvent } from '../types/event/broadcast/broadcastEvent.types';
|
|
5
|
+
import { MODULE_NAMES } from '../modules/moduleNames';
|
|
4
6
|
export declare class EmbedCommunicator {
|
|
5
7
|
#private;
|
|
8
|
+
private broadcastEventHandler;
|
|
6
9
|
private messageBroker;
|
|
7
|
-
private
|
|
10
|
+
private iFrameManagers;
|
|
8
11
|
private isListening;
|
|
9
12
|
private constructor();
|
|
10
13
|
static getInstance(): EmbedCommunicator;
|
|
11
|
-
sendCorrelatedRequest<TReturn>(eventName: ActionEventName, payload?: ActionEventPayload): Promise<TReturn>;
|
|
12
|
-
setIFrameManager(iFrameManager: iFrameManager): void;
|
|
14
|
+
sendCorrelatedRequest<TReturn>(eventName: ActionEventName, moduleType: typeof MODULE_NAMES.SDK | typeof MODULE_NAMES.EDM, payload?: ActionEventPayload): Promise<TReturn>;
|
|
15
|
+
setIFrameManager(mainModule: typeof MODULE_NAMES.SDK | typeof MODULE_NAMES.EDM, iFrameManager: iFrameManager): void;
|
|
13
16
|
setupListener(): void;
|
|
14
17
|
private handleInboundMessageEvent;
|
|
15
18
|
private handleInboundEvent;
|
|
16
19
|
private handleInboundEventNotification;
|
|
20
|
+
private getIframeManagerByMainModule;
|
|
17
21
|
private isNotificationSuccess;
|
|
22
|
+
isValidBroadcastEvent(event: BroadcastEvent): false | import("../modules/edm/types").OnDesignStatusEvent | import("../modules/edm/types").OnErrorEvent | import("../modules/edm/types").OnFilePickerRequestedEvent | import("../modules/edm/types").StepResponse | import("../modules/edm/types/event/broadcastEventPayload.types").OnPricingStatusUpdateEventPayload | undefined;
|
|
18
23
|
private resolveSuccessfulEvent;
|
|
19
|
-
|
|
24
|
+
handleBroadcastEvent(event: BroadcastEvent): void;
|
|
25
|
+
protected send(event: ActionEvent, moduleType: typeof MODULE_NAMES.SDK | typeof MODULE_NAMES.EDM): void;
|
|
20
26
|
cleanup(): void;
|
|
21
27
|
}
|
|
@@ -4,10 +4,14 @@ exports.EmbedCommunicator = void 0;
|
|
|
4
4
|
const messageBroker_1 = require("./messageBroker");
|
|
5
5
|
const eventTypes_1 = require("../modules/eventTypes");
|
|
6
6
|
const messageLogger_1 = require("../helpers/messageLogger");
|
|
7
|
+
const broadcastEventMap_1 = require("../types/event/broadcast/broadcastEventMap");
|
|
8
|
+
const broadcastEventDispatcher_1 = require("../services/broadcastEventDispatcher");
|
|
9
|
+
const moduleNames_1 = require("../modules/moduleNames");
|
|
7
10
|
class EmbedCommunicator {
|
|
8
11
|
static #instance;
|
|
12
|
+
broadcastEventHandler = new broadcastEventDispatcher_1.BroadcastEventDispatcher();
|
|
9
13
|
messageBroker = new messageBroker_1.MessageBroker();
|
|
10
|
-
|
|
14
|
+
iFrameManagers = { [moduleNames_1.MODULE_NAMES.SDK]: null, [moduleNames_1.MODULE_NAMES.EDM]: null };
|
|
11
15
|
isListening = false;
|
|
12
16
|
constructor() { }
|
|
13
17
|
static getInstance() {
|
|
@@ -16,7 +20,7 @@ class EmbedCommunicator {
|
|
|
16
20
|
}
|
|
17
21
|
return EmbedCommunicator.#instance;
|
|
18
22
|
}
|
|
19
|
-
async sendCorrelatedRequest(eventName, payload) {
|
|
23
|
+
async sendCorrelatedRequest(eventName, moduleType, payload) {
|
|
20
24
|
if (!this.isListening) {
|
|
21
25
|
(0, messageLogger_1.logEmbedMessage)({
|
|
22
26
|
message: 'Warn [sendCorrelatedRequest]: Communicator is not listening, response may be ignored!',
|
|
@@ -32,11 +36,11 @@ class EmbedCommunicator {
|
|
|
32
36
|
payload,
|
|
33
37
|
correlationId,
|
|
34
38
|
};
|
|
35
|
-
this.send(actionEvent);
|
|
39
|
+
this.send(actionEvent, moduleType);
|
|
36
40
|
return pendingMessagePromise;
|
|
37
41
|
}
|
|
38
|
-
setIFrameManager(iFrameManager) {
|
|
39
|
-
this.
|
|
42
|
+
setIFrameManager(mainModule, iFrameManager) {
|
|
43
|
+
this.iFrameManagers[mainModule] = iFrameManager;
|
|
40
44
|
}
|
|
41
45
|
setupListener() {
|
|
42
46
|
if (this.isListening) {
|
|
@@ -52,16 +56,21 @@ class EmbedCommunicator {
|
|
|
52
56
|
message: ['Received message', event.data],
|
|
53
57
|
logType: messageLogger_1.LOG_TYPES.LOG,
|
|
54
58
|
});
|
|
55
|
-
|
|
59
|
+
const iframeManagerType = this.getIframeManagerByMainModule(event);
|
|
60
|
+
if (!iframeManagerType) {
|
|
56
61
|
throw new Error('iFrameManager not set');
|
|
57
62
|
}
|
|
58
63
|
// Only process messages from our iframe
|
|
59
|
-
if (!
|
|
64
|
+
if (!iframeManagerType.isMessageFromIFrame(event)) {
|
|
60
65
|
return;
|
|
61
66
|
}
|
|
62
67
|
this.handleInboundEvent(event.data);
|
|
63
68
|
}
|
|
64
69
|
handleInboundEvent(event) {
|
|
70
|
+
if ((0, eventTypes_1.isBroadcast)(event)) {
|
|
71
|
+
this.handleBroadcastEvent(event);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
65
74
|
if (!event.correlationId) {
|
|
66
75
|
throw new Error(`Fail [handleInboundEvent (${event.name})]: correlationId missing`);
|
|
67
76
|
}
|
|
@@ -78,6 +87,9 @@ class EmbedCommunicator {
|
|
|
78
87
|
throw new Error('Fail [handleInboundEvent]: Unsupported event type received!');
|
|
79
88
|
}
|
|
80
89
|
handleInboundEventNotification(event) {
|
|
90
|
+
if (!event.correlationId) {
|
|
91
|
+
throw new Error(`Fail [handleInboundEventNotification (${event.name})]: correlationId missing`);
|
|
92
|
+
}
|
|
81
93
|
if (this.isNotificationSuccess(event)) {
|
|
82
94
|
this.resolveSuccessfulEvent(event);
|
|
83
95
|
return;
|
|
@@ -86,20 +98,40 @@ class EmbedCommunicator {
|
|
|
86
98
|
// Error should always be provided on a notification with fail status
|
|
87
99
|
event.payload);
|
|
88
100
|
}
|
|
101
|
+
getIframeManagerByMainModule(event) {
|
|
102
|
+
for (const manager of Object.values(this.iFrameManagers)) {
|
|
103
|
+
if (manager?.isMessageFromIFrame(event)) {
|
|
104
|
+
return manager;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
89
109
|
isNotificationSuccess(event) {
|
|
90
110
|
if (!event.payload) {
|
|
91
111
|
throw new Error(`Fail [handleNotification (${event.name})] Payload missing!`);
|
|
92
112
|
}
|
|
93
113
|
return event.payload.status === 'success';
|
|
94
114
|
}
|
|
115
|
+
isValidBroadcastEvent(event) {
|
|
116
|
+
return event.name in broadcastEventMap_1.BROADCAST_EVENT_MAP && event.payload;
|
|
117
|
+
}
|
|
95
118
|
resolveSuccessfulEvent(event) {
|
|
119
|
+
if (!event.correlationId) {
|
|
120
|
+
throw new Error(`Fail [resolveSuccessfulEvent (${event.name})]: correlationId missing`);
|
|
121
|
+
}
|
|
96
122
|
this.messageBroker.resolveMessage(event.correlationId, event.payload);
|
|
97
123
|
}
|
|
98
|
-
|
|
99
|
-
if (!this.
|
|
124
|
+
handleBroadcastEvent(event) {
|
|
125
|
+
if (!this.isValidBroadcastEvent(event) || !event.payload) {
|
|
126
|
+
throw new Error(`Fail [handleInboundEvent (${event.name})]: Broadcast event payload missing`);
|
|
127
|
+
}
|
|
128
|
+
this.broadcastEventHandler.do(event.name, event.payload);
|
|
129
|
+
}
|
|
130
|
+
send(event, moduleType) {
|
|
131
|
+
if (!this.iFrameManagers[moduleType]) {
|
|
100
132
|
throw new Error('iFrameManager not set');
|
|
101
133
|
}
|
|
102
|
-
this.
|
|
134
|
+
this.iFrameManagers[moduleType].postMessage(event);
|
|
103
135
|
}
|
|
104
136
|
cleanup() {
|
|
105
137
|
this.messageBroker.clearAll();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export interface IFrameConfig {
|
|
2
2
|
baseUrl: string;
|
|
3
|
-
nonce: string;
|
|
4
3
|
style?: Partial<CSSStyleDeclaration>;
|
|
4
|
+
urlParams: Record<string, string | number | boolean>;
|
|
5
|
+
class?: string;
|
|
6
|
+
elementToAppendTo: HTMLElement;
|
|
5
7
|
}
|
|
6
8
|
export declare class iFrameManager {
|
|
7
9
|
private config;
|
|
@@ -13,17 +13,14 @@ class iFrameManager {
|
|
|
13
13
|
return new Promise((resolve, reject) => {
|
|
14
14
|
this.destroy();
|
|
15
15
|
const iFrame = document.createElement('iframe');
|
|
16
|
-
// Apply default styles
|
|
17
|
-
iFrame.style.display = 'none';
|
|
18
|
-
iFrame.style.position = 'fixed';
|
|
19
|
-
iFrame.style.width = '0';
|
|
20
|
-
iFrame.style.height = '0';
|
|
21
|
-
iFrame.style.border = 'none';
|
|
22
|
-
// Apply custom styles if provided
|
|
23
16
|
if (this.config.style) {
|
|
24
17
|
Object.assign(iFrame.style, this.config.style);
|
|
25
18
|
}
|
|
26
|
-
|
|
19
|
+
if (this.config.class) {
|
|
20
|
+
iFrame.setAttribute('class', this.config.class);
|
|
21
|
+
}
|
|
22
|
+
const convertedUrlParams = Object.entries(this.config.urlParams).map(([k, v]) => [k, String(v)]);
|
|
23
|
+
iFrame.src = `${this.config.baseUrl}?${new URLSearchParams(convertedUrlParams).toString()}`;
|
|
27
24
|
let settled = false;
|
|
28
25
|
const cleanup = () => {
|
|
29
26
|
settled = true;
|
|
@@ -46,7 +43,7 @@ class iFrameManager {
|
|
|
46
43
|
};
|
|
47
44
|
iFrame.addEventListener('load', onLoad);
|
|
48
45
|
iFrame.addEventListener('error', onError);
|
|
49
|
-
|
|
46
|
+
this.config.elementToAppendTo.appendChild(iFrame);
|
|
50
47
|
});
|
|
51
48
|
}
|
|
52
49
|
destroy() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ModuleName } from '../types/module/module.types';
|
|
2
2
|
import { MODULES } from '../modules/modules';
|
|
3
3
|
import { ModuleConfig, ModuleConfigData } from '../types/module/moduleConfig.types';
|
|
4
|
-
type ModuleInstance = InstanceType<(typeof MODULES)[keyof typeof MODULES]>;
|
|
4
|
+
export type ModuleInstance = InstanceType<(typeof MODULES)[keyof typeof MODULES]>;
|
|
5
5
|
export declare class ModuleLoaderService {
|
|
6
6
|
private static instance;
|
|
7
7
|
private communicator;
|
|
@@ -13,4 +13,3 @@ export declare class ModuleLoaderService {
|
|
|
13
13
|
clearCache(): void;
|
|
14
14
|
isModuleLoaded(moduleName: ModuleName): boolean;
|
|
15
15
|
}
|
|
16
|
-
export {};
|
|
@@ -23,7 +23,8 @@ class ModuleLoaderService {
|
|
|
23
23
|
return this.moduleCache.get(moduleName);
|
|
24
24
|
}
|
|
25
25
|
async loadModule(config) {
|
|
26
|
-
const
|
|
26
|
+
const mainModule = modules_1.MODULE_DEPENDENCY_MAP[config.name];
|
|
27
|
+
const notification = await this.communicator.sendCorrelatedRequest(types_1.EVENTS_ACTION.LOAD_MODULE, mainModule, config);
|
|
27
28
|
(0, messageLogger_1.logEmbedMessage)({
|
|
28
29
|
message: ['Loaded module', notification],
|
|
29
30
|
logType: messageLogger_1.LOG_TYPES.LOG,
|
|
@@ -2,10 +2,11 @@ import { ActionEvent as SdkActionEvent } from '../../../modules/sdk/types/event/
|
|
|
2
2
|
import { ActionEvent as CatalogActionEvent } from '../../../modules/catalog/types/event/actionEvent.types';
|
|
3
3
|
import { ActionEvent as MockupGenerationActionEvent } from '../../../modules/mockup-generation/types/event/actionEvent.types';
|
|
4
4
|
import { ActionEvent as ProductPublishActionEvent } from '../../../modules/product-publish/types/event/actionEvent.types';
|
|
5
|
+
import { ActionEvent as EdmActionEvent } from '../../../modules/edm/types/event/actionEvent.types';
|
|
5
6
|
import { ALL_ACTION_EVENTS } from '../../../modules/events';
|
|
6
7
|
import { Event } from '../../../types/event/event.types';
|
|
7
8
|
import { EVENT_TYPES } from '../../../modules/eventTypes';
|
|
8
9
|
import { ActionEventPayload } from './actionEventPayload.types';
|
|
9
10
|
export type ActionEventName = (typeof ALL_ACTION_EVENTS)[keyof typeof ALL_ACTION_EVENTS];
|
|
10
11
|
export type BaseActionEvent<TName extends ActionEventName, TPayload extends ActionEventPayload> = Event<TName, typeof EVENT_TYPES.ACTION, TPayload>;
|
|
11
|
-
export type ActionEvent = MockupGenerationActionEvent | CatalogActionEvent | ProductPublishActionEvent | SdkActionEvent;
|
|
12
|
+
export type ActionEvent = MockupGenerationActionEvent | CatalogActionEvent | ProductPublishActionEvent | SdkActionEvent | EdmActionEvent;
|
|
@@ -2,4 +2,5 @@ import { ActionEventPayload as SdkEventPayload, LoadModulePayload } from '../../
|
|
|
2
2
|
import { ActionEventPayload as CatalogEventPayload } from '../../../modules/catalog/types/event/actionEventPayload.types';
|
|
3
3
|
import { ActionEventPayload as MockupGenerationEventPayload } from '../../../modules/mockup-generation/types/event/actionEventPayload.types';
|
|
4
4
|
import { ActionEventPayload as ProductPublishEventPayload } from '../../../modules/product-publish/types/event/actionEventPayload.types';
|
|
5
|
-
|
|
5
|
+
import { ActionEventPayload as EdmEventPayload } from '../../../modules/edm/types/event/actionEventPayload.types';
|
|
6
|
+
export type ActionEventPayload = LoadModulePayload | MockupGenerationEventPayload | CatalogEventPayload | SdkEventPayload | ProductPublishEventPayload | EdmEventPayload | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ALL_BROADCAST_EVENTS } from '../../../modules/events';
|
|
2
|
+
import { Event } from '../../../types/event/event.types';
|
|
3
|
+
import { EVENT_TYPES } from '../../../modules/eventTypes';
|
|
4
|
+
import { BroadcastEventPayload } from '../../../types/event/broadcast/broadcastEventPayload.types';
|
|
5
|
+
import { BroadcastEvent as EdmBroadcastEvent } from '../../../modules/edm/types/event/broadcastEvent.types';
|
|
6
|
+
export type BroadcastEventName = (typeof ALL_BROADCAST_EVENTS)[keyof typeof ALL_BROADCAST_EVENTS];
|
|
7
|
+
export type BaseBroadcastEvent<TName extends BroadcastEventName, TPayload extends BroadcastEventPayload> = Event<TName, typeof EVENT_TYPES.BROADCAST, TPayload>;
|
|
8
|
+
export type BroadcastEvent = EdmBroadcastEvent;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BroadcastEventPayload } from '../../../types/event/broadcast/broadcastEventPayload.types';
|
|
2
|
+
import { BROADCAST_EVENT_MAP } from '../../../types/event/broadcast/broadcastEventMap';
|
|
3
|
+
export interface BroadcastEventHandler {
|
|
4
|
+
handle(payload?: BroadcastEventPayload): typeof BROADCAST_EVENT_MAP;
|
|
5
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OnDesignStatusUpdate } from '../../../modules/edm/broadcastEvents/onDesignStatusUpdate';
|
|
2
|
+
import { OnStepStatusUpdate } from '../../../modules/edm/broadcastEvents/onStepStatusUpdate';
|
|
3
|
+
import { OnPricingStatusUpdate } from '../../../modules/edm/broadcastEvents/onPricingStatusUpdate';
|
|
4
|
+
import { OnFilePickerRequested } from '../../../modules/edm/broadcastEvents/onFilePickerRequested';
|
|
5
|
+
import { OnErrorUpdate } from '../../../modules/edm/broadcastEvents/onErrorUpdate';
|
|
6
|
+
export declare const BROADCAST_EVENT_MAP: {
|
|
7
|
+
onDesignStatusUpdate: typeof OnDesignStatusUpdate;
|
|
8
|
+
onFilePickerRequested: typeof OnFilePickerRequested;
|
|
9
|
+
onStepStatusUpdate: typeof OnStepStatusUpdate;
|
|
10
|
+
onPricingStatusUpdate: typeof OnPricingStatusUpdate;
|
|
11
|
+
onError: typeof OnErrorUpdate;
|
|
12
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BROADCAST_EVENT_MAP = void 0;
|
|
4
|
+
const events_1 = require("../../../modules/events");
|
|
5
|
+
const onDesignStatusUpdate_1 = require("../../../modules/edm/broadcastEvents/onDesignStatusUpdate");
|
|
6
|
+
const onStepStatusUpdate_1 = require("../../../modules/edm/broadcastEvents/onStepStatusUpdate");
|
|
7
|
+
const onPricingStatusUpdate_1 = require("../../../modules/edm/broadcastEvents/onPricingStatusUpdate");
|
|
8
|
+
const onFilePickerRequested_1 = require("../../../modules/edm/broadcastEvents/onFilePickerRequested");
|
|
9
|
+
const onErrorUpdate_1 = require("../../../modules/edm/broadcastEvents/onErrorUpdate");
|
|
10
|
+
exports.BROADCAST_EVENT_MAP = {
|
|
11
|
+
[events_1.ALL_BROADCAST_EVENTS.ON_DESIGN_STATUS_UPDATE]: onDesignStatusUpdate_1.OnDesignStatusUpdate,
|
|
12
|
+
[events_1.ALL_BROADCAST_EVENTS.ON_FILE_PICKER_REQUESTED]: onFilePickerRequested_1.OnFilePickerRequested,
|
|
13
|
+
[events_1.ALL_BROADCAST_EVENTS.ON_STEP_STATUS_UPDATE]: onStepStatusUpdate_1.OnStepStatusUpdate,
|
|
14
|
+
[events_1.ALL_BROADCAST_EVENTS.ON_PRICING_STATUS_UPDATE]: onPricingStatusUpdate_1.OnPricingStatusUpdate,
|
|
15
|
+
[events_1.ALL_BROADCAST_EVENTS.ON_INTERNAL_ERROR]: onErrorUpdate_1.OnErrorUpdate,
|
|
16
|
+
};
|
|
@@ -4,12 +4,13 @@ import type { NotificationEvent } from './notification/notificationEvent.types';
|
|
|
4
4
|
import type { ResultEvent } from './result/resultEvent.types';
|
|
5
5
|
import { EVENT_TYPES } from '../../modules/eventTypes';
|
|
6
6
|
import { EventPayload } from './eventPayload.types';
|
|
7
|
+
import { BroadcastEvent } from '../../types/event/broadcast/broadcastEvent.types';
|
|
7
8
|
export type EventName = (typeof ALL_EVENTS)[keyof typeof ALL_EVENTS];
|
|
8
9
|
export type EventTypeName = (typeof EVENT_TYPES)[keyof typeof EVENT_TYPES];
|
|
9
10
|
export interface Event<TName extends EventName, TType extends EventTypeName, TPayload extends EventPayload> {
|
|
10
11
|
name: TName;
|
|
11
12
|
type: TType;
|
|
12
13
|
payload?: TPayload;
|
|
13
|
-
correlationId
|
|
14
|
+
correlationId?: string;
|
|
14
15
|
}
|
|
15
|
-
export type AnyEvent = ActionEvent | NotificationEvent | ResultEvent;
|
|
16
|
+
export type AnyEvent = ActionEvent | NotificationEvent | ResultEvent | BroadcastEvent;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ActionEventPayload } from './action/actionEventPayload.types';
|
|
2
2
|
import type { NotificationEventPayload } from './notification/notificationEventPayload.types';
|
|
3
3
|
import { ResultEventPayload } from './result/resultEventPayload.types';
|
|
4
|
-
|
|
4
|
+
import { BroadcastEventPayload } from '../../types/event/broadcast/broadcastEventPayload.types';
|
|
5
|
+
export type EventPayload = ActionEventPayload | NotificationEventPayload | ResultEventPayload | BroadcastEventPayload | undefined;
|