nxus-qbd 0.6.2 → 0.7.2
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 -21
- package/README.md +369 -340
- package/dist/client.d.ts +11 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -0
- package/dist/client.js.map +1 -1
- package/dist/generated/index.d.ts +1 -1
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/types.gen.d.ts +11114 -10110
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/generated/types.gen.js +167 -118
- package/dist/generated/types.gen.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/models/core/connections.d.ts +1 -1
- package/dist/models/core/connections.d.ts.map +1 -1
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -2
- package/dist/models/index.js.map +1 -1
- package/dist/models/qbd/custom_field_definitions.d.ts +2 -0
- package/dist/models/qbd/custom_field_definitions.d.ts.map +1 -0
- package/dist/models/qbd/custom_field_definitions.js +2 -0
- package/dist/models/qbd/custom_field_definitions.js.map +1 -0
- package/dist/models/qbd/custom_fields.d.ts +3 -0
- package/dist/models/qbd/custom_fields.d.ts.map +1 -0
- package/dist/models/qbd/custom_fields.js +3 -0
- package/dist/models/qbd/custom_fields.js.map +1 -0
- package/dist/models/qbd/index.d.ts +2 -0
- package/dist/models/qbd/index.d.ts.map +1 -1
- package/dist/models/qbd/index.js +2 -0
- package/dist/models/qbd/index.js.map +1 -1
- package/dist/models/qbd/sales_receipt.d.ts +1 -1
- package/dist/models/qbd/sales_receipt.d.ts.map +1 -1
- package/dist/resources/custom-fields.d.ts +123 -0
- package/dist/resources/custom-fields.d.ts.map +1 -0
- package/dist/resources/custom-fields.js +204 -0
- package/dist/resources/custom-fields.js.map +1 -0
- package/package.json +3 -3
- package/dist/models/qbd/bill_to_pay.d.ts +0 -2
- package/dist/models/qbd/bill_to_pay.d.ts.map +0 -1
- package/dist/models/qbd/bill_to_pay.js +0 -2
- package/dist/models/qbd/bill_to_pay.js.map +0 -1
- package/dist/models/qbd/check_bill.d.ts +0 -2
- package/dist/models/qbd/check_bill.d.ts.map +0 -1
- package/dist/models/qbd/check_bill.js +0 -2
- package/dist/models/qbd/check_bill.js.map +0 -1
- package/dist/models/qbd/credit_card_bill.d.ts +0 -2
- package/dist/models/qbd/credit_card_bill.d.ts.map +0 -1
- package/dist/models/qbd/credit_card_bill.js +0 -2
- package/dist/models/qbd/credit_card_bill.js.map +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Field (DataExt) resources.
|
|
3
|
+
*
|
|
4
|
+
* QuickBooks Desktop exposes user-defined custom fields through two distinct
|
|
5
|
+
* concerns, and the backend mirrors that split across two route families that
|
|
6
|
+
* do NOT follow the usual REST CRUD convention (no `/{id}` path segment — the
|
|
7
|
+
* target is always carried in the request body):
|
|
8
|
+
*
|
|
9
|
+
* • **Definitions** (`/api/v1/custom-field-definitions`) — the schema of a
|
|
10
|
+
* custom field: its name, data type, which QBD objects it attaches to, and
|
|
11
|
+
* whether it is required. Backed by QBXML `DataExtDefAdd/Mod/Del/Query`.
|
|
12
|
+
*
|
|
13
|
+
* • **Values** (`/api/v1/custom-fields`) — a single value assigned to a named
|
|
14
|
+
* field on one concrete target object (a list entity, a transaction, or a
|
|
15
|
+
* transaction line). Backed by QBXML `DataExtAdd/Mod/Del`.
|
|
16
|
+
*
|
|
17
|
+
* Both families use POST for create AND update (update lives on a `/update`
|
|
18
|
+
* sub-path) and DELETE with a JSON body. Listing definitions is a plain `GET`
|
|
19
|
+
* on the base route (`list()`), like every other list endpoint in the API.
|
|
20
|
+
* Because none of that maps onto the generic `Resource<T>` (which keys
|
|
21
|
+
* everything off an id path segment), these are hand-written.
|
|
22
|
+
*/
|
|
23
|
+
import type { NxusHttpTransport, RequestOptions } from '../transport';
|
|
24
|
+
import type { CreateCustomFieldDefinitionRequest, UpdateCustomFieldDefinitionRequest, DeleteCustomFieldDefinitionRequest, DataExtDef, CreateCustomFieldValueRequest, UpdateCustomFieldValueRequest, DeleteCustomFieldValueRequest, DataExtDataExt, DeleteResponse } from '../generated/types.gen';
|
|
25
|
+
/**
|
|
26
|
+
* Optional filters for {@link CustomFieldDefinitionsResource.list}. Mirrors the
|
|
27
|
+
* `query` block of the generated `ListCustomFieldDefinitionsData`, flattened to
|
|
28
|
+
* the SDK's camelCase surface (the resource maps them to the `OwnerIds` /
|
|
29
|
+
* `AssignToObjects` wire query keys).
|
|
30
|
+
*/
|
|
31
|
+
export interface ListCustomFieldDefinitionsParams {
|
|
32
|
+
/** Restrict to the given owner ids (`"0"` = public / UI-defined fields). */
|
|
33
|
+
ownerIds?: Array<string>;
|
|
34
|
+
/** Restrict to definitions assignable to any of the given object types. */
|
|
35
|
+
assignToObjects?: Array<string>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Which family of QuickBooks object a custom field value attaches to.
|
|
39
|
+
* Mirrors the backend `DataExtTargetKind` enum (a C# enum serialized as its
|
|
40
|
+
* integer value): a list entity, a transaction (optionally one line), or the
|
|
41
|
+
* company file itself.
|
|
42
|
+
*/
|
|
43
|
+
export declare const DataExtTargetKind: {
|
|
44
|
+
/** A list entity (Customer, Vendor, Employee, Item, Account, OtherName). */
|
|
45
|
+
readonly List: 0;
|
|
46
|
+
/** A transaction (optionally a single transaction line). */
|
|
47
|
+
readonly Transaction: 1;
|
|
48
|
+
/** The company file itself. */
|
|
49
|
+
readonly Company: 2;
|
|
50
|
+
};
|
|
51
|
+
export type DataExtTargetKindValue = (typeof DataExtTargetKind)[keyof typeof DataExtTargetKind];
|
|
52
|
+
/**
|
|
53
|
+
* Manage custom field *definitions* (the schema). DataExtDef in QBXML.
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* // Define a string field on Customers and Invoices
|
|
57
|
+
* const def = await client.customFieldDefinitions.create({
|
|
58
|
+
* ownerId: "0",
|
|
59
|
+
* name: "SdkTestField",
|
|
60
|
+
* type: DataExtensionType.STR255TYPE,
|
|
61
|
+
* assignToObjects: ["Customer", "Invoice"],
|
|
62
|
+
* listRequired: false,
|
|
63
|
+
* transactionRequired: false,
|
|
64
|
+
* connectionId: "conn_...",
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare class CustomFieldDefinitionsResource {
|
|
69
|
+
private readonly transport;
|
|
70
|
+
constructor(transport: NxusHttpTransport);
|
|
71
|
+
private static readonly BASE;
|
|
72
|
+
/** Create a new custom field definition. Returns the created `DataExtDef`. */
|
|
73
|
+
create(params: CreateCustomFieldDefinitionRequest & RequestOptions): Promise<DataExtDef>;
|
|
74
|
+
/**
|
|
75
|
+
* Update an existing definition (rename, change type, add/remove target
|
|
76
|
+
* objects, toggle required). POSTs to the `/update` sub-path.
|
|
77
|
+
*/
|
|
78
|
+
update(params: UpdateCustomFieldDefinitionRequest & RequestOptions): Promise<DataExtDef>;
|
|
79
|
+
/**
|
|
80
|
+
* List definitions. All filters are optional — omit them to fetch every
|
|
81
|
+
* definition visible to the connection. This is a plain `GET` on the base
|
|
82
|
+
* route (matching every other list endpoint in the API); the filters are
|
|
83
|
+
* repeated query-string params, not a request body. Returns a flat array
|
|
84
|
+
* (not paginated).
|
|
85
|
+
*
|
|
86
|
+
* @param params.ownerIds Restrict to the given owner ids
|
|
87
|
+
* (`"0"` selects public / UI-defined fields).
|
|
88
|
+
* @param params.assignToObjects Restrict to definitions assignable to any of
|
|
89
|
+
* the given object types (`Customer`, `Vendor`, `Invoice`, …).
|
|
90
|
+
*/
|
|
91
|
+
list(params?: ListCustomFieldDefinitionsParams & RequestOptions): Promise<Array<DataExtDef>>;
|
|
92
|
+
/**
|
|
93
|
+
* Delete a definition by owner + name (DELETE with a JSON body — there is no
|
|
94
|
+
* id path segment). Returns the standard `DeleteResponse`.
|
|
95
|
+
*/
|
|
96
|
+
delete(params: DeleteCustomFieldDefinitionRequest & RequestOptions): Promise<DeleteResponse>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Assign / change / clear custom field *values* on a concrete QBD target.
|
|
100
|
+
* DataExt in QBXML. The `target` selects the object the value attaches to:
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* await client.customFields.create({
|
|
104
|
+
* ownerId: "0",
|
|
105
|
+
* name: "SdkTestField",
|
|
106
|
+
* value: "hello-from-sdk",
|
|
107
|
+
* target: { kind: DataExtTargetKind.List, listType: ListType.CUSTOMER, fullName: "Acme" },
|
|
108
|
+
* connectionId: "conn_...",
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export declare class CustomFieldsResource {
|
|
113
|
+
private readonly transport;
|
|
114
|
+
constructor(transport: NxusHttpTransport);
|
|
115
|
+
private static readonly BASE;
|
|
116
|
+
/** Assign a value to a named custom field on a target. Returns `DataExtDataExt`. */
|
|
117
|
+
create(params: CreateCustomFieldValueRequest & RequestOptions): Promise<DataExtDataExt>;
|
|
118
|
+
/** Change an existing value. POSTs to the `/update` sub-path. */
|
|
119
|
+
update(params: UpdateCustomFieldValueRequest & RequestOptions): Promise<DataExtDataExt>;
|
|
120
|
+
/** Clear a value (DELETE with a JSON body). Returns `DeleteResponse`. */
|
|
121
|
+
delete(params: DeleteCustomFieldValueRequest & RequestOptions): Promise<DeleteResponse>;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=custom-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-fields.d.ts","sourceRoot":"","sources":["../../src/resources/custom-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EA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AAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,iBAAiB;IAEzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAA2B;IAEvD,oFAAoF;IAC9E,MAAM,CACV,MAAM,EAAE,6BAA6B,GAAG,cAAc,GACrD,OAAO,CAAC,cAAc,CAAC;IAS1B,iEAAiE;IAC3D,MAAM,CACV,MAAM,EAAE,6BAA6B,GAAG,cAAc,GACrD,OAAO,CAAC,cAAc,CAAC;IAS1B,yEAAyE;IACnE,MAAM,CACV,MAAM,EAAE,6BAA6B,GAAG,cAAc,GACrD,OAAO,CAAC,cAAc,CAAC;CAS3B"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Field (DataExt) resources.
|
|
3
|
+
*
|
|
4
|
+
* QuickBooks Desktop exposes user-defined custom fields through two distinct
|
|
5
|
+
* concerns, and the backend mirrors that split across two route families that
|
|
6
|
+
* do NOT follow the usual REST CRUD convention (no `/{id}` path segment — the
|
|
7
|
+
* target is always carried in the request body):
|
|
8
|
+
*
|
|
9
|
+
* • **Definitions** (`/api/v1/custom-field-definitions`) — the schema of a
|
|
10
|
+
* custom field: its name, data type, which QBD objects it attaches to, and
|
|
11
|
+
* whether it is required. Backed by QBXML `DataExtDefAdd/Mod/Del/Query`.
|
|
12
|
+
*
|
|
13
|
+
* • **Values** (`/api/v1/custom-fields`) — a single value assigned to a named
|
|
14
|
+
* field on one concrete target object (a list entity, a transaction, or a
|
|
15
|
+
* transaction line). Backed by QBXML `DataExtAdd/Mod/Del`.
|
|
16
|
+
*
|
|
17
|
+
* Both families use POST for create AND update (update lives on a `/update`
|
|
18
|
+
* sub-path) and DELETE with a JSON body. Listing definitions is a plain `GET`
|
|
19
|
+
* on the base route (`list()`), like every other list endpoint in the API.
|
|
20
|
+
* Because none of that maps onto the generic `Resource<T>` (which keys
|
|
21
|
+
* everything off an id path segment), these are hand-written.
|
|
22
|
+
*/
|
|
23
|
+
import { NxusApiError } from '../helpers/errors';
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
// DataExtTargetKind — the OpenAPI spec types this as a bare `integer`, so the
|
|
26
|
+
// generated TS is just `number`. These are the QBXML target families a custom
|
|
27
|
+
// field value can attach to. Exposed here as a named const so callers don't
|
|
28
|
+
// have to hard-code magic numbers.
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
/**
|
|
31
|
+
* Which family of QuickBooks object a custom field value attaches to.
|
|
32
|
+
* Mirrors the backend `DataExtTargetKind` enum (a C# enum serialized as its
|
|
33
|
+
* integer value): a list entity, a transaction (optionally one line), or the
|
|
34
|
+
* company file itself.
|
|
35
|
+
*/
|
|
36
|
+
export const DataExtTargetKind = {
|
|
37
|
+
/** A list entity (Customer, Vendor, Employee, Item, Account, OtherName). */
|
|
38
|
+
List: 0,
|
|
39
|
+
/** A transaction (optionally a single transaction line). */
|
|
40
|
+
Transaction: 1,
|
|
41
|
+
/** The company file itself. */
|
|
42
|
+
Company: 2,
|
|
43
|
+
};
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Shared option extraction (mirrors resources/base.ts extractOptions, but the
|
|
46
|
+
// custom-field requests never carry a path id, so the whole typed body is the
|
|
47
|
+
// payload and we only peel RequestOptions off the top).
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
function splitOptions(params) {
|
|
50
|
+
const { connectionId, headers, timeout, serverTimeoutSeconds, maxRetries, verbose, fetchOptions, ...body } = params;
|
|
51
|
+
const options = {};
|
|
52
|
+
if (connectionId !== undefined)
|
|
53
|
+
options.connectionId = connectionId;
|
|
54
|
+
if (headers !== undefined)
|
|
55
|
+
options.headers = headers;
|
|
56
|
+
if (timeout !== undefined)
|
|
57
|
+
options.timeout = timeout;
|
|
58
|
+
if (serverTimeoutSeconds !== undefined)
|
|
59
|
+
options.serverTimeoutSeconds = serverTimeoutSeconds;
|
|
60
|
+
if (maxRetries !== undefined)
|
|
61
|
+
options.maxRetries = maxRetries;
|
|
62
|
+
if (verbose !== undefined)
|
|
63
|
+
options.verbose = verbose;
|
|
64
|
+
if (fetchOptions !== undefined)
|
|
65
|
+
options.fetchOptions = fetchOptions;
|
|
66
|
+
return { body, options };
|
|
67
|
+
}
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// Custom Field Definitions — /api/v1/custom-field-definitions
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
/**
|
|
72
|
+
* Manage custom field *definitions* (the schema). DataExtDef in QBXML.
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* // Define a string field on Customers and Invoices
|
|
76
|
+
* const def = await client.customFieldDefinitions.create({
|
|
77
|
+
* ownerId: "0",
|
|
78
|
+
* name: "SdkTestField",
|
|
79
|
+
* type: DataExtensionType.STR255TYPE,
|
|
80
|
+
* assignToObjects: ["Customer", "Invoice"],
|
|
81
|
+
* listRequired: false,
|
|
82
|
+
* transactionRequired: false,
|
|
83
|
+
* connectionId: "conn_...",
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export class CustomFieldDefinitionsResource {
|
|
88
|
+
transport;
|
|
89
|
+
constructor(transport) {
|
|
90
|
+
this.transport = transport;
|
|
91
|
+
}
|
|
92
|
+
static BASE = '/api/v1/custom-field-definitions';
|
|
93
|
+
/** Create a new custom field definition. Returns the created `DataExtDef`. */
|
|
94
|
+
async create(params) {
|
|
95
|
+
const { body, options } = splitOptions(params);
|
|
96
|
+
return this.transport.post(CustomFieldDefinitionsResource.BASE, body, options);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Update an existing definition (rename, change type, add/remove target
|
|
100
|
+
* objects, toggle required). POSTs to the `/update` sub-path.
|
|
101
|
+
*/
|
|
102
|
+
async update(params) {
|
|
103
|
+
const { body, options } = splitOptions(params);
|
|
104
|
+
return this.transport.post(`${CustomFieldDefinitionsResource.BASE}/update`, body, options);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* List definitions. All filters are optional — omit them to fetch every
|
|
108
|
+
* definition visible to the connection. This is a plain `GET` on the base
|
|
109
|
+
* route (matching every other list endpoint in the API); the filters are
|
|
110
|
+
* repeated query-string params, not a request body. Returns a flat array
|
|
111
|
+
* (not paginated).
|
|
112
|
+
*
|
|
113
|
+
* @param params.ownerIds Restrict to the given owner ids
|
|
114
|
+
* (`"0"` selects public / UI-defined fields).
|
|
115
|
+
* @param params.assignToObjects Restrict to definitions assignable to any of
|
|
116
|
+
* the given object types (`Customer`, `Vendor`, `Invoice`, …).
|
|
117
|
+
*/
|
|
118
|
+
async list(params = {}) {
|
|
119
|
+
const { ownerIds, assignToObjects, ...rest } = params;
|
|
120
|
+
const { options } = splitOptions(rest);
|
|
121
|
+
const query = {};
|
|
122
|
+
if (ownerIds !== undefined)
|
|
123
|
+
query.OwnerIds = ownerIds;
|
|
124
|
+
if (assignToObjects !== undefined)
|
|
125
|
+
query.AssignToObjects = assignToObjects;
|
|
126
|
+
return this.transport.get(CustomFieldDefinitionsResource.BASE, query, options);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Delete a definition by owner + name (DELETE with a JSON body — there is no
|
|
130
|
+
* id path segment). Returns the standard `DeleteResponse`.
|
|
131
|
+
*/
|
|
132
|
+
async delete(params) {
|
|
133
|
+
const { body, options } = splitOptions(params);
|
|
134
|
+
return deleteWithBody(this.transport, CustomFieldDefinitionsResource.BASE, body, options);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
// Custom Field Values — /api/v1/custom-fields
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
/**
|
|
141
|
+
* Assign / change / clear custom field *values* on a concrete QBD target.
|
|
142
|
+
* DataExt in QBXML. The `target` selects the object the value attaches to:
|
|
143
|
+
*
|
|
144
|
+
* ```ts
|
|
145
|
+
* await client.customFields.create({
|
|
146
|
+
* ownerId: "0",
|
|
147
|
+
* name: "SdkTestField",
|
|
148
|
+
* value: "hello-from-sdk",
|
|
149
|
+
* target: { kind: DataExtTargetKind.List, listType: ListType.CUSTOMER, fullName: "Acme" },
|
|
150
|
+
* connectionId: "conn_...",
|
|
151
|
+
* });
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export class CustomFieldsResource {
|
|
155
|
+
transport;
|
|
156
|
+
constructor(transport) {
|
|
157
|
+
this.transport = transport;
|
|
158
|
+
}
|
|
159
|
+
static BASE = '/api/v1/custom-fields';
|
|
160
|
+
/** Assign a value to a named custom field on a target. Returns `DataExtDataExt`. */
|
|
161
|
+
async create(params) {
|
|
162
|
+
const { body, options } = splitOptions(params);
|
|
163
|
+
return this.transport.post(CustomFieldsResource.BASE, body, options);
|
|
164
|
+
}
|
|
165
|
+
/** Change an existing value. POSTs to the `/update` sub-path. */
|
|
166
|
+
async update(params) {
|
|
167
|
+
const { body, options } = splitOptions(params);
|
|
168
|
+
return this.transport.post(`${CustomFieldsResource.BASE}/update`, body, options);
|
|
169
|
+
}
|
|
170
|
+
/** Clear a value (DELETE with a JSON body). Returns `DeleteResponse`. */
|
|
171
|
+
async delete(params) {
|
|
172
|
+
const { body, options } = splitOptions(params);
|
|
173
|
+
return deleteWithBody(this.transport, CustomFieldsResource.BASE, body, options);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
// DELETE-with-body helper.
|
|
178
|
+
//
|
|
179
|
+
// These two routes are the only ones in the API that take a JSON body on a
|
|
180
|
+
// DELETE (the target is identified by owner+name in the body, not a path id).
|
|
181
|
+
// The shared transport's `delete()` sends no body, so rather than widen that
|
|
182
|
+
// hot path we go through `transport.raw()` — which already applies auth, the
|
|
183
|
+
// default headers, the timeout, and retries — and parse the JSON ourselves.
|
|
184
|
+
// `raw()` returns non-2xx responses instead of throwing, so we map those onto
|
|
185
|
+
// the same `NxusApiError` shape the rest of the SDK surfaces.
|
|
186
|
+
// ---------------------------------------------------------------------------
|
|
187
|
+
async function deleteWithBody(transport, path, body, options) {
|
|
188
|
+
const response = await transport.raw(path, { method: 'DELETE', body: JSON.stringify(body) }, options);
|
|
189
|
+
if (!response.ok) {
|
|
190
|
+
let errorBody;
|
|
191
|
+
try {
|
|
192
|
+
errorBody = await response.json();
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
errorBody = await response.text().catch(() => null);
|
|
196
|
+
}
|
|
197
|
+
throw NxusApiError.from(errorBody ?? { status: response.status, message: response.statusText });
|
|
198
|
+
}
|
|
199
|
+
if (response.status === 204)
|
|
200
|
+
return undefined;
|
|
201
|
+
const text = await response.text();
|
|
202
|
+
return (text ? JSON.parse(text) : undefined);
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=custom-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-fields.js","sourceRoot":"","sources":["../../src/resources/custom-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA0BjD,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,mCAAmC;AACnC,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,4EAA4E;IAC5E,IAAI,EAAE,CAAC;IACP,4DAA4D;IAC5D,WAAW,EAAE,CAAC;IACd,+BAA+B;IAC/B,OAAO,EAAE,CAAC;CACF,CAAC;AAKX,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,wDAAwD;AACxD,8EAA8E;AAE9E,SAAS,YAAY,CACnB,MAA0B;IAE1B,MAAM,EACJ,YAAY,EACZ,OAAO,EACP,OAAO,EACP,oBAAoB,EACpB,UAAU,EACV,OAAO,EACP,YAAY,EACZ,GAAG,IAAI,EACR,GAAG,MAAkD,CAAC;IACvD,MAAM,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I,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACtD,CAAC;QACD,MAAM,YAAY,CAAC,IAAI,CACrB,SAAS,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,CACvE,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,SAAc,CAAC;IACnD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAM,CAAC;AACpD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nxus-qbd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Official TypeScript SDK for the Nxus QuickBooks Desktop API. Runs on Node.js 18+ and Bun 1.0+.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
],
|
|
54
54
|
"repository": {
|
|
55
55
|
"type": "git",
|
|
56
|
-
"url": "https://github.com/nxus-
|
|
56
|
+
"url": "https://github.com/nxus-net/nxus-qbd.git"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=18",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"scripts": {
|
|
63
63
|
"generate": "openapi-ts && pnpm run generate:models",
|
|
64
64
|
"generate:live": "cross-env OPENAPI_SPEC_URL=https://api.nx-us.net/openapi/v1.json openapi-ts && pnpm run generate:models",
|
|
65
|
-
"generate:local": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 OPENAPI_SPEC_URL=https://localhost:7242/openapi/v1.json openapi-ts && pnpm run generate:models",
|
|
65
|
+
"generate:local": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 OPENAPI_SPEC_URL=https://localhost:7242/openapi/v1.json openapi-ts && cross-env OPENAPI_PUBLIC_BASE_URL=https://api.nx-us.net/ pnpm run generate:models",
|
|
66
66
|
"generate:models": "node ./scripts/generate-model-exports.mjs",
|
|
67
67
|
"build": "tsc",
|
|
68
68
|
"clean": "rm -rf dist",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bill_to_pay.d.ts","sourceRoot":"","sources":["../../../src/models/qbd/bill_to_pay.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bill_to_pay.js","sourceRoot":"","sources":["../../../src/models/qbd/bill_to_pay.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"check_bill.d.ts","sourceRoot":"","sources":["../../../src/models/qbd/check_bill.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,yBAAyB,EAAE,SAAS,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"check_bill.js","sourceRoot":"","sources":["../../../src/models/qbd/check_bill.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credit_card_bill.d.ts","sourceRoot":"","sources":["../../../src/models/qbd/credit_card_bill.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,2BAA2B,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credit_card_bill.js","sourceRoot":"","sources":["../../../src/models/qbd/credit_card_bill.ts"],"names":[],"mappings":""}
|