@sixtyninecommerce/admin 0.8.0 → 0.10.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.
Files changed (179) hide show
  1. package/README.md +2739 -17
  2. package/dist/api-tokens/index.d.ts +15 -5
  3. package/dist/api-tokens/index.js +1 -0
  4. package/dist/apps/event-subscription.d.ts +59 -0
  5. package/dist/apps/event-subscription.js +32 -0
  6. package/dist/apps/hook-secret.d.ts +22 -0
  7. package/dist/apps/hook-secret.js +36 -0
  8. package/dist/apps/index.d.ts +54 -3
  9. package/dist/apps/index.js +17 -0
  10. package/dist/audit/index.d.ts +7 -0
  11. package/dist/auth/queries.d.ts +5 -1
  12. package/dist/auth/queries.js +6 -0
  13. package/dist/bulk/index.d.ts +323 -0
  14. package/dist/bulk/index.js +162 -0
  15. package/dist/catalog/assets.d.ts +147 -0
  16. package/dist/catalog/assets.js +164 -0
  17. package/dist/catalog/collections.d.ts +109 -0
  18. package/dist/catalog/collections.js +91 -0
  19. package/dist/catalog/facets.d.ts +103 -0
  20. package/dist/catalog/facets.js +100 -0
  21. package/dist/catalog/index.d.ts +115 -0
  22. package/dist/catalog/index.js +21 -0
  23. package/dist/catalog/options.d.ts +89 -0
  24. package/dist/catalog/options.js +88 -0
  25. package/dist/catalog/products-bulk.d.ts +21 -0
  26. package/dist/catalog/products-bulk.js +58 -0
  27. package/dist/catalog/products.d.ts +650 -0
  28. package/dist/catalog/products.js +458 -0
  29. package/dist/catalog/properties.d.ts +234 -0
  30. package/dist/catalog/properties.js +158 -0
  31. package/dist/catalog/types.d.ts +174 -0
  32. package/dist/catalog/types.js +141 -0
  33. package/dist/catalog/variants.d.ts +324 -0
  34. package/dist/catalog/variants.js +288 -0
  35. package/dist/catalog/visibility.d.ts +57 -0
  36. package/dist/catalog/visibility.js +59 -0
  37. package/dist/client.d.ts +192 -3
  38. package/dist/client.js +87 -12
  39. package/dist/compliance/index.d.ts +88 -0
  40. package/dist/compliance/index.js +88 -0
  41. package/dist/customer-data-redaction.d.ts +14 -0
  42. package/dist/customer-data-redaction.js +22 -0
  43. package/dist/customers/index.d.ts +428 -17
  44. package/dist/customers/index.js +322 -15
  45. package/dist/documents/index.d.ts +513 -16
  46. package/dist/documents/index.js +229 -3
  47. package/dist/events/index.d.ts +259 -0
  48. package/dist/events/index.js +147 -0
  49. package/dist/feeds/ai.d.ts +46 -0
  50. package/dist/feeds/ai.js +43 -0
  51. package/dist/feeds/categories.d.ts +50 -0
  52. package/dist/feeds/categories.js +56 -0
  53. package/dist/feeds/configs.d.ts +54 -0
  54. package/dist/feeds/configs.js +85 -0
  55. package/dist/feeds/identifier-fields.d.ts +25 -0
  56. package/dist/feeds/identifier-fields.js +29 -0
  57. package/dist/feeds/index.d.ts +54 -0
  58. package/dist/feeds/index.js +46 -0
  59. package/dist/feeds/preserve.d.ts +38 -0
  60. package/dist/feeds/preserve.js +74 -0
  61. package/dist/feeds/rules.d.ts +42 -0
  62. package/dist/feeds/rules.js +56 -0
  63. package/dist/feeds/types.d.ts +654 -0
  64. package/dist/feeds/types.js +135 -0
  65. package/dist/fulfillments/index.d.ts +437 -0
  66. package/dist/fulfillments/index.js +534 -0
  67. package/dist/heads/index.d.ts +60 -0
  68. package/dist/heads/index.js +45 -0
  69. package/dist/hooks/assignments.d.ts +90 -0
  70. package/dist/hooks/assignments.js +53 -0
  71. package/dist/hooks/index.d.ts +97 -0
  72. package/dist/hooks/index.js +76 -0
  73. package/dist/index.d.ts +95 -9
  74. package/dist/index.js +21 -1
  75. package/dist/integrations/index.d.ts +14 -0
  76. package/dist/integrations/index.js +9 -0
  77. package/dist/integrations/pipelines.d.ts +113 -0
  78. package/dist/integrations/pipelines.js +62 -0
  79. package/dist/integrations/types.d.ts +176 -0
  80. package/dist/integrations/types.js +8 -0
  81. package/dist/jobs/bulk-action-run.d.ts +74 -0
  82. package/dist/jobs/bulk-action-run.js +69 -0
  83. package/dist/locations/index.d.ts +6 -2
  84. package/dist/meta/index.d.ts +32 -0
  85. package/dist/orders/bulk.d.ts +75 -0
  86. package/dist/orders/bulk.js +150 -0
  87. package/dist/orders/commit-edit.d.ts +123 -0
  88. package/dist/orders/commit-edit.js +142 -0
  89. package/dist/orders/deposit-policy.d.ts +103 -0
  90. package/dist/orders/deposit-policy.js +202 -0
  91. package/dist/orders/get.d.ts +722 -0
  92. package/dist/orders/get.js +530 -0
  93. package/dist/orders/index.d.ts +186 -21
  94. package/dist/orders/index.js +57 -0
  95. package/dist/orders/line-price-preview.d.ts +297 -0
  96. package/dist/orders/line-price-preview.js +50 -0
  97. package/dist/orders/manual-discounts.d.ts +141 -0
  98. package/dist/orders/manual-discounts.js +97 -0
  99. package/dist/orders/manual-pricing.d.ts +192 -0
  100. package/dist/orders/manual-pricing.js +72 -0
  101. package/dist/orders/order-entry.d.ts +566 -0
  102. package/dist/orders/order-entry.js +129 -0
  103. package/dist/orders/parcel-charge.d.ts +45 -0
  104. package/dist/orders/parcel-charge.js +55 -0
  105. package/dist/orders/plan-edit.d.ts +489 -0
  106. package/dist/orders/plan-edit.js +93 -0
  107. package/dist/orders/status.d.ts +235 -0
  108. package/dist/orders/status.js +96 -0
  109. package/dist/orders/surcharges.d.ts +75 -2
  110. package/dist/orders/surcharges.js +110 -4
  111. package/dist/payments/account-credit.d.ts +171 -0
  112. package/dist/payments/account-credit.js +107 -0
  113. package/dist/payments/index.d.ts +241 -9
  114. package/dist/payments/index.js +92 -0
  115. package/dist/payments/methods.d.ts +37 -0
  116. package/dist/payments/methods.js +33 -0
  117. package/dist/platform/catalog.d.ts +148 -0
  118. package/dist/platform/catalog.js +74 -0
  119. package/dist/platform/entitlements.d.ts +111 -0
  120. package/dist/platform/entitlements.js +86 -0
  121. package/dist/platform/legal-entities.d.ts +139 -0
  122. package/dist/platform/legal-entities.js +126 -0
  123. package/dist/platform/legal-entity-numbering.d.ts +103 -0
  124. package/dist/platform/legal-entity-numbering.js +101 -0
  125. package/dist/platform/organization-membership.d.ts +80 -0
  126. package/dist/platform/organization-membership.js +71 -0
  127. package/dist/platform/organization-settings.d.ts +33 -0
  128. package/dist/platform/organization-settings.js +42 -0
  129. package/dist/platform/organization-sharing.d.ts +172 -0
  130. package/dist/platform/organization-sharing.js +120 -0
  131. package/dist/platform/organizations.d.ts +205 -0
  132. package/dist/platform/organizations.js +180 -0
  133. package/dist/platform/provision-store.d.ts +88 -8
  134. package/dist/platform/provision-store.js +12 -0
  135. package/dist/platform/reports.d.ts +46 -0
  136. package/dist/platform/reports.js +31 -0
  137. package/dist/platform/server-metrics.d.ts +58 -0
  138. package/dist/platform/server-metrics.js +11 -0
  139. package/dist/pos/index.d.ts +567 -0
  140. package/dist/pos/index.js +205 -0
  141. package/dist/pricing/index.d.ts +408 -0
  142. package/dist/pricing/index.js +353 -0
  143. package/dist/pricing/vouchers.d.ts +103 -0
  144. package/dist/pricing/vouchers.js +69 -0
  145. package/dist/provenance/index.d.ts +93 -0
  146. package/dist/provenance/index.js +53 -0
  147. package/dist/reports/index.d.ts +199 -0
  148. package/dist/reports/index.js +154 -0
  149. package/dist/returns/index.d.ts +225 -0
  150. package/dist/returns/index.js +160 -0
  151. package/dist/search/index.d.ts +99 -0
  152. package/dist/search/index.js +62 -0
  153. package/dist/shipping/parcel-count-suggestion.d.ts +52 -0
  154. package/dist/shipping/parcel-count-suggestion.js +73 -0
  155. package/dist/shipping/parcel-rule.d.ts +48 -0
  156. package/dist/shipping/parcel-rule.js +91 -0
  157. package/dist/stock/index.d.ts +166 -0
  158. package/dist/stock/index.js +115 -0
  159. package/dist/stock/transfers.d.ts +520 -0
  160. package/dist/stock/transfers.js +437 -0
  161. package/dist/stored-value/index.d.ts +154 -0
  162. package/dist/stored-value/index.js +130 -0
  163. package/dist/tenant/capabilities.d.ts +10 -0
  164. package/dist/tenant/entitlements.d.ts +35 -0
  165. package/dist/tenant/entitlements.js +15 -0
  166. package/dist/tenant/field-groups.d.ts +64 -0
  167. package/dist/tenant/field-groups.js +34 -0
  168. package/dist/tenant/legal-entity.d.ts +32 -0
  169. package/dist/tenant/legal-entity.js +41 -0
  170. package/dist/tenant/notifications.d.ts +148 -0
  171. package/dist/tenant/notifications.js +79 -0
  172. package/dist/tenant/retention.d.ts +10 -4
  173. package/dist/tenant/settings-sources.d.ts +103 -0
  174. package/dist/tenant/settings-sources.js +92 -0
  175. package/dist/types.d.ts +86 -11
  176. package/dist/uploads/index.d.ts +11 -7
  177. package/dist/users/index.d.ts +104 -0
  178. package/dist/users/index.js +80 -0
  179. package/package.json +3 -2
