conductor-node 9.1.1 → 9.1.3

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
@@ -175,14 +175,14 @@ All errors thrown by the Conductor API are instances of `ConductorError` or its
175
175
 
176
176
  The error object you receive will have one of the following error types:
177
177
 
178
- | Type | Description |
179
- | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
180
- | `ConductorIntegrationError` | Raised when the third-party integration returned an error while processing your end-user's request. This is likely due to an issue with your request or data handling that you must fix.<br><br>E.g., a `ListID` you provided was not found in QuickBooks Desktop, or an accounting value you provided failed the integration's accounting rules.<br><br>See `error.integrationCode` (above) for the error code that the integration returned, if any. |
181
- | `ConductorIntegrationConnectionError` | Raised when an error occurred connecting to the third-party integration on behalf of the end-user. Most likely, something is wrong with the end-user's integration connection or configuration that _the end-user must fix_, not you. <br><br>E.g., QuickBooks Web Connector (QBWC) failed to connect to QuickBooks Desktop on the end-user's computer.<br><br>See `error.integrationCode` (above) for the error code that the integration connector returned, if any.<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. |
182
- | `ConductorInvalidRequestError` | Raised when you make an API call with the wrong parameters, in the wrong state, or in an invalid way. |
183
- | `ConductorAuthenticationError` | Raised when Conductor cannot authenticate you with the credentials you provided. E.g., an incorrect API key. |
184
- | `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. |
185
- | `ConductorInternalError` | Raised when something went wrong on Conductor's end. (These are rare.) |
178
+ | Type | Description |
179
+ | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
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. |
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 [Centralized Error Handling](#centralized-error-handling) for an example of this. |
182
+ | `ConductorInvalidRequestError` | Raised when you make an API call with the wrong parameters, in the wrong state, or in an invalid way. |
183
+ | `ConductorAuthenticationError` | Raised when Conductor cannot authenticate you with the credentials you provided. E.g., an incorrect API key. |
184
+ | `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. |
185
+ | `ConductorInternalError` | Raised when something went wrong on Conductor's end. (These are rare.) |
186
186
 
187
187
  ### Specific Error Handling
188
188
 
@@ -227,14 +227,14 @@ conductor.qbd.account
227
227
  });
