@sixtyninecommerce/admin 0.6.0 → 0.8.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/README.md +359 -2
- package/dist/apps/assertion.d.ts +30 -3
- package/dist/apps/assertion.js +40 -3
- package/dist/apps/config.d.ts +39 -0
- package/dist/apps/config.js +22 -0
- package/dist/apps/credential.d.ts +5 -0
- package/dist/apps/credential.js +55 -4
- package/dist/apps/index.d.ts +11 -0
- package/dist/client.d.ts +54 -1
- package/dist/client.js +34 -1
- package/dist/custom-objects/index.d.ts +66 -0
- package/dist/custom-objects/index.js +48 -0
- package/dist/customers/index.d.ts +225 -0
- package/dist/customers/index.js +279 -0
- package/dist/documents/index.d.ts +432 -0
- package/dist/documents/index.js +289 -0
- package/dist/index.d.ts +34 -2
- package/dist/index.js +16 -1
- package/dist/jobs/index.d.ts +143 -0
- package/dist/jobs/index.js +132 -0
- package/dist/metafields/index.d.ts +291 -0
- package/dist/metafields/index.js +141 -0
- package/dist/orders/index.d.ts +106 -0
- package/dist/orders/index.js +115 -0
- package/dist/orders/surcharges.d.ts +121 -0
- package/dist/orders/surcharges.js +110 -0
- package/dist/payments/index.d.ts +244 -0
- package/dist/payments/index.js +103 -0
- package/dist/payments/providers.d.ts +281 -0
- package/dist/payments/providers.js +205 -0
- package/dist/platform/provision-store.d.ts +9 -26
- package/dist/platform/provision-store.js +8 -66
- package/dist/tax/index.d.ts +128 -0
- package/dist/tax/index.js +101 -0
- package/dist/tenant/capabilities.d.ts +15 -0
- package/dist/types.d.ts +20 -3
- package/dist/uploads/index.d.ts +146 -0
- package/dist/uploads/index.js +72 -0
- package/package.json +3 -3
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { type Page, type Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Which document a call is about. The platform issues three, and every method
|
|
5
|
+
* here that takes a type takes one of these.
|
|
6
|
+
*/
|
|
7
|
+
export type DocumentType = 'invoice' | 'credit-note' | 'packing-slip';
|
|
8
|
+
/** An issued invoice. Money is in MINOR UNITS, as everywhere in this SDK. */
|
|
9
|
+
export interface Invoice {
|
|
10
|
+
id: string;
|
|
11
|
+
invoiceNumber: string;
|
|
12
|
+
/** Issue date, `YYYY-MM-DD`. */
|
|
13
|
+
invoicedOn: string;
|
|
14
|
+
orderId: string;
|
|
15
|
+
languageCode: string;
|
|
16
|
+
storageKey: string;
|
|
17
|
+
totalWithTax: number;
|
|
18
|
+
currencyCode: string;
|
|
19
|
+
note: string | null;
|
|
20
|
+
/** Set once a void & reissue reversed it; null while the invoice is live. */
|
|
21
|
+
voidedOn: string | null;
|
|
22
|
+
/** `standard` for the order's invoice, `supplementary` for an under-charge billed on top. */
|
|
23
|
+
kind: string;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
}
|
|
26
|
+
/** An issued credit note. `totalWithTax` is the POSITIVE value of the credit. */
|
|
27
|
+
export interface CreditNote {
|
|
28
|
+
id: string;
|
|
29
|
+
creditNoteNumber: string;
|
|
30
|
+
issuedOn: string;
|
|
31
|
+
totalWithTax: number;
|
|
32
|
+
currencyCode: string;
|
|
33
|
+
reason: string;
|
|
34
|
+
invoiceId: string;
|
|
35
|
+
/** `correction` | `cancellation` | `return` | `adjustment`. */
|
|
36
|
+
kind: string;
|
|
37
|
+
/** Null until the PDF has been rendered and stored. */
|
|
38
|
+
storageKey: string | null;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
}
|
|
41
|
+
export interface PackingSlip {
|
|
42
|
+
id: string;
|
|
43
|
+
packingSlipNumber: string;
|
|
44
|
+
fulfillmentId: string;
|
|
45
|
+
languageCode: string;
|
|
46
|
+
storageKey: string;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* One block as supplied at generation time.
|
|
51
|
+
*
|
|
52
|
+
* Validated against the registered schema AT THAT VERSION. An unknown key, a
|
|
53
|
+
* stale `schemaVersion` or data the schema refuses rejects the WHOLE document:
|
|
54
|
+
* the platform never issues a numbered document that silently lacks a block
|
|
55
|
+
* the caller asked for.
|
|
56
|
+
*/
|
|
57
|
+
export interface DocumentExtensionInput {
|
|
58
|
+
key: string;
|
|
59
|
+
/** The version the data was written against. A stale one is refused, never coerced. */
|
|
60
|
+
schemaVersion: number;
|
|
61
|
+
data: unknown;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Most blocks one document may carry. A longer list refuses the whole document
|
|
65
|
+
* (`DOCUMENT_EXTENSION_INVALID`) rather than issuing a numbered one that
|
|
66
|
+
* dropped the overflow — a document is a page, not a feed.
|
|
67
|
+
*/
|
|
68
|
+
export declare const MAX_DOCUMENT_EXTENSIONS = 10;
|
|
69
|
+
/**
|
|
70
|
+
* A registered extension block.
|
|
71
|
+
*
|
|
72
|
+
* ## The schema grammar is BOUNDED, on purpose
|
|
73
|
+
*
|
|
74
|
+
* This platform accepts exactly fifteen JSON Schema keywords and refuses any
|
|
75
|
+
* other one BY NAME at registration — `DOCUMENT_EXTENSION_SCHEMA_KEYWORD_UNSUPPORTED`,
|
|
76
|
+
* with the keyword and the JSON Pointer in `details[]`. Thirteen of them
|
|
77
|
+
* constrain the data; `title` and `description` are annotations with nothing to
|
|
78
|
+
* check. The fifteen:
|
|
79
|
+
*
|
|
80
|
+
* **And a keyword must sit on a type it can constrain**, or it is refused the
|
|
81
|
+
* same way, naming the keyword AND the type: `minLength` on an `integer`
|
|
82
|
+
* constrains nothing, and an `enum` on an `object` matches nothing so it
|
|
83
|
+
* refuses every value. `minLength`/`maxLength`/`pattern` belong to a `string`,
|
|
84
|
+
* `minimum`/`maximum` to a `number` or `integer`, `minItems`/`maxItems`/`items`
|
|
85
|
+
* to an `array`, `properties`/`required`/`additionalProperties` to an `object`,
|
|
86
|
+
* `enum` to the four scalar types; `type`, `title` and `description` go
|
|
87
|
+
* anywhere. A PIN is a `string` with `minLength`, not an `integer` with one.
|
|
88
|
+
*
|
|
89
|
+
* `type`, `title`, `description`, `properties`, `required`,
|
|
90
|
+
* `additionalProperties`, `items`, `enum`, `minLength`, `maxLength`,
|
|
91
|
+
* `minimum`, `maximum`, `minItems`, `maxItems`, `pattern`.
|
|
92
|
+
*
|
|
93
|
+
* Six types are accepted: `object`, `array`, `string`, `number`, `integer`,
|
|
94
|
+
* `boolean`. One deliberate difference from JSON Schema: `additionalProperties`
|
|
95
|
+
* defaults to **false**, so a block cannot carry unvalidated fields onto a
|
|
96
|
+
* document.
|
|
97
|
+
*
|
|
98
|
+
* A keyword this list does not name is refused rather than ignored — a schema
|
|
99
|
+
* that appears to constrain something it does not is worse than one that is
|
|
100
|
+
* rejected while the merchant is still editing it.
|
|
101
|
+
*
|
|
102
|
+
* ## The template fragment is allow-listed
|
|
103
|
+
*
|
|
104
|
+
* Each node names its kind in `node` — `{ node: 'text', text: 'HS {{ /hsCode }}' }`
|
|
105
|
+
* — and the five kinds are `text`, `stack`, `columns`, `table` and `repeat`.
|
|
106
|
+
* `{{ /json/pointer }}` placeholders are filled from the block's data, and text
|
|
107
|
+
* is never interpreted as document markup. Margins are bounded and cannot be
|
|
108
|
+
* negative (a negative one would draw the block over the document's own
|
|
109
|
+
* totals), a `table`'s rows must all be the same width, and a `repeat` belongs
|
|
110
|
+
* inside a `stack` rather than being a table cell — each would otherwise throw
|
|
111
|
+
* inside the PDF engine after the document had been numbered.
|
|
112
|
+
*
|
|
113
|
+
* A placeholder that resolves to nothing,
|
|
114
|
+
* or to an object or array, is refused AT GENERATION
|
|
115
|
+
* (`DOCUMENT_EXTENSION_PLACEHOLDER_UNRESOLVED`) rather than printed as an empty
|
|
116
|
+
* string or `[object Object]`.
|
|
117
|
+
*/
|
|
118
|
+
export interface DocumentExtensionSchema {
|
|
119
|
+
key: string;
|
|
120
|
+
/**
|
|
121
|
+
* `string[]`, not `DocumentType[]`, on purpose: the platform may additively
|
|
122
|
+
* grow a fourth kind, and an SDK a version behind would then be handing back
|
|
123
|
+
* a value typed as one of the three it knows. Compare against
|
|
124
|
+
* {@link DocumentType} members rather than assuming exhaustiveness.
|
|
125
|
+
*/
|
|
126
|
+
documentTypes: string[];
|
|
127
|
+
/** Bumped by every re-registration. A generation must name the version it wrote against. */
|
|
128
|
+
schemaVersion: number;
|
|
129
|
+
jsonSchema: unknown;
|
|
130
|
+
templateFragment: unknown;
|
|
131
|
+
createdAt: string;
|
|
132
|
+
updatedAt: string;
|
|
133
|
+
}
|
|
134
|
+
export interface RegisterDocumentExtensionInput {
|
|
135
|
+
/** Lower-case kebab handle, at most 64 characters. */
|
|
136
|
+
key: string;
|
|
137
|
+
documentTypes: DocumentType[];
|
|
138
|
+
/** See {@link DocumentExtensionSchema} for the fifteen keywords this platform accepts. */
|
|
139
|
+
jsonSchema: unknown;
|
|
140
|
+
/** See {@link DocumentExtensionSchema} for the allow-listed fragment nodes. */
|
|
141
|
+
templateFragment: unknown;
|
|
142
|
+
}
|
|
143
|
+
/** One line of a document, in minor units. Every money field is null on a packing slip. */
|
|
144
|
+
export interface DocumentDataLine {
|
|
145
|
+
description: string;
|
|
146
|
+
sku: string;
|
|
147
|
+
quantity: number;
|
|
148
|
+
unitPriceNet: number | null;
|
|
149
|
+
unitPriceWithTax: number | null;
|
|
150
|
+
taxRate: number | null;
|
|
151
|
+
lineTotalNet: number | null;
|
|
152
|
+
lineTotalWithTax: number | null;
|
|
153
|
+
}
|
|
154
|
+
export interface DocumentDataTaxRow {
|
|
155
|
+
taxRate: number;
|
|
156
|
+
taxBase: number;
|
|
157
|
+
taxTotal: number;
|
|
158
|
+
}
|
|
159
|
+
export interface DocumentDataTotals {
|
|
160
|
+
/** Net subtotal (lines and surcharges, excluding shipping). */
|
|
161
|
+
subTotal: number;
|
|
162
|
+
shippingTotal: number;
|
|
163
|
+
taxTotal: number;
|
|
164
|
+
totalWithTax: number;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Where a document's number came from.
|
|
168
|
+
*
|
|
169
|
+
* `scope` is modelled rather than assumed. Today every series is per channel;
|
|
170
|
+
* multi-region will issue per legal entity (spec §12.2), and a consumer that
|
|
171
|
+
* reads `scope`/`scopeId` keeps working when that lands — which is why the
|
|
172
|
+
* field exists before there is a second value for it. Numbering itself stays
|
|
173
|
+
* platform-owned: there is no SDK method that allocates or reserves a number.
|
|
174
|
+
*/
|
|
175
|
+
export interface DocumentDataNumbering {
|
|
176
|
+
scope: 'channel';
|
|
177
|
+
scopeId: string;
|
|
178
|
+
/** The configured prefix of the series, when the store set one. */
|
|
179
|
+
series: string | null;
|
|
180
|
+
number: string;
|
|
181
|
+
}
|
|
182
|
+
export interface DocumentDataParty {
|
|
183
|
+
companyName?: string;
|
|
184
|
+
fullName: string;
|
|
185
|
+
addressLine1: string;
|
|
186
|
+
addressLine2?: string;
|
|
187
|
+
postalCode: string;
|
|
188
|
+
city: string;
|
|
189
|
+
province?: string;
|
|
190
|
+
country?: string;
|
|
191
|
+
}
|
|
192
|
+
/** WHO issued the document — the legal entity whose identity is printed on it. */
|
|
193
|
+
export interface DocumentDataIssuer {
|
|
194
|
+
name: string;
|
|
195
|
+
address: {
|
|
196
|
+
line1: string;
|
|
197
|
+
line2?: string;
|
|
198
|
+
postalCode: string;
|
|
199
|
+
city: string;
|
|
200
|
+
province?: string;
|
|
201
|
+
country?: string;
|
|
202
|
+
};
|
|
203
|
+
vatNumber?: string;
|
|
204
|
+
registrationNumber?: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The numbered facts a document was built from — enough to render your own
|
|
208
|
+
* document from the same figures the platform printed.
|
|
209
|
+
*/
|
|
210
|
+
export interface DocumentData {
|
|
211
|
+
type: DocumentType;
|
|
212
|
+
id: string;
|
|
213
|
+
numbering: DocumentDataNumbering;
|
|
214
|
+
/** `YYYY-MM-DD`, as the document stored it. */
|
|
215
|
+
issuedOn: string;
|
|
216
|
+
languageCode: string;
|
|
217
|
+
/** Null on a packing slip, which carries no money. */
|
|
218
|
+
currencyCode: string | null;
|
|
219
|
+
issuer: DocumentDataIssuer;
|
|
220
|
+
recipient: DocumentDataParty | null;
|
|
221
|
+
order: {
|
|
222
|
+
id: string;
|
|
223
|
+
code: string;
|
|
224
|
+
} | null;
|
|
225
|
+
lines: DocumentDataLine[];
|
|
226
|
+
/**
|
|
227
|
+
* Null — never an empty array — when the document never stated a per-rate
|
|
228
|
+
* split. A lump-sum credit note on a mixed-rate order is the case: "it never
|
|
229
|
+
* said" must not read as "it said nothing is taxed".
|
|
230
|
+
*/
|
|
231
|
+
taxSummary: DocumentDataTaxRow[] | null;
|
|
232
|
+
totals: DocumentDataTotals | null;
|
|
233
|
+
/**
|
|
234
|
+
* The gross the document was NUMBERED with, straight off its own row — the
|
|
235
|
+
* figure every downstream operation (credit ceiling, reversal, refund) acts
|
|
236
|
+
* on. Null on a packing slip.
|
|
237
|
+
*/
|
|
238
|
+
issuedTotalWithTax: number | null;
|
|
239
|
+
/**
|
|
240
|
+
* Whether {@link totals} still reconciles with {@link issuedTotalWithTax}.
|
|
241
|
+
*
|
|
242
|
+
* The question only really arises on a STANDARD invoice: it is the one
|
|
243
|
+
* document that derives its lines from the ORDER, and an order can be
|
|
244
|
+
* modified after the invoice was numbered. The document is immutable, the
|
|
245
|
+
* order is not — so the two CAN disagree, and you are told rather than handed
|
|
246
|
+
* a silently re-derived total under the issued number. A credit note states
|
|
247
|
+
* its own lines and always reports `true`; a packing slip carries no money
|
|
248
|
+
* and reports null.
|
|
249
|
+
*/
|
|
250
|
+
reconciled: boolean | null;
|
|
251
|
+
/** Exactly what the document froze — never the store's current registration. */
|
|
252
|
+
extensions: Array<{
|
|
253
|
+
key: string;
|
|
254
|
+
schemaVersion: number;
|
|
255
|
+
data: unknown;
|
|
256
|
+
templateFragment: unknown;
|
|
257
|
+
}>;
|
|
258
|
+
invoice?: {
|
|
259
|
+
kind: string;
|
|
260
|
+
dueOn: string | null;
|
|
261
|
+
voidedOn: string | null;
|
|
262
|
+
note: string | null;
|
|
263
|
+
};
|
|
264
|
+
creditNote?: {
|
|
265
|
+
kind: string;
|
|
266
|
+
reason: string;
|
|
267
|
+
invoiceId: string;
|
|
268
|
+
};
|
|
269
|
+
packingSlip?: {
|
|
270
|
+
fulfillmentId: string;
|
|
271
|
+
orderCodes: string[];
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/** What `generate` needs, per document type. */
|
|
275
|
+
export interface GenerateDocumentOptions extends Call {
|
|
276
|
+
/**
|
|
277
|
+
* Invoice date, `YYYY-MM-DD`. REQUIRED for an invoice and rejected for a
|
|
278
|
+
* packing slip. Deliberately not defaulted: a document date decides which
|
|
279
|
+
* period the money books into, and the caller's clock is not the store's.
|
|
280
|
+
*/
|
|
281
|
+
invoicedOn?: string;
|
|
282
|
+
languageCode?: string;
|
|
283
|
+
/** Rendered on the invoice and in the invoice email. Invoices only. */
|
|
284
|
+
note?: string;
|
|
285
|
+
/**
|
|
286
|
+
* Tenant-registered blocks, at most {@link MAX_DOCUMENT_EXTENSIONS}. An
|
|
287
|
+
* invalid, duplicate or over-long list refuses the whole generation; nothing
|
|
288
|
+
* is dropped.
|
|
289
|
+
*/
|
|
290
|
+
extensions?: DocumentExtensionInput[];
|
|
291
|
+
}
|
|
292
|
+
export interface IssuePartialCreditNoteInput {
|
|
293
|
+
orderId: string;
|
|
294
|
+
/** Why the credit was issued — required, printed on the note. */
|
|
295
|
+
reason: string;
|
|
296
|
+
/** What is being credited. The credited total is their sum; it is never stated separately. */
|
|
297
|
+
lines: DocumentLineInput[];
|
|
298
|
+
/** The invoice to credit; defaults to the order's newest live one. */
|
|
299
|
+
invoiceId?: string;
|
|
300
|
+
/** Also refund the credited amount against this payment. Omit for a document-only credit. */
|
|
301
|
+
refundPaymentId?: string;
|
|
302
|
+
/** Blocks for the credit note. An invalid one refuses the issue BEFORE the refund moves. */
|
|
303
|
+
extensions?: DocumentExtensionInput[];
|
|
304
|
+
}
|
|
305
|
+
export interface IssueSupplementaryInvoiceInput {
|
|
306
|
+
orderId: string;
|
|
307
|
+
/** The live invoice this one adds to; both stay owed. */
|
|
308
|
+
supplementsInvoiceId: string;
|
|
309
|
+
lines: DocumentLineInput[];
|
|
310
|
+
invoicedOn?: string;
|
|
311
|
+
languageCode?: string;
|
|
312
|
+
note?: string;
|
|
313
|
+
extensions?: DocumentExtensionInput[];
|
|
314
|
+
}
|
|
315
|
+
/** One line a document states itself, rather than deriving from the order. */
|
|
316
|
+
export interface DocumentLineInput {
|
|
317
|
+
description: string;
|
|
318
|
+
sku?: string;
|
|
319
|
+
/** The order line this row was prefilled from; omit for a free-form row. */
|
|
320
|
+
orderLineId?: string;
|
|
321
|
+
quantity: number;
|
|
322
|
+
/** Minor units, in the basis named by `unitPriceBasis`. May be negative for a discount row. */
|
|
323
|
+
unitPrice: number;
|
|
324
|
+
unitPriceBasis: 'net' | 'gross';
|
|
325
|
+
/** Percentage; may be fractional. 0 means an untaxed line. */
|
|
326
|
+
taxRate: number;
|
|
327
|
+
}
|
|
328
|
+
export interface SendInvoiceEmailInput {
|
|
329
|
+
orderId: string;
|
|
330
|
+
recipientsTo: string[];
|
|
331
|
+
recipientsCc?: string[];
|
|
332
|
+
}
|
|
333
|
+
/** The store's extension-block registry. Reading needs `ReadSettings`, writing `UpdateSettings`. */
|
|
334
|
+
export interface DocumentExtensionsModule {
|
|
335
|
+
/**
|
|
336
|
+
* The USABLE set: the newest version of each key.
|
|
337
|
+
*
|
|
338
|
+
* A superseded version is deliberately absent. It still exists — every
|
|
339
|
+
* document issued against it froze its own copy and still redraws — but
|
|
340
|
+
* nothing new can be written against it, so offering it as a choice would
|
|
341
|
+
* only invite a `DOCUMENT_EXTENSION_VERSION_MISMATCH`.
|
|
342
|
+
*/
|
|
343
|
+
list(options?: Call): Promise<Page<DocumentExtensionSchema>>;
|
|
344
|
+
/**
|
|
345
|
+
* Register a block, or a NEW VERSION of one. A key is never edited in place,
|
|
346
|
+
* so documents already issued keep the schema and fragment they carry.
|
|
347
|
+
*/
|
|
348
|
+
register(input: RegisterDocumentExtensionInput, options?: Call): Promise<DocumentExtensionSchema>;
|
|
349
|
+
/**
|
|
350
|
+
* Stop a key being usable on new documents. True when something was removed,
|
|
351
|
+
* false when there was nothing — so a repeated delete is not an error.
|
|
352
|
+
* Documents already issued with it are untouched.
|
|
353
|
+
*/
|
|
354
|
+
delete(key: string, options?: Call): Promise<boolean>;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* The store's documents: issuing them, reading the facts they were built from,
|
|
358
|
+
* and the tenant-registered blocks that extend them (headless spec §8.5).
|
|
359
|
+
*
|
|
360
|
+
* **Coded refusals**, delivered as GraphQL errors with `extensions.code`:
|
|
361
|
+
* `DOCUMENT_EXTENSION_NOT_FOUND` (→ `NotFoundError`) for a key this store has
|
|
362
|
+
* not registered; `DOCUMENT_EXTENSION_VERSION_MISMATCH` (→ `ConflictError`)
|
|
363
|
+
* when the key exists but not at the version you wrote against;
|
|
364
|
+
* `DOCUMENT_EXTENSION_WRONG_DOCUMENT_TYPE`, `DOCUMENT_EXTENSION_INVALID`,
|
|
365
|
+
* `DOCUMENT_EXTENSION_PLACEHOLDER_UNRESOLVED`,
|
|
366
|
+
* `DOCUMENT_EXTENSION_SCHEMA_INVALID`,
|
|
367
|
+
* `DOCUMENT_EXTENSION_SCHEMA_KEYWORD_UNSUPPORTED`,
|
|
368
|
+
* `DOCUMENT_EXTENSION_TEMPLATE_INVALID` and `INVALID_DOCUMENT_EXTENSION_KEY`
|
|
369
|
+
* (→ `ValidationError`). A refusal about several fields at once carries
|
|
370
|
+
* `error.details`: one entry per JSON Pointer, its `field` the pointer and its
|
|
371
|
+
* `code` the schema keyword that refused — so a form marks each offending field
|
|
372
|
+
* rather than showing one joined sentence.
|
|
373
|
+
*
|
|
374
|
+
* `idempotencyKey` on these calls is recorded on the wire and acts on nothing:
|
|
375
|
+
* the Admin API is GraphQL and has no header for it (see {@link Call}). A
|
|
376
|
+
* repeated `generate` is a second attempt, which for an invoice the platform
|
|
377
|
+
* refuses on its own — an order carries at most one live standard invoice.
|
|
378
|
+
*/
|
|
379
|
+
export interface DocumentsModule {
|
|
380
|
+
/**
|
|
381
|
+
* Issue a document.
|
|
382
|
+
*
|
|
383
|
+
* `subjectId` is what the document is FOR, which differs by type: an order id
|
|
384
|
+
* for an invoice, a FULFILLMENT id for a packing slip. A credit note is not
|
|
385
|
+
* issued here — it credits an invoice and needs a reason and lines, so it has
|
|
386
|
+
* its own method ({@link issuePartialCreditNote}).
|
|
387
|
+
*
|
|
388
|
+
* An invoice REQUIRES `invoicedOn`: the document date decides which period
|
|
389
|
+
* the money books into, and the caller's clock is not the store's. The
|
|
390
|
+
* overloads put that in the type system, and refuse an invoice-only option on
|
|
391
|
+
* a packing slip the same way.
|
|
392
|
+
*/
|
|
393
|
+
generate(subjectId: string, type: 'invoice', options: GenerateDocumentOptions & {
|
|
394
|
+
invoicedOn: string;
|
|
395
|
+
}): Promise<Invoice>;
|
|
396
|
+
generate(subjectId: string, type: 'packing-slip', options?: Omit<GenerateDocumentOptions, 'invoicedOn' | 'note'>): Promise<PackingSlip>;
|
|
397
|
+
/** The numbered facts a document was built from. Needs `ReadOrder`. */
|
|
398
|
+
data(documentId: string, type: DocumentType, options?: Call): Promise<DocumentData>;
|
|
399
|
+
/** Every invoice of an order, including voided ones. */
|
|
400
|
+
invoices(orderId: string, options?: Call): Promise<Page<Invoice>>;
|
|
401
|
+
/** Every credit note of an order. */
|
|
402
|
+
creditNotes(orderId: string, options?: Call): Promise<Page<CreditNote>>;
|
|
403
|
+
/**
|
|
404
|
+
* Render what an invoice WOULD look like, without numbering or storing one.
|
|
405
|
+
* Returns the PDF bytes (the wire carries base64; this decodes it).
|
|
406
|
+
*/
|
|
407
|
+
previewInvoice(orderId: string, options: {
|
|
408
|
+
invoicedOn: string;
|
|
409
|
+
languageCode?: string;
|
|
410
|
+
note?: string;
|
|
411
|
+
} & Call): Promise<Uint8Array>;
|
|
412
|
+
/** Email an order's invoice. True when the dispatch was accepted. */
|
|
413
|
+
sendInvoiceEmail(input: SendInvoiceEmailInput, options?: Call): Promise<boolean>;
|
|
414
|
+
/** Credit PART of a still-valid invoice; the invoice keeps standing. */
|
|
415
|
+
issuePartialCreditNote(input: IssuePartialCreditNoteInput, options?: Call): Promise<CreditNote>;
|
|
416
|
+
/** Bill an under-charge as a supplementary invoice; both invoices stay owed. */
|
|
417
|
+
issueSupplementaryInvoice(input: IssueSupplementaryInvoiceInput, options?: Call): Promise<Invoice>;
|
|
418
|
+
extensions: DocumentExtensionsModule;
|
|
419
|
+
}
|
|
420
|
+
export declare const GENERATE_INVOICE_MUTATION = "\n mutation GenerateInvoice(\n $orderId: ID!\n $invoicedOn: String!\n $languageCode: String\n $note: String\n $extensions: [DocumentExtensionInput!]\n ) {\n generateInvoice(\n orderId: $orderId\n invoicedOn: $invoicedOn\n languageCode: $languageCode\n note: $note\n extensions: $extensions\n ) { \n id\n invoiceNumber\n invoicedOn\n orderId\n languageCode\n storageKey\n totalWithTax\n currencyCode\n note\n voidedOn\n kind\n createdAt\n }\n }\n";
|
|
421
|
+
export declare const GENERATE_PACKING_SLIP_MUTATION = "\n mutation GeneratePackingSlip(\n $fulfillmentId: ID!\n $languageCode: String\n $extensions: [DocumentExtensionInput!]\n ) {\n generatePackingSlip(\n fulfillmentId: $fulfillmentId\n languageCode: $languageCode\n extensions: $extensions\n ) { \n id\n packingSlipNumber\n fulfillmentId\n languageCode\n storageKey\n createdAt\n }\n }\n";
|
|
422
|
+
export declare const DOCUMENT_DATA_QUERY = "\n query DocumentData($documentId: ID!, $type: DocumentType!) {\n documentData(documentId: $documentId, type: $type)\n }\n";
|
|
423
|
+
export declare const ORDER_INVOICES_QUERY = "\n query OrderInvoices($orderId: ID!) {\n orderInvoices(orderId: $orderId) { \n id\n invoiceNumber\n invoicedOn\n orderId\n languageCode\n storageKey\n totalWithTax\n currencyCode\n note\n voidedOn\n kind\n createdAt\n }\n }\n";
|
|
424
|
+
export declare const ORDER_CREDIT_NOTES_QUERY = "\n query OrderCreditNotes($orderId: ID!) {\n orderCreditNotes(orderId: $orderId) { \n id\n creditNoteNumber\n issuedOn\n totalWithTax\n currencyCode\n reason\n invoiceId\n kind\n storageKey\n createdAt\n }\n }\n";
|
|
425
|
+
export declare const PREVIEW_INVOICE_MUTATION = "\n mutation PreviewInvoice($orderId: ID!, $invoicedOn: String!, $languageCode: String, $note: String) {\n previewInvoice(orderId: $orderId, invoicedOn: $invoicedOn, languageCode: $languageCode, note: $note)\n }\n";
|
|
426
|
+
export declare const SEND_INVOICE_EMAIL_MUTATION = "\n mutation SendInvoiceEmail($input: SendInvoiceEmailInput!) {\n sendInvoiceEmail(input: $input)\n }\n";
|
|
427
|
+
export declare const ISSUE_PARTIAL_CREDIT_NOTE_MUTATION = "\n mutation IssuePartialCreditNote($input: IssuePartialCreditNoteInput!) {\n issuePartialCreditNote(input: $input) { \n id\n creditNoteNumber\n issuedOn\n totalWithTax\n currencyCode\n reason\n invoiceId\n kind\n storageKey\n createdAt\n }\n }\n";
|
|
428
|
+
export declare const ISSUE_SUPPLEMENTARY_INVOICE_MUTATION = "\n mutation IssueSupplementaryInvoice($input: IssueSupplementaryInvoiceInput!) {\n issueSupplementaryInvoice(input: $input) { \n id\n invoiceNumber\n invoicedOn\n orderId\n languageCode\n storageKey\n totalWithTax\n currencyCode\n note\n voidedOn\n kind\n createdAt\n }\n }\n";
|
|
429
|
+
export declare const DOCUMENT_EXTENSIONS_QUERY = "\n query DocumentExtensions {\n documentExtensions { \n key\n documentTypes\n schemaVersion\n jsonSchema\n templateFragment\n createdAt\n updatedAt\n }\n }\n";
|
|
430
|
+
export declare const REGISTER_DOCUMENT_EXTENSION_MUTATION = "\n mutation RegisterDocumentExtension($input: RegisterDocumentExtensionInput!) {\n registerDocumentExtension(input: $input) { \n key\n documentTypes\n schemaVersion\n jsonSchema\n templateFragment\n createdAt\n updatedAt\n }\n }\n";
|
|
431
|
+
export declare const DELETE_DOCUMENT_EXTENSION_MUTATION = "\n mutation DeleteDocumentExtension($key: String!) {\n deleteDocumentExtension(key: $key)\n }\n";
|
|
432
|
+
export declare function createDocumentsModule(transport: Transport): DocumentsModule;
|