@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,530 @@
1
+ /**
2
+ * `admin.orders.get(orderId)`: one order, typed (headless spec §9.2 `orders`
3
+ * "read", plan W9-9).
4
+ *
5
+ * The read has two layers. The CORE is what the engine itself serves for an
6
+ * order, and it is all a call without `include` asks for. Around it sit the
7
+ * blocks a plugin adds to an order (payment terms, delivery terms, the order's
8
+ * own price list, the ERP and carrier references). Each is asked for by name
9
+ * in `include`, so a caller reads only what it uses, and the core document
10
+ * names no field an engine without that plugin lacks.
11
+ *
12
+ * Money is an integer in minor units of the order's currency, with three
13
+ * exceptions that are NOT converted to it: a line's `productVariant.price` and
14
+ * `priceWithTax` (the catalogue price in the currency of the request, which is
15
+ * the store's default unless the call names another), and a line's
16
+ * `customFields.cost` (the store's default currency). An instant is an ISO-8601
17
+ * string with its offset.
18
+ */
19
+ import { ValidationError } from '@sixtyninecommerce/core';
20
+ import { redactionWatcher } from '../customer-data-redaction.js';
21
+ /**
22
+ * The blocks a plugin adds to an order, in the order the document lists them.
23
+ *
24
+ * - `paymentTerms`: the payment terms the order was placed under, and the
25
+ * order's own override of them (the B2B credit plugin).
26
+ * - `deliveryTerms`: the delivery terms accepted at placement (the shipping
27
+ * calculator plugin).
28
+ * - `priceList`: the order's own price list, which is its one-time pricing
29
+ * (the price-list plugin).
30
+ * - `lineAllocations`: each line's raw allocation rows (the stock-transfer
31
+ * plugin). They never decrement: `OrderLine.outstandingAllocations` is what a
32
+ * line reserves now, and needs no include.
33
+ * - `fulfillmentDetails`: each fulfillment's handler (code, name, its detail
34
+ * rows) and packing slips (the order-documents plugin).
35
+ * - `vatValidation`: the customer's VAT number and its validation status (the
36
+ * VAT-validation plugin).
37
+ * - `afas`, `parasut`: the references those ERP plugins keep on the order, its
38
+ * customer and the customer's addresses.
39
+ * - `myparcel`: the MyParcel shipment and label state on each fulfillment.
40
+ */
41
+ export const ORDER_INCLUDES = [
42
+ 'paymentTerms',
43
+ 'deliveryTerms',
44
+ 'priceList',
45
+ 'lineAllocations',
46
+ 'fulfillmentDetails',
47
+ 'vatValidation',
48
+ 'afas',
49
+ 'parasut',
50
+ 'myparcel',
51
+ ];
52
+ /**
53
+ * The order document with EVERY block, written out whole.
54
+ *
55
+ * One static literal on purpose. The repository's GraphQL cost guard
56
+ * (`services/vendure/src/rate-limit/__tests__/graphql-cost-fits-repo.spec.ts`)
57
+ * measures every document this package holds against the engine's caps, and it
58
+ * can only read a literal. This is the largest operation the dashboard sends,
59
+ * so it has to be the one that is measured: do not assemble it at run time.
60
+ *
61
+ * A block's fields sit between a `#[name` line and its `#]` line. Both are
62
+ * GraphQL comments, so the literal parses as it stands. `orderQuery` keeps a
63
+ * marked part when the call included the block, drops it otherwise, and drops
64
+ * the marker lines either way. `#[a|b` marks a part that is kept when ANY of
65
+ * the named blocks is included: an object whose every field belongs to a block
66
+ * (an empty selection is not valid GraphQL).
67
+ */
68
+ export const ORDER_QUERY_EVERY_BLOCK = /* GraphQL */ `
69
+ query Order($id: ID!) {
70
+ order(id: $id) {
71
+ id
72
+ code
73
+ state
74
+ active
75
+ total
76
+ totalWithTax
77
+ subTotal
78
+ subTotalWithTax
79
+ shipping
80
+ shippingWithTax
81
+ currencyCode
82
+ orderPlacedAt
83
+ #[paymentTerms
84
+ paymentTerms {
85
+ source
86
+ managedExternally
87
+ status
88
+ conditionCode
89
+ conditionDescription
90
+ summary
91
+ classification
92
+ paymentDays
93
+ paymentEndOfMonths
94
+ paymentMethod
95
+ percentage
96
+ discountPaymentDays
97
+ discountPercentage
98
+ paymentDiscountType
99
+ stale
100
+ syncedAt
101
+ error
102
+ resolvedAt
103
+ remoteConditionCode
104
+ remoteConfirmedAt
105
+ remoteMismatch
106
+ }
107
+ #]
108
+ #[deliveryTerms
109
+ deliveryTerms {
110
+ source
111
+ sourceScope
112
+ governingCustomerId
113
+ sourceCustomerId
114
+ managedExternally
115
+ status
116
+ shippingMethodStatus
117
+ policyStatus
118
+ summary
119
+ selectionSource
120
+ selectedShippingMethodId
121
+ selectedShippingMethodCode
122
+ selectedShippingMethodName
123
+ platformShippingMethodCode
124
+ platformShippingMethodName
125
+ platformShippingMethodDescription
126
+ platformShippingPrice
127
+ platformShippingPriceWithTax
128
+ preferredShippingMethodId
129
+ incotermStatus
130
+ incotermCode
131
+ incotermVersion
132
+ incotermAddress
133
+ incotermDescription
134
+ shippingLeadDays
135
+ deliveryAdvice
136
+ stale
137
+ syncedAt
138
+ warning
139
+ resolvedAt
140
+ remoteShippingMethodCode
141
+ remoteShippingMethodName
142
+ remoteIncotermCode
143
+ remoteIncotermVersion
144
+ remoteIncotermAddress
145
+ remoteDeliveryDate
146
+ remoteConfirmedAt
147
+ remoteMismatch
148
+ }
149
+ #]
150
+ couponCodes
151
+ customer {
152
+ id
153
+ firstName
154
+ lastName
155
+ emailAddress
156
+ phoneNumber
157
+ #[vatValidation|afas|parasut
158
+ customFields {
159
+ #[vatValidation
160
+ vatNumber
161
+ vatValidationStatus
162
+ #]
163
+ #[afas
164
+ afasVrId
165
+ afasOrgId
166
+ afasContactId
167
+ afasPersId
168
+ #]
169
+ #[parasut
170
+ parasutContactId
171
+ #]
172
+ }
173
+ #]
174
+ addresses {
175
+ id
176
+ fullName
177
+ company
178
+ streetLine1
179
+ streetLine2
180
+ city
181
+ postalCode
182
+ country {
183
+ code
184
+ }
185
+ defaultShippingAddress
186
+ defaultBillingAddress
187
+ #[afas
188
+ customFields {
189
+ afasAddressId
190
+ }
191
+ #]
192
+ }
193
+ }
194
+ lines {
195
+ id
196
+ quantity
197
+ unitPrice
198
+ unitPriceWithTax
199
+ listPriceIncludesTax
200
+ discountedUnitPrice
201
+ discountedUnitPriceWithTax
202
+ linePrice
203
+ linePriceWithTax
204
+ discountedLinePrice
205
+ discountedLinePriceWithTax
206
+ proratedLinePrice
207
+ proratedLinePriceWithTax
208
+ taxRate
209
+ productVariant {
210
+ id
211
+ name
212
+ sku
213
+ price
214
+ priceWithTax
215
+ stockOnHand
216
+ stockAllocated
217
+ trackInventory
218
+ outOfStockThreshold
219
+ useGlobalOutOfStockThreshold
220
+ stockLevels {
221
+ stockLocationId
222
+ stockOnHand
223
+ stockAllocated
224
+ stockLocation {
225
+ id
226
+ name
227
+ }
228
+ }
229
+ product {
230
+ id
231
+ name
232
+ featuredAsset {
233
+ id
234
+ preview
235
+ }
236
+ }
237
+ }
238
+ featuredAsset {
239
+ id
240
+ preview
241
+ }
242
+ #[lineAllocations
243
+ allocations {
244
+ id
245
+ stockLocation {
246
+ id
247
+ name
248
+ }
249
+ quantity
250
+ }
251
+ #]
252
+ outstandingAllocatedQuantity
253
+ outstandingAllocations {
254
+ stockLocationId
255
+ stockLocationName
256
+ quantity
257
+ }
258
+ customFields {
259
+ unitPriceOverride
260
+ priceOverrideReason
261
+ unitPriceImported
262
+ priceListId
263
+ priceListName
264
+ retailPrice
265
+ priceListPrice
266
+ priceListDiscountType
267
+ priceListDiscountValue
268
+ priceListDiscountChain
269
+ cost
270
+ preferredStockLocationId
271
+ backorderedQuantity
272
+ }
273
+ }
274
+ surcharges {
275
+ id
276
+ description
277
+ sku
278
+ price
279
+ priceWithTax
280
+ taxRate
281
+ }
282
+ discounts {
283
+ description
284
+ amount
285
+ amountWithTax
286
+ }
287
+ shippingLines {
288
+ shippingMethod {
289
+ id
290
+ name
291
+ }
292
+ }
293
+ payments {
294
+ id
295
+ state
296
+ method
297
+ amount
298
+ transactionId
299
+ createdAt
300
+ refunds {
301
+ id
302
+ state
303
+ total
304
+ reason
305
+ }
306
+ }
307
+ fulfillments {
308
+ id
309
+ state
310
+ nextStates
311
+ method
312
+ trackingCode
313
+ lines {
314
+ orderLineId
315
+ quantity
316
+ }
317
+ #[fulfillmentDetails
318
+ handlerCode
319
+ handlerName
320
+ handlerDetails {
321
+ label
322
+ value
323
+ }
324
+ packingSlips {
325
+ id
326
+ packingSlipNumber
327
+ fulfillmentId
328
+ languageCode
329
+ storageKey
330
+ createdAt
331
+ }
332
+ #]
333
+ stockLocationName
334
+ linkedOrders {
335
+ id
336
+ code
337
+ }
338
+ customFields {
339
+ #[myparcel
340
+ myparcelShipmentId
341
+ myparcelLabelStatus
342
+ myparcelLabelFormat
343
+ myparcelLabelUrlA4
344
+ myparcelLabelUrlA6
345
+ myparcelLabelLastError
346
+ myparcelLabelHandoff
347
+ #]
348
+ bookingStatus
349
+ }
350
+ createdAt
351
+ }
352
+ shippingAddress {
353
+ fullName
354
+ company
355
+ streetLine1
356
+ streetLine2
357
+ city
358
+ province
359
+ postalCode
360
+ country
361
+ countryCode
362
+ phoneNumber
363
+ }
364
+ billingAddress {
365
+ fullName
366
+ company
367
+ streetLine1
368
+ streetLine2
369
+ city
370
+ province
371
+ postalCode
372
+ country
373
+ countryCode
374
+ phoneNumber
375
+ }
376
+ history(options: { take: 50, sort: { createdAt: DESC } }) {
377
+ items {
378
+ id
379
+ type
380
+ data
381
+ createdAt
382
+ isPublic
383
+ administrator {
384
+ id
385
+ firstName
386
+ lastName
387
+ }
388
+ }
389
+ }
390
+ taxSummary {
391
+ description
392
+ taxRate
393
+ taxBase
394
+ taxTotal
395
+ }
396
+ nextStates
397
+ createdAt
398
+ updatedAt
399
+ customFields {
400
+ isLocked
401
+ externalOrderId
402
+ externalPlatform
403
+ sourceFulfillmentHandedOff
404
+ originalPlacedAt
405
+ sourceWarehouse
406
+ pickupLocation
407
+ allocationExpiresAt
408
+ goodwillRoundingMinor
409
+ removeTax
410
+ isGift
411
+ giftNote
412
+ hidePricesOnPackingSlip
413
+ poNumber
414
+ requestedDeliveryDate
415
+ orderNotes
416
+ customerShippingAddressId
417
+ customerBillingAddressId
418
+ shippingAddressIsTemporary
419
+ billingAddressIsTemporary
420
+ paymentStatus
421
+ fulfillmentStatus
422
+ returnStatus
423
+ lifecycleStatus
424
+ #[paymentTerms
425
+ paymentTermsDays
426
+ paymentConditionCode
427
+ #]
428
+ #[afas
429
+ afasSalesOrderId
430
+ afasDirectInvoiceOrNu
431
+ afasInvoiceNumber
432
+ afasInvoiceDate
433
+ afasLocked
434
+ afasLockReason
435
+ afasLastSyncAt
436
+ #]
437
+ #[parasut
438
+ parasutInvoiceId
439
+ parasutEInvoiceStatus
440
+ parasutEInvoiceUuid
441
+ parasutLastError
442
+ #]
443
+ }
444
+ fulfillmentHold {
445
+ reason
446
+ note
447
+ heldAt
448
+ heldByUserId
449
+ heldBy
450
+ }
451
+ #[priceList
452
+ priceList {
453
+ id
454
+ name
455
+ description
456
+ defaultDiscountBps
457
+ defaultDiscountAmount
458
+ entries {
459
+ id
460
+ variantId
461
+ discountType
462
+ discountValue
463
+ }
464
+ }
465
+ #]
466
+ }
467
+ }
468
+ `;
469
+ const BLOCK_OPEN = '#[';
470
+ const BLOCK_CLOSE = '#]';
471
+ /**
472
+ * The document `get` sends for a set of blocks: {@link ORDER_QUERY_EVERY_BLOCK}
473
+ * without the blocks the call did not include, and without the marker lines.
474
+ * It depends on the SET only, never on the order the caller listed them in, so
475
+ * one set is one document.
476
+ */
477
+ export function orderQuery(include = []) {
478
+ const asked = new Set(include);
479
+ const kept = [];
480
+ // One entry per marked part that is open: whether its lines are kept. A part
481
+ // inside a dropped part is dropped whatever it names.
482
+ const open = [];
483
+ for (const line of ORDER_QUERY_EVERY_BLOCK.split('\n')) {
484
+ const text = line.trim();
485
+ const outerKept = open.at(-1) ?? true;
486
+ if (text.startsWith(BLOCK_OPEN)) {
487
+ const names = text.slice(BLOCK_OPEN.length).split('|');
488
+ open.push(outerKept && names.some((name) => asked.has(name)));
489
+ }
490
+ else if (text === BLOCK_CLOSE) {
491
+ open.pop();
492
+ }
493
+ else if (outerKept) {
494
+ kept.push(line);
495
+ }
496
+ }
497
+ return kept.join('\n');
498
+ }
499
+ export function createOrderGetModule(transport) {
500
+ async function get(orderId, options) {
501
+ // Typed callers cannot get here wrong. A JavaScript caller can, and an
502
+ // unknown name would otherwise be dropped in silence: the read would
503
+ // answer an order without the block the caller believes it asked for.
504
+ const include = options?.include ?? [];
505
+ const known = (name) => ORDER_INCLUDES.includes(name);
506
+ if (!Array.isArray(include) || !include.every(known)) {
507
+ const given = Array.isArray(include)
508
+ ? include.filter((name) => !known(name)).map((name) => `"${String(name)}"`)
509
+ : [String(include)];
510
+ throw new ValidationError({
511
+ code: 'INVALID_ORDER_INCLUDE',
512
+ message: `\`include\` takes a list of an order's blocks, and ${given.join(', ')} is not one. The blocks are: ${ORDER_INCLUDES.join(', ')}.`,
513
+ status: 400,
514
+ service: 'vendure',
515
+ });
516
+ }
517
+ const redaction = redactionWatcher();
518
+ const data = await transport.graphql({
519
+ api: 'admin',
520
+ query: orderQuery(include),
521
+ variables: { id: orderId },
522
+ onExtensions: redaction.onExtensions,
523
+ }, options);
524
+ return redaction.mark(data.order);
525
+ }
526
+ // The answer holds exactly the blocks asked for; `OrderGetAnswer` decides how
527
+ // many of them the caller's type of the options may rely on. The overloads
528
+ // narrow this one implementation, which TypeScript cannot check for them.
529
+ return { get: get };
530
+ }