conductor-node 11.0.2 → 11.0.4
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 +6 -267
- package/dist/package.json +2 -4
- package/dist/src/integrations/qbd/QbdIntegration.d.ts +358 -73
- package/dist/src/integrations/qbd/QbdIntegration.js +358 -73
- package/dist/src/interceptors/errorHandling.js +7 -2
- package/dist/src/interceptors/logging.js +3 -1
- package/dist/src/resources/EndUsersResource.d.ts +3 -0
- package/dist/src/utils/checkForUpdates.js +8 -4
- package/dist/src/utils/error.d.ts +6 -1
- package/dist/src/utils/error.js +9 -1
- package/package.json +2 -4
|
@@ -12,6 +12,8 @@ function addErrorHandlingInterceptors(httpClient) {
|
|
|
12
12
|
const errorData = error.response.data;
|
|
13
13
|
if ((0, error_1.isWellFormedConductorServerError)(errorData)) {
|
|
14
14
|
throw (0, error_1.generateConductorErrorFromType)({
|
|
15
|
+
// The request ID is already in the response body, so no need to
|
|
16
|
+
// copy it from the headers.
|
|
15
17
|
...errorData.error,
|
|
16
18
|
httpStatusCode: error.response.status,
|
|
17
19
|
headers,
|
|
@@ -21,9 +23,12 @@ function addErrorHandlingInterceptors(httpClient) {
|
|
|
21
23
|
message: "Invalid JSON received from the Conductor API.",
|
|
22
24
|
code: "INVALID_JSON_RESPONSE",
|
|
23
25
|
httpStatusCode: error.status ?? axios_1.HttpStatusCode.InternalServerError,
|
|
24
|
-
// @ts-expect-error -- `error.response.headers`
|
|
26
|
+
// @ts-expect-error -- `error.response.headers` always exists as an `AxiosHeaders` instance.
|
|
25
27
|
requestId: error.response.headers.get("request-id"),
|
|
26
28
|
headers,
|
|
29
|
+
// Include to understand why `isWellFormedConductorServerError()`
|
|
30
|
+
// failed.
|
|
31
|
+
raw: errorData,
|
|
27
32
|
});
|
|
28
33
|
}
|
|
29
34
|
if (error.code === axios_1.AxiosError.ECONNABORTED) {
|
|
@@ -41,7 +46,7 @@ function addErrorHandlingInterceptors(httpClient) {
|
|
|
41
46
|
// Conductor API is offline) or an error ocurred when setting up the
|
|
42
47
|
// request (e.g., no network connection).
|
|
43
48
|
throw new error_1.ConductorConnectionError({
|
|
44
|
-
message:
|
|
49
|
+
message: `An error occurred with our connection to Conductor: ${error.message}`,
|
|
45
50
|
code: error.code ?? "NETWORK_ERROR",
|
|
46
51
|
httpStatusCode: error.status,
|
|
47
52
|
});
|
|
@@ -24,7 +24,9 @@ function addLoggingInterceptors(httpClient, verbose) {
|
|
|
24
24
|
// NOTE: We cannot include duration because we lack access to
|
|
25
25
|
// `AxiosError.config` because we already wrapped the error.
|
|
26
26
|
if (verbose) {
|
|
27
|
-
|
|
27
|
+
// No prefix "Conductor error:" because the error already includes a
|
|
28
|
+
// prefix (e.g., `ConductorConnectionError`).
|
|
29
|
+
console.log(stringifyForLogs(error));
|
|
28
30
|
}
|
|
29
31
|
throw error;
|
|
30
32
|
});
|
|
@@ -25,6 +25,9 @@ export interface EndUser {
|
|
|
25
25
|
}
|
|
26
26
|
export type EndUserCreateInput = Pick<EndUser, "email" | "name" | "sourceId">;
|
|
27
27
|
export interface EndUserPingOutput {
|
|
28
|
+
/**
|
|
29
|
+
* The time, in milliseconds, that it took to ping the connection.
|
|
30
|
+
*/
|
|
28
31
|
readonly duration: number;
|
|
29
32
|
}
|
|
30
33
|
export default class EndUsersResource extends BaseResource {
|
|
@@ -5,21 +5,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.checkForUpdates = void 0;
|
|
7
7
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
8
|
-
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
const node_child_process_1 = __importDefault(require("node:child_process"));
|
|
9
9
|
function checkForUpdates() {
|
|
10
10
|
// Exit early if npm is not installed.
|
|
11
11
|
try {
|
|
12
|
-
|
|
12
|
+
node_child_process_1.default.execSync("which npm");
|
|
13
13
|
}
|
|
14
14
|
catch {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
const currentVersion = package_json_1.default.version;
|
|
18
|
-
const latestVersion =
|
|
18
|
+
const latestVersion = node_child_process_1.default
|
|
19
|
+
.execSync(`npm view ${package_json_1.default.name} version --silent`)
|
|
19
20
|
.toString()
|
|
20
21
|
.trim();
|
|
21
22
|
if (currentVersion !== latestVersion) {
|
|
22
|
-
|
|
23
|
+
const updateCommand = process.env["npm_execpath"]?.includes("yarn") === true
|
|
24
|
+
? "yarn add"
|
|
25
|
+
: "npm install";
|
|
26
|
+
console.warn(`⚠️ Update available for Conductor: ${currentVersion} -> ${latestVersion}. To update, run: ${updateCommand} ${package_json_1.default.name}@latest`);
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
exports.checkForUpdates = checkForUpdates;
|
|
@@ -8,6 +8,7 @@ export interface ConductorErrorOptions {
|
|
|
8
8
|
readonly integrationCode?: string | undefined;
|
|
9
9
|
readonly requestId?: string | undefined;
|
|
10
10
|
readonly headers?: Record<string, string>;
|
|
11
|
+
readonly raw?: unknown;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* The raw REST error response that Conductor's API returns.
|
|
@@ -89,7 +90,11 @@ export declare abstract class ConductorError extends Error {
|
|
|
89
90
|
*/
|
|
90
91
|
readonly headers: Record<string, string> | undefined;
|
|
91
92
|
/**
|
|
92
|
-
* The
|
|
93
|
+
* The raw REST error response that Conductor's API returned.
|
|
94
|
+
*/
|
|
95
|
+
protected readonly raw: unknown;
|
|
96
|
+
/**
|
|
97
|
+
* Conductor's internal representation of `type` for debugging.
|
|
93
98
|
*/
|
|
94
99
|
protected readonly rawType: string;
|
|
95
100
|
constructor(options: ConductorErrorOptions);
|
package/dist/src/utils/error.js
CHANGED
|
@@ -80,7 +80,11 @@ class ConductorError extends Error {
|
|
|
80
80
|
*/
|
|
81
81
|
headers;
|
|
82
82
|
/**
|
|
83
|
-
* The
|
|
83
|
+
* The raw REST error response that Conductor's API returned.
|
|
84
|
+
*/
|
|
85
|
+
raw;
|
|
86
|
+
/**
|
|
87
|
+
* Conductor's internal representation of `type` for debugging.
|
|
84
88
|
*/
|
|
85
89
|
rawType;
|
|
86
90
|
constructor(options) {
|
|
@@ -105,6 +109,10 @@ class ConductorError extends Error {
|
|
|
105
109
|
this.integrationCode = options.integrationCode;
|
|
106
110
|
this.requestId = options.requestId;
|
|
107
111
|
this.headers = options.headers;
|
|
112
|
+
// Only set `raw` if provided instead of always setting it to `options`
|
|
113
|
+
// because the latter is usually a near duplicate of `this`, which we don't
|
|
114
|
+
// want to log unless necessary.
|
|
115
|
+
this.raw = options.raw;
|
|
108
116
|
this.rawType = options.type;
|
|
109
117
|
}
|
|
110
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conductor-node",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.4",
|
|
4
4
|
"description": "Easily integrate the entire QuickBooks Desktop API using fully-typed async TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"QuickBooks Desktop",
|
|
@@ -26,9 +26,7 @@
|
|
|
26
26
|
"postpack": "rm -rf dist",
|
|
27
27
|
"clean": "rm -rf dist package conductor-node-*.tgz tsconfig.tsbuildinfo",
|
|
28
28
|
"diff": "yarn pack && npm diff --diff=conductor-node@latest --diff=conductor-node-v$(node -p \"require('./package.json').version\").tgz && yarn clean",
|
|
29
|
-
"prepublishOnly": "yarn
|
|
30
|
-
"test": "yarn --cwd=../../ test ./packages/client",
|
|
31
|
-
"jest": "yarn --cwd=../../ jest"
|
|
29
|
+
"prepublishOnly": "yarn jest"
|
|
32
30
|
},
|
|
33
31
|
"engines": {
|
|
34
32
|
"node": ">=16"
|