conductor-node 10.1.0 → 10.2.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 CHANGED
@@ -92,9 +92,8 @@ The response looks like the following:
92
92
  Retrieves the specified integration-connection.
93
93
 
94
94
  ```ts
95
- const qbdConnection = await conductor.integrationConnections.retrieve(
96
- qbdConnectionId,
97
- );
95
+ const qbdConnection =
96
+ await conductor.integrationConnections.retrieve(qbdConnectionId);
98
97
  ```
99
98
 
100
99
  ### `integrationConnections.ping(id: string)`
@@ -179,9 +178,10 @@ The error object you receive will have one of the following error types:
179
178
  | Name | Description |
180
179
  | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
181
180
  | `ConductorIntegrationError` | Raised when the third-party integration encounters an error while processing the end-user's request. This often results from an issue with the request or data handling that requires your attention to resolve.<br><br>E.g., a `ListID` you provided was not found in QuickBooks Desktop, or an accounting value you supplied did not adhere to the integration's accounting rules.<br><br>Refer to `error.integrationCode` for the error code returned by the integration, if available. |
182
- | `ConductorIntegrationConnectionError` | Raised when a connection error occurs with the third-party integration on the end-user's side. This typically indicates an issue with the end-user's integration connection or configuration, which they must resolve. In other words, you cannot take action to fix these errors.<br><br>E.g., QuickBooks Web Connector (QBWC) failed to connect to QuickBooks Desktop on the end-user's computer.<br><br>Refer to `error.integrationCode` for the error code returned by the integration connector, if available.<br><br>❗ We recommend _not_ alerting your team for these errors because only the end-user can fix them. See [Global Error Handling](#global-error-handling) for an example of this. |
181
+ | `ConductorIntegrationConnectionError` | Raised when a connection error occurs with the third-party integration on the end-user's side. This typically indicates an issue with the end-user's integration-connection or configuration, which they must resolve. In other words, you cannot take action to fix these errors.<br><br>E.g., QuickBooks Web Connector (QBWC) failed to connect to QuickBooks Desktop on the end-user's computer.<br><br>Refer to `error.integrationCode` for the error code returned by the integration connector, if available.<br><br>❗ We recommend _not_ alerting your team for these errors because only the end-user can fix them. See [Global Error Handling](#global-error-handling) for an example of this. |
183
182
  | `ConductorInvalidRequestError` | Raised when you make an API call with the wrong parameters, in the wrong state, or in an invalid way. |
184
183
  | `ConductorAuthenticationError` | Raised when Conductor cannot authenticate you with the credentials you provided. E.g., an incorrect API key. |
184
+ | `ConductorPermissionError` | Raised when you attempt to access a resource that is not allowed. |
185
185
  | `ConductorConnectionError` | Raised when there was a network problem between the client (on your server) and Conductor's servers. E.g., a downed network or a bad TLS certificate. |
186
186
  | `ConductorInternalError` | Raised when something went wrong on Conductor's end. (These are rare.) |
187
187
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-node",
3
- "version": "10.1.0",
3
+ "version": "10.2.0",
4
4
  "description": "Easily integrate the entire QuickBooks Desktop API using fully-typed async TypeScript",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -1,12 +1,16 @@
1
1
  import QbdIntegration from "./integrations/qbd/QbdIntegration";
2
+ import EndUsersResource from "./resources/EndUsersResource";
2
3
  import IntegrationConnectionsResource from "./resources/IntegrationConnectionsResource";
3
4
  import { getServerUrlForEnvironment } from "./utils/http";
4
5
  export interface ClientOptions {
5
- /** Logs each request, response, and error. */
6
+ /**
7
+ * Enables logging each request, response, and error.
8
+ */
6
9
  readonly verbose?: boolean;
7
10
  readonly serverEnvironment?: Parameters<typeof getServerUrlForEnvironment>[0];
8
11
  }
9
12
  export default class Client {
13
+ readonly endUsers: EndUsersResource;
10
14
  readonly integrationConnections: IntegrationConnectionsResource;
11
15
  /** QuickBooks Desktop integration. */
12
16
  readonly qbd: QbdIntegration;
@@ -7,11 +7,13 @@ const package_json_1 = __importDefault(require("./../package.json"));
7
7
  const QbdIntegration_1 = __importDefault(require("./integrations/qbd/QbdIntegration"));
8
8
  const errorHandling_1 = require("./interceptors/errorHandling");
9
9
  const logging_1 = require("./interceptors/logging");
10
+ const EndUsersResource_1 = __importDefault(require("./resources/EndUsersResource"));
10
11
  const IntegrationConnectionsResource_1 = __importDefault(require("./resources/IntegrationConnectionsResource"));
11
12
  const checkForUpdates_1 = require("./utils/checkForUpdates");
12
13
  const http_1 = require("./utils/http");
13
14
  const axios_1 = __importDefault(require("axios"));
14
15
  class Client {
16
+ endUsers;
15
17
  integrationConnections;
16
18
  /** QuickBooks Desktop integration. */
17
19
  qbd;
@@ -19,6 +21,7 @@ class Client {
19
21
  constructor(apiKey, { verbose = false, serverEnvironment = "production" } = {}) {
20
22
  (0, checkForUpdates_1.checkForUpdates)();
21
23
  this.httpClient = this.createHttpClient(apiKey, verbose, serverEnvironment);
24
+ this.endUsers = new EndUsersResource_1.default(this.httpClient);
22
25
  this.integrationConnections = new IntegrationConnectionsResource_1.default(this.httpClient);
23
26
  this.qbd = new QbdIntegration_1.default(this.httpClient);
24
27
  }
@@ -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 IntegrationConnectionCreateInput {
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 type CreateIntegrationConnectionInput = Pick<IntegrationConnection, "endUserCompanyName" | "endUserEmail" | "endUserSourceId" | "integrationKey">;
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 associated with your
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
- * @param input The input object to create the integration-connection.
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: IntegrationConnectionCreateInput): 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<PingIntegrationConnectionOutput>;
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 associated with your
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 connection or configuration, which they must resolve. In other
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.
@@ -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 connection or configuration, which they must resolve. In other
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-node",
3
- "version": "10.1.0",
3
+ "version": "10.2.0",
4
4
  "description": "Easily integrate the entire QuickBooks Desktop API using fully-typed async TypeScript",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",