@sixtyninecommerce/admin 0.10.0 → 0.11.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 (247) hide show
  1. package/README.md +4347 -171
  2. package/dist/catalog/assets.d.ts +120 -8
  3. package/dist/catalog/assets.js +98 -12
  4. package/dist/catalog/collections.d.ts +279 -14
  5. package/dist/catalog/collections.js +246 -15
  6. package/dist/catalog/index.d.ts +9 -2
  7. package/dist/catalog/index.js +4 -0
  8. package/dist/catalog/products.d.ts +159 -19
  9. package/dist/catalog/products.js +88 -13
  10. package/dist/catalog/properties.d.ts +102 -14
  11. package/dist/catalog/properties.js +13 -0
  12. package/dist/catalog/recommendations.d.ts +261 -0
  13. package/dist/catalog/recommendations.js +145 -0
  14. package/dist/catalog/reviews.d.ts +368 -0
  15. package/dist/catalog/reviews.js +318 -0
  16. package/dist/catalog/types.d.ts +17 -1
  17. package/dist/catalog/types.js +10 -0
  18. package/dist/catalog/variant-find.d.ts +136 -0
  19. package/dist/catalog/variant-find.js +239 -0
  20. package/dist/catalog/variants.d.ts +233 -26
  21. package/dist/catalog/variants.js +125 -7
  22. package/dist/catalog/visibility.d.ts +20 -5
  23. package/dist/catalog/visibility.js +19 -1
  24. package/dist/client.d.ts +95 -9
  25. package/dist/client.js +35 -7
  26. package/dist/content/assets.d.ts +286 -0
  27. package/dist/content/assets.js +181 -0
  28. package/dist/content/items.d.ts +269 -0
  29. package/dist/content/items.js +170 -0
  30. package/dist/content/types.d.ts +282 -0
  31. package/dist/content/types.js +100 -0
  32. package/dist/customers/age-verification.d.ts +66 -0
  33. package/dist/customers/age-verification.js +79 -0
  34. package/dist/customers/credit.d.ts +263 -0
  35. package/dist/customers/credit.js +244 -0
  36. package/dist/customers/delivery-preferences.d.ts +120 -0
  37. package/dist/customers/delivery-preferences.js +97 -0
  38. package/dist/customers/groups.d.ts +207 -0
  39. package/dist/customers/groups.js +438 -0
  40. package/dist/customers/index.d.ts +447 -37
  41. package/dist/customers/index.js +313 -40
  42. package/dist/customers/invitation-status.d.ts +57 -0
  43. package/dist/customers/invitation-status.js +21 -0
  44. package/dist/customers/notes.d.ts +67 -0
  45. package/dist/customers/notes.js +51 -0
  46. package/dist/customers/notification-recipients.d.ts +97 -0
  47. package/dist/customers/notification-recipients.js +84 -0
  48. package/dist/customers/saved-lists.d.ts +42 -0
  49. package/dist/customers/saved-lists.js +61 -0
  50. package/dist/customers/vat.d.ts +83 -0
  51. package/dist/customers/vat.js +46 -0
  52. package/dist/customers/wire.d.ts +20 -0
  53. package/dist/customers/wire.js +35 -0
  54. package/dist/documents/ar.d.ts +307 -0
  55. package/dist/documents/ar.js +254 -0
  56. package/dist/documents/index.d.ts +731 -21
  57. package/dist/documents/index.js +436 -24
  58. package/dist/documents/pdf.d.ts +2 -0
  59. package/dist/documents/pdf.js +11 -0
  60. package/dist/fulfillments/create.d.ts +167 -0
  61. package/dist/fulfillments/create.js +216 -0
  62. package/dist/fulfillments/index.d.ts +44 -10
  63. package/dist/fulfillments/index.js +11 -2
  64. package/dist/fulfillments/payment-policy.d.ts +64 -0
  65. package/dist/fulfillments/payment-policy.js +140 -0
  66. package/dist/fulfillments/warehouse.d.ts +724 -0
  67. package/dist/fulfillments/warehouse.js +914 -0
  68. package/dist/geo/index.d.ts +119 -0
  69. package/dist/geo/index.js +107 -0
  70. package/dist/index.d.ts +123 -35
  71. package/dist/index.js +45 -12
  72. package/dist/integrations/afas-actions.d.ts +234 -0
  73. package/dist/integrations/afas-actions.js +310 -0
  74. package/dist/integrations/afas-types.d.ts +483 -0
  75. package/dist/integrations/afas-types.js +5 -0
  76. package/dist/integrations/afas.d.ts +234 -0
  77. package/dist/integrations/afas.js +290 -0
  78. package/dist/integrations/connections.d.ts +103 -0
  79. package/dist/integrations/connections.js +55 -0
  80. package/dist/integrations/esp.d.ts +313 -0
  81. package/dist/integrations/esp.js +169 -0
  82. package/dist/integrations/exact-online-types.d.ts +423 -0
  83. package/dist/integrations/exact-online-types.js +6 -0
  84. package/dist/integrations/exact-online.d.ts +248 -0
  85. package/dist/integrations/exact-online.js +376 -0
  86. package/dist/integrations/index.d.ts +29 -3
  87. package/dist/integrations/index.js +18 -3
  88. package/dist/integrations/pipeline-keys.d.ts +13 -0
  89. package/dist/integrations/pipeline-keys.js +22 -0
  90. package/dist/integrations/pipelines.d.ts +15 -14
  91. package/dist/integrations/pipelines.js +6 -22
  92. package/dist/integrations/types.d.ts +146 -0
  93. package/dist/locations/index.d.ts +66 -0
  94. package/dist/locations/index.js +31 -0
  95. package/dist/meta/index.d.ts +162 -0
  96. package/dist/orders/cancel-with-money.d.ts +227 -0
  97. package/dist/orders/cancel-with-money.js +153 -0
  98. package/dist/orders/commit-edit.d.ts +7 -1
  99. package/dist/orders/commit-edit.js +5 -1
  100. package/dist/orders/drafts.d.ts +800 -0
  101. package/dist/orders/drafts.js +771 -0
  102. package/dist/orders/fields.d.ts +245 -0
  103. package/dist/orders/fields.js +188 -0
  104. package/dist/orders/get.d.ts +29 -19
  105. package/dist/orders/get.js +17 -8
  106. package/dist/orders/index.d.ts +49 -9
  107. package/dist/orders/index.js +22 -2
  108. package/dist/orders/lifecycle.d.ts +128 -0
  109. package/dist/orders/lifecycle.js +158 -0
  110. package/dist/orders/line-price-preview.d.ts +7 -2
  111. package/dist/orders/list.d.ts +222 -0
  112. package/dist/orders/list.js +377 -0
  113. package/dist/orders/manual-pricing.d.ts +5 -0
  114. package/dist/orders/order-entry.d.ts +20 -7
  115. package/dist/orders/plan-edit.d.ts +1 -1
  116. package/dist/orders/plan-edit.js +4 -1
  117. package/dist/orders/settings.d.ts +201 -0
  118. package/dist/orders/settings.js +325 -0
  119. package/dist/orders/status.d.ts +159 -13
  120. package/dist/orders/status.js +21 -0
  121. package/dist/orders/surcharges.d.ts +8 -1
  122. package/dist/orders/surcharges.js +3 -2
  123. package/dist/payments/account-credit.d.ts +30 -0
  124. package/dist/payments/account-credit.js +19 -0
  125. package/dist/payments/ar.d.ts +292 -0
  126. package/dist/payments/ar.js +223 -0
  127. package/dist/payments/connected-account.d.ts +47 -0
  128. package/dist/payments/connected-account.js +61 -0
  129. package/dist/payments/credit-noted-fields.d.ts +12 -0
  130. package/dist/payments/credit-noted-fields.js +37 -0
  131. package/dist/payments/index.d.ts +257 -11
  132. package/dist/payments/index.js +131 -1
  133. package/dist/payments/methods.d.ts +303 -8
  134. package/dist/payments/methods.js +337 -7
  135. package/dist/payments/mollie-methods.d.ts +159 -0
  136. package/dist/payments/mollie-methods.js +141 -0
  137. package/dist/payments/payment-links.d.ts +180 -0
  138. package/dist/payments/payment-links.js +97 -0
  139. package/dist/payments/provider-keys.d.ts +150 -0
  140. package/dist/payments/provider-keys.js +118 -0
  141. package/dist/payments/providers.d.ts +86 -11
  142. package/dist/payments/providers.js +29 -0
  143. package/dist/payments/requests.d.ts +144 -0
  144. package/dist/payments/requests.js +92 -0
  145. package/dist/payments/store-credit-fields.d.ts +15 -0
  146. package/dist/payments/store-credit-fields.js +51 -0
  147. package/dist/pickups/index.d.ts +104 -0
  148. package/dist/pickups/index.js +105 -0
  149. package/dist/platform/channels.d.ts +132 -0
  150. package/dist/platform/channels.js +128 -0
  151. package/dist/platform/geo.d.ts +123 -0
  152. package/dist/platform/geo.js +144 -0
  153. package/dist/platform/tax.d.ts +154 -0
  154. package/dist/platform/tax.js +139 -0
  155. package/dist/pos/anomalies.d.ts +158 -0
  156. package/dist/pos/anomalies.js +64 -0
  157. package/dist/pos/assisted-selling.d.ts +79 -0
  158. package/dist/pos/assisted-selling.js +38 -0
  159. package/dist/pos/exchanges.d.ts +103 -0
  160. package/dist/pos/exchanges.js +22 -0
  161. package/dist/pos/gift-cards.d.ts +135 -0
  162. package/dist/pos/gift-cards.js +47 -0
  163. package/dist/pos/index.d.ts +2125 -32
  164. package/dist/pos/index.js +742 -4
  165. package/dist/pos/no-receipt.d.ts +94 -0
  166. package/dist/pos/no-receipt.js +25 -0
  167. package/dist/pos/offline-sales.d.ts +187 -0
  168. package/dist/pos/offline-sales.js +116 -0
  169. package/dist/pos/pay-by-link.d.ts +143 -0
  170. package/dist/pos/pay-by-link.js +57 -0
  171. package/dist/pos/quick-keys.d.ts +103 -0
  172. package/dist/pos/quick-keys.js +45 -0
  173. package/dist/pos/reports.d.ts +360 -0
  174. package/dist/pos/reports.js +62 -0
  175. package/dist/pos/returns.d.ts +217 -0
  176. package/dist/pos/returns.js +53 -0
  177. package/dist/pricing/bulk-coupons.d.ts +139 -0
  178. package/dist/pricing/bulk-coupons.js +112 -0
  179. package/dist/pricing/index.d.ts +174 -4
  180. package/dist/pricing/index.js +174 -1
  181. package/dist/pricing/price-lists.d.ts +604 -0
  182. package/dist/pricing/price-lists.js +600 -0
  183. package/dist/purchasing/alerts.d.ts +89 -0
  184. package/dist/purchasing/alerts.js +62 -0
  185. package/dist/purchasing/cost.d.ts +110 -0
  186. package/dist/purchasing/cost.js +86 -0
  187. package/dist/purchasing/index.d.ts +36 -0
  188. package/dist/purchasing/index.js +16 -0
  189. package/dist/purchasing/purchase-orders.d.ts +548 -0
  190. package/dist/purchasing/purchase-orders.js +491 -0
  191. package/dist/purchasing/replenishment.d.ts +281 -0
  192. package/dist/purchasing/replenishment.js +240 -0
  193. package/dist/purchasing/settings.d.ts +152 -0
  194. package/dist/purchasing/settings.js +181 -0
  195. package/dist/purchasing/suppliers.d.ts +476 -0
  196. package/dist/purchasing/suppliers.js +438 -0
  197. package/dist/quotes/index.d.ts +501 -0
  198. package/dist/quotes/index.js +439 -0
  199. package/dist/reports/index.d.ts +71 -8
  200. package/dist/reports/index.js +74 -11
  201. package/dist/returns/index.d.ts +614 -21
  202. package/dist/returns/index.js +695 -11
  203. package/dist/search/index.d.ts +76 -1
  204. package/dist/search/index.js +63 -0
  205. package/dist/shipping/definitions.d.ts +29 -0
  206. package/dist/shipping/definitions.js +47 -0
  207. package/dist/shipping/fulfillment-profiles.d.ts +174 -0
  208. package/dist/shipping/fulfillment-profiles.js +104 -0
  209. package/dist/shipping/hendriks.d.ts +97 -0
  210. package/dist/shipping/hendriks.js +50 -0
  211. package/dist/shipping/index.d.ts +48 -0
  212. package/dist/shipping/index.js +25 -0
  213. package/dist/shipping/methods.d.ts +198 -0
  214. package/dist/shipping/methods.js +240 -0
  215. package/dist/shipping/myparcel.d.ts +254 -0
  216. package/dist/shipping/myparcel.js +178 -0
  217. package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
  218. package/dist/shipping/parcel-rule.d.ts +6 -5
  219. package/dist/shipping/parcel-rule.js +21 -23
  220. package/dist/shipping/rate-tables.d.ts +179 -0
  221. package/dist/shipping/rate-tables.js +184 -0
  222. package/dist/stock/index.d.ts +10 -3
  223. package/dist/stock/index.js +3 -0
  224. package/dist/stock/locations.d.ts +144 -0
  225. package/dist/stock/locations.js +168 -0
  226. package/dist/stock/transfers.d.ts +216 -43
  227. package/dist/stock/transfers.js +140 -13
  228. package/dist/stored-value/index.d.ts +214 -4
  229. package/dist/stored-value/index.js +152 -0
  230. package/dist/subscriptions/index.d.ts +682 -0
  231. package/dist/subscriptions/index.js +815 -0
  232. package/dist/tax/index.d.ts +76 -1
  233. package/dist/tax/index.js +50 -0
  234. package/dist/tenant/email-style.d.ts +102 -0
  235. package/dist/tenant/email-style.js +72 -0
  236. package/dist/tenant/email-templates.d.ts +66 -0
  237. package/dist/tenant/email-templates.js +54 -0
  238. package/dist/tenant/notifications.d.ts +23 -17
  239. package/dist/tenant/settings-sources.d.ts +1 -1
  240. package/dist/tenant/time-zone.d.ts +17 -0
  241. package/dist/tenant/time-zone.js +11 -0
  242. package/dist/types.d.ts +50 -3
  243. package/dist/users/index.d.ts +3 -0
  244. package/dist/users/index.js +2 -0
  245. package/dist/users/warehouses.d.ts +50 -0
  246. package/dist/users/warehouses.js +51 -0
  247. package/package.json +2 -2
