conductor-node 0.4.1 → 1.0.1

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