conductor-node 3.1.1 → 3.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-node",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "Conductor API wrapper",
5
5
  "author": "Danny Nemer <hi@DannyNemer.com>",
6
6
  "license": "MIT",
@@ -12,8 +12,10 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "prepack": "yarn tsc && yarn tsc-alias",
15
- "postpack": "rm -rf dist",
16
- "test-staging": "yarn ts-node ./test/sendMockRequest"
15
+ "postpack": "rm -rf dist"
16
+ },
17
+ "engines": {
18
+ "node": ">=16"
17
19
  },
18
20
  "devDependencies": {
19
21
  "tsc-alias": "^1.7.0"
@@ -1,5 +0,0 @@
1
- import type Client from "./Client";
2
- export default class BaseClient {
3
- protected readonly root: Client;
4
- constructor(client: Client);
5
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class BaseClient {
4
- root;
5
- constructor(client) {
6
- this.root = client;
7
- }
8
- }
9
- exports.default = BaseClient;
@@ -1,21 +0,0 @@
1
- import type { Environment } from "./environment";
2
- import ClientQbd from "./qbd/ClientQbd";
3
- export interface ClientOptions {
4
- /** Log the each request and response. */
5
- verbose?: boolean;
6
- environment?: Environment;
7
- }
8
- export interface IntegrationRequestParams {
9
- integrationUserConnectionId: string;
10
- requestObject: object;
11
- }
12
- export default class Client {
13
- /** QuickBooks Desktop integration. */
14
- readonly qbd: ClientQbd;
15
- private readonly serverURL;
16
- private readonly gqlClient;
17
- private readonly verbose;
18
- constructor(apiKey: string, { verbose, environment }?: ClientOptions);
19
- integrationUserConnections(): Promise<object[]>;
20
- integrationRequest(integrationRequestParams: IntegrationRequestParams): Promise<object>;
21
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const environment_1 = require("./environment");
7
- const ClientQbd_1 = __importDefault(require("./qbd/ClientQbd"));
8
- const graphql_request_1 = require("graphql-request");
9
- class Client {
10
- /** QuickBooks Desktop integration. */
11
- qbd;
12
- serverURL;
13
- gqlClient;
14
- verbose;
15
- constructor(apiKey, { verbose = false, environment = "staging" } = {}) {
16
- this.verbose = verbose;
17
- this.serverURL = (0, environment_1.envToBaseServerURL)(environment);
18
- this.gqlClient = new graphql_request_1.GraphQLClient(`${this.serverURL}/graphql`, {
19
- headers: {
20
- authorization: `Bearer ${apiKey}`,
21
- },
22
- });
23
- this.qbd = new ClientQbd_1.default(this);
24
- }
25
- async integrationUserConnections() {
26
- const data = await this.gqlClient.request(`#graphql
27
- query {
28
- integrationUserConnections {
29
- id
30
- integration {
31
- id
32
- name
33
- }
34
- username
35
- }
36
- }
37
- `);
38
- // @ts-expect-error - This will pass after we integrate GQL codegen.
39
- return data.integrationUserConnections;
40
- }
41
- // TODO: Hide this method from the dev user while still allowing the
42
- // integration clients to access it.
43
- async integrationRequest(integrationRequestParams) {
44
- if (this.verbose) {
45
- console.log(`Client sent request to ${this.serverURL}:`, JSON.stringify(integrationRequestParams, null, 2));
46
- console.time("Request time");
47
- }
48
- const response = await this.gqlClient.request(`#graphql
49
- query IntegrationRequest($integrationRequestParams: IntegrationRequestParams!) {
50
- integrationRequest(integrationRequestParams: $integrationRequestParams)
51
- }
52
- `, { integrationRequestParams });
53
- // @ts-expect-error - This will pass after we integrate GQL codegen.
54
- const responseBody = response.integrationRequest;
55
- if (this.verbose) {
56
- console.timeEnd("Request time");
57
- console.log(`Client received response from ${this.serverURL}:`, JSON.stringify(responseBody, null, 2));
58
- }
59
- return responseBody;
60
- }
61
- }
62
- exports.default = Client;
@@ -1,2 +0,0 @@
1
- export declare type Environment = "development" | "staging";
2
- export declare function envToBaseServerURL(environment: Environment): string;
@@ -1,16 +0,0 @@
1
- "use strict";
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";
6
- function envToBaseServerURL(environment) {
7
- switch (environment) {
8
- case "staging":
9
- return STAGING_BASE_URL;
10
- case "development":
11
- return DEVELOPMENT_BASE_URL;
12
- default:
13
- throw new Error("Invalid environment");
14
- }
15
- }
16
- exports.envToBaseServerURL = envToBaseServerURL;
@@ -1,252 +0,0 @@
1
- import BaseClient from "../BaseClient";
2
- import type * as qbd from "../qbd/qbdTypes";
3
- export default class ClientQbd extends BaseClient {
4
- account: {
5
- /**
6
- * Perform the same activities as a user does in the QB New Account form,
7
- * which can be accessed in QB by selecting "Lists" → "Chart of Accounts" →
8
- * "Accounts" → "New".
9
- *
10
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountAdd
11
- */
12
- add: (integrationUserConnectionId: string, params: qbd.AccountAddRq["AccountAdd"]) => Promise<NonNullable<qbd.AccountAddRs["AccountRet"]>>;
13
- /**
14
- * Modifies an account.
15
- *
16
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountMod
17
- */
18
- mod: (integrationUserConnectionId: string, params: qbd.AccountModRq["AccountMod"]) => Promise<NonNullable<qbd.AccountModRs["AccountRet"]>>;
19
- /**
20
- * `AccountQuery` is a list query that returns data for all accounts that
21
- * match the provided filter criteria. Notice that it returns only data
22
- * internal to the account itself. It does not return any data about
23
- * transactions involving the account. It does, however, return the parent
24
- * account, if there is one. You can search across all accounts or you can
25
- * specify an account type and search only those.
26
- *
27
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/AccountQuery
28
- */
29
- query: (integrationUserConnectionId: string, params: qbd.AccountQueryRq) => Promise<NonNullable<qbd.AccountQueryRs["AccountRet"]>>;
30
- };
31
- customer: {
32
- /**
33
- * The customer list includes information about the QuickBooks user’s
34
- * customers and the individual jobs that are being performed for them. A
35
- * `CustomerRef` aggregate refers to one of the customers (or customer jobs)
36
- * on the list. In a request, if a `CustomerRef` aggregate includes both
37
- * `FullName` and `ListID`, `FullName` will be ignored. Special cases to
38
- * note:
39
- *
40
- * - In `SalesReceipt` and `ReceivePayment` requests, `CustomerRef` refers
41
- * to the customer or customer job to which the payment is credited.
42
- *
43
- * - In a `TimeTracking` request, CustomerRef refers to the customer or
44
- * customer job to which this time could be billed. If `IsBillable` is set
45
- * to true, `CustomerRef` is required in `TimeTrackingAdd`.
46
- *
47
- * - In an `ExpenseLineAdd` request, if `AccountRef` refers to an A/P
48
- * account, `CustomerRef` must refer to a vendor (not to a customer). If
49
- * `AccountRef` refers to any other type of account, the `CustomerRef`
50
- * must refer to a customer.
51
- *
52
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerAdd
53
- */
54
- add: (integrationUserConnectionId: string, params: qbd.CustomerAddRq["CustomerAdd"]) => Promise<NonNullable<qbd.CustomerAddRs["CustomerRet"]>>;
55
- /**
56
- * Modifies the customer record.
57
- *
58
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerMod
59
- */
60
- mod: (integrationUserConnectionId: string, params: qbd.CustomerModRq["CustomerMod"]) => Promise<NonNullable<qbd.CustomerModRs["CustomerRet"]>>;
61
- /**
62
- * Returns data for the specified customers.
63
- *
64
- * Important: We highly recommend that you use the `IncludeRetElement` tag
65
- * in your `CustomerQuery` to include any data you want but do NOT include
66
- * the `ShipAddress` data in the `Response`, unless you need to get the
67
- * shipping address for a particular customer. Excluding the shipping
68
- * address data will significantly improve the performance of the
69
- * `CustomerQuery`.
70
- *
71
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/CustomerQuery
72
- */
73
- query: (integrationUserConnectionId: string, params: qbd.CustomerQueryRq) => Promise<NonNullable<qbd.CustomerQueryRs["CustomerRet"]>>;
74
- };
75
- employee: {
76
- /**
77
- * Adds an employee with personal data about the employee as well as certain
78
- * payroll-related data.
79
- *
80
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeAdd
81
- */
82
- add: (integrationUserConnectionId: string, params: qbd.EmployeeAddRq["EmployeeAdd"]) => Promise<NonNullable<qbd.EmployeeAddRs["EmployeeRet"]>>;
83
- /**
84
- * Modifies an existing employee.
85
- *
86
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeMod
87
- */
88
- mod: (integrationUserConnectionId: string, params: qbd.EmployeeModRq["EmployeeMod"]) => Promise<NonNullable<qbd.EmployeeModRs["EmployeeRet"]>>;
89
- /**
90
- * Returns employee data.
91
- *
92
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/EmployeeQuery
93
- */
94
- query: (integrationUserConnectionId: string, params: qbd.EmployeeQueryRq) => Promise<NonNullable<qbd.EmployeeQueryRs["EmployeeRet"]>>;
95
- };
96
- journalEntry: {
97
- /**
98
- * The debit and credit lines can be intermingled. A credit line can legally
99
- * come first in the journal entry add.
100
- *
101
- * In traditional accounting, transactions are entered into the general
102
- * journal and categorized exclusively by account. In QuickBooks, most
103
- * transactions can be categorized either by account or by type (invoice,
104
- * check, and so on). For a few activities in QuickBooks, you must use the
105
- * general journal directly, for example for recording depreciation. Notice
106
- * that you must supply the credit line and a corresponding debit line in
107
- * the same request. It will not work to supply them in two distinct
108
- * requests. You can supply as many credit lines and debit lines in one
109
- * single request as you want so long as the total monetary amount from the
110
- * credits equals the total monetary amount from the debits in that request.
111
- *
112
- * Finally, DO NOT supply negative sign for the monetary amounts. QuickBooks
113
- * does that for you. If you do supply the negative sign, amounts will add
114
- * instead of cancel and you’ll get a runtime error.
115
- *
116
- * Querying for Condensed Transactions: If you need the query to return
117
- * condensed transactions, you can do this by using either an `Entity` or
118
- * `Account` filter in the journal query request. Alternatively, you could
119
- * use the The generic `TransactionQuery`, which can return condensed
120
- * transactions.
121
- *
122
- * If the transaction is a home currency adjustment, QuickBooks will ignore
123
- * the `IsAmountsEnteredInHomeCurrency`, `CurrencyRef`, and `ExchangeRate`
124
- * elements.
125
- *
126
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryAdd
127
- */
128
- add: (integrationUserConnectionId: string, params: qbd.JournalEntryAddRq["JournalEntryAdd"]) => Promise<NonNullable<qbd.JournalEntryAddRs["JournalEntryRet"]>>;
129
- /**
130
- * Modifies a journal entry.
131
- *
132
- * If the transaction is a home currency adjustment, QuickBooks will ignore
133
- * the `IsAmountsEnteredInHomeCurrency`, `CurrencyRef`, and `ExchangeRate`
134
- * elements.
135
- *
136
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryMod
137
- */
138
- mod: (integrationUserConnectionId: string, params: qbd.JournalEntryModRq["JournalEntryMod"]) => Promise<NonNullable<qbd.JournalEntryModRs["JournalEntryRet"]>>;
139
- /**
140
- * In traditional accounting, transactions are entered into the general
141
- * journal and categorized exclusively by account. In QuickBooks, most
142
- * transactions can be categorized either by account or by type (invoice,
143
- * check, and so on). For a few activities in QuickBooks, you must use the
144
- * general journal directly, for example for recording depreciation. Notice
145
- * that you must supply the credit line and a corresponding debit line in
146
- * the same request. It will not work to supply them in two distinct
147
- * requests. You can supply as many credit lines and debit lines in one
148
- * single request as you want so long as the total monetary amount from the
149
- * credits equals the total monetary amount from the debits in that request.
150
- *
151
- * Finally, DO NOT supply negative sign for the monetary amounts. QuickBooks
152
- * does that for you. If you do supply the negative sign, amounts will add
153
- * instead of cancel and you’ll get a runtime error.
154
- *
155
- * Querying for Condensed Transactions: If you need the query to return
156
- * condensed transactions, you can do this by using either an `Entity` or
157
- * `Account` filter in the journal query request. Alternatively, you could
158
- * use the The generic `TransactionQuery`, which can return condensed
159
- * transactions.
160
- *
161
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/JournalEntryQuery
162
- */
163
- query: (integrationUserConnectionId: string, params: qbd.JournalEntryQueryRq) => Promise<NonNullable<qbd.JournalEntryQueryRs["JournalEntryRet"]>>;
164
- };
165
- timeTracking: {
166
- /**
167
- * The time-tracking transactions that are returned in this query include
168
- * time tracking information that was entered into QuickBooks manually or
169
- * gathered using the QuickBooks “Timer” or “Stopwatch.” Note that the
170
- * QuickBooks Timer application can run on its own without QuickBooks, but
171
- * the QuickBooks SDK cannot access the Timer data directly. The Timer data
172
- * must be imported into QuickBooks before it is accessible via the SDK.)
173
- *
174
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingQuery
175
- */
176
- add: (integrationUserConnectionId: string, params: qbd.TimeTrackingAddRq["TimeTrackingAdd"]) => Promise<NonNullable<qbd.TimeTrackingAddRs["TimeTrackingRet"]>>;
177
- /**
178
- * Modifies a time tracking transaction.
179
- *
180
- * This allows you to modify time entry and mark time entered as billed.
181
- * Applications using qbXML spec levels less than 6.0 aren’t able to Modify
182
- * a time tracking transaction. However, those applications can achieve the
183
- * results of a modify operation by deleting the time tracking transaction
184
- * (using `TxnDelRq`) and then re-adding it with the desired values. You can
185
- * do this only if no other downstream transactions have used that
186
- * particular time tracking transaction. (Otherwise, the `TxnDel` request
187
- * will fail.) This differs slightly from the UI, which allows these
188
- * transactions to be edited directly. However, even in the UI, modifying a
189
- * time tracking transaction does not result in changes to any downstream
190
- * transactions that use it. There is no link between an invoice and the
191
- * time entries. However when you do the invoicing from QuickBooks,
192
- * QuickBooks does mark the time entries as “billed.” If you don’t record
193
- * the time entries as billed properly, then you get into a user workflow
194
- * issue where every time the user creates an invoice for a customer, QB
195
- * pops up a dialog asking if they want to bill the un-billed time (which
196
- * you already billed from your app). That’s why beginning with QB2007 and
197
- * qbXML spec 6.0 we added support for the “BillableStatus” field *and* add
198
- * `TimeTrackingMod` so that you can mark the time as billed when you create
199
- * an invoice for it.
200
- *
201
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingMod
202
- */
203
- mod: (integrationUserConnectionId: string, params: qbd.TimeTrackingModRq["TimeTrackingMod"]) => Promise<NonNullable<qbd.TimeTrackingModRs["TimeTrackingRet"]>>;
204
- /**
205
- * The time-tracking transactions that are returned in this query include
206
- * time tracking information that was entered into QuickBooks manually or
207
- * gathered using the QuickBooks “Timer” or “Stopwatch.” Note that the
208
- * QuickBooks Timer application can run on its own without QuickBooks, but
209
- * the QuickBooks SDK cannot access the Timer data directly. The Timer data
210
- * must be imported into QuickBooks before it is accessible via the SDK.)
211
- *
212
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/TimeTrackingQuery
213
- */
214
- query: (integrationUserConnectionId: string, params: qbd.TimeTrackingQueryRq) => Promise<NonNullable<qbd.TimeTrackingQueryRs["TimeTrackingRet"]>>;
215
- };
216
- vendor: {
217
- /**
218
- * Adds a vendor.
219
- *
220
- * A vendor is any person or company from whom a small business owner buys
221
- * goods and services. (Banks and tax agencies usually are included on the
222
- * vendor list.) A company’s vendor list contains information such as
223
- * account balance and contact information about each vendor. A `VendorRef`
224
- * aggregate refers to one of the vendors on the list. In a request, if a
225
- * `VendorRef` aggregate includes both `FullName` and `ListID`, `FullName`
226
- * will be ignored.
227
- *
228
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorAdd
229
- */
230
- add: (integrationUserConnectionId: string, params: qbd.VendorAddRq["VendorAdd"]) => Promise<NonNullable<qbd.VendorAddRs["VendorRet"]>>;
231
- /**
232
- * Modifies a vendor.
233
- *
234
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorMod
235
- */
236
- mod: (integrationUserConnectionId: string, params: qbd.VendorModRq["VendorMod"]) => Promise<NonNullable<qbd.VendorModRs["VendorRet"]>>;
237
- /**
238
- * Queries for the specified vendor or set of vendors.
239
- *
240
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop/VendorQuery
241
- */
242
- query: (integrationUserConnectionId: string, params: qbd.VendorQueryRq) => Promise<NonNullable<qbd.VendorQueryRs["VendorRet"]>>;
243
- };
244
- /**
245
- * Send any QBXML request to QuickBooks Desktop.
246
- *
247
- * Available APIs:
248
- * https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop
249
- */
250
- sendRequest(integrationUserConnectionId: string, requestObject: object): Promise<object>;
251
- private sendRequestBase;
252
- }