conductor-node 10.1.0 → 10.3.0
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/README.md +4 -4
- package/dist/package.json +1 -1
- package/dist/src/Client.d.ts +5 -1
- package/dist/src/Client.js +3 -0
- package/dist/src/integrations/BaseIntegration.d.ts +6 -1
- package/dist/src/integrations/BaseIntegration.js +10 -2
- package/dist/src/integrations/qbd/QbdIntegration.d.ts +167 -167
- package/dist/src/integrations/qbd/QbdIntegration.js +176 -169
- package/dist/src/resources/EndUsersResource.d.ts +41 -0
- package/dist/src/resources/EndUsersResource.js +31 -0
- package/dist/src/resources/IntegrationConnectionAuthSessionsResource.d.ts +50 -0
- package/dist/src/resources/IntegrationConnectionAuthSessionsResource.js +26 -0
- package/dist/src/resources/IntegrationConnectionsResource.d.ts +46 -24
- package/dist/src/resources/IntegrationConnectionsResource.js +7 -19
- package/dist/src/utils/error.d.ts +8 -1
- package/dist/src/utils/error.js +15 -2
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import BaseResource from "../resources/BaseResource";
|
|
2
|
+
export interface EndUser {
|
|
3
|
+
/**
|
|
4
|
+
* The unique identifier for the object.
|
|
5
|
+
*/
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* Your end-user's unique ID in your database. Must be distinct from
|
|
9
|
+
* your other end-users.
|
|
10
|
+
*/
|
|
11
|
+
sourceId: string;
|
|
12
|
+
/**
|
|
13
|
+
* Your end-user's email address for identification only. No emails will be
|
|
14
|
+
* sent.
|
|
15
|
+
*/
|
|
16
|
+
email: string;
|
|
17
|
+
/**
|
|
18
|
+
* Your end-user's company name that will be shown elsewhere in Conductor.
|
|
19
|
+
*/
|
|
20
|
+
name: string;
|
|
21
|
+
/**
|
|
22
|
+
* The time at which the object was created.
|
|
23
|
+
*/
|
|
24
|
+
createdAt: string;
|
|
25
|
+
}
|
|
26
|
+
export type EndUserCreateInput = Pick<EndUser, "email" | "name" | "sourceId">;
|
|
27
|
+
export default class EndUsersResource extends BaseResource {
|
|
28
|
+
protected readonly ROUTE = "/end-users";
|
|
29
|
+
/**
|
|
30
|
+
* Returns a list of your end-users.
|
|
31
|
+
*/
|
|
32
|
+
list(): Promise<EndUser[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new end-user.
|
|
35
|
+
*/
|
|
36
|
+
create(input: EndUserCreateInput): Promise<EndUser>;
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the specified end-user.
|
|
39
|
+
*/
|
|
40
|
+
retrieve(id: EndUser["id"]): Promise<EndUser>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const BaseResource_1 = __importDefault(require("../resources/BaseResource"));
|
|
7
|
+
class EndUsersResource extends BaseResource_1.default {
|
|
8
|
+
ROUTE = "/end-users";
|
|
9
|
+
/**
|
|
10
|
+
* Returns a list of your end-users.
|
|
11
|
+
*/
|
|
12
|
+
async list() {
|
|
13
|
+
const { data } = await this.httpClient.get(this.ROUTE);
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new end-user.
|
|
18
|
+
*/
|
|
19
|
+
async create(input) {
|
|
20
|
+
const { data } = await this.httpClient.post(this.ROUTE, input);
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves the specified end-user.
|
|
25
|
+
*/
|
|
26
|
+
async retrieve(id) {
|
|
27
|
+
const { data } = await this.httpClient.get(`${this.ROUTE}/${id}`);
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = EndUsersResource;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import BaseResource from "../resources/BaseResource";
|
|
2
|
+
export interface IntegrationConnectionAuthSession {
|
|
3
|
+
/**
|
|
4
|
+
* The unique identifier for the object.
|
|
5
|
+
*/
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* The ID of the end-user for whom to create an integration-connection in this
|
|
9
|
+
* auth session.
|
|
10
|
+
*/
|
|
11
|
+
endUserId: string;
|
|
12
|
+
/**
|
|
13
|
+
* The value that you will pass to the client to launch the authentication flow.
|
|
14
|
+
*/
|
|
15
|
+
clientSecret: string;
|
|
16
|
+
/**
|
|
17
|
+
* The URL to which to redirect the end-user to return to your app after
|
|
18
|
+
* completing the authentication flow.
|
|
19
|
+
*/
|
|
20
|
+
returnUrl: string;
|
|
21
|
+
/**
|
|
22
|
+
* The time at which the auth-session expires.
|
|
23
|
+
*/
|
|
24
|
+
expiresAt: string;
|
|
25
|
+
}
|
|
26
|
+
export interface IntegrationConnectionAuthSessionCreateInput {
|
|
27
|
+
/**
|
|
28
|
+
* The ID of the end-user for whom to create an integration-connection in this
|
|
29
|
+
* auth session.
|
|
30
|
+
*/
|
|
31
|
+
endUserId: string;
|
|
32
|
+
/**
|
|
33
|
+
* The URL to which to redirect the end-user to return to your app after
|
|
34
|
+
* completing the authentication flow.
|
|
35
|
+
*/
|
|
36
|
+
returnUrl: string;
|
|
37
|
+
}
|
|
38
|
+
export default class IntegrationConnectionAuthSessionsResource extends BaseResource {
|
|
39
|
+
protected readonly ROUTE = "/integration-connection-auth-sessions";
|
|
40
|
+
/**
|
|
41
|
+
* Creates an auth `session for launch the client-side Integration Connection
|
|
42
|
+
* authentication flow. Use the returned session’s `clientSecret` to launch
|
|
43
|
+
* the auth flow using `conductor-react`.
|
|
44
|
+
*/
|
|
45
|
+
create(input: IntegrationConnectionAuthSessionCreateInput): Promise<IntegrationConnectionAuthSession>;
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves the specified integration-connection-auth-session.
|
|
48
|
+
*/
|
|
49
|
+
retrieve(id: IntegrationConnectionAuthSession["id"]): Promise<IntegrationConnectionAuthSession>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const BaseResource_1 = __importDefault(require("../resources/BaseResource"));
|
|
7
|
+
class IntegrationConnectionAuthSessionsResource extends BaseResource_1.default {
|
|
8
|
+
ROUTE = "/integration-connection-auth-sessions";
|
|
9
|
+
/**
|
|
10
|
+
* Creates an auth `session for launch the client-side Integration Connection
|
|
11
|
+
* authentication flow. Use the returned session’s `clientSecret` to launch
|
|
12
|
+
* the auth flow using `conductor-react`.
|
|
13
|
+
*/
|
|
14
|
+
async create(input) {
|
|
15
|
+
const { data } = await this.httpClient.post(this.ROUTE, input);
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves the specified integration-connection-auth-session.
|
|
20
|
+
*/
|
|
21
|
+
async retrieve(id) {
|
|
22
|
+
const { data } = await this.httpClient.get(`${this.ROUTE}/${id}`);
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = IntegrationConnectionAuthSessionsResource;
|
|
@@ -1,45 +1,67 @@
|
|
|
1
1
|
import BaseResource from "../resources/BaseResource";
|
|
2
|
+
import IntegrationConnectionAuthSessionsResource from "../resources/IntegrationConnectionAuthSessionsResource";
|
|
3
|
+
import type { AxiosInstance } from "axios";
|
|
2
4
|
export interface IntegrationConnection {
|
|
5
|
+
/**
|
|
6
|
+
* The unique identifier for the object.
|
|
7
|
+
*/
|
|
3
8
|
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* The ID of the end-user who owns this integration-connection.
|
|
11
|
+
*/
|
|
12
|
+
endUserId: string;
|
|
13
|
+
/**
|
|
14
|
+
* The identifier of the third-party platform to integrate (e.g.,
|
|
15
|
+
* "quickbooks-desktop").
|
|
16
|
+
*/
|
|
17
|
+
integrationKey: string;
|
|
18
|
+
/**
|
|
19
|
+
* The time at which the object was created.
|
|
20
|
+
*/
|
|
21
|
+
createdAt: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated We will soon remove this endpoint as we migrate to the new
|
|
25
|
+
* end-user + auth-session model.
|
|
26
|
+
*/
|
|
27
|
+
export interface IntegrationConnectionCreateOldInput {
|
|
28
|
+
/**
|
|
29
|
+
* The identifier of the third-party platform to integrate (e.g.,
|
|
30
|
+
* "quickbooks-desktop").
|
|
31
|
+
*/
|
|
4
32
|
integrationKey: string;
|
|
33
|
+
/**
|
|
34
|
+
* Your end-user's unique ID in your product's database. Must be distinct from
|
|
35
|
+
* your other connections for the same integration.
|
|
36
|
+
*/
|
|
5
37
|
endUserSourceId: string;
|
|
38
|
+
/**
|
|
39
|
+
* Your end-user's email address for identification only. No emails will be
|
|
40
|
+
* sent.
|
|
41
|
+
*/
|
|
6
42
|
endUserEmail: string;
|
|
43
|
+
/**
|
|
44
|
+
* Your end-user's company name that will be shown elsewhere in Conductor.
|
|
45
|
+
*/
|
|
7
46
|
endUserCompanyName: string;
|
|
8
47
|
}
|
|
9
|
-
export
|
|
10
|
-
export interface PingIntegrationConnectionOutput {
|
|
48
|
+
export interface IntegrationConnectionPingOutput {
|
|
11
49
|
duration: number;
|
|
12
50
|
}
|
|
13
51
|
export default class IntegrationConnectionsResource extends BaseResource {
|
|
52
|
+
readonly authSessions: IntegrationConnectionAuthSessionsResource;
|
|
14
53
|
protected readonly ROUTE = "/integration-connections";
|
|
54
|
+
constructor(httpClient: AxiosInstance);
|
|
15
55
|
/**
|
|
16
|
-
* Returns a list of all integration-connections
|
|
17
|
-
* Conductor account.
|
|
18
|
-
*
|
|
19
|
-
* @returns Your integration-connections.
|
|
56
|
+
* Returns a list of all integration-connections of all your end-users.
|
|
20
57
|
*/
|
|
21
58
|
list(): Promise<IntegrationConnection[]>;
|
|
22
59
|
/**
|
|
23
60
|
* Creates a new integration-connection.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* @param input.integrationKey The identifier of the third-party platform to
|
|
27
|
-
* integrate (e.g., "quickbooks-desktop").
|
|
28
|
-
* @param input.endUserSourceId Your end-user's unique ID in your product's
|
|
29
|
-
* database. Must be distinct from your other connections for the same
|
|
30
|
-
* integration.
|
|
31
|
-
* @param input.endUserEmail Your end-user's email address for identification
|
|
32
|
-
* only. No emails will be sent.
|
|
33
|
-
* @param input.endUserCompanyName Your end-user's company name that will be
|
|
34
|
-
* shown elsewhere in Conductor.
|
|
35
|
-
* @returns The newly created integration-connection.
|
|
36
|
-
*/
|
|
37
|
-
create(input: CreateIntegrationConnectionInput): Promise<IntegrationConnection>;
|
|
61
|
+
*/
|
|
62
|
+
create(input: IntegrationConnectionCreateOldInput): Promise<IntegrationConnection>;
|
|
38
63
|
/**
|
|
39
64
|
* Retrieves the specified integration-connection.
|
|
40
|
-
*
|
|
41
|
-
* @param id The integration-connection ID.
|
|
42
|
-
* @returns The integration-connection.
|
|
43
65
|
*/
|
|
44
66
|
retrieve(id: IntegrationConnection["id"]): Promise<IntegrationConnection>;
|
|
45
67
|
/**
|
|
@@ -55,5 +77,5 @@ export default class IntegrationConnectionsResource extends BaseResource {
|
|
|
55
77
|
* @param id The integration-connection ID.
|
|
56
78
|
* @returns The ping result with the duration in milliseconds.
|
|
57
79
|
*/
|
|
58
|
-
ping(id: IntegrationConnection["id"]): Promise<
|
|
80
|
+
ping(id: IntegrationConnection["id"]): Promise<IntegrationConnectionPingOutput>;
|
|
59
81
|
}
|
|
@@ -4,13 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const BaseResource_1 = __importDefault(require("../resources/BaseResource"));
|
|
7
|
+
const IntegrationConnectionAuthSessionsResource_1 = __importDefault(require("../resources/IntegrationConnectionAuthSessionsResource"));
|
|
7
8
|
class IntegrationConnectionsResource extends BaseResource_1.default {
|
|
9
|
+
authSessions;
|
|
8
10
|
ROUTE = "/integration-connections";
|
|
11
|
+
constructor(httpClient) {
|
|
12
|
+
super(httpClient);
|
|
13
|
+
this.authSessions = new IntegrationConnectionAuthSessionsResource_1.default(this.httpClient);
|
|
14
|
+
}
|
|
9
15
|
/**
|
|
10
|
-
* Returns a list of all integration-connections
|
|
11
|
-
* Conductor account.
|
|
12
|
-
*
|
|
13
|
-
* @returns Your integration-connections.
|
|
16
|
+
* Returns a list of all integration-connections of all your end-users.
|
|
14
17
|
*/
|
|
15
18
|
async list() {
|
|
16
19
|
const { data } = await this.httpClient.get(this.ROUTE);
|
|
@@ -18,18 +21,6 @@ class IntegrationConnectionsResource extends BaseResource_1.default {
|
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* Creates a new integration-connection.
|
|
21
|
-
*
|
|
22
|
-
* @param input The input object to create the integration-connection.
|
|
23
|
-
* @param input.integrationKey The identifier of the third-party platform to
|
|
24
|
-
* integrate (e.g., "quickbooks-desktop").
|
|
25
|
-
* @param input.endUserSourceId Your end-user's unique ID in your product's
|
|
26
|
-
* database. Must be distinct from your other connections for the same
|
|
27
|
-
* integration.
|
|
28
|
-
* @param input.endUserEmail Your end-user's email address for identification
|
|
29
|
-
* only. No emails will be sent.
|
|
30
|
-
* @param input.endUserCompanyName Your end-user's company name that will be
|
|
31
|
-
* shown elsewhere in Conductor.
|
|
32
|
-
* @returns The newly created integration-connection.
|
|
33
24
|
*/
|
|
34
25
|
async create(input) {
|
|
35
26
|
const { data } = await this.httpClient.post(this.ROUTE, input);
|
|
@@ -37,9 +28,6 @@ class IntegrationConnectionsResource extends BaseResource_1.default {
|
|
|
37
28
|
}
|
|
38
29
|
/**
|
|
39
30
|
* Retrieves the specified integration-connection.
|
|
40
|
-
*
|
|
41
|
-
* @param id The integration-connection ID.
|
|
42
|
-
* @returns The integration-connection.
|
|
43
31
|
*/
|
|
44
32
|
async retrieve(id) {
|
|
45
33
|
const { data } = await this.httpClient.get(`${this.ROUTE}/${id}`);
|
|
@@ -114,7 +114,7 @@ export declare class ConductorIntegrationError extends ConductorError {
|
|
|
114
114
|
/**
|
|
115
115
|
* Raised when a connection error occurs with the third-party integration on the
|
|
116
116
|
* end-user's side. This typically indicates an issue with the end-user's
|
|
117
|
-
* integration
|
|
117
|
+
* integration-connection or configuration, which they must resolve. In other
|
|
118
118
|
* words, you cannot take action to fix these errors.
|
|
119
119
|
*
|
|
120
120
|
* E.g., QuickBooks Web Connector (QBWC) failed to connect to QuickBooks Desktop
|
|
@@ -143,6 +143,13 @@ export declare class ConductorAuthenticationError extends ConductorError {
|
|
|
143
143
|
static readonly rawType = "AUTHENTICATION_ERROR";
|
|
144
144
|
constructor(options: ConductorErrorOptionsWithoutType);
|
|
145
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Raised when you attempt to access a resource that is not allowed.
|
|
148
|
+
*/
|
|
149
|
+
export declare class ConductorPermissionError extends ConductorError {
|
|
150
|
+
static readonly rawType = "PERMISSION_ERROR";
|
|
151
|
+
constructor(options: ConductorErrorOptionsWithoutType);
|
|
152
|
+
}
|
|
146
153
|
/**
|
|
147
154
|
* Raised when there was a network problem between the client (on your server)
|
|
148
155
|
* and Conductor's servers. E.g., a downed network or a bad TLS certificate.
|
package/dist/src/utils/error.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable max-classes-per-file -- Use one module for all error classes. */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.generateConductorErrorFromType = exports.ConductorUnknownError = exports.ConductorInternalError = exports.ConductorConnectionError = exports.ConductorAuthenticationError = exports.ConductorInvalidRequestError = exports.ConductorIntegrationConnectionError = exports.ConductorIntegrationError = exports.ConductorError = exports.isWellFormedConductorServerError = exports.DEFAULT_END_USER_MESSAGE = void 0;
|
|
4
|
+
exports.generateConductorErrorFromType = exports.ConductorUnknownError = exports.ConductorInternalError = exports.ConductorConnectionError = exports.ConductorPermissionError = exports.ConductorAuthenticationError = exports.ConductorInvalidRequestError = exports.ConductorIntegrationConnectionError = exports.ConductorIntegrationError = exports.ConductorError = exports.isWellFormedConductorServerError = exports.DEFAULT_END_USER_MESSAGE = void 0;
|
|
5
5
|
// Matches server-side value.
|
|
6
6
|
exports.DEFAULT_END_USER_MESSAGE = "An internal server error occurred. Please try again later.";
|
|
7
7
|
function isWellFormedConductorServerError(error) {
|
|
@@ -129,7 +129,7 @@ exports.ConductorIntegrationError = ConductorIntegrationError;
|
|
|
129
129
|
/**
|
|
130
130
|
* Raised when a connection error occurs with the third-party integration on the
|
|
131
131
|
* end-user's side. This typically indicates an issue with the end-user's
|
|
132
|
-
* integration
|
|
132
|
+
* integration-connection or configuration, which they must resolve. In other
|
|
133
133
|
* words, you cannot take action to fix these errors.
|
|
134
134
|
*
|
|
135
135
|
* E.g., QuickBooks Web Connector (QBWC) failed to connect to QuickBooks Desktop
|
|
@@ -167,6 +167,16 @@ class ConductorAuthenticationError extends ConductorError {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
exports.ConductorAuthenticationError = ConductorAuthenticationError;
|
|
170
|
+
/**
|
|
171
|
+
* Raised when you attempt to access a resource that is not allowed.
|
|
172
|
+
*/
|
|
173
|
+
class ConductorPermissionError extends ConductorError {
|
|
174
|
+
static rawType = "PERMISSION_ERROR";
|
|
175
|
+
constructor(options) {
|
|
176
|
+
super({ ...options, type: ConductorPermissionError.rawType });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.ConductorPermissionError = ConductorPermissionError;
|
|
170
180
|
/**
|
|
171
181
|
* Raised when there was a network problem between the client (on your server)
|
|
172
182
|
* and Conductor's servers. E.g., a downed network or a bad TLS certificate.
|
|
@@ -214,6 +224,9 @@ function generateConductorErrorFromType(options) {
|
|
|
214
224
|
case ConductorAuthenticationError.rawType: {
|
|
215
225
|
return new ConductorAuthenticationError(options);
|
|
216
226
|
}
|
|
227
|
+
case ConductorPermissionError.rawType: {
|
|
228
|
+
return new ConductorPermissionError(options);
|
|
229
|
+
}
|
|
217
230
|
case ConductorConnectionError.rawType: {
|
|
218
231
|
return new ConductorConnectionError(options);
|
|
219
232
|
}
|