@integry/sdk 3.3.2-beta.6 → 3.3.2-beta.7

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