conductor-node 10.5.0 → 10.5.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/README.md CHANGED
@@ -98,7 +98,7 @@ const qbdConnection =
98
98
 
99
99
  Checks whether the specified integration-connection can connect and process requests end-to-end.
100
100
 
101
- If the connection fails, the error we encountered will be thrown as a [`ConductorError`](#error-handling) (like any request). This information is useful for showing a "connection status" indicator in your app. If an error occurs, we recommend displaying the property `error.endUserMessage` to your end-user in your app's UI.
101
+ If the connection fails, the error we encountered will be thrown as a [`ConductorError`](#error-handling) (like any request). This information is useful for showing a "connection status" indicator in your app. If an error occurs, we strongly recommend displaying the property `error.userFriendlyMessage` to your end-user in your app's UI.
102
102
 
103
103
  Using `async`/`await`:
104
104
 
@@ -107,7 +107,7 @@ try {
107
107
  await conductor.integrationConnections.ping(qbdConnectionId);
108
108
  } catch (error) {
109
109
  if (error instanceof ConductorError) {
110
- // Update your app's UI to display `error.endUserMessage`.
110
+ // Update your app's UI to display `error.userFriendlyMessage`.
111
111
  }
112
112
  // ...
113
113
  }
@@ -118,7 +118,7 @@ Or in the form of a rejected promise:
118
118
  ```ts
119
119
  conductor.integrationConnections.ping(qbdConnectionId).catch((error) => {
120
120
  if (error instanceof ConductorError) {
121
- // Update your app's UI to display `error.endUserMessage`.
121
+ // Update your app's UI to display `error.userFriendlyMessage`.
122
122
  }
123
123
  // ...
124
124
  });
@@ -158,16 +158,16 @@ const accountAddInput: QbdTypes.AccountAdd = {
158
158
 
159
159
  All errors thrown by the Conductor API are instances of `ConductorError` or its subclasses. These errors have the following properties:
160
160
 
161
- | Property | Type | Description |
162
- | ----------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
163
- | `message` | `string` | The developer-friendly error message for your logs. |
164
- | `endUserMessage` | `string` | The end-user-friendly error message to display in your app's UI to your end-users.<br><br>This value exists for _every_ error. E.g., for a QBD connection error, it might recommend the end-user to check that their QuickBooks Desktop is open and that they're logged in. But if a Conductor API key is expired, e.g., this message will just say "An internal server error occurred. Please try again later.". |
165
- | `type` | `string` | Categorizes the error. See [Error Types](#error-types) below.<br><br>This value is the same as the subclass name. E.g., `"ConductorIntegrationError"` or `"ConductorInvalidRequestError"`. |
166
- | `code` | `string` | The unique error code from Conductor, which is useful for adding special handling for specific errors. E.g., `"RESOURCE_MISSING"`, `"API_KEY_INVALID"`, or `"QBD_REQUEST_ERROR"`.<br><br>In contrast, `type` is more general and categorizes the error. |
167
- | `httpStatusCode` | `number` or `undefined` | The HTTP status code of the response that included the error. |
168
- | `integrationCode` | `string` or `undefined` | The unique error code supplied by the third-party integration for errors returned by the integration (i.e., `ConductorIntegrationError`) or integration connector (i.e., `ConductorIntegrationConnectorError`). This is useful for adding special handling for specific errors from the third-party integration or connector.<br><br>The integration's corresponding error message for this code is in `error.message`.<br><br>The third-party integrations' error codes are not standardized, so you should not rely on this code to be the same across integrations. |
169
- | `requestId` | `string` or `undefined` | The unique identifier for the request that caused the error.<br><br>If you need to contact us about a specific request, providing the request identifier will ensure the fastest possible resolution. |
170
- | `headers` | `object` or `undefined` | The headers of the response that included the error. |
161
+ | Property | Type | Description |
162
+ | --------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
163
+ | `message` | `string` | The developer-friendly error message for your logs. |
164
+ | `userFriendlyMessage` | `string` | The user-friendly error message, written specifically for displaying to your end-users in your app's UI.<br><br>This value exists for _every_ error. E.g., for a QBD connection error, it might recommend the end-user to check that their QuickBooks Desktop is open and that they're logged in. But if a Conductor API key is expired, e.g., this message will just say "An internal server error occurred. Please try again later.". |
165
+ | `type` | `string` | Categorizes the error. See [Error Types](#error-types) below.<br><br>This value is the same as the subclass name. E.g., `"ConductorIntegrationError"` or `"ConductorInvalidRequestError"`. |
166
+ | `code` | `string` | The unique error code from Conductor, which is useful for adding special handling for specific errors. E.g., `"RESOURCE_MISSING"`, `"API_KEY_INVALID"`, or `"QBD_REQUEST_ERROR"`.<br><br>In contrast, `type` is more general and categorizes the error. |
167
+ | `httpStatusCode` | `number` or `undefined` | The HTTP status code of the response that included the error. |
168
+ | `integrationCode` | `string` or `undefined` | The unique error code supplied by the third-party integration for errors returned by the integration (i.e., `ConductorIntegrationError`) or integration connector (i.e., `ConductorIntegrationConnectorError`). This is useful for adding special handling for specific errors from the third-party integration or connector.<br><br>The integration's corresponding error message for this code is in `error.message`.<br><br>The third-party integrations' error codes are not standardized, so you should not rely on this code to be the same across integrations. |
169
+ | `requestId` | `string` or `undefined` | The unique identifier for the request that caused the error.<br><br>If you need to contact us about a specific request, providing the request identifier will ensure the fastest possible resolution. |
170
+ | `headers` | `object` or `undefined` | The headers of the response that included the error. |
171
171
 
172
172
  ### Error Types
173
173
 
@@ -230,7 +230,7 @@ conductor.qbd.account
230
230
 
231
231
  It is unnecessary to wrap each API call individually, as demonstrated in the examples above. Instead, we suggest implementing a Global error handler for your server, such as [`app.use((error, ...) => { ... })` in Express](https://expressjs.com/en/guide/error-handling.html#writing-error-handlers) or [`formatError` in Apollo Server](https://apollographql.com/docs/apollo-server/data/errors/#for-client-responses). Within this handler, perform the following actions:
232
232
 
233
- 1. For any `ConductorError` instance, display the `error.endUserMessage` property to the end-user in your app's UI while logging the complete error object.
233
+ 1. For any `ConductorError` instance, display the `error.userFriendlyMessage` property to the end-user in your app's UI while logging the complete error object.
234
234
  2. For all `ConductorError` instances, transmit the full error object to your error-tracking service (e.g., Sentry):
235
235
  - Send a **warning** for instances of `ConductorIntegrationConnectionError`, which are not actionable by you and can only be resolved by the end-user; for example, failure to connect to QuickBooks Desktop on the end-user's computer.
236
236
  - Send an **error** for all other `ConductorError` instances, such as an invalid API key.
@@ -254,7 +254,7 @@ app.use((error, req, res, next) => {
254
254
  });
255
255
  // Return a different error message for your end-user to see in your
256
256
  // app's UI.
257
- res.status(500).send({ error: { message: error.endUserMessage } });
257
+ res.status(500).send({ error: { message: error.userFriendlyMessage } });
258
258
  } else {
259
259
  // ...
260
260
  }
@@ -287,7 +287,7 @@ const server = new ApolloServer({
287
287
  ...formattedError,
288
288
  // Return a different error message for your end-user to see in
289
289
  // your app's UI.
290
- message: origError.endUserMessage,
290
+ message: origError.userFriendlyMessage,
291
291
  };
292
292
  }
293
293
  // ...
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-node",
3
- "version": "10.5.0",
3
+ "version": "10.5.2",
4
4
  "description": "Easily integrate the entire QuickBooks Desktop API using fully-typed async TypeScript",
5
5
  "keywords": [
6
6
  "QuickBooks Desktop",
@@ -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.httpClient);
25
+ this.integrationConnections = new IntegrationConnectionsResource_1.default(this);
26
26
  this.qbd = new QbdIntegration_1.default(this.httpClient);
27
27
  }
28
28
  createHttpClient(apiKey, verbose, serverEnvironment) {
@@ -2450,7 +2450,7 @@ class QbdIntegration extends BaseIntegration_1.default {
2450
2450
  if (responseBody === undefined) {
2451
2451
  throw new error_1.ConductorIntegrationError({
2452
2452
  message: "No response received from QuickBooks Desktop.",
2453
- endUserMessage: "No response received from QuickBooks Desktop.",
2453
+ userFriendlyMessage: "No response received from QuickBooks Desktop.",
2454
2454
  code: "QBD_NO_RESPONSE",
2455
2455
  });
2456
2456
  }
@@ -48,8 +48,8 @@ export default class EndUsersResource extends BaseResource {
48
48
  * If the connection fails, the error we encountered will be thrown as a
49
49
  * `ConductorError` (like any request). This information is useful for showing
50
50
  * a "connection status" indicator in your app. If an error occurs, we
51
- * recommend displaying the property `error.endUserMessage` to your end-user
52
- * in your app's UI.
51
+ * strongly recommend displaying the property `error.userFriendlyMessage` to
52
+ * your end-user in your app's UI.
53
53
  *
54
54
  * @param endUserId The ID of the end-user to ping.
55
55
  * @param integrationSlug The integration identifier for the
@@ -34,8 +34,8 @@ class EndUsersResource extends BaseResource_1.default {
34
34
  * If the connection fails, the error we encountered will be thrown as a
35
35
  * `ConductorError` (like any request). This information is useful for showing
36
36
  * a "connection status" indicator in your app. If an error occurs, we
37
- * recommend displaying the property `error.endUserMessage` to your end-user
38
- * in your app's UI.
37
+ * strongly recommend displaying the property `error.userFriendlyMessage` to
38
+ * your end-user in your app's UI.
39
39
  *
40
40
  * @param endUserId The ID of the end-user to ping.
41
41
  * @param integrationSlug The integration identifier for the
@@ -38,9 +38,9 @@ export interface IntegrationConnectionAuthSessionCreateInput {
38
38
  export default class IntegrationConnectionAuthSessionsResource extends BaseResource {
39
39
  protected readonly ROUTE = "/integration-connection-auth-sessions";
40
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`.
41
+ * Creates an auth session for launching the client-side
42
+ * integration-connection authentication flow. Use the returned session’s
43
+ * `clientSecret` to launch the auth flow using Conductor.js.
44
44
  */
45
45
  create(input: IntegrationConnectionAuthSessionCreateInput): Promise<IntegrationConnectionAuthSession>;
46
46
  /**
@@ -7,9 +7,9 @@ const BaseResource_1 = __importDefault(require("../resources/BaseResource"));
7
7
  class IntegrationConnectionAuthSessionsResource extends BaseResource_1.default {
8
8
  ROUTE = "/integration-connection-auth-sessions";
9
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`.
10
+ * Creates an auth session for launching the client-side
11
+ * integration-connection authentication flow. Use the returned session’s
12
+ * `clientSecret` to launch the auth flow using Conductor.js.
13
13
  */
14
14
  async create(input) {
15
15
  const { data } = await this.httpClient.post(this.ROUTE, input);
@@ -1,6 +1,6 @@
1
+ import type Client from "../Client";
1
2
  import BaseResource from "../resources/BaseResource";
2
3
  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
  /**
@@ -22,8 +22,7 @@ export interface IntegrationConnection {
22
22
  createdAt: string;
23
23
  }
24
24
  /**
25
- * @deprecated We will soon remove this endpoint as we migrate to the new
26
- * end-user + auth-session model.
25
+ * @deprecated Use `conductor.endUsers.create()` instead.
27
26
  */
28
27
  export interface IntegrationConnectionCreateOldInput {
29
28
  /**
@@ -51,13 +50,14 @@ export interface IntegrationConnectionPingOutput {
51
50
  export default class IntegrationConnectionsResource extends BaseResource {
52
51
  readonly authSessions: IntegrationConnectionAuthSessionsResource;
53
52
  protected readonly ROUTE = "/integration-connections";
54
- constructor(httpClient: AxiosInstance);
53
+ private readonly client;
54
+ constructor(client: Client);
55
55
  /**
56
56
  * Returns a list of all integration-connections of all your end-users.
57
57
  */
58
58
  list(): Promise<IntegrationConnection[]>;
59
59
  /**
60
- * Creates a new integration-connection.
60
+ * @deprecated Use `conductor.endUsers.create({ ... })` instead.
61
61
  */
62
62
  create(input: IntegrationConnectionCreateOldInput): Promise<IntegrationConnection>;
63
63
  /**
@@ -65,17 +65,7 @@ export default class IntegrationConnectionsResource extends BaseResource {
65
65
  */
66
66
  retrieve(id: IntegrationConnection["id"]): Promise<IntegrationConnection>;
67
67
  /**
68
- * Checks whether the specified integration-connection can connect and process
69
- * requests end-to-end.
70
- *
71
- * If the connection fails, the error we encountered will be thrown as a
72
- * `ConductorError` (like any request). This information is useful for showing
73
- * a "connection status" indicator in your app. If an error occurs, we
74
- * recommend displaying the property `error.endUserMessage` to your end-user
75
- * in your app's UI.
76
- *
77
- * @param id The integration-connection ID.
78
- * @returns The ping result with the duration in milliseconds.
68
+ * @deprecated Use `conductor.endUsers.ping(id, "quickbooks-desktop")` instead.
79
69
  */
80
70
  ping(id: IntegrationConnection["id"]): Promise<IntegrationConnectionPingOutput>;
81
71
  }
@@ -8,8 +8,11 @@ const IntegrationConnectionAuthSessionsResource_1 = __importDefault(require("../
8
8
  class IntegrationConnectionsResource extends BaseResource_1.default {
9
9
  authSessions;
10
10
  ROUTE = "/integration-connections";
11
- constructor(httpClient) {
12
- super(httpClient);
11
+ client;
12
+ constructor(client) {
13
+ // @ts-expect-error -- Temporary hack.
14
+ super(client.httpClient);
15
+ this.client = client;
13
16
  this.authSessions = new IntegrationConnectionAuthSessionsResource_1.default(this.httpClient);
14
17
  }
15
18
  /**
@@ -20,11 +23,20 @@ class IntegrationConnectionsResource extends BaseResource_1.default {
20
23
  return data;
21
24
  }
22
25
  /**
23
- * Creates a new integration-connection.
26
+ * @deprecated Use `conductor.endUsers.create({ ... })` instead.
24
27
  */
25
28
  async create(input) {
26
- const { data } = await this.httpClient.post(this.ROUTE, input);
27
- return data;
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
+ };
28
40
  }
29
41
  /**
30
42
  * Retrieves the specified integration-connection.
@@ -34,21 +46,14 @@ class IntegrationConnectionsResource extends BaseResource_1.default {
34
46
  return data;
35
47
  }
36
48
  /**
37
- * Checks whether the specified integration-connection can connect and process
38
- * requests end-to-end.
39
- *
40
- * If the connection fails, the error we encountered will be thrown as a
41
- * `ConductorError` (like any request). This information is useful for showing
42
- * a "connection status" indicator in your app. If an error occurs, we
43
- * recommend displaying the property `error.endUserMessage` to your end-user
44
- * in your app's UI.
45
- *
46
- * @param id The integration-connection ID.
47
- * @returns The ping result with the duration in milliseconds.
49
+ * @deprecated Use `conductor.endUsers.ping(id, "quickbooks-desktop")` instead.
48
50
  */
49
51
  async ping(id) {
50
- const { data } = await this.httpClient.get(`${this.ROUTE}/${id}/ping`);
51
- return data;
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");
52
57
  }
53
58
  }
54
59
  exports.default = IntegrationConnectionsResource;
@@ -1,7 +1,11 @@
1
- export declare const DEFAULT_END_USER_MESSAGE = "An internal server error occurred. Please try again later.";
1
+ export declare const DEFAULT_USER_FRIENDLY_MESSAGE = "An internal server error occurred. Please try again later.";
2
2
  export interface ConductorErrorOptions {
3
3
  readonly message: string;
4
+ /**
5
+ * @deprecated Use `userFriendlyMessage` instead.
6
+ */
4
7
  readonly endUserMessage?: string;
8
+ readonly userFriendlyMessage?: string;
5
9
  readonly type: string;
6
10
  readonly code: string;
7
11
  readonly httpStatusCode?: number | undefined;
@@ -15,12 +19,16 @@ export interface ConductorErrorOptions {
15
19
  export interface ConductorServerError {
16
20
  readonly error: {
17
21
  readonly message: string;
22
+ /**
23
+ * @deprecated Use `userFriendlyMessage` instead.
24
+ */
18
25
  readonly endUserMessage: string;
26
+ readonly userFriendlyMessage: string;
19
27
  readonly type: string;
20
28
  readonly code: string;
21
29
  readonly httpStatusCode: number;
22
30
  readonly integrationCode?: string;
23
- readonly requestId?: string;
31
+ readonly requestId: string;
24
32
  };
25
33
  }
26
34
  export declare function isWellFormedConductorServerError(error: unknown): error is ConductorServerError;
@@ -34,8 +42,12 @@ export declare abstract class ConductorError extends Error {
34
42
  */
35
43
  readonly message: string;
36
44
  /**
37
- * The end-user-friendly error message to display in your app's UI to your
38
- * end-users.
45
+ * @deprecated Use `userFriendlyMessage` instead.
46
+ */
47
+ readonly endUserMessage: string;
48
+ /**
49
+ * The user-friendly error message, written specifically for displaying to
50
+ * your end-users in your app's UI.
39
51
  *
40
52
  * This value exists for *every* error. E.g., for a QBD connection error, it
41
53
  * might recommend the end-user to check that their QuickBooks Desktop is open
@@ -43,7 +55,7 @@ export declare abstract class ConductorError extends Error {
43
55
  * this message will just say "An internal server error occurred. Please try
44
56
  * again later.".
45
57
  */
46
- readonly endUserMessage: string;
58
+ readonly userFriendlyMessage: string;
47
59
  /**
48
60
  * Categorizes the error.
49
61
  *
@@ -1,14 +1,16 @@
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.ConductorPermissionError = 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_USER_FRIENDLY_MESSAGE = void 0;
5
5
  // Matches server-side value.
6
- exports.DEFAULT_END_USER_MESSAGE = "An internal server error occurred. Please try again later.";
6
+ exports.DEFAULT_USER_FRIENDLY_MESSAGE = "An internal server error occurred. Please try again later.";
7
7
  function isWellFormedConductorServerError(error) {
8
8
  return (error instanceof Object &&
9
9
  typeof error.error === "object" &&
10
10
  typeof error.error.message === "string" &&
11
- typeof error.error.endUserMessage === "string" &&
11
+ (typeof error.error.endUserMessage === "string" ||
12
+ typeof error.error.userFriendlyMessage ===
13
+ "string") &&
12
14
  typeof error.error.type === "string" &&
13
15
  typeof error.error.code === "string" &&
14
16
  typeof error.error.httpStatusCode === "number");
@@ -24,8 +26,12 @@ class ConductorError extends Error {
24
26
  */
25
27
  message;
26
28
  /**
27
- * The end-user-friendly error message to display in your app's UI to your
28
- * end-users.
29
+ * @deprecated Use `userFriendlyMessage` instead.
30
+ */
31
+ endUserMessage;
32
+ /**
33
+ * The user-friendly error message, written specifically for displaying to
34
+ * your end-users in your app's UI.
29
35
  *
30
36
  * This value exists for *every* error. E.g., for a QBD connection error, it
31
37
  * might recommend the end-user to check that their QuickBooks Desktop is open
@@ -33,7 +39,7 @@ class ConductorError extends Error {
33
39
  * this message will just say "An internal server error occurred. Please try
34
40
  * again later.".
35
41
  */
36
- endUserMessage;
42
+ userFriendlyMessage;
37
43
  /**
38
44
  * Categorizes the error.
39
45
  *
@@ -97,7 +103,14 @@ class ConductorError extends Error {
97
103
  // instantiated with the wrong options.
98
104
  this.type = this.constructor.name;
99
105
  this.message = options.message;
100
- this.endUserMessage = options.endUserMessage ?? exports.DEFAULT_END_USER_MESSAGE;
106
+ this.endUserMessage =
107
+ options.endUserMessage ??
108
+ options.userFriendlyMessage ??
109
+ exports.DEFAULT_USER_FRIENDLY_MESSAGE;
110
+ this.userFriendlyMessage =
111
+ options.userFriendlyMessage ??
112
+ options.endUserMessage ??
113
+ exports.DEFAULT_USER_FRIENDLY_MESSAGE;
101
114
  this.code = options.code;
102
115
  this.httpStatusCode = options.httpStatusCode;
103
116
  this.integrationCode = options.integrationCode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-node",
3
- "version": "10.5.0",
3
+ "version": "10.5.2",
4
4
  "description": "Easily integrate the entire QuickBooks Desktop API using fully-typed async TypeScript",
5
5
  "keywords": [
6
6
  "QuickBooks Desktop",