@@ -0,0 +1,520 @@
1
+ import { type Page, type Transport } from '@sixtyninecommerce/core';
2
+ import { type MyparcelUnretractedShipment } from '../fulfillments/index.js';
3
+ import type { Call, ListOptions } from '../types.js';
4
+ export type StockTransferState = 'draft' | 'in_transit' | 'received' | 'cancelled';
5
+ /** A `transfer` moves stock between two locations; a `consumption` uses it up at one. */
6
+ export type StockTransferKind = 'transfer' | 'consumption';
7
+ export interface StockTransferAddress {
8
+ contactName: string | null;
9
+ company: string | null;
10
+ streetLine1: string;
11
+ streetLine2: string | null;
12
+ city: string;
13
+ province: string | null;
14
+ postalCode: string;
15
+ /** ISO 3166-1 alpha-2, upper case. */
16
+ countryCode: string;
17
+ phoneNumber: string | null;
18
+ }
19
+ export interface StockTransferAddressInput {
20
+ contactName?: string | null;
21
+ company?: string | null;
22
+ streetLine1: string;
23
+ streetLine2?: string | null;
24
+ city: string;
25
+ province?: string | null;
26
+ postalCode: string;
27
+ countryCode: string;
28
+ phoneNumber?: string | null;
29
+ }
30
+ export interface StockTransferLine {
31
+ id: string;
32
+ variantId: string;
33
+ sku: string;
34
+ quantity: number;
35
+ receivedQuantity: number;
36
+ lostQuantity: number;
37
+ /**
38
+ * `quantity − received − lost − returned to the source`. The units a close
39
+ * sent back to the source are read by `shortfall(id)`.
40
+ */
41
+ outstandingQuantity: number;
42
+ }
43
+ export interface StockTransfer {
44
+ id: string;
45
+ code: string;
46
+ kind: StockTransferKind;
47
+ state: StockTransferState;
48
+ sourceLocation: {
49
+ id: string;
50
+ name: string;
51
+ };
52
+ /** Null for a consumption. */
53
+ destinationLocation: {
54
+ id: string;
55
+ name: string;
56
+ } | null;
57
+ label: string | null;
58
+ /** Free text for the people moving the stock. Not a movement reason. */
59
+ note: string | null;
60
+ carrier: string | null;
61
+ trackingCode: string | null;
62
+ estimatedArrivalAt: string | null;
63
+ shippedAt: string | null;
64
+ receivedAt: string | null;
65
+ cancelledAt: string | null;
66
+ cancelReason: string | null;
67
+ deliveryAddress: StockTransferAddress | null;
68
+ createdAt: string;
69
+ updatedAt: string;
70
+ items: StockTransferLine[];
71
+ totalQuantity: number;
72
+ totalReceivedQuantity: number;
73
+ totalLostQuantity: number;
74
+ }
75
+ export interface StockTransferLineInput {
76
+ variantId: string;
77
+ quantity: number;
78
+ }
79
+ export interface CreateStockTransferInput {
80
+ /** Defaults to `transfer`. A `consumption` has no destination. */
81
+ kind?: StockTransferKind;
82
+ sourceLocationId: string;
83
+ /** Required for a transfer; omit for a consumption. */
84
+ destinationLocationId?: string;
85
+ label?: string;
86
+ note?: string;
87
+ lines: StockTransferLineInput[];
88
+ }
89
+ /** A draft's fields; an omitted field is left as it is. */
90
+ export interface UpdateStockTransferInput {
91
+ sourceLocationId?: string;
92
+ destinationLocationId?: string;
93
+ label?: string;
94
+ note?: string;
95
+ /** Replaces every line. */
96
+ lines?: StockTransferLineInput[];
97
+ carrier?: string;
98
+ trackingCode?: string;
99
+ /** ISO 8601 with an explicit offset. */
100
+ estimatedArrivalAt?: string;
101
+ }
102
+ export interface ShipStockTransferInput {
103
+ carrier?: string;
104
+ trackingCode?: string;
105
+ /** ISO 8601 with an explicit offset. */
106
+ estimatedArrivalAt?: string;
107
+ /** The engine's fulfilment handler code; defaults to manual shipping. */
108
+ fulfillmentHandlerCode?: string;
109
+ handlerArgs?: Record<string, unknown>;
110
+ /** Ship somewhere other than the destination's own address; null re-addresses it there. */
111
+ deliveryAddress?: StockTransferAddressInput | null;
112
+ }
113
+ export interface ReceiveStockTransferLineInput {
114
+ lineId: string;
115
+ receivedQuantity: number;
116
+ lostQuantity: number;
117
+ }
118
+ /**
119
+ * What closing a transfer does with a line's unaccounted units: `LOST` writes
120
+ * them off (what a close does without a disposition), `RETURN_TO_SOURCE`
121
+ * credits them back to the transfer's source location.
122
+ */
123
+ export type StockTransferShortfallDisposition = 'LOST' | 'RETURN_TO_SOURCE';
124
+ /** One line's disposition when closing a transfer. */
125
+ export interface StockTransferShortfallLineInput {
126
+ /** A line (`StockTransferLine.id`) with `outstandingQuantity` above 0. */
127
+ lineId: string;
128
+ disposition: StockTransferShortfallDisposition;
129
+ }
130
+ /** `close` options. */
131
+ export interface CloseStockTransferOptions extends Call {
132
+ /** Write off as lost every line still short that `shortfall` does not name. */
133
+ acceptShortfallAsLost?: boolean;
134
+ /**
135
+ * Per line, what happens to its unaccounted units. Needs an engine with
136
+ * per-line dispositions; an older one refuses the call
137
+ * (`GRAPHQL_VALIDATION_FAILED`), and a close without it works on both.
138
+ */
139
+ shortfall?: StockTransferShortfallLineInput[];
140
+ }
141
+ /** One line of a transfer, with where each of its units ended up. */
142
+ export interface StockTransferShortfallLine {
143
+ lineId: string;
144
+ variantId: string;
145
+ sku: string;
146
+ quantity: number;
147
+ receivedQuantity: number;
148
+ lostQuantity: number;
149
+ /** Units the transfer's close credited back to the source (`RETURN_TO_SOURCE`). */
150
+ returnedToSourceQuantity: number;
151
+ /** `quantity − received − lost − returnedToSource`. */
152
+ outstandingQuantity: number;
153
+ }
154
+ /** Where the units of a transfer's lines ended up: arrived, lost, or back at the source. */
155
+ export interface StockTransferShortfall {
156
+ transferId: string;
157
+ state: StockTransferState;
158
+ lines: StockTransferShortfallLine[];
159
+ totalLostQuantity: number;
160
+ totalReturnedToSourceQuantity: number;
161
+ }
162
+ export interface StockTransferFilter extends ListOptions {
163
+ /** Either end of the transfer. */
164
+ locationId?: string;
165
+ sourceLocationId?: string;
166
+ destinationLocationId?: string;
167
+ state?: StockTransferState[];
168
+ /** ISO 8601 with an explicit offset. */
169
+ dateFrom?: string;
170
+ /** ISO 8601 with an explicit offset. */
171
+ dateTo?: string;
172
+ search?: string;
173
+ /** Only the returns of this transfer. Needs an engine with returns. */
174
+ returnOfTransferId?: string;
175
+ /**
176
+ * `true`: only returns; `false`: only transfers that are not returns;
177
+ * omitted: both. Needs an engine with returns.
178
+ */
179
+ isReturn?: boolean;
180
+ }
181
+ /** A draft return of a transfer. Its source is always the transfer's destination. */
182
+ export interface CreateStockTransferReturnInput {
183
+ /**
184
+ * Where the returned stock goes: any location of this store except the
185
+ * return's source (the transfer's destination).
186
+ */
187
+ destinationLocationId: string;
188
+ label?: string;
189
+ note?: string;
190
+ /**
191
+ * Per variant, at most its `returnableQuantity` (`returns(id)`). A variant
192
+ * on several lines counts once, summed.
193
+ */
194
+ lines: StockTransferLineInput[];
195
+ }
196
+ /** A transfer at the other end of a return link: enough to list it and link to it. */
197
+ export interface StockTransferReturnRef {
198
+ id: string;
199
+ code: string;
200
+ state: StockTransferState;
201
+ label: string | null;
202
+ sourceLocation: {
203
+ id: string;
204
+ name: string;
205
+ };
206
+ destinationLocation: {
207
+ id: string;
208
+ name: string;
209
+ } | null;
210
+ createdAt: string;
211
+ totalQuantity: number;
212
+ }
213
+ /** One variant of a transfer, as a return of that transfer sees it. */
214
+ export interface StockTransferReturnableLine {
215
+ variantId: string;
216
+ sku: string;
217
+ variantName: string;
218
+ /** Summed over the transfer's lines for this variant. */
219
+ receivedQuantity: number;
220
+ /** Summed over the transfer's returns that are not cancelled, plus units lost on a cancelled one. */
221
+ returnedQuantity: number;
222
+ /** `max(0, received − returned)`: what a new return may still take. */
223
+ returnableQuantity: number;
224
+ }
225
+ /** How a transfer is linked to returns: the one it returns from, and its own. */
226
+ export interface StockTransferReturns {
227
+ /** The transfer this one returns stock from; null when it is not a return. */
228
+ returnOfTransferId: string | null;
229
+ returnOf: StockTransferReturnRef | null;
230
+ /** Returns created from this transfer, newest first, every state (cancelled included). */
231
+ returns: StockTransferReturnRef[];
232
+ /**
233
+ * Per variant, what a new return may still take. Empty for a consumption, a
234
+ * return, or a transfer with nothing received.
235
+ */
236
+ returnableLines: StockTransferReturnableLine[];
237
+ }
238
+ /** A member of staff who acted on a transfer. */
239
+ export interface StockTransferStaffRef {
240
+ /** The administrator's id. */
241
+ id: string;
242
+ firstName: string;
243
+ lastName: string;
244
+ }
245
+ /**
246
+ * How a transfer's cancellation stands: who cancelled it and why, and what the
247
+ * operator must still have done outside the platform.
248
+ */
249
+ export interface StockTransferCancellation {
250
+ transferId: string;
251
+ state: StockTransferState;
252
+ /** Null until it is cancelled. */
253
+ cancelledAt: string | null;
254
+ cancelReason: string | null;
255
+ /**
256
+ * Who cancelled it. Null when it is not cancelled, or was cancelled before
257
+ * the engine recorded who did.
258
+ */
259
+ cancelledBy: StockTransferStaffRef | null;
260
+ /**
261
+ * The Hendriks (3PL) export its shipment is on record under, or null when
262
+ * it has none: not shipped with Hendriks, or the export never completed. A
263
+ * cancel withdraws nothing at Hendriks, so a cancelled transfer that still
264
+ * has one needs Hendriks asked to retract `bluJayOrderNumber`, or the goods
265
+ * still ship. `bluJayOrderNumber` is null only for an export recorded before
266
+ * BluJay numbers were.
267
+ */
268
+ hendriksExport: {
269
+ bluJayOrderNumber: string | null;
270
+ } | null;
271
+ }
272
+ /** One MyParcel parcel of a stock transfer: its own shipment, label and barcode. */
273
+ export interface StockTransferParcel {
274
+ /** 1-based, parcel order. */
275
+ ordinal: number;
276
+ /** Its MyParcel shipment id. */
277
+ shipmentId: number;
278
+ /** Null until MyParcel has issued one (it does once the parcel's label is bought). */
279
+ barcode: string | null;
280
+ /** Its label was bought; it is never requested again. */
281
+ labelReady: boolean;
282
+ /** Why its label could not be bought (e.g. the prepaid balance), else null. */
283
+ lastError: string | null;
284
+ }
285
+ /**
286
+ * A stock transfer's MyParcel parcels. A transfer shipped with MyParcel as N
287
+ * parcels is booked as N MyParcel shipments, one label and one barcode each;
288
+ * the booking and the labels finish AFTER the ship returns, so read this again
289
+ * until every parcel has its barcode.
290
+ */
291
+ export interface StockTransferParcels {
292
+ transferId: string;
293
+ state: StockTransferState;
294
+ /**
295
+ * The engine's handler it shipped with (`myparcel`, `hendriks-3pl`,
296
+ * `manual-fulfillment`); null while it is a draft.
297
+ */
298
+ fulfillmentHandlerCode: string | null;
299
+ /**
300
+ * How many parcels the MyParcel shipment was asked to go in, never fewer
301
+ * than are booked. Null when the transfer has no MyParcel shipment.
302
+ */
303
+ parcelCount: number | null;
304
+ /**
305
+ * Every BOOKED parcel, parcel order. Fewer than `parcelCount` while the
306
+ * booking is still running, or when it stopped part-way (`lastError`).
307
+ */
308
+ parcels: StockTransferParcel[];
309
+ /** Every barcode issued so far, parcel order, without gaps. */
310
+ trackingCodes: string[];
311
+ /**
312
+ * Why the MyParcel booking stopped part-way (`retryMyparcelShipments`
313
+ * finishes it), or which parcels a removed shipment or a cancel could not
314
+ * retract at MyParcel (cancel those in the MyParcel backoffice). Null when
315
+ * there is nothing to act on.
316
+ */
317
+ lastError: string | null;
318
+ /**
319
+ * The MyParcel shipments a removed shipment or a cancel of this transfer let
320
+ * go of that MyParcel kept or could not be reached to delete, resolved
321
+ * entries included. Kept across a re-ship, whatever the handler then is.
322
+ */
323
+ unretractedShipments: MyparcelUnretractedShipment[];
324
+ }
325
+ export type StockTransferLabelFormat = 'A4' | 'A6';
326
+ /** One PDF holding every parcel's label of a transfer, in parcel order. */
327
+ export interface StockTransferLabel {
328
+ format: StockTransferLabelFormat;
329
+ contentType: string;
330
+ filename: string;
331
+ bytes: Uint8Array;
332
+ }
333
+ /**
334
+ * Stock transfers (the engine's stock-transfer module, wrapped): a draft is
335
+ * created, shipped (debiting the source), received line by line (crediting the
336
+ * destination) and closed, or cancelled. A consumption is posted instead of
337
+ * shipped and debits its one location.
338
+ *
339
+ * `note` and `cancelReason` are the transfer's OWN words and stay on the
340
+ * transfer; they are not movement reasons and do not appear on
341
+ * `stock.movements()`. Reads need `ReadStockLocation`; every write needs `AdjustStock`
342
+ * (or, for credentials minted before it existed, `UpdateStockLocation` — a transition a
343
+ * later release ends).
344
+ * None of these writes takes an idempotency key yet.
345
+ *
346
+ * Every location and variant a transfer names must be the store's own:
347
+ * another store's location (or an id that does not exist) is refused
348
+ * `LOCATION_NOT_IN_CHANNEL` (→ `ValidationError`), another store's variant
349
+ * `STOCK_VARIANT_NOT_FOUND` (→ `NotFoundError`), and another store's transfer
350
+ * reads as `null` from `get`.
351
+ *
352
+ * A credential restricted with `locationIds` is refused `LOCATION_NOT_ALLOWED`
353
+ * (→ `PermissionDeniedError`) unless it holds the end of the transfer the call
354
+ * acts for: the SOURCE — the location whose stock is debited — to `create`,
355
+ * `createReturn` (the RETURN's source, which is the original transfer's
356
+ * destination), `update`, `ship`, `postConsumption` or `cancel`; the
357
+ * DESTINATION to `receive`; either end to `close`, and the SOURCE to a `close`
358
+ * that sends a line back to it. An `update` that moves the
359
+ * source needs the new source as well. Such a credential lists, and can `get`,
360
+ * only transfers with at least one end it holds.
361
+ *
362
+ * **Returns.** Stock sent somewhere temporary (an event, a pop-up) comes back
363
+ * as a RETURN: an ordinary transfer, with its own code, linked to the transfer
364
+ * it reverses. `createReturn` pins its source to that transfer's destination
365
+ * (where the goods are); its destination is any other location of the store.
366
+ * Each variant is capped at what the transfer RECEIVED minus its returns that
367
+ * are not cancelled (`returns(id).returnableLines`), so nothing received means
368
+ * nothing returnable; what is not returned stays where it is. The return then
369
+ * ships, receives, closes and cancels like any transfer, and a cancelled
370
+ * return frees its quantity again. Refusals, each → `BusinessRuleError`:
371
+ * `STOCK_TRANSFER_NOT_RETURNABLE` (a consumption, a return, or a transfer
372
+ * neither in transit nor received), `RETURN_QUANTITY_EXCEEDS_RECEIVED` (above
373
+ * the cap, or a variant not on the transfer, also on an `update` of a return
374
+ * draft's lines) and `RETURN_SOURCE_LOCKED` (an `update` moving a return's
375
+ * source). `createReturn` needs what every write needs. The return fields are
376
+ * read by `returns(id)` and filtered by `list({ returnOfTransferId, isReturn })`,
377
+ * never by `get`: a caller ahead of the engine sees only those calls refused.
378
+ */
379
+ export interface StockTransfersModule {
380
+ list(filter?: StockTransferFilter): Promise<Page<StockTransfer>>;
381
+ get(id: string, options?: Call): Promise<StockTransfer | null>;
382
+ create(input: CreateStockTransferInput, options?: Call): Promise<StockTransfer>;
383
+ /** Only a draft can be edited. */
384
+ update(id: string, input: UpdateStockTransferInput, options?: Call): Promise<StockTransfer>;
385
+ /**
386
+ * Draft → in transit: the source is debited. A MyParcel ship books every
387
+ * parcel at MyParcel before it answers, so it is allowed up to 120s; a
388
+ * `REQUEST_TIMEOUT` does not mean it failed — `get` it before shipping again.
389
+ */
390
+ ship(id: string, input?: ShipStockTransferInput, options?: Call): Promise<StockTransfer>;
391
+ /** Post a consumption: debit its location and complete the draft. */
392
+ postConsumption(id: string, options?: Call): Promise<StockTransfer>;
393
+ /** Credit the destination with what arrived, and write off what was lost, per line. */
394
+ receive(id: string, lines: ReceiveStockTransferLineInput[], options?: Call): Promise<StockTransfer>;
395
+ /**
396
+ * Close an in-transit transfer as received. Each line still short is settled
397
+ * as `shortfall` names it — `LOST`, or `RETURN_TO_SOURCE` (credited back to
398
+ * the source) — and a line it does not name is written off as lost only with
399
+ * `acceptShortfallAsLost`; otherwise the close is refused. Refused too: a
400
+ * line named twice, a line of another transfer, a line with nothing
401
+ * outstanding. Each refusal is a `ValidationError` and changes nothing.
402
+ */
403
+ close(id: string, options?: CloseStockTransferOptions): Promise<StockTransfer>;
404
+ /**
405
+ * Cancel a draft, or an in-transit transfer (unreceived stock returns to the
406
+ * source). An in-transit MyParcel shipment's parcels are voided at MyParcel
407
+ * inside the call, so it is allowed up to 120s.
408
+ */
409
+ cancel(id: string, options?: Call & {
410
+ reason?: string;
411
+ }): Promise<StockTransfer>;
412
+ /**
413
+ * Create a draft RETURN of transfer `id` (the original): its source is the
414
+ * original's destination, its lines capped per variant at what the original
415
+ * received minus its other returns that are not cancelled. Answers the
416
+ * return; ship and receive it like any transfer. A restricted credential
417
+ * must hold the return's source (the original's destination).
418
+ */
419
+ createReturn(id: string, input: CreateStockTransferReturnInput, options?: Call): Promise<StockTransfer>;
420
+ /**
421
+ * How transfer `id` is linked to returns — the transfer it returns from, its
422
+ * own returns, and what a new return may still take per variant — or null
423
+ * when this store has no such transfer. Its own request, never part of
424
+ * `get`. Needs `ReadStockLocation`.
425
+ */
426
+ returns(id: string, options?: Call): Promise<StockTransferReturns | null>;
427
+ /**
428
+ * Where the units of transfer `id`'s lines ended up — received, lost, or
429
+ * sent back to the source by its close — or null when this store has no such
430
+ * transfer. Its own request, never part of `get`, so `get` keeps working
431
+ * against an engine without it. Needs `ReadStockLocation`.
432
+ */
433
+ shortfall(id: string, options?: Call): Promise<StockTransferShortfall | null>;
434
+ /**
435
+ * Who cancelled transfer `id`, why, and the Hendriks export a cancel leaves
436
+ * to be retracted by hand — or null when this store has no such transfer.
437
+ * Read it before `cancel` to warn about the export, and after to show who
438
+ * did it. Its own request, never part of `get`: a caller deployed ahead of
439
+ * an engine that does not record the canceller sees only this call refused.
440
+ * Needs `ReadStockLocation`.
441
+ */
442
+ cancellation(id: string, options?: Call): Promise<StockTransferCancellation | null>;
443
+ /**
444
+ * The transfer's MyParcel parcels, or null when this store has no such
445
+ * transfer. Its own request, never part of `get`: a caller deployed ahead of
446
+ * an engine without the parcel fields sees only this call refused. Needs
447
+ * `ReadStockLocation`; reads the engine only, never MyParcel.
448
+ */
449
+ parcels(id: string, options?: Call): Promise<StockTransferParcels | null>;
450
+ /**
451
+ * Finish an in-transit MyParcel transfer's booking: book exactly the parcels
452
+ * still missing (a parcel MyParcel already holds is adopted, never booked
453
+ * twice) and ask again for the label of every parcel without a barcode.
454
+ * Answers the parcels as the retry left them: a booking that fails again is
455
+ * NOT thrown, it is on `lastError`. Refused `MYPARCEL_RETRY_NOT_APPLICABLE`
456
+ * (→ `BusinessRuleError`) when the transfer did not ship with MyParcel or is
457
+ * no longer in transit, and with the ship's own refusals (MyParcel disabled
458
+ * meanwhile: `MYPARCEL_NOT_AVAILABLE`). Needs what `ship` needs, and a
459
+ * restricted credential must hold the source.
460
+ *
461
+ * The engine books each missing parcel at MyParcel inside this call, so it
462
+ * is allowed up to 120s. A `REQUEST_TIMEOUT` does NOT mean the booking
463
+ * failed — the engine carries on — so read `parcels()` again before retrying.
464
+ */
465
+ retryMyparcelShipments(id: string, options?: Call): Promise<StockTransferParcels>;
466
+ /**
467
+ * Label every MyParcel parcel of an in-transit transfer that still needs its
468
+ * label or its barcode: queues ONE label job, which asks nothing again for a
469
+ * parcel already labelled. Answers the parcels as they stand when the job is
470
+ * queued; the labels land when it has run, so read `parcels()` again. Labels
471
+ * only: a parcel not booked yet is booked by `retryMyparcelShipments`.
472
+ *
473
+ * Refused `MYPARCEL_LABEL_NOT_AVAILABLE` (→ `BusinessRuleError`) when the
474
+ * transfer did not ship with MyParcel, is not in transit or has no parcel
475
+ * booked, and `MYPARCEL_NOT_AVAILABLE` while MyParcel is not installed, set
476
+ * up or enabled. Needs what `ship` needs, and a restricted credential must
477
+ * hold the source. It only queues, so the default timeout applies.
478
+ */
479
+ labelMyparcelParcels(id: string, options?: Call): Promise<StockTransferParcels>;
480
+ /**
481
+ * Every MyParcel parcel's label of an in-transit transfer, merged by
482
+ * MyParcel into one PDF in parcel order, fetched live and never stored.
483
+ * Refused `MYPARCEL_LABEL_NOT_AVAILABLE` (→ `BusinessRuleError`) when the
484
+ * transfer has no booked MyParcel parcel in transit. Needs
485
+ * `ReadStockLocation`, and a restricted credential must hold either end.
486
+ * Allowed up to 55s: the engine retries a slow MyParcel within a budget the
487
+ * default timeout does not cover.
488
+ */
489
+ myparcelLabel(id: string, format: StockTransferLabelFormat, options?: Call): Promise<StockTransferLabel>;
490
+ }
491
+ export declare const STOCK_TRANSFERS_QUERY = "\n query StockTransfers($options: StockTransferListOptions) {\n stockTransfers(options: $options) { items { \n id\n code\n kind\n state\n sourceLocation { id name }\n destinationLocation { id name }\n label\n note\n carrier\n trackingCode\n estimatedArrivalAt\n shippedAt\n receivedAt\n cancelledAt\n cancelReason\n deliveryAddress {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n createdAt\n updatedAt\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n outstandingQuantity\n }\n totalQuantity\n totalReceivedQuantity\n totalLostQuantity\n } totalItems }\n }\n";
492
+ export declare const STOCK_TRANSFER_QUERY = "\n query StockTransfer($id: ID!) { stockTransfer(id: $id) { \n id\n code\n kind\n state\n sourceLocation { id name }\n destinationLocation { id name }\n label\n note\n carrier\n trackingCode\n estimatedArrivalAt\n shippedAt\n receivedAt\n cancelledAt\n cancelReason\n deliveryAddress {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n createdAt\n updatedAt\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n outstandingQuantity\n }\n totalQuantity\n totalReceivedQuantity\n totalLostQuantity\n } }\n";
493
+ export declare const CREATE_STOCK_TRANSFER_MUTATION = "\n mutation CreateStockTransfer($input: CreateStockTransferInput!) {\n createStockTransfer(input: $input) { \n id\n code\n kind\n state\n sourceLocation { id name }\n destinationLocation { id name }\n label\n note\n carrier\n trackingCode\n estimatedArrivalAt\n shippedAt\n receivedAt\n cancelledAt\n cancelReason\n deliveryAddress {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n createdAt\n updatedAt\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n outstandingQuantity\n }\n totalQuantity\n totalReceivedQuantity\n totalLostQuantity\n }\n }\n";
494
+ export declare const UPDATE_STOCK_TRANSFER_MUTATION = "\n mutation UpdateStockTransfer($id: ID!, $input: UpdateStockTransferInput!) {\n updateStockTransfer(id: $id, input: $input) { \n id\n code\n kind\n state\n sourceLocation { id name }\n destinationLocation { id name }\n label\n note\n carrier\n trackingCode\n estimatedArrivalAt\n shippedAt\n receivedAt\n cancelledAt\n cancelReason\n deliveryAddress {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n createdAt\n updatedAt\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n outstandingQuantity\n }\n totalQuantity\n totalReceivedQuantity\n totalLostQuantity\n }\n }\n";
495
+ export declare const SHIP_STOCK_TRANSFER_MUTATION = "\n mutation ShipStockTransfer($id: ID!, $input: ShipStockTransferInput) {\n shipStockTransfer(id: $id, input: $input) { \n id\n code\n kind\n state\n sourceLocation { id name }\n destinationLocation { id name }\n label\n note\n carrier\n trackingCode\n estimatedArrivalAt\n shippedAt\n receivedAt\n cancelledAt\n cancelReason\n deliveryAddress {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n createdAt\n updatedAt\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n outstandingQuantity\n }\n totalQuantity\n totalReceivedQuantity\n totalLostQuantity\n }\n }\n";
496
+ export declare const POST_STOCK_TRANSFER_CONSUMPTION_MUTATION = "\n mutation PostStockTransferConsumption($id: ID!) {\n postStockTransferConsumption(id: $id) { \n id\n code\n kind\n state\n sourceLocation { id name }\n destinationLocation { id name }\n label\n note\n carrier\n trackingCode\n estimatedArrivalAt\n shippedAt\n receivedAt\n cancelledAt\n cancelReason\n deliveryAddress {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n createdAt\n updatedAt\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n outstandingQuantity\n }\n totalQuantity\n totalReceivedQuantity\n totalLostQuantity\n }\n }\n";
497
+ export declare const RECEIVE_STOCK_TRANSFER_LINES_MUTATION = "\n mutation ReceiveStockTransferLines($id: ID!, $lines: [ReceiveStockTransferLineInput!]!) {\n receiveStockTransferLines(id: $id, lines: $lines) { \n id\n code\n kind\n state\n sourceLocation { id name }\n destinationLocation { id name }\n label\n note\n carrier\n trackingCode\n estimatedArrivalAt\n shippedAt\n receivedAt\n cancelledAt\n cancelReason\n deliveryAddress {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n createdAt\n updatedAt\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n outstandingQuantity\n }\n totalQuantity\n totalReceivedQuantity\n totalLostQuantity\n }\n }\n";
498
+ export declare const CLOSE_STOCK_TRANSFER_MUTATION = "\n mutation CloseStockTransfer($id: ID!, $acceptShortfallAsLost: Boolean) {\n closeStockTransfer(id: $id, acceptShortfallAsLost: $acceptShortfallAsLost) { \n id\n code\n kind\n state\n sourceLocation { id name }\n destinationLocation { id name }\n label\n note\n carrier\n trackingCode\n estimatedArrivalAt\n shippedAt\n receivedAt\n cancelledAt\n cancelReason\n deliveryAddress {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n createdAt\n updatedAt\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n outstandingQuantity\n }\n totalQuantity\n totalReceivedQuantity\n totalLostQuantity\n }\n }\n";
499
+ /**
500
+ * Its own document: it declares `$shortfall`, which an engine without per-line
501
+ * dispositions refuses as a whole. A close without dispositions keeps sending
502
+ * the document above.
503
+ */
504
+ export declare const CLOSE_STOCK_TRANSFER_WITH_SHORTFALL_MUTATION = "\n mutation CloseStockTransferWithShortfall(\n $id: ID!\n $acceptShortfallAsLost: Boolean\n $shortfall: [StockTransferShortfallLineInput!]!\n ) {\n closeStockTransfer(\n id: $id\n acceptShortfallAsLost: $acceptShortfallAsLost\n shortfall: $shortfall\n ) { \n id\n code\n kind\n state\n sourceLocation { id name }\n destinationLocation { id name }\n label\n note\n carrier\n trackingCode\n estimatedArrivalAt\n shippedAt\n receivedAt\n cancelledAt\n cancelReason\n deliveryAddress {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n createdAt\n updatedAt\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n outstandingQuantity\n }\n totalQuantity\n totalReceivedQuantity\n totalLostQuantity\n }\n }\n";
505
+ export declare const CANCEL_STOCK_TRANSFER_MUTATION = "\n mutation CancelStockTransfer($id: ID!, $reason: String) {\n cancelStockTransfer(id: $id, reason: $reason) { \n id\n code\n kind\n state\n sourceLocation { id name }\n destinationLocation { id name }\n label\n note\n carrier\n trackingCode\n estimatedArrivalAt\n shippedAt\n receivedAt\n cancelledAt\n cancelReason\n deliveryAddress {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n createdAt\n updatedAt\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n outstandingQuantity\n }\n totalQuantity\n totalReceivedQuantity\n totalLostQuantity\n }\n }\n";
506
+ export declare const CREATE_STOCK_TRANSFER_RETURN_MUTATION = "\n mutation CreateStockTransferReturn($id: ID!, $input: CreateStockTransferReturnInput!) {\n createStockTransferReturn(id: $id, input: $input) { \n id\n code\n kind\n state\n sourceLocation { id name }\n destinationLocation { id name }\n label\n note\n carrier\n trackingCode\n estimatedArrivalAt\n shippedAt\n receivedAt\n cancelledAt\n cancelReason\n deliveryAddress {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n createdAt\n updatedAt\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n outstandingQuantity\n }\n totalQuantity\n totalReceivedQuantity\n totalLostQuantity\n }\n }\n";
507
+ export declare const STOCK_TRANSFER_RETURNS_QUERY = "\n query StockTransferReturns($id: ID!) {\n stockTransfer(id: $id) {\n returnOfTransferId\n returnOf { \n id\n code\n state\n label\n sourceLocation { id name }\n destinationLocation { id name }\n createdAt\n totalQuantity\n }\n returns { \n id\n code\n state\n label\n sourceLocation { id name }\n destinationLocation { id name }\n createdAt\n totalQuantity\n }\n returnableLines {\n productVariantId\n productVariant { name sku }\n receivedQuantity\n returnedQuantity\n returnableQuantity\n }\n }\n }\n";
508
+ /** The per-line settlement fields, in a document of their own like the return fields. */
509
+ export declare const STOCK_TRANSFER_SHORTFALL_QUERY = "\n query StockTransferShortfall($id: ID!) {\n stockTransfer(id: $id) {\n id\n state\n items {\n id\n productVariant { id sku }\n quantity\n receivedQuantity\n lostQuantity\n returnedToSourceQuantity\n outstandingQuantity\n }\n totalLostQuantity\n totalReturnedToSourceQuantity\n }\n }\n";
510
+ /**
511
+ * The cancellation fields, in a document of their own like the return and
512
+ * parcel fields: `cancelledBy` is newer than the transfer module, and
513
+ * `get`/`list`/`cancel` keep working against an engine without it.
514
+ */
515
+ export declare const STOCK_TRANSFER_CANCELLATION_QUERY = "\n query StockTransferCancellation($id: ID!) {\n stockTransfer(id: $id) {\n id\n state\n cancelledAt\n cancelReason\n cancelledBy { id firstName lastName }\n fulfillmentHandlerCode\n hendriksRemotePath\n hendriksBluJayOrderNumber\n }\n }\n";
516
+ export declare const STOCK_TRANSFER_PARCELS_QUERY = "\n query StockTransferParcels($id: ID!) { stockTransfer(id: $id) { \n id\n state\n fulfillmentHandlerCode\n parcelCount\n myparcelParcels { ordinal shipmentId barcode labelReady lastError }\n trackingCodes\n myparcelBarcode\n myparcelLastError\n myparcelUnretractedShipments { \n shipmentId\n reference\n verdict\n status\n statusName\n billable\n hidden\n reason\n cause\n firstRecordedAt\n lastCheckedAt\n resolvedAt\n }\n } }\n";
517
+ export declare const RETRY_STOCK_TRANSFER_MYPARCEL_SHIPMENTS_MUTATION = "\n mutation RetryStockTransferMyparcelShipments($id: ID!) {\n retryStockTransferMyparcelShipments(id: $id) { \n id\n state\n fulfillmentHandlerCode\n parcelCount\n myparcelParcels { ordinal shipmentId barcode labelReady lastError }\n trackingCodes\n myparcelBarcode\n myparcelLastError\n myparcelUnretractedShipments { \n shipmentId\n reference\n verdict\n status\n statusName\n billable\n hidden\n reason\n cause\n firstRecordedAt\n lastCheckedAt\n resolvedAt\n }\n }\n }\n";
518
+ export declare const LABEL_STOCK_TRANSFER_MYPARCEL_PARCELS_MUTATION = "\n mutation LabelStockTransferMyparcelParcels($id: ID!) {\n labelStockTransferMyparcelParcels(id: $id) { \n id\n state\n fulfillmentHandlerCode\n parcelCount\n myparcelParcels { ordinal shipmentId barcode labelReady lastError }\n trackingCodes\n myparcelBarcode\n myparcelLastError\n myparcelUnretractedShipments { \n shipmentId\n reference\n verdict\n status\n statusName\n billable\n hidden\n reason\n cause\n firstRecordedAt\n lastCheckedAt\n resolvedAt\n }\n }\n }\n";
519
+ export declare const MYPARCEL_STOCK_TRANSFER_LABEL_MUTATION = "\n mutation MyparcelStockTransferLabel($transferId: ID!, $format: StockTransferLabelFormat!) {\n getMyparcelStockTransferLabel(transferId: $transferId, format: $format) {\n format\n base64\n contentType\n filename\n }\n }\n";
520
+ export declare function createStockTransfersModule(transport: Transport): StockTransfersModule;