conductor-node 3.8.5 → 4.0.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 +9 -8
- package/dist/package.json +2 -2
- package/dist/src/Client.d.ts +5 -4
- package/dist/src/Client.js +26 -5
- package/dist/src/environment.d.ts +8 -1
- package/dist/src/environment.js +15 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Conductor
|
|
1
|
+
# Conductor - QuickBooks Desktop Integration
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Execute _any_ read or write [QuickBooks Desktop API](https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop) through async TypeScript and receive a fully-typed response.
|
|
4
4
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
@@ -15,16 +15,17 @@ yarn add conductor-node
|
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
18
|
-
Instantiate `Conductor` with your account's secret key, which is available from Danny.
|
|
19
|
-
|
|
20
|
-
The `Conductor` instance can execute _any_ read or write [QuickBooks Desktop API](https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop) through TypeScript and receive a fully-typed response. Each request requires the integration-user-connection id of a specific QuickBooks Desktop user.
|
|
21
|
-
|
|
22
18
|
```ts
|
|
23
19
|
import Conductor from "conductor-node";
|
|
20
|
+
|
|
21
|
+
// Instantiate `Conductor` with your account's secret key.
|
|
24
22
|
const conductor = new Conductor("sk_test_...");
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
const
|
|
24
|
+
// Fetch all authorized integration-user-connections.
|
|
25
|
+
const qbdConnections = await client.getIntegrationUserConnections();
|
|
26
|
+
|
|
27
|
+
// Execute any QBD API against your QBD connection id.
|
|
28
|
+
const newAccount = await conductor.qbd.account.add(qbdConnections[0].id, {
|
|
28
29
|
Name: "Test Account",
|
|
29
30
|
AccountType: "Bank",
|
|
30
31
|
OpenBalance: "100",
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conductor-node",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Easily integrate with the entire QuickBooks Desktop API with fully-type async TypeScript",
|
|
5
5
|
"author": "Danny Nemer <hi@DannyNemer.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "commonjs",
|
package/dist/src/Client.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Environment } from "./environment";
|
|
2
2
|
import QbdIntegration from "./integrations/qbd/QbdIntegration";
|
|
3
3
|
export interface ClientOptions {
|
|
4
|
-
/** Log
|
|
4
|
+
/** Log each request and response. */
|
|
5
5
|
verbose?: boolean;
|
|
6
|
-
|
|
6
|
+
serverEnvironment?: Environment;
|
|
7
7
|
}
|
|
8
8
|
export interface IntegrationRequestParams {
|
|
9
9
|
integrationUserConnectionId: string;
|
|
@@ -15,8 +15,9 @@ export default class Client {
|
|
|
15
15
|
private readonly serverURL;
|
|
16
16
|
private readonly gqlClient;
|
|
17
17
|
private readonly verbose;
|
|
18
|
-
constructor(apiKey: string, { verbose,
|
|
19
|
-
|
|
18
|
+
constructor(apiKey: string, { verbose, serverEnvironment }?: ClientOptions);
|
|
19
|
+
getIntegrationUserConnection(integrationUserConnectionId: string): Promise<object>;
|
|
20
|
+
getIntegrationUserConnections(): Promise<object[]>;
|
|
20
21
|
integrationRequest(integrationRequestParams: IntegrationRequestParams): Promise<object>;
|
|
21
22
|
private request;
|
|
22
23
|
private checkForUpdates;
|
package/dist/src/Client.js
CHANGED
|
@@ -14,10 +14,10 @@ class Client {
|
|
|
14
14
|
serverURL;
|
|
15
15
|
gqlClient;
|
|
16
16
|
verbose;
|
|
17
|
-
constructor(apiKey, { verbose = false,
|
|
17
|
+
constructor(apiKey, { verbose = false, serverEnvironment = "staging" } = {}) {
|
|
18
18
|
this.checkForUpdates();
|
|
19
19
|
this.verbose = verbose;
|
|
20
|
-
this.serverURL = (0, environment_1.envToBaseServerURL)(
|
|
20
|
+
this.serverURL = (0, environment_1.envToBaseServerURL)(serverEnvironment);
|
|
21
21
|
this.gqlClient = new graphql_request_1.GraphQLClient(`${this.serverURL}/graphql`, {
|
|
22
22
|
headers: {
|
|
23
23
|
Authorization: `Bearer ${apiKey}`,
|
|
@@ -26,7 +26,24 @@ class Client {
|
|
|
26
26
|
});
|
|
27
27
|
this.qbd = new QbdIntegration_1.default(this);
|
|
28
28
|
}
|
|
29
|
-
async
|
|
29
|
+
async getIntegrationUserConnection(integrationUserConnectionId) {
|
|
30
|
+
const data = await this.request(`#graphql
|
|
31
|
+
query GetIntegrationUserConnection($integrationUserConnectionId: ID!) {
|
|
32
|
+
integrationUserConnection(id: $integrationUserConnectionId) {
|
|
33
|
+
id
|
|
34
|
+
integration {
|
|
35
|
+
id
|
|
36
|
+
name
|
|
37
|
+
}
|
|
38
|
+
qbwcUsername
|
|
39
|
+
lastHeartbeatAt
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`, { integrationUserConnectionId });
|
|
43
|
+
// @ts-expect-error - This will pass after we integrate GQL codegen.
|
|
44
|
+
return data.integrationUserConnection;
|
|
45
|
+
}
|
|
46
|
+
async getIntegrationUserConnections() {
|
|
30
47
|
const data = await this.request(`#graphql
|
|
31
48
|
query {
|
|
32
49
|
integrationUserConnections {
|
|
@@ -35,7 +52,8 @@ class Client {
|
|
|
35
52
|
id
|
|
36
53
|
name
|
|
37
54
|
}
|
|
38
|
-
|
|
55
|
+
qbwcUsername
|
|
56
|
+
lastHeartbeatAt
|
|
39
57
|
}
|
|
40
58
|
}
|
|
41
59
|
`);
|
|
@@ -72,7 +90,7 @@ class Client {
|
|
|
72
90
|
}
|
|
73
91
|
if (error instanceof graphql_request_1.ClientError) {
|
|
74
92
|
const errorMessage = error.response.errors?.[0]?.message ??
|
|
75
|
-
// Though property `ClientError.response.error` does *not* exist,
|
|
93
|
+
// Though the property `ClientError.response.error` does *not* exist,
|
|
76
94
|
// we've seen it occur (e.g., attempting to access `development`
|
|
77
95
|
// environment when `ngrok` is not running locally).
|
|
78
96
|
error.response["error"];
|
|
@@ -84,6 +102,9 @@ class Client {
|
|
|
84
102
|
}
|
|
85
103
|
}
|
|
86
104
|
checkForUpdates() {
|
|
105
|
+
if (environment_1.currentEnvironment.isTest) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
87
108
|
const currentVersion = package_json_1.default.version;
|
|
88
109
|
const latestVersion = (0, node_child_process_1.execSync)(`yarn info ${package_json_1.default.name} version`)
|
|
89
110
|
.toString()
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
export declare type Environment = "development" | "staging";
|
|
1
|
+
export declare type Environment = "development" | "production" | "staging" | "test";
|
|
2
2
|
export declare function envToBaseServerURL(environment: Environment): string;
|
|
3
|
+
export declare const currentEnvironment: {
|
|
4
|
+
name: string;
|
|
5
|
+
isTest: boolean;
|
|
6
|
+
isDevelopment: boolean;
|
|
7
|
+
isStaging: boolean;
|
|
8
|
+
isProduction: boolean;
|
|
9
|
+
};
|
package/dist/src/environment.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.envToBaseServerURL = void 0;
|
|
4
|
-
const STAGING_BASE_URL = "https://staging.api.conductor.is";
|
|
5
|
-
const DEVELOPMENT_BASE_URL = "https://conductor.ngrok.io";
|
|
3
|
+
exports.currentEnvironment = exports.envToBaseServerURL = void 0;
|
|
6
4
|
function envToBaseServerURL(environment) {
|
|
7
5
|
switch (environment) {
|
|
6
|
+
case "development": {
|
|
7
|
+
return "https://conductor.ngrok.io";
|
|
8
|
+
}
|
|
8
9
|
case "staging": {
|
|
9
|
-
return
|
|
10
|
+
return "https://staging.api.conductor.is";
|
|
10
11
|
}
|
|
11
|
-
case "
|
|
12
|
-
return
|
|
12
|
+
case "production": {
|
|
13
|
+
return "https://production.api.conductor.is";
|
|
13
14
|
}
|
|
14
15
|
default: {
|
|
15
16
|
throw new Error("Invalid environment");
|
|
@@ -17,3 +18,11 @@ function envToBaseServerURL(environment) {
|
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
exports.envToBaseServerURL = envToBaseServerURL;
|
|
21
|
+
const currentEnvironmentName = process.env["NODE_ENV"] ?? "development";
|
|
22
|
+
exports.currentEnvironment = {
|
|
23
|
+
name: currentEnvironmentName,
|
|
24
|
+
isTest: currentEnvironmentName === "test",
|
|
25
|
+
isDevelopment: currentEnvironmentName === "development",
|
|
26
|
+
isStaging: currentEnvironmentName === "staging",
|
|
27
|
+
isProduction: currentEnvironmentName === "production",
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conductor-node",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Easily integrate with the entire QuickBooks Desktop API with fully-type async TypeScript",
|
|
5
5
|
"author": "Danny Nemer <hi@DannyNemer.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "commonjs",
|