@@ -29,14 +29,74 @@ const TRANSFER_FIELDS = /* GraphQL */ `
29
29
  }
30
30
  createdAt
31
31
  updatedAt
32
+ initiatedBy { id firstName lastName }
32
33
  items {
33
34
  id
34
- productVariant { id sku }
35
+ productVariant { id name sku }
35
36
  quantity
36
37
  receivedQuantity
37
38
  lostQuantity
38
39
  outstandingQuantity
39
40
  }
41
+ totalLines
42
+ totalQuantity
43
+ totalReceivedQuantity
44
+ totalLostQuantity
45
+ `;
46
+ /**
47
+ * What `get` and every write answer. Every field is one the transfer module has always served
48
+ * (the dashboard's own transfer pages read them all), so no engine refuses it.
49
+ */
50
+ const TRANSFER_DETAIL_FIELDS = /* GraphQL */ `
51
+ id
52
+ code
53
+ kind
54
+ state
55
+ sourceLocation { id name }
56
+ destinationLocation { id name customFields { address } }
57
+ label
58
+ note
59
+ carrier
60
+ trackingCode
61
+ estimatedArrivalAt
62
+ shippedAt
63
+ receivedAt
64
+ cancelledAt
65
+ cancelReason
66
+ deliveryAddress {
67
+ contactName
68
+ company
69
+ streetLine1
70
+ streetLine2
71
+ city
72
+ province
73
+ postalCode
74
+ countryCode
75
+ phoneNumber
76
+ }
77
+ createdAt
78
+ updatedAt
79
+ initiatedBy { id firstName lastName }
80
+ shippedBy { id firstName lastName }
81
+ receivedBy { id firstName lastName }
82
+ consumptionTotalValue
83
+ consumptionHasUnpricedLines
84
+ pdfStorageKey
85
+ fulfillmentHandlerCode
86
+ handlerArgs
87
+ myparcelShipmentId
88
+ myparcelBarcode
89
+ hendriksRemotePath
90
+ items {
91
+ id
92
+ productVariant { id name sku }
93
+ quantity
94
+ receivedQuantity
95
+ lostQuantity
96
+ outstandingQuantity
97
+ unitCost
98
+ }
99
+ totalLines
40
100
  totalQuantity
41
101
  totalReceivedQuantity
42
102
  totalLostQuantity
@@ -47,36 +107,36 @@ export const STOCK_TRANSFERS_QUERY = /* GraphQL */ `
47
107
  }
