@useparagon/connect 0.0.16-canary.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.
- package/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/src/ConnectSDK.d.ts +245 -0
- package/dist/src/SDKEventEmitter.d.ts +56 -0
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/entities/base.entity.d.ts +5 -0
- package/dist/src/entities/connectCredential.interface.d.ts +36 -0
- package/dist/src/entities/credential.interface.d.ts +15 -0
- package/dist/src/entities/customIntegration.interface.d.ts +60 -0
- package/dist/src/entities/integration.interface.d.ts +45 -0
- package/dist/src/entities/integrationConfig.interface.d.ts +9 -0
- package/dist/src/entities/license.interface.d.ts +6 -0
- package/dist/src/entities/persona.interface.d.ts +34 -0
- package/dist/src/entities/project.interface.d.ts +32 -0
- package/dist/src/entities/steps.d.ts +30 -0
- package/dist/src/entities/team.interface.d.ts +19 -0
- package/dist/src/entities/user.interface.d.ts +23 -0
- package/dist/src/entities/workflow.interface.d.ts +11 -0
- package/dist/src/file-picker/integrations/googledrive.d.ts +24 -0
- package/dist/src/file-picker/integrations/index.d.ts +5 -0
- package/dist/src/file-picker/types/baseFilePicker.d.ts +32 -0
- package/dist/src/file-picker/types/externalFilePicker.d.ts +9 -0
- package/dist/src/file-picker/types/index.d.ts +1 -0
- package/dist/src/helpers/ConnectUserContext.d.ts +18 -0
- package/dist/src/helpers/index.d.ts +29 -0
- package/dist/src/helpers/oauth.d.ts +20 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.LICENSE.txt +14 -0
- package/dist/src/server.types.d.ts +14 -0
- package/dist/src/types/action.d.ts +266 -0
- package/dist/src/types/billing.d.ts +2 -0
- package/dist/src/types/connect.d.ts +213 -0
- package/dist/src/types/connectModal.d.ts +35 -0
- package/dist/src/types/environment.d.ts +16 -0
- package/dist/src/types/execution.d.ts +5 -0
- package/dist/src/types/index.d.ts +9 -0
- package/dist/src/types/resolvers.d.ts +297 -0
- package/dist/src/types/sdk.d.ts +302 -0
- package/dist/src/types/stripe.d.ts +23 -0
- package/dist/src/utils/connect.d.ts +13 -0
- package/dist/src/utils/crypto.d.ts +7 -0
- package/dist/src/utils/generic.d.ts +30 -0
- package/dist/src/utils/http.d.ts +57 -0
- package/dist/src/utils/throttle.d.ts +118 -0
- package/package.json +103 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Paragon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<p align="center">
|
|
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
|
+
</p>
|
|
4
|
+
|
|
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:
|
|
24
|
+
|
|
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)
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { paragon } from '@useparagon/connect';
|
|
32
|
+
|
|
33
|
+
// Authenticate your user with the SDK
|
|
34
|
+
await paragon.authenticate(projectId, paragonUserToken);
|
|
35
|
+
|
|
36
|
+
// Launch the Connect Portal for Salesforce in your app
|
|
37
|
+
paragon.connect('salesforce');
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Documentation
|
|
41
|
+
|
|
42
|
+
To start using the Paragon SDK, you will need to [sign up and register for an account](https://dashboard.useparagon.com/signup).
|
|
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,245 @@
|
|
|
1
|
+
import { IConnectCredential } from './entities/connectCredential.interface';
|
|
2
|
+
import { OauthCallbackResponse } from './entities/credential.interface';
|
|
3
|
+
import { IConnectIntegrationWithCredentialInfo, IIntegrationMetadata } from './entities/integration.interface';
|
|
4
|
+
import { PersonaMeta } from './entities/persona.interface';
|
|
5
|
+
import SDKEventEmitter from './SDKEventEmitter';
|
|
6
|
+
import { ConnectSdkEnvironments } from './server.types';
|
|
7
|
+
import { AuthenticateOptions, AuthenticatedConnectUser, CompleteInstallOptions, Props as ConnectModalProps, ConnectParams, ConnectUser, DisableWorkflowOptions, EventInfo, GetIntegrationAccountOptions, IConnectSDK, InstallIntegrationOptions, TriggerWorkflowRequest, UninstallOptions } from './types';
|
|
8
|
+
export declare const PARAGON_OVERFLOW_EMPTY_VALUE = "PARAGON_OVERFLOW_EMPTY_VALUE";
|
|
9
|
+
export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
|
|
10
|
+
root: HTMLIFrameElement | undefined;
|
|
11
|
+
private rootLoaded;
|
|
12
|
+
/**
|
|
13
|
+
* sometime DOMContentLoaded event firing twice
|
|
14
|
+
* so it was creating two iframes see PARA-8749
|
|
15
|
+
*/
|
|
16
|
+
private rootElementCreated;
|
|
17
|
+
private projectId;
|
|
18
|
+
private integrationToBeEnabled;
|
|
19
|
+
private modalState;
|
|
20
|
+
private userState;
|
|
21
|
+
private loadedConfigs;
|
|
22
|
+
private loadedIntegrations;
|
|
23
|
+
private endUserIntegrationConfig;
|
|
24
|
+
private environments;
|
|
25
|
+
private project;
|
|
26
|
+
/**
|
|
27
|
+
* map b/w integration key name to integration metadata
|
|
28
|
+
*/
|
|
29
|
+
private metadata;
|
|
30
|
+
/**
|
|
31
|
+
* cache service
|
|
32
|
+
*/
|
|
33
|
+
private cachedApiResponse;
|
|
34
|
+
/**
|
|
35
|
+
* in order to not call multiple same GET request at same time
|
|
36
|
+
* we are storing {key -> promise} map
|
|
37
|
+
*/
|
|
38
|
+
private keyToRequestPromiseMap;
|
|
39
|
+
/**
|
|
40
|
+
* this will store the original overflow style of body
|
|
41
|
+
* we are using PARAGON_OVERFLOW_EMPTY_VALUE as default
|
|
42
|
+
* so that we will be able to know whether style is added in body or not
|
|
43
|
+
*/
|
|
44
|
+
private originalBodyOverflow;
|
|
45
|
+
constructor(environments?: ConnectSdkEnvironments);
|
|
46
|
+
/**
|
|
47
|
+
* post message handler
|
|
48
|
+
* @param event
|
|
49
|
+
*/
|
|
50
|
+
private eventMessageHandler;
|
|
51
|
+
private functionInvocationHandler;
|
|
52
|
+
private createReactRoot;
|
|
53
|
+
/**
|
|
54
|
+
* checks
|
|
55
|
+
* - if integartion name is valid
|
|
56
|
+
* - if integration is setup in project
|
|
57
|
+
* - if integration is active in project
|
|
58
|
+
* throws error if any of these is not met
|
|
59
|
+
* @param action
|
|
60
|
+
* @param validateIsEnabled boolean
|
|
61
|
+
*/
|
|
62
|
+
validateAction(action: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* checks if the integration is installed.
|
|
65
|
+
* Assumes that the user is authenticated
|
|
66
|
+
* @param action
|
|
67
|
+
* @param userState
|
|
68
|
+
* @returns boolean value
|
|
69
|
+
*/
|
|
70
|
+
private isAlreadyInstalled;
|
|
71
|
+
private bootstrapSDKState;
|
|
72
|
+
setModalState(statePartial: Partial<ConnectModalProps>): void;
|
|
73
|
+
/**
|
|
74
|
+
* Loads previous SDK state saved in localStorage.
|
|
75
|
+
*
|
|
76
|
+
* **Warning:** This favors stored to current state. This should typically be called in
|
|
77
|
+
* unauthenticated contexts, as a fallback.
|
|
78
|
+
*/
|
|
79
|
+
private loadState;
|
|
80
|
+
/**
|
|
81
|
+
* Saves the current SDK state into localStorage, if available.
|
|
82
|
+
*/
|
|
83
|
+
private saveState;
|
|
84
|
+
/**
|
|
85
|
+
* Clears the current SDK state from localStorage, if available.
|
|
86
|
+
*/
|
|
87
|
+
private clearState;
|
|
88
|
+
private render;
|
|
89
|
+
/**
|
|
90
|
+
* this will update container style
|
|
91
|
+
* @param param0
|
|
92
|
+
* @returns
|
|
93
|
+
*/
|
|
94
|
+
updateContainerStyle({ isModalShown }: {
|
|
95
|
+
isModalShown: boolean;
|
|
96
|
+
}): void;
|
|
97
|
+
/**
|
|
98
|
+
* Authenticate your end user into the Paragon Connect SDK.
|
|
99
|
+
*
|
|
100
|
+
* @param projectId Your Paragon project ID.
|
|
101
|
+
* @param token A JWT signed by your App Server. The JWT should include a user ID and a
|
|
102
|
+
* session expiration time.
|
|
103
|
+
*/
|
|
104
|
+
authenticate(projectId: string, token: string, options?: AuthenticateOptions): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Get the Paragon authentication and integration state of your end user.
|
|
107
|
+
*/
|
|
108
|
+
getUser(): ConnectUser;
|
|
109
|
+
updateAuthenticatedUser(statePartial: Partial<AuthenticatedConnectUser>): void;
|
|
110
|
+
/**
|
|
111
|
+
* Logout the currently authenticated end user from the Paragon SDK.
|
|
112
|
+
*/
|
|
113
|
+
logout(): void;
|
|
114
|
+
/**
|
|
115
|
+
* Display the Paragon Connect modal
|
|
116
|
+
*/
|
|
117
|
+
connect(action: string, params?: ConnectParams): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Retrieves an integration object from the loaded integrations based on the integration ID.
|
|
120
|
+
* @param integrationId The ID of the integration to retrieve.
|
|
121
|
+
* @returns The integration object if found, otherwise undefined.
|
|
122
|
+
*/
|
|
123
|
+
_getIntegration(integrationId: string): IConnectIntegrationWithCredentialInfo | undefined;
|
|
124
|
+
_oauthCallback(oauthResponse: OauthCallbackResponse, credentialId?: string): Promise<void>;
|
|
125
|
+
_oauthErrorCallback(errorMessage: string | object, event?: MessageEvent): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Send a Connect API request. Automatically handles authorization and errors.
|
|
128
|
+
*
|
|
129
|
+
* @param path The path of the request, including the leading slash, i.e. `/sdk/actions`
|
|
130
|
+
* @param init Options for the request, excluding headers (automatically added).
|
|
131
|
+
* @param prefixWithProjectPath Defaults to true. Prepends /projects/${this.projectId}` to the
|
|
132
|
+
* path.
|
|
133
|
+
*/
|
|
134
|
+
sendConnectRequest<TResponse>(path: string, init?: RequestInit & {
|
|
135
|
+
cacheResult?: boolean;
|
|
136
|
+
baseURLOverride?: string;
|
|
137
|
+
}, prefixWithProjectPath?: boolean): Promise<TResponse | undefined>;
|
|
138
|
+
private sendRequest;
|
|
139
|
+
/**
|
|
140
|
+
* Sends a proxy request to an action
|
|
141
|
+
* @param action
|
|
142
|
+
* @param path
|
|
143
|
+
* @param init
|
|
144
|
+
* @returns api request response
|
|
145
|
+
*/
|
|
146
|
+
request<TResponse>(action: string, path: string, init: {
|
|
147
|
+
selectedCredentialId?: string;
|
|
148
|
+
method: RequestInit['method'];
|
|
149
|
+
body: RequestInit['body'] | object;
|
|
150
|
+
headers: RequestInit['headers'];
|
|
151
|
+
}): Promise<TResponse | undefined>;
|
|
152
|
+
event(name: string, payload: Record<string, unknown>): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* @summary this will be called to close the modal
|
|
155
|
+
* @param forceClose is set when modal is closed by cross btn
|
|
156
|
+
* @returns
|
|
157
|
+
*/
|
|
158
|
+
onClose(forceClose?: boolean): void;
|
|
159
|
+
/**
|
|
160
|
+
* @summary this will be called when modal will be visible
|
|
161
|
+
*/
|
|
162
|
+
onOpen(): void;
|
|
163
|
+
/**
|
|
164
|
+
* this is shared in ConnectUserContext
|
|
165
|
+
* so that event can be trigger from components
|
|
166
|
+
* @param eventInfo
|
|
167
|
+
*/
|
|
168
|
+
triggerSDKEvent(eventInfo: EventInfo): void;
|
|
169
|
+
/**
|
|
170
|
+
* get single or all metadata info for integrations
|
|
171
|
+
* @param integrationKey
|
|
172
|
+
* @returns
|
|
173
|
+
*/
|
|
174
|
+
getIntegrationMetadata(): IIntegrationMetadata[];
|
|
175
|
+
getIntegrationMetadata(integrationKey: string): IIntegrationMetadata;
|
|
176
|
+
/**
|
|
177
|
+
* trigger connect endpoint trigger workflow
|
|
178
|
+
* @param workflowId
|
|
179
|
+
* @param payload
|
|
180
|
+
*/
|
|
181
|
+
workflow(workflowId: string, { selectedCredentialId, body, query, headers }?: TriggerWorkflowRequest): Promise<object | undefined>;
|
|
182
|
+
/**
|
|
183
|
+
* for programmatically installing an integration
|
|
184
|
+
*/
|
|
185
|
+
installIntegration(action: string, params?: InstallIntegrationOptions): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* gates headless feature to pro and enterprise users
|
|
188
|
+
*/
|
|
189
|
+
ensureHeadlessIsSupported(): void;
|
|
190
|
+
uninstallIntegration(action: string, options?: UninstallOptions): Promise<void>;
|
|
191
|
+
disableWorkflow(workflowId: string, options?: DisableWorkflowOptions): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* Get account details by integration type. To get accountAuth, includeAccountAuth should be true in options.
|
|
194
|
+
* Note that accountAuth is allowed for only some of the integrations.
|
|
195
|
+
*/
|
|
196
|
+
getIntegrationAccount(integrationType: string, options?: GetIntegrationAccountOptions): Promise<IConnectIntegrationWithCredentialInfo>;
|
|
197
|
+
private getIntegrationForWorkflow;
|
|
198
|
+
private updateLocalState;
|
|
199
|
+
/**
|
|
200
|
+
* also returns false if unable to find workflow in configured workflow property of any integration
|
|
201
|
+
*/
|
|
202
|
+
private isWorkflowEnabled;
|
|
203
|
+
/**
|
|
204
|
+
* gets the user data from api `/sdk/me`
|
|
205
|
+
*/
|
|
206
|
+
private fetchUserData;
|
|
207
|
+
/**
|
|
208
|
+
* Gets the integrations from api `/sdk/integrations`
|
|
209
|
+
* Required this another request for integrations, as `/sdk/me` provides only minimal data for integrations
|
|
210
|
+
* we also need integration config and other credentials info which is not included in `sdk/me`
|
|
211
|
+
*/
|
|
212
|
+
private fetchIntegrations;
|
|
213
|
+
/**
|
|
214
|
+
* Updates internal state where integration information may be used.
|
|
215
|
+
*/
|
|
216
|
+
private updateIntegrations;
|
|
217
|
+
setUserMetadata(meta: PersonaMeta): Promise<AuthenticatedConnectUser>;
|
|
218
|
+
/**
|
|
219
|
+
* @param param
|
|
220
|
+
* sets the domain for making http service request
|
|
221
|
+
* example: `configureGlobal({host: 'myDomain.com'});` would set service urls as `https://service.myDomain.com`
|
|
222
|
+
*/
|
|
223
|
+
configureGlobal(param: {
|
|
224
|
+
host: string;
|
|
225
|
+
envPrefix?: string;
|
|
226
|
+
}): void;
|
|
227
|
+
/**
|
|
228
|
+
* some integration required flow in which user recieve authorization code
|
|
229
|
+
* from marketplace oauth flow , so needed this method see PARA-8385
|
|
230
|
+
*/
|
|
231
|
+
completeInstall(action: string, options: CompleteInstallOptions): Promise<void>;
|
|
232
|
+
/**
|
|
233
|
+
* update credential data in integration
|
|
234
|
+
* @param newCredential
|
|
235
|
+
* @param integration
|
|
236
|
+
*/
|
|
237
|
+
private updateCredentialData;
|
|
238
|
+
/**
|
|
239
|
+
* create resource connection
|
|
240
|
+
* @param resourceName
|
|
241
|
+
* @param payload
|
|
242
|
+
* @returns
|
|
243
|
+
*/
|
|
244
|
+
connectAction(resourceName: string, payload: Record<string, unknown>): Promise<IConnectCredential>;
|
|
245
|
+
}
|
|
@@ -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,36 @@
|
|
|
1
|
+
import { ConnectCredentialConfig } from '../types/connect';
|
|
2
|
+
export interface IConnectCredential {
|
|
3
|
+
id: string;
|
|
4
|
+
projectId: string;
|
|
5
|
+
integrationId: string;
|
|
6
|
+
config: ConnectCredentialConfig;
|
|
7
|
+
personaId: string;
|
|
8
|
+
isPreviewCredential: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* @property providerId : this property stores user's identifiers in third party database e.g. Shopify
|
|
11
|
+
*/
|
|
12
|
+
providerId: string;
|
|
13
|
+
dateCreated: Date;
|
|
14
|
+
dateUpdated: Date;
|
|
15
|
+
dateValidUntil?: Date;
|
|
16
|
+
dateRefreshed: Date;
|
|
17
|
+
status: CredentialStatus;
|
|
18
|
+
/**
|
|
19
|
+
* miscellaneous integration provider data received along with access_token/userinfo
|
|
20
|
+
*/
|
|
21
|
+
providerData: ConnectCredentialProviderData;
|
|
22
|
+
/**
|
|
23
|
+
* count how many times credential failed to refresh
|
|
24
|
+
*/
|
|
25
|
+
refreshFailureCount: number;
|
|
26
|
+
/**
|
|
27
|
+
* accountAuth contains the decrypted oauth access token. This property will only be available for some of integrations
|
|
28
|
+
*/
|
|
29
|
+
accountAuth?: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
export type ConnectCredentialProviderData = Record<string, string | number | boolean>;
|
|
32
|
+
export declare enum CredentialStatus {
|
|
33
|
+
PENDING = "PENDING",
|
|
34
|
+
INVALID = "INVALID",
|
|
35
|
+
VALID = "VALID"
|
|
36
|
+
}
|
|
@@ -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,45 @@
|
|
|
1
|
+
import { SDKIntegrationConfig } from '../types/connect';
|
|
2
|
+
import { ICustomIntegration } from './customIntegration.interface';
|
|
3
|
+
import { IConnectIntegrationConfig } from './integrationConfig.interface';
|
|
4
|
+
import { IWorkflowBase } from './workflow.interface';
|
|
5
|
+
export type IConnectIntegration = {
|
|
6
|
+
id: string;
|
|
7
|
+
dateCreated: Date;
|
|
8
|
+
dateUpdated: Date;
|
|
9
|
+
projectId: string;
|
|
10
|
+
configs: IConnectIntegrationConfig[];
|
|
11
|
+
workflows: IWorkflowBase[];
|
|
12
|
+
type: string;
|
|
13
|
+
isActive: boolean;
|
|
14
|
+
customIntegrationId?: string;
|
|
15
|
+
customIntegration?: ICustomIntegration;
|
|
16
|
+
};
|
|
17
|
+
export interface IConnectIntegrationWithCredentialInfo extends IConnectIntegration {
|
|
18
|
+
hasCredential: boolean;
|
|
19
|
+
connectedUserLimitOnDevCred: number;
|
|
20
|
+
connectedUserLimitReached: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface IIntegrationMetadata {
|
|
23
|
+
type: string;
|
|
24
|
+
name: string;
|
|
25
|
+
icon: string;
|
|
26
|
+
brandColor: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function getIntegrationTypeName(integration: IConnectIntegration): string | undefined;
|
|
29
|
+
export declare function isCustomIntegrationTypeName(type: string): boolean;
|
|
30
|
+
export interface IConnectIntegrationWithCredentialInfo extends IConnectIntegration {
|
|
31
|
+
hasCredential: boolean;
|
|
32
|
+
connectedUserLimitOnDevCred: number;
|
|
33
|
+
connectedUserLimitReached: boolean;
|
|
34
|
+
needPreOauthInputs: boolean;
|
|
35
|
+
name: string;
|
|
36
|
+
brandColor: string;
|
|
37
|
+
/**
|
|
38
|
+
* accountAuth contains the decrypted oauth access token. This property will only be available for some of integrations
|
|
39
|
+
*/
|
|
40
|
+
accountAuth?: Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* sdkIntegrationConfig on a integration is available only for those which are active
|
|
43
|
+
*/
|
|
44
|
+
sdkIntegrationConfig?: SDKIntegrationConfig | null;
|
|
45
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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 {};
|