@useparagon/connect 1.0.35-experimental.8 → 2.0.0-rc.2

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, 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,20 @@ 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 & {
125
+ endUserSuppliedValues?: Record<string, ConnectInputValue>;
126
+ }, options?: {
127
+ onSuccess?: (connectCredentialId: string) => void;
128
+ onError?: (error: unknown) => void;
129
+ }): void;
130
+ private getIntegrationByName;
131
+ private getSelectedMultipleAccountTypes;
132
+ /**
133
+ * in chrome getting issue for asynchronous popup opening
134
+ * see PARA-1505
135
+ */
136
+ private getAccountName;
119
137
  /**
120
138
  * Display the Paragon Connect modal
121
139
  */
@@ -128,6 +146,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
128
146
  * @returns The integration object if found, otherwise undefined.
129
147
  */
130
148
  _getIntegration(integrationId: string): IConnectIntegrationWithCredentialInfo | undefined;
149
+ getIntegrationBySlug(integrationName: string): IConnectIntegrationWithCredentialInfo;
131
150
  _oauthCallback(oauthResponse: OauthCallbackResponse, credentialId?: string): Promise<void>;
132
151
  _oauthErrorCallback(errorMessage: string | object, event?: MessageEvent): Promise<void>;
133
152
  customDropdownOptionsLoaders: Record<string, (cursor?: string | undefined, search?: string | undefined) => LoadCustomDropdownOptionsResult>;
@@ -223,6 +242,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
223
242
  * we also need integration config and other credentials info which is not included in `sdk/me`
224
243
  */
225
244
  private fetchIntegrations;
245
+ private getIntegrationIcon;
226
246
  /**
227
247
  * Updates internal state where integration information may be used.
228
248
  */
@@ -267,4 +287,130 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
267
287
  destroyConfiguration({ id, credentialId }: DeleteConfigurationOptions): Promise<void>;
268
288
  updateConfiguration({ id, credentialId, meta, }: UpdateConfigurationOptions): Promise<IConnectCredentialConfig>;
269
289
  private pollForCredential;
