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 +14 -14
- package/dist/package.json +3 -3
- package/dist/src/Client.d.ts +1 -1
- package/dist/src/Client.js +3 -3
- package/dist/src/graphql/graphqlOperationWrapper.d.ts +1 -1
- package/dist/src/graphql/graphqlOperationWrapper.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +4 -4
- package/dist/src/integrations/qbd/QbdIntegration.js +1 -1
- package/dist/src/{error.d.ts → utils/error.d.ts} +13 -11
- package/dist/src/{error.js → utils/error.js} +13 -11
- package/dist/src/{utils.d.ts → utils/misc.d.ts} +1 -1
- package/dist/src/{utils.js → utils/misc.js} +1 -1
- package/package.json +3 -3
- package/dist/src/graphql/codegenConfig.d.ts +0 -3
- package/dist/src/graphql/codegenConfig.js +0 -45
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
|
|
181
|
-
| `ConductorIntegrationConnectionError` | Raised when
|
|
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
|
-
###
|
|
230
|
+
### Centralized Error Handling
|
|
231
231
|
|
|
232
|
-
|
|
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.
|
|
235
|
-
2.
|
|
236
|
-
- Send a **warning** for instances of `ConductorIntegrationConnectionError`, which only the end-user
|
|
237
|
-
- Send an **error** for all other `ConductorError` instances
|
|
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.
|
|
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-
|
|
16
|
-
"delete-compiled-
|
|
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",
|
package/dist/src/Client.d.ts
CHANGED
|
@@ -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;
|
package/dist/src/Client.js
CHANGED
|
@@ -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
|
|
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,
|
|
19
|
-
this.graphqlClient = new graphql_request_1.GraphQLClient(`${(0,
|
|
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) {
|
package/dist/src/index.d.ts
CHANGED
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
|
|
80
|
-
*
|
|
81
|
-
* data handling that
|
|
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
|
|
84
|
+
* accounting value you supplied did not adhere to the integration's accounting
|
|
85
|
+
* rules.
|
|
85
86
|
*
|
|
86
|
-
*
|
|
87
|
-
* if
|
|
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
|
|
95
|
-
*
|
|
96
|
-
* integration connection or configuration
|
|
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
|
-
*
|
|
102
|
-
*
|
|
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
|
|
88
|
-
*
|
|
89
|
-
* data handling that
|
|
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
|
|
92
|
+
* accounting value you supplied did not adhere to the integration's accounting
|
|
93
|
+
* rules.
|
|
93
94
|
*
|
|
94
|
-
*
|
|
95
|
-
* if
|
|
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
|
|
106
|
-
*
|
|
107
|
-
* integration connection or configuration
|
|
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
|
-
*
|
|
113
|
-
*
|
|
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("
|
|
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.
|
|
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-
|
|
16
|
-
"delete-compiled-
|
|
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,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;
|