@useparagon/connect 1.0.0 → 1.0.1

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.
Files changed (42) hide show
  1. package/LICENSE +21 -674
  2. package/README.md +33 -8
  3. package/dist/src/ConnectSDK.d.ts +189 -0
  4. package/dist/src/SDKEventEmitter.d.ts +56 -0
  5. package/dist/src/constants.d.ts +1 -0
  6. package/dist/src/entities/base.entity.d.ts +5 -0
  7. package/dist/src/entities/connectCredential.interface.d.ts +42 -0
  8. package/dist/src/entities/credential.interface.d.ts +15 -0
  9. package/dist/src/entities/customIntegration.interface.d.ts +60 -0
  10. package/dist/src/entities/integration.interface.d.ts +33 -0
  11. package/dist/src/entities/integrationConfig.interface.d.ts +9 -0
  12. package/{src/entities/license.interface.ts → dist/src/entities/license.interface.d.ts} +2 -4
  13. package/dist/src/entities/persona.interface.d.ts +34 -0
  14. package/dist/src/entities/project.interface.d.ts +32 -0
  15. package/dist/src/entities/steps.d.ts +30 -0
  16. package/dist/src/entities/team.interface.d.ts +19 -0
  17. package/dist/src/entities/user.interface.d.ts +23 -0
  18. package/dist/src/entities/workflow.interface.d.ts +11 -0
  19. package/dist/src/helpers/ConnectUserContext.d.ts +18 -0
  20. package/dist/src/helpers/index.d.ts +15 -0
  21. package/dist/src/helpers/oauth.d.ts +30 -0
  22. package/dist/src/index.d.ts +8 -0
  23. package/dist/src/index.js +4376 -0
  24. package/dist/src/server.types.d.ts +13 -0
  25. package/dist/src/types/action.d.ts +252 -0
  26. package/dist/src/types/billing.d.ts +2 -0
  27. package/dist/src/types/connect.d.ts +200 -0
  28. package/dist/src/types/connectModal.d.ts +28 -0
  29. package/dist/src/types/environment.d.ts +16 -0
  30. package/dist/src/types/execution.d.ts +5 -0
  31. package/dist/src/types/index.d.ts +10 -0
  32. package/dist/src/types/oauth.d.ts +3 -0
  33. package/dist/src/types/resolvers.d.ts +297 -0
  34. package/dist/src/types/sdk.d.ts +223 -0
  35. package/dist/src/types/stripe.d.ts +23 -0
  36. package/dist/src/utils/connect.d.ts +13 -0
  37. package/dist/src/utils/crypto.d.ts +7 -0
  38. package/dist/src/utils/generic.d.ts +30 -0
  39. package/dist/src/utils/http.d.ts +13 -0
  40. package/dist/src/utils/throttle.d.ts +118 -0
  41. package/package.json +16 -42
  42. package/src/ConnectSDK.tsx +0 -1065