228
228
  ```
229
229
 
230
- ### Global Error Handling
230
+ ### Centralized Error Handling
231
231
 
232
- We do _not_ expect you to individually wrap every API call like the examples above. Instead, we recommend your server use a single global error handler, 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), where you do the following:
232
+ It is unnecessary to wrap each API call individually, as demonstrated in the examples above. Instead, we suggest implementing a centralized 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:
233
233
 
234
- 1. Ensure your app's UI shows your end-user the property `error.endUserMessage` for any `ConductorError` instance while you log the rest of the error object.
235
- 2. Send the entire error object to your error-tracking service (e.g., Sentry) for all `ConductorError` instances:
236
- - Send a **warning** for instances of `ConductorIntegrationConnectionError`, which only the end-user can fix; e.g., failed to connect to QuickBooks Desktop on your end-user's computer.
237
- - Send an **error** for all other `ConductorError` instances; e.g., invalid API key.
234
+ 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.
235
+ 2. For all `ConductorError` instances, transmit the full error object to your error-tracking service (e.g., Sentry):
236
+ - 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.
237
+ - Send an **error** for all other `ConductorError` instances, such as an invalid API key.
238
238
 
239
239
  For example, using an Express error handler:
240
240
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-node",
3
- "version": "9.1.1",
3
+ "version": "9.1.3",
4
4
  "description": "Easily integrate with the entire QuickBooks Desktop API with fully-typed async TypeScript",
5
5
  "author": "Danny Nemer <hi@DannyNemer.com>",
6
6
  "license": "MIT",
@@ -12,8 +12,8 @@
12
12
  "dist/package.json"
13
13
  ],
14
14
  "scripts": {
15
- "prepack": "yarn tsc && yarn delete-compiled-tests && yarn tsc-alias --verbose",
16
- "delete-compiled-tests": "rm -rf `find ./dist -type d -name __tests__` ./dist/src/utils/testing.*",
15
+ "prepack": "yarn tsc && yarn delete-compiled-dev-files && yarn tsc-alias --verbose",
16
+ "delete-compiled-dev-files": "rm -rf `find ./dist -type d -name __tests__` ./dist/src/utils/testing.* ./dist/src/graphql/codegenConfig.*",
17
17
  "postpack": "rm -rf dist",
18
18
  "clean": "rm -rf dist package conductor-node-*.tgz tsconfig.tsbuildinfo",
19
19
  "gen:graphql": "yarn graphql-codegen --config=./src/graphql/codegenConfig.ts",
@@ -1,6 +1,6 @@
1
1
  import type { GraphqlCreateIntegrationConnectionInput, GraphqlCreateIntegrationConnectionMutation, GraphqlGetIntegrationConnectionQuery, GraphqlGetIntegrationConnectionQueryVariables, GraphqlGetIntegrationConnectionsQuery, GraphqlPingIntegrationConnectionMutation, GraphqlPingIntegrationConnectionMutationVariables } from "./graphql/__generated__/operationTypes";
2
2
  import QbdIntegration from "./integrations/qbd/QbdIntegration";
3
- import { getServerUrlForEnvironment } from "./utils";
3
+ import { getServerUrlForEnvironment } from "./utils/misc";
4
4
  export interface ClientOptions {
5
5
  /** Logs each request and response. */
6
6
  readonly verbose?: boolean;
@@ -7,7 +7,7 @@ const package_json_1 = __importDefault(require("./../package.json"));
7
7
  const graphqlOperationWrapper_1 = require("./graphql/graphqlOperationWrapper");
8
8
  const operationTypes_1 = require("./graphql/__generated__/operationTypes");
9
9
  const QbdIntegration_1 = __importDefault(require("./integrations/qbd/QbdIntegration"));
10
- const utils_1 = require("./utils");
10
+ const misc_1 = require("./utils/misc");
11
11
  const graphql_request_1 = require("graphql-request");
12
12
  class Client {
13
13
  /** QuickBooks Desktop integration. */
@@ -15,8 +15,8 @@ class Client {
15
15
  graphqlClient;
16
16
  graphqlOperations;
17
17
  constructor(apiKey, { verbose = false, serverEnvironment = "production" } = {}) {
18
- (0, utils_1.checkForUpdates)();
19
- this.graphqlClient = new graphql_request_1.GraphQLClient(`${(0, utils_1.getServerUrlForEnvironment)(serverEnvironment)}/graphql`, { headers: this.createHeaders(apiKey) });
18
+ (0, misc_1.checkForUpdates)();
19
+ this.graphqlClient = new graphql_request_1.GraphQLClient(`${(0, misc_1.getServerUrlForEnvironment)(serverEnvironment)}/graphql`, { headers: this.createHeaders(apiKey) });
20
20
  this.graphqlOperations = (0, graphqlOperationWrapper_1.wrapGraphqlOperations)((0, operationTypes_1.getSdk)(this.graphqlClient), verbose);
21
21
  this.qbd = new QbdIntegration_1.default(this.graphqlOperations);
22
22
  }
@@ -1,5 +1,5 @@
1
- import type { ConductorError } from "../error";
2
1
  import type { getSdk } from "../graphql/__generated__/operationTypes";
2
+ import type { ConductorError } from "../utils/error";
3
3
  export declare function wrapGraphqlOperations<T extends ReturnType<typeof getSdk>>(graphqlOperations: T, verbose: boolean): T;
4
4
  export declare function graphqlOperationWrapper<V extends {
5
5
  [key: string]: unknown;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.wrapError = exports.getDurationString = exports.graphqlOperationWrapper = exports.wrapGraphqlOperations = void 0;
7
7
  const package_json_1 = __importDefault(require("../../package.json"));
8
- const error_1 = require("../error");
8
+ const error_1 = require("../utils/error");
9
9
  const graphql_request_1 = require("graphql-request");
10
10
  const node_util_1 = __importDefault(require("node:util"));
11
11
  function wrapGraphqlOperations(graphqlOperations, verbose) {
@@ -1,5 +1,5 @@
1
1
  import Client from "./Client";
2
2
  export default Client;
3
3
  export { type ClientOptions } from "./Client";
4
- export * from "./error";
5
4
  export * as QbdTypes from "./integrations/qbd/qbdTypes";
5
+ export * from "./utils/error";
package/dist/src/index.js CHANGED
@@ -15,9 +15,6 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
- };
21
18
  var __importStar = (this && this.__importStar) || function (mod) {
22
19
  if (mod && mod.__esModule) return mod;
23
20
  var result = {};
@@ -25,6 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
22
  __setModuleDefault(result, mod);
26
23
  return result;
27
24
  };
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
28
  var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
@@ -34,5 +34,5 @@ exports.QbdTypes = void 0;
34
34
  const Client_1 = __importDefault(require("./Client"));
35
35
  // eslint-disable-next-line unicorn/prefer-export-from -- We need `Client` to be the default export, which is impossible to define with `export from`.
36
36
  exports.default = Client_1.default;
37
- __exportStar(require("./error"), exports);
38
37
  exports.QbdTypes = __importStar(require("./integrations/qbd/qbdTypes"));
38
+ __exportStar(require("./utils/error"), exports);
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const error_1 = require("../../error");
7
6
  const BaseIntegration_1 = __importDefault(require("../../integrations/BaseIntegration"));
7
+ const error_1 = require("../../utils/error");
8
8
  class QbdIntegration extends BaseIntegration_1.default {
9
9
  account = {
10
10
  /**
@@ -76,30 +76,32 @@ export declare class ConductorError extends Error {
76
76
  }
77
77
  type ConductorErrorOptionsWithoutType = Omit<ConductorErrorOptions, "type">;
78
78
  /**
79
- * Raised when the third-party integration returned an error while processing
80
- * your end-user's request. This is likely due to an issue with your request or
81
- * data handling that you must fix.
79
+ * Raised when the third-party integration encounters an error while processing
80
+ * the end-user's request. This often results from an issue with the request or
81
+ * data handling that requires your attention to resolve.
82
82
  *
83
83
  * E.g., a `ListID` you provided was not found in QuickBooks Desktop, or an
84
- * accounting value you provided failed the integration's accounting rules.
84
+ * accounting value you supplied did not adhere to the integration's accounting
85
+ * rules.
85
86
  *
86
- * See `error.integrationCode` for the error code that the integration returned,
87
- * if any.
87
+ * Refer to `error.integrationCode` for the error code returned by the
88
+ * integration, if available.
88
89
  */
89
90
  export declare class ConductorIntegrationError extends ConductorError {
90
91
  static readonly rawType = "INTEGRATION_ERROR";
91
92
  constructor(options: ConductorErrorOptionsWithoutType);
92
93
  }
93
94
  /**
94
- * Raised when an error occurred connecting to the third-party integration on
95
- * behalf of the end-user. Most likely, something is wrong with the end-user's
96
- * integration connection or configuration that the end-user must fix, not you.
95
+ * Raised when a connection error occurs with the third-party integration on the
96
+ * end-user's side. This typically indicates an issue with the end-user's
97
+ * integration connection or configuration, which they must resolve. In other
98
+ * words, you cannot take action to fix these errors.
97
99
  *
98
100
  * E.g., QuickBooks Web Connector (QBWC) failed to connect to QuickBooks Desktop
99
101
  * on the end-user's computer.
100
102
  *
101
- * See `error.integrationCode` for the error code that the integration connector
102
- * returned, if any.
103
+ * Refer to `error.integrationCode` for the error code returned by the
104
+ * integration connector, if available.
103
105
  */
104
106
  export declare class ConductorIntegrationConnectionError extends ConductorError {
105
107
  static readonly rawType = "INTEGRATION_CONNECTION_ERROR";
@@ -84,15 +84,16 @@ class ConductorError extends Error {
84
84
  }
85
85
  exports.ConductorError = ConductorError;
86
86
  /**
87
- * Raised when the third-party integration returned an error while processing
88
- * your end-user's request. This is likely due to an issue with your request or
89
- * data handling that you must fix.
87
+ * Raised when the third-party integration encounters an error while processing
88
+ * the end-user's request. This often results from an issue with the request or
89
+ * data handling that requires your attention to resolve.
90
90
  *
91
91
  * E.g., a `ListID` you provided was not found in QuickBooks Desktop, or an
92
- * accounting value you provided failed the integration's accounting rules.
92
+ * accounting value you supplied did not adhere to the integration's accounting
93
+ * rules.
93
94
  *
94
- * See `error.integrationCode` for the error code that the integration returned,
95
- * if any.
95
+ * Refer to `error.integrationCode` for the error code returned by the
96
+ * integration, if available.
96
97
  */
97
98
  class ConductorIntegrationError extends ConductorError {
98
99
  static rawType = "INTEGRATION_ERROR";
@@ -102,15 +103,16 @@ class ConductorIntegrationError extends ConductorError {
102
103
  }
103
104
  exports.ConductorIntegrationError = ConductorIntegrationError;
104
105
  /**
105
- * Raised when an error occurred connecting to the third-party integration on
106
- * behalf of the end-user. Most likely, something is wrong with the end-user's
107
- * integration connection or configuration that the end-user must fix, not you.
106
+ * Raised when a connection error occurs with the third-party integration on the
107
+ * end-user's side. This typically indicates an issue with the end-user's
108
+ * integration connection or configuration, which they must resolve. In other
109
+ * words, you cannot take action to fix these errors.
108
110
  *
109
111
  * E.g., QuickBooks Web Connector (QBWC) failed to connect to QuickBooks Desktop
110
112
  * on the end-user's computer.
111
113
  *
112
- * See `error.integrationCode` for the error code that the integration connector
113
- * returned, if any.
114
+ * Refer to `error.integrationCode` for the error code returned by the
115
+ * integration connector, if available.
114
116
  */
115
117
  class ConductorIntegrationConnectionError extends ConductorError {
116
118
  static rawType = "INTEGRATION_CONNECTION_ERROR";
@@ -1,2 +1,2 @@
1
1
  export declare function checkForUpdates(): void;
2
- export declare function getServerUrlForEnvironment(environment: "development" | "production"): string;
2
+ export declare function getServerUrlForEnvironment(environment: "development" | "production" | "test"): string;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getServerUrlForEnvironment = exports.checkForUpdates = void 0;
7
- const package_json_1 = __importDefault(require("./../package.json"));
7
+ const package_json_1 = __importDefault(require("../../package.json"));
8
8
  const node_child_process_1 = require("node:child_process");
9
9
  function checkForUpdates() {
10
10
  const currentVersion = package_json_1.default.version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-node",
3
- "version": "9.1.1",
3
+ "version": "9.1.3",
4
4
  "description": "Easily integrate with the entire QuickBooks Desktop API with fully-typed async TypeScript",
5
5
  "author": "Danny Nemer <hi@DannyNemer.com>",
6
6
  "license": "MIT",
@@ -12,8 +12,8 @@
12
12
  "dist/package.json"
13
13
  ],
14
14
  "scripts": {
15
- "prepack": "yarn tsc && yarn delete-compiled-tests && yarn tsc-alias --verbose",
16
- "delete-compiled-tests": "rm -rf `find ./dist -type d -name __tests__` ./dist/src/utils/testing.*",
15
+ "prepack": "yarn tsc && yarn delete-compiled-dev-files && yarn tsc-alias --verbose",
16
+ "delete-compiled-dev-files": "rm -rf `find ./dist -type d -name __tests__` ./dist/src/utils/testing.* ./dist/src/graphql/codegenConfig.*",
17
17
  "postpack": "rm -rf dist",
18
18
  "clean": "rm -rf dist package conductor-node-*.tgz tsconfig.tsbuildinfo",
19
19
  "gen:graphql": "yarn graphql-codegen --config=./src/graphql/codegenConfig.ts",
@@ -1,3 +0,0 @@
1
- import type { CodegenConfig } from "@graphql-codegen/cli";
2
- declare const codegenConfig: CodegenConfig;
3
- export default codegenConfig;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const codegenConfig = {
4
- schema: "../server/src/graphql/__generated__/schema.graphql",
5
- hooks: { afterOneFileWrite: ["yarn prettier --write"] },
6
- documents: ["./src/graphql/operations.graphql"],
7
- ignoreNoDocuments: true,
8
- generates: {
9
- "./src/graphql/__generated__/operationTypes.ts": {
10
- plugins: [
11
- "typescript",
12
- "typescript-operations",
13
- "typescript-graphql-request",
14
- {
15
- add: {
16
- content: [
17
- "/* eslint-disable eslint-comments/no-unlimited-disable -- Auto-generated */",
18
- "/* eslint-disable -- Auto-generated */",
19
- ].join("\n"),
20
- },
21
- },
22
- ],
23
- config: {
24
- // Avoid including `__typename` in objects we return to dev-users.
25
- skipTypename: true,
26
- // Use `import type {}` rather than `import {}`.
27
- useTypeImports: true,
28
- // Only emit types used in `operations.graphql`. This avoids confusion
29
- // by creating types with more fields than the client actually returns
30
- // (e.g. `IntegrationConnection` vs. `IntegrationConnectionFragment`)).
31
- onlyOperationTypes: true,
32
- avoidOptionals: true,
33
- typesPrefix: "Graphql",
34
- // Avoid adding `graphql-tag` as a client dependency.
35
- documentMode: "string",
36
- scalars: {
37
- DateTime: "Date",
38
- JSONObject: "object",
39
- },
40
- strictScalars: true,
41
- },
42
- },
43
- },
44
- };
45
- exports.default = codegenConfig;