@nebulateam/jarvis-sdk 0.0.0-stage → 5.57.9

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.
@@ -0,0 +1,79 @@
1
+ import { ExternalContextMenuEntry, JarvisConfigurationResponseMessage, JarvisExternalMessageKind, JarvisNotification } from "./jarvis-shell.models";
2
+ /**
3
+ * Lets a component embedded in Jarvis (iframe or web component) talk to the Jarvis host:
4
+ * navigation, toasts, dialogs, context menus and subscriptions to Jarvis events.
5
+ *
6
+ * Call {@link JarvisShell.init} before anything else: it loads the host configuration and capabilities.
7
+ * @example
8
+ * const shell = new JarvisShell();
9
+ * shell.init((jarvis, configuration) => {
10
+ * jarvis.showToast('Hello', `Welcome ${configuration?.user.fullName}`, 'info');
11
+ * });
12
+ */
13
+ export declare class JarvisShell {
14
+ private _targetOrigin;
15
+ private INIT_ERROR_MESSAGE;
16
+ private subscriptions;
17
+ private dialogCallbacks;
18
+ private contextMenuCallbacks;
19
+ private configuration;
20
+ private tempConfigSubscription;
21
+ private htmlElement;
22
+ constructor();
23
+ private reactToMessage;
24
+ /**
25
+ * Asks the host for its configuration and capabilities; call it once on startup.
26
+ * @param onLoaded invoked when the host answers, with the configuration (user, capabilities, events)
27
+ * @param htmlElement for web components, the element used to dispatch the messages to Jarvis
28
+ */
29
+ init(onLoaded: (jarvis: JarvisShell, configuration: null | JarvisConfigurationResponseMessage) => void, htmlElement?: HTMLElement | null): void;
30
+ /**
31
+ * Subscribes to a Jarvis event (e.g. "WorkTask.Updated"); the supported events are listed in the configuration.
32
+ * @param event the event name, prefixed by its model
33
+ * @param callback invoked for every notification of the event
34
+ */
35
+ on: (event: string, callback: (notification: JarvisNotification) => void) => void;
36
+ private getConfiguration;
37
+ /** Opens the detail of a Jarvis entity. @param id the Jarvis id of the entity */
38
+ openDetail(id: string): void;
39
+ /**
40
+ * Navigates the host to a url.
41
+ * @param url the url to open
42
+ * @param openNewTab opens the url in a new tab
43
+ * @param external true for addresses outside Jarvis, opened as they are
44
+ */
45
+ navigate(url: string, openNewTab: boolean, external: boolean): void;
46
+ /**
47
+ * Navigates the host to a Jarvis entity.
48
+ * @param id the Jarvis id of the entity
49
+ * @param parentId the parent entity (e.g. the workspace of a work task, the dataset of an item)
50
+ * @param openNewTab opens the entity in a new tab
51
+ */
52
+ navigateById(id: string, parentId: string, openNewTab: boolean): void;
53
+ /** Shows a toast message in the host. */
54
+ showToast: (title: string, message: string, kind: "error" | "warning" | "success" | "info") => void;
55
+ /**
56
+ * Shows a confirmation dialog in the host.
57
+ * @param callback receives true when the user confirms
58
+ */
59
+ showDialog: (dialog: {
60
+ kind: "yesNo" | "okCancel";
61
+ subtitle: string;
62
+ title: string;
63
+ body: string;
64
+ isDanger?: boolean;
65
+ }, callback: (response: boolean) => void) => void;
66
+ /**
67
+ * Shows a context menu in the host at the given position.
68
+ * @param callback receives the selected action id and its context data
69
+ */
70
+ showContextMenu: (mouseEvent: {
71
+ x: number;
72
+ y: number;
73
+ }, menuEntries: ExternalContextMenuEntry[], callback: (actionId: string, contextData: any) => void) => void;
74
+ /** Sends a raw message to the host; prefer the specific methods. */
75
+ sendMessage(msg: {
76
+ kind: JarvisExternalMessageKind;
77
+ data: any;
78
+ }): void;
79
+ }
@@ -0,0 +1,204 @@
1
+ /** Identifier that marks a message as addressed to (or coming from) Jarvis. */
2
+ export declare const JARVIS_COMMAND_EVENT_ID = "JARVIS_EVENT";
3
+ /** Each possible kind of message exchanged between the embedded component and Jarvis */
4
+ export declare enum JarvisExternalMessageKind {
5
+ Navigate = "navigate",
6
+ NavigateById = "navigateById",
7
+ ReloadById = "reloadById",
8
+ OpenDetail = "openDetail",
9
+ ShowToast = "showToast",
10
+ ShowDialog = "showDialog",
11
+ ShowDialogResponse = "showDialogResponse",
12
+ Subscription = "subscription",
13
+ Notification = "notification",
14
+ GetConfiguration = "getConfiguration",
15
+ ConfigurationResponse = "configurationResponse",
16
+ ShowContextMenu = "showContextMenu",
17
+ ShowContextMenuResponse = "showContextMenuResponse",
18
+ DeleteItem = "deleteItem",
19
+ CloneItem = "cloneItem",
20
+ EditItem = "editItem"
21
+ }
22
+ export interface JarvisExternalMessage {
23
+ id: typeof JARVIS_COMMAND_EVENT_ID;
24
+ kind: JarvisExternalMessageKind;
25
+ data: JarvisNavigateExternalMessage | JarvisNavigateByIdExternalMessage | JarvisReloadByIdExternalMessage | JarvisOpenDetailExternalMessage | JarvisSubscriptionMessage | JarvisNotificationMessage | JarvisShowToastExternalMessage | JarvisGetConfigurationMessage | JarvisConfigurationResponseMessage | JarvisShowDialogMessage | JarvisShowDialogResponseMessage | JarvisShowContextMenuMessage | JarvisShowContextMenuResponseMessage | JarvisDeleteItemMessage | JarvisCloneItemMessage | JarvisEditItemMessage;
26
+ }
27
+ export interface JarvisNavigateExternalMessage {
28
+ /** The url to navigate to */
29
+ url: string;
30
+ /** If we should navigate in another tab */
31
+ openNewTab: boolean;
32
+ /**
33
+ * If the url we navigate to is an external address
34
+ * so we should navigate to it without modifying it
35
+ */
36
+ external: boolean;
37
+ }
38
+ export interface JarvisOpenDetailExternalMessage {
39
+ /** Id of the entity in Jarvis */
40
+ id: string;
41
+ }
42
+ export interface JarvisNavigateByIdExternalMessage {
43
+ /** Id of the entity in Jarvis */
44
+ id: string;
45
+ /**
46
+ * Parent of the entity in Jarvis, needed to correctly open
47
+ * stuff like worktask inside workspaces or dataset details
48
+ */
49
+ parentId: string;
50
+ /** If we should navigate in another tab */
51
+ openNewTab: boolean;
52
+ }
53
+ export interface JarvisReloadByIdExternalMessage {
54
+ /** Id of the entity in Jarvis */
55
+ id: string;
56
+ }
57
+ export interface JarvisShowToastExternalMessage {
58
+ /** The title of the toast */
59
+ title: string;
60
+ /** The text to be displayed in the toast */
61
+ message: string;
62
+ /** The kind of toast to show */
63
+ kind: "error" | "warning" | "success" | "info";
64
+ }
65
+ export interface JarvisSubscriptionMessage {
66
+ event: string;
67
+ }
68
+ export interface JarvisNotificationMessage {
69
+ notification: JarvisNotification;
70
+ }
71
+ export interface JarvisGetConfigurationMessage {
72
+ }
73
+ export interface JarvisConfigurationResponseMessage {
74
+ user: JarvisUserConfiguration;
75
+ capabilities: JarvisExternalMessageKind[];
76
+ events: {
77
+ [model: string]: string[];
78
+ };
79
+ }
80
+ export interface JarvisShowDialogMessage {
81
+ id: string;
82
+ kind: "yesNo" | "okCancel";
83
+ subtitle: string;
84
+ title: string;
85
+ body?: string;
86
+ isDanger?: boolean;
87
+ }
88
+ export interface JarvisShowDialogResponseMessage {
89
+ id: string;
90
+ response: boolean;
91
+ }
92
+ export interface JarvisUserConfiguration {
93
+ userId?: string | undefined;
94
+ emailAddress?: string | undefined;
95
+ firstName?: string | undefined;
96
+ middleName?: string | undefined;
97
+ lastName?: string | undefined;
98
+ fullName?: string | undefined;
99
+ mobilePhone?: string | undefined;
100
+ crmUserId?: string | undefined;
101
+ crmUserEnabled: boolean;
102
+ plmUserId?: string | undefined;
103
+ plmUserEnabled: boolean;
104
+ profileId?: string | undefined;
105
+ language?: string | undefined;
106
+ }
107
+ export interface JarvisNotification {
108
+ id: number;
109
+ event: string;
110
+ model: string;
111
+ action: string;
112
+ modelId: any;
113
+ data: any;
114
+ extraData?: any;
115
+ }
116
+ export interface JarvisCustomEvent extends Event {
117
+ detail: JarvisExternalMessage;
118
+ }
119
+ /**
120
+ * The message that will be sent from the iframe to show a context menu in JARVIS
121
+ * at the specified position
122
+ */
123
+ export interface JarvisShowContextMenuMessage {
124
+ /** A unique identifier for the request */
125
+ requestId: string;
126
+ /** The x and y position of the context menu */
127
+ x: number;
128
+ y: number;
129
+ /** The entries that will be shown in the context menu */
130
+ entries: ExternalContextMenuEntry[];
131
+ }
132
+ /** An entry in the context menu */
133
+ export interface ExternalContextMenuEntry {
134
+ /** A unique identifier for the action */
135
+ actionId: string;
136
+ /** The icon tha will be shown next to the label */
137
+ icon?: string;
138
+ /** The label of the action */
139
+ label: string;
140
+ /** The tooltip of the action */
141
+ tooltip: string;
142
+ /** If the action is disabled */
143
+ isDisabled?: boolean;
144
+ /** If the action should be shown in red, i.e. it will perform a destructive action */
145
+ isDanger?: boolean;
146
+ /** If this is not an action, but a header */
147
+ isHeader?: boolean;
148
+ /** If the action is custom, i.e. it will be handled by the iframe */
149
+ isCustom?: boolean;
150
+ /**
151
+ * The action that will be performed by JARVIS if the user selects this entry
152
+ * If isCustom is true, this will be ignored
153
+ */
154
+ jarvisAction?: JarvisExternalContextMenuAction;
155
+ /** The id of the element that the action will be performed on, if this is not a custom action */
156
+ jarvisActionElementId?: string | string[];
157
+ /**
158
+ * The context data that will be sent back to the iframe if the user selects this entry
159
+ * This is helpful to provide the iframe with the necessary data to perform the action
160
+ * for custom actions
161
+ */
162
+ contextData?: any;
163
+ }
164
+ /**
165
+ * The possible actions that can be performed by the context menu
166
+ * They will be shown only if the context we are in provides them
167
+ */
168
+ export declare enum JarvisExternalContextMenuAction {
169
+ /** Open the entity */
170
+ Open = "open",
171
+ /** Edit the entity/entities */
172
+ Edit = "edit",
173
+ /** Delete the entity */
174
+ Delete = "delete",
175
+ /** Clone the entity */
176
+ Clone = "clone"
177
+ }
178
+ /**
179
+ * The response message that will be sent back to the iframe after the user
180
+ * has selected an action from the context menu
181
+ */
182
+ export interface JarvisShowContextMenuResponseMessage {
183
+ /** The unique identifier of the request this message is a response to */
184
+ requestId: string;
185
+ /** The action that the user has selected */
186
+ actionId: string;
187
+ /** The context data that was provided by the context menu */
188
+ contextData?: any;
189
+ }
190
+ /** The message that will be sent from the iframe to delete an item (or multiple items) in JARVIS */
191
+ export interface JarvisDeleteItemMessage {
192
+ /** Id of the entity (or identities) in Jarvis */
193
+ id: string | string[];
194
+ }
195
+ /** The message that will be sent from the iframe to clone an item in JARVIS */
196
+ export interface JarvisCloneItemMessage {
197
+ /** Id of the entity in Jarvis */
198
+ id: string;
199
+ }
200
+ /** The message that will be sent from the iframe to edit an item (or multiple items) in JARVIS */
201
+ export interface JarvisEditItemMessage {
202
+ /** Id of the entity (or identities) in Jarvis */
203
+ id: string | string[];
204
+ }
@@ -0,0 +1,22 @@
1
+ export declare class JarvisApiBase {
2
+ private readonly config;
3
+ protected constructor(config: JarvisApiConfig);
4
+ protected transformOptions: (options: RequestInit) => Promise<RequestInit>;
5
+ }
6
+ export declare class JarvisApiBaseClient {
7
+ constructor();
8
+ }
9
+ /**
10
+ * Configuration class needed in base class.
11
+ * The config is provided to the API client at initialization time.
12
+ * API clients inherit from #AuthorizedApiBase and provide the config.
13
+ */
14
+ export declare class JarvisApiConfig {
15
+ jarvisToken: string;
16
+ jarvisCallInfoHeader?: string | undefined;
17
+ /**
18
+ * Returns a valid value for the Authorization header.
19
+ * Used to dynamically inject the current auth header and call info header.
20
+ */
21
+ constructor(jarvisToken: string, jarvisCallInfoHeader?: string | undefined);
22
+ }
@@ -0,0 +1,6 @@
1
+ export * from './app/jarvis-client';
2
+ export * from './app/jarvis-shell';
3
+ export * from './app/jarvis-shell.models';
4
+ export * from './app/automation-client';
5
+ export * from './app/automation-client.models';
6
+ export * from './app/jarvis-public-api-v2.client';