@elliemae/microfe-common 2.0.0-next.30
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/app.config.json +17 -0
- package/dist/cjs/common.js +16 -0
- package/dist/cjs/event.js +67 -0
- package/dist/cjs/eventManager.js +201 -0
- package/dist/cjs/guest.js +16 -0
- package/dist/cjs/index.html +12 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/messageType.js +37 -0
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/remoting.js +386 -0
- package/dist/cjs/remotingEventMessage.js +16 -0
- package/dist/cjs/scriptingObject.js +119 -0
- package/dist/cjs/tests/scriptingObjects/appraisalServiceModule.js +101 -0
- package/dist/cjs/tests/scriptingObjects/constant.js +26 -0
- package/dist/cjs/tests/scriptingObjects/global.js +61 -0
- package/dist/esm/app.config.json +17 -0
- package/dist/esm/common.js +0 -0
- package/dist/esm/event.js +47 -0
- package/dist/esm/eventManager.js +182 -0
- package/dist/esm/guest.js +0 -0
- package/dist/esm/index.html +12 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/messageType.js +17 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/remoting.js +367 -0
- package/dist/esm/remotingEventMessage.js +0 -0
- package/dist/esm/scriptingObject.js +100 -0
- package/dist/esm/tests/scriptingObjects/appraisalServiceModule.js +82 -0
- package/dist/esm/tests/scriptingObjects/constant.js +6 -0
- package/dist/esm/tests/scriptingObjects/global.js +42 -0
- package/dist/types/common.d.ts +35 -0
- package/dist/types/event.d.ts +82 -0
- package/dist/types/eventManager.d.ts +125 -0
- package/dist/types/guest.d.ts +90 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/messageType.d.ts +13 -0
- package/dist/types/remoting.d.ts +237 -0
- package/dist/types/remotingEventMessage.d.ts +26 -0
- package/dist/types/scriptingObject.d.ts +37 -0
- package/dist/types/tests/eventManager.test.d.ts +1 -0
- package/dist/types/tests/scriptingObjects/appraisalServiceModule.d.ts +33 -0
- package/dist/types/tests/scriptingObjects/constant.d.ts +2 -0
- package/dist/types/tests/scriptingObjects/global.d.ts +10 -0
- package/package.json +62 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { IScriptingObject, IEvent, Events } from '@elliemae/pui-scripting-object';
|
|
2
|
+
import { EventListeners } from './common.js';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for scripting object proxy events
|
|
5
|
+
*/
|
|
6
|
+
export interface IScriptingObjectProxyEvent<EventsList extends EventListeners = Events> {
|
|
7
|
+
/**
|
|
8
|
+
* unique id of the event
|
|
9
|
+
*/
|
|
10
|
+
readonly id: Extract<keyof EventsList, string>;
|
|
11
|
+
/**
|
|
12
|
+
* name of the event
|
|
13
|
+
*/
|
|
14
|
+
readonly name: string;
|
|
15
|
+
/**
|
|
16
|
+
* scripting object id that owns this event
|
|
17
|
+
*/
|
|
18
|
+
readonly objectId: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* parameters for creating an event
|
|
22
|
+
*/
|
|
23
|
+
export type EventParam = {
|
|
24
|
+
/**
|
|
25
|
+
* name of the event
|
|
26
|
+
*/
|
|
27
|
+
name: string;
|
|
28
|
+
/**
|
|
29
|
+
* flag indicating this event requires feedback from all of the listeners
|
|
30
|
+
*/
|
|
31
|
+
requiresFeedback: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* scripting object that owns this event
|
|
34
|
+
*/
|
|
35
|
+
so: IScriptingObject;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Base class for all events
|
|
39
|
+
*/
|
|
40
|
+
export declare class Event<EventsList extends EventListeners = Events> implements IEvent {
|
|
41
|
+
/**
|
|
42
|
+
* scripting object that owns this event
|
|
43
|
+
*/
|
|
44
|
+
readonly scriptingObject: IScriptingObject;
|
|
45
|
+
/**
|
|
46
|
+
* name of the event
|
|
47
|
+
*/
|
|
48
|
+
readonly name: string;
|
|
49
|
+
/**
|
|
50
|
+
* scripting object id that owns this event
|
|
51
|
+
*/
|
|
52
|
+
readonly objectId: string;
|
|
53
|
+
/**
|
|
54
|
+
* flag indicating this event requires feedback from all of the listeners
|
|
55
|
+
*/
|
|
56
|
+
readonly requiresFeedback: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* unique id of the event
|
|
59
|
+
*/
|
|
60
|
+
readonly id: Extract<keyof EventsList, string>;
|
|
61
|
+
/**
|
|
62
|
+
* Create an event object
|
|
63
|
+
*
|
|
64
|
+
* @param {EventParam} param - parameters for creating an event
|
|
65
|
+
*/
|
|
66
|
+
constructor(param: EventParam);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Check given object is an event
|
|
70
|
+
*
|
|
71
|
+
* @param value object to check
|
|
72
|
+
* @returns true if given object is an event
|
|
73
|
+
*/
|
|
74
|
+
export declare const isEvent: (value: any) => value is Event<Events>;
|
|
75
|
+
/**
|
|
76
|
+
* Get normalized event ID for an object and event
|
|
77
|
+
*
|
|
78
|
+
* @param objectId scripting object id
|
|
79
|
+
* @param eventName event name
|
|
80
|
+
* @returns normalized event ID
|
|
81
|
+
*/
|
|
82
|
+
export declare const getEventId: (objectId: string, eventName: string) => string;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { IScriptingObject, Listener, Events } from '@elliemae/pui-scripting-object';
|
|
2
|
+
import { EventListeners } from './common.js';
|
|
3
|
+
/**
|
|
4
|
+
* details of an event listener
|
|
5
|
+
*/
|
|
6
|
+
type EventListenerDetails = {
|
|
7
|
+
/**
|
|
8
|
+
* event listener
|
|
9
|
+
*/
|
|
10
|
+
callback: Listener<any, any, any, any>;
|
|
11
|
+
/**
|
|
12
|
+
* subscription id
|
|
13
|
+
*/
|
|
14
|
+
subscriptionId: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* parameters for subscribing to an event
|
|
18
|
+
*/
|
|
19
|
+
export type SubscribeParam<EventId, EventListener> = {
|
|
20
|
+
/**
|
|
21
|
+
* unique id of the event
|
|
22
|
+
*/
|
|
23
|
+
eventId: EventId;
|
|
24
|
+
/**
|
|
25
|
+
* event listener
|
|
26
|
+
*/
|
|
27
|
+
listener: EventListener;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* parameters for unsubscribing from an event
|
|
31
|
+
*/
|
|
32
|
+
export type UnsubscribeParam<EventId> = {
|
|
33
|
+
/**
|
|
34
|
+
* unique id of the event
|
|
35
|
+
*/
|
|
36
|
+
eventId: EventId;
|
|
37
|
+
/**
|
|
38
|
+
* subscription id
|
|
39
|
+
*/
|
|
40
|
+
subscriptionId?: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* parameters for emitting an event
|
|
44
|
+
*/
|
|
45
|
+
export type EmitEventParam = {
|
|
46
|
+
/**
|
|
47
|
+
* name of the event
|
|
48
|
+
*/
|
|
49
|
+
eventName: string;
|
|
50
|
+
/**
|
|
51
|
+
* scripting object that owns this event
|
|
52
|
+
*/
|
|
53
|
+
scriptingObject: IScriptingObject;
|
|
54
|
+
/**
|
|
55
|
+
* event parameters
|
|
56
|
+
*/
|
|
57
|
+
eventParams: Record<string, unknown>;
|
|
58
|
+
/**
|
|
59
|
+
* event listeners
|
|
60
|
+
*/
|
|
61
|
+
listeners: EventListenerDetails[];
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* parameters for dispatching an event
|
|
65
|
+
*/
|
|
66
|
+
export type DispatchEventParam<EventId, Params> = {
|
|
67
|
+
/**
|
|
68
|
+
* event details
|
|
69
|
+
*/
|
|
70
|
+
event: {
|
|
71
|
+
/**
|
|
72
|
+
* unique id of the event
|
|
73
|
+
*/
|
|
74
|
+
id: EventId;
|
|
75
|
+
/**
|
|
76
|
+
* name of the event
|
|
77
|
+
*/
|
|
78
|
+
name: string;
|
|
79
|
+
/**
|
|
80
|
+
* flag indicating this event requires feedback from all of the listeners
|
|
81
|
+
*/
|
|
82
|
+
requiresFeedback: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* scripting object that owns this event
|
|
85
|
+
*/
|
|
86
|
+
scriptingObject: IScriptingObject;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* event parameters
|
|
90
|
+
*/
|
|
91
|
+
eventParams: Params;
|
|
92
|
+
/**
|
|
93
|
+
* time to wait for feedback from listeners. milliseconds
|
|
94
|
+
*/
|
|
95
|
+
feedbackWaitTime?: number;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Event Manager
|
|
99
|
+
*/
|
|
100
|
+
export declare class EventManager<AppEvents extends EventListeners = Events> {
|
|
101
|
+
#private;
|
|
102
|
+
/**
|
|
103
|
+
* dispatch an event
|
|
104
|
+
*
|
|
105
|
+
* @param {DispatchEventParam<EventId, Params>} param - parameters for dispatching an event
|
|
106
|
+
*/
|
|
107
|
+
dispatchEvent: <EventId extends Extract<keyof AppEvents, string>, Params extends Parameters<AppEvents[EventId]>[0]["eventParams"]>(param: DispatchEventParam<EventId, Params>) => Promise<void | any[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Subscribe to an event
|
|
110
|
+
*
|
|
111
|
+
* @param {SubscribeParam<EventId, AppEvents[EventId]>} param - parameters for subscribing to an event
|
|
112
|
+
*/
|
|
113
|
+
subscribe: <EventId extends Extract<keyof AppEvents, string>>(param: SubscribeParam<EventId, AppEvents[EventId]>) => string;
|
|
114
|
+
/**
|
|
115
|
+
* Unsubscribe from an event
|
|
116
|
+
*
|
|
117
|
+
* @param {UnsubscribeParam<EventId>} param - parameters for unsubscribing from an event
|
|
118
|
+
*/
|
|
119
|
+
unsubscribe: <EventId extends Extract<keyof AppEvents, string>>(param: UnsubscribeParam<EventId>) => void;
|
|
120
|
+
/**
|
|
121
|
+
* Unsubscribe from all events
|
|
122
|
+
*/
|
|
123
|
+
unsubscribeAll: () => void;
|
|
124
|
+
}
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { LogLevels } from '@elliemae/pui-diagnostics';
|
|
2
|
+
import type { IScriptingObjectProxy } from '@elliemae/pui-scripting-object';
|
|
3
|
+
import { EventListeners } from './common.js';
|
|
4
|
+
/**
|
|
5
|
+
* parameters for connecting to the host
|
|
6
|
+
*/
|
|
7
|
+
export type ConnectParam = {
|
|
8
|
+
/**
|
|
9
|
+
* reference to the guest window
|
|
10
|
+
*/
|
|
11
|
+
window?: Window;
|
|
12
|
+
} & Record<string, any>;
|
|
13
|
+
/**
|
|
14
|
+
* parameters for subscribing to an event
|
|
15
|
+
*/
|
|
16
|
+
export type SubscribeParam<EventId, EventListener> = {
|
|
17
|
+
/**
|
|
18
|
+
* unique id of the event
|
|
19
|
+
*/
|
|
20
|
+
eventId: EventId;
|
|
21
|
+
/**
|
|
22
|
+
* event listener
|
|
23
|
+
*/
|
|
24
|
+
callback: EventListener;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* parameters for unsubscribing from an event
|
|
28
|
+
*/
|
|
29
|
+
export type UnsubscribeParam<EventId> = {
|
|
30
|
+
/**
|
|
31
|
+
* unique id of the event
|
|
32
|
+
*/
|
|
33
|
+
eventId: EventId;
|
|
34
|
+
/**
|
|
35
|
+
* subscription token
|
|
36
|
+
*/
|
|
37
|
+
token: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Interface for SSF guest
|
|
41
|
+
*/
|
|
42
|
+
export interface ISSFGuest<AppEvents extends EventListeners> {
|
|
43
|
+
/**
|
|
44
|
+
* Initialize guest using script
|
|
45
|
+
*
|
|
46
|
+
* @param scriptUri uri of the script
|
|
47
|
+
* @param containerElement dom element to inject the script at
|
|
48
|
+
*/
|
|
49
|
+
addScript: (scriptUri: string, containerElement: HTMLElement) => Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Close the connection to the host
|
|
52
|
+
*/
|
|
53
|
+
close: () => void;
|
|
54
|
+
/**
|
|
55
|
+
* Connect to the host
|
|
56
|
+
*
|
|
57
|
+
* @param {ConnectParam} param - reference to the guest window or parameters
|
|
58
|
+
*/
|
|
59
|
+
connect: (param?: ConnectParam) => Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Get scripting object proxy by id
|
|
62
|
+
*
|
|
63
|
+
* @param objectId unique id of the scripting object
|
|
64
|
+
* @returns scripting object proxy
|
|
65
|
+
*/
|
|
66
|
+
getObject: (objectId: string) => Promise<IScriptingObjectProxy>;
|
|
67
|
+
/**
|
|
68
|
+
* remove the guest from the host
|
|
69
|
+
*/
|
|
70
|
+
removeScript: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* set the log level
|
|
73
|
+
*
|
|
74
|
+
* @param {LogLevels} logLevel - log level
|
|
75
|
+
*/
|
|
76
|
+
setLogLevel: (logLevel: LogLevels) => void;
|
|
77
|
+
/**
|
|
78
|
+
* subscribe to an scripting object event
|
|
79
|
+
*
|
|
80
|
+
* @param {SubscribeParam<EventId, AppEvents[EventId]>} param - parameters for subscribing to an event
|
|
81
|
+
* @returns subscription token
|
|
82
|
+
*/
|
|
83
|
+
subscribe: <EventId extends Extract<keyof AppEvents, string>>(param: SubscribeParam<EventId, AppEvents[EventId]>) => string;
|
|
84
|
+
/**
|
|
85
|
+
* unsubscribe from an scripting object event
|
|
86
|
+
*
|
|
87
|
+
* @param {UnsubscribeParam<EventId>} param - parameters for unsubscribing from an event
|
|
88
|
+
*/
|
|
89
|
+
unsubscribe: <EventId extends Extract<keyof AppEvents, string>>(param: UnsubscribeParam<EventId>) => void;
|
|
90
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Remoting, sendMessage } from './remoting.js';
|
|
2
|
+
export type { ListenerCallback, ListenerCallbackParams, ListenParam, InvokeParam, RaiseExceptionParam, RespondParam, SendParam, AddSenderParam, } from './remoting.js';
|
|
3
|
+
export type { RemotingEventMessage } from './remotingEventMessage.js';
|
|
4
|
+
export { EventManager } from './eventManager.js';
|
|
5
|
+
export type { EmitEventParam, SubscribeParam, UnsubscribeParam, DispatchEventParam, } from './eventManager.js';
|
|
6
|
+
export { getEventId } from './event.js';
|
|
7
|
+
export type { IScriptingObjectProxyEvent, EventParam } from './event.js';
|
|
8
|
+
export { Event } from './event.js';
|
|
9
|
+
export { ScriptingObject } from './scriptingObject.js';
|
|
10
|
+
export { MessageType } from './messageType.js';
|
|
11
|
+
export type { EventListeners } from './common.js';
|
|
12
|
+
export type { ISSFGuest, ConnectParam, SubscribeParam as GuestSubscribeParam, UnsubscribeParam as GuestUnsubscribeParam, } from './guest.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum MessageType {
|
|
2
|
+
GuestReady = "guest:ready",
|
|
3
|
+
GuestClose = "guest:close",
|
|
4
|
+
GuestReadyComplete = "guest:readyComplete",
|
|
5
|
+
GuestResize = "guest:resize",
|
|
6
|
+
GuestFocus = "guest:focus",
|
|
7
|
+
HandShake = "handshake",
|
|
8
|
+
HandShakeAck = "handshake:ack",
|
|
9
|
+
ObjectInvoke = "object:invoke",
|
|
10
|
+
ObjectGet = "object:get",
|
|
11
|
+
ObjectEvent = "object:event",
|
|
12
|
+
HostConfig = "host:config"
|
|
13
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { Logger } from '@elliemae/pui-diagnostics';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a callback parameters when a message is received
|
|
4
|
+
*/
|
|
5
|
+
export type ListenerCallbackParams<T> = {
|
|
6
|
+
/**
|
|
7
|
+
* The window that sent the message
|
|
8
|
+
*/
|
|
9
|
+
sourceWin: Window;
|
|
10
|
+
/**
|
|
11
|
+
* source origin
|
|
12
|
+
*/
|
|
13
|
+
sourceOrigin: string;
|
|
14
|
+
/**
|
|
15
|
+
* The unique ID of the message
|
|
16
|
+
*/
|
|
17
|
+
requestId: string;
|
|
18
|
+
/**
|
|
19
|
+
* The message type
|
|
20
|
+
*/
|
|
21
|
+
type: string;
|
|
22
|
+
/**
|
|
23
|
+
* The message body
|
|
24
|
+
*/
|
|
25
|
+
body: T;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Represents a callback to invoke when a message is received
|
|
29
|
+
*/
|
|
30
|
+
export type ListenerCallback<T> = ({ sourceWin, requestId, type, body, }: ListenerCallbackParams<T>) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Represents a message received from another window
|
|
33
|
+
*/
|
|
34
|
+
export type RemotingMessage = {
|
|
35
|
+
/**
|
|
36
|
+
* The unique ID of the message
|
|
37
|
+
*/
|
|
38
|
+
requestId: string | null;
|
|
39
|
+
/**
|
|
40
|
+
* The source of the message
|
|
41
|
+
*/
|
|
42
|
+
source: string;
|
|
43
|
+
/**
|
|
44
|
+
* The message type
|
|
45
|
+
*/
|
|
46
|
+
type: string;
|
|
47
|
+
/**
|
|
48
|
+
* The message body
|
|
49
|
+
*/
|
|
50
|
+
body: any;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Represents a message to be sent to another window
|
|
54
|
+
*/
|
|
55
|
+
export type InvokeParam = {
|
|
56
|
+
/**
|
|
57
|
+
* The window to send the message to
|
|
58
|
+
*/
|
|
59
|
+
targetWin: Window;
|
|
60
|
+
/**
|
|
61
|
+
* The origin of the target window
|
|
62
|
+
*/
|
|
63
|
+
targetOrigin: string;
|
|
64
|
+
/**
|
|
65
|
+
* The message type to send
|
|
66
|
+
*/
|
|
67
|
+
messageType: string;
|
|
68
|
+
/**
|
|
69
|
+
* The message body to send
|
|
70
|
+
*/
|
|
71
|
+
messageBody: unknown;
|
|
72
|
+
/**
|
|
73
|
+
* The timeout in milliseconds to wait for a response
|
|
74
|
+
*/
|
|
75
|
+
responseTimeoutMs?: number;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Represents a listener registration
|
|
79
|
+
*/
|
|
80
|
+
export type ListenParam<T> = {
|
|
81
|
+
/**
|
|
82
|
+
* The message type to listen for
|
|
83
|
+
*/
|
|
84
|
+
messageType: string;
|
|
85
|
+
/**
|
|
86
|
+
* The callback to invoke when the message is received
|
|
87
|
+
*/
|
|
88
|
+
callback: ListenerCallback<T>;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Parameters for sending a message to another window
|
|
92
|
+
*/
|
|
93
|
+
export type SendParam = {
|
|
94
|
+
/**
|
|
95
|
+
* The window to send the message to
|
|
96
|
+
*/
|
|
97
|
+
targetWin: Window;
|
|
98
|
+
/**
|
|
99
|
+
* The origin of the target window
|
|
100
|
+
*/
|
|
101
|
+
targetOrigin: string;
|
|
102
|
+
/**
|
|
103
|
+
* The message type to send
|
|
104
|
+
*/
|
|
105
|
+
messageType: string;
|
|
106
|
+
/**
|
|
107
|
+
* The message body to send
|
|
108
|
+
*/
|
|
109
|
+
messageBody: unknown;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Parameters for responding to a message
|
|
113
|
+
*/
|
|
114
|
+
export type RespondParam = {
|
|
115
|
+
/**
|
|
116
|
+
* The window to send the response message to
|
|
117
|
+
*/
|
|
118
|
+
targetWin: Window;
|
|
119
|
+
/**
|
|
120
|
+
* The origin of the target window
|
|
121
|
+
*/
|
|
122
|
+
targetOrigin: string;
|
|
123
|
+
/**
|
|
124
|
+
* The unique ID of the message to respond to
|
|
125
|
+
*/
|
|
126
|
+
requestId: string;
|
|
127
|
+
/**
|
|
128
|
+
* The response message body
|
|
129
|
+
*/
|
|
130
|
+
response: unknown;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Parameters for raising an exception
|
|
134
|
+
*/
|
|
135
|
+
export type RaiseExceptionParam = {
|
|
136
|
+
/**
|
|
137
|
+
* The window to send the exception message to
|
|
138
|
+
*/
|
|
139
|
+
targetWin: Window;
|
|
140
|
+
/**
|
|
141
|
+
* The origin of the target window
|
|
142
|
+
*/
|
|
143
|
+
targetOrigin: string;
|
|
144
|
+
/**
|
|
145
|
+
* The unique ID of the message to respond to
|
|
146
|
+
*/
|
|
147
|
+
requestId: string;
|
|
148
|
+
/**
|
|
149
|
+
* The exception / error message
|
|
150
|
+
*/
|
|
151
|
+
ex: string;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Sends a message to another window
|
|
155
|
+
*
|
|
156
|
+
* @param {SendParam} param - parameters for sending the message
|
|
157
|
+
*/
|
|
158
|
+
export declare const sendMessage: (param: SendParam) => void;
|
|
159
|
+
/**
|
|
160
|
+
* Description of a window that is allowed to send messages to this window
|
|
161
|
+
*/
|
|
162
|
+
export type AddSenderParam = {
|
|
163
|
+
/**
|
|
164
|
+
* origin of the window
|
|
165
|
+
*/
|
|
166
|
+
origin: string;
|
|
167
|
+
/**
|
|
168
|
+
* window object
|
|
169
|
+
*/
|
|
170
|
+
window: Window;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Provides core messaging capabilities for cross-frame interactions in a sandboxed environment.
|
|
174
|
+
*/
|
|
175
|
+
export declare class Remoting {
|
|
176
|
+
#private;
|
|
177
|
+
/**
|
|
178
|
+
* Create a new instance of the Remoting class
|
|
179
|
+
*
|
|
180
|
+
* @param logger pui-diagnostic logger
|
|
181
|
+
* @param correlationId unique id for the current session
|
|
182
|
+
*/
|
|
183
|
+
constructor(logger: Logger, correlationId: string);
|
|
184
|
+
/**
|
|
185
|
+
* Adds window and its origin list of allowed senders
|
|
186
|
+
*
|
|
187
|
+
* @param {AddSenderParam} param - The sender to add
|
|
188
|
+
*/
|
|
189
|
+
addSender: (param: AddSenderParam) => void;
|
|
190
|
+
/**
|
|
191
|
+
* Initializes the remoting service for a window
|
|
192
|
+
*
|
|
193
|
+
* @param win The window to initialize remoting for
|
|
194
|
+
*/
|
|
195
|
+
initialize: (win: Window) => void;
|
|
196
|
+
/**
|
|
197
|
+
* Closes the remoting service for a window
|
|
198
|
+
*/
|
|
199
|
+
close: () => void;
|
|
200
|
+
/**
|
|
201
|
+
* Sends an invocation which generates a Promise to be used to get a response
|
|
202
|
+
*
|
|
203
|
+
* @param {InvokeParam} param The parameters for the invocation
|
|
204
|
+
* @returns promisifyed response
|
|
205
|
+
*/
|
|
206
|
+
invoke: <T>(param: InvokeParam) => Promise<T>;
|
|
207
|
+
/**
|
|
208
|
+
* Setup callback for a specific message type
|
|
209
|
+
*
|
|
210
|
+
* @param {ListenParam<T>} param The parameters for the listener
|
|
211
|
+
*/
|
|
212
|
+
listen: <T>(param: ListenParam<T>) => void;
|
|
213
|
+
/**
|
|
214
|
+
* Send a message without any form of response. Fire and forget
|
|
215
|
+
*
|
|
216
|
+
* @param {SendParam} param The parameters for the send
|
|
217
|
+
*/
|
|
218
|
+
send: (param: SendParam) => void;
|
|
219
|
+
/**
|
|
220
|
+
* Removes a window from the list of allowed senders
|
|
221
|
+
*
|
|
222
|
+
* @param {AddSenderParam} param - The sender to remove
|
|
223
|
+
*/
|
|
224
|
+
removeSender: (param: AddSenderParam) => void;
|
|
225
|
+
/**
|
|
226
|
+
* Send a response message to a window
|
|
227
|
+
*
|
|
228
|
+
* @param {RespondParam} param The parameters for the response
|
|
229
|
+
*/
|
|
230
|
+
respond: (param: RespondParam) => void;
|
|
231
|
+
/**
|
|
232
|
+
* Send an exception message to a window
|
|
233
|
+
*
|
|
234
|
+
* @param {RaiseExceptionParam} param The parameters for the exception
|
|
235
|
+
*/
|
|
236
|
+
raiseException: (param: RaiseExceptionParam) => void;
|
|
237
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RemotingScriptingObject } from '@elliemae/pui-scripting-object';
|
|
2
|
+
/**
|
|
3
|
+
* Event message for remoting
|
|
4
|
+
*/
|
|
5
|
+
export type RemotingEventMessage = {
|
|
6
|
+
/**
|
|
7
|
+
* Marshalled scripting object
|
|
8
|
+
*/
|
|
9
|
+
readonly object: RemotingScriptingObject;
|
|
10
|
+
/**
|
|
11
|
+
* Event name
|
|
12
|
+
*/
|
|
13
|
+
readonly eventName: string;
|
|
14
|
+
/**
|
|
15
|
+
* Event handler
|
|
16
|
+
*/
|
|
17
|
+
readonly eventHandler?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Event parameters
|
|
20
|
+
*/
|
|
21
|
+
readonly eventParams?: Array<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Event options
|
|
24
|
+
*/
|
|
25
|
+
readonly eventOptions?: Record<string, any>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { RemotingScriptingObject, IScriptingObject } from '@elliemae/pui-scripting-object';
|
|
2
|
+
export type GenericFunction = (...args: unknown[]) => unknown;
|
|
3
|
+
/**
|
|
4
|
+
* Base class for all scripting objects
|
|
5
|
+
*/
|
|
6
|
+
export declare class ScriptingObject implements IScriptingObject {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of ScriptingObject.
|
|
10
|
+
*
|
|
11
|
+
* @param objectId unique id of the scripting object
|
|
12
|
+
* @param objectType type of the scripting object
|
|
13
|
+
*/
|
|
14
|
+
constructor(objectId: string, objectType?: string);
|
|
15
|
+
/**
|
|
16
|
+
* get unique id of the scripting object
|
|
17
|
+
*/
|
|
18
|
+
get id(): string;
|
|
19
|
+
/**
|
|
20
|
+
* get type of the scripting object
|
|
21
|
+
*/
|
|
22
|
+
get objectType(): string;
|
|
23
|
+
/**
|
|
24
|
+
* transform the scripting object to a format suitable for transmitting over window.postMessage
|
|
25
|
+
*
|
|
26
|
+
* @returns marshalled scripting object
|
|
27
|
+
*/
|
|
28
|
+
_toJSON: () => RemotingScriptingObject;
|
|
29
|
+
/**
|
|
30
|
+
* dispose the scripting object
|
|
31
|
+
*/
|
|
32
|
+
_dispose: () => void;
|
|
33
|
+
/**
|
|
34
|
+
* dispose the scripting object
|
|
35
|
+
*/
|
|
36
|
+
dispose: () => void;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IModule, Listener, Events } from '@elliemae/pui-scripting-object';
|
|
2
|
+
import { ScriptingObject, Event } from '../../index.js';
|
|
3
|
+
export type AppraisalServiceEvents = {
|
|
4
|
+
'appraisalservice.onprecommit': Listener<AppraisalService, {
|
|
5
|
+
loanId: string;
|
|
6
|
+
}, Record<string, unknown>, boolean>;
|
|
7
|
+
'appraisalservice.onsaved': Listener<AppraisalService, {
|
|
8
|
+
loanId: string;
|
|
9
|
+
}, Record<string, unknown>, void>;
|
|
10
|
+
};
|
|
11
|
+
export declare class AppraisalService extends ScriptingObject implements IModule {
|
|
12
|
+
#private;
|
|
13
|
+
Unloading: Event<Events>;
|
|
14
|
+
onPreCommit: Event<AppraisalServiceEvents>;
|
|
15
|
+
onSaved: Event<AppraisalServiceEvents>;
|
|
16
|
+
constructor({ loanId, creditScore, }: {
|
|
17
|
+
loanId: string;
|
|
18
|
+
creditScore: number;
|
|
19
|
+
});
|
|
20
|
+
getCapabilities: () => Promise<{
|
|
21
|
+
isAdmin: boolean;
|
|
22
|
+
los: string;
|
|
23
|
+
}>;
|
|
24
|
+
getParameters: () => Promise<{
|
|
25
|
+
loanId: string;
|
|
26
|
+
creditScore: number;
|
|
27
|
+
}>;
|
|
28
|
+
setCreditScore: (creditScore: number) => Promise<void>;
|
|
29
|
+
saveLoan: () => Promise<void>;
|
|
30
|
+
commit: () => Promise<unknown>;
|
|
31
|
+
delete: () => never;
|
|
32
|
+
unload: () => Promise<void>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Events, IGlobal } from '@elliemae/pui-scripting-object';
|
|
2
|
+
import { Event } from '../../event.js';
|
|
3
|
+
import { ScriptingObject } from '../../index.js';
|
|
4
|
+
export declare class Global extends ScriptingObject implements IGlobal {
|
|
5
|
+
#private;
|
|
6
|
+
constructor();
|
|
7
|
+
readonly Change: Event<Events>;
|
|
8
|
+
set: (key: string, value: any) => Promise<void>;
|
|
9
|
+
get: (key: string) => Promise<unknown>;
|
|
10
|
+
}
|