48
108
  `;
49
109
  export const STOCK_TRANSFER_QUERY = /* GraphQL */ `
50
- query StockTransfer($id: ID!) { stockTransfer(id: $id) { ${TRANSFER_FIELDS} } }
110
+ query StockTransfer($id: ID!) { stockTransfer(id: $id) { ${TRANSFER_DETAIL_FIELDS} } }
51
111
  `;
52
112
  export const CREATE_STOCK_TRANSFER_MUTATION = /* GraphQL */ `
53
113
  mutation CreateStockTransfer($input: CreateStockTransferInput!) {
54
- createStockTransfer(input: $input) { ${TRANSFER_FIELDS} }
114
+ createStockTransfer(input: $input) { ${TRANSFER_DETAIL_FIELDS} }
55
115
  }
56
116
  `;
57
117
  export const UPDATE_STOCK_TRANSFER_MUTATION = /* GraphQL */ `
58
118
  mutation UpdateStockTransfer($id: ID!, $input: UpdateStockTransferInput!) {
59
- updateStockTransfer(id: $id, input: $input) { ${TRANSFER_FIELDS} }
119
+ updateStockTransfer(id: $id, input: $input) { ${TRANSFER_DETAIL_FIELDS} }
60
120
  }
61
121
  `;
62
122
  export const SHIP_STOCK_TRANSFER_MUTATION = /* GraphQL */ `
63
123
  mutation ShipStockTransfer($id: ID!, $input: ShipStockTransferInput) {
64
- shipStockTransfer(id: $id, input: $input) { ${TRANSFER_FIELDS} }
124
+ shipStockTransfer(id: $id, input: $input) { ${TRANSFER_DETAIL_FIELDS} }
65
125
  }
66
126
  `;
67
127
  export const POST_STOCK_TRANSFER_CONSUMPTION_MUTATION = /* GraphQL */ `
68
128
  mutation PostStockTransferConsumption($id: ID!) {
69
- postStockTransferConsumption(id: $id) { ${TRANSFER_FIELDS} }
129
+ postStockTransferConsumption(id: $id) { ${TRANSFER_DETAIL_FIELDS} }
70
130
  }
71
131
  `;
72
132
  export const RECEIVE_STOCK_TRANSFER_LINES_MUTATION = /* GraphQL */ `
73
133
  mutation ReceiveStockTransferLines($id: ID!, $lines: [ReceiveStockTransferLineInput!]!) {
74
- receiveStockTransferLines(id: $id, lines: $lines) { ${TRANSFER_FIELDS} }
134
+ receiveStockTransferLines(id: $id, lines: $lines) { ${TRANSFER_DETAIL_FIELDS} }
75
135
  }
76
136
  `;
77
137
  export const CLOSE_STOCK_TRANSFER_MUTATION = /* GraphQL */ `
78
138
  mutation CloseStockTransfer($id: ID!, $acceptShortfallAsLost: Boolean) {
79
- closeStockTransfer(id: $id, acceptShortfallAsLost: $acceptShortfallAsLost) { ${TRANSFER_FIELDS} }
139
+ closeStockTransfer(id: $id, acceptShortfallAsLost: $acceptShortfallAsLost) { ${TRANSFER_DETAIL_FIELDS} }
80
140
  }
81
141
  `;
82
142
  /**
@@ -94,17 +154,17 @@ export const CLOSE_STOCK_TRANSFER_WITH_SHORTFALL_MUTATION = /* GraphQL */ `
94
154
  id: $id
95
155
  acceptShortfallAsLost: $acceptShortfallAsLost
96
156
  shortfall: $shortfall
97
- ) { ${TRANSFER_FIELDS} }
157
+ ) { ${TRANSFER_DETAIL_FIELDS} }
98
158
  }
