@integry/sdk 3.7.16 → 3.7.18

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,507 @@
1
+ import { VNode } from "preact";
2
+ type IntegrySDKEventType = "authorizations" | "did-add-authorization" | "did-begin-remove-authorization" | "did-change-step" | "did-fail-authorization-verification" | "did-load-flow" | "did-load-flows" | "did-load-integration" | "did-load-integrations" | "did-load-preview" | "did-remove-authorization" | "did-save-integration" | "did-delete-integration" | "did-select-authorization" | "ready" | "should-load-flow" | "did-click-close-button" | "did-app-load";
3
+ type IntegrySDKEventPayloads = {
4
+ ready: {
5
+ deploymentId: number;
6
+ };
7
+ "should-load-flow": {
8
+ templateId: number;
9
+ flowId: number;
10
+ };
11
+ "did-load-flows": {
12
+ flows: any[];
13
+ };
14
+ "did-load-integrations": {
15
+ integrations: any[];
16
+ };
17
+ "did-load-flow": {
18
+ flowId: number;
19
+ flowTitle: string;
20
+ flowDescription: string;
21
+ templateId: number;
22
+ templateTitle: string;
23
+ templateDescription: string;
24
+ mode: "EDIT" | "CREATE";
25
+ };
26
+ "did-load-integration": {
27
+ flowId: number;
28
+ integrationId: number;
29
+ };
30
+ "did-delete-integration": {
31
+ flowId: number;
32
+ flowName: string;
33
+ flowDescription: string;
34
+ integrationId: number;
35
+ integrationName: string;
36
+ };
37
+ "did-save-integration": {
38
+ integrationId: number;
39
+ name: string;
40
+ templateId: number;
41
+ flowId: number;
42
+ status: string;
43
+ callbackUrl: string | null;
44
+ callbackUrlArray: {
45
+ templateStepId: number;
46
+ activityId: number;
47
+ callbackUrl: string | null;
48
+ }[];
49
+ authorizations: {
50
+ authorizationId: number;
51
+ userIdentity: string;
52
+ isBrandingAppAuth: boolean;
53
+ }[];
54
+ event: "EDIT" | "CREATE";
55
+ };
56
+ "did-load-preview": {
57
+ flowId: number;
58
+ flowTitle: string;
59
+ flowDescription: string;
60
+ };
61
+ "did-change-step": {
62
+ stepId: number;
63
+ stepType: "AUTH" | "CONFIGURATION" | "SECTION" | "CONFIRMATION";
64
+ };
65
+ "did-add-authorization": {
66
+ identity: string;
67
+ authorizationId: number;
68
+ flowId: number | null;
69
+ appIcon: string;
70
+ alreadyExists: boolean;
71
+ externalId?: string;
72
+ };
73
+ "did-select-authorization": {
74
+ authorizationId: number;
75
+ };
76
+ "did-remove-authorization": {
77
+ authorizationId: number;
78
+ appId?: number | null;
79
+ };
80
+ "did-begin-remove-authorization": {
81
+ authorizationId: number;
82
+ };
83
+ "did-click-close-button": {
84
+ isCloseClicked: boolean;
85
+ };
86
+ "did-app-load": {
87
+ appName: string;
88
+ appId: number;
89
+ appLogoUrl: string;
90
+ authorizationId: number | null;
91
+ };
92
+ };
93
+ type EventCallback<P extends IntegrySDKEventType> = (
94
+ // @ts-expect-error P can index IntegrySDKEventPayloads
95
+ payload: IntegrySDKEventPayloads[P]) => void;
96
+ type IntegrySDKEvents = {
97
+ authorizations: EventCallback<"authorizations">;
98
+ "did-add-authorization": EventCallback<"did-add-authorization">;
99
+ "did-begin-remove-authorization": EventCallback<"did-begin-remove-authorization">;
100
+ "did-change-step": EventCallback<"did-change-step">;
101
+ "did-fail-authorization-verification": EventCallback<"did-fail-authorization-verification">;
102
+ "did-load-flow": EventCallback<"did-load-flow">;
103
+ "did-load-flows": EventCallback<"did-load-flows">;
104
+ "did-load-integration": EventCallback<"did-load-integration">;
105
+ "did-delete-integration": EventCallback<"did-delete-integration">;
106
+ "did-load-integrations": EventCallback<"did-load-integrations">;
107
+ "did-load-preview": EventCallback<"did-load-preview">;
108
+ "did-remove-authorization": EventCallback<"did-remove-authorization">;
109
+ "did-save-integration": EventCallback<"did-save-integration">;
110
+ "did-select-authorization": EventCallback<"did-select-authorization">;
111
+ ready: EventCallback<"ready">;
112
+ "should-load-flow": EventCallback<"should-load-flow">;
113
+ "did-click-close-button": EventCallback<"did-click-close-button">;
114
+ "did-app-load": EventCallback<"did-app-load">;
115
+ };
116
+ declare enum TemplateFormRenderModes {
117
+ MODAL = "MODAL",
118
+ INLINE = "INLINE",
119
+ DETACHED = "DETACHED",
120
+ CUSTOM = "CUSTOM"
121
+ }
122
+ declare enum MarketplaceRenderModes {
123
+ MODAL = "MODAL",
124
+ INLINE = "INLINE"
125
+ }
126
+ declare enum TemplateListingRenderModes {
127
+ GRID = "GRID",
128
+ LIST = "LIST"
129
+ }
130
+ type Authorization = {
131
+ id: number;
132
+ authorization_type: string;
133
+ app_user?: number;
134
+ app_user_id?: number;
135
+ disable_link?: string;
136
+ integration_count?: number;
137
+ user_identity: string;
138
+ };
139
+ type TemplateType = Template;
140
+ type FlowCardProps = {
141
+ id: number | string;
142
+ imgUrl: string;
143
+ name: string;
144
+ description: string;
145
+ tags: string;
146
+ layout: TemplateListingRenderModes;
147
+ handleClick: () => void;
148
+ apiHandler?: any;
149
+ app?: {
150
+ id: number;
151
+ };
152
+ onEdit?: (instance: Instance) => void;
153
+ onDelete?: (instance: Instance) => void;
154
+ onEditName?: ({ instance, newName }: {
155
+ instance: Instance;
156
+ newName: string;
157
+ }) => void;
158
+ dFlag?: string;
159
+ templateObj?: TemplateType | any;
160
+ };
161
+ interface NestedObject {
162
+ [key: string]: string | number | NestedObject;
163
+ }
164
+ interface UserConfig {
165
+ availableFlowsLabel?: string;
166
+ myFlowsLabel?: string;
167
+ hideWebhookUrlScreen?: boolean;
168
+ hideAppConnectionModal?: boolean;
169
+ customComponents?: {
170
+ flowCard?: (props: FlowCardProps) => VNode;
171
+ };
172
+ autoRedirectToMyFlows?: boolean;
173
+ isReadOnly?: boolean;
174
+ marketplaceModalTitle?: string;
175
+ buttonLabelToSaveIntegration?: string;
176
+ objects?: NestedObject;
177
+ tags?: string[];
178
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
179
+ [other: string]: any;
180
+ }
181
+ type SDKOptions = UserConfig; // rename user config to options for better understanding
182
+ // rename user config to options for better understanding
183
+ interface SDKConfig {
184
+ env?: "staging" | "production";
185
+ baseUrl?: string;
186
+ debug?: boolean;
187
+ integrationId?: number;
188
+ xIntegryConfig?: {
189
+ isAnonymous?: boolean;
190
+ appAuth?: {
191
+ apiKey?: string;
192
+ authId?: string;
193
+ extras?: Record<string, string | number>;
194
+ };
195
+ };
196
+ userConfig?: UserConfig;
197
+ options?: SDKOptions;
198
+ }
199
+ interface ConfigWithObject extends SDKConfig {
200
+ appKey: string;
201
+ hash: string;
202
+ userId: string;
203
+ deploymentId: string;
204
+ marketplaceId?: string;
205
+ appId?: number;
206
+ showApps?: boolean;
207
+ showTemplates?: boolean;
208
+ }
209
+ interface ConfigWithUrlParams extends SDKConfig {
210
+ useUrlParams?: boolean;
211
+ }
212
+ interface Template {
213
+ id: number;
214
+ name: string;
215
+ description: string;
216
+ can_add_integration: boolean;
217
+ integration_count: number;
218
+ app: {
219
+ icon_url: string;
220
+ category: string[];
221
+ tags: string;
222
+ };
223
+ branding_app: {
224
+ id: string;
225
+ name: string;
226
+ icon_url: string;
227
+ category: string[];
228
+ tags: string;
229
+ };
230
+ is_manual?: boolean;
231
+ }
232
+ type App = {
233
+ id: number;
234
+ name: string;
235
+ description: string;
236
+ icon_url: string;
237
+ color: string;
238
+ publishing_status: string;
239
+ category: string[];
240
+ app_type?: string;
241
+ action_url?: string | null;
242
+ created_at?: Date;
243
+ tags: string;
244
+ };
245
+ type Activity = {
246
+ id: number;
247
+ name: string;
248
+ type: string;
249
+ endpoint: string;
250
+ auth_required: boolean;
251
+ total_fields: number;
252
+ app: App;
253
+ activity_output: string | null;
254
+ activity_output_url: string | null;
255
+ dynamic_field_data_endpoint: string | null;
256
+ };
257
+ type AuthorizationType = {
258
+ id: number;
259
+ type: string;
260
+ authorizations: Authorization[];
261
+ provider: string;
262
+ is_sandbox_enabled: boolean;
263
+ is_userinfo_required?: boolean;
264
+ authorization_url_sandbox: string;
265
+ app: {
266
+ icon_url: string;
267
+ id: number;
268
+ name: string;
269
+ };
270
+ };
271
+ interface TemplateField {
272
+ id: number;
273
+ is_required: boolean;
274
+ is_hidden: boolean;
275
+ default_value: string | null;
276
+ weight: number;
277
+ description: string;
278
+ summary: string | null;
279
+ activity_field: {
280
+ id: number;
281
+ machine_name: string;
282
+ type: string;
283
+ title: string;
284
+ description: string;
285
+ weight: number;
286
+ is_required: boolean;
287
+ child_fields: string | null;
288
+ placeholder: string | null;
289
+ is_dynamic: boolean;
290
+ data_src: string | null;
291
+ data_src_endpoint: number | null;
292
+ parent_fields: string | null;
293
+ dynamic_field_src: string | null;
294
+ default_value: string | null;
295
+ auto_machine_name: string;
296
+ dynamic_field_src_endpoint: number | null;
297
+ regex: string | null;
298
+ regex_error_message?: string | null;
299
+ is_searchable: boolean;
300
+ conditional_fields?: string | null;
301
+ } | null;
302
+ title: string | null;
303
+ type: string;
304
+ placeholder: string | null;
305
+ // manual_template: unknown | null;
306
+ child_field: string | null;
307
+ child_field_value: string | null;
308
+ // template_fields: unknown[];
309
+ button_text: string | null;
310
+ // field_actions: unknown[];
311
+ icon_url: string | null;
312
+ long_description: string | null;
313
+ regex: string | null;
314
+ regex_msg: string | null;
315
+ is_visible: boolean;
316
+ app_user_data?: {
317
+ app_user: number;
318
+ id: number;
319
+ value: string | number;
320
+ is_changed: boolean;
321
+ changed_dynamic_fields: string;
322
+ }[];
323
+ added_in_mapping?: boolean;
324
+ field_mapping_source?: string;
325
+ }
326
+ interface TemplateStep {
327
+ id: number;
328
+ weight: number;
329
+ title: string;
330
+ is_visible: boolean;
331
+ activity: Activity;
332
+ authorization_type: AuthorizationType;
333
+ template_fields: TemplateField[];
334
+ step_instance?: number | null;
335
+ allow_multiple_authorizations: boolean;
336
+ step_authorization: number | null;
337
+ button_text: string | null;
338
+ is_self_step: boolean;
339
+ summary: string | null;
340
+ is_workspace_app_step: boolean;
341
+ auth_description: string | null;
342
+ hide_authorization: boolean;
343
+ // step_condition: unknown | null;
344
+ machine_name: string | null;
345
+ is_custom_machine_name: boolean;
346
+ }
347
+ interface InitConfig {
348
+ containerId: string;
349
+ templateContainerId?: string;
350
+ renderMode: TemplateFormRenderModes;
351
+ renderFlowsMode?: TemplateFormRenderModes;
352
+ renderFlowSetupMode?: TemplateFormRenderModes;
353
+ renderAppsPageMode?: TemplateFormRenderModes;
354
+ renderAppPageMode?: TemplateFormRenderModes;
355
+ appId?: number;
356
+ showApps?: boolean;
357
+ showTemplates?: boolean;
358
+ skipOnDemand?: boolean;
359
+ skipAccountConnectionOnLoad?: boolean;
360
+ deploymentIdFromConfig?: number;
361
+ }
362
+ interface MarketplaceConfig {
363
+ containerId: string;
364
+ renderMode: MarketplaceRenderModes;
365
+ }
366
+ interface TemplatePreviewData {
367
+ id: number;
368
+ name: string;
369
+ description: string;
370
+ app: App;
371
+ branding_app: App;
372
+ button_text: string | null;
373
+ is_wizard: boolean;
374
+ publishing_status: string;
375
+ level?: number;
376
+ parent_id?: number;
377
+ steps: TemplateStep[];
378
+ }
379
+ interface PreviewMetadata {
380
+ stepId: number | null;
381
+ type: "AUTH" | "CONFIGURATION" | "CONFIRMATION" | "SECTION";
382
+ }
383
+ interface PreviewPayload {
384
+ templateData: TemplatePreviewData;
385
+ metadata: PreviewMetadata;
386
+ previewContainerId: string;
387
+ }
388
+ // interface for app flows
389
+ interface Instance {
390
+ status: string;
391
+ last_run_status: string;
392
+ id: number;
393
+ last_run_start_time: string;
394
+ name: string;
395
+ error_app_name: string;
396
+ error_code: number;
397
+ first_error_received_at: string;
398
+ usage_limit_reached_at: string;
399
+ }
400
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
401
+ type EventSet = Record<string, (...args: any[]) => void>;
402
+ interface EventEmitterType<ESet extends EventSet> {
403
+ on<EventName extends keyof ESet>(eventName: EventName, handler: ESet[EventName]): void;
404
+ once<EventName extends keyof ESet>(eventName: EventName, handler: ESet[EventName]): void;
405
+ off<EventName extends keyof ESet>(eventName: EventName, handler: ESet[EventName]): void;
406
+ offAll(): void;
407
+ emit<EventName extends keyof ESet>(eventName: EventName, ...args: Parameters<ESet[EventName]>): void;
408
+ }
409
+ declare class EventEmitter<ESet extends EventSet> implements EventEmitterType<EventSet> {
410
+ private events;
411
+ on<EventName extends keyof ESet>(eventName: EventName, handler: ESet[EventName]): void;
412
+ once<EventName extends keyof ESet>(eventName: EventName, handler: ESet[EventName]): void;
413
+ off<EventName extends keyof ESet>(eventName: EventName, handler: ESet[EventName]): void;
414
+ offAll(): void;
415
+ emit<EventName extends keyof ESet>(eventName: EventName, ...args: Parameters<ESet[EventName]>): void;
416
+ private addEventListener;
417
+ }
418
+ /**
419
+ * Integry JS SDK
420
+ */
421
+ declare class IntegryJS {
422
+ static SDK_VERSION: string;
423
+ private config;
424
+ private apiHandler;
425
+ private initConfig;
426
+ eventEmitter: EventEmitter<IntegrySDKEvents>;
427
+ // allow customers to use template tagging
428
+ static html: (strings: TemplateStringsArray, ...values: any[]) => import("preact").VNode<{}>;
429
+ static RenderModes: typeof TemplateFormRenderModes;
430
+ static MarketplaceRenderModes: typeof MarketplaceRenderModes;
431
+ static Helpers: {
432
+ getAuthHash: (key: string, message: string) => Promise<string>;
433
+ };
434
+ private authModalId;
435
+ private forceRerender;
436
+ constructor(config: ConfigWithObject | ConfigWithUrlParams);
437
+ /**
438
+ *
439
+ * @param length Length of string to randomly generate
440
+ * @returns {string} Returns a random string
441
+ */
442
+ private getRandomFlowId;
443
+ private getAuthParamsFromUrl;
444
+ /**
445
+ * Prints version number of this SDK version
446
+ */
447
+ printVersion: () => void;
448
+ /**
449
+ *
450
+ * @param renderMode
451
+ * @param templateContainerId
452
+ * @returns {HTMLElement | null}
453
+ */
454
+ private setupFlowFormDestination;
455
+ /**
456
+ * Render the template form we ship
457
+ * @param data
458
+ */
459
+ renderFlowSetupForm: (data: {
460
+ flowId?: string;
461
+ integrationId?: number;
462
+ flowContainerId: string;
463
+ versionId?: number;
464
+ }) => void;
465
+ /**
466
+ * Render the template form we ship
467
+ * @param data
468
+ */
469
+ renderAccountConnectionModal: (data?: {
470
+ deploymentId?: string | undefined;
471
+ appId?: number | undefined;
472
+ authTypeId?: number | undefined;
473
+ } | undefined) => void;
474
+ removeAuthorization(data: {
475
+ authorizationId: number;
476
+ }): Promise<{
477
+ data: string | null;
478
+ status: number;
479
+ } | null>;
480
+ /**
481
+ * Render the template form we ship
482
+ * @param params
483
+ */
484
+ renderPreview: (params: PreviewPayload) => void;
485
+ /**
486
+ *
487
+ * @param initConfig
488
+ */
489
+ init: (initConfig: InitConfig) => void;
490
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
491
+ updateSdkUserConfig: (config: any) => void;
492
+ initializeMarketplace: (initConfig: InitConfig) => void;
493
+ /**
494
+ *
495
+ * @param marketplaceConfig
496
+ */
497
+ renderMarketplace: (marketplaceConfig: MarketplaceConfig) => void;
498
+ renderAppFlows: (appFlowConfig: InitConfig) => void;
499
+ verifyAuthConfig: () => Promise<{
500
+ config_verified: boolean;
501
+ } | null>;
502
+ /**
503
+ * Destroy SDK instance and cleanup store
504
+ */
505
+ destroy: () => void;
506
+ }
507
+ export { IntegryJS as default };