conductor-node 6.2.1 → 6.2.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/dist/package.json +1 -1
- package/dist/src/Client.d.ts +2 -7
- package/dist/src/Client.js +35 -26
- package/dist/src/graphqlTypes.d.ts +1 -3
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/src/Client.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import type { Environment } from "./environment";
|
|
2
|
-
import type { IntegrationConnection } from "./graphqlTypes";
|
|
2
|
+
import type { IntegrationConnection, IntegrationRequestInput } from "./graphqlTypes";
|
|
3
3
|
import QbdIntegration from "./integrations/qbd/QbdIntegration";
|
|
4
4
|
export interface ClientOptions {
|
|
5
5
|
/** Log each request and response. */
|
|
6
6
|
verbose?: boolean;
|
|
7
7
|
serverEnvironment?: Environment;
|
|
8
8
|
}
|
|
9
|
-
interface IntegrationRequestParams {
|
|
10
|
-
integrationConnectionId: string;
|
|
11
|
-
requestObject: object;
|
|
12
|
-
}
|
|
13
9
|
export default class Client {
|
|
14
10
|
/** QuickBooks Desktop integration. */
|
|
15
11
|
readonly qbd: QbdIntegration;
|
|
@@ -22,8 +18,7 @@ export default class Client {
|
|
|
22
18
|
createIntegrationConnection(qbwcUsername: string): Promise<IntegrationConnection>;
|
|
23
19
|
isIntegrationConnectionActive(integrationConnectionId: string, secondsSinceLastActive?: number): Promise<boolean>;
|
|
24
20
|
logConnectionStatuses(): Promise<void>;
|
|
25
|
-
integrationRequest(
|
|
21
|
+
integrationRequest(input: IntegrationRequestInput): Promise<object>;
|
|
26
22
|
private request;
|
|
27
23
|
private checkForUpdates;
|
|
28
24
|
}
|
|
29
|
-
export {};
|
package/dist/src/Client.js
CHANGED
|
@@ -28,7 +28,8 @@ class Client {
|
|
|
28
28
|
this.qbd = new QbdIntegration_1.default(this);
|
|
29
29
|
}
|
|
30
30
|
async getIntegrationConnectionById(integrationConnectionId) {
|
|
31
|
-
const data = (await this.request(
|
|
31
|
+
const data = (await this.request(
|
|
32
|
+
/* GraphQL */ `
|
|
32
33
|
query GetIntegrationConnectionById($integrationConnectionId: ID!) {
|
|
33
34
|
integrationConnection(id: $integrationConnectionId) {
|
|
34
35
|
id
|
|
@@ -44,25 +45,28 @@ class Client {
|
|
|
44
45
|
return data.integrationConnection;
|
|
45
46
|
}
|
|
46
47
|
async getIntegrationConnections() {
|
|
47
|
-
const data = (await this.request(
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const data = (await this.request(/* GraphQL */ `
|
|
49
|
+
query {
|
|
50
|
+
integrationConnections {
|
|
51
|
+
id
|
|
52
|
+
integration {
|
|
50
53
|
id
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
name
|
|
54
|
-
key
|
|
55
|
-
}
|
|
56
|
-
qbwcUsername
|
|
57
|
-
lastHeartbeatAt
|
|
54
|
+
name
|
|
55
|
+
key
|
|
58
56
|
}
|
|
57
|
+
qbwcUsername
|
|
58
|
+
lastHeartbeatAt
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
}
|
|
61
|
+
`));
|
|
61
62
|
return data.integrationConnections;
|
|
62
63
|
}
|
|
63
64
|
async createIntegrationConnection(qbwcUsername) {
|
|
64
|
-
const data = (await this.request(
|
|
65
|
-
|
|
65
|
+
const data = (await this.request(
|
|
66
|
+
/* GraphQL */ `
|
|
67
|
+
mutation CreateIntegrationConnection(
|
|
68
|
+
$input: IntegrationConnectionInput!
|
|
69
|
+
) {
|
|
66
70
|
createIntegrationConnection(input: $input) {
|
|
67
71
|
id
|
|
68
72
|
integration {
|
|
@@ -83,14 +87,18 @@ class Client {
|
|
|
83
87
|
return data.createIntegrationConnection;
|
|
84
88
|
}
|
|
85
89
|
async isIntegrationConnectionActive(integrationConnectionId, secondsSinceLastActive = 10) {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
const data = (await this.request(
|
|
91
|
+
/* GraphQL */ `
|
|
92
|
+
query IsIntegrationConnectionActive(
|
|
93
|
+
$integrationConnectionId: ID!
|
|
94
|
+
$secondsSinceLastActive: Int!
|
|
95
|
+
) {
|
|
96
|
+
integrationConnection(id: $integrationConnectionId) {
|
|
97
|
+
isActive(secondsSinceLastActive: $secondsSinceLastActive)
|
|
98
|
+
}
|
|
89
99
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const secondsSinceLastActiveActual = (now.getTime() - lastHeartbeatAt.getTime()) / 1000;
|
|
93
|
-
return secondsSinceLastActiveActual <= secondsSinceLastActive;
|
|
100
|
+
`, { integrationConnectionId, secondsSinceLastActive }));
|
|
101
|
+
return data.integrationConnection.isActive;
|
|
94
102
|
}
|
|
95
103
|
async logConnectionStatuses() {
|
|
96
104
|
const integrationConnections = (await this.getIntegrationConnections());
|
|
@@ -109,12 +117,13 @@ class Client {
|
|
|
109
117
|
}
|
|
110
118
|
// TODO: Hide this method from the dev user while still allowing the
|
|
111
119
|
// integration clients to access it.
|
|
112
|
-
async integrationRequest(
|
|
113
|
-
const response = await this.request(
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
async integrationRequest(input) {
|
|
121
|
+
const response = await this.request(
|
|
122
|
+
/* GraphQL */ `
|
|
123
|
+
query IntegrationRequest($input: IntegrationRequestInput!) {
|
|
124
|
+
integrationRequest(input: $input)
|
|
116
125
|
}
|
|
117
|
-
`, {
|
|
126
|
+
`, { input });
|
|
118
127
|
// @ts-expect-error - This will pass after we integrate GQL codegen.
|
|
119
128
|
return response.integrationRequest;
|
|
120
129
|
}
|
|
@@ -5,13 +5,11 @@ export interface Integration {
|
|
|
5
5
|
}
|
|
6
6
|
export interface IntegrationConnection {
|
|
7
7
|
id: string;
|
|
8
|
-
devUserId: string;
|
|
9
8
|
integration: Integration;
|
|
10
9
|
qbwcUsername: string;
|
|
11
|
-
qbwcPassword: string;
|
|
12
10
|
lastHeartbeatAt: string | null;
|
|
13
11
|
}
|
|
14
|
-
export interface
|
|
12
|
+
export interface IntegrationRequestInput {
|
|
15
13
|
integrationConnectionId: string;
|
|
16
14
|
requestObject: object;
|
|
17
15
|
}
|