@superdurable/connector-intuit-quickbooks 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +53 -2
- package/dex-connector.json +262 -0
- package/dist/chunk-4GHHKYDN.js +505 -0
- package/dist/connection-DfEHGjAp.d.ts +678 -0
- package/dist/index.d.ts +456 -0
- package/dist/index.js +1291 -0
- package/dist/mock.d.ts +190 -0
- package/dist/mock.js +455 -0
- package/package.json +61 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,1291 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
CreateCustomerBranch,
|
|
6
|
+
CreateCustomerBranchCreated,
|
|
7
|
+
CreateCustomerBranchDefect,
|
|
8
|
+
CreateCustomerBranchNameConflict,
|
|
9
|
+
CreateCustomerBranchProviderRejected,
|
|
10
|
+
CreateCustomerBranchUncertain,
|
|
11
|
+
CreateCustomerDefinition,
|
|
12
|
+
CreateCustomerInputSchema,
|
|
13
|
+
CreateCustomerMetadata,
|
|
14
|
+
CreateCustomerOutputSchema,
|
|
15
|
+
CreateInvoiceBranch,
|
|
16
|
+
CreateInvoiceBranchCreated,
|
|
17
|
+
CreateInvoiceBranchDefect,
|
|
18
|
+
CreateInvoiceBranchProviderRejected,
|
|
19
|
+
CreateInvoiceBranchUncertain,
|
|
20
|
+
CreateInvoiceDefinition,
|
|
21
|
+
CreateInvoiceInputSchema,
|
|
22
|
+
CreateInvoiceMetadata,
|
|
23
|
+
CreateInvoiceOutputSchema,
|
|
24
|
+
CustomerSchema,
|
|
25
|
+
FindCustomerBranch,
|
|
26
|
+
FindCustomerBranchAmbiguous,
|
|
27
|
+
FindCustomerBranchDefect,
|
|
28
|
+
FindCustomerBranchFound,
|
|
29
|
+
FindCustomerBranchInvalidResponse,
|
|
30
|
+
FindCustomerBranchNotFound,
|
|
31
|
+
FindCustomerBranchProviderRejected,
|
|
32
|
+
FindCustomerDefinition,
|
|
33
|
+
FindCustomerInputSchema,
|
|
34
|
+
FindCustomerMetadata,
|
|
35
|
+
FindCustomerOutputSchema,
|
|
36
|
+
GetInvoiceBranch,
|
|
37
|
+
GetInvoiceBranchDefect,
|
|
38
|
+
GetInvoiceBranchFound,
|
|
39
|
+
GetInvoiceBranchInvalidResponse,
|
|
40
|
+
GetInvoiceBranchNotFound,
|
|
41
|
+
GetInvoiceBranchProviderRejected,
|
|
42
|
+
GetInvoiceDefinition,
|
|
43
|
+
GetInvoiceInputSchema,
|
|
44
|
+
GetInvoiceMetadata,
|
|
45
|
+
InvoiceLineInputSchema,
|
|
46
|
+
InvoiceLineSchema,
|
|
47
|
+
InvoicePageSchema,
|
|
48
|
+
InvoiceSchema,
|
|
49
|
+
ListInvoicesBranch,
|
|
50
|
+
ListInvoicesBranchDefect,
|
|
51
|
+
ListInvoicesBranchInvalidResponse,
|
|
52
|
+
ListInvoicesBranchListed,
|
|
53
|
+
ListInvoicesBranchProviderRejected,
|
|
54
|
+
ListInvoicesDefinition,
|
|
55
|
+
ListInvoicesInputSchema,
|
|
56
|
+
ListInvoicesMetadata,
|
|
57
|
+
PaymentApplicationSchema,
|
|
58
|
+
PaymentSchema,
|
|
59
|
+
ProviderID,
|
|
60
|
+
RecordPaymentBranch,
|
|
61
|
+
RecordPaymentBranchDefect,
|
|
62
|
+
RecordPaymentBranchProviderRejected,
|
|
63
|
+
RecordPaymentBranchRecorded,
|
|
64
|
+
RecordPaymentBranchUncertain,
|
|
65
|
+
RecordPaymentDefinition,
|
|
66
|
+
RecordPaymentInputSchema,
|
|
67
|
+
RecordPaymentMetadata,
|
|
68
|
+
SendInvoiceBranch,
|
|
69
|
+
SendInvoiceBranchDefect,
|
|
70
|
+
SendInvoiceBranchProviderRejected,
|
|
71
|
+
SendInvoiceBranchSent,
|
|
72
|
+
SendInvoiceBranchUncertain,
|
|
73
|
+
SendInvoiceDefinition,
|
|
74
|
+
SendInvoiceInputSchema,
|
|
75
|
+
SendInvoiceMetadata,
|
|
76
|
+
decodeCredentials,
|
|
77
|
+
decodeSharedCredentials,
|
|
78
|
+
newConnection,
|
|
79
|
+
newConnectionWithOperations,
|
|
80
|
+
newProjectConnection,
|
|
81
|
+
newProjectCredentialProvider
|
|
82
|
+
} from "./chunk-4GHHKYDN.js";
|
|
83
|
+
|
|
84
|
+
// src/client.ts
|
|
85
|
+
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest } from "@superdurable/connectors-sdk/providerhttp";
|
|
86
|
+
import { isIP as isIP2 } from "net";
|
|
87
|
+
import { ManifestCredentialRefreshDriver } from "@superdurable/connectors-sdk/oauthtoken";
|
|
88
|
+
import { ReauthorizationRequiredError, resolveCredential, resolveCredentialAfterRejection } from "@superdurable/connectors-sdk";
|
|
89
|
+
|
|
90
|
+
// src/generated/refresh.ts
|
|
91
|
+
var Authorization = {
|
|
92
|
+
"fields": [
|
|
93
|
+
{
|
|
94
|
+
"name": "client_id",
|
|
95
|
+
"required": true,
|
|
96
|
+
"type": "string"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "client_secret",
|
|
100
|
+
"required": true,
|
|
101
|
+
"type": "secretString"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "access_token",
|
|
105
|
+
"required": true,
|
|
106
|
+
"type": "secretString"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "refresh_token",
|
|
110
|
+
"required": true,
|
|
111
|
+
"type": "secretString"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "id_token",
|
|
115
|
+
"required": false,
|
|
116
|
+
"type": "secretString"
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"oauth2": {
|
|
120
|
+
"clientIDCredential": "client_id",
|
|
121
|
+
"clientSecretCredential": "client_secret",
|
|
122
|
+
"credentialMappings": [
|
|
123
|
+
{
|
|
124
|
+
"credential": "access_token",
|
|
125
|
+
"source": "access_token"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"credential": "refresh_token",
|
|
129
|
+
"source": "refresh_token"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"credential": "id_token",
|
|
133
|
+
"source": "id_token"
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"refresh": {
|
|
137
|
+
"grants": [
|
|
138
|
+
{
|
|
139
|
+
"credentialMappings": [
|
|
140
|
+
{
|
|
141
|
+
"credential": "access_token",
|
|
142
|
+
"source": "access_token"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"credential": "refresh_token",
|
|
146
|
+
"source": "refresh_token"
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"refreshTokenCredential": "refresh_token"
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"missingExpiry": "reject",
|
|
153
|
+
"requiredScopes": [
|
|
154
|
+
"com.intuit.quickbooks.accounting"
|
|
155
|
+
],
|
|
156
|
+
"scopeSeparators": "whitespaceAndComma",
|
|
157
|
+
"storedMissingExpiry": "refresh",
|
|
158
|
+
"terminalErrorCodes": [
|
|
159
|
+
"invalid_grant",
|
|
160
|
+
"invalid_client",
|
|
161
|
+
"unauthorized_client",
|
|
162
|
+
"unsupported_grant_type"
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
"scopes": [
|
|
166
|
+
"com.intuit.quickbooks.accounting",
|
|
167
|
+
"openid"
|
|
168
|
+
],
|
|
169
|
+
"tokenEndpoint": "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",
|
|
170
|
+
"tokenEndpointAuthMethod": "client_secret_basic"
|
|
171
|
+
},
|
|
172
|
+
"refreshable": true,
|
|
173
|
+
"type": "oauth2"
|
|
174
|
+
};
|
|
175
|
+
var CredentialFields = {
|
|
176
|
+
"access_token": "accessToken",
|
|
177
|
+
"client_id": "clientId",
|
|
178
|
+
"client_secret": "clientSecret",
|
|
179
|
+
"id_token": "idToken",
|
|
180
|
+
"refresh_token": "refreshToken"
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// src/operations.ts
|
|
184
|
+
import { newMutationBranch, newMutationRetry, newMutationUncertain, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
185
|
+
import { isIP } from "net";
|
|
186
|
+
var entityID = /^[0-9]{1,20}$/;
|
|
187
|
+
var currencyCode = /^[A-Z]{3}$/;
|
|
188
|
+
var zeroCustomer = { customerId: "", displayName: "", isActive: false };
|
|
189
|
+
var zeroInvoice = { invoiceId: "", customerId: "", lines: [], totalAmount: "", balance: "" };
|
|
190
|
+
var zeroPayment = { paymentId: "", customerId: "", totalAmount: "" };
|
|
191
|
+
function object(value) {
|
|
192
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("response is not a JSON object");
|
|
193
|
+
return value;
|
|
194
|
+
}
|
|
195
|
+
function string(value) {
|
|
196
|
+
if (value === void 0 || value === null) return "";
|
|
197
|
+
if (typeof value !== "string") throw new TypeError("provider field is not a string");
|
|
198
|
+
return value;
|
|
199
|
+
}
|
|
200
|
+
function array(value) {
|
|
201
|
+
if (value == null) return [];
|
|
202
|
+
if (!Array.isArray(value)) throw new TypeError("provider field is not a list");
|
|
203
|
+
return value;
|
|
204
|
+
}
|
|
205
|
+
function reference(value) {
|
|
206
|
+
return value == null ? "" : string(object(value).value);
|
|
207
|
+
}
|
|
208
|
+
function optional(condition, key, value) {
|
|
209
|
+
return condition ? { [key]: value } : {};
|
|
210
|
+
}
|
|
211
|
+
function parse(body) {
|
|
212
|
+
const parseWithSource = JSON.parse;
|
|
213
|
+
return object(parseWithSource(Buffer.from(body).toString("utf8"), (_key, value, context) => typeof value === "number" ? context.source ?? String(value) : value));
|
|
214
|
+
}
|
|
215
|
+
function entity(body, name) {
|
|
216
|
+
const response = parse(body);
|
|
217
|
+
if (!(name in response)) throw new TypeError(`response has no ${name}`);
|
|
218
|
+
return object(response[name]);
|
|
219
|
+
}
|
|
220
|
+
function entities(body, name) {
|
|
221
|
+
const response = parse(body);
|
|
222
|
+
const query = object(response.QueryResponse);
|
|
223
|
+
if (!(name in query)) return [];
|
|
224
|
+
return array(query[name]).map(object);
|
|
225
|
+
}
|
|
226
|
+
function validID(name, value) {
|
|
227
|
+
if (!entityID.test(value)) throw new TypeError(`${name} must be a QuickBooks Id, a decimal string such as 145`);
|
|
228
|
+
}
|
|
229
|
+
function validText(name, value, maximum, multiline = false) {
|
|
230
|
+
if ([...value].length > maximum) throw new TypeError(`${name} can be at most ${maximum} characters`);
|
|
231
|
+
if ([...value].some((char) => {
|
|
232
|
+
const code = char.codePointAt(0);
|
|
233
|
+
return (code < 32 || code === 127) && !(multiline && "\n\r ".includes(char));
|
|
234
|
+
})) throw new TypeError(`${name} must not contain control characters`);
|
|
235
|
+
}
|
|
236
|
+
function validQuery(name, value, maximum) {
|
|
237
|
+
validText(name, value, maximum);
|
|
238
|
+
if (value.includes("\\")) throw new TypeError(`${name} cannot contain a backslash`);
|
|
239
|
+
}
|
|
240
|
+
function quote(value) {
|
|
241
|
+
return `'${value.replaceAll("'", "\\'")}'`;
|
|
242
|
+
}
|
|
243
|
+
function validDate(name, value) {
|
|
244
|
+
const parts = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
245
|
+
const year = Number(parts?.[1]), month = Number(parts?.[2]), day = Number(parts?.[3]);
|
|
246
|
+
const boundary = /* @__PURE__ */ new Date(0);
|
|
247
|
+
boundary.setUTCFullYear(year, month, 0);
|
|
248
|
+
const lastDay = boundary.getUTCDate();
|
|
249
|
+
if (!parts || month < 1 || month > 12 || day < 1 || day > lastDay) throw new TypeError(`${name} must be a calendar date written YYYY-MM-DD, such as 2026-10-01`);
|
|
250
|
+
}
|
|
251
|
+
function validCurrency(name, value) {
|
|
252
|
+
if (value && !currencyCode.test(value)) throw new TypeError(`${name} must be a three-letter ISO 4217 code such as USD`);
|
|
253
|
+
}
|
|
254
|
+
function validEmail(name, value) {
|
|
255
|
+
const invalid = () => {
|
|
256
|
+
throw new TypeError(`${name} must be one bare email address such as jane@example.com`);
|
|
257
|
+
};
|
|
258
|
+
if (!value || Buffer.byteLength(value, "utf8") > 254 || /[ "\\'()<>,;]/.test(value)) invalid();
|
|
259
|
+
const at = value.lastIndexOf("@");
|
|
260
|
+
if (at < 1 || at === value.length - 1 || value.indexOf("@") !== at) invalid();
|
|
261
|
+
const local = value.slice(0, at), domain = value.slice(at + 1);
|
|
262
|
+
const localAtom = /^[\p{L}\p{N}\p{M}!#$%&*+\-/=?^_`{|}~]+$/u;
|
|
263
|
+
if (local.split(".").some((part) => !localAtom.test(part))) invalid();
|
|
264
|
+
if (domain.startsWith("[") && domain.endsWith("]")) {
|
|
265
|
+
const contents = domain.slice(1, -1);
|
|
266
|
+
if (!isIP(contents)) invalid();
|
|
267
|
+
} else {
|
|
268
|
+
const domainAtom = /^[\p{L}\p{N}\p{M}_-]+$/u;
|
|
269
|
+
if (domain.split(".").some((part) => !domainAtom.test(part))) invalid();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function metadata(wire) {
|
|
273
|
+
const raw = wire.MetaData;
|
|
274
|
+
if (raw == null) return {};
|
|
275
|
+
const meta = object(raw);
|
|
276
|
+
const result = {};
|
|
277
|
+
for (const [wireName, outputName] of [["CreateTime", "createdAt"], ["LastUpdatedTime", "updatedAt"]]) {
|
|
278
|
+
const value = string(meta[wireName]);
|
|
279
|
+
if (!value) continue;
|
|
280
|
+
try {
|
|
281
|
+
result[outputName] = parseRFC3339(value);
|
|
282
|
+
} catch {
|
|
283
|
+
throw new TypeError(`invalid MetaData.${wireName}`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
function decimal(value, required = false) {
|
|
289
|
+
if (value === void 0 || value === null) {
|
|
290
|
+
if (required) throw new TypeError("missing decimal");
|
|
291
|
+
return "";
|
|
292
|
+
}
|
|
293
|
+
if (typeof value !== "number" && typeof value !== "string") throw new TypeError("invalid decimal");
|
|
294
|
+
const text = String(value).trim();
|
|
295
|
+
if (!/^-?(?:0|[1-9][0-9]{0,17})(?:\.[0-9]{1,18})?(?:[eE][+-]?[0-9]{1,2})?$/.test(text)) throw new TypeError("invalid decimal");
|
|
296
|
+
const match = /^(-?)(\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/.exec(text);
|
|
297
|
+
let digits = match[2] + (match[3] ?? "");
|
|
298
|
+
let point = match[2].length + Number(match[4] ?? 0);
|
|
299
|
+
if (point <= 0) {
|
|
300
|
+
digits = "0".repeat(1 - point) + digits;
|
|
301
|
+
point = 1;
|
|
302
|
+
} else if (point > digits.length) digits += "0".repeat(point - digits.length);
|
|
303
|
+
const whole = digits.slice(0, point).replace(/^0+/, "") || "0";
|
|
304
|
+
const fraction = digits.slice(point);
|
|
305
|
+
const result = `${match[1]}${whole}${fraction ? `.${fraction}` : ""}`;
|
|
306
|
+
const canonical = /[1-9]/.test(result) ? result : result.replace(/^-/, "");
|
|
307
|
+
if (!/^-?(?:0|[1-9][0-9]{0,17})(?:\.[0-9]{1,10})?$/.test(canonical)) throw new TypeError("invalid decimal");
|
|
308
|
+
return canonical;
|
|
309
|
+
}
|
|
310
|
+
function parseRFC3339(value, includeFraction = true) {
|
|
311
|
+
const parts = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|[+-]\d{2}:\d{2})$/.exec(value);
|
|
312
|
+
if (!parts) throw new TypeError("invalid RFC 3339 timestamp");
|
|
313
|
+
const [year, month, day, hour, minute, second] = parts.slice(1, 7).map(Number);
|
|
314
|
+
validDate("timestamp", `${parts[1]}-${parts[2]}-${parts[3]}`);
|
|
315
|
+
if (hour > 23 || minute > 59 || second > 59) throw new TypeError("invalid RFC 3339 timestamp");
|
|
316
|
+
const zone = parts[8];
|
|
317
|
+
const offsetHours = zone === "Z" ? 0 : Number(zone.slice(1, 3));
|
|
318
|
+
const offsetMinutes = zone === "Z" ? 0 : Number(zone.slice(4, 6));
|
|
319
|
+
if (offsetHours > 24 || offsetMinutes > 59) throw new TypeError("invalid RFC 3339 timestamp");
|
|
320
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
321
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
322
|
+
date.setUTCHours(hour, minute, second, 0);
|
|
323
|
+
const sign = zone.startsWith("-") ? -1 : 1;
|
|
324
|
+
const utc = new Date(date.getTime() - sign * (offsetHours * 60 + offsetMinutes) * 6e4);
|
|
325
|
+
const seconds = utc.toISOString().slice(0, 19);
|
|
326
|
+
const fraction = includeFraction ? (parts[7] ?? "").slice(0, 9).replace(/0+$/, "") : "";
|
|
327
|
+
return `${seconds}${fraction ? `.${fraction}` : ""}Z`;
|
|
328
|
+
}
|
|
329
|
+
function omitEmptyOptionalFields(value) {
|
|
330
|
+
return Object.fromEntries(Object.entries(value).filter(([name, item]) => item !== "" && (!Array.isArray(item) || item.length > 0 || name === "lines")));
|
|
331
|
+
}
|
|
332
|
+
function decodeCustomer(wire) {
|
|
333
|
+
const id = string(wire.Id), displayName = string(wire.DisplayName);
|
|
334
|
+
validID("customer Id", id);
|
|
335
|
+
if (!displayName.trim()) throw new TypeError("customer has no DisplayName");
|
|
336
|
+
const email = wire.PrimaryEmailAddr == null ? "" : string(object(wire.PrimaryEmailAddr).Address).trim();
|
|
337
|
+
const phone = wire.PrimaryPhone == null ? "" : string(object(wire.PrimaryPhone).FreeFormNumber);
|
|
338
|
+
if (wire.Active != null && typeof wire.Active !== "boolean") throw new TypeError("invalid Active");
|
|
339
|
+
return omitEmptyOptionalFields({
|
|
340
|
+
customerId: id,
|
|
341
|
+
displayName,
|
|
342
|
+
isActive: wire.Active == null || wire.Active === true,
|
|
343
|
+
...optional(!!wire.SyncToken, "syncToken", string(wire.SyncToken)),
|
|
344
|
+
...optional(!!wire.GivenName, "givenName", string(wire.GivenName)),
|
|
345
|
+
...optional(!!wire.FamilyName, "familyName", string(wire.FamilyName)),
|
|
346
|
+
...optional(!!wire.CompanyName, "companyName", string(wire.CompanyName)),
|
|
347
|
+
...optional(!!email, "emailAddress", email),
|
|
348
|
+
...optional(!!phone, "phone", phone),
|
|
349
|
+
...optional(wire.Balance != null, "balance", decimal(wire.Balance)),
|
|
350
|
+
...optional(wire.CurrencyRef != null, "currencyCode", reference(wire.CurrencyRef)),
|
|
351
|
+
...metadata(wire)
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
function decodeInvoiceLine(wire) {
|
|
355
|
+
const detailType = string(wire.DetailType);
|
|
356
|
+
if (!detailType) throw new TypeError("line has no DetailType");
|
|
357
|
+
const detail = wire.SalesItemLineDetail == null ? null : object(wire.SalesItemLineDetail);
|
|
358
|
+
return omitEmptyOptionalFields({
|
|
359
|
+
detailType,
|
|
360
|
+
...optional(!!wire.Id, "lineId", string(wire.Id)),
|
|
361
|
+
...optional(!!wire.Description, "description", string(wire.Description)),
|
|
362
|
+
...optional(wire.Amount != null, "amount", decimal(wire.Amount)),
|
|
363
|
+
...detail ? { ...optional(detail.ItemRef != null, "itemId", reference(detail.ItemRef)), ...optional(detail.ItemRef != null && !!object(detail.ItemRef).name, "itemName", string(detail.ItemRef == null ? "" : object(detail.ItemRef).name)), ...optional(detail.Qty != null, "quantity", decimal(detail.Qty)), ...optional(detail.UnitPrice != null, "unitPrice", decimal(detail.UnitPrice)), ...optional(detail.TaxCodeRef != null, "taxCodeId", reference(detail.TaxCodeRef)), ...optional(!!detail.ServiceDate, "serviceDate", string(detail.ServiceDate)) } : {}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
function decodeInvoice(wire) {
|
|
367
|
+
const id = string(wire.Id), customer = reference(wire.CustomerRef);
|
|
368
|
+
validID("invoice Id", id);
|
|
369
|
+
validID("CustomerRef", customer);
|
|
370
|
+
const total = decimal(wire.TotalAmt, true), balance = decimal(wire.Balance, true);
|
|
371
|
+
const lines = array(wire.Line).map(object).map(decodeInvoiceLine);
|
|
372
|
+
const linked = array(wire.LinkedTxn).map(object).filter((item) => item.TxnType === "Payment" && entityID.test(string(item.TxnId))).map((item) => string(item.TxnId));
|
|
373
|
+
const delivered = wire.DeliveryInfo == null ? "" : string(object(wire.DeliveryInfo).DeliveryTime);
|
|
374
|
+
if (delivered) try {
|
|
375
|
+
parseRFC3339(delivered);
|
|
376
|
+
} catch {
|
|
377
|
+
throw new TypeError("invoice has an invalid DeliveryInfo.DeliveryTime");
|
|
378
|
+
}
|
|
379
|
+
for (const key of ["TxnDate", "DueDate"]) if (wire[key]) validDate(key, string(wire[key]));
|
|
380
|
+
return omitEmptyOptionalFields({
|
|
381
|
+
invoiceId: id,
|
|
382
|
+
customerId: customer,
|
|
383
|
+
lines,
|
|
384
|
+
totalAmount: total,
|
|
385
|
+
balance,
|
|
386
|
+
...optional(!!wire.SyncToken, "syncToken", string(wire.SyncToken)),
|
|
387
|
+
...optional(!!wire.DocNumber, "docNumber", string(wire.DocNumber)),
|
|
388
|
+
...optional(wire.CustomerRef != null && !!object(wire.CustomerRef).name, "customerName", wire.CustomerRef == null ? "" : string(object(wire.CustomerRef).name)),
|
|
389
|
+
...optional(!!wire.TxnDate, "txnDate", string(wire.TxnDate)),
|
|
390
|
+
...optional(!!wire.DueDate, "dueDate", string(wire.DueDate)),
|
|
391
|
+
...optional(wire.CurrencyRef != null, "currencyCode", reference(wire.CurrencyRef)),
|
|
392
|
+
...optional(wire.ExchangeRate != null, "exchangeRate", decimal(wire.ExchangeRate)),
|
|
393
|
+
...optional(wire.TxnTaxDetail != null, "totalTax", decimal(wire.TxnTaxDetail == null ? void 0 : object(wire.TxnTaxDetail).TotalTax)),
|
|
394
|
+
...optional(!!wire.EmailStatus, "emailStatus", string(wire.EmailStatus)),
|
|
395
|
+
...optional(wire.BillEmail != null, "billEmail", wire.BillEmail == null ? "" : string(object(wire.BillEmail).Address).trim()),
|
|
396
|
+
...optional(!!delivered, "deliveredAt", delivered ? parseRFC3339(delivered) : ""),
|
|
397
|
+
...optional(wire.CustomerMemo != null, "customerMemo", wire.CustomerMemo == null ? "" : string(object(wire.CustomerMemo).value)),
|
|
398
|
+
...optional(!!wire.PrivateNote, "privateNote", string(wire.PrivateNote)),
|
|
399
|
+
...optional(linked.length > 0, "linkedPaymentIds", linked),
|
|
400
|
+
...metadata(wire)
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
function decodePayment(wire) {
|
|
404
|
+
const id = string(wire.Id), customer = reference(wire.CustomerRef);
|
|
405
|
+
validID("payment Id", id);
|
|
406
|
+
validID("CustomerRef", customer);
|
|
407
|
+
const applications = [];
|
|
408
|
+
if (wire.TxnDate) validDate("TxnDate", string(wire.TxnDate));
|
|
409
|
+
for (const line of array(wire.Line).map(object)) for (const linked of array(line.LinkedTxn).map(object)) if (linked.TxnType === "Invoice") {
|
|
410
|
+
const invoiceID = string(linked.TxnId);
|
|
411
|
+
validID("payment TxnId", invoiceID);
|
|
412
|
+
applications.push({ invoiceId: invoiceID, amount: decimal(line.Amount, true) });
|
|
413
|
+
}
|
|
414
|
+
return omitEmptyOptionalFields({ paymentId: id, customerId: customer, totalAmount: decimal(wire.TotalAmt, true), ...optional(!!wire.SyncToken, "syncToken", string(wire.SyncToken)), ...optional(!!wire.TxnDate, "txnDate", string(wire.TxnDate)), ...optional(wire.UnappliedAmt != null, "unappliedAmount", decimal(wire.UnappliedAmt)), ...optional(wire.CurrencyRef != null, "currencyCode", reference(wire.CurrencyRef)), ...optional(!!wire.PaymentRefNum, "paymentReferenceNumber", string(wire.PaymentRefNum)), ...optional(wire.DepositToAccountRef != null, "depositAccountId", reference(wire.DepositToAccountRef)), ...optional(applications.length > 0, "appliedInvoices", applications), ...optional(!!wire.PrivateNote, "privateNote", string(wire.PrivateNote)), ...metadata(wire) });
|
|
415
|
+
}
|
|
416
|
+
function queryOutcome(result, output, notFound = false) {
|
|
417
|
+
if (result.disposition === "succeeded") return void 0;
|
|
418
|
+
if (result.disposition === "retry" || result.disposition === "interrupted") return newQueryRetry(result.failure, result.retryAfterMs);
|
|
419
|
+
const branch = result.disposition === "defect" ? "defect" : result.disposition === "invalid" ? "invalidResponse" : result.disposition === "notFound" && notFound ? "notFound" : "providerRejected";
|
|
420
|
+
return newQueryBranch(branch, output, result.receipt, result.failure);
|
|
421
|
+
}
|
|
422
|
+
function mutationOutcome(result, output, nameConflict = false) {
|
|
423
|
+
if (result.disposition === "succeeded" || result.disposition === "invalid" || result.disposition === "interrupted") return void 0;
|
|
424
|
+
if (result.disposition === "retry") return newMutationRetry(result.failure, result.retryAfterMs);
|
|
425
|
+
return newMutationBranch(result.disposition === "defect" ? "defect" : result.disposition === "nameConflict" && nameConflict ? "nameConflict" : "providerRejected", output, result.receipt, result.failure);
|
|
426
|
+
}
|
|
427
|
+
function defect(client, operation, error) {
|
|
428
|
+
return client.failure("VALIDATION", operation, error instanceof Error ? error.message : "invalid input");
|
|
429
|
+
}
|
|
430
|
+
var FindCustomerOperation = class {
|
|
431
|
+
/** Bind one client. */
|
|
432
|
+
constructor(client) {
|
|
433
|
+
this.client = client;
|
|
434
|
+
}
|
|
435
|
+
client;
|
|
436
|
+
/** Return the manifest definition. */
|
|
437
|
+
definition() {
|
|
438
|
+
return FindCustomerDefinition;
|
|
439
|
+
}
|
|
440
|
+
/** Execute one bounded QuickBooks customer query. */
|
|
441
|
+
async invoke(call, input) {
|
|
442
|
+
const requested = { ...optional(!!input.emailAddress?.trim(), "emailAddress", input.emailAddress?.trim() ?? ""), ...optional(!!input.displayName?.trim(), "displayName", input.displayName?.trim() ?? "") };
|
|
443
|
+
let statement;
|
|
444
|
+
try {
|
|
445
|
+
const email = input.emailAddress?.trim() ?? "", displayName = input.displayName?.trim() ?? "";
|
|
446
|
+
if (email && displayName) throw new TypeError("give either emailAddress or displayName, not both");
|
|
447
|
+
if (email) {
|
|
448
|
+
validEmail("emailAddress", email);
|
|
449
|
+
statement = `PrimaryEmailAddr = ${quote(email)}`;
|
|
450
|
+
} else if (displayName) {
|
|
451
|
+
validQuery("displayName", displayName, 500);
|
|
452
|
+
statement = `DisplayName = ${quote(displayName)}`;
|
|
453
|
+
} else throw new TypeError("emailAddress or displayName is required");
|
|
454
|
+
if (input.includesInactive) statement += " AND Active IN (true, false)";
|
|
455
|
+
statement = `select * from Customer where ${statement} MAXRESULTS 10`;
|
|
456
|
+
} catch (error) {
|
|
457
|
+
return newQueryBranch("defect", requested, {}, defect(this.client, "findCustomer", error));
|
|
458
|
+
}
|
|
459
|
+
const result = await this.client.exchange(call, "findCustomer", { method: "GET", path: "/query", query: { query: statement } });
|
|
460
|
+
const outcome = queryOutcome(result, requested);
|
|
461
|
+
if (outcome) return outcome;
|
|
462
|
+
try {
|
|
463
|
+
const matches = entities(result.body, "Customer").map(decodeCustomer).filter((customer) => (requested.emailAddress ? customer.emailAddress?.toLowerCase() === requested.emailAddress.toLowerCase() : customer.displayName.toLowerCase() === requested.displayName?.toLowerCase()) && (input.includesInactive || customer.isActive));
|
|
464
|
+
if (matches.length > 10) throw new TypeError("response has more customers than requested");
|
|
465
|
+
if (!matches.length) return newQueryBranch("notFound", requested, result.receipt, this.client.failure("NOT_FOUND", "findCustomer", "no QuickBooks customer matches"));
|
|
466
|
+
if (matches.length > 1) return newQueryBranch("ambiguous", { ...requested, matches }, result.receipt, this.client.failure("CONFLICT", "findCustomer", "several QuickBooks customers match"));
|
|
467
|
+
result.receipt.providerObjectId = matches[0].customerId;
|
|
468
|
+
return newQueryBranch("found", { ...requested, customer: matches[0] }, result.receipt);
|
|
469
|
+
} catch (error) {
|
|
470
|
+
return newQueryBranch("invalidResponse", requested, result.receipt, this.client.failure("PROTOCOL", "findCustomer", `QuickBooks returned an invalid customer list: ${error instanceof Error ? error.message : "invalid response"}`));
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
var GetInvoiceOperation = class {
|
|
475
|
+
/** Bind one client. */
|
|
476
|
+
constructor(client) {
|
|
477
|
+
this.client = client;
|
|
478
|
+
}
|
|
479
|
+
client;
|
|
480
|
+
/** Return the manifest definition. */
|
|
481
|
+
definition() {
|
|
482
|
+
return GetInvoiceDefinition;
|
|
483
|
+
}
|
|
484
|
+
/** Validate and read one invoice. */
|
|
485
|
+
async invoke(call, input) {
|
|
486
|
+
const invoiceID = input.invoiceId.trim(), requested = { ...zeroInvoice, invoiceId: invoiceID };
|
|
487
|
+
try {
|
|
488
|
+
validID("invoiceId", invoiceID);
|
|
489
|
+
} catch (error) {
|
|
490
|
+
return newQueryBranch("defect", requested, {}, defect(this.client, "getInvoice", error));
|
|
491
|
+
}
|
|
492
|
+
const result = await this.client.exchange(call, "getInvoice", { method: "GET", path: `/invoice/${invoiceID}` }, invoiceID);
|
|
493
|
+
const outcome = queryOutcome(result, requested, true);
|
|
494
|
+
if (outcome) return outcome;
|
|
495
|
+
try {
|
|
496
|
+
const invoice = decodeInvoice(entity(result.body, "Invoice"));
|
|
497
|
+
if (invoice.invoiceId !== invoiceID) throw new TypeError("QuickBooks returned another invoice");
|
|
498
|
+
return newQueryBranch("found", invoice, result.receipt);
|
|
499
|
+
} catch (error) {
|
|
500
|
+
return newQueryBranch("invalidResponse", requested, result.receipt, this.client.failure("PROTOCOL", "getInvoice", `QuickBooks returned an invalid invoice: ${error instanceof Error ? error.message : "invalid response"}`));
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
var ListInvoicesOperation = class {
|
|
505
|
+
/** Bind one client. */
|
|
506
|
+
constructor(client) {
|
|
507
|
+
this.client = client;
|
|
508
|
+
}
|
|
509
|
+
client;
|
|
510
|
+
/** Return the manifest definition. */
|
|
511
|
+
definition() {
|
|
512
|
+
return ListInvoicesDefinition;
|
|
513
|
+
}
|
|
514
|
+
/** Build and execute the invoice page query. */
|
|
515
|
+
async invoke(call, input) {
|
|
516
|
+
const empty = { invoices: [], startPosition: 0, maxResults: 0, hasMorePages: false };
|
|
517
|
+
let statement, startPosition, maxResults;
|
|
518
|
+
try {
|
|
519
|
+
startPosition = input.startPosition || 1;
|
|
520
|
+
maxResults = input.maxResults || 25;
|
|
521
|
+
if (startPosition < 1) throw new TypeError("startPosition must be 1 or greater");
|
|
522
|
+
if (maxResults < 1 || maxResults > 100) throw new TypeError("maxResults must be between 1 and 100");
|
|
523
|
+
const conditions = [];
|
|
524
|
+
if (input.customerId?.trim()) {
|
|
525
|
+
validID("customerId", input.customerId.trim());
|
|
526
|
+
conditions.push(`CustomerRef = ${quote(input.customerId.trim())}`);
|
|
527
|
+
}
|
|
528
|
+
if (input.docNumber?.trim()) {
|
|
529
|
+
validQuery("docNumber", input.docNumber.trim(), 21);
|
|
530
|
+
conditions.push(`DocNumber = ${quote(input.docNumber.trim())}`);
|
|
531
|
+
}
|
|
532
|
+
if (input.isOpenOnly) conditions.push("Balance > '0'");
|
|
533
|
+
for (const [name, operator] of [["txnDateFrom", ">="], ["txnDateTo", "<="]]) {
|
|
534
|
+
const value = (input[name] ?? "").trim();
|
|
535
|
+
if (value) {
|
|
536
|
+
validDate(name, value);
|
|
537
|
+
conditions.push(`TxnDate ${operator} ${quote(value)}`);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
if (input.updatedSince) conditions.push(`MetaData.LastUpdatedTime >= ${quote(parseRFC3339(input.updatedSince, false))}`);
|
|
541
|
+
statement = `select * from Invoice${conditions.length ? ` where ${conditions.join(" AND ")}` : ""} ORDERBY MetaData.CreateTime STARTPOSITION ${startPosition} MAXRESULTS ${maxResults}`;
|
|
542
|
+
} catch (error) {
|
|
543
|
+
return newQueryBranch("defect", empty, {}, defect(this.client, "listInvoices", error));
|
|
544
|
+
}
|
|
545
|
+
const result = await this.client.exchange(call, "listInvoices", { method: "GET", path: "/query", query: { query: statement } });
|
|
546
|
+
const outcome = queryOutcome(result, empty);
|
|
547
|
+
if (outcome) return outcome;
|
|
548
|
+
try {
|
|
549
|
+
const invoices = entities(result.body, "Invoice").map(decodeInvoice);
|
|
550
|
+
if (invoices.length > maxResults) throw new TypeError("response has more invoices than requested");
|
|
551
|
+
const page = { invoices, startPosition, maxResults, hasMorePages: invoices.length === maxResults, ...invoices.length === maxResults ? { nextStartPosition: startPosition + maxResults } : {} };
|
|
552
|
+
return newQueryBranch("listed", page, result.receipt);
|
|
553
|
+
} catch (error) {
|
|
554
|
+
return newQueryBranch("invalidResponse", empty, result.receipt, this.client.failure("PROTOCOL", "listInvoices", `QuickBooks returned an invalid invoice page: ${error instanceof Error ? error.message : "invalid response"}`));
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
function encoded(value) {
|
|
559
|
+
const serialize = (part) => {
|
|
560
|
+
if (part && typeof part === "object" && "__quickbooksRawNumber" in part) return String(part.__quickbooksRawNumber);
|
|
561
|
+
if (Array.isArray(part)) return `[${part.map(serialize).join(",")}]`;
|
|
562
|
+
if (part && typeof part === "object") return `{${Object.entries(part).filter(([, item]) => item !== void 0).map(([key, item]) => `${JSON.stringify(key)}:${serialize(item)}`).join(",")}}`;
|
|
563
|
+
return JSON.stringify(part);
|
|
564
|
+
};
|
|
565
|
+
return Buffer.from(serialize(value), "utf8");
|
|
566
|
+
}
|
|
567
|
+
function validDecimal(name, value, fraction, integer, negative, zero) {
|
|
568
|
+
if (!/^-?(?:0|[1-9][0-9]{0,17})(?:\.[0-9]{1,10})?$/.test(value)) throw new TypeError(`${name} must be an exact decimal number such as 1800.00, without an exponent or leading zeros`);
|
|
569
|
+
const unsigned = value.replace(/^-/, ""), [whole, fractional = ""] = unsigned.split(".");
|
|
570
|
+
if (fractional.length > fraction) throw new TypeError(`${name} can have at most ${fraction} decimal places`);
|
|
571
|
+
if (whole.length > integer) throw new TypeError(`${name} can have at most ${integer} digits before the decimal point`);
|
|
572
|
+
if (!negative && value.startsWith("-") && /[1-9]/.test(value)) throw new TypeError(`${name} cannot be negative`);
|
|
573
|
+
if (!zero && !/[1-9]/.test(value)) throw new TypeError(`${name} must be greater than zero`);
|
|
574
|
+
}
|
|
575
|
+
function rawNumber(value) {
|
|
576
|
+
return { __quickbooksRawNumber: value };
|
|
577
|
+
}
|
|
578
|
+
function acceptedID(body, name) {
|
|
579
|
+
if (!body) return "";
|
|
580
|
+
try {
|
|
581
|
+
const found = parse(body)[name];
|
|
582
|
+
const id = string(object(found).Id);
|
|
583
|
+
return entityID.test(id) ? id : "";
|
|
584
|
+
} catch {
|
|
585
|
+
return "";
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
async function readAccepted(client, call, operation, name, id) {
|
|
589
|
+
if (!id) return void 0;
|
|
590
|
+
const result = await client.exchange(call, operation, { method: "GET", path: `/${name.toLowerCase()}/${id}` });
|
|
591
|
+
if (result.disposition !== "succeeded") return void 0;
|
|
592
|
+
try {
|
|
593
|
+
return entity(result.body, name);
|
|
594
|
+
} catch {
|
|
595
|
+
return void 0;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
var CreateCustomerOperation = class {
|
|
599
|
+
/** Bind one client. */
|
|
600
|
+
constructor(client) {
|
|
601
|
+
this.client = client;
|
|
602
|
+
}
|
|
603
|
+
client;
|
|
604
|
+
/** Return the manifest definition. */
|
|
605
|
+
definition() {
|
|
606
|
+
return CreateCustomerDefinition;
|
|
607
|
+
}
|
|
608
|
+
/** Use Dex Call ID as QuickBooks requestid. */
|
|
609
|
+
idempotencyKey(callID) {
|
|
610
|
+
return callID;
|
|
611
|
+
}
|
|
612
|
+
/** Validate, create, and confirm an accepted write if necessary. */
|
|
613
|
+
async invoke(call, input) {
|
|
614
|
+
const requested = { customer: zeroCustomer, displayName: input.displayName.trim() };
|
|
615
|
+
let payload;
|
|
616
|
+
try {
|
|
617
|
+
const displayName = input.displayName.trim(), givenName = input.givenName?.trim() ?? "", familyName = input.familyName?.trim() ?? "", companyName = input.companyName?.trim() ?? "", email = input.emailAddress?.trim() ?? "", phone = input.phone?.trim() ?? "", currency = input.currencyCode?.trim() ?? "";
|
|
618
|
+
if (!displayName) throw new TypeError("displayName is required");
|
|
619
|
+
for (const [name, value, max] of [["displayName", displayName, 500], ["givenName", givenName, 100], ["familyName", familyName, 100], ["companyName", companyName, 100]]) validText(name, value, max);
|
|
620
|
+
if (displayName.includes(":")) throw new TypeError("displayName cannot contain a colon, which QuickBooks reserves for sub-customers");
|
|
621
|
+
if (email) {
|
|
622
|
+
validEmail("emailAddress", email);
|
|
623
|
+
validText("emailAddress", email, 100);
|
|
624
|
+
}
|
|
625
|
+
if (phone) validText("phone", phone, 30);
|
|
626
|
+
validCurrency("currencyCode", currency);
|
|
627
|
+
payload = { DisplayName: displayName, ...optional(!!email, "PrimaryEmailAddr", { Address: email }), ...optional(!!givenName, "GivenName", givenName), ...optional(!!familyName, "FamilyName", familyName), ...optional(!!companyName, "CompanyName", companyName), ...optional(!!phone, "PrimaryPhone", { FreeFormNumber: phone }), ...optional(!!currency, "CurrencyRef", { value: currency }) };
|
|
628
|
+
} catch (error) {
|
|
629
|
+
return newMutationBranch("defect", requested, {}, defect(this.client, "createCustomer", error));
|
|
630
|
+
}
|
|
631
|
+
const result = await this.client.exchange(call, "createCustomer", { method: "POST", path: "/customer", body: encoded(payload), mutation: true });
|
|
632
|
+
const outcome = mutationOutcome(result, requested, true);
|
|
633
|
+
if (outcome) return outcome;
|
|
634
|
+
let cause = "invalid customer";
|
|
635
|
+
try {
|
|
636
|
+
const customer = decodeCustomer(entity(result.body, "Customer"));
|
|
637
|
+
if (!customerMatches(customer, payload)) throw new TypeError("QuickBooks returned another customer");
|
|
638
|
+
result.receipt.providerObjectId = customer.customerId;
|
|
639
|
+
return newMutationBranch("created", { customer, displayName: requested.displayName }, result.receipt);
|
|
640
|
+
} catch (error) {
|
|
641
|
+
cause = error instanceof Error ? error.message : cause;
|
|
642
|
+
}
|
|
643
|
+
const id = acceptedID(result.body, "Customer");
|
|
644
|
+
const read = await readAccepted(this.client, call, "createCustomer", "Customer", id);
|
|
645
|
+
if (read) try {
|
|
646
|
+
const customer = decodeCustomer(read);
|
|
647
|
+
if (customer.customerId === id && customerMatches(customer, payload)) {
|
|
648
|
+
result.receipt.providerObjectId = id;
|
|
649
|
+
return newMutationBranch("created", { customer, displayName: requested.displayName }, result.receipt);
|
|
650
|
+
}
|
|
651
|
+
} catch {
|
|
652
|
+
}
|
|
653
|
+
return newMutationUncertain(requested, this.client.failure("PROTOCOL", "createCustomer", `QuickBooks accepted the customer but returned an unusable customer: ${cause}`), result.receipt);
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
function customerMatches(customer, payload) {
|
|
657
|
+
if (customer.displayName !== payload.DisplayName) return false;
|
|
658
|
+
for (const [requested, actual] of [["GivenName", customer.givenName], ["FamilyName", customer.familyName], ["CompanyName", customer.companyName]]) if (payload[requested] && actual !== payload[requested]) return false;
|
|
659
|
+
return !payload.PrimaryEmailAddr || (customer.emailAddress ?? "").toLowerCase() === string(object(payload.PrimaryEmailAddr).Address).toLowerCase();
|
|
660
|
+
}
|
|
661
|
+
var CreateInvoiceOperation = class {
|
|
662
|
+
/** Bind one client. */
|
|
663
|
+
constructor(client) {
|
|
664
|
+
this.client = client;
|
|
665
|
+
}
|
|
666
|
+
client;
|
|
667
|
+
/** Return the manifest definition. */
|
|
668
|
+
definition() {
|
|
669
|
+
return CreateInvoiceDefinition;
|
|
670
|
+
}
|
|
671
|
+
/** Use Dex Call ID as QuickBooks requestid. */
|
|
672
|
+
idempotencyKey(callID) {
|
|
673
|
+
return callID;
|
|
674
|
+
}
|
|
675
|
+
/** Validate, create, and read back an accepted invoice if necessary. */
|
|
676
|
+
async invoke(call, input) {
|
|
677
|
+
const requested = { invoice: zeroInvoice, ...optional(!!input.docNumber?.trim(), "docNumber", input.docNumber?.trim() ?? "") };
|
|
678
|
+
let payload;
|
|
679
|
+
try {
|
|
680
|
+
payload = buildInvoicePayload(input);
|
|
681
|
+
} catch (error) {
|
|
682
|
+
return newMutationBranch("defect", requested, {}, defect(this.client, "createInvoice", error));
|
|
683
|
+
}
|
|
684
|
+
const result = await this.client.exchange(call, "createInvoice", { method: "POST", path: "/invoice", body: encoded(payload), mutation: true });
|
|
685
|
+
const outcome = mutationOutcome(result, requested);
|
|
686
|
+
if (outcome) return outcome;
|
|
687
|
+
let cause = "invalid invoice";
|
|
688
|
+
try {
|
|
689
|
+
const invoice = decodeInvoice(entity(result.body, "Invoice"));
|
|
690
|
+
if (invoice.customerId !== input.customerId.trim()) throw new TypeError("invoice belongs to another customer");
|
|
691
|
+
result.receipt.providerObjectId = invoice.invoiceId;
|
|
692
|
+
return newMutationBranch("created", { invoice, ...optional(!!requested.docNumber, "docNumber", requested.docNumber ?? "") }, result.receipt);
|
|
693
|
+
} catch (error) {
|
|
694
|
+
cause = error instanceof Error ? error.message : cause;
|
|
695
|
+
}
|
|
696
|
+
const id = acceptedID(result.body, "Invoice"), read = await readAccepted(this.client, call, "createInvoice", "Invoice", id);
|
|
697
|
+
if (read) try {
|
|
698
|
+
const invoice = decodeInvoice(read);
|
|
699
|
+
if (invoice.invoiceId === id && invoice.customerId === input.customerId.trim() && (!requested.docNumber || invoice.docNumber === requested.docNumber)) {
|
|
700
|
+
result.receipt.providerObjectId = id;
|
|
701
|
+
return newMutationBranch("created", { invoice, ...optional(!!requested.docNumber, "docNumber", requested.docNumber ?? "") }, result.receipt);
|
|
702
|
+
}
|
|
703
|
+
} catch {
|
|
704
|
+
}
|
|
705
|
+
return newMutationUncertain(requested, this.client.failure("PROTOCOL", "createInvoice", `QuickBooks accepted the invoice but returned an unusable invoice: ${cause}`), result.receipt);
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
function buildInvoicePayload(input) {
|
|
709
|
+
const customer = input.customerId.trim(), txnDate = input.txnDate?.trim() ?? "", dueDate = input.dueDate?.trim() ?? "", docNumber = input.docNumber?.trim() ?? "", billEmail = input.billEmail?.trim() ?? "", currency = input.currencyCode?.trim() ?? "";
|
|
710
|
+
validID("customerId", customer);
|
|
711
|
+
if (txnDate) validDate("txnDate", txnDate);
|
|
712
|
+
if (dueDate) validDate("dueDate", dueDate);
|
|
713
|
+
if (txnDate && dueDate && dueDate < txnDate) throw new TypeError("dueDate cannot be before txnDate");
|
|
714
|
+
validQuery("docNumber", docNumber, 21);
|
|
715
|
+
if (billEmail) validEmail("billEmail", billEmail);
|
|
716
|
+
validCurrency("currencyCode", currency);
|
|
717
|
+
validText("customerMemo", input.customerMemo ?? "", 1e3, true);
|
|
718
|
+
validText("privateNote", input.privateNote ?? "", 4e3, true);
|
|
719
|
+
if (!input.lines || input.lines.length < 1 || input.lines.length > 100) throw new TypeError("lines must hold 1 to 100 lines");
|
|
720
|
+
return { CustomerRef: { value: customer }, Line: input.lines.map((line, index) => buildInvoiceLine(line, index)), ...optional(!!txnDate, "TxnDate", txnDate), ...optional(!!dueDate, "DueDate", dueDate), ...optional(!!docNumber, "DocNumber", docNumber), ...optional(!!billEmail, "BillEmail", { Address: billEmail }), ...optional(!!currency, "CurrencyRef", { value: currency }), ...optional(!!input.customerMemo, "CustomerMemo", { value: input.customerMemo ?? "" }), ...optional(!!input.privateNote, "PrivateNote", input.privateNote ?? "") };
|
|
721
|
+
}
|
|
722
|
+
function buildInvoiceLine(line, index) {
|
|
723
|
+
const prefix = `lines[${index}]`, itemID = line.itemId.trim(), serviceDate = line.serviceDate?.trim() ?? "", taxCode = line.taxCodeId?.trim() ?? "";
|
|
724
|
+
validID(`${prefix}.itemId`, itemID);
|
|
725
|
+
validText(`${prefix}.description`, line.description ?? "", 4e3, true);
|
|
726
|
+
if (serviceDate) validDate(`${prefix}.serviceDate`, serviceDate);
|
|
727
|
+
if (taxCode && !/^[A-Za-z0-9]{1,20}$/.test(taxCode)) throw new TypeError(`${prefix}.taxCodeId must be a QuickBooks tax code such as TAX, NON, or 3`);
|
|
728
|
+
if (line.quantity) validDecimal(`${prefix}.quantity`, line.quantity, 5, 12, false, true);
|
|
729
|
+
if (line.unitPrice) validDecimal(`${prefix}.unitPrice`, line.unitPrice, 5, 12, true, true);
|
|
730
|
+
let amount = line.amount ?? "";
|
|
731
|
+
if (amount) validDecimal(`${prefix}.amount`, amount, 2, 10, true, true);
|
|
732
|
+
else {
|
|
733
|
+
if (!line.quantity || !line.unitPrice) throw new TypeError(`${prefix} needs an amount, or both quantity and unitPrice`);
|
|
734
|
+
amount = multiplyRoundedToCents(line.quantity, line.unitPrice);
|
|
735
|
+
validDecimal(`${prefix}.amount`, amount, 2, 10, true, true);
|
|
736
|
+
}
|
|
737
|
+
return { DetailType: "SalesItemLineDetail", Amount: rawNumber(amount), ...optional(!!line.description, "Description", line.description ?? ""), SalesItemLineDetail: { ItemRef: { value: itemID }, ...optional(!!line.quantity, "Qty", rawNumber(line.quantity ?? "")), ...optional(!!line.unitPrice, "UnitPrice", rawNumber(line.unitPrice ?? "")), ...optional(!!taxCode, "TaxCodeRef", { value: taxCode }), ...optional(!!serviceDate, "ServiceDate", serviceDate) } };
|
|
738
|
+
}
|
|
739
|
+
function multiplyRoundedToCents(quantity, unitPrice) {
|
|
740
|
+
const scaled = (value) => {
|
|
741
|
+
const sign = value.startsWith("-") ? -1n : 1n;
|
|
742
|
+
const unsigned = value.replace(/^-/, "");
|
|
743
|
+
const [whole, fraction = ""] = unsigned.split(".");
|
|
744
|
+
return { digits: sign * BigInt(whole + fraction), scale: fraction.length };
|
|
745
|
+
};
|
|
746
|
+
const left = scaled(quantity), right = scaled(unitPrice);
|
|
747
|
+
const product = left.digits * right.digits;
|
|
748
|
+
const scale = left.scale + right.scale;
|
|
749
|
+
const divisor = 10n ** BigInt(Math.max(scale - 2, 0));
|
|
750
|
+
const magnitude = product < 0n ? -product : product;
|
|
751
|
+
const cents = scale > 2 ? (magnitude + divisor / 2n) / divisor : magnitude * 10n ** BigInt(2 - scale);
|
|
752
|
+
return `${product < 0n && cents !== 0n ? "-" : ""}${cents / 100n}.${String(cents % 100n).padStart(2, "0")}`;
|
|
753
|
+
}
|
|
754
|
+
var SendInvoiceOperation = class {
|
|
755
|
+
/** Bind one client. */
|
|
756
|
+
constructor(client) {
|
|
757
|
+
this.client = client;
|
|
758
|
+
}
|
|
759
|
+
client;
|
|
760
|
+
/** Return the manifest definition. */
|
|
761
|
+
definition() {
|
|
762
|
+
return SendInvoiceDefinition;
|
|
763
|
+
}
|
|
764
|
+
/** Use Dex Call ID as QuickBooks requestid. */
|
|
765
|
+
idempotencyKey(callID) {
|
|
766
|
+
return callID;
|
|
767
|
+
}
|
|
768
|
+
/** Send and confirm one invoice delivery. */
|
|
769
|
+
async invoke(call, input) {
|
|
770
|
+
const invoiceID = input.invoiceId.trim(), sendTo = input.sendTo?.trim() ?? "", requested = { ...zeroInvoice, invoiceId: invoiceID };
|
|
771
|
+
try {
|
|
772
|
+
validID("invoiceId", invoiceID);
|
|
773
|
+
if (sendTo) validEmail("sendTo", sendTo);
|
|
774
|
+
} catch (error) {
|
|
775
|
+
return newMutationBranch("defect", requested, {}, defect(this.client, "sendInvoice", error));
|
|
776
|
+
}
|
|
777
|
+
const result = await this.client.exchange(call, "sendInvoice", { method: "POST", path: `/invoice/${invoiceID}/send`, query: sendTo ? { sendTo } : {}, mutation: true }, invoiceID);
|
|
778
|
+
const outcome = mutationOutcome(result, requested);
|
|
779
|
+
if (outcome) return outcome;
|
|
780
|
+
let cause = "invalid invoice";
|
|
781
|
+
try {
|
|
782
|
+
const invoice = decodeInvoice(entity(result.body, "Invoice"));
|
|
783
|
+
verifySent(invoice, invoiceID, sendTo);
|
|
784
|
+
return newMutationBranch("sent", invoice, result.receipt);
|
|
785
|
+
} catch (error) {
|
|
786
|
+
cause = error instanceof Error ? error.message : cause;
|
|
787
|
+
}
|
|
788
|
+
const read = await readAccepted(this.client, call, "sendInvoice", "Invoice", invoiceID);
|
|
789
|
+
if (read) try {
|
|
790
|
+
const invoice = decodeInvoice(read);
|
|
791
|
+
verifySent(invoice, invoiceID, sendTo);
|
|
792
|
+
return newMutationBranch("sent", invoice, result.receipt);
|
|
793
|
+
} catch {
|
|
794
|
+
}
|
|
795
|
+
return newMutationUncertain(requested, this.client.failure("PROTOCOL", "sendInvoice", `QuickBooks accepted the delivery but returned an unusable invoice: ${cause}`), result.receipt);
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
function verifySent(invoice, invoiceID, sendTo) {
|
|
799
|
+
if (invoice.invoiceId !== invoiceID) throw new TypeError("QuickBooks returned another invoice");
|
|
800
|
+
if (invoice.emailStatus !== "EmailSent") throw new TypeError("the returned invoice is not marked EmailSent");
|
|
801
|
+
if (sendTo && invoice.billEmail?.toLowerCase() !== sendTo.toLowerCase()) throw new TypeError("the returned invoice has another billing address");
|
|
802
|
+
}
|
|
803
|
+
var RecordPaymentOperation = class {
|
|
804
|
+
/** Bind one client. */
|
|
805
|
+
constructor(client) {
|
|
806
|
+
this.client = client;
|
|
807
|
+
}
|
|
808
|
+
client;
|
|
809
|
+
/** Return the manifest definition. */
|
|
810
|
+
definition() {
|
|
811
|
+
return RecordPaymentDefinition;
|
|
812
|
+
}
|
|
813
|
+
/** Use Dex Call ID as QuickBooks requestid. */
|
|
814
|
+
idempotencyKey(callID) {
|
|
815
|
+
return callID;
|
|
816
|
+
}
|
|
817
|
+
/** Record and confirm one payment. */
|
|
818
|
+
async invoke(call, input) {
|
|
819
|
+
const requested = { ...zeroPayment, customerId: input.customerId.trim(), totalAmount: input.amount };
|
|
820
|
+
let payload;
|
|
821
|
+
try {
|
|
822
|
+
payload = buildPaymentPayload(input);
|
|
823
|
+
} catch (error) {
|
|
824
|
+
return newMutationBranch("defect", requested, {}, defect(this.client, "recordPayment", error));
|
|
825
|
+
}
|
|
826
|
+
const result = await this.client.exchange(call, "recordPayment", { method: "POST", path: "/payment", body: encoded(payload), mutation: true });
|
|
827
|
+
const outcome = mutationOutcome(result, requested);
|
|
828
|
+
if (outcome) return outcome;
|
|
829
|
+
let cause = "invalid payment";
|
|
830
|
+
try {
|
|
831
|
+
const payment = decodePayment(entity(result.body, "Payment"));
|
|
832
|
+
verifyPayment(payment, input);
|
|
833
|
+
result.receipt.providerObjectId = payment.paymentId;
|
|
834
|
+
return newMutationBranch("recorded", payment, result.receipt);
|
|
835
|
+
} catch (error) {
|
|
836
|
+
cause = error instanceof Error ? error.message : cause;
|
|
837
|
+
}
|
|
838
|
+
const id = acceptedID(result.body, "Payment"), read = await readAccepted(this.client, call, "recordPayment", "Payment", id);
|
|
839
|
+
if (read) try {
|
|
840
|
+
const payment = decodePayment(read);
|
|
841
|
+
verifyPayment(payment, input);
|
|
842
|
+
if (payment.paymentId !== id) throw new TypeError("another payment");
|
|
843
|
+
result.receipt.providerObjectId = id;
|
|
844
|
+
return newMutationBranch("recorded", payment, result.receipt);
|
|
845
|
+
} catch {
|
|
846
|
+
}
|
|
847
|
+
return newMutationUncertain(requested, this.client.failure("PROTOCOL", "recordPayment", `QuickBooks accepted the payment but returned an unusable payment: ${cause}`), result.receipt);
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
function buildPaymentPayload(input) {
|
|
851
|
+
const customer = input.customerId.trim(), invoice = input.invoiceId.trim(), txnDate = input.txnDate?.trim() ?? "", referenceNumber = input.paymentReferenceNumber?.trim() ?? "", deposit = input.depositAccountId?.trim() ?? "", method = input.paymentMethodId?.trim() ?? "", currency = input.currencyCode?.trim() ?? "";
|
|
852
|
+
validID("customerId", customer);
|
|
853
|
+
validID("invoiceId", invoice);
|
|
854
|
+
validDecimal("amount", input.amount, 2, 10, false, false);
|
|
855
|
+
if (txnDate) validDate("txnDate", txnDate);
|
|
856
|
+
validText("paymentReferenceNumber", referenceNumber, 21);
|
|
857
|
+
validText("privateNote", input.privateNote ?? "", 4e3, true);
|
|
858
|
+
if (deposit) validID("depositAccountId", deposit);
|
|
859
|
+
if (method) validID("paymentMethodId", method);
|
|
860
|
+
validCurrency("currencyCode", currency);
|
|
861
|
+
return { CustomerRef: { value: customer }, TotalAmt: rawNumber(input.amount), ...optional(!!txnDate, "TxnDate", txnDate), Line: [{ Amount: rawNumber(input.amount), LinkedTxn: [{ TxnId: invoice, TxnType: "Invoice" }] }], ...optional(!!referenceNumber, "PaymentRefNum", referenceNumber), ...optional(!!deposit, "DepositToAccountRef", { value: deposit }), ...optional(!!method, "PaymentMethodRef", { value: method }), ...optional(!!currency, "CurrencyRef", { value: currency }), ...optional(!!input.privateNote, "PrivateNote", input.privateNote ?? "") };
|
|
862
|
+
}
|
|
863
|
+
function verifyPayment(payment, input) {
|
|
864
|
+
if (payment.customerId !== input.customerId.trim() || !payment.appliedInvoices?.some((item) => item.invoiceId === input.invoiceId.trim())) throw new TypeError("the returned payment does not apply to the invoice");
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// src/client.ts
|
|
868
|
+
var productionEndpoint = "https://quickbooks.api.intuit.com";
|
|
869
|
+
var sandboxEndpoint = "https://sandbox-quickbooks.api.intuit.com";
|
|
870
|
+
var realmPattern = /^[1-9][0-9]{0,24}$/;
|
|
871
|
+
var transactionPattern = /^[A-Za-z0-9-]{1,64}$/;
|
|
872
|
+
var QuickBooksClient = class {
|
|
873
|
+
/** Validate immutable connection configuration without contacting Intuit. */
|
|
874
|
+
constructor(config, credentials, options = {}) {
|
|
875
|
+
this.credentials = credentials;
|
|
876
|
+
if (!credentials) throw new TypeError("QuickBooks credential provider is required");
|
|
877
|
+
this.environment = config.environment === "sandbox" ? "sandbox" : "production";
|
|
878
|
+
if (config.environment && config.environment !== "production" && config.environment !== "sandbox") throw new TypeError("QuickBooks environment is invalid");
|
|
879
|
+
this.configuredRealmID = (config.realmId ?? "").trim();
|
|
880
|
+
if (this.configuredRealmID && !realmPattern.test(this.configuredRealmID)) throw new TypeError("QuickBooks realmId must be a company ID");
|
|
881
|
+
this.maxResponseBytes = config.maxResponseBytes || 4194304;
|
|
882
|
+
if (!Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes < 1) throw new TypeError("QuickBooks response limit must be positive");
|
|
883
|
+
this.endpoint = options.localProviderURL ?? (this.environment === "sandbox" ? sandboxEndpoint : productionEndpoint);
|
|
884
|
+
if (options.localProviderURL) {
|
|
885
|
+
const target = new URL(options.localProviderURL);
|
|
886
|
+
const hostname = target.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
887
|
+
const isLoopback = hostname === "localhost" || isIP2(hostname) === 4 && hostname.startsWith("127.") || hostname === "::1" || isIP2(hostname) === 6 && /^::ffff:7f[0-9a-f]{2}:[0-9a-f]{1,4}$/.test(hostname);
|
|
888
|
+
if (!isLoopback || target.pathname !== "/" || target.search || target.hash || target.username || target.password) throw new TypeError("QuickBooks local provider URL must be a loopback origin");
|
|
889
|
+
}
|
|
890
|
+
this.send = options.send ?? sendProviderRequest;
|
|
891
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
892
|
+
}
|
|
893
|
+
credentials;
|
|
894
|
+
endpoint;
|
|
895
|
+
environment;
|
|
896
|
+
configuredRealmID;
|
|
897
|
+
maxResponseBytes;
|
|
898
|
+
send;
|
|
899
|
+
now;
|
|
900
|
+
refreshDriver = new ManifestCredentialRefreshDriver({ providerName: "Intuit", auth: Authorization, credentialFields: CredentialFields });
|
|
901
|
+
/** Bind the customer lookup. */
|
|
902
|
+
findCustomer() {
|
|
903
|
+
return new FindCustomerOperation(this);
|
|
904
|
+
}
|
|
905
|
+
/** Bind customer creation. */
|
|
906
|
+
createCustomer() {
|
|
907
|
+
return new CreateCustomerOperation(this);
|
|
908
|
+
}
|
|
909
|
+
/** Bind invoice creation. */
|
|
910
|
+
createInvoice() {
|
|
911
|
+
return new CreateInvoiceOperation(this);
|
|
912
|
+
}
|
|
913
|
+
/** Bind invoice lookup. */
|
|
914
|
+
getInvoice() {
|
|
915
|
+
return new GetInvoiceOperation(this);
|
|
916
|
+
}
|
|
917
|
+
/** Bind invoice paging. */
|
|
918
|
+
listInvoices() {
|
|
919
|
+
return new ListInvoicesOperation(this);
|
|
920
|
+
}
|
|
921
|
+
/** Bind invoice delivery. */
|
|
922
|
+
sendInvoice() {
|
|
923
|
+
return new SendInvoiceOperation(this);
|
|
924
|
+
}
|
|
925
|
+
/** Bind payment recording. */
|
|
926
|
+
recordPayment() {
|
|
927
|
+
return new RecordPaymentOperation(this);
|
|
928
|
+
}
|
|
929
|
+
/** Return a secret-safe failure. */
|
|
930
|
+
failure(kind, operation, message) {
|
|
931
|
+
return { kind, provider: "quickbooks", operation, message };
|
|
932
|
+
}
|
|
933
|
+
/** Send and classify one request, preserving the original requestid after a credential refresh. */
|
|
934
|
+
async exchange(call, operation, request, objectID = "") {
|
|
935
|
+
let credentials;
|
|
936
|
+
try {
|
|
937
|
+
credentials = await resolveCredential(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
|
|
938
|
+
} catch (error) {
|
|
939
|
+
const isReauthorization = error instanceof ReauthorizationRequiredError;
|
|
940
|
+
const isMalformed = error instanceof TypeError;
|
|
941
|
+
return this.localFailure(
|
|
942
|
+
call,
|
|
943
|
+
isReauthorization ? "rejected" : isMalformed ? "defect" : "retry",
|
|
944
|
+
isReauthorization || isMalformed ? "AUTHENTICATION" : "AVAILABILITY",
|
|
945
|
+
operation,
|
|
946
|
+
isReauthorization ? "QuickBooks authorization must be renewed: connect the company again" : isMalformed ? "QuickBooks connection credentials are unavailable" : "Intuit access token refresh is temporarily unavailable",
|
|
947
|
+
objectID
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
const token = credentials.accessToken.reveal();
|
|
951
|
+
if (!isHeaderSafeCredential(token)) return this.localFailure(call, "defect", "AUTHENTICATION", operation, "QuickBooks connection credentials are unavailable", objectID);
|
|
952
|
+
let realmID;
|
|
953
|
+
try {
|
|
954
|
+
realmID = resolveRealmID(credentials, this.configuredRealmID);
|
|
955
|
+
} catch (error) {
|
|
956
|
+
return this.localFailure(call, "defect", "AUTHENTICATION", operation, error instanceof Error ? error.message : "QuickBooks company ID is invalid", objectID);
|
|
957
|
+
}
|
|
958
|
+
if (request.mutation && (!call.idempotencyKey || Buffer.byteLength(call.idempotencyKey, "utf8") > 50)) return this.localFailure(call, "defect", "LOCAL_DEFECT", operation, "QuickBooks mutation has no usable requestid", objectID);
|
|
959
|
+
const startedAt = this.now().getTime();
|
|
960
|
+
const available = Math.max(0, Math.min(3e4, (call.context.deadline?.getTime() ?? startedAt + 3e4) - startedAt));
|
|
961
|
+
const budget = { deadline: startedAt + available, minimumWriteTime: available / 10 };
|
|
962
|
+
let result = await this.sendRequest(call, operation, request, objectID, realmID, token, budget);
|
|
963
|
+
if (result.status === 401 && "resolveAfterRejection" in this.credentials) {
|
|
964
|
+
try {
|
|
965
|
+
const replacement = await resolveCredentialAfterRejection(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
|
|
966
|
+
if (isHeaderSafeCredential(replacement.accessToken.reveal()) && resolveRealmID(replacement, this.configuredRealmID) === realmID) result = await this.sendRequest(call, operation, request, objectID, realmID, replacement.accessToken.reveal(), budget);
|
|
967
|
+
} catch {
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
result.receipt.metadata = { ...result.receipt.metadata ?? {}, realmId: realmID, environment: this.environment };
|
|
971
|
+
return result;
|
|
972
|
+
}
|
|
973
|
+
localFailure(call, disposition, kind, operation, message, objectID = "") {
|
|
974
|
+
return { disposition, failure: this.failure(kind, operation, message), retryAfterMs: 0, status: 0, receipt: this.receipt(call, objectID) };
|
|
975
|
+
}
|
|
976
|
+
/** Create a receipt after a provider attempt. */
|
|
977
|
+
receipt(call, objectID) {
|
|
978
|
+
return { callId: call.id, provider: "quickbooks", observedAt: this.now().toISOString(), ...call.idempotencyKey ? { idempotencyKey: call.idempotencyKey } : {}, ...objectID ? { providerObjectId: objectID } : {} };
|
|
979
|
+
}
|
|
980
|
+
async sendRequest(call, operation, request, objectID, realmID, token, budget) {
|
|
981
|
+
const receipt = this.receipt(call, objectID);
|
|
982
|
+
const now = this.now().getTime();
|
|
983
|
+
if (request.mutation && (budget.minimumWriteTime <= 0 || budget.deadline - now < budget.minimumWriteTime)) return this.localFailure(call, "retry", "TRANSPORT", operation, "QuickBooks write was not sent because too little attempt time remains", objectID);
|
|
984
|
+
if (call.context.cancellationSignal.aborted) return this.localFailure(call, "retry", "TRANSPORT", operation, "QuickBooks attempt has no time left for a request; no request was sent", objectID);
|
|
985
|
+
const deadline = Math.min(call.context.deadline?.getTime() ?? Infinity, request.mutation ? budget.deadline : Infinity);
|
|
986
|
+
if (deadline !== Infinity && deadline - now <= 500) return this.localFailure(call, "retry", "TRANSPORT", operation, "QuickBooks attempt has no time left for a request; no request was sent", objectID);
|
|
987
|
+
const timeoutMs = Math.min(2e4, deadline === Infinity ? 2e4 : deadline - now - 500);
|
|
988
|
+
const query = goQueryEncode({ ...request.query ?? {}, minorversion: "75", ...request.mutation ? { requestid: call.idempotencyKey } : {} });
|
|
989
|
+
const url = `${this.endpoint}/v3/company/${realmID}${request.path}?${query}`;
|
|
990
|
+
const headers = { Authorization: `Bearer ${token}`, Accept: "application/json", ...request.body ? { "Content-Type": "application/json" } : request.method === "POST" ? { "Content-Type": "application/octet-stream" } : {} };
|
|
991
|
+
let response;
|
|
992
|
+
let observedStatus = 0;
|
|
993
|
+
let observedHeaders = {};
|
|
994
|
+
try {
|
|
995
|
+
response = await this.send({ url, method: request.method, headers, ...request.body ? { body: request.body } : {}, maxResponseBytes: this.maxResponseBytes, maxErrorResponseBytes: 65536, ignoreErrorBodyReadFailure: true, addressPolicy: this.endpoint.startsWith("https://") ? "publicHTTPS" : "privateNetworkHTTP", timeoutMs, signal: call.context.cancellationSignal, onResponseChunk: (_chunk, status, responseHeaders) => {
|
|
996
|
+
observedStatus = status;
|
|
997
|
+
observedHeaders = responseHeaders;
|
|
998
|
+
} });
|
|
999
|
+
} catch (error) {
|
|
1000
|
+
if (error instanceof BodyTooLargeError) {
|
|
1001
|
+
const transaction2 = error.headers?.intuit_tid;
|
|
1002
|
+
const transactionID3 = Array.isArray(transaction2) ? transaction2[0] : transaction2;
|
|
1003
|
+
if (transactionID3 && transactionPattern.test(transactionID3)) receipt.providerRequestId = transactionID3;
|
|
1004
|
+
return { disposition: "invalid", status: error.status ?? 0, failure: this.failure("RESPONSE_TOO_LARGE", operation, "QuickBooks response exceeds the configured maxResponseBytes limit"), receipt, retryAfterMs: 0 };
|
|
1005
|
+
}
|
|
1006
|
+
const transaction = observedHeaders.intuit_tid;
|
|
1007
|
+
const transactionID2 = Array.isArray(transaction) ? transaction[0] : transaction;
|
|
1008
|
+
if (transactionID2 && transactionPattern.test(transactionID2)) receipt.providerRequestId = transactionID2;
|
|
1009
|
+
if (observedStatus >= 200 && observedStatus < 300) return { disposition: "interrupted", status: observedStatus, failure: this.failure("TRANSPORT", operation, "QuickBooks response was interrupted"), receipt, retryAfterMs: 0 };
|
|
1010
|
+
return { disposition: "retry", status: observedStatus, failure: this.failure("TRANSPORT", operation, "QuickBooks request failed before a response arrived"), receipt, retryAfterMs: 0 };
|
|
1011
|
+
}
|
|
1012
|
+
const transactionID = response.headers.intuit_tid;
|
|
1013
|
+
const reportedID = Array.isArray(transactionID) ? transactionID[0] : transactionID;
|
|
1014
|
+
if (reportedID && transactionPattern.test(reportedID)) receipt.providerRequestId = reportedID;
|
|
1015
|
+
if (response.status >= 200 && response.status < 300) {
|
|
1016
|
+
if (Buffer.from(response.body).includes(token)) return { disposition: "invalid", status: response.status, failure: this.failure("PROTOCOL", operation, "QuickBooks response reflected the connection credential"), receipt, retryAfterMs: 0 };
|
|
1017
|
+
const fault = summarizeFault(response.body);
|
|
1018
|
+
if (fault.type || fault.count) return this.classifyStatus(operation, response, receipt, fault);
|
|
1019
|
+
return { disposition: "succeeded", status: response.status, body: response.body, receipt, retryAfterMs: 0 };
|
|
1020
|
+
}
|
|
1021
|
+
return this.classifyStatus(operation, response, receipt, summarizeFault(response.body));
|
|
1022
|
+
}
|
|
1023
|
+
classifyStatus(operation, response, receipt, fault) {
|
|
1024
|
+
const status = response.status;
|
|
1025
|
+
if (fault.codes.length) receipt.metadata = { faultCode: fault.codes[0] };
|
|
1026
|
+
const suffix = `${fault.type ? fault.type : ""}${fault.codes.length ? `${fault.type ? "; " : ""}code ${fault.codes.join(", ")}` : ""}${fault.count > 1 ? `${fault.type || fault.codes.length ? "; " : ""}${fault.count} errors` : ""}`;
|
|
1027
|
+
const classified = (disposition, kind, message, retryAfterMs = 0) => ({ disposition, status, failure: this.failure(kind, operation, `${message} (HTTP ${status})${suffix ? ` [${suffix}]` : ""}`), receipt, retryAfterMs });
|
|
1028
|
+
if (status === 429) return classified("retry", "RATE_LIMIT", "QuickBooks throttled the request", parseRetryAfter(String(response.headers["retry-after"] ?? ""), this.now()) || 6e4);
|
|
1029
|
+
if (status === 501) return classified("rejected", "PROVIDER_REJECTION", "QuickBooks does not implement the request");
|
|
1030
|
+
if (status === 408 || status >= 500) return classified("retry", "AVAILABILITY", "QuickBooks is temporarily unavailable");
|
|
1031
|
+
if (status === 401) return classified("rejected", "AUTHENTICATION", "QuickBooks rejected the access token");
|
|
1032
|
+
if (status === 403) return fault.codes.includes("3100") ? classified("rejected", "AUTHORIZATION", "QuickBooks token lacks the com.intuit.quickbooks.accounting scope") : classified("rejected", "AUTHORIZATION", "QuickBooks denied access to the company or the request");
|
|
1033
|
+
if (status === 404) return classified("notFound", "NOT_FOUND", "QuickBooks found no such resource");
|
|
1034
|
+
if (status === 409) return classified("retry", "CONFLICT", "QuickBooks returned a conflict; retrying the same requestid");
|
|
1035
|
+
if (fault.codes.includes("600")) return classified("retry", "CONFLICT", "QuickBooks is still answering an earlier attempt with this requestid");
|
|
1036
|
+
if (fault.codes.includes("610")) return classified("notFound", "NOT_FOUND", "QuickBooks found no such object");
|
|
1037
|
+
if (fault.codes.includes("6240")) return classified("nameConflict", "CONFLICT", "QuickBooks already has a name list entry with that display name");
|
|
1038
|
+
if (fault.codes.includes("6140")) return classified("rejected", "CONFLICT", "QuickBooks already has a transaction with that document number");
|
|
1039
|
+
if (fault.type.toLowerCase() === "authenticationfault") return classified("rejected", "AUTHENTICATION", "QuickBooks rejected the authentication");
|
|
1040
|
+
if (fault.type.toLowerCase() === "authorizationfault") return classified("rejected", "AUTHORIZATION", "QuickBooks denied the request");
|
|
1041
|
+
if (fault.type.toLowerCase() === "systemfault") return classified("retry", "AVAILABILITY", "QuickBooks failed internally");
|
|
1042
|
+
if (status === 400) return classified("rejected", "VALIDATION", "QuickBooks rejected the request");
|
|
1043
|
+
if (status >= 200 && status < 300) return classified("rejected", "VALIDATION", "QuickBooks rejected the request");
|
|
1044
|
+
if (status >= 300 && status < 400) return classified("rejected", "PROTOCOL", "QuickBooks redirected the request");
|
|
1045
|
+
return classified("rejected", "PROVIDER_REJECTION", "QuickBooks rejected the request");
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
function summarizeFault(body) {
|
|
1049
|
+
try {
|
|
1050
|
+
const parseWithSource = JSON.parse;
|
|
1051
|
+
const parsed = parseWithSource(Buffer.from(body).toString("utf8"), (_key, value, context) => typeof value === "number" ? context.source ?? String(value) : value);
|
|
1052
|
+
if (!parsed || typeof parsed !== "object" || !("Fault" in parsed) || !parsed.Fault || typeof parsed.Fault !== "object") return { type: "", codes: [], count: 0 };
|
|
1053
|
+
const fault = parsed.Fault;
|
|
1054
|
+
if (fault.type != null && typeof fault.type !== "string") return { type: "", codes: [], count: 0 };
|
|
1055
|
+
if (fault.Error != null && (!Array.isArray(fault.Error) || fault.Error.some((item) => !item || typeof item !== "object" || Array.isArray(item)))) return { type: "", codes: [], count: 0 };
|
|
1056
|
+
const errors = Array.isArray(fault.Error) ? fault.Error.slice(0, 1e3) : [];
|
|
1057
|
+
const codes = errors.flatMap((error) => {
|
|
1058
|
+
const code = error && typeof error === "object" ? error.code : void 0;
|
|
1059
|
+
const text = typeof code === "number" || typeof code === "string" ? String(code) : "";
|
|
1060
|
+
return /^[0-9]{1,10}$/.test(text) ? [text] : [];
|
|
1061
|
+
}).slice(0, 5);
|
|
1062
|
+
return { type: typeof fault.type === "string" && /^[A-Za-z]{1,64}$/.test(fault.type) ? fault.type : "", codes, count: errors.length };
|
|
1063
|
+
} catch {
|
|
1064
|
+
return { type: "", codes: [], count: 0 };
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
function resolveRealmID(credentials, configured) {
|
|
1068
|
+
const token = credentials.idToken?.reveal() ?? "";
|
|
1069
|
+
if (!token) {
|
|
1070
|
+
if (configured) return configured;
|
|
1071
|
+
throw new TypeError("QuickBooks company ID is unknown: authorize again while signed in to the company, or enter its company ID in realmId");
|
|
1072
|
+
}
|
|
1073
|
+
if (Buffer.byteLength(token, "utf8") > 16384) throw new TypeError("QuickBooks ID token is too large");
|
|
1074
|
+
const parts = token.split(".");
|
|
1075
|
+
if (parts.length !== 3) throw new TypeError("QuickBooks ID token is not a JWT");
|
|
1076
|
+
const payloadSegment = parts[1].replace(/=+$/, "");
|
|
1077
|
+
if (!/^[A-Za-z0-9_-]+$/.test(payloadSegment) || payloadSegment.length % 4 === 1) throw new TypeError("QuickBooks ID token payload is not base64url");
|
|
1078
|
+
let claims;
|
|
1079
|
+
try {
|
|
1080
|
+
const decoded = JSON.parse(Buffer.from(payloadSegment, "base64url").toString("utf8"));
|
|
1081
|
+
if (!decoded || typeof decoded !== "object" || Array.isArray(decoded)) throw new TypeError("invalid object");
|
|
1082
|
+
claims = decoded;
|
|
1083
|
+
} catch {
|
|
1084
|
+
throw new TypeError("QuickBooks ID token payload is not a JSON object");
|
|
1085
|
+
}
|
|
1086
|
+
if (claims.iss !== "https://oauth.platform.intuit.com/op/v1") throw new TypeError("QuickBooks ID token was not issued by Intuit");
|
|
1087
|
+
const audience = claims.aud;
|
|
1088
|
+
if (!credentials.clientId || !(audience === credentials.clientId || Array.isArray(audience) && audience.every((value) => typeof value === "string") && audience.includes(credentials.clientId))) throw new TypeError("QuickBooks ID token was issued to another app");
|
|
1089
|
+
const realm = claims.realmid;
|
|
1090
|
+
if (!realm) {
|
|
1091
|
+
if (configured) return configured;
|
|
1092
|
+
throw new TypeError("QuickBooks company ID is unknown: authorize again while signed in to the company, or enter its company ID in realmId");
|
|
1093
|
+
}
|
|
1094
|
+
if (typeof realm !== "string" || !realmPattern.test(realm)) throw new TypeError("QuickBooks ID token realmid is not a company ID");
|
|
1095
|
+
if (configured && configured !== realm) throw new TypeError("the realmId setting names another company than the one Intuit authorized: clear it or authorize that company");
|
|
1096
|
+
return realm;
|
|
1097
|
+
}
|
|
1098
|
+
function goQueryEncode(values) {
|
|
1099
|
+
return Object.keys(values).sort((left, right) => Buffer.compare(Buffer.from(left), Buffer.from(right))).flatMap((key) => {
|
|
1100
|
+
const entry = values[key];
|
|
1101
|
+
return (typeof entry === "string" ? [entry] : entry).map((value) => `${goQueryEscape(key)}=${goQueryEscape(value)}`);
|
|
1102
|
+
}).join("&");
|
|
1103
|
+
}
|
|
1104
|
+
function goQueryEscape(value) {
|
|
1105
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%20/g, "+");
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
// src/generated/steps.ts
|
|
1109
|
+
import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
|
|
1110
|
+
function newFindCustomerStep(configuration) {
|
|
1111
|
+
const { connection, connectionName, found, notFound, ambiguous, providerRejected, invalidResponse, defect: defect2, ...stepConfiguration } = configuration;
|
|
1112
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
1113
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.findCustomer(), connection: connection.reference, branches: [
|
|
1114
|
+
goToBranch("found", found),
|
|
1115
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
1116
|
+
...ambiguous ? [goToBranch("ambiguous", ambiguous)] : [],
|
|
1117
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
1118
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
1119
|
+
...defect2 ? [goToBranch("defect", defect2)] : []
|
|
1120
|
+
] });
|
|
1121
|
+
}
|
|
1122
|
+
function newCreateCustomerStep(configuration) {
|
|
1123
|
+
const { connection, connectionName, created, nameConflict, providerRejected, uncertain, defect: defect2, ...stepConfiguration } = configuration;
|
|
1124
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
1125
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.createCustomer(), connection: connection.reference, branches: [
|
|
1126
|
+
goToBranch("created", created),
|
|
1127
|
+
...nameConflict ? [goToBranch("nameConflict", nameConflict)] : [],
|
|
1128
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
1129
|
+
...uncertain ? [goToBranch("uncertain", uncertain)] : [],
|
|
1130
|
+
...defect2 ? [goToBranch("defect", defect2)] : []
|
|
1131
|
+
] });
|
|
1132
|
+
}
|
|
1133
|
+
function newCreateInvoiceStep(configuration) {
|
|
1134
|
+
const { connection, connectionName, created, providerRejected, uncertain, defect: defect2, ...stepConfiguration } = configuration;
|
|
1135
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
1136
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.createInvoice(), connection: connection.reference, branches: [
|
|
1137
|
+
goToBranch("created", created),
|
|
1138
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
1139
|
+
...uncertain ? [goToBranch("uncertain", uncertain)] : [],
|
|
1140
|
+
...defect2 ? [goToBranch("defect", defect2)] : []
|
|
1141
|
+
] });
|
|
1142
|
+
}
|
|
1143
|
+
function newGetInvoiceStep(configuration) {
|
|
1144
|
+
const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect: defect2, ...stepConfiguration } = configuration;
|
|
1145
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
1146
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getInvoice(), connection: connection.reference, branches: [
|
|
1147
|
+
goToBranch("found", found),
|
|
1148
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
1149
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
1150
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
1151
|
+
...defect2 ? [goToBranch("defect", defect2)] : []
|
|
1152
|
+
] });
|
|
1153
|
+
}
|
|
1154
|
+
function newListInvoicesStep(configuration) {
|
|
1155
|
+
const { connection, connectionName, listed, providerRejected, invalidResponse, defect: defect2, ...stepConfiguration } = configuration;
|
|
1156
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
1157
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.listInvoices(), connection: connection.reference, branches: [
|
|
1158
|
+
goToBranch("listed", listed),
|
|
1159
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
1160
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
1161
|
+
...defect2 ? [goToBranch("defect", defect2)] : []
|
|
1162
|
+
] });
|
|
1163
|
+
}
|
|
1164
|
+
function newSendInvoiceStep(configuration) {
|
|
1165
|
+
const { connection, connectionName, sent, providerRejected, uncertain, defect: defect2, ...stepConfiguration } = configuration;
|
|
1166
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
1167
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.sendInvoice(), connection: connection.reference, branches: [
|
|
1168
|
+
goToBranch("sent", sent),
|
|
1169
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
1170
|
+
...uncertain ? [goToBranch("uncertain", uncertain)] : [],
|
|
1171
|
+
...defect2 ? [goToBranch("defect", defect2)] : []
|
|
1172
|
+
] });
|
|
1173
|
+
}
|
|
1174
|
+
function newRecordPaymentStep(configuration) {
|
|
1175
|
+
const { connection, connectionName, recorded, providerRejected, uncertain, defect: defect2, ...stepConfiguration } = configuration;
|
|
1176
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
1177
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.recordPayment(), connection: connection.reference, branches: [
|
|
1178
|
+
goToBranch("recorded", recorded),
|
|
1179
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
1180
|
+
...uncertain ? [goToBranch("uncertain", uncertain)] : [],
|
|
1181
|
+
...defect2 ? [goToBranch("defect", defect2)] : []
|
|
1182
|
+
] });
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
// src/project.ts
|
|
1186
|
+
function encodeCredentials(credentials) {
|
|
1187
|
+
return { client_id: credentials.clientId, client_secret: credentials.clientSecret.reveal(), access_token: credentials.accessToken.reveal(), refresh_token: credentials.refreshToken.reveal(), id_token: credentials.idToken?.reveal() ?? "" };
|
|
1188
|
+
}
|
|
1189
|
+
function newProjectConnection2(project, connectionName, options = {}) {
|
|
1190
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
1191
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "quickbooks" && entry.connectionName === name);
|
|
1192
|
+
if (!selected) throw new TypeError("QuickBooks project connection is not configured");
|
|
1193
|
+
const settings = ConfigSchema.parse(selected.configuration);
|
|
1194
|
+
const config = {
|
|
1195
|
+
...settings.environment !== void 0 ? { environment: settings.environment } : {},
|
|
1196
|
+
...settings.realmId !== void 0 ? { realmId: settings.realmId } : {},
|
|
1197
|
+
...settings.maxResponseBytes !== void 0 ? { maxResponseBytes: settings.maxResponseBytes } : {}
|
|
1198
|
+
};
|
|
1199
|
+
return new QuickBooksClient(config, newProjectCredentialProvider(loadedProject, name, decodeCredentials, encodeCredentials, decodeSharedCredentials), options);
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
export {
|
|
1203
|
+
ConfigSchema,
|
|
1204
|
+
Connection,
|
|
1205
|
+
ConnectorID,
|
|
1206
|
+
CreateCustomerBranch,
|
|
1207
|
+
CreateCustomerBranchCreated,
|
|
1208
|
+
CreateCustomerBranchDefect,
|
|
1209
|
+
CreateCustomerBranchNameConflict,
|
|
1210
|
+
CreateCustomerBranchProviderRejected,
|
|
1211
|
+
CreateCustomerBranchUncertain,
|
|
1212
|
+
CreateCustomerDefinition,
|
|
1213
|
+
CreateCustomerInputSchema,
|
|
1214
|
+
CreateCustomerMetadata,
|
|
1215
|
+
CreateCustomerOutputSchema,
|
|
1216
|
+
CreateInvoiceBranch,
|
|
1217
|
+
CreateInvoiceBranchCreated,
|
|
1218
|
+
CreateInvoiceBranchDefect,
|
|
1219
|
+
CreateInvoiceBranchProviderRejected,
|
|
1220
|
+
CreateInvoiceBranchUncertain,
|
|
1221
|
+
CreateInvoiceDefinition,
|
|
1222
|
+
CreateInvoiceInputSchema,
|
|
1223
|
+
CreateInvoiceMetadata,
|
|
1224
|
+
CreateInvoiceOutputSchema,
|
|
1225
|
+
CustomerSchema,
|
|
1226
|
+
FindCustomerBranch,
|
|
1227
|
+
FindCustomerBranchAmbiguous,
|
|
1228
|
+
FindCustomerBranchDefect,
|
|
1229
|
+
FindCustomerBranchFound,
|
|
1230
|
+
FindCustomerBranchInvalidResponse,
|
|
1231
|
+
FindCustomerBranchNotFound,
|
|
1232
|
+
FindCustomerBranchProviderRejected,
|
|
1233
|
+
FindCustomerDefinition,
|
|
1234
|
+
FindCustomerInputSchema,
|
|
1235
|
+
FindCustomerMetadata,
|
|
1236
|
+
FindCustomerOutputSchema,
|
|
1237
|
+
GetInvoiceBranch,
|
|
1238
|
+
GetInvoiceBranchDefect,
|
|
1239
|
+
GetInvoiceBranchFound,
|
|
1240
|
+
GetInvoiceBranchInvalidResponse,
|
|
1241
|
+
GetInvoiceBranchNotFound,
|
|
1242
|
+
GetInvoiceBranchProviderRejected,
|
|
1243
|
+
GetInvoiceDefinition,
|
|
1244
|
+
GetInvoiceInputSchema,
|
|
1245
|
+
GetInvoiceMetadata,
|
|
1246
|
+
InvoiceLineInputSchema,
|
|
1247
|
+
InvoiceLineSchema,
|
|
1248
|
+
InvoicePageSchema,
|
|
1249
|
+
InvoiceSchema,
|
|
1250
|
+
ListInvoicesBranch,
|
|
1251
|
+
ListInvoicesBranchDefect,
|
|
1252
|
+
ListInvoicesBranchInvalidResponse,
|
|
1253
|
+
ListInvoicesBranchListed,
|
|
1254
|
+
ListInvoicesBranchProviderRejected,
|
|
1255
|
+
ListInvoicesDefinition,
|
|
1256
|
+
ListInvoicesInputSchema,
|
|
1257
|
+
ListInvoicesMetadata,
|
|
1258
|
+
PaymentApplicationSchema,
|
|
1259
|
+
PaymentSchema,
|
|
1260
|
+
ProviderID,
|
|
1261
|
+
QuickBooksClient,
|
|
1262
|
+
RecordPaymentBranch,
|
|
1263
|
+
RecordPaymentBranchDefect,
|
|
1264
|
+
RecordPaymentBranchProviderRejected,
|
|
1265
|
+
RecordPaymentBranchRecorded,
|
|
1266
|
+
RecordPaymentBranchUncertain,
|
|
1267
|
+
RecordPaymentDefinition,
|
|
1268
|
+
RecordPaymentInputSchema,
|
|
1269
|
+
RecordPaymentMetadata,
|
|
1270
|
+
SendInvoiceBranch,
|
|
1271
|
+
SendInvoiceBranchDefect,
|
|
1272
|
+
SendInvoiceBranchProviderRejected,
|
|
1273
|
+
SendInvoiceBranchSent,
|
|
1274
|
+
SendInvoiceBranchUncertain,
|
|
1275
|
+
SendInvoiceDefinition,
|
|
1276
|
+
SendInvoiceInputSchema,
|
|
1277
|
+
SendInvoiceMetadata,
|
|
1278
|
+
decodeCredentials,
|
|
1279
|
+
decodeSharedCredentials,
|
|
1280
|
+
newConnection,
|
|
1281
|
+
newConnectionWithOperations,
|
|
1282
|
+
newCreateCustomerStep,
|
|
1283
|
+
newCreateInvoiceStep,
|
|
1284
|
+
newFindCustomerStep,
|
|
1285
|
+
newGetInvoiceStep,
|
|
1286
|
+
newListInvoicesStep,
|
|
1287
|
+
newProjectConnection2 as newProjectConnection,
|
|
1288
|
+
newProjectCredentialProvider,
|
|
1289
|
+
newRecordPaymentStep,
|
|
1290
|
+
newSendInvoiceStep
|
|
1291
|
+
};
|