@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
package/README.md CHANGED
@@ -1,19 +1,44 @@
1
1
  <p align="center">
2
- <a href="https://www.useparagon.com/" target="blank"><img src="../../static/paragon-banner.png" width="320" alt="Paragon Logo" /></a>
2
+ <a href="https://www.useparagon.com/" target="blank"><img src="https://raw.githubusercontent.com/useparagon/aws-on-prem/master/assets/paragon-logo-dark.png" width="150" alt="Paragon Logo" /></a>
3
3
  </p>
4
4
 
5
- ## Description
5
+ <p align="center">
6
+ <b>
7
+ The embedded integration platform for developers.
8
+ </b>
9
+ </p>
10
+
11
+ ---
12
+
13
+ Paragon is an embedded integration platform that 100+ software companies rely on to rapidly accelerate development of native product integrations with 3rd party SaaS apps such as Salesforce, Slack, and QuickBooks. This allows their engineering teams to avoid the heavy costs and risks that come with building and maintaining dozens of their own integrations.
14
+
15
+ ## Usage
16
+
17
+ To install the Paragon SDK, run this command in your project to add it as a dependency:
18
+
19
+ ```sh
20
+ npm install @useparagon/connect
21
+ ```
22
+
23
+ This package is intended for usage in your frontend application to embed the Paragon connection experience. After importing the **[Paragon SDK](https://docs.useparagon.com/getting-started/installing-the-connect-sdk)**, you can:
6
24
 
7
- Work on [Paragon](https://www.useparagon.com) tasks.
25
+ - Display the **[Connect Portal](https://docs.useparagon.com/connect-portal/connect-portal-customization)**, a prebuilt UI component for your users to connect third-party app accounts
26
+ - Trigger [**Workflows**](https://docs.useparagon.com/workflows/building-workflows), which are observable, durable jobs you define to sync integration data
27
+ - Send [**Connect API**](https://docs.useparagon.com/api/making-api-requests) requests to access integration data in realtime from your app
28
+ - Render a custom integrations UI using the [**Headless Connect Portal**](https://docs.useparagon.com/connect-portal/headless-connect-portal)
8
29
 
9
- ## Running the app
30
+ ```typescript
31
+ import { paragon } from '@useparagon/connect';
10
32
 
11
- ```bash
12
- # development
13
- $ yarn run start
33
+ // Authenticate your user with the SDK
34
+ await paragon.authenticate(projectId, paragonUserToken);
14
35
 
36
+ // Launch the Connect Portal for Salesforce in your app
37
+ paragon.connect('salesforce');
15
38
  ```
16
39
 
17
- ## Test
40
+ ## Documentation
18
41
 
42
+ To start using the Paragon SDK, you will need to [sign up and register for an account](https://dashboard.useparagon.com/signup).
19
43
 
44
+ For details on getting started and a reference on all available SDK functions, please see [our documentation](https://docs.useparagon.com/getting-started/introduction).
@@ -0,0 +1,189 @@
1
+ import { OauthCallbackResponse } from './entities/credential.interface';
2
+ import { IIntegrationMetadata } from './entities/integration.interface';
3
+ import { PersonaMeta } from './entities/persona.interface';
4
+ import SDKEventEmitter from './SDKEventEmitter';
5
+ import { AuthenticateOptions, AuthenticatedConnectUser, Props as ConnectModalProps, ConnectParams, ConnectUser, EventInfo, IConnectSDK, InstallOptions, TriggerWorkflowRequest } from './types';
6
+ export declare const PARAGON_OVERFLOW_EMPTY_VALUE = "PARAGON_OVERFLOW_EMPTY_VALUE";
7
+ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
8
+ root: HTMLIFrameElement | undefined;
9
+ private rootLoaded;
10
+ private projectId;
11
+ private modalState;
12
+ private userState;
13
+ private loadedConfigs;
14
+ private loadedIntegrations;
15
+ private endUserIntegrationConfig;
16
+ private environments;
17
+ private project;
18
+ /**
19
+ * map b/w integration key name to integration metadata
20
+ */
21
+ private metadata;
22
+ /**
23
+ * cache service
24
+ */
25
+ private cachedApiResponse;
26
+ /**
27
+ * in order to not call multiple same GET request at same time
28
+ * we are storing {key -> promise} map
29
+ */
30
+ private keyToRequestPromiseMap;
31
+ /**
32
+ * this will store the original overflow style of body
33
+ * we are using PARAGON_OVERFLOW_EMPTY_VALUE as default
34
+ * so that we will be able to know whether style is added in body or not
35
+ */
36
+ private originalBodyOverflow;
37
+ private configs;
38
+ constructor();
39
+ /**
40
+ * post message handler
41
+ * @param event
42
+ */
43
+ private eventMessageHandler;
44
+ private functionInvocationHandler;
45
+ private createReactRoot;
46
+ private validateAction;
47
+ private bootstrapSDKState;
48
+ setModalState(statePartial: Partial<ConnectModalProps>): void;
49
+ /**
50
+ * Loads previous SDK state saved in localStorage.
51
+ *
52
+ * **Warning:** This favors stored to current state. This should typically be called in
53
+ * unauthenticated contexts, as a fallback.
54
+ */
55
+ private loadState;
56
+ /**
57
+ * Saves the current SDK state into localStorage, if available.
58
+ */
59
+ private saveState;
60
+ /**
61
+ * Clears the current SDK state from localStorage, if available.
62
+ */
63
+ private clearState;
64
+ private render;
65
+ /**
66
+ * this will update container style
67
+ * @param param0
68
+ * @returns
69
+ */
70
+ updateContainerStyle({ isModalShown }: {
71
+ isModalShown: boolean;
72
+ }): void;
73
+ /**
74
+ * Authenticate your end user into the Paragon Connect SDK.
75
+ *
76
+ * @param projectId Your Paragon project ID.
77
+ * @param token A JWT signed by your App Server. The JWT should include a user ID and a
78
+ * session expiration time.
79
+ */
80
+ authenticate(projectId: string, token: string, options?: AuthenticateOptions): Promise<void>;
81
+ /**
82
+ * Get the Paragon authentication and integration state of your end user.
83
+ */
84
+ getUser(): ConnectUser;
85
+ updateAuthenticatedUser(statePartial: Partial<AuthenticatedConnectUser>): void;
86
+ /**
87
+ * Logout the currently authenticated end user from the Paragon SDK.
88
+ */
89
+ logout(): void;
90
+ /**
91
+ * Display the Paragon Connect modal
92
+ */
93
+ connect(action: string, params?: ConnectParams): Promise<void>;
94
+ _oauthCallback(oauthResponse: OauthCallbackResponse, credentialId?: string): Promise<void>;
95
+ _oauthErrorCallback(errorMessage: string | object): Promise<void>;
96
+ /**
97
+ * Send a Connect API request. Automatically handles authorization and errors.
98
+ *
99
+ * @param path The path of the request, including the leading slash, i.e. `/sdk/actions`
100
+ * @param init Options for the request, excluding headers (automatically added).
101
+ * @param prefixWithProjectPath Defaults to true. Prepends /projects/${this.projectId}` to the
102
+ * path.
103
+ */
104
+ sendConnectRequest<TResponse>(path: string, init?: RequestInit & {
105
+ cacheResult?: boolean;
106
+ }, prefixWithProjectPath?: boolean): Promise<TResponse | undefined>;
107
+ private sendRequest;
108
+ /**
109
+ * Sends a proxy request to an action
110
+ * @param action
111
+ * @param path
112
+ * @param init
113
+ * @returns api request response
114
+ */
115
+ request<TResponse>(action: string, path: string, init: {
116
+ method: RequestInit['method'];
117
+ body: RequestInit['body'] | object;
118
+ headers: RequestInit['headers'];
119
+ }): Promise<TResponse | undefined>;
120
+ event(name: string, payload: Record<string, unknown>): Promise<void>;
121
+ /**
122
+ * @summary this will be called to close the modal
123
+ * @param forceClose is set when modal is closed by cross btn
124
+ * @returns
125
+ */
126
+ onClose(forceClose?: boolean): void;
127
+ /**
128
+ * @summary this will be called when modal will be visible
129
+ */
130
+ onOpen(): void;
131
+ /**
132
+ * this is shared in ConnectUserContext
133
+ * so that event can be trigger from components
134
+ * @param eventInfo
135
+ */
136
+ triggerSDKEvent(eventInfo: EventInfo): void;
137
+ /**
138
+ * get single or all metadata info for integrations
139
+ * @param integrationKeyName
140
+ * @returns
141
+ */
142
+ getIntegrationMetadata(): IIntegrationMetadata[];
143
+ getIntegrationMetadata(integrationKeyName: string): IIntegrationMetadata;
144
+ /**
145
+ * trigger connect endpoint trigger workflow
146
+ * @param workflowId
147
+ * @param payload
148
+ */
149
+ workflow(workflowId: string, { body, query, headers }?: TriggerWorkflowRequest): Promise<object | undefined>;
150
+ /**
151
+ * for programmatically installing an integration
152
+ */
153
+ installIntegration(action: string, params?: Partial<Omit<InstallOptions, 'isApiInstallation'>>): Promise<void>;
154
+ /**
155
+ * gates headless feature to pro and enterprise users
156
+ */
157
+ ensureHeadlessIsSupported(): void;
158
+ uninstallIntegration(action: string): Promise<void>;
159
+ disableWorkflow(workflowId: string): Promise<void>;
160
+ private updateLocalState;
161
+ /**
162
+ * also returns false if unable to find workflow in configured workflow property of any integration
163
+ */
164
+ private isWorkflowEnabled;
165
+ /**
166
+ * gets the user data from api `/sdk/me`
167
+ */
168
+ private fetchUserData;
169
+ /**
170
+ * Gets the integrations from api `/sdk/integrations`
171
+ * Required this another request for integrations, as `/sdk/me` provides only minimal data for integrations
172
+ * we also need integration config and other credentials info which is not included in `sdk/me`
173
+ */
174
+ private fetchIntegrations;
175
+ /**
176
+ * Updates internal state where integration information may be used.
177
+ */
178
+ private updateIntegrations;
179
+ setUserMetadata(meta: PersonaMeta): Promise<AuthenticatedConnectUser>;
180
+ getIntegrationConfigs(actionNames: string[]): Promise<void>;
181
+ /**
182
+ * @param {host: string;} domain
183
+ * sets the domain for making http service request
184
+ * example: configureGlobal({host: 'myDomain.com'}) would set service urls as `https://service.myDomain.com`
185
+ */
186
+ configureGlobal(param: {
187
+ host: string;
188
+ }): void;
189
+ }
@@ -0,0 +1,56 @@
1
+ import { AuthenticatedConnectUser, CallbackMap, EventInfo, ListenerFunction, SDK_EVENT } from './types';
2
+ export default class SDKEventEmitter {
3
+ private eventListenersMap;
4
+ private integrationStateCallbacks;
5
+ /**
6
+ * this will add listener to event listeners list
7
+ * @param eventName
8
+ * @returns function to unsubscribe current listener
9
+ */
10
+ subscribe(eventName: SDK_EVENT, listener: ListenerFunction): () => boolean;
11
+ /**
12
+ * this method add bind callbackMap to integration type
13
+ * and emit event for particular integration
14
+ * @param integrationType
15
+ * @param callbackMap
16
+ */
17
+ subscribeToIntegration(integrationType: string, callbackMap: CallbackMap): void;
18
+ /**
19
+ * this method removes listener from evenListenerMap
20
+ * @param eventName
21
+ * @param listener
22
+ * @returns true if successfully unsubscribed else false
23
+ */
24
+ unsubscribe(eventName: SDK_EVENT, listener: ListenerFunction): boolean;
25
+ /**
26
+ * check if event is valid paragon sdk event
27
+ * @param eventName
28
+ */
29
+ private assertEventType;
30
+ /**
31
+ * this method call attached listeners with payload for eventName type
32
+ * @param eventName
33
+ * @param eventPayload
34
+ */
35
+ private emitSafe;
36
+ /**
37
+ * this method will call errorCallback for integration
38
+ * @param error
39
+ * @param integrationType
40
+ */
41
+ emitError(error: Error, integrationType: string): void;
42
+ /**
43
+ * this will call callBack function inside try-catch block
44
+ * @param integrationType
45
+ * @param callbackType
46
+ * @param payload
47
+ */
48
+ private invokeCallbackSafe;
49
+ /**
50
+ * this will invoke emitSafe method with proper payload
51
+ * @param event
52
+ * @param userState
53
+ * @param modalState
54
+ */
55
+ triggerEvent({ type, integrationId, integrationType, workflowId, workflowStateChange }: EventInfo, userState: AuthenticatedConnectUser): void;
56
+ }
@@ -0,0 +1 @@
1
+ export declare const ACTION_CUSTOM = "custom";
@@ -0,0 +1,5 @@
1
+ export interface IBaseEntity {
2
+ id: string;
3
+ dateCreated: Date;
4
+ dateUpdated: Date;
5
+ }
@@ -0,0 +1,42 @@
1
+ import { ConnectCredentialConfig } from '../types/connect';
2
+ import { IConnectIntegration } from './integration.interface';
3
+ import { IPersona } from './persona.interface';
4
+ import { IProject } from './project.interface';
5
+ export interface IConnectCredential {
6
+ id: string;
7
+ projectId: string;
8
+ integrationId: string;
9
+ config: ConnectCredentialConfig;
10
+ personaId: string;
11
+ isPreviewCredential: boolean;
12
+ /**
13
+ * @property providerId : this property stores user's identifiers in third party database e.g. Shopify
14
+ */
15
+ providerId: string;
16
+ dateCreated: Date;
17
+ dateUpdated: Date;
18
+ dateValidUntil?: Date;
19
+ dateRefreshed: Date;
20
+ status: CredentialStatus;
21
+ /**
22
+ * miscellaneous integration provider data received along with access_token/userinfo
23
+ */
24
+ providerData: ConnectCredentialProviderData;
25
+ /**
26
+ * count how many times credential failed to refresh
27
+ */
28
+ refreshFailureCount: number;
29
+ /**
30
+ * track refreshing status
31
+ */
32
+ isRefreshing: boolean;
33
+ project?: IProject;
34
+ integration?: IConnectIntegration;
35
+ persona?: IPersona;
36
+ }
37
+ export type ConnectCredentialProviderData = Record<string, string | number | boolean>;
38
+ export declare enum CredentialStatus {
39
+ PENDING = "PENDING",
40
+ INVALID = "INVALID",
41
+ VALID = "VALID"
42
+ }
@@ -0,0 +1,15 @@
1
+ export declare enum AuthenticationScheme {
2
+ BASIC = "basic",
3
+ OAUTH = "oauth",
4
+ OAUTH_CLIENT_CREDENTIAL = "oauth_client_credential",
5
+ SERVICE_ACCOUNT = "service_account",
6
+ OAUTH_APP = "oauth_app",
7
+ IMPERSONATED_APP = "impersonated_app"
8
+ }
9
+ /**
10
+ * oauth response return from our service
11
+ */
12
+ export type OauthCallbackResponse = {
13
+ integrationId: string;
14
+ payload: Record<string, string | number | boolean | any>;
15
+ };
@@ -0,0 +1,60 @@
1
+ import { IntegrationConnectInput } from '../types/action';
2
+ import { DataType, TokenizedSource } from '../types/resolvers';
3
+ import { IBaseEntity } from './base.entity';
4
+ import { AuthenticationScheme } from './credential.interface';
5
+ import { IConnectIntegration } from './integration.interface';
6
+ import { IProject } from './project.interface';
7
+ import { RequestAuthorization } from './steps';
8
+ export interface ICustomIntegration extends IBaseEntity {
9
+ /**
10
+ * the project that authored and maintains this custom integration.
11
+ */
12
+ project: IProject;
13
+ /**
14
+ * The ID of the project that authored and maintains this custom integration.
15
+ */
16
+ projectId: string;
17
+ name?: string;
18
+ /**
19
+ * a slug generated from the name of the custom integration (e.g. `custom.github`)
20
+ * it's stripped of non-alphanumeric characters and lowercased
21
+ * they're unique between projects
22
+ */
23
+ readonly slug?: string;
24
+ /**
25
+ * The CDN path of the custom integration's SVG-format icon file.
26
+ */
27
+ icon?: string;
28
+ /**
29
+ * Instances of this custom integration configured for a particular project.
30
+ *
31
+ * Currently, we only expect that one integration will be associated with a custom integration
32
+ * at a time. However, this is subject to change and should not be treated as an invariant in
33
+ * code (hence the array typing).
34
+ */
35
+ integrations: IConnectIntegration[];
36
+ /**
37
+ * Basic (API keys) and OAuth 2.0 authentication types are supported for custom integrations.
38
+ */
39
+ authenticationType?: AuthenticationScheme;
40
+ inputFields: IntegrationConnectInput[];
41
+ oauthAuthorizationUrl?: TokenizedSource<DataType.STRING>;
42
+ oauthAccessTokenUrl?: TokenizedSource<DataType.STRING>;
43
+ oauthScopes?: string;
44
+ oauthIncludeClientAuthorizationHeader?: boolean;
45
+ usePKCEInCodeExchange: boolean;
46
+ apiBaseUrl?: TokenizedSource<DataType.STRING>;
47
+ testEndpointPath?: TokenizedSource<DataType.STRING>;
48
+ apiAuthorization: RequestAuthorization;
49
+ isPublished: boolean;
50
+ }
51
+ export interface IPublishedCustomIntegration extends ICustomIntegration {
52
+ isPublished: true;
53
+ name: string;
54
+ readonly slug: string;
55
+ icon: string;
56
+ authenticationType: AuthenticationScheme;
57
+ oauthClientId: string;
58
+ oauthScopes: string;
59
+ }
60
+ export declare function generateSlugForIntegration(customIntegration: ICustomIntegration): string | undefined;
@@ -0,0 +1,33 @@
1
+ import { ICustomIntegration } from './customIntegration.interface';
2
+ import { IConnectIntegrationConfig } from './integrationConfig.interface';
3
+ import { IWorkflowBase } from './workflow.interface';
4
+ export type IConnectIntegration = {
5
+ id: string;
6
+ dateCreated: Date;
7
+ dateUpdated: Date;
8
+ projectId: string;
9
+ configs: IConnectIntegrationConfig[];
10
+ workflows: IWorkflowBase[];
11
+ type: string;
12
+ isActive: boolean;
13
+ customIntegrationId?: string;
14
+ customIntegration?: ICustomIntegration;
15
+ };
16
+ export interface IConnectIntegrationWithCredentialInfo extends IConnectIntegration {
17
+ hasCredential: boolean;
18
+ connectedUserLimitOnDevCred: number;
19
+ connectedUserLimitReached: boolean;
20
+ }
21
+ export interface IIntegrationMetadata {
22
+ type: string;
23
+ name: string;
24
+ icon: string;
25
+ brandColor: string;
26
+ }
27
+ export declare function getIntegrationTypeName(integration: IConnectIntegration): string | undefined;
28
+ export declare function isCustomIntegrationTypeName(type: string): boolean;
29
+ export interface IConnectIntegrationWithCredentialInfo extends IConnectIntegration {
30
+ hasCredential: boolean;
31
+ connectedUserLimitOnDevCred: number;
32
+ connectedUserLimitReached: boolean;
33
+ }
@@ -0,0 +1,9 @@
1
+ import { ModalConfig } from '../types/connect';
2
+ import { IBaseEntity } from './base.entity';
3
+ import { IConnectIntegration } from './integration.interface';
4
+ export interface IConnectIntegrationConfig extends IBaseEntity {
5
+ id: string;
6
+ integration: IConnectIntegration;
7
+ integrationId: string;
8
+ values: ModalConfig;
9
+ }
@@ -1,8 +1,6 @@
1
- import { ITeam } from "./team.interface";
2
-
1
+ import { ITeam } from './team.interface';
3
2
  export interface ILicense {
4
3
  id: string;
5
4
  team: ITeam;
6
5
  active: boolean;
7
- }
8
-
6
+ }
@@ -0,0 +1,34 @@
1
+ import { IBaseEntity } from './base.entity';
2
+ import { IConnectCredential } from './connectCredential.interface';
3
+ export type PersonaMeta = {
4
+ Name?: string;
5
+ Email?: string;
6
+ } & {
7
+ [key: string]: unknown;
8
+ };
9
+ export interface IPersona extends IBaseEntity {
10
+ projectId: string;
11
+ endUserId: string;
12
+ meta: PersonaMeta;
13
+ /**
14
+ * timestamp value for the latest workflow execution by persona. Will be populated
15
+ * later on by chronos
16
+ */
17
+ dateLastActive: Date;
18
+ /**
19
+ * boolean value that tells wether there are integration errors for persona.
20
+ * In a future work effort this would be populated by the chronos service.
21
+ */
22
+ hasIntegrationErrors: boolean;
23
+ /**
24
+ * boolean value that tells if persona has any failed workflows. This will be
25
+ * populated by chronos work effort later
26
+ */
27
+ hasWorkflowErrors: boolean;
28
+ /**
29
+ * boolean value . A persona may be disabled from connected users dashboard and
30
+ * will not be able to perform any activity
31
+ */
32
+ active: boolean;
33
+ connectCredentials?: IConnectCredential[];
34
+ }
@@ -0,0 +1,32 @@
1
+ import { BillingPlan, ConnectAddOn } from '../types/stripe';
2
+ import { IBaseEntity } from './base.entity';
3
+ import { ICustomIntegration } from './customIntegration.interface';
4
+ import { ITeam } from './team.interface';
5
+ import { IUserSanitized } from './user.interface';
6
+ declare enum ProjectType {
7
+ PERSONAL = "PERSONAL",
8
+ BUSINESS = "BUSINESS"
9
+ }
10
+ export interface IProject extends IBaseEntity {
11
+ title: string;
12
+ owner: IUserSanitized;
13
+ ownerId: string;
14
+ team: ITeam;
15
+ teamId: string;
16
+ billingPeriodEndAt?: Date;
17
+ completedQualification?: boolean;
18
+ projectType?: ProjectType;
19
+ projectPurpose?: string;
20
+ isConnectProject?: boolean;
21
+ customIntegrations: ICustomIntegration[];
22
+ isHidden: boolean;
23
+ }
24
+ /**
25
+ * a light version of a project sent to end users interacting with the connect sdk
26
+ */
27
+ export interface IConnectSDKProject {
28
+ id: string;
29
+ billingPlan: BillingPlan;
30
+ accessibleFeatures: ConnectAddOn[];
31
+ }
32
+ export {};
@@ -0,0 +1,30 @@
1
+ import { DataType, KeyedSource, TokenizedSource } from '../types/resolvers';
2
+ export type RequestAuthorization = NoAuthorization | BearerAuthorization | BasicAuthorization | QueryParamAuthorization | AuthHeaderAuthorization;
3
+ declare enum RequestAuthorizationType {
4
+ NONE = "none",
5
+ BEARER_TOKEN = "bearer",
6
+ BASIC = "basic",
7
+ QUERY_PARAMS = "query_params",
8
+ AUTH_HEADER = "auth_header"
9
+ }
10
+ type NoAuthorization = {
11
+ type: RequestAuthorizationType.NONE;
12
+ };
13
+ type BearerAuthorization = {
14
+ type: RequestAuthorizationType.BEARER_TOKEN;
15
+ token: TokenizedSource<DataType.STRING>;
16
+ };
17
+ type BasicAuthorization = {
18
+ type: RequestAuthorizationType.BASIC;
19
+ username: TokenizedSource<DataType.STRING>;
20
+ password: TokenizedSource<DataType.STRING>;
21
+ };
22
+ type QueryParamAuthorization = {
23
+ type: RequestAuthorizationType.QUERY_PARAMS;
24
+ params: KeyedSource<DataType.STRING>[];
25
+ };
26
+ type AuthHeaderAuthorization = {
27
+ type: RequestAuthorizationType.AUTH_HEADER;
28
+ headers: KeyedSource<DataType.STRING>[];
29
+ };
30
+ export {};
@@ -0,0 +1,19 @@
1
+ import { IBaseEntity } from './base.entity';
2
+ import { ILicense } from './license.interface';
3
+ export interface ITeam extends IBaseEntity {
4
+ name: string;
5
+ website?: string;
6
+ licenses?: ILicense[];
7
+ organizationId: string;
8
+ }
9
+ export interface ITeamMember {
10
+ id: string;
11
+ organizationId: string;
12
+ userId?: string;
13
+ role: TeamMemberRole;
14
+ }
15
+ declare enum TeamMemberRole {
16
+ ADMIN = "ADMIN",
17
+ MEMBER = "MEMBER"
18
+ }
19
+ export {};
@@ -0,0 +1,23 @@
1
+ import { IBaseEntity } from './base.entity';
2
+ import { ITeamMember } from './team.interface';
3
+ export declare enum OnboardingStage {
4
+ ADD_TEAM_DETAILS = "ADD_TEAM_DETAILS",
5
+ PROMPT_TUTORIAL = "PROMPT_TUTORIAL",
6
+ IN_TUTORIAL = "IN_TUTORIAL",
7
+ COMPLETED = "COMPLETED",
8
+ COMPLETED_SKIPPED_TUTORIAL = "COMPLETED_SKIPPED_TUTORIAL"
9
+ }
10
+ export interface IUser extends IBaseEntity {
11
+ firstName: string;
12
+ middleName: string;
13
+ lastName: string;
14
+ email: string;
15
+ password: string;
16
+ active: boolean;
17
+ teamMembers: ITeamMember[];
18
+ onboardingStage: OnboardingStage;
19
+ admin: boolean;
20
+ }
21
+ export interface IUserSanitized extends Omit<IUser, 'admin' | 'password'> {
22
+ impersonated?: boolean;
23
+ }
@@ -0,0 +1,11 @@
1
+ import { IBaseEntity } from './base.entity';
2
+ import { IProject } from './project.interface';
3
+ export interface IWorkflow extends IBaseEntity {
4
+ description: string;
5
+ projectId: string;
6
+ project: IProject;
7
+ teamId?: string;
8
+ isOnboardingWorkflow?: boolean;
9
+ integrationId?: string;
10
+ }
11
+ export type IWorkflowBase = Omit<IWorkflow, 'project' | 'projectId'>;
@@ -0,0 +1,18 @@
1
+ import ConnectSDK from '../ConnectSDK';
2
+ import { IConnectSDKProject } from '../entities/project.interface';
3
+ import { ConnectSdkEnvironments } from '../server.types';
4
+ import { AuthenticatedConnectUser } from '../types/connect';
5
+ import { ConnectUser, EventInfo, UserProvidedIntegrationConfig } from '../types/sdk';
6
+ export type IConnectUserContext = {
7
+ user: ConnectUser;
8
+ projectId?: string;
9
+ updateUser?: (user: Partial<AuthenticatedConnectUser>) => void;
10
+ sendAuthenticatedRequest: ConnectSDK['sendConnectRequest'];
11
+ environments: ConnectSdkEnvironments;
12
+ project?: IConnectSDKProject;
13
+ triggerSDKEvent?: (eventInfo: EventInfo) => void;
14
+ /**
15
+ * Ender user supplied integration config
16
+ */
17
+ endUserIntegrationConfig?: UserProvidedIntegrationConfig;
18
+ };