290
+ /**
291
+ * Returns integration config
292
+ * @param integration
293
+ * @returns
294
+ */
295
+ getIntegrationConfig(integration: string): IntegrationConfig;
296
+ private getIntegrationCredential;
297
+ /**
298
+ * Updates stored User Settings for an integration or workflow.
299
+ *
300
+ * @param integration - An integration name, e.g. "googledrive"
301
+ * @param userSettingsUpdate - A partial map of input IDs <> values to update the user's settings
302
+ * @param settings - Optional object with selectedCredentialId or selectedConfigurationId
303
+ * @returns Promise with the new user state and an array of errors, if any were found
304
+ */
305
+ updateIntegrationUserSettings(integration: string, userSettingsUpdate: Record<string, any>, settings?: CredentialConfigOptions): Promise<{
306
+ userState: AuthenticatedConnectUser;
307
+ errors: string[];
308
+ }>;
309
+ /**
310
+ * Updates user settings for a specific workflow within an integration.
311
+ *
312
+ * @param integration - An integration name, e.g. "googledrive"
313
+ * @param workflowId - The ID of the workflow to update settings for
314
+ * @param userSettingsUpdate - A partial map of input IDs <> values to update the workflow's settings
315
+ * @param settings - Optional object with selectedCredentialId or selectedConfigurationId
316
+ * @returns Promise with the new user state and an array of errors, if any were found
317
+ * @throws Error if the workflow is not enabled or if the integration is not found
318
+ */
319
+ updateWorkflowUserSettings(integration: string, workflowId: string, userSettingsUpdate: Record<string, any>, settings?: CredentialConfigOptions): Promise<{
320
+ userState: AuthenticatedConnectUser;
321
+ errors: string[];
322
+ }>;
323
+ /**
324
+ * Updates the enabled/disabled state of multiple workflows for a given integration.
325
+ *
326
+ * @param workflowStateUpdate - An object mapping workflow IDs to their desired enabled state (true/false)
327
+ * @param options - Optional settings for credential and configuration selection
328
+ * @param options.selectedCredentialId - Optional ID of the specific credential to use
329
+ * @param options.selectedConfigurationId - Optional ID of the specific configuration to use
330
+ * @returns Promise that resolves with the updated user state and any errors that occurred during the update
331
+ * @throws Error if no valid credential is found or if the integration is not enabled
332
+ */
333
+ updateWorkflowState(workflowStateUpdate: Record<string, boolean>, options?: CredentialConfigOptions): Promise<UpdateWorkflowStateResponse>;
334
+ /**
335
+ * Retrieves field options for a specific integration action.
336
+ *
337
+ * @param integration - The integration type to validate and retrieve field options for.
338
+ * @param action - The specific action within the integration to retrieve field options for.
339
+ * @param search - Optional search term to filter field options.
340
+ * @param cursor - Optional cursor for pagination, can be a string, number, or false.
341
+ * @param parameters - Optional array of parameters to be used in the request.
342
+ * @returns A promise that resolves with the field options or logs an error if the request fails.
343
+ */
344
+ getFieldOptions({ integration, action, search, cursor, parameters, }: {
345
+ integration: string;
346
+ action: string;
347
+ search?: string;
348
+ cursor?: string | number | false;
349
+ parameters: KeyedSource<DataType.ANY>[];
350
+ }): Promise<{
351
+ data: {
352
+ value: string;
353
+ label: string;
354
+ }[];
355
+ nestedData: {
356
+ title: string;
357
+ items: {
358
+ value: string;
359
+ label: string;
360
+ }[];
361
+ }[];
362
+ nextPageCursor: string | null;
363
+ }>;
364
+ getDataSourceOptions(integrationName: string, action: string): Promise<ComboInputDataSource>;
365
+ getAccountTypeOptions(integrationName: string): AccountType[];
366
+ getPreOptions(integrationName: string, accountTypeId?: string): IntegrationConnectInput[];
367
+ getPostOptions(integrationName: string): IntegrationConnectInput[];
368
+ }
369
+ export declare class InstallFlow {
370
+ private readonly paragon;
371
+ private integrationName;
372
+ private accountType;
373
+ private preOptions;
374
+ private postOptions;
375
+ private credentialId;
376
+ private onNext;
377
+ private onComplete;
378
+ constructor(paragon: ConnectSDK);
379
+ start(integrationName: string, startOptions?: StartOptions): Promise<void | undefined>;
380
+ getScheme(): null | AuthenticationScheme;
381
+ private getSelectedAccountTypeOption;
382
+ private requiresAccountType;
383
+ private requiresPreOptions;
384
+ private requiresPostOptions;
385
+ setAccountType(accountType: string, onError: (error: unknown) => void): void;
386
+ setPreOptions(options: Record<string, ConnectInputValue>, onError: (error: unknown) => void): void;
387
+ setPostOptions(options: Record<string, ConnectInputValue>, onError: (error: unknown) => void): void;
388
+ getAccountType(): string | null;
389
+ getPreOptions(): Record<string, ConnectInputValue> | null;
390
+ getPostOptions(): Record<string, ConnectInputValue> | null;
391
+ next(): InstallFlowStage;
270
392
  }
393
+ type AccountTypeStage = {
394
+ stage: 'accountType';
395
+ options: AccountType[];
396
+ done: false;
397
+ };
398
+ type PreOptionsStage = {
399
+ stage: 'preOptions';
400
+ options: IntegrationConnectInput[];
401
+ done: false;
402
+ };
403
+ type PostOptionsStage = {
404
+ stage: 'postOptions';
405
+ options: IntegrationConnectInput[];
406
+ done: false;
407
+ };
408
+ type DoneStage = {
409
+ stage: 'done';
410
+ done: true;
411
+ };
412
+ type InstallFlowStage = AccountTypeStage | PreOptionsStage | PostOptionsStage | DoneStage;
413
+ type StartOptions = {
414
+ onComplete?: VoidFunction;
415
+ onNext?: (nextState: InstallFlowStage) => void;
416
+ };