@useparagon/connect 2.0.9 → 2.0.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.
- package/dist/src/ConnectSDK.d.ts +18 -38
- package/dist/src/ConnectSDK.js +1 -1
- package/dist/src/entities/integration.interface.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/types/connect.d.ts +51 -1
- package/dist/src/types/errors.d.ts +52 -0
- package/dist/src/types/sdk.d.ts +11 -5
- package/package.json +1 -1
|
@@ -3,10 +3,12 @@ import { ConnectCredentialProviderData, CredentialStatus, IConnectCredential } f
|
|
|
3
3
|
import { ConnectCredentialConfigMeta, IConnectCredentialConfig } from '../entities/connectCredentialConfig.interface';
|
|
4
4
|
import { PersonaMeta } from '../entities/persona.interface';
|
|
5
5
|
import { AccountType, BooleanInput, ComboInput, CopyableButtonInput, CustomDropdownInput, DataSource, DynamicComboInput, DynamicEnumInput, EmailInput, FieldMapperInput, IntegrationConnectInput, NumberInput, PasswordInput, PermissionInput, SidebarInputType, SwitchInput, URLInput, ValueTextInput } from './action';
|
|
6
|
+
import { InstallFlowError } from './errors';
|
|
6
7
|
import { OrConditions } from './resolvers';
|
|
7
8
|
import { CredentialConfigOptions } from './sdk';
|
|
8
9
|
export { CredentialStatus } from '../entities/connectCredential.interface';
|
|
9
|
-
export type {
|
|
10
|
+
export type { IntegrationMetadata } from '../entities/integration.interface';
|
|
11
|
+
export * from './errors';
|
|
10
12
|
export interface SDKConnectCredentialConfig {
|
|
11
13
|
sharedSettings?: IntegrationSharedInputStateMap;
|
|
12
14
|
workflowSettings?: IntegrationWorkflowStateMap;
|
|
@@ -238,3 +240,51 @@ export type IConnectUserWithProject = IConnectUser & {
|
|
|
238
240
|
export declare const INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS = "auto";
|
|
239
241
|
export declare const SELECTED_CREDENTIAL_ID_HEADER = "X-Paragon-Credential";
|
|
240
242
|
export declare const SELECTED_CREDENTIAL_CONFIG_ID_HEADER = "X-Paragon-Configuration-Id";
|
|
243
|
+
export type AccountTypeStage = {
|
|
244
|
+
stage: 'accountType';
|
|
245
|
+
options: AccountType[];
|
|
246
|
+
done: false;
|
|
247
|
+
};
|
|
248
|
+
export type PreOptionsStage = {
|
|
249
|
+
stage: 'preOptions';
|
|
250
|
+
options: IntegrationConnectInput[];
|
|
251
|
+
done: false;
|
|
252
|
+
};
|
|
253
|
+
export type PostOptionsStage = {
|
|
254
|
+
stage: 'postOptions';
|
|
255
|
+
options: IntegrationConnectInput[];
|
|
256
|
+
done: false;
|
|
257
|
+
};
|
|
258
|
+
export type DoneStage = {
|
|
259
|
+
stage: 'done';
|
|
260
|
+
done: true;
|
|
261
|
+
};
|
|
262
|
+
export type InstallFlowStage = AccountTypeStage | PreOptionsStage | PostOptionsStage | DoneStage;
|
|
263
|
+
export type OnErrorContext = {
|
|
264
|
+
/**
|
|
265
|
+
* The stage of the install flow that failed.
|
|
266
|
+
*/
|
|
267
|
+
stage: Exclude<InstallFlowStage['stage'], 'done'>;
|
|
268
|
+
};
|
|
269
|
+
export type StartOptions = {
|
|
270
|
+
/**
|
|
271
|
+
* Callback to be called when the installation is complete
|
|
272
|
+
*/
|
|
273
|
+
onComplete?: VoidFunction;
|
|
274
|
+
onNext?: (nextState: InstallFlowStage) => void;
|
|
275
|
+
/**
|
|
276
|
+
* Callback to be called when the installation fails.
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* onError: (error, context) => {
|
|
280
|
+
* if (error.name === 'IntegrationNotInstalledError') {
|
|
281
|
+
* // Access the error details
|
|
282
|
+
* console.log("The integration " + error.meta.integrationName + " is not installed");
|
|
283
|
+
* } else {
|
|
284
|
+
* // Handle other errors
|
|
285
|
+
* }
|
|
286
|
+
* }
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
onError?: (error: InstallFlowError, context: null | OnErrorContext) => void;
|
|
290
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type ConnectSDKError = {
|
|
2
|
+
name: 'UnknownError';
|
|
3
|
+
message: string;
|
|
4
|
+
originalError: unknown;
|
|
5
|
+
} | {
|
|
6
|
+
name: 'UserNotAuthenticatedError';
|
|
7
|
+
message: string;
|
|
8
|
+
} | {
|
|
9
|
+
name: 'NoActiveInstallFlowError';
|
|
10
|
+
message: string;
|
|
11
|
+
} | {
|
|
12
|
+
name: 'IntegrationNotFoundError';
|
|
13
|
+
message: string;
|
|
14
|
+
meta: {
|
|
15
|
+
integrationName: string;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
name: 'IntegrationNotInstalledError';
|
|
19
|
+
message: string;
|
|
20
|
+
meta: {
|
|
21
|
+
integrationName: string;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
name: 'HeadlessModeNotEnabledError';
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
type ErrorByName<T> = Extract<ConnectSDKError, {
|
|
28
|
+
name: T;
|
|
29
|
+
}>;
|
|
30
|
+
export type InstallFlowError = ErrorByName<'UserNotAuthenticatedError' | 'NoActiveInstallFlowError' | 'HeadlessModeNotEnabledError' | 'IntegrationNotFoundError' | 'UnknownError'>;
|
|
31
|
+
export declare class BaseSDKError extends Error {
|
|
32
|
+
readonly meta: Record<string, unknown> | null;
|
|
33
|
+
constructor(error: ConnectSDKError);
|
|
34
|
+
}
|
|
35
|
+
export declare class UserNotAuthenticatedError extends BaseSDKError {
|
|
36
|
+
constructor();
|
|
37
|
+
}
|
|
38
|
+
export declare class NoActiveInstallFlowError extends BaseSDKError {
|
|
39
|
+
constructor();
|
|
40
|
+
}
|
|
41
|
+
export declare class IntegrationNotFoundError extends BaseSDKError {
|
|
42
|
+
constructor(integrationName: string);
|
|
43
|
+
}
|
|
44
|
+
export declare class IntegrationNotInstalledError extends BaseSDKError {
|
|
45
|
+
readonly integrationName: string;
|
|
46
|
+
constructor(integrationName: string);
|
|
47
|
+
}
|
|
48
|
+
export declare class HeadlessModeNotEnabledError extends BaseSDKError {
|
|
49
|
+
constructor();
|
|
50
|
+
}
|
|
51
|
+
export declare function getConnectSDKError(error: unknown): ConnectSDKError;
|
|
52
|
+
export {};
|
package/dist/src/types/sdk.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import ConnectSDK, { InstallFlow } from '../ConnectSDK';
|
|
|
3
3
|
import { IConnectCredential } from '../entities/connectCredential.interface';
|
|
4
4
|
import { IConnectCredentialConfig } from '../entities/connectCredentialConfig.interface';
|
|
5
5
|
import { OauthCallbackResponse } from '../entities/credential.interface';
|
|
6
|
-
import { IConnectIntegrationWithCredentialInfo,
|
|
6
|
+
import { IConnectIntegrationWithCredentialInfo, IntegrationMetadata } from '../entities/integration.interface';
|
|
7
7
|
import { PersonaMeta } from '../entities/persona.interface';
|
|
8
8
|
import { IConnectUserContext } from '../helpers/ConnectUserContext';
|
|
9
9
|
import { ConnectSdkEnvironments } from '../server.types';
|
|
@@ -159,9 +159,9 @@ export interface IConnectSDK {
|
|
|
159
159
|
* returns metadata for given integration
|
|
160
160
|
* @param integrationName integration name
|
|
161
161
|
*/
|
|
162
|
-
getIntegrationMetadata():
|
|
163
|
-
getIntegrationMetadata(integrationKey: string):
|
|
164
|
-
getIntegrationMetadata(integrationKey?: string):
|
|
162
|
+
getIntegrationMetadata(): IntegrationMetadata[];
|
|
163
|
+
getIntegrationMetadata(integrationKey: string): IntegrationMetadata;
|
|
164
|
+
getIntegrationMetadata(integrationKey?: string): IntegrationMetadata | IntegrationMetadata[];
|
|
165
165
|
/**
|
|
166
166
|
* triggers all workflows for event
|
|
167
167
|
* @param name eventName
|
|
@@ -363,7 +363,13 @@ export type UserProvidedIntegrationConfig = {
|
|
|
363
363
|
[objectName: string]: DynamicMappingField[] | DynamicMappingOptions | DynamicFieldMappingConfig;
|
|
364
364
|
};
|
|
365
365
|
};
|
|
366
|
-
export type
|
|
366
|
+
export type DropdownOptions = {
|
|
367
|
+
dropdowns?: Record<string, Array<{
|
|
368
|
+
label: string;
|
|
369
|
+
value: string;
|
|
370
|
+
}>>;
|
|
371
|
+
};
|
|
372
|
+
export type ConnectParams = CallbackMap & UserProvidedIntegrationConfig & InstallOptions & CredentialConfigOptions & DropdownOptions;
|
|
367
373
|
export type EventInfo = {
|
|
368
374
|
type: SDK_EVENT;
|
|
369
375
|
integrationId: string;
|