99
159
  `;
100
160
  export const CANCEL_STOCK_TRANSFER_MUTATION = /* GraphQL */ `
101
161
  mutation CancelStockTransfer($id: ID!, $reason: String) {
102
- cancelStockTransfer(id: $id, reason: $reason) { ${TRANSFER_FIELDS} }
162
+ cancelStockTransfer(id: $id, reason: $reason) { ${TRANSFER_DETAIL_FIELDS} }
103
163
  }
104
164
  `;
105
165
  export const CREATE_STOCK_TRANSFER_RETURN_MUTATION = /* GraphQL */ `
106
166
  mutation CreateStockTransferReturn($id: ID!, $input: CreateStockTransferReturnInput!) {
107
- createStockTransferReturn(id: $id, input: $input) { ${TRANSFER_FIELDS} }
167
+ createStockTransferReturn(id: $id, input: $input) { ${TRANSFER_DETAIL_FIELDS} }
108
168
  }
109
169
  `;
110
170
  /**
@@ -295,7 +355,71 @@ function toTransfer(raw) {
295
355
  ...line,
296
356
  variantId: productVariant.id,
297
357
  sku: productVariant.sku,
358
+ variantName: productVariant.name,
359
+ })),
360
+ };
361
+ }
362
+ const ADDRESS_KEYS = [
363
+ 'contactName',
364
+ 'company',
365
+ 'streetLine1',
366
+ 'streetLine2',
367
+ 'city',
368
+ 'province',
369
+ 'postalCode',
370
+ 'countryCode',
371
+ 'phoneNumber',
372
+ ];
373
+ /**
374
+ * A location's `customFields.address`: JSON text earlier writers filled freely. Only its string
375
+ * fields are taken. Text that is not a JSON object, or one with no string field, reads as no
376
+ * address; the engine reads such a column the same way, and refuses to address a parcel to it.
377
+ */
378
+ function locationAddress(raw) {
379
+ if (!raw?.trim())
380
+ return null;
381
+ let parsed;
382
+ try {
383
+ parsed = JSON.parse(raw);
384
+ }
385
+ catch {
386
+ return null;
387
+ }
388
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
389
+ return null;
390
+ const source = parsed;
391
+ const address = {};
392
+ let any = false;
393
+ for (const key of ADDRESS_KEYS) {
394
+ const value = source[key];
395
+ address[key] = typeof value === 'string' ? value : null;
396
+ any ||= typeof value === 'string' && value.trim() !== '';
397
+ }
398
+ return any ? address : null;
399
+ }
400
+ function toHandlerArgs(raw) {
401
+ if (Array.isArray(raw))
402
+ return raw;
403
+ if (raw && typeof raw === 'object')
404
+ return raw;
405
+ return null;
406
+ }
407
+ function toDetail(raw) {
408
+ const { destinationLocation, items, handlerArgs, ...rest } = raw;
409
+ return {
410
+ ...rest,
411
+ destinationLocation: destinationLocation && {
412
+ id: destinationLocation.id,
413
+ name: destinationLocation.name,
414
+ address: locationAddress(destinationLocation.customFields?.address),
415
+ },
416
+ items: items.map(({ productVariant, ...line }) => ({
417
+ ...line,
418
+ variantId: productVariant.id,
419
+ sku: productVariant.sku,
420
+ variantName: productVariant.name,
298
421
  })),
422
+ handlerArgs: toHandlerArgs(handlerArgs),
299
423
  };
300
424
  }
301
425
  function toReturns(raw) {
@@ -316,7 +440,7 @@ const DEFAULT_PAGE_SIZE = 25;
316
440
  export function createStockTransfersModule(transport) {
317
441
  const one = async (field, query, variables, options) => {
318
442
  const data = await transport.graphql({ api: 'admin', query, variables }, options);
319
- return toTransfer(data[field]);
443
+ return toDetail(data[field]);
320
444
  };
321
445
  const listPage = async (skip, take, filter) => {
322
446
  const data = await transport.graphql({
@@ -333,6 +457,9 @@ export function createStockTransfersModule(transport) {
333
457
  dateFrom: filter?.dateFrom,
334
458
  dateTo: filter?.dateTo,
335
459
  search: filter?.search,
460
+ // Only when set, as the return filters below: a caller that never names a mode
461
+ // keeps sending the document every engine since the transfer module accepts.
462
+ ...(filter?.searchMode === undefined ? {} : { searchMode: filter.searchMode }),
336
463
  // Only when set: an engine without returns refuses an unknown
337
464
  // input field, which would fail every list against it.
338
465
  ...(filter?.returnOfTransferId === undefined
@@ -355,7 +482,7 @@ export function createStockTransfersModule(transport) {
355
482
  },
356
483
  async get(id, options) {
357
484
  const data = await transport.graphql({ api: 'admin', query: STOCK_TRANSFER_QUERY, variables: { id } }, options);
358
- return data.stockTransfer === null ? null : toTransfer(data.stockTransfer);
485
+ return data.stockTransfer === null ? null : toDetail(data.stockTransfer);
359
486
  },
360
487
  create(input, options) {
361
488
  const { lines, ...rest } = input;
@@ -20,7 +20,11 @@ export interface StoredValueAccount {
20
20
  expiresAt: string | null;
21
21
  /** The last day (`YYYY-MM-DD`, store zone) the value is valid through; refund lots never expire. */
22
22
  expiresOn: string | null;
23
- status: 'active' | 'blocked';
23
+ /**
24
+ * `voided`: a gift card a void blocked for good (`giftCards.void`); it is never blocked or
25
+ * unblocked again. Treat any other value this version does not know as not spendable.
26
+ */
27
+ status: 'active' | 'blocked' | 'voided';
24
28
  balance: number;
25
29
  /** What can be spent now: the balance less expired value the daily job has not booked yet. */
26
30
  spendable: number;
@@ -75,6 +79,37 @@ export interface IssueStoredValueInput {
75
79
  reason: string;
76
80
  /** Sets the account's expiry: valid through this day (`YYYY-MM-DD`) in the store's time zone. */
77
81
  expiresOn?: string;
82
+ /**
83
+ * Goodwill FOR this order of the store: linked on the statement; it moves none of the order's
84
+ * money. Another store's order is not found; an account takes goodwill only for its owner's
85
+ * order (`STORED_VALUE_OWNER_MISMATCH`). Needs an engine that knows the field (incentives
86
+ * sprint 8): an older one refuses the whole call.
87
+ */
88
+ orderId?: string;
89
+ }
90
+ /**
91
+ * Whether the store may put an order's money in its customers' store-credit wallets instead of
92
+ * refunding it (incentives sprint 8).
93
+ */
94
+ export interface StoreCreditSettings {
95
+ /** The store's switch. Off until the store turns it on. */
96
+ refundToCredit: boolean;
97
+ /**
98
+ * Where the store keeps what it owes its customers now: `AR` (its own accounts receivable, which
99
+ * then holds every customer credit), `STORE_CREDIT` (a wallet each: the Stored Value grant, the
100
+ * switch on, a stored-value method enabled) or `NONE` (neither). Treat any other value as no
101
+ * store credit.
102
+ */
103
+ book: 'AR' | 'STORE_CREDIT' | 'NONE' | (string & {});
104
+ /** Usable now: the book is `STORE_CREDIT`. */
105
+ available: boolean;
106
+ /**
107
+ * Why the book is not `STORE_CREDIT` (null exactly when it is):
108
+ * `STORE_CREDIT_STORE_KEEPS_ACCOUNTS`, `STORE_CREDIT_NOT_GRANTED`, `STORE_CREDIT_NOT_ENABLED` or
109
+ * `STORE_CREDIT_METHOD_REQUIRED`.
110
+ */
111
+ code: string | null;
112
+ message: string | null;
78
113
  }
79
114
  export interface RedeemStoredValueInput {
80
115
  orderId: string;
@@ -108,9 +143,17 @@ export interface StoredValueModule {
108
143
  kind?: string;
109
144
  locationId?: string;
110
145
  }, options?: Call): Promise<StoredValueLiability[]>;
111
- /** Requires ManageStoredValue. Send an `idempotencyKey`: a repeat returns the first result. */
146
+ /**
147
+ * Requires ManageStoredValue. Send an `idempotencyKey`: a repeat returns the first result. A
148
+ * gift card sold on an order is never credited (`STORED_VALUE_GIFT_CARD_CREDIT_NOT_ALLOWED`),
149
+ * nor is a voided one (`STORED_VALUE_GIFT_CARD_VOIDED`).
150
+ */
112
151
  issue(input: IssueStoredValueInput, options?: Call): Promise<StoredValueAccount>;
113
- /** Requires ManageStoredValue. Signed; a debit may not take the balance below zero. */
152
+ /**
153
+ * Requires ManageStoredValue. Signed; a debit may not take the balance below zero. A voided gift
154
+ * card takes no credit and no `expiresOn` (`STORED_VALUE_GIFT_CARD_VOIDED`); a plain debit of it
155
+ * is allowed.
156
+ */
114
157
  adjust(input: {
115
158
  accountId: string;
116
159
  amount: number;
@@ -120,10 +163,13 @@ export interface StoredValueModule {
120
163
  /**
121
164
  * Requires ManageStoredValue. The account's value is valid through `expiresOn` (`YYYY-MM-DD`,
122
165
  * store zone); `null` clears it. A day already over is refused (`STORED_VALUE_EXPIRY_INVALID`);
123
- * value the job already booked as expired stays booked.
166
+ * value the job already booked as expired stays booked. A voided gift card's expiry never changes
167
+ * (`STORED_VALUE_GIFT_CARD_VOIDED`).
124
168
  */
125
169
  setExpiry(id: string, expiresOn: string | null, reason: string, options?: Call): Promise<StoredValueAccount>;
170
+ /** A voided gift card is refused (`STORED_VALUE_GIFT_CARD_VOIDED`): it is blocked for good. */
126
171
  block(id: string, reason: string, options?: Call): Promise<StoredValueAccount>;
172
+ /** A voided gift card is refused (`STORED_VALUE_GIFT_CARD_VOIDED`): it is blocked for good. */
127
173
  unblock(id: string, reason: string, options?: Call): Promise<StoredValueAccount>;
128
174
  /**
129
175
  * Pay part (or all) of an order from an account (`redeemStoredValue`), through the platform's
@@ -132,6 +178,159 @@ export interface StoredValueModule {
132
178
  * payment the SERVER recorded for this call; a repeat under the same key answers the same one.
133
179
  */
134
180
  redeem(input: RedeemStoredValueInput, options?: Call): Promise<StoredValueRedemption>;
181
+ /**
182
+ * Requires ReadStoredValue. The store's refund-to-credit switch and whether it is usable now.
183
+ * Needs an engine that serves `storeCreditSettings` (incentives sprint 8).
184
+ */
185
+ storeCreditSettings(options?: Call): Promise<StoreCreditSettings>;
186
+ /**
187
+ * Requires ManageStoredValue. Switch refund to store credit on or off: whether "credit the
188
+ * customer" may put an order's money in the customer's store-credit wallet instead of refunding
189
+ * it. Turning it on is refused `STORE_CREDIT_STORE_KEEPS_ACCOUNTS` (the store keeps its
190
+ * customers' balances on their accounts), `STORE_CREDIT_NOT_GRANTED` (no Stored Value grant)
191
+ * and `STORE_CREDIT_METHOD_REQUIRED` (no enabled stored-value payment method); turning it off
192
+ * always works. A setting written whole: no key.
193
+ */
194
+ updateStoreCreditSettings(input: {
195
+ refundToCredit: boolean;
196
+ }, options?: Call): Promise<StoreCreditSettings>;
197
+ /** Gift cards: sold on orders, one per paid unit, or issued by staff; each its own account. */
198
+ giftCards: GiftCardModule;
199
+ }
200
+ /**
201
+ * A gift card. Its code is never readable: the card is found by id, by order, or by the code
202
+ * itself (`byCode`, which answers it masked).
203
+ */
204
+ export interface GiftCard {
205
+ /** The card's account id. */
206
+ id: string;
207
+ createdAt: string;
208
+ account: StoredValueAccount;
209
+ /**
210
+ * `sale`: sold on an order, one card per paid unit. `staff`: issued by staff with no sale
211
+ * (`giftCards.issue`), on no order.
212
+ */
213
+ origin: 'sale' | 'staff';
214
+ orderId: string | null;
215
+ orderLineId: string | null;
216
+ /** The 0-based unit of the order line this card was issued for. */
217
+ unitIndex: number | null;
218
+ productVariantId: string | null;
219
+ /** What the unit was paid, or what staff issued, minor units of the account's unit. */
220
+ faceValue: number;
221
+ /** The code's last four characters behind a mask. */
222
+ maskedCode: string;
223
+ /** A void blocked the card for good (its account `status` is `voided`); see `void`. */
224
+ voided: boolean;
225
+ }
226
+ /**
227
+ * A gift card and the code it was just given. `code` (`XXXX-XXXX-XXXX-XXXX`) is shown ONCE: it is
228
+ * null when the code went to the buyer by email, and on a repeat under the same `idempotencyKey`
229
+ * (the server keeps the card's id, never the code).
230
+ */
231
+ export interface IssuedGiftCard {
232
+ giftCard: GiftCard;
233
+ code: string | null;
234
+ }
235
+ /** A gift card staff issue with no sale (`giftCards.issue`). */
236
+ export interface IssueGiftCardInput {
237
+ /** Minor units, greater than zero. */
238
+ amount: number;
239
+ /** An ISO 4217 currency the store sells. */
240
+ currencyCode: string;
241
+ reason: string;
242
+ /** Valid through this day (`YYYY-MM-DD`) in the store's time zone; omitted or null: never expires. */
243
+ expiresOn?: string | null;
244
+ }
245
+ /** A variant this store sells as a gift card. */
246
+ export interface GiftCardVariant {
247
+ productVariantId: string;
248
+ /** A sold card is valid this many calendar months from its issue day; null: never expires. */
249
+ validityMonths: number | null;
250
+ createdAt: string;
251
+ }
252
+ export interface GiftCardModule {
253
+ /** Requires ReadStoredValue. Newest first; `orderId` lists the cards an order sold. */
254
+ list(filter?: {
255
+ orderId?: string;
256
+ origin?: 'sale' | 'staff';
257
+ take?: number;
258
+ skip?: number;
259
+ }, options?: Call): Promise<{
260
+ items: GiftCard[];
261
+ totalItems: number;
262
+ }>;
263
+ get(id: string, options?: Call): Promise<GiftCard | null>;
264
+ /**
265
+ * Requires ReadStoredValue. This store's card for a code, masked, or null: an unknown,
266
+ * malformed or other store's code answers the same null. Sent as a POST (a code never goes in a
267
+ * URL), one lookup per request, and budgeted per token: past the budget it is refused
268
+ * `RATE_LIMITED` with a wait.
269
+ */
270
+ byCode(code: string, options?: Call): Promise<GiftCard | null>;
271
+ /** Requires ReadStoredValue. Which of these variants the store sells as gift cards. */
272
+ variants(productVariantIds: string[], options?: Call): Promise<GiftCardVariant[]>;
273
+ /**
274
+ * Requires ReadStoredValue. How many of this store's orders would issue a gift card of the
275
+ * variant once paid in full, and so issue none once it is switched off: what the "stop selling"
276
+ * confirmation names. The engine's issuing rule: an order of this store alone, not cancelled and
277
+ * not imported, with a unit of the variant priced above zero that has no card yet, and not paid
278
+ * in full (no settled payment yet, or its settled money below what it bills). Carts, drafts and
279
+ * placed orders not yet paid in full count alike. `null` when the store does not sell the
280
+ * variant as a gift card. Read now, without a lock.
281
+ *
282
+ * Its own document rather than a field of {@link variants}, so the tab's read pays for no count
283
+ * and a release of this SDK reading an older engine fails only this call. Needs an engine that
284
+ * serves `GiftCardVariant.unpaidOrders`.
285
+ */
286
+ variantUnpaidOrders(productVariantId: string, options?: Call): Promise<number | null>;
287
+ /**
288
+ * Requires ManageStoredValue. Sell a variant as a gift card (or stop: `enabled: false` answers
289
+ * null). Turning it on is refused once the variant has sold as an ordinary product.
290
+ * `validityMonths` omitted keeps the validity already set; `null` means no expiry.
291
+ */
292
+ setVariant(productVariantId: string, enabled: boolean, validityMonths?: number | null, options?: Call): Promise<GiftCardVariant | null>;
293
+ /**
294
+ * Requires ManageStoredValue, or no Stored Value grant at all for a card the store sold. The
295
+ * step before refunding a gift card's sale: blocks the card for good (status `voided`) and
296
+ * withdraws what it can still spend, which releases that much of its order's money for a refund (never what the card spent,
297
+ * never value past its expiry). A second void takes only what became spendable since (a refund
298
+ * credited back to the card). Send an `idempotencyKey`: a
299
+ * repeat answers the card as it is then and voids nothing again. A card of another store is not
300
+ * found; a voided card is never unblocked (`STORED_VALUE_GIFT_CARD_VOIDED`).
301
+ */
302
+ void(id: string, reason: string, options?: Call): Promise<GiftCard>;
303
+ /**
304
+ * Requires ManageStoredValue (an app installation is refused). A new code for a live gift card:
305
+ * the old code stops working at once; the balance, expiry, statement and status stay. The code
306
+ * goes to ONE place:
307
+ * - `notify: true` emails it to the buyer of a card sold on an order, and `code` is null. A card
308
+ * no email can reach (issued with no sale, no email delivery, a buyer whose address cannot
309
+ * receive it) is refused `STORED_VALUE_GIFT_CARD_NOT_MAILABLE`, nothing changed;
310
+ * - `notify: false` answers it in `code`, once, for staff to hand over.
311
+ *
312
+ * Send an `idempotencyKey`: a repeat answers the card with `code: null` and changes nothing
313
+ * again. The first answer is the only copy of a code it shows: a lost one is replaced by another
314
+ * reissue under a NEW key. A voided card is refused (`STORED_VALUE_GIFT_CARD_VOIDED`); a card of
315
+ * another store is not found.
316
+ */
317
+ reissueCode(id: string, input: {
318
+ reason: string;
319
+ notify: boolean;
320
+ }, options?: Call): Promise<IssuedGiftCard>;
321
+ /**
322
+ * Requires ManageStoredValue (an app installation is refused). A bearer gift card with no sale
323
+ * (goodwill): value created without payment, booked as liability with `origin: 'staff'`. No email
324
+ * is sent: `code` is in the answer ONCE, for staff to hand over.
325
+ *
326
+ * Send an `idempotencyKey`: a repeat answers the card with `code: null` and issues nothing again.
327
+ * The first answer is the only copy of the code: a lost one is replaced by `reissueCode` on the
328
+ * card (`notify: false`). Refusals: `STORED_VALUE_ROOT_CHANNEL_NOT_ALLOWED`,
329
+ * `STORED_VALUE_REASON_REQUIRED`, `STORED_VALUE_AMOUNT_INVALID`, `STORED_VALUE_UNIT_INVALID` (a
330
+ * currency the store does not sell), `STORED_VALUE_GIFT_CARD_NOT_CONFIGURED`,
331
+ * `STORED_VALUE_EXPIRY_INVALID` (not a day, or a day already over), `STORED_VALUE_POSTING_CONFLICT`.
332
+ */
333
+ issue(input: IssueGiftCardInput, options?: Call): Promise<IssuedGiftCard>;
135
334
  }
136
335
  /** What a redemption recorded: the order, the payment this call created, the account and amount. */
137
336
  export interface StoredValueRedemption {
@@ -151,4 +350,15 @@ export declare const BLOCK_STORED_VALUE_MUTATION = "\n mutation BlockStoredValu
151
350
  export declare const UNBLOCK_STORED_VALUE_MUTATION = "\n mutation UnblockStoredValueAccount($id: ID!, $reason: String!) {\n unblockStoredValueAccount(id: $id, reason: $reason) { \n id\n createdAt\n updatedAt\n kind\n unit\n customerId\n codeLast4\n expiresAt\n expiresOn\n status\n balance\n spendable\n }\n }\n";
152
351
  export declare const SET_STORED_VALUE_EXPIRY_MUTATION = "\n mutation SetStoredValueAccountExpiry(\n $id: ID!\n $expiresOn: String\n $reason: String!\n $idempotencyKey: String\n ) {\n setStoredValueAccountExpiry(\n id: $id\n expiresOn: $expiresOn\n reason: $reason\n idempotencyKey: $idempotencyKey\n ) { \n id\n createdAt\n updatedAt\n kind\n unit\n customerId\n codeLast4\n expiresAt\n expiresOn\n status\n balance\n spendable\n }\n }\n";
153
352
  export declare const REDEEM_STORED_VALUE_MUTATION = "\n mutation RedeemStoredValue($input: RedeemStoredValueInput!, $idempotencyKey: String) {\n redeemStoredValue(input: $input, idempotencyKey: $idempotencyKey) {\n orderId\n paymentId\n accountId\n amount\n }\n }\n";
353
+ export declare const STORE_CREDIT_SETTINGS_QUERY = "\n query StoreCreditSettings {\n storeCreditSettings { \n refundToCredit\n book\n available\n code\n message\n }\n }\n";
354
+ export declare const UPDATE_STORE_CREDIT_SETTINGS_MUTATION = "\n mutation UpdateStoreCreditSettings($input: UpdateStoreCreditSettingsInput!) {\n updateStoreCreditSettings(input: $input) { \n refundToCredit\n book\n available\n code\n message\n }\n }\n";
355
+ export declare const GIFT_CARDS_QUERY = "\n query GiftCards($orderId: ID, $origin: String, $take: Int, $skip: Int) {\n giftCards(orderId: $orderId, origin: $origin, take: $take, skip: $skip) {\n items { \n id\n createdAt\n account { \n id\n createdAt\n updatedAt\n kind\n unit\n customerId\n codeLast4\n expiresAt\n expiresOn\n status\n balance\n spendable\n }\n origin\n orderId\n orderLineId\n unitIndex\n productVariantId\n faceValue\n maskedCode\n voided\n }\n totalItems\n }\n }\n";
356
+ export declare const GIFT_CARD_QUERY = "\n query GiftCard($id: ID!) {\n giftCard(id: $id) { \n id\n createdAt\n account { \n id\n createdAt\n updatedAt\n kind\n unit\n customerId\n codeLast4\n expiresAt\n expiresOn\n status\n balance\n spendable\n }\n origin\n orderId\n orderLineId\n unitIndex\n productVariantId\n faceValue\n maskedCode\n voided\n }\n }\n";
357
+ export declare const GIFT_CARD_BY_CODE_QUERY = "\n query GiftCardByCode($code: String!) {\n giftCardByCode(code: $code) { \n id\n createdAt\n account { \n id\n createdAt\n updatedAt\n kind\n unit\n customerId\n codeLast4\n expiresAt\n expiresOn\n status\n balance\n spendable\n }\n origin\n orderId\n orderLineId\n unitIndex\n productVariantId\n faceValue\n maskedCode\n voided\n }\n }\n";
358
+ export declare const GIFT_CARD_VARIANTS_QUERY = "\n query GiftCardVariants($productVariantIds: [ID!]!) {\n giftCardVariants(productVariantIds: $productVariantIds) {\n productVariantId\n validityMonths\n createdAt\n }\n }\n";
359
+ export declare const GIFT_CARD_VARIANT_UNPAID_ORDERS_QUERY = "\n query GiftCardVariantUnpaidOrders($productVariantIds: [ID!]!) {\n giftCardVariants(productVariantIds: $productVariantIds) {\n productVariantId\n unpaidOrders\n }\n }\n";
360
+ export declare const SET_GIFT_CARD_VARIANT_MUTATION = "\n mutation SetGiftCardVariant($productVariantId: ID!, $enabled: Boolean!, $validityMonths: Int) {\n setGiftCardVariant(\n productVariantId: $productVariantId\n enabled: $enabled\n validityMonths: $validityMonths\n ) {\n productVariantId\n validityMonths\n createdAt\n }\n }\n";
361
+ export declare const VOID_GIFT_CARD_MUTATION = "\n mutation VoidGiftCard($id: ID!, $reason: String!, $idempotencyKey: String) {\n voidGiftCard(id: $id, reason: $reason, idempotencyKey: $idempotencyKey) { \n id\n createdAt\n account { \n id\n createdAt\n updatedAt\n kind\n unit\n customerId\n codeLast4\n expiresAt\n expiresOn\n status\n balance\n spendable\n }\n origin\n orderId\n orderLineId\n unitIndex\n productVariantId\n faceValue\n maskedCode\n voided\n }\n }\n";
362
+ export declare const REISSUE_GIFT_CARD_CODE_MUTATION = "\n mutation ReissueGiftCardCode(\n $id: ID!\n $reason: String!\n $notify: Boolean!\n $idempotencyKey: String\n ) {\n reissueGiftCardCode(\n id: $id\n reason: $reason\n notify: $notify\n idempotencyKey: $idempotencyKey\n ) {\n giftCard { \n id\n createdAt\n account { \n id\n createdAt\n updatedAt\n kind\n unit\n customerId\n codeLast4\n expiresAt\n expiresOn\n status\n balance\n spendable\n }\n origin\n orderId\n orderLineId\n unitIndex\n productVariantId\n faceValue\n maskedCode\n voided\n }\n code\n }\n }\n";
363
+ export declare const ISSUE_GIFT_CARD_MUTATION = "\n mutation IssueGiftCard($input: IssueGiftCardInput!, $idempotencyKey: String) {\n issueGiftCard(input: $input, idempotencyKey: $idempotencyKey) {\n giftCard { \n id\n createdAt\n account { \n id\n createdAt\n updatedAt\n kind\n unit\n customerId\n codeLast4\n expiresAt\n expiresOn\n status\n balance\n spendable\n }\n origin\n orderId\n orderLineId\n unitIndex\n productVariantId\n faceValue\n maskedCode\n voided\n }\n code\n }\n }\n";
154
364
  export declare function createStoredValueModule(transport: Transport): StoredValueModule;
@@ -91,6 +91,115 @@ export const REDEEM_STORED_VALUE_MUTATION = /* GraphQL */ `
91
91
  }
