@useparagon/connect 1.0.34 → 1.0.35-experimental.10

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,17 +1,18 @@
1
1
  import { IConnectCredential } from './entities/connectCredential.interface';
2
2
  import { IConnectCredentialConfig } from './entities/connectCredentialConfig.interface';
3
- import { OauthCallbackResponse } from './entities/credential.interface';
3
+ import { AuthenticationScheme, OauthCallbackResponse } from './entities/credential.interface';
4
4
  import { IConnectIntegrationWithCredentialInfo, IIntegrationMetadata } from './entities/integration.interface';
5
5
  import { PersonaMeta } from './entities/persona.interface';
6
6
  import { ExternalFilePicker } from './file-picker/types';
7
7
  import SDKEventEmitter from './SDKEventEmitter';
8
8
  import { ConnectSdkEnvironments } from './server.types';
9
- import { AuthenticateOptions, AuthenticatedConnectUser, CompleteInstallOptions, Props as ConnectModalProps, ConnectParams, ConnectUser, CreateConfigurationOptions, CredentialConfigOptions, DeleteConfigurationOptions, DisableWorkflowOptions, EventInfo, GetIntegrationAccountOptions, IConnectSDK, InstallIntegrationOptions, IntegrationInstallEvent, LoadCustomDropdownOptionsResult, TriggerWorkflowRequest, UninstallOptions, UpdateConfigurationOptions } from './types';
9
+ import { AccountType, AuthenticateOptions, AuthenticatedConnectUser, ComboInputDataSource, CompleteInstallOptions, ConnectInputValue, Props as ConnectModalProps, ConnectParams, ConnectUser, CreateConfigurationOptions, CredentialConfigOptions, DataType, DeleteConfigurationOptions, DisableWorkflowOptions, EventInfo, GetIntegrationAccountOptions, IConnectSDK, InstallIntegrationOptions, InstallOptions, IntegrationConfig, IntegrationConnectInput, IntegrationInstallEvent, KeyedSource, LoadCustomDropdownOptionsResult, SerializedConnectInput, TriggerWorkflowRequest, UninstallOptions, UpdateConfigurationOptions, UpdateWorkflowStateResponse } from './types';
10
10
  export declare const PARAGON_OVERFLOW_EMPTY_VALUE = "PARAGON_OVERFLOW_EMPTY_VALUE";
11
11
  export { ExternalFilePicker };
12
12
  export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
13
13
  root: HTMLIFrameElement | undefined;
14
14
  private rootLoaded;
15
+ private isHeadless;
15
16
  /**
16
17
  * sometime DOMContentLoaded event firing twice
17
18
  * so it was creating two iframes see PARA-8749
@@ -45,9 +46,11 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
45
46
  * so that we will be able to know whether style is added in body or not
46
47
  */
47
48
  private originalBodyOverflow;
49
+ installFlow: InstallFlow;
48
50
  constructor(environmentsOrHost?: ConnectSdkEnvironments | string, flags?: {
49
51
  skipBootstrapWithLastKnownState?: boolean;
50
52
  });
53
+ setHeadless(headless: boolean): void;
51
54
  /**
52
55
  * post message handler
53
56
  * @param event
@@ -82,6 +85,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
82
85
  * unauthenticated contexts, as a fallback.
83
86
  */
84
87
  private loadState;
88
+ getIntegrationId(integration: string): string;
85
89
  /**
86
90
  * Saves the current SDK state into localStorage, if available.
87
91
  */
@@ -116,6 +120,18 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
116
120
  * Logout the currently authenticated end user from the Paragon SDK.
117
121
  */
118
122
  logout(): void;
123
+ private removeOptionDuplicates;
124
+ startOAuthFlow(action: string, apiInstallationOptions: InstallOptions & CredentialConfigOptions, options?: {
125
+ onSuccess?: (connectCredentialId: string) => void;
126
+ onError?: (error: unknown) => void;
127
+ }): void;
128
+ private getIntegrationByName;
129
+ private getSelectedMultipleAccountTypes;
130
+ /**
131
+ * in chrome getting issue for asynchronous popup opening
132
+ * see PARA-1505
133
+ */
134
+ private getAccountName;
119
135
  /**
120
136
  * Display the Paragon Connect modal
121
137
  */
@@ -128,6 +144,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
128
144
  * @returns The integration object if found, otherwise undefined.
129
145
  */
130
146
  _getIntegration(integrationId: string): IConnectIntegrationWithCredentialInfo | undefined;
147
+ getIntegrationBySlug(integrationName: string): IConnectIntegrationWithCredentialInfo;
131
148
  _oauthCallback(oauthResponse: OauthCallbackResponse, credentialId?: string): Promise<void>;
132
149
  _oauthErrorCallback(errorMessage: string | object, event?: MessageEvent): Promise<void>;
133
150
  customDropdownOptionsLoaders: Record<string, (cursor?: string | undefined, search?: string | undefined) => LoadCustomDropdownOptionsResult>;
@@ -223,6 +240,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
223
240
  * we also need integration config and other credentials info which is not included in `sdk/me`
224
241
  */
225
242
  private fetchIntegrations;
243
+ private getIntegrationIcon;
226
244
  /**
227
245
  * Updates internal state where integration information may be used.
228
246
  */
@@ -267,4 +285,122 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
267
285
  destroyConfiguration({ id, credentialId }: DeleteConfigurationOptions): Promise<void>;
268
286
  updateConfiguration({ id, credentialId, meta, }: UpdateConfigurationOptions): Promise<IConnectCredentialConfig>;
269
287
  private pollForCredential;
