conductor-node 10.5.4 → 11.0.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/dist/package.json +1 -1
- package/dist/src/Client.js +1 -1
- package/dist/src/integrations/BaseIntegration.d.ts +1 -6
- package/dist/src/integrations/BaseIntegration.js +0 -8
- package/dist/src/integrations/qbd/QbdIntegration.js +1 -3
- package/dist/src/resources/EndUsersResource.d.ts +8 -8
- package/dist/src/resources/EndUsersResource.js +3 -3
- package/dist/src/resources/IntegrationConnectionAuthSessionsResource.d.ts +7 -7
- package/dist/src/resources/IntegrationConnectionsResource.d.ts +7 -39
- package/dist/src/resources/IntegrationConnectionsResource.js +2 -31
- package/dist/src/utils/error.d.ts +0 -12
- package/dist/src/utils/error.js +3 -14
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/src/Client.js
CHANGED
|
@@ -22,7 +22,7 @@ class Client {
|
|
|
22
22
|
(0, checkForUpdates_1.checkForUpdates)();
|
|
23
23
|
this.httpClient = this.createHttpClient(apiKey, verbose, serverEnvironment);
|
|
24
24
|
this.endUsers = new EndUsersResource_1.default(this.httpClient);
|
|
25
|
-
this.integrationConnections = new IntegrationConnectionsResource_1.default(this);
|
|
25
|
+
this.integrationConnections = new IntegrationConnectionsResource_1.default(this.httpClient);
|
|
26
26
|
this.qbd = new QbdIntegration_1.default(this.httpClient);
|
|
27
27
|
}
|
|
28
28
|
createHttpClient(apiKey, verbose, serverEnvironment) {
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import type { EndUser } from "../resources/EndUsersResource";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IntegrationSlug } from "../resources/IntegrationConnectionsResource";
|
|
3
3
|
import type { AxiosInstance } from "axios";
|
|
4
4
|
export default abstract class BaseIntegration {
|
|
5
5
|
protected readonly httpClient: AxiosInstance;
|
|
6
6
|
constructor(httpClient: AxiosInstance);
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated Instead use `sendRequest` after migrating to the end-user
|
|
9
|
-
* model.
|
|
10
|
-
*/
|
|
11
|
-
protected sendRequestDeprecated(id: IntegrationConnection["id"], payload: Record<string, unknown>): Promise<object>;
|
|
12
7
|
/** Not intended for public use. */
|
|
13
8
|
protected sendRequest(endUserId: EndUser["id"], integrationSlug: IntegrationSlug, payload: Record<string, unknown>): Promise<object>;
|
|
14
9
|
}
|
|
@@ -5,14 +5,6 @@ class BaseIntegration {
|
|
|
5
5
|
constructor(httpClient) {
|
|
6
6
|
this.httpClient = httpClient;
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated Instead use `sendRequest` after migrating to the end-user
|
|
10
|
-
* model.
|
|
11
|
-
*/
|
|
12
|
-
async sendRequestDeprecated(id, payload) {
|
|
13
|
-
const { data } = await this.httpClient.post(`/integration-connections/${id}/send-request`, payload);
|
|
14
|
-
return data;
|
|
15
|
-
}
|
|
16
8
|
/** Not intended for public use. */
|
|
17
9
|
async sendRequest(endUserId, integrationSlug, payload) {
|
|
18
10
|
const { data } = await this.httpClient.post(`/end-users/${endUserId}/send-request/${integrationSlug}`, payload);
|
|
@@ -2443,9 +2443,7 @@ class QbdIntegration extends BaseIntegration_1.default {
|
|
|
2443
2443
|
query: async (endUserId, params) => this.sendRequestWrapper(endUserId, { WorkersCompCodeQueryRq: params }, "WorkersCompCodeQueryRs", "WorkersCompCodeRet"),
|
|
2444
2444
|
};
|
|
2445
2445
|
async sendRequestWrapper(endUserId, params, responseWrapperKey, responseBodyKey) {
|
|
2446
|
-
const response = (
|
|
2447
|
-
? await this.sendRequestDeprecated(endUserId, params)
|
|
2448
|
-
: await this.sendRequest(endUserId, "quickbooks-desktop", params));
|
|
2446
|
+
const response = (await this.sendRequest(endUserId, "quickbooks-desktop", params));
|
|
2449
2447
|
const responseBody = response[responseWrapperKey]?.[responseBodyKey];
|
|
2450
2448
|
if (responseBody === undefined) {
|
|
2451
2449
|
throw new error_1.ConductorIntegrationError({
|
|
@@ -4,28 +4,28 @@ export interface EndUser {
|
|
|
4
4
|
/**
|
|
5
5
|
* The unique identifier for the object.
|
|
6
6
|
*/
|
|
7
|
-
id: string;
|
|
7
|
+
readonly id: string;
|
|
8
8
|
/**
|
|
9
9
|
* Your end-user's unique ID in your database. Must be distinct from your
|
|
10
10
|
* other end-users.
|
|
11
11
|
*/
|
|
12
|
-
sourceId: string;
|
|
12
|
+
readonly sourceId: string;
|
|
13
13
|
/**
|
|
14
14
|
* Your end-user's email address.
|
|
15
15
|
*/
|
|
16
|
-
email: string;
|
|
16
|
+
readonly email: string;
|
|
17
17
|
/**
|
|
18
18
|
* Your end-user's company name that will be shown elsewhere in Conductor.
|
|
19
19
|
*/
|
|
20
|
-
name: string;
|
|
20
|
+
readonly name: string;
|
|
21
21
|
/**
|
|
22
22
|
* The time at which the object was created.
|
|
23
23
|
*/
|
|
24
|
-
createdAt: string;
|
|
24
|
+
readonly createdAt: string;
|
|
25
25
|
}
|
|
26
26
|
export type EndUserCreateInput = Pick<EndUser, "email" | "name" | "sourceId">;
|
|
27
27
|
export interface EndUserPingOutput {
|
|
28
|
-
duration: number;
|
|
28
|
+
readonly duration: number;
|
|
29
29
|
}
|
|
30
30
|
export default class EndUsersResource extends BaseResource {
|
|
31
31
|
protected readonly ROUTE = "/end-users";
|
|
@@ -51,10 +51,10 @@ export default class EndUsersResource extends BaseResource {
|
|
|
51
51
|
* strongly recommend displaying the property `error.userFacingMessage` to
|
|
52
52
|
* your end-user in your app's UI.
|
|
53
53
|
*
|
|
54
|
-
* @param
|
|
54
|
+
* @param id The ID of the end-user to ping.
|
|
55
55
|
* @param integrationSlug The integration identifier for the
|
|
56
56
|
* integration-connection to ping.
|
|
57
57
|
* @returns The ping result with the duration in milliseconds.
|
|
58
58
|
*/
|
|
59
|
-
ping(
|
|
59
|
+
ping(id: EndUser["id"], integrationSlug: IntegrationSlug): Promise<EndUserPingOutput>;
|
|
60
60
|
}
|
|
@@ -37,13 +37,13 @@ class EndUsersResource extends BaseResource_1.default {
|
|
|
37
37
|
* strongly recommend displaying the property `error.userFacingMessage` to
|
|
38
38
|
* your end-user in your app's UI.
|
|
39
39
|
*
|
|
40
|
-
* @param
|
|
40
|
+
* @param id The ID of the end-user to ping.
|
|
41
41
|
* @param integrationSlug The integration identifier for the
|
|
42
42
|
* integration-connection to ping.
|
|
43
43
|
* @returns The ping result with the duration in milliseconds.
|
|
44
44
|
*/
|
|
45
|
-
async ping(
|
|
46
|
-
const { data } = await this.httpClient.get(`${this.ROUTE}/${
|
|
45
|
+
async ping(id, integrationSlug) {
|
|
46
|
+
const { data } = await this.httpClient.get(`${this.ROUTE}/${id}/ping/${integrationSlug}`);
|
|
47
47
|
return data;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -3,37 +3,37 @@ export interface IntegrationConnectionAuthSession {
|
|
|
3
3
|
/**
|
|
4
4
|
* The unique identifier for the object.
|
|
5
5
|
*/
|
|
6
|
-
id: string;
|
|
6
|
+
readonly id: string;
|
|
7
7
|
/**
|
|
8
8
|
* The ID of the end-user for whom to create an integration-connection in this
|
|
9
9
|
* auth session.
|
|
10
10
|
*/
|
|
11
|
-
endUserId: string;
|
|
11
|
+
readonly endUserId: string;
|
|
12
12
|
/**
|
|
13
13
|
* The value that you will pass to the client to launch the authentication flow.
|
|
14
14
|
*/
|
|
15
|
-
clientSecret: string;
|
|
15
|
+
readonly clientSecret: string;
|
|
16
16
|
/**
|
|
17
17
|
* The URL to which to redirect the end-user to return to your app after
|
|
18
18
|
* completing the authentication flow.
|
|
19
19
|
*/
|
|
20
|
-
returnUrl: string;
|
|
20
|
+
readonly returnUrl: string;
|
|
21
21
|
/**
|
|
22
22
|
* The time at which the auth-session expires.
|
|
23
23
|
*/
|
|
24
|
-
expiresAt: string;
|
|
24
|
+
readonly expiresAt: string;
|
|
25
25
|
}
|
|
26
26
|
export interface IntegrationConnectionAuthSessionCreateInput {
|
|
27
27
|
/**
|
|
28
28
|
* The ID of the end-user for whom to create an integration-connection in this
|
|
29
29
|
* auth session.
|
|
30
30
|
*/
|
|
31
|
-
endUserId: string;
|
|
31
|
+
readonly endUserId: string;
|
|
32
32
|
/**
|
|
33
33
|
* The URL to which to redirect the end-user to return to your app after
|
|
34
34
|
* completing the authentication flow.
|
|
35
35
|
*/
|
|
36
|
-
returnUrl: string;
|
|
36
|
+
readonly returnUrl: string;
|
|
37
37
|
}
|
|
38
38
|
export default class IntegrationConnectionAuthSessionsResource extends BaseResource {
|
|
39
39
|
protected readonly ROUTE = "/integration-connection-auth-sessions";
|
|
@@ -1,71 +1,39 @@
|
|
|
1
|
-
import type Client from "../Client";
|
|
2
1
|
import BaseResource from "../resources/BaseResource";
|
|
3
2
|
import IntegrationConnectionAuthSessionsResource from "../resources/IntegrationConnectionAuthSessionsResource";
|
|
3
|
+
import type { AxiosInstance } from "axios";
|
|
4
4
|
export type IntegrationSlug = "quickbooks-desktop";
|
|
5
5
|
export interface IntegrationConnection {
|
|
6
6
|
/**
|
|
7
7
|
* The unique identifier for the object.
|
|
8
8
|
*/
|
|
9
|
-
id: string;
|
|
9
|
+
readonly id: string;
|
|
10
10
|
/**
|
|
11
11
|
* The ID of the end-user who owns this integration-connection.
|
|
12
12
|
*/
|
|
13
|
-
endUserId: string;
|
|
13
|
+
readonly endUserId: string;
|
|
14
14
|
/**
|
|
15
15
|
* The identifier of the third-party platform to integrate (e.g.,
|
|
16
16
|
* "quickbooks-desktop").
|
|
17
17
|
*/
|
|
18
|
-
integrationSlug: IntegrationSlug;
|
|
18
|
+
readonly integrationSlug: IntegrationSlug;
|
|
19
19
|
/**
|
|
20
20
|
* The time at which the object was created.
|
|
21
21
|
*/
|
|
22
|
-
createdAt: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated Use `conductor.endUsers.create()` instead.
|
|
26
|
-
*/
|
|
27
|
-
export interface IntegrationConnectionCreateOldInput {
|
|
28
|
-
/**
|
|
29
|
-
* The identifier of the third-party platform to integrate (e.g.,
|
|
30
|
-
* "quickbooks-desktop").
|
|
31
|
-
*/
|
|
32
|
-
integrationSlug: IntegrationSlug;
|
|
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
|
-
*/
|
|
37
|
-
endUserSourceId: string;
|
|
38
|
-
/**
|
|
39
|
-
* Your end-user's email address.
|
|
40
|
-
*/
|
|
41
|
-
endUserEmail: string;
|
|
42
|
-
/**
|
|
43
|
-
* Your end-user's company name that will be shown elsewhere in Conductor.
|
|
44
|
-
*/
|
|
45
|
-
endUserCompanyName: string;
|
|
22
|
+
readonly createdAt: string;
|
|
46
23
|
}
|
|
47
24
|
export interface IntegrationConnectionPingOutput {
|
|
48
|
-
duration: number;
|
|
25
|
+
readonly duration: number;
|
|
49
26
|
}
|
|
50
27
|
export default class IntegrationConnectionsResource extends BaseResource {
|
|
51
28
|
readonly authSessions: IntegrationConnectionAuthSessionsResource;
|
|
52
29
|
protected readonly ROUTE = "/integration-connections";
|
|
53
|
-
|
|
54
|
-
constructor(client: Client);
|
|
30
|
+
constructor(httpClient: AxiosInstance);
|
|
55
31
|
/**
|
|
56
32
|
* Returns a list of all integration-connections of all your end-users.
|
|
57
33
|
*/
|
|
58
34
|
list(): Promise<IntegrationConnection[]>;
|
|
59
|
-
/**
|
|
60
|
-
* @deprecated Use `conductor.endUsers.create({ ... })` instead.
|
|
61
|
-
*/
|
|
62
|
-
create(input: IntegrationConnectionCreateOldInput): Promise<IntegrationConnection>;
|
|
63
35
|
/**
|
|
64
36
|
* Retrieves the specified integration-connection.
|
|
65
37
|
*/
|
|
66
38
|
retrieve(id: IntegrationConnection["id"]): Promise<IntegrationConnection>;
|
|
67
|
-
/**
|
|
68
|
-
* @deprecated Use `conductor.endUsers.ping(id, "quickbooks-desktop")` instead.
|
|
69
|
-
*/
|
|
70
|
-
ping(id: IntegrationConnection["id"]): Promise<IntegrationConnectionPingOutput>;
|
|
71
39
|
}
|
|
@@ -8,11 +8,8 @@ const IntegrationConnectionAuthSessionsResource_1 = __importDefault(require("../
|
|
|
8
8
|
class IntegrationConnectionsResource extends BaseResource_1.default {
|
|
9
9
|
authSessions;
|
|
10
10
|
ROUTE = "/integration-connections";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// @ts-expect-error -- Temporary hack.
|
|
14
|
-
super(client.httpClient);
|
|
15
|
-
this.client = client;
|
|
11
|
+
constructor(httpClient) {
|
|
12
|
+
super(httpClient);
|
|
16
13
|
this.authSessions = new IntegrationConnectionAuthSessionsResource_1.default(this.httpClient);
|
|
17
14
|
}
|
|
18
15
|
/**
|
|
@@ -22,22 +19,6 @@ class IntegrationConnectionsResource extends BaseResource_1.default {
|
|
|
22
19
|
const { data } = await this.httpClient.get(this.ROUTE);
|
|
23
20
|
return data;
|
|
24
21
|
}
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated Use `conductor.endUsers.create({ ... })` instead.
|
|
27
|
-
*/
|
|
28
|
-
async create(input) {
|
|
29
|
-
const endUser = await this.client.endUsers.create({
|
|
30
|
-
sourceId: input.endUserSourceId,
|
|
31
|
-
email: input.endUserEmail,
|
|
32
|
-
name: input.endUserCompanyName,
|
|
33
|
-
});
|
|
34
|
-
return {
|
|
35
|
-
id: endUser.id,
|
|
36
|
-
endUserId: endUser.id,
|
|
37
|
-
integrationSlug: input.integrationSlug,
|
|
38
|
-
createdAt: endUser.createdAt,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
22
|
/**
|
|
42
23
|
* Retrieves the specified integration-connection.
|
|
43
24
|
*/
|
|
@@ -45,15 +26,5 @@ class IntegrationConnectionsResource extends BaseResource_1.default {
|
|
|
45
26
|
const { data } = await this.httpClient.get(`${this.ROUTE}/${id}`);
|
|
46
27
|
return data;
|
|
47
28
|
}
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated Use `conductor.endUsers.ping(id, "quickbooks-desktop")` instead.
|
|
50
|
-
*/
|
|
51
|
-
async ping(id) {
|
|
52
|
-
if (id.startsWith("int_conn")) {
|
|
53
|
-
const { data } = await this.httpClient.get(`${this.ROUTE}/${id}/ping`);
|
|
54
|
-
return data;
|
|
55
|
-
}
|
|
56
|
-
return this.client.endUsers.ping(id, "quickbooks-desktop");
|
|
57
|
-
}
|
|
58
29
|
}
|
|
59
30
|
exports.default = IntegrationConnectionsResource;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export declare const DEFAULT_USER_FACING_MESSAGE = "An internal server error occurred. Please try again later.";
|
|
2
2
|
export interface ConductorErrorOptions {
|
|
3
3
|
readonly message: string;
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Use `userFacingMessage` instead.
|
|
6
|
-
*/
|
|
7
|
-
readonly endUserMessage?: string;
|
|
8
4
|
readonly userFacingMessage?: string;
|
|
9
5
|
readonly type: string;
|
|
10
6
|
readonly code: string;
|
|
@@ -19,10 +15,6 @@ export interface ConductorErrorOptions {
|
|
|
19
15
|
export interface ConductorServerError {
|
|
20
16
|
readonly error: {
|
|
21
17
|
readonly message: string;
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated Use `userFacingMessage` instead.
|
|
24
|
-
*/
|
|
25
|
-
readonly endUserMessage?: string;
|
|
26
18
|
readonly userFacingMessage: string;
|
|
27
19
|
readonly type: string;
|
|
28
20
|
readonly code: string;
|
|
@@ -41,10 +33,6 @@ export declare abstract class ConductorError extends Error {
|
|
|
41
33
|
* The developer error message for your logs.
|
|
42
34
|
*/
|
|
43
35
|
readonly message: string;
|
|
44
|
-
/**
|
|
45
|
-
* @deprecated Use `userFacingMessage` instead.
|
|
46
|
-
*/
|
|
47
|
-
readonly endUserMessage: string;
|
|
48
36
|
/**
|
|
49
37
|
* The user-friendly error message, written specifically for displaying to
|
|
50
38
|
* your end-users in your app's UI.
|
package/dist/src/utils/error.js
CHANGED
|
@@ -8,9 +8,8 @@ function isWellFormedConductorServerError(error) {
|
|
|
8
8
|
return (error instanceof Object &&
|
|
9
9
|
typeof error.error === "object" &&
|
|
10
10
|
typeof error.error.message === "string" &&
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"string") &&
|
|
11
|
+
typeof error.error.userFacingMessage ===
|
|
12
|
+
"string" &&
|
|
14
13
|
typeof error.error.type === "string" &&
|
|
15
14
|
typeof error.error.code === "string" &&
|
|
16
15
|
typeof error.error.httpStatusCode === "number");
|
|
@@ -25,10 +24,6 @@ class ConductorError extends Error {
|
|
|
25
24
|
* The developer error message for your logs.
|
|
26
25
|
*/
|
|
27
26
|
message;
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated Use `userFacingMessage` instead.
|
|
30
|
-
*/
|
|
31
|
-
endUserMessage;
|
|
32
27
|
/**
|
|
33
28
|
* The user-friendly error message, written specifically for displaying to
|
|
34
29
|
* your end-users in your app's UI.
|
|
@@ -103,14 +98,8 @@ class ConductorError extends Error {
|
|
|
103
98
|
// instantiated with the wrong options.
|
|
104
99
|
this.type = this.constructor.name;
|
|
105
100
|
this.message = options.message;
|
|
106
|
-
this.endUserMessage =
|
|
107
|
-
options.endUserMessage ??
|
|
108
|
-
options.userFacingMessage ??
|
|
109
|
-
exports.DEFAULT_USER_FACING_MESSAGE;
|
|
110
101
|
this.userFacingMessage =
|
|
111
|
-
options.userFacingMessage ??
|
|
112
|
-
options.endUserMessage ??
|
|
113
|
-
exports.DEFAULT_USER_FACING_MESSAGE;
|
|
102
|
+
options.userFacingMessage ?? exports.DEFAULT_USER_FACING_MESSAGE;
|
|
114
103
|
this.code = options.code;
|
|
115
104
|
this.httpStatusCode = options.httpStatusCode;
|
|
116
105
|
this.integrationCode = options.integrationCode;
|