92
92
  }
93
93
  `;
94
+ const STORE_CREDIT_SETTINGS_FIELDS = `
95
+ refundToCredit
96
+ book
97
+ available
98
+ code
99
+ message
100
+ `;
101
+ export const STORE_CREDIT_SETTINGS_QUERY = /* GraphQL */ `
102
+ query StoreCreditSettings {
103
+ storeCreditSettings { ${STORE_CREDIT_SETTINGS_FIELDS} }
104
+ }
105
+ `;
106
+ export const UPDATE_STORE_CREDIT_SETTINGS_MUTATION = /* GraphQL */ `
107
+ mutation UpdateStoreCreditSettings($input: UpdateStoreCreditSettingsInput!) {
108
+ updateStoreCreditSettings(input: $input) { ${STORE_CREDIT_SETTINGS_FIELDS} }
109
+ }
110
+ `;
111
+ const GIFT_CARD_FIELDS = `
112
+ id
113
+ createdAt
114
+ account { ${ACCOUNT_FIELDS} }
115
+ origin
116
+ orderId
117
+ orderLineId
118
+ unitIndex
119
+ productVariantId
120
+ faceValue
121
+ maskedCode
122
+ voided
123
+ `;
124
+ export const GIFT_CARDS_QUERY = /* GraphQL */ `
125
+ query GiftCards($orderId: ID, $origin: String, $take: Int, $skip: Int) {
126
+ giftCards(orderId: $orderId, origin: $origin, take: $take, skip: $skip) {
127
+ items { ${GIFT_CARD_FIELDS} }
128
+ totalItems
129
+ }
130
+ }
131
+ `;
132
+ export const GIFT_CARD_QUERY = /* GraphQL */ `
133
+ query GiftCard($id: ID!) {
134
+ giftCard(id: $id) { ${GIFT_CARD_FIELDS} }
135
+ }
136
+ `;
137
+ export const GIFT_CARD_BY_CODE_QUERY = /* GraphQL */ `
138
+ query GiftCardByCode($code: String!) {
139
+ giftCardByCode(code: $code) { ${GIFT_CARD_FIELDS} }
140
+ }
141
+ `;
142
+ export const GIFT_CARD_VARIANTS_QUERY = /* GraphQL */ `
143
+ query GiftCardVariants($productVariantIds: [ID!]!) {
144
+ giftCardVariants(productVariantIds: $productVariantIds) {
145
+ productVariantId
146
+ validityMonths
147
+ createdAt
148
+ }
149
+ }
150
+ `;
151
+ export const GIFT_CARD_VARIANT_UNPAID_ORDERS_QUERY = /* GraphQL */ `
152
+ query GiftCardVariantUnpaidOrders($productVariantIds: [ID!]!) {
153
+ giftCardVariants(productVariantIds: $productVariantIds) {
154
+ productVariantId
155
+ unpaidOrders
156
+ }
157
+ }
158
+ `;
159
+ export const SET_GIFT_CARD_VARIANT_MUTATION = /* GraphQL */ `
160
+ mutation SetGiftCardVariant($productVariantId: ID!, $enabled: Boolean!, $validityMonths: Int) {
161
+ setGiftCardVariant(
162
+ productVariantId: $productVariantId
163
+ enabled: $enabled
164
+ validityMonths: $validityMonths
165
+ ) {
166
+ productVariantId
167
+ validityMonths
168
+ createdAt
169
+ }
170
+ }
171
+ `;
172
+ export const VOID_GIFT_CARD_MUTATION = /* GraphQL */ `
173
+ mutation VoidGiftCard($id: ID!, $reason: String!, $idempotencyKey: String) {
174
+ voidGiftCard(id: $id, reason: $reason, idempotencyKey: $idempotencyKey) { ${GIFT_CARD_FIELDS} }
175
+ }
176
+ `;
177
+ export const REISSUE_GIFT_CARD_CODE_MUTATION = /* GraphQL */ `
178
+ mutation ReissueGiftCardCode(
179
+ $id: ID!
180
+ $reason: String!
181
+ $notify: Boolean!
182
+ $idempotencyKey: String
183
+ ) {
184
+ reissueGiftCardCode(
185
+ id: $id
186
+ reason: $reason
187
+ notify: $notify
188
+ idempotencyKey: $idempotencyKey
189
+ ) {
190
+ giftCard { ${GIFT_CARD_FIELDS} }
191
+ code
192
+ }
193
+ }
194
+ `;
195
+ export const ISSUE_GIFT_CARD_MUTATION = /* GraphQL */ `
196
+ mutation IssueGiftCard($input: IssueGiftCardInput!, $idempotencyKey: String) {
197
+ issueGiftCard(input: $input, idempotencyKey: $idempotencyKey) {
198
+ giftCard { ${GIFT_CARD_FIELDS} }
199
+ code
200
+ }
201
+ }
202
+ `;
94
203
  export function createStoredValueModule(transport) {
95
204
  const read = async (query, variables, options) => transport.graphql({ api: 'admin', query, variables }, options);
96
205
  // The key is an ARGUMENT on the Admin API; `undefined` keeps an omitted key off the wire.
@@ -126,5 +235,48 @@ export function createStoredValueModule(transport) {
126
235
  async redeem(input, options) {
127
236
  return (await write(REDEEM_STORED_VALUE_MUTATION, { input }, options)).redeemStoredValue;
128
237
  },
238
+ async storeCreditSettings(options) {
239
+ return (await read(STORE_CREDIT_SETTINGS_QUERY, {}, options)).storeCreditSettings;
240
+ },
241
+ async updateStoreCreditSettings(input, options) {
242
+ return (await read(UPDATE_STORE_CREDIT_SETTINGS_MUTATION, { input: { refundToCredit: input.refundToCredit } }, options)).updateStoreCreditSettings;
243
+ },
244
+ giftCards: {
245
+ async list(filter = {}, options) {
246
+ return (await read(GIFT_CARDS_QUERY, filter, options)).giftCards;
247
+ },
248
+ async get(id, options) {
249
+ return (await read(GIFT_CARD_QUERY, { id }, options))
250
+ .giftCard;
251
+ },
252
+ // A GraphQL call is always a POST body: the code never reaches a URL (the engine refuses a
253
+ // GET lookup, `STORED_VALUE_GIFT_CARD_LOOKUP_POST_ONLY`).
254
+ async byCode(code, options) {
255
+ return (await read(GIFT_CARD_BY_CODE_QUERY, { code }, options)).giftCardByCode;
256
+ },
257
+ async variants(productVariantIds, options) {
258
+ return (await read(GIFT_CARD_VARIANTS_QUERY, { productVariantIds }, options)).giftCardVariants;
259
+ },
260
+ async variantUnpaidOrders(productVariantId, options) {
261
+ const [variant] = (await read(GIFT_CARD_VARIANT_UNPAID_ORDERS_QUERY, { productVariantIds: [productVariantId] }, options)).giftCardVariants;
262
+ return variant ? variant.unpaidOrders : null;
263
+ },
264
+ async setVariant(productVariantId, enabled, validityMonths, options) {
265
+ return (await read(SET_GIFT_CARD_VARIANT_MUTATION, {
266
+ productVariantId,
267
+ enabled,
268
+ ...(validityMonths === undefined ? {} : { validityMonths }),
269
+ }, options)).setGiftCardVariant;
270
+ },
271
+ async void(id, reason, options) {
272
+ return (await write(VOID_GIFT_CARD_MUTATION, { id, reason }, options)).voidGiftCard;
273
+ },
274
+ async reissueCode(id, input, options) {
275
+ return (await write(REISSUE_GIFT_CARD_CODE_MUTATION, { id, reason: input.reason, notify: input.notify }, options)).reissueGiftCardCode;
276
+ },
277
+ async issue(input, options) {
278
+ return (await write(ISSUE_GIFT_CARD_MUTATION, { input }, options)).issueGiftCard;
279
+ },
280
+ },
129
281
  };
130
282
  }