288
+ /**
289
+ * Returns integration config
290
+ * @param integration
291
+ * @returns
292
+ */
293
+ getIntegrationConfig(integration: string): IntegrationConfig;
294
+ private getIntegrationCredential;
295
+ /**
296
+ * Updates stored User Settings for an integration or workflow.
297
+ *
298
+ * @param integration - An integration name, e.g. "googledrive"
299
+ * @param userSettingsUpdate - A partial map of input IDs <> values to update the user's settings
300
+ * @param settings - Optional object with selectedCredentialId or selectedConfigurationId
301
+ * @returns Promise with the new user state and an array of errors, if any were found
302
+ */
303
+ updateIntegrationUserSettings(integration: string, userSettingsUpdate: Record<string, any>, settings?: CredentialConfigOptions): Promise<{
304
+ userState: AuthenticatedConnectUser;
305
+ errors: string[];
306
+ }>;
307
+ /**
308
+ * Updates user settings for a specific workflow within an integration.
309
+ *
310
+ * @param integration - An integration name, e.g. "googledrive"
311
+ * @param workflowId - The ID of the workflow to update settings for
312
+ * @param userSettingsUpdate - A partial map of input IDs <> values to update the workflow's settings
313
+ * @param settings - Optional object with selectedCredentialId or selectedConfigurationId
314
+ * @returns Promise with the new user state and an array of errors, if any were found
315
+ * @throws Error if the workflow is not enabled or if the integration is not found
316
+ */
317
+ updateWorkflowUserSettings(integration: string, workflowId: string, userSettingsUpdate: Record<string, any>, settings?: CredentialConfigOptions): Promise<{
318
+ userState: AuthenticatedConnectUser;
319
+ errors: string[];
320
+ }>;
321
+ /**
322
+ * Updates the enabled/disabled state of multiple workflows for a given integration.
323
+ *
324
+ * @param workflowStateUpdate - An object mapping workflow IDs to their desired enabled state (true/false)
325
+ * @param options - Optional settings for credential and configuration selection
326
+ * @param options.selectedCredentialId - Optional ID of the specific credential to use
327
+ * @param options.selectedConfigurationId - Optional ID of the specific configuration to use
328
+ * @returns Promise that resolves with the updated user state and any errors that occurred during the update
329
+ * @throws Error if no valid credential is found or if the integration is not enabled
330
+ */
331
+ updateWorkflowState(workflowStateUpdate: Record<string, boolean>, options?: CredentialConfigOptions): Promise<UpdateWorkflowStateResponse>;
332
+ /**
333
+ * Retrieves field options for a specific integration action.
334
+ *
335
+ * @param integration - The integration type to validate and retrieve field options for.
336
+ * @param action - The specific action within the integration to retrieve field options for.
337
+ * @param search - Optional search term to filter field options.
338
+ * @param cursor - Optional cursor for pagination, can be a string, number, or false.
339
+ * @param parameters - Optional array of parameters to be used in the request.
340
+ * @returns A promise that resolves with the field options or logs an error if the request fails.
341
+ */
342
+ getFieldOptions({ integration, action, search, cursor, parameters, }: {
343
+ integration: string;
344
+ action: string;
345
+ search?: string;
346
+ cursor?: string | number | false;
347
+ parameters: KeyedSource<DataType.ANY>[];
348
+ }): Promise<{
349
+ data: {
350
+ value: string;
351
+ label: string;
352
+ }[];
353
+ nextPageCursor: string | null;
354
+ }>;
355
+ getDataSourceOptions(integrationName: string, action: string): Promise<ComboInputDataSource>;
356
+ getAccountTypeOptions(integrationName: string): AccountType[];
357
+ getPreOptions(integrationName: string, accountTypeId?: string): KeyedSource<DataType.ANY>[] | IntegrationConnectInput[];
358
+ getPostOptions(integrationName: string): IntegrationConnectInput[];
359
+ }
360
+ export declare class InstallFlow {
361
+ private readonly paragon;
362
+ private integrationName;
363
+ private accountType;
364
+ private preOptions;
365
+ private postOptions;
366
+ private credentialId;
367
+ private onNext;
368
+ private onComplete;
369
+ constructor(paragon: ConnectSDK);
370
+ start(integrationName: string, startOptions?: StartOptions): Promise<InstallFlowStage>;
371
+ getScheme(): null | AuthenticationScheme;
372
+ private requiresAccountType;
373
+ private requiresPreOptions;
374
+ private requiresPostOptions;
375
+ setAccountType(accountType: string, onError: (error: unknown) => void): void;
376
+ setPreOptions(options: Record<string, ConnectInputValue>, onError: (error: unknown) => void): void;
377
+ setPostOptions(options: Record<string, ConnectInputValue>, onError: (error: unknown) => void): void;
378
+ getAccountType(): string | null;
379
+ getPreOptions(): Record<string, ConnectInputValue> | null;
380
+ getPostOptions(): Record<string, ConnectInputValue> | null;
381
+ next(): InstallFlowStage;
270
382
  }
383
+ type AccountTypeStage = {
384
+ stage: 'accountType';
385
+ options: AccountType[];
386
+ done: false;
387
+ };
388
+ type PreOptionsStage = {
389
+ stage: 'preOptions';
390
+ options: IntegrationConnectInput[] | KeyedSource<DataType.ANY>[] | SerializedConnectInput[];
391
+ done: false;
392
+ };
393
+ type PostOptionsStage = {
394
+ stage: 'postOptions';
395
+ options: IntegrationConnectInput[];
396
+ done: false;
397
+ };
398
+ type DoneStage = {
399
+ stage: 'done';
400
+ done: true;
401
+ };
402
+ type InstallFlowStage = AccountTypeStage | PreOptionsStage | PostOptionsStage | DoneStage;
403
+ type StartOptions = {
404
+ onComplete?: VoidFunction;
405
+ onNext?: (nextState: InstallFlowStage) => void;
406
+ };