@@ -0,0 +1,297 @@
1
+ /// <reference types="node" />
2
+ import { TokenType } from './action';
3
+ import { FanoutStackEntry } from './execution';
4
+ export declare enum DataType {
5
+ STRING = "STRING",
6
+ NUMBER = "NUMBER",
7
+ DATE = "DATE",
8
+ BOOLEAN = "BOOLEAN",
9
+ EMAIL = "EMAIL",
10
+ OBJECT = "OBJECT",
11
+ ARRAY = "ARRAY",
12
+ ANY = "ANY",
13
+ FILE = "FILE",
14
+ NON_DECIMAL = "NON_DECIMAL"
15
+ }
16
+ export type TokenizedSource<T extends DataType = DataType> = {
17
+ dataType?: T;
18
+ type: 'TOKENIZED';
19
+ parts: TokenizedValue[];
20
+ };
21
+ type TokenizedValue<T extends DataType = DataType> = ValueSource<T> | VariableSource<T> | SecretSource | ConnectCredentialSource | ObjectValueSource | PersonaMetadataSource;
22
+ type ObjectValueSource<T extends DataType = DataType> = {
23
+ type: 'OBJECT_VALUE';
24
+ name: string;
25
+ path: string[];
26
+ dataType?: T;
27
+ };
28
+ type VariableSource<T extends DataType = DataType> = {
29
+ dataType?: T;
30
+ type: 'VARIABLE';
31
+ stepId: string;
32
+ path: string[];
33
+ };
34
+ type SecretSource = {
35
+ type: 'ENVIRONMENT_SECRET';
36
+ environmentSecretId: string;
37
+ };
38
+ type ValueSource<T extends DataType = DataType> = {
39
+ dataType?: T;
40
+ type: 'VALUE';
41
+ value: DataTypeValues[T];
42
+ };
43
+ type ConnectCredentialSource = {
44
+ type: 'CONNECT_CREDENTIAL_FIELD';
45
+ fieldType: 'WORKFLOW_SETTING';
46
+ inputId: string;
47
+ /**
48
+ * @since PARA-3065: ConnectInputValue can now include more than a string/number type, so a
49
+ * path is specified similarly to VariableSource to traverse object types.
50
+ */
51
+ path?: string[];
52
+ } | {
53
+ type: 'CONNECT_CREDENTIAL_FIELD';
54
+ fieldType: 'SHARED_WORKFLOW_SETTING';
55
+ inputId: string;
56
+ path?: string[];
57
+ } | {
58
+ type: 'CONNECT_CREDENTIAL_FIELD';
59
+ fieldType: 'EXTERNAL_USER_ID';
60
+ } | {
61
+ type: 'CONNECT_CREDENTIAL_FIELD';
62
+ fieldType: 'EXTERNAL_USER_PROVIDER_ID';
63
+ } | {
64
+ type: 'CONNECT_CREDENTIAL_FIELD';
65
+ fieldType: 'OAUTH_ACCESS_TOKEN';
66
+ } | {
67
+ type: 'CONNECT_CREDENTIAL_FIELD';
68
+ fieldType: 'EXTERNAL_USER_PROVIDER_DATA';
69
+ dataKey: string;
70
+ };
71
+ type PersonaMetadataSource = {
72
+ type: 'PERSONA_METADATA';
73
+ path?: string[];
74
+ };
75
+ type DataTypeValues = {
76
+ [DataType.STRING]: string;
77
+ [DataType.NUMBER]: number;
78
+ [DataType.DATE]: Date;
79
+ [DataType.BOOLEAN]: boolean;
80
+ [DataType.EMAIL]: string;
81
+ [DataType.OBJECT]: object;
82
+ [DataType.ARRAY]: any[];
83
+ [DataType.ANY]: any;
84
+ [DataType.FILE]: FileValue;
85
+ [DataType.NON_DECIMAL]: number;
86
+ };
87
+ type FileDataType = Buffer;
88
+ type FileValue = {
89
+ data: FileDataType;
90
+ dataType: DataType.FILE;
91
+ encoding?: string;
92
+ id?: string;
93
+ mimeType?: string;
94
+ name?: string;
95
+ size?: string;
96
+ };
97
+ export type KeyedSource<T extends DataType = DataType> = {
98
+ key: string;
99
+ source: Source<T>;
100
+ };
101
+ export type Source<T extends DataType = DataType> = ValueSource<T> | VariableSource<T> | TokenizedSource<T> | ConditionSource | SecretSource | ExecutionSource | FanoutExecutionSource | UserSuppliedCredentialSource | ConnectCredentialSource | ObjectValueSource | PersonaMetadataSource;
102
+ type ConditionSource = {
103
+ type: 'CONDITION';
104
+ condition: ConditionWrapper;
105
+ };
106
+ type ConditionWrapper = JoinedConditions | OperatorCondition;
107
+ type JoinedConditions = AndConditions | OrConditions;
108
+ type AndConditions = {
109
+ type: 'JOIN';
110
+ join: 'AND';
111
+ conditions: ConditionWrapper[];
112
+ };
113
+ export type OrConditions = {
114
+ type: 'JOIN';
115
+ join: 'OR';
116
+ conditions: ConditionWrapper[];
117
+ };
118
+ type OperatorCondition = {
119
+ type: 'OPERATOR';
120
+ condition: Condition;
121
+ };
122
+ type Condition = {
123
+ operator: Operator.None;
124
+ variable: Source<DataType.ANY>;
125
+ } | {
126
+ operator: Operator.StringContains;
127
+ variable: Source<DataType.STRING>;
128
+ argument: Source<DataType.STRING>;
129
+ } | {
130
+ operator: Operator.StringDoesNotContain;
131
+ variable: Source<DataType.STRING>;
132
+ argument: Source<DataType.STRING>;
133
+ } | {
134
+ operator: Operator.StringExactlyMatches;
135
+ variable: Source<DataType.STRING>;
136
+ argument: Source<DataType.STRING>;
137
+ } | {
138
+ operator: Operator.StringDoesNotExactlyMatch;
139
+ variable: Source<DataType.STRING>;
140
+ argument: Source<DataType.STRING>;
141
+ } | {
142
+ operator: Operator.StringIsIn;
143
+ variable: Source<DataType.STRING>;
144
+ argument: Source<DataType.STRING>;
145
+ } | {
146
+ operator: Operator.StringIsNotIn;
147
+ variable: Source<DataType.STRING>;
148
+ argument: Source<DataType.STRING>;
149
+ } | {
150
+ operator: Operator.StringStartsWith;
151
+ variable: Source<DataType.STRING>;
152
+ argument: Source<DataType.STRING>;
153
+ } | {
154
+ operator: Operator.StringDoesNotStartWith;
155
+ variable: Source<DataType.STRING>;
156
+ argument: Source<DataType.STRING>;
157
+ } | {
158
+ operator: Operator.StringEndsWith;
159
+ variable: Source<DataType.STRING>;
160
+ argument: Source<DataType.STRING>;
161
+ } | {
162
+ operator: Operator.StringDoesNotEndWith;
163
+ variable: Source<DataType.STRING>;
164
+ argument: Source<DataType.STRING>;
165
+ } | {
166
+ operator: Operator.NumberGreaterThan;
167
+ variable: Source<DataType.NUMBER>;
168
+ argument: Source<DataType.NUMBER>;
169
+ } | {
170
+ operator: Operator.NumberLessThan;
171
+ variable: Source<DataType.NUMBER>;
172
+ argument: Source<DataType.NUMBER>;
173
+ } | {
174
+ operator: Operator.NumberGreaterThanOrEqualTo;
175
+ variable: Source<DataType.NUMBER>;
176
+ argument: Source<DataType.NUMBER>;
177
+ } | {
178
+ operator: Operator.NumberLessThanOrEqualTo;
179
+ variable: Source<DataType.NUMBER>;
180
+ argument: Source<DataType.NUMBER>;
181
+ } | {
182
+ operator: Operator.NumberEquals;
183
+ variable: Source<DataType.NUMBER>;
184
+ argument: Source<DataType.NUMBER>;
185
+ } | {
186
+ operator: Operator.NumberDoesNotEqual;
187
+ variable: Source<DataType.NUMBER>;
188
+ argument: Source<DataType.NUMBER>;
189
+ } | {
190
+ operator: Operator.DateTimeAfter;
191
+ variable: Source<DataType.DATE>;
192
+ argument: Source<DataType.DATE>;
193
+ } | {
194
+ operator: Operator.DateTimeBefore;
195
+ variable: Source<DataType.DATE>;
196
+ argument: Source<DataType.DATE>;
197
+ } | {
198
+ operator: Operator.DateTimeEquals;
199
+ variable: Source<DataType.DATE>;
200
+ argument: Source<DataType.DATE>;
201
+ } | {
202
+ operator: Operator.BooleanTrue;
203
+ variable: Source<DataType.BOOLEAN>;
204
+ } | {
205
+ operator: Operator.BooleanFalse;
206
+ variable: Source<DataType.BOOLEAN>;
207
+ } | {
208
+ operator: Operator.IsNull;
209
+ variable: Source;
210
+ } | {
211
+ operator: Operator.IsNotNull;
212
+ variable: Source;
213
+ } | {
214
+ operator: Operator.Exists;
215
+ variable: Source;
216
+ } | {
217
+ operator: Operator.DoesNotExist;
218
+ variable: Source;
219
+ } | {
220
+ operator: Operator.ArrayIsEmpty;
221
+ variable: Source<DataType.ARRAY>;
222
+ } | {
223
+ operator: Operator.ArrayIsNotEmpty;
224
+ variable: Source<DataType.ARRAY>;
225
+ } | {
226
+ operator: Operator.StringGreaterThan;
227
+ variable: Source<DataType.STRING>;
228
+ argument: Source<DataType.STRING>;
229
+ } | {
230
+ operator: Operator.StringLessThan;
231
+ variable: Source<DataType.STRING>;
232
+ argument: Source<DataType.STRING>;
233
+ };
234
+ declare enum Operator {
235
+ 'None' = "$none",
236
+ 'StringContains' = "$stringContains",
237
+ 'StringDoesNotContain' = "$stringDoesNotContain",
238
+ 'StringExactlyMatches' = "$stringExactlyMatches",
239
+ 'StringDoesNotExactlyMatch' = "$stringDoesNotExactlyMatch",
240
+ 'StringIsIn' = "$stringIsIn",
241
+ 'StringIsNotIn' = "$stringIsNotIn",
242
+ 'StringStartsWith' = "$stringStartsWith",
243
+ 'StringDoesNotStartWith' = "$stringDoesNotStartWith",
244
+ 'StringEndsWith' = "$stringEndsWith",
245
+ 'StringDoesNotEndWith' = "$stringDoesNotEndWith",
246
+ 'NumberGreaterThan' = "$numberGreaterThan",
247
+ 'NumberLessThan' = "$numberLessThan",
248
+ 'NumberEquals' = "$numberEquals",
249
+ 'NumberDoesNotEqual' = "$numberDoesNotEqual",
250
+ 'NumberLessThanOrEqualTo' = "$numberLessThanOrEqualTo",
251
+ 'NumberGreaterThanOrEqualTo' = "$numberGreaterThanOrEqualTo",
252
+ 'DateTimeAfter' = "$dateTimeAfter",
253
+ 'DateTimeBefore' = "$dateTimeBefore",
254
+ 'DateTimeEquals' = "$dateTimeEquals",
255
+ 'BooleanTrue' = "$booleanTrue",
256
+ 'BooleanFalse' = "$booleanFalse",
257
+ /** (PARA-5551) previously operators for Does Exist / Does Not Exist do a strict check for equality to null, resulting in a bug where value is undefined
258
+ * to handle this situation, we are adding 2 new operators IsNotNull and IsNull and changing functionality of
259
+ * Exist and DoesNotExist operators to handle undefined values
260
+ */
261
+ 'IsNotNull' = "$exists",
262
+ 'IsNull' = "$doesNotExist",
263
+ 'Exists' = "$isNotUndefinedOrNull",
264
+ 'DoesNotExist' = "$isUndefinedOrNull",
265
+ 'ArrayIsIn' = "$arrayIsIn",
266
+ 'ArrayIsNotIn' = "$arrayIsNotIn",
267
+ 'ArrayIsEmpty' = "$arrayIsEmpty",
268
+ 'ArrayIsNotEmpty' = "$arrayIsNotEmpty",
269
+ 'StringGreaterThan' = "$stringGreaterThan",
270
+ 'StringLessThan' = "$stringLessThan"
271
+ }
272
+ type ExecutionSource = {
273
+ type: 'EXECUTION';
274
+ id: string;
275
+ stepId: string;
276
+ /**
277
+ * a timestamp representing when the execution occurred
278
+ */
279
+ start: number;
280
+ fanoutStack: FanoutStackEntry[];
281
+ /**
282
+ * This flag suggests that the content of the variable will be stored on remmote storage service
283
+ * such as s3
284
+ */
285
+ remoteCached?: boolean;
286
+ };
287
+ type FanoutExecutionSource = {
288
+ type: 'FANOUT_EXECUTION';
289
+ stepId: string;
290
+ };
291
+ type UserSuppliedCredentialSource = {
292
+ type: 'USER_SUPPLIED_CREDENTIAL';
293
+ tokenType: TokenType;
294
+ providerType: string;
295
+ credential: TokenizedSource<DataType.STRING>;
296
+ };
297
+ export {};
@@ -0,0 +1,223 @@
1
+ import ConnectSDK from '../ConnectSDK';
2
+ import { OauthCallbackResponse } from '../entities/credential.interface';
3
+ import { IIntegrationMetadata } from '../entities/integration.interface';
4
+ import { PersonaMeta } from '../entities/persona.interface';
5
+ import { IConnectUserContext } from '../helpers/ConnectUserContext';
6
+ import { AuthenticatedConnectUser, DynamicMappingField, DynamicMappingOptions, IntegrationWorkflowState } from '../types/connect';
7
+ import { Props as ConnectModalProps } from './connectModal';
8
+ export type ConnectUser = {
9
+ authenticated: false;
10
+ } | AuthenticatedConnectUser;
11
+ export type FunctionPropertyNames<T> = {
12
+ [K in keyof T]: T[K] extends Function ? K : never;
13
+ }[keyof T];
14
+ type NonFunctionPropertyNames<T> = {
15
+ [K in keyof T]: T[K] extends Function ? never : K;
16
+ }[keyof T];
17
+ export type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
18
+ export type UnwrapPromise<T> = T extends PromiseLike<infer U> ? U : T;
19
+ export type NonNullUndefinedField<T> = {
20
+ [P in keyof T]-?: NonNullUndefinedField<NonNullable<T[P]>>;
21
+ };
22
+ export type UIUpdateMessage = {
23
+ messageType: 'UI_UPDATE';
24
+ nextContext: NonFunctionProperties<IConnectUserContext>;
25
+ nextModalState: NonFunctionProperties<ConnectModalProps>;
26
+ };
27
+ export type SDKFunctionInvocationMessage<T extends FunctionPropertyNames<ConnectSDK> = never> = {
28
+ messageType: 'SDK_FUNCTION_INVOCATION';
29
+ type: T;
30
+ parameters: Parameters<ConnectSDK[T]>;
31
+ id: string;
32
+ };
33
+ export type SDKFunctionResponseMessage<T extends FunctionPropertyNames<ConnectSDK> = never> = {
34
+ messageType: 'SDK_FUNCTION_RESPONSE';
35
+ type: T;
36
+ result: UnwrapPromise<ReturnType<ConnectSDK[T]>>;
37
+ id: string;
38
+ };
39
+ export type SDKFunctionErrorMessage = {
40
+ messageType: 'SDK_FUNCTION_ERROR';
41
+ error: true;
42
+ message: string;
43
+ id: string;
44
+ };
45
+ export type SDKReceivedMessage = SDKFunctionInvocationMessage;
46
+ export interface IConnectSDK {
47
+ authenticate(projectId: string, token: string, options?: AuthenticateOptions): Promise<void>;
48
+ connect(action: string): void;
49
+ getUser(): ConnectUser;
50
+ /**
51
+ * **Do not call this function directly.**
52
+ *
53
+ * Invoked by the OAuth popup after finishing the credential exchange.
54
+ * @private
55
+ */
56
+ _oauthCallback(credential: OauthCallbackResponse): Promise<void>;
57
+ /**
58
+ * **Do not call this function directly.**
59
+ *
60
+ * Invoked by the OAuth popup on an error encountered during the credential exchange.
61
+ * @private
62
+ */
63
+ _oauthErrorCallback(errorMessage: string): Promise<void>;
64
+ /**
65
+ * installs an integration without the need to click on enable button from portal
66
+ * Install Options:
67
+ * `{showPortalAfterInstall: boolean}` decides wether to show portal with configuration view after the installation is completed
68
+ */
69
+ installIntegration(name: string, options: InstallOptions): Promise<void>;
70
+ /**
71
+ * uninstalls an integration for connected user.
72
+ */
73
+ uninstallIntegration(name: string): Promise<void>;
74
+ /**
75
+ * disables a workflow for the connected user and unsubscribes all the workflows in hermes
76
+ */
77
+ disableWorkflow(workflowId: string): Promise<void>;
78
+ setUserMetadata(meta: PersonaMeta): Promise<AuthenticatedConnectUser>;
79
+ /**
80
+ * sets the base url for different services used in connect sdk
81
+ */
82
+ configureGlobal(options: {
83
+ host: string;
84
+ }): void;
85
+ /**
86
+ * returns metadata for given integration
87
+ * @param integrationName integration name
88
+ */
89
+ getIntegrationMetadata(integrationName: string): IIntegrationMetadata;
90
+ getIntegrationMetadata(): IIntegrationMetadata[];
91
+ /**
92
+ * triggers all workflows for event
93
+ * @param name eventName
94
+ * @param payload event payload object
95
+ */
96
+ event(name: string, payload: Record<string, unknown>): Promise<void>;
97
+ /**
98
+ * makes an connect proxy action request
99
+ * @param action actionName
100
+ * @param path request path
101
+ * @param init request initialization options {method: httpMethod, body:RequestBody, header}
102
+ */
103
+ request<TResponse>(action: string, path: string, init: {
104
+ method: RequestInit['method'];
105
+ body: RequestInit['body'] | object;
106
+ headers: RequestInit['headers'];
107
+ }): Promise<TResponse | undefined>;
108
+ /**
109
+ * listen on connect sdk events
110
+ * @param eventName SDKEVENTS
111
+ * @param listener
112
+ */
113
+ subscribe(eventName: SDK_EVENT, listener: ListenerFunction): () => boolean;
114
+ /**
115
+ * remove listeners on connect sdk events
116
+ * @param eventName SDKEVENTS
117
+ * @param listener
118
+ */
119
+ unsubscribe(eventName: SDK_EVENT, listener: ListenerFunction): boolean;
120
+ /**
121
+ * trigger connect endpoint trigger workflow
122
+ * @param workflowId
123
+ * @param triggerWorkflowRequest
124
+ */
125
+ workflow(workflowId: string, triggerWorkflowRequest: TriggerWorkflowRequest): Promise<object | undefined>;
126
+ }
127
+ /**
128
+ * sdk install options
129
+ */
130
+ export type InstallOptions = {
131
+ /**
132
+ * api only install or ui install
133
+ */
134
+ isApiInstallation?: boolean;
135
+ /**
136
+ * if true show portal when install with api install option
137
+ */
138
+ showPortalAfterInstall?: boolean;
139
+ /**
140
+ * not show post oauth promt if this is true
141
+ */
142
+ bypassPostOAuthPrompt?: boolean;
143
+ };
144
+ export type AuthenticateOptions = {
145
+ metadata?: PersonaMeta;
146
+ };
147
+ /**
148
+ * Connect Modal Tabs
149
+ */
150
+ export declare enum ModalView {
151
+ OVERVIEW = "overview",
152
+ CONFIGURATION = "configuration"
153
+ }
154
+ export type IntegrationInstallEvent = {
155
+ integrationId: string;
156
+ integrationType: string;
157
+ };
158
+ export type IntegrationUninstallEvent = IntegrationInstallEvent;
159
+ export type WorkflowStateChangeEvent = {
160
+ integrationId: string;
161
+ workflowId: string;
162
+ workflowStateChange: Partial<IntegrationWorkflowState>;
163
+ };
164
+ export type PortalOpenEvent = {
165
+ integrationId: string;
166
+ integrationType: string;
167
+ };
168
+ export type PortalCloseEvent = PortalOpenEvent;
169
+ export type CallbackMap = {
170
+ onSuccess?: (event: IntegrationInstallEvent, user: AuthenticatedConnectUser) => void;
171
+ onInstall?: (event: IntegrationInstallEvent, user: AuthenticatedConnectUser) => void;
172
+ onError?: (err: Error) => void;
173
+ onUninstall?: (event: IntegrationUninstallEvent, user: AuthenticatedConnectUser) => void;
174
+ onWorkflowChange?: (event: WorkflowStateChangeEvent, user: AuthenticatedConnectUser) => void;
175
+ onOpen?: (event: PortalOpenEvent, user: AuthenticatedConnectUser) => void;
176
+ onClose?: (event: PortalCloseEvent, user: AuthenticatedConnectUser) => void;
177
+ };
178
+ export type UserProvidedIntegrationConfig = {
179
+ /**
180
+ * used to override redirect url passed in getAuthUrl instead of our passport url
181
+ */
182
+ overrideRedirectUrl?: string;
183
+ /**
184
+ * This will allow users to provide dynamic fields options for object mapping inputs
185
+ */
186
+ mapObjectFields?: {
187
+ [objectName: string]: DynamicMappingField[] | DynamicMappingOptions;
188
+ };
189
+ };
190
+ export type ConnectParams = CallbackMap & UserProvidedIntegrationConfig & InstallOptions;
191
+ export type EventInfo = {
192
+ type: SDK_EVENT;
193
+ integrationId: string;
194
+ integrationType: string;
195
+ workflowId?: string;
196
+ workflowStateChange?: Partial<IntegrationWorkflowState>;
197
+ };
198
+ export declare enum SDK_EVENT {
199
+ ON_INTEGRATION_INSTALL = "onIntegrationInstall",
200
+ ON_INTEGRATION_UNINSTALL = "onIntegrationUninstall",
201
+ ON_WORKFLOW_CHANGE = "onWorkflowChange",
202
+ ON_PORTAL_OPEN = "onPortalOpen",
203
+ ON_PORTAL_CLOSE = "onPortalClose"
204
+ }
205
+ export type SDKEventListenerMap = {
206
+ [SDK_EVENT.ON_INTEGRATION_INSTALL]: Array<(event: IntegrationInstallEvent, user: AuthenticatedConnectUser) => void>;
207
+ [SDK_EVENT.ON_INTEGRATION_UNINSTALL]: Array<(event: IntegrationUninstallEvent, user: AuthenticatedConnectUser) => void>;
208
+ [SDK_EVENT.ON_PORTAL_CLOSE]: Array<(event: PortalCloseEvent, user: AuthenticatedConnectUser) => void>;
209
+ [SDK_EVENT.ON_PORTAL_OPEN]: Array<(event: PortalOpenEvent, user: AuthenticatedConnectUser) => void>;
210
+ [SDK_EVENT.ON_WORKFLOW_CHANGE]: Array<(event: WorkflowStateChangeEvent, user: AuthenticatedConnectUser) => void>;
211
+ };
212
+ export type ListenerFunction = SDKEventListenerMap[keyof SDKEventListenerMap][number];
213
+ export declare enum DocumentLoadingState {
214
+ LOADING = "loading",
215
+ INTERACTIVE = "interactive",
216
+ COMPLETE = "complete"
217
+ }
218
+ export type TriggerWorkflowRequest = {
219
+ body?: RequestInit['body'] | object;
220
+ headers?: RequestInit['headers'];
221
+ query?: Record<string, string>;
222
+ };
223
+ export {};
@@ -0,0 +1,23 @@
1
+ export declare enum BillingPlan {
2
+ ClassicFree = "free",
3
+ ClassicStarter = "starter",
4
+ ClassicBusiness = "business",
5
+ ClassicPremium = "premium",
6
+ ClassicEnterprise = "enterprise",
7
+ ConnectTrial = "connect_trial",
8
+ ConnectBasic = "basic",
9
+ ConnectPro = "pro",
10
+ ConnectEnterprise = "connect_enterprise"
11
+ }
12
+ export declare enum ConnectAddOn {
13
+ CustomIntegrationBuilder = "byo",
14
+ DynamicFieldMapper = "dfm",
15
+ HeadlessConnectPortal = "headless-cp",
16
+ TaskHistoryAPI = "th-api",
17
+ Monitoring = "monitoring",
18
+ RoleBasedAccessControl = "rbac",
19
+ UserMetadata = "user-metadata",
20
+ WhiteLabeling = "whitelabel",
21
+ WorkflowPermission = "workflow-permissions"
22
+ }
23
+ export type ConnectNonTrialBillingPlan = BillingPlan.ConnectBasic | BillingPlan.ConnectPro | BillingPlan.ConnectEnterprise;
@@ -0,0 +1,13 @@
1
+ import { NODE_ENV, PLATFORM_ENV } from '../types/environment';
2
+ /**
3
+ * get asset url i.e. cdn public url or dashboard public url
4
+ * @param env
5
+ * @returns
6
+ */
7
+ export declare const getAssetUrl: ({ CDN_PUBLIC_URL: cdnHost, DASHBOARD_PUBLIC_URL: dashboardPublicURL, VERSION: version, PLATFORM_ENV: platformEnv, NODE_ENV: nodeEnv, }: {
8
+ CDN_PUBLIC_URL: string;
9
+ DASHBOARD_PUBLIC_URL: string;
10
+ NODE_ENV: string;
11
+ PLATFORM_ENV: string;
12
+ VERSION: string;
13
+ }) => string;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * hashes a string
3
+ *
4
+ * @param {string} value
5
+ * @returns {string} 10 digit hash
6
+ */
7
+ export declare function hash(value: string): string;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * a helper class for creating deferred promises
3
+ * @tutorial https://gist.github.com/GFoley83/5877f6c09fbcfd62569c51dc91444cf0
4
+ */
5
+ export declare class DeferredPromise<T> implements Promise<T> {
6
+ [Symbol.toStringTag]: 'Promise';
7
+ private _promise;
8
+ private _resolve;
9
+ private _reject;
10
+ private _state;
11
+ get state(): 'pending' | 'fulfilled' | 'rejected';
12
+ constructor();
13
+ then<TResult1, TResult2>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>;
14
+ catch<TResult>(onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>;
15
+ resolve(value?: T | PromiseLike<T>): void;
16
+ reject(reason?: any): void;
17
+ finally(onfinally?: () => void): Promise<T>;
18
+ }
19
+ /**
20
+ * given a type definition of a record and possible values for each key,
21
+ * it generates an array of every permutation
22
+ *
23
+ * @template T
24
+ * @param {{ [k in keyof T]: T[k][] }} input
25
+ * @returns {T[]}
26
+ */
27
+ export declare function generateMatrix<T extends Record<string, any>>(input: {
28
+ [k in keyof T]: T[k][];
29
+ }, limit?: number): T[];
30
+ export declare function sleep(milliseconds: number): Promise<void>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * check if url is valid or not
3
+ * @param url
4
+ * @returns
5
+ */
6
+ export declare const isValidUrl: (url: string) => boolean;
7
+ /**
8
+ * it will add https protocol if protocol is not added in utl
9
+ * @param url
10
+ * @returns
11
+ */
12
+ export declare function sanitizeUrl(url: string): string;
13
+ export declare function getServiceUrl(service: string, domain: string): string;