@sixtyninecommerce/admin 0.10.0 → 0.12.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 (302) hide show
  1. package/README.md +5772 -118
  2. package/dist/auth/index.d.ts +7 -1
  3. package/dist/auth/index.js +8 -1
  4. package/dist/catalog/assets.d.ts +120 -8
  5. package/dist/catalog/assets.js +98 -12
  6. package/dist/catalog/collections.d.ts +279 -14
  7. package/dist/catalog/collections.js +246 -15
  8. package/dist/catalog/documents.d.ts +142 -0
  9. package/dist/catalog/documents.js +114 -0
  10. package/dist/catalog/index.d.ts +54 -6
  11. package/dist/catalog/index.js +10 -1
  12. package/dist/catalog/metadata.d.ts +244 -0
  13. package/dist/catalog/metadata.js +220 -0
  14. package/dist/catalog/products.d.ts +159 -19
  15. package/dist/catalog/products.js +88 -13
  16. package/dist/catalog/properties.d.ts +140 -14
  17. package/dist/catalog/properties.js +65 -1
  18. package/dist/catalog/recommendations.d.ts +288 -0
  19. package/dist/catalog/recommendations.js +237 -0
  20. package/dist/catalog/reviews.d.ts +381 -0
  21. package/dist/catalog/reviews.js +325 -0
  22. package/dist/catalog/types.d.ts +17 -1
  23. package/dist/catalog/types.js +10 -0
  24. package/dist/catalog/variant-find.d.ts +136 -0
  25. package/dist/catalog/variant-find.js +239 -0
  26. package/dist/catalog/variants.d.ts +293 -26
  27. package/dist/catalog/variants.js +164 -7
  28. package/dist/catalog/visibility.d.ts +38 -7
  29. package/dist/catalog/visibility.js +19 -1
  30. package/dist/client.d.ts +121 -9
  31. package/dist/client.js +53 -14
  32. package/dist/content/assets.d.ts +285 -0
  33. package/dist/content/assets.js +181 -0
  34. package/dist/content/forms.d.ts +332 -1
  35. package/dist/content/forms.js +140 -4
  36. package/dist/content/items.d.ts +292 -0
  37. package/dist/content/items.js +170 -0
  38. package/dist/content/menus.d.ts +254 -0
  39. package/dist/content/menus.js +70 -0
  40. package/dist/content/strings.d.ts +137 -0
  41. package/dist/content/strings.js +82 -0
  42. package/dist/content/types.d.ts +282 -0
  43. package/dist/content/types.js +100 -0
  44. package/dist/customers/age-verification.d.ts +66 -0
  45. package/dist/customers/age-verification.js +79 -0
  46. package/dist/customers/credit.d.ts +263 -0
  47. package/dist/customers/credit.js +244 -0
  48. package/dist/customers/delivery-preferences.d.ts +120 -0
  49. package/dist/customers/delivery-preferences.js +97 -0
  50. package/dist/customers/delivery-terms.d.ts +44 -0
  51. package/dist/customers/delivery-terms.js +32 -0
  52. package/dist/customers/groups.d.ts +207 -0
  53. package/dist/customers/groups.js +438 -0
  54. package/dist/customers/index.d.ts +462 -37
  55. package/dist/customers/index.js +317 -40
  56. package/dist/customers/invitation-status.d.ts +57 -0
  57. package/dist/customers/invitation-status.js +21 -0
  58. package/dist/customers/notes.d.ts +67 -0
  59. package/dist/customers/notes.js +51 -0
  60. package/dist/customers/notification-recipients.d.ts +97 -0
  61. package/dist/customers/notification-recipients.js +84 -0
  62. package/dist/customers/saved-lists.d.ts +42 -0
  63. package/dist/customers/saved-lists.js +61 -0
  64. package/dist/customers/vat.d.ts +83 -0
  65. package/dist/customers/vat.js +46 -0
  66. package/dist/customers/wire.d.ts +20 -0
  67. package/dist/customers/wire.js +35 -0
  68. package/dist/documents/ar.d.ts +307 -0
  69. package/dist/documents/ar.js +254 -0
  70. package/dist/documents/emails.d.ts +150 -0
  71. package/dist/documents/emails.js +220 -0
  72. package/dist/documents/index.d.ts +744 -21
  73. package/dist/documents/index.js +438 -24
  74. package/dist/documents/pdf.d.ts +2 -0
  75. package/dist/documents/pdf.js +11 -0
  76. package/dist/fulfillments/create.d.ts +167 -0
  77. package/dist/fulfillments/create.js +216 -0
  78. package/dist/fulfillments/index.d.ts +163 -11
  79. package/dist/fulfillments/index.js +135 -6
  80. package/dist/fulfillments/payment-policy.d.ts +64 -0
  81. package/dist/fulfillments/payment-policy.js +140 -0
  82. package/dist/fulfillments/warehouse.d.ts +724 -0
  83. package/dist/fulfillments/warehouse.js +914 -0
  84. package/dist/geo/index.d.ts +119 -0
  85. package/dist/geo/index.js +107 -0
  86. package/dist/index.d.ts +147 -39
  87. package/dist/index.js +51 -12
  88. package/dist/integrations/afas-actions.d.ts +234 -0
  89. package/dist/integrations/afas-actions.js +310 -0
  90. package/dist/integrations/afas-types.d.ts +483 -0
  91. package/dist/integrations/afas-types.js +5 -0
  92. package/dist/integrations/afas.d.ts +234 -0
  93. package/dist/integrations/afas.js +290 -0
  94. package/dist/integrations/connections.d.ts +103 -0
  95. package/dist/integrations/connections.js +55 -0
  96. package/dist/integrations/esp.d.ts +313 -0
  97. package/dist/integrations/esp.js +169 -0
  98. package/dist/integrations/exact-online-types.d.ts +965 -0
  99. package/dist/integrations/exact-online-types.js +6 -0
  100. package/dist/integrations/exact-online.d.ts +784 -0
  101. package/dist/integrations/exact-online.js +1089 -0
  102. package/dist/integrations/index.d.ts +44 -3
  103. package/dist/integrations/index.js +23 -3
  104. package/dist/integrations/pipeline-discoveries.d.ts +65 -0
  105. package/dist/integrations/pipeline-discoveries.js +65 -0
  106. package/dist/integrations/pipeline-keys.d.ts +13 -0
  107. package/dist/integrations/pipeline-keys.js +22 -0
  108. package/dist/integrations/pipeline-runs.d.ts +119 -0
  109. package/dist/integrations/pipeline-runs.js +87 -0
  110. package/dist/integrations/pipelines.d.ts +87 -15
  111. package/dist/integrations/pipelines.js +41 -22
  112. package/dist/integrations/price-import.d.ts +223 -0
  113. package/dist/integrations/price-import.js +124 -0
  114. package/dist/integrations/types.d.ts +367 -3
  115. package/dist/integrations/types.js +4 -3
  116. package/dist/locations/index.d.ts +66 -0
  117. package/dist/locations/index.js +31 -0
  118. package/dist/meta/index.d.ts +172 -0
  119. package/dist/metafields/index.d.ts +8 -1
  120. package/dist/metafields/index.js +10 -0
  121. package/dist/orders/cancel-with-money.d.ts +237 -0
  122. package/dist/orders/cancel-with-money.js +155 -0
  123. package/dist/orders/commit-edit.d.ts +23 -1
  124. package/dist/orders/commit-edit.js +19 -2
  125. package/dist/orders/deposit-policy.d.ts +3 -1
  126. package/dist/orders/drafts.d.ts +800 -0
  127. package/dist/orders/drafts.js +771 -0
  128. package/dist/orders/fields.d.ts +245 -0
  129. package/dist/orders/fields.js +188 -0
  130. package/dist/orders/get.d.ts +29 -19
  131. package/dist/orders/get.js +17 -8
  132. package/dist/orders/index.d.ts +66 -15
  133. package/dist/orders/index.js +25 -2
  134. package/dist/orders/lifecycle.d.ts +128 -0
  135. package/dist/orders/lifecycle.js +158 -0
  136. package/dist/orders/line-price-preview.d.ts +7 -2
  137. package/dist/orders/list.d.ts +243 -0
  138. package/dist/orders/list.js +487 -0
  139. package/dist/orders/manual-discounts.d.ts +13 -5
  140. package/dist/orders/manual-pricing.d.ts +5 -0
  141. package/dist/orders/money-view.d.ts +149 -0
  142. package/dist/orders/money-view.js +99 -0
  143. package/dist/orders/order-entry.d.ts +20 -7
  144. package/dist/orders/plan-edit.d.ts +34 -2
  145. package/dist/orders/plan-edit.js +112 -11
  146. package/dist/orders/settings.d.ts +201 -0
  147. package/dist/orders/settings.js +325 -0
  148. package/dist/orders/status.d.ts +159 -13
  149. package/dist/orders/status.js +21 -0
  150. package/dist/orders/surcharges.d.ts +20 -1
  151. package/dist/orders/surcharges.js +37 -11
  152. package/dist/payments/account-credit.d.ts +46 -0
  153. package/dist/payments/account-credit.js +42 -0
  154. package/dist/payments/ar.d.ts +292 -0
  155. package/dist/payments/ar.js +223 -0
  156. package/dist/payments/connected-account.d.ts +47 -0
  157. package/dist/payments/connected-account.js +61 -0
  158. package/dist/payments/credit-noted-fields.d.ts +19 -0
  159. package/dist/payments/credit-noted-fields.js +69 -0
  160. package/dist/payments/customer-consent.d.ts +30 -0
  161. package/dist/payments/customer-consent.js +49 -0
  162. package/dist/payments/index.d.ts +340 -19
  163. package/dist/payments/index.js +151 -1
  164. package/dist/payments/methods.d.ts +303 -8
  165. package/dist/payments/methods.js +337 -7
  166. package/dist/payments/mollie-methods.d.ts +159 -0
  167. package/dist/payments/mollie-methods.js +141 -0
  168. package/dist/payments/payment-links.d.ts +180 -0
  169. package/dist/payments/payment-links.js +97 -0
  170. package/dist/payments/provider-keys.d.ts +150 -0
  171. package/dist/payments/provider-keys.js +118 -0
  172. package/dist/payments/providers.d.ts +86 -11
  173. package/dist/payments/providers.js +29 -0
  174. package/dist/payments/requests.d.ts +147 -0
  175. package/dist/payments/requests.js +93 -0
  176. package/dist/payments/store-credit-fields.d.ts +15 -0
  177. package/dist/payments/store-credit-fields.js +51 -0
  178. package/dist/pickups/index.d.ts +106 -0
  179. package/dist/pickups/index.js +108 -0
  180. package/dist/platform/channels.d.ts +132 -0
  181. package/dist/platform/channels.js +128 -0
  182. package/dist/platform/email-gateways.d.ts +165 -0
  183. package/dist/platform/email-gateways.js +78 -0
  184. package/dist/platform/geo.d.ts +123 -0
  185. package/dist/platform/geo.js +144 -0
  186. package/dist/platform/tax.d.ts +162 -0
  187. package/dist/platform/tax.js +169 -0
  188. package/dist/pos/anomalies.d.ts +158 -0
  189. package/dist/pos/anomalies.js +64 -0
  190. package/dist/pos/assisted-selling.d.ts +79 -0
  191. package/dist/pos/assisted-selling.js +38 -0
  192. package/dist/pos/exchanges.d.ts +108 -0
  193. package/dist/pos/exchanges.js +22 -0
  194. package/dist/pos/gift-cards.d.ts +135 -0
  195. package/dist/pos/gift-cards.js +47 -0
  196. package/dist/pos/index.d.ts +2370 -58
  197. package/dist/pos/index.js +854 -7
  198. package/dist/pos/no-receipt.d.ts +94 -0
  199. package/dist/pos/no-receipt.js +25 -0
  200. package/dist/pos/offline-sales.d.ts +228 -0
  201. package/dist/pos/offline-sales.js +170 -0
  202. package/dist/pos/pay-by-link.d.ts +143 -0
  203. package/dist/pos/pay-by-link.js +57 -0
  204. package/dist/pos/quick-keys.d.ts +103 -0
  205. package/dist/pos/quick-keys.js +45 -0
  206. package/dist/pos/reports.d.ts +360 -0
  207. package/dist/pos/reports.js +62 -0
  208. package/dist/pos/returns.d.ts +244 -0
  209. package/dist/pos/returns.js +83 -0
  210. package/dist/pricing/bulk-coupons.d.ts +139 -0
  211. package/dist/pricing/bulk-coupons.js +112 -0
  212. package/dist/pricing/index.d.ts +174 -4
  213. package/dist/pricing/index.js +174 -1
  214. package/dist/pricing/price-lists.d.ts +606 -0
  215. package/dist/pricing/price-lists.js +600 -0
  216. package/dist/purchasing/alerts.d.ts +104 -0
  217. package/dist/purchasing/alerts.js +88 -0
  218. package/dist/purchasing/backorders.d.ts +61 -0
  219. package/dist/purchasing/backorders.js +92 -0
  220. package/dist/purchasing/cost.d.ts +110 -0
  221. package/dist/purchasing/cost.js +86 -0
  222. package/dist/purchasing/index.d.ts +54 -0
  223. package/dist/purchasing/index.js +24 -0
  224. package/dist/purchasing/links.d.ts +263 -0
  225. package/dist/purchasing/links.js +192 -0
  226. package/dist/purchasing/purchase-orders.d.ts +551 -0
  227. package/dist/purchasing/purchase-orders.js +491 -0
  228. package/dist/purchasing/receipts.d.ts +396 -0
  229. package/dist/purchasing/receipts.js +287 -0
  230. package/dist/purchasing/replenishment.d.ts +281 -0
  231. package/dist/purchasing/replenishment.js +240 -0
  232. package/dist/purchasing/returns.d.ts +273 -0
  233. package/dist/purchasing/returns.js +229 -0
  234. package/dist/purchasing/settings.d.ts +152 -0
  235. package/dist/purchasing/settings.js +181 -0
  236. package/dist/purchasing/suppliers.d.ts +476 -0
  237. package/dist/purchasing/suppliers.js +438 -0
  238. package/dist/quotes/index.d.ts +518 -0
  239. package/dist/quotes/index.js +439 -0
  240. package/dist/reports/index.d.ts +71 -8
  241. package/dist/reports/index.js +74 -11
  242. package/dist/returns/index.d.ts +675 -21
  243. package/dist/returns/index.js +756 -11
  244. package/dist/search/index.d.ts +76 -1
  245. package/dist/search/index.js +63 -0
  246. package/dist/seo/config.d.ts +128 -0
  247. package/dist/seo/config.js +95 -0
  248. package/dist/seo/redirects.d.ts +125 -0
  249. package/dist/seo/redirects.js +60 -1
  250. package/dist/seo/settings.d.ts +147 -0
  251. package/dist/seo/settings.js +209 -0
  252. package/dist/shipping/definitions.d.ts +29 -0
  253. package/dist/shipping/definitions.js +47 -0
  254. package/dist/shipping/fulfillment-profiles.d.ts +174 -0
  255. package/dist/shipping/fulfillment-profiles.js +104 -0
  256. package/dist/shipping/hendriks.d.ts +97 -0
  257. package/dist/shipping/hendriks.js +50 -0
  258. package/dist/shipping/index.d.ts +54 -0
  259. package/dist/shipping/index.js +27 -0
  260. package/dist/shipping/methods.d.ts +205 -0
  261. package/dist/shipping/methods.js +240 -0
  262. package/dist/shipping/myparcel.d.ts +668 -0
  263. package/dist/shipping/myparcel.js +466 -0
  264. package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
  265. package/dist/shipping/parcel-rule.d.ts +6 -5
  266. package/dist/shipping/parcel-rule.js +21 -23
  267. package/dist/shipping/rate-tables.d.ts +324 -0
  268. package/dist/shipping/rate-tables.js +390 -0
  269. package/dist/shipping/ship-to-countries.d.ts +75 -0
  270. package/dist/shipping/ship-to-countries.js +47 -0
  271. package/dist/stock/by-location.d.ts +86 -0
  272. package/dist/stock/by-location.js +94 -0
  273. package/dist/stock/index.d.ts +18 -4
  274. package/dist/stock/index.js +7 -0
  275. package/dist/stock/locations.d.ts +144 -0
  276. package/dist/stock/locations.js +168 -0
  277. package/dist/stock/settings.d.ts +106 -0
  278. package/dist/stock/settings.js +103 -0
  279. package/dist/stock/transfers.d.ts +386 -52
  280. package/dist/stock/transfers.js +222 -17
  281. package/dist/stored-value/index.d.ts +312 -11
  282. package/dist/stored-value/index.js +223 -4
  283. package/dist/subscriptions/index.d.ts +682 -0
  284. package/dist/subscriptions/index.js +815 -0
  285. package/dist/tax/display-policy.d.ts +105 -0
  286. package/dist/tax/display-policy.js +84 -0
  287. package/dist/tax/index.d.ts +79 -1
  288. package/dist/tax/index.js +52 -0
  289. package/dist/tenant/email-style.d.ts +102 -0
  290. package/dist/tenant/email-style.js +72 -0
  291. package/dist/tenant/email-templates.d.ts +287 -0
  292. package/dist/tenant/email-templates.js +271 -0
  293. package/dist/tenant/notifications.d.ts +23 -17
  294. package/dist/tenant/settings-sources.d.ts +1 -1
  295. package/dist/tenant/time-zone.d.ts +17 -0
  296. package/dist/tenant/time-zone.js +11 -0
  297. package/dist/types.d.ts +50 -3
  298. package/dist/users/index.d.ts +3 -0
  299. package/dist/users/index.js +2 -0
  300. package/dist/users/warehouses.d.ts +50 -0
  301. package/dist/users/warehouses.js +51 -0
  302. package/package.json +2 -2
@@ -39,6 +39,16 @@ export interface MetaCatalogLabels {
39
39
  auditCallOutcome: LabelMap;
40
40
  /** Who sends a notification event's email: `platform` or `none` (`admin.tenant.notifications`). */
41
41
  notificationSender: LabelMap;
42
+ /**
43
+ * A supplier purchase order's status (`admin.purchasing.purchaseOrders`). Served by a platform
44
+ * with purchase orders; absent before.
45
+ */
46
+ purchaseOrderStatus?: LabelMap;
47
+ /**
48
+ * A return of goods to a supplier's status (`admin.purchasing.returns`). Served by a platform
49
+ * with supplier returns; absent before.
50
+ */
51
+ supplierReturnStatus?: LabelMap;
42
52
  /**
43
53
  * A vocabulary added after this SDK release arrives camelised, with its map
44
54
  * untouched.
@@ -54,6 +64,17 @@ export interface MetaCatalogTransitions {
54
64
  * UNRANKED, so it is absent — treat "no rank" as "no forward move", never 0.
55
65
  */
56
66
  fulfillmentRank: Record<string, number>;
67
+ /**
68
+ * A supplier purchase order's lifecycle (`admin.purchasing.purchaseOrders`): `cancelled` is
69
+ * terminal, `closed` moves only back to `sent`. Served by a platform with purchase orders;
70
+ * absent before.
71
+ */
72
+ purchaseOrder?: TransitionMap;
73
+ /**
74
+ * A return of goods to a supplier's lifecycle (`admin.purchasing.returns`): `draft → shipped →
75
+ * resolved`, and `draft → cancelled`. Served by a platform with supplier returns; absent before.
76
+ */
77
+ supplierReturn?: TransitionMap;
57
78
  [extra: string]: unknown;
58
79
  }
59
80
  export interface PermissionGroup {
@@ -108,6 +129,12 @@ export interface MetaCatalogPermissions {
108
129
  export interface PluginCatalogEntry {
109
130
  key: string;
110
131
  name: string;
132
+ /**
133
+ * One sentence on what the plugin does, in merchant English: the words the
134
+ * platform's own dashboard shows beside the name. Served by a platform from
135
+ * this release on.
136
+ */
137
+ description: string;
111
138
  group: string;
112
139
  /** `system` plugins are always on; `external` ones need an entitlement. */
113
140
  kind: string;
@@ -117,6 +144,142 @@ export interface MetaCatalogPlugins {
117
144
  groupLabels: Record<string, string>;
118
145
  [extra: string]: unknown;
119
146
  }
147
+ /** Which API a plugin settings input is written through. */
148
+ export type PluginConfigWriteApi = 'admin-graphql' | 'plugins-rest';
149
+ /**
150
+ * How a secret property of a plugin settings schema behaves on READ, carried
151
+ * as the schema property's `x-secret` keyword beside `writeOnly: true`:
152
+ *
153
+ * - `masked-roundtrip`: the config read returns a masked preview (named in
154
+ * {@link PluginConfigRead.fields}); sending that preview back unchanged, or
155
+ * leaving the property out, keeps the stored secret. A BLANK is not the same
156
+ * everywhere: it keeps the Tikkie credentials but REMOVES the till's Mollie
157
+ * key, so read the property's `description` before sending one;
158
+ * - `write-only`: no value the read returns may be sent back. A masked preview
159
+ * may exist for display, but the platform would store it AS the secret, so
160
+ * never pre-fill the field;
161
+ * - `server-generated`: the platform mints it; a head shows it, never asks for it.
162
+ */
163
+ export type PluginConfigSecret = 'masked-roundtrip' | 'write-only' | 'server-generated';
164
+ /** The operation that writes a settings input. */
165
+ export interface PluginConfigWrite {
166
+ api: PluginConfigWriteApi;
167
+ /** The Admin API mutation (`admin-graphql`), or `METHOD /path` on the plugins service. */
168
+ operation: string;
169
+ /**
170
+ * The mutation argument that takes the input type named by
171
+ * {@link PluginConfigInput.name}, e.g. `input`. Absent when the mutation takes
172
+ * its settings as INLINE arguments (then `name` is the operation itself and the
173
+ * schema's properties are the argument names), and absent for a REST body.
174
+ */
175
+ argument?: string;
176
+ /**
177
+ * The field of the argument's input object that takes the schema's
178
+ * properties, when they are only PART of a wider input: the SEO plugin's
179
+ * Channel defaults go in `updateChannel(input: { id, customFields: { … } })`
180
+ * under `customFields`. That schema lists only its own fields and stays open
181
+ * to the rest (other forms' fields), and {@link key} is then a field of the
182
+ * argument object (`input.id`). Absent: the argument IS the input. Served by a
183
+ * platform from this release on.
184
+ */
185
+ field?: string;
186
+ /**
187
+ * For a plugin whose settings are a COLLECTION of records (email gateways,
188
+ * product feeds): what names the record this input changes. The mutation
189
+ * argument sent beside {@link argument} (`updateEmailGateway(id:, input:)`);
190
+ * with {@link field}, a field of the argument object; for a REST write, the
191
+ * path parameter of `operation` (`PATCH /feeds/configs/:id` → `id`). Absent
192
+ * for a create and for settings that are one record per store, and for an
193
+ * input that names its record by a property of its own (`paymentMethodCode`,
194
+ * which {@link PluginConfigRead.fields} pre-fills). Served by a platform from
195
+ * this release on.
196
+ */
197
+ key?: string;
198
+ }
199
+ /** The read that pre-fills a form for this input. */
200
+ export interface PluginConfigRead {
201
+ /** The Admin API query (or `GET /path`) that returns the stored config. */
202
+ operation: string;
203
+ /**
204
+ * The field of the read's answer that holds {@link fields}, when they are
205
+ * nested: `activeChannel { customFields { … } }` → `customFields`. Absent: the
206
+ * answer itself holds them. Served by a platform from this release on.
207
+ */
208
+ field?: string;
209
+ /** The permission the read needs; not always the write's. */
210
+ permission: string;
211
+ /**
212
+ * EVERY permission that allows the read, {@link permission} first, when there
213
+ * is more than one: holding any one of them is enough. Absent when
214
+ * `permission` is the only one, so read `permissions ?? [permission]`. Served
215
+ * by a platform from this release on.
216
+ */
217
+ permissions?: string[];
218
+ /**
219
+ * For a collection: the query argument (for a REST read, the path parameter
220
+ * of {@link operation}) that names the record to read, e.g. `id`. Served by a
221
+ * platform from this release on.
222
+ */
223
+ key?: string;
224
+ /**
225
+ * For a collection: the query that lists every record. Each item reads like
226
+ * {@link operation}'s answer, and its field named like {@link key} is the
227
+ * value {@link key} takes (`id`; `paymentMethodCode` for a payment provider).
228
+ * A REST list is `GET /path` answering a cursor page: the items in `data`, the
229
+ * next page through `pagination.next_cursor`. Served by a platform from this
230
+ * release on.
231
+ */
232
+ list?: string;
233
+ /**
234
+ * Schema property → the field of the read that pre-fills it, keyed by DATA
235
+ * (the schema's own property names). A property absent here has nothing to
236
+ * pre-fill: a write-only secret, or a value the read does not return. A read
237
+ * field that is null pre-fills nothing either: leave the property out, which
238
+ * keeps the stored value. Projected that way, a read validates against the
239
+ * schema once any required write-only secret is typed in. For a
240
+ * `plugins-rest` input both sides are the route's WIRE names
241
+ * (`language_code`); this SDK's typed modules over those routes
242
+ * (`admin.feeds.get`) camelise top-level keys, so map them back, or call the
243
+ * route in wire form.
244
+ */
245
+ fields: Record<string, string>;
246
+ }
247
+ /** One settings input of a plugin: what to send, where, and who may send it. */
248
+ export interface PluginConfigInput {
249
+ /**
250
+ * The GraphQL input type (or REST DTO) the schema describes, e.g.
251
+ * `UpdateHendriksConfigInput`; for a mutation that takes inline arguments
252
+ * (`write.argument` absent), the operation itself, e.g. `setMyparcelEnabled`.
253
+ */
254
+ name: string;
255
+ write: PluginConfigWrite;
256
+ /** `null` when no read returns this input's values. */
257
+ read: PluginConfigRead | null;
258
+ /** The permission the write needs on the active store. */
259
+ permission: string;
260
+ /**
261
+ * EVERY permission that allows the write, {@link permission} first, when there
262
+ * is more than one: holding any one of them is enough (POS receipt numbering
263
+ * takes `UpdateSettings` or `ManagePosDevices`). Absent when `permission` is
264
+ * the only one, so read `permissions ?? [permission]`. Served by a platform
265
+ * from this release on.
266
+ */
267
+ permissions?: string[];
268
+ /**
269
+ * Draft 2020-12 JSON Schema of the input. It states only what the platform
270
+ * enforces on write: schema-valid means "worth sending", not "certain to be
271
+ * accepted" (a refusal can depend on stored state, e.g. enabling before a
272
+ * credential exists). Property names are the API's own and are never
273
+ * camelised. A secret carries `writeOnly: true` and `x-secret`. A write the
274
+ * platform deprecates (the legacy Mollie/Stripe key door) carries the
275
+ * standard `deprecated: true`.
276
+ */
277
+ schema: JsonSchema;
278
+ }
279
+ /** Every settings input one plugin takes. */
280
+ export interface PluginConfigSchemas {
281
+ inputs: PluginConfigInput[];
282
+ }
120
283
  export interface MetaCatalog {
121
284
  /**
122
285
  * A short hash of everything else. It changes only when the catalog's content
@@ -138,6 +301,15 @@ export interface MetaCatalog {
138
301
  * shape.
139
302
  */
140
303
  settingsSchemas: Record<string, JsonSchema>;
304
+ /**
305
+ * JSON Schema of each plugin's settings inputs, keyed by PLUGIN KEY
306
+ * (`payment-links`, `external-tracking`, …, as in `plugins.catalog`), so a
307
+ * head can render a plugin's settings form from data. Everything below the
308
+ * plugin key, the schemas included, arrives exactly as the platform spells
309
+ * it. A plugin with no entry has no per-store settings at all (search,
310
+ * warehouse, stored value). Served by a platform from this release on.
311
+ */
312
+ pluginConfigSchemas: Record<string, PluginConfigSchemas>;
141
313
  /**
142
314
  * A member added after this SDK release arrives with its NAME camelised and
143
315
  * its contents untouched — the half that matters, since a member this build
@@ -8,8 +8,15 @@ import type { Call } from '../types.js';
8
8
  * fields, and commerce refuses a value written against it
9
9
  * (`METAFIELD_OWNER_INVALID`). A manifest declaring one still registers; only
10
10
  * the value surface says no.
11
+ *
12
+ * `purchase_order`, `purchase_order_line` and `supplier` are the purchasing
13
+ * records, which belong to the store's legal entity rather than to the store:
14
+ * one of another legal entity answers `NotFoundError` like an id of nothing,
15
+ * and a store that does not purchase answers `PURCHASING_NOT_ENABLED`. Their
16
+ * values are still the store's own. An engine older than them refuses them with
17
+ * `METAFIELD_OWNER_INVALID`.
11
18
  */
12
- export declare const METAFIELD_OWNER_TYPES: readonly ["product", "variant", "customer", "order", "order_line", "location", "collection"];
19
+ export declare const METAFIELD_OWNER_TYPES: readonly ["product", "variant", "customer", "order", "order_line", "location", "collection", "purchase_order", "purchase_order_line", "supplier"];
13
20
  export type MetafieldOwnerType = (typeof METAFIELD_OWNER_TYPES)[number];
14
21
  /** Scalar value types. `list<T>` of any of them is also a type. */
15
22
  export declare const METAFIELD_SCALAR_TYPES: readonly ["text", "number", "money", "boolean", "date", "json", "reference", "attachment"];
@@ -7,6 +7,13 @@ import { createPage } from '@sixtyninecommerce/core';
7
7
  * fields, and commerce refuses a value written against it
8
8
  * (`METAFIELD_OWNER_INVALID`). A manifest declaring one still registers; only
9
9
  * the value surface says no.
10
+ *
11
+ * `purchase_order`, `purchase_order_line` and `supplier` are the purchasing
12
+ * records, which belong to the store's legal entity rather than to the store:
13
+ * one of another legal entity answers `NotFoundError` like an id of nothing,
14
+ * and a store that does not purchase answers `PURCHASING_NOT_ENABLED`. Their
15
+ * values are still the store's own. An engine older than them refuses them with
16
+ * `METAFIELD_OWNER_INVALID`.
10
17
  */
11
18
  export const METAFIELD_OWNER_TYPES = [
12
19
  'product',
@@ -16,6 +23,9 @@ export const METAFIELD_OWNER_TYPES = [
16
23
  'order_line',
17
24
  'location',
18
25
  'collection',
26
+ 'purchase_order',
27
+ 'purchase_order_line',
28
+ 'supplier',
19
29
  ];
20
30
  /** Scalar value types. `list<T>` of any of them is also a type. */
21
31
  export const METAFIELD_SCALAR_TYPES = [
@@ -0,0 +1,237 @@
1
+ import type { Transport } from '@sixtyninecommerce/core';
2
+ import type { StoreCreditMove } from '../payments/account-credit.js';
3
+ import type { IssuedRefund, OrderPaymentPosition, PaidOrder } from '../payments/index.js';
4
+ import type { Call } from '../types.js';
5
+ import type { OrderOverpaymentChoice, OverpaymentOption } from './surcharges.js';
6
+ /** What happens to the money an order holds when it is cancelled. Pass one, or neither. */
7
+ export interface CancelWithMoneyCall extends Call {
8
+ /**
9
+ * Why the order is cancelled. REQUIRED with `retain`, where it is recorded in the order's
10
+ * history and the audit trail; otherwise written on the refunds and the account credit. At
11
+ * most 500 characters.
12
+ */
13
+ reason?: string;
14
+ /**
15
+ * The settled money goes back: `REFUND` to the payments it came from, or `ACCOUNT_CREDIT` to
16
+ * the customer's account (only where the store keeps the customer's balance itself). Ignored
17
+ * when the order holds no settled money.
18
+ */
19
+ overpayment?: OrderOverpaymentChoice;
20
+ /** The settled money stays on the cancelled order (with a `reason`). */
21
+ retain?: boolean;
22
+ /**
23
+ * With `overpayment: 'ACCOUNT_CREDIT'` in a store whose book is store credit (the preview's
24
+ * `accountCredit.book` `STORE_CREDIT`): whether the customer expressly agreed to store credit
25
+ * instead of a refund to their payment (EU consumer law, CRD art. 13(1)), as staff recorded it.
26
+ * The move records it on its ledger entries (`StoredValueEntry.customerAgreed`); never a
27
+ * condition, nothing is refused for it. Part of the request: a repeat under the same key sends
28
+ * the same answer. Sent only when given; an engine before the field (incentives sprint 8 PR 6a)
29
+ * refuses a call that gives it.
30
+ */
31
+ customerAgreed?: boolean;
32
+ }
33
+ /** What a cancel with a money decision did. */
34
+ /**
35
+ * How a refund's money reaches the customer: `PROVIDER` (the payment provider pays it back; the
36
+ * refund stays `Pending` until it confirms), `AUTOMATIC` (the platform puts it back itself: a
37
+ * stored-value refund credits the gift card or store credit it was paid with), `MANUAL` (an
38
+ * offline method: the refund is recorded and staff pay it out by hand). Only a `MANUAL` refund
39
+ * needs anyone to move money.
40
+ */
41
+ export type OrderCancelMoneyPayout = 'PROVIDER' | 'AUTOMATIC' | 'MANUAL';
42
+ /** How one refund a cancel made reaches the customer. */
43
+ export interface OrderCancelRefundPayout {
44
+ refundId: string;
45
+ paymentId: string;
46
+ payout: OrderCancelMoneyPayout;
47
+ }
48
+ export interface OrderCancellation {
49
+ /** The order as the cancel left it (`state: 'Cancelled'`). */
50
+ order: PaidOrder;
51
+ /**
52
+ * The refunds the cancel made: a card refund stays `Pending` until the payment provider
53
+ * confirms it; one recorded (an offline method, or stored value) is `Settled`. Which ones
54
+ * staff pay out by hand is `refundPayouts`.
55
+ */
56
+ refunds: IssuedRefund[];
57
+ /** Minor units the store kept on the cancelled order (`retain`); 0 otherwise. */
58
+ retained: number;
59
+ /** How each refund in `refunds` reaches the customer, by refund id. */
60
+ refundPayouts: OrderCancelRefundPayout[];
61
+ /** Minor units the cancel moved to the customer's account (`ACCOUNT_CREDIT`); 0 otherwise. */
62
+ creditedToAccount: number;
63
+ /**
64
+ * Minor units the cancel moved to the customer's store credit (`ACCOUNT_CREDIT` in a store
65
+ * whose book is store credit); 0 otherwise, and from an engine before it. Beside
66
+ * `creditedToAccount`, never part of it. Such a cancel also refunds its gift-card and
67
+ * store-credit payments to their own balances (`refunds`, payout `AUTOMATIC`).
68
+ */
69
+ creditedToStoreCredit: number;
70
+ /** The move to the customer's store-credit wallet; null otherwise. */
71
+ storeCredit: StoreCreditMove | null;
72
+ /** The card holds the cancel voided. */
73
+ voidedHolds: OrderCancelMoneyHold[];
74
+ /**
75
+ * The order's payment position after the cancel, with what of its money is now on the
76
+ * customer's account (`creditedToAccount`, already taken off `settled`).
77
+ */
78
+ position: OrderPaymentPosition & {
79
+ creditedToAccount: number;
80
+ };
81
+ }
82
+ /** A card hold `cancelWithMoney` voids, whatever is decided. Minor units. */
83
+ export interface OrderCancelMoneyHold {
84
+ paymentId: string;
85
+ method: string | null;
86
+ amount: number;
87
+ }
88
+ /** A refund `cancelWithMoney` makes on `REFUND`: everything one settled payment holds. */
89
+ export interface OrderCancelMoneyRefund {
90
+ paymentId: string;
91
+ method: string | null;
92
+ /** Minor units. */
93
+ amount: number;
94
+ /** How its money reaches the customer: only a `MANUAL` refund is paid out by hand. */
95
+ payout: OrderCancelMoneyPayout;
96
+ }
97
+ /**
98
+ * What `cancelWithMoney` would do with the money an order holds (`previewCancelWithMoney`), read
99
+ * now: each way of deciding, open or with the refusal the cancel would answer for it. Nothing was
100
+ * written and no lock was taken: the cancel judges it all again.
101
+ */
102
+ export interface OrderCancelMoneyPreview {
103
+ orderId: string;
104
+ currencyCode: string;
105
+ /**
106
+ * What the order's settled payments still hold, minor units: what `REFUND` gives back,
107
+ * `ACCOUNT_CREDIT` moves, or `retain` keeps. 0 when no decision is needed (a decision is then
108
+ * ignored).
109
+ */
110
+ settledHeld: number;
111
+ /**
112
+ * What gift cards sold on the order hold of its settled payments, minor units, beside
113
+ * `settledHeld` (never part of it): the value of a card already spent, which stays with the
114
+ * store, or of a card still live. No refund or account credit gives it back: only `retain` keeps
115
+ * it, with `settledHeld`, and while it is above 0 `REFUND` and `ACCOUNT_CREDIT` are closed
116
+ * (`REFUND_HELD_BY_GIFT_CARD`). A decision is needed when `settledHeld + giftCardHeld` is above 0;
117
+ * `retain` keeps that sum.
118
+ */
119
+ giftCardHeld: number;
120
+ /** The card holds the cancel voids, whatever is decided. */
121
+ holds: OrderCancelMoneyHold[];
122
+ /** The refunds `REFUND` would make, the recorded ones first. Empty while it is closed. */
123
+ refunds: OrderCancelMoneyRefund[];
124
+ /** `overpayment: 'REFUND'`: open, or the refusal choosing it would answer. */
125
+ refund: OverpaymentOption;
126
+ /**
127
+ * `overpayment: 'ACCOUNT_CREDIT'`: open only where the store keeps the customer's balance itself
128
+ * and the customer has a credit account there; otherwise the account's own refusal
129
+ * (`AR_LEDGER_NOT_ENABLED`, `AR_ACCOUNT_REQUIRED`, `AR_ACCOUNT_IN_ERP`, `ACCOUNT_CREDIT_*`, …).
130
+ */
131
+ accountCredit: OverpaymentOption;
132
+ /** `retain: true` (with a `reason`): open, or the refusal choosing it would answer. */
133
+ retain: OverpaymentOption;
134
+ /**
135
+ * The refusal the cancel answers whatever is decided (`ORDER_OVERPAYMENT_REFUND_UNRECONCILED`,
136
+ * `ORDER_CANCEL_HOLD_NOT_RELEASABLE`, `ORDER_CANCEL_SETTLEMENT_SPLIT` over two card holds,
137
+ * `REFUND_METHOD_UNAVAILABLE` for a hold), in the cancel's own words; null while a decision is
138
+ * open.
139
+ */
140
+ refusal: {
141
+ code: string;
142
+ message: string;
143
+ } | null;
144
+ /** The order's payment position, with what of its money is on the customer's account. */
145
+ position: OrderPaymentPosition & {
146
+ creditedToAccount: number;
147
+ };
148
+ }
149
+ /**
150
+ * Its own document, like the cancel's: on an engine without the query this call alone fails
151
+ * validation.
152
+ */
153
+ export declare const CANCEL_ORDER_WITH_MONEY_PREVIEW_QUERY = "\n query CancelOrderWithMoneyPreview($orderId: ID!) {\n cancelOrderWithMoneyPreview(orderId: $orderId) {\n orderId\n currencyCode\n settledHeld\n giftCardHeld\n holds {\n paymentId\n method\n amount\n }\n refunds {\n paymentId\n method\n amount\n payout\n }\n refund { \n available\n code\n message\n book\n }\n accountCredit { \n available\n code\n message\n book\n }\n retain { \n available\n code\n message\n book\n }\n refusal {\n code\n message\n }\n position {\n total\n covered\n settled\n authorized\n refunded\n creditedToAccount\n creditNoted\n owed\n outstanding\n overpaid\n availableToCharge\n }\n }\n }\n";
154
+ /**
155
+ * Its own document on purpose: `cancelOrderWithMoney` exists only on an engine that serves it,
156
+ * so on an older one this call alone fails validation and no other order call does.
157
+ */
158
+ export declare const CANCEL_ORDER_WITH_MONEY_MUTATION = "\n mutation CancelOrderWithMoney($input: CancelOrderWithMoneyInput!, $idempotencyKey: String) {\n cancelOrderWithMoney(input: $input, idempotencyKey: $idempotencyKey) {\n order {\n id\n code\n state\n currencyCode\n total\n totalWithTax\n }\n refunds {\n id\n total\n state\n method\n transactionId\n reason\n }\n retained\n refundPayouts {\n refundId\n paymentId\n payout\n }\n creditedToAccount\n creditedToStoreCredit\n storeCredit { accountId amount currencyCode entryIds }\n voidedHolds {\n paymentId\n method\n amount\n }\n position {\n total\n covered\n settled\n authorized\n refunded\n creditedToAccount\n creditNoted\n owed\n outstanding\n overpaid\n availableToCharge\n }\n }\n }\n";
159
+ export interface OrderCancelWithMoneyModule {
160
+ /**
161
+ * Cancel a whole order, its shipping included (a cancelled order bills nothing), and decide,
162
+ * in the same transaction, what happens to the money it holds. Needs `UpdateOrder`. The
163
+ * cancel's own rules are the order page's: a fulfillment
164
+ * holding a line refuses it, and a shopper's live cart is cancelled only when it carries a
165
+ * payment or a stock movement. It is the one way to cancel a `Parked` order: straight out of
166
+ * the park, its reserved stock released, with no `order.unparked`.
167
+ *
168
+ * Settled money goes back by `overpayment: 'REFUND'` (every payment that holds some, whole)
169
+ * or `'ACCOUNT_CREDIT'`, or stays with `retain: true` and a `reason`. A card hold on a gateway
170
+ * is voided whatever the choice; capture it first (`settlePayment`) to keep that money.
171
+ *
172
+ * A plain cancel (`cancelOrder` on the Admin API, or `orders.bulk` with `CANCEL`) of an order
173
+ * that has been placed or parked and still holds money is refused `ORDER_HOLDS_MONEY`
174
+ * (`BusinessRuleError`, 422), with `extensions.position` and `extensions.refundPosition`:
175
+ * cancel it here instead, or give the money back first (refund each settled payment with
176
+ * `payments.refund`, cancel a card hold's payment) and then cancel. What gift cards sold on the
177
+ * order hold (`giftCardHeld`) is never given back: only `retain` here keeps it.
178
+ *
179
+ * Refusals, with nothing written:
180
+ * - `ORDER_CANCEL_MONEY_CHOICE_REQUIRED` (422): settled money and no decision.
181
+ * - `CANCEL_RETAIN_REASON_REQUIRED` (422), `ORDER_CANCEL_MONEY_INPUT_INVALID`
182
+ * (`ValidationError`, 400: both a choice and `retain`, or a reason over 500 characters).
183
+ * - `ORDER_CANCEL_SETTLEMENT_SPLIT` (422): more than one card payment to refund or void. The
184
+ * cancel asks a payment provider at most once, as its last step: refund or void all but one
185
+ * first (`payments.refund`; release a card hold at the payment provider first where its
186
+ * payment method cannot), then cancel. A hold its method cannot release answers
187
+ * `ORDER_CANCEL_HOLD_NOT_RELEASABLE` instead, whatever else the order holds.
188
+ * - `ORDER_CANCEL_HOLD_NOT_RELEASABLE` (422, `extensions.paymentId`, `extensions.method`): a card
189
+ * hold whose payment method cannot void an authorization at its provider (cancelling it here
190
+ * would mark it cancelled while the provider keeps the money reserved). Release the hold at
191
+ * the payment provider first, then cancel that payment on the order, then cancel the order.
192
+ * - `ORDER_OVERPAYMENT_REFUND_UNRECONCILED` (422): a refund of unknown outcome is open; record
193
+ * the provider's answer first (`payments.reconcileRefund`).
194
+ * - `REFUND_HELD_BY_GIFT_CARD` (422, with `extensions.refundPosition`): `overpayment` while gift
195
+ * cards sold on the order hold part of its settled money (`giftCardHeld` on the preview).
196
+ * Neither way gives that back, and the cancel settles all of the money or none: refund the
197
+ * rest first (`payments.refund`), then cancel with `retain` and a `reason`, which keeps the
198
+ * gift cards' share on the cancelled order and records it.
199
+ * - `REFUND_METHOD_UNAVAILABLE`, the account's own refusals (`ACCOUNT_CREDIT_*`, `AR_*`), and
200
+ * the cancel's (`ORDER_HAS_ACTIVE_FULFILLMENT`, `ORDER_UNITS_SHIPPED`,
201
+ * `ORDER_CART_NOT_CANCELLABLE`, and `LOCATION_OUT_OF_SCOPE` for a credential restricted to
202
+ * stock locations while the order's stock is reserved outside them).
203
+ * - `ORDER_CANCEL_REFUSED`: the engine refused the cancel itself (an order already cancelled
204
+ * included), or the void of a card hold was not confirmed and recorded: the provider refused
205
+ * it, did not answer (an app's cancel hook that never answered included), or answered and the
206
+ * engine could not record it. NOTHING is cancelled either way, but the key differs: an engine
207
+ * refusal is stored and a repeat under the same key answers it again, so clear the condition
208
+ * and cancel again under a NEW key; a void that was not confirmed releases the key, so a retry
209
+ * under it asks the provider again. After a void, the hold may or may not still stand: check
210
+ * it at the provider (void or capture it there if it does), then cancel again.
211
+ * - `PAYMENT_CANCEL_CONFLICT` (`ConflictError`, 409, `extensions.state`): the engine refused the
212
+ * void before asking the provider: the payment moved since the cancel read it, or a capture
213
+ * of it may have reached its provider. Nothing was asked and NOTHING is cancelled; read the
214
+ * order again and act on it as it stands.
215
+ *
216
+ * `IDEMPOTENCY_OUTCOME_UNKNOWN` (`error.outcomeUnknown`, `extensions.movement`): the refund
217
+ * reached the payment provider and its answer never came. NOTHING is cancelled; the attempt is
218
+ * recorded and reserved on the order, and the key stays spent for 24 hours. Record the
219
+ * provider's answer (`payments.reconcileRefund`), then cancel again under a NEW key: a refund
220
+ * recorded as made is not made a second time.
221
+ *
222
+ * `idempotencyKey`: a repeat under it answers the first call's result, never a second cancel.
223
+ */
224
+ cancelWithMoney(orderId: string, options?: CancelWithMoneyCall): Promise<OrderCancellation>;
225
+ /**
226
+ * What {@link cancelWithMoney} would do with the money the order holds, before staff decide:
227
+ * what its settled payments hold (`settledHeld`, and beside it `giftCardHeld`, what gift cards
228
+ * sold on the order hold, which only `retain` keeps), the card holds it voids, the refunds
229
+ * `REFUND` would make,
230
+ * and for each way (`REFUND`, `ACCOUNT_CREDIT`, `retain`) whether it is open or the refusal
231
+ * the cancel would answer, in the cancel's own words. `refusal` is set when the cancel would
232
+ * be refused whatever is decided. Read now and without a lock: the cancel judges it again.
233
+ * Needs `UpdateOrder`, as the cancel does. Another store's order is a `NotFoundError`.
234
+ */
235
+ previewCancelWithMoney(orderId: string, options?: Call): Promise<OrderCancelMoneyPreview>;
236
+ }
237
+ export declare function createOrderCancelWithMoneyModule(transport: Transport): OrderCancelWithMoneyModule;
@@ -0,0 +1,155 @@
1
+ import { creditNotedAware } from '../payments/credit-noted-fields.js';
2
+ import { customerAgreedVariable } from '../payments/customer-consent.js';
3
+ import { STORE_CREDIT_MOVE_FIELDS, storeCreditAware } from '../payments/store-credit-fields.js';
4
+ const OPTION_FIELDS = /* GraphQL */ `
5
+ available
6
+ code
7
+ message
8
+ book
9
+ `;
10
+ /**
11
+ * Its own document, like the cancel's: on an engine without the query this call alone fails
12
+ * validation.
13
+ */
14
+ export const CANCEL_ORDER_WITH_MONEY_PREVIEW_QUERY = /* GraphQL */ `
15
+ query CancelOrderWithMoneyPreview($orderId: ID!) {
16
+ cancelOrderWithMoneyPreview(orderId: $orderId) {
17
+ orderId
18
+ currencyCode
19
+ settledHeld
20
+ giftCardHeld
21
+ holds {
22
+ paymentId
23
+ method
24
+ amount
25
+ }
26
+ refunds {
27
+ paymentId
28
+ method
29
+ amount
30
+ payout
31
+ }
32
+ refund { ${OPTION_FIELDS} }
33
+ accountCredit { ${OPTION_FIELDS} }
34
+ retain { ${OPTION_FIELDS} }
35
+ refusal {
36
+ code
37
+ message
38
+ }
39
+ position {
40
+ total
41
+ covered
42
+ settled
43
+ authorized
44
+ refunded
45
+ creditedToAccount
46
+ creditNoted
47
+ owed
48
+ outstanding
49
+ overpaid
50
+ availableToCharge
51
+ }
52
+ }
53
+ }
54
+ `;
55
+ /**
56
+ * Its own document on purpose: `cancelOrderWithMoney` exists only on an engine that serves it,
57
+ * so on an older one this call alone fails validation and no other order call does.
58
+ */
59
+ export const CANCEL_ORDER_WITH_MONEY_MUTATION = /* GraphQL */ `
60
+ mutation CancelOrderWithMoney($input: CancelOrderWithMoneyInput!, $idempotencyKey: String) {
61
+ cancelOrderWithMoney(input: $input, idempotencyKey: $idempotencyKey) {
62
+ order {
63
+ id
64
+ code
65
+ state
66
+ currencyCode
67
+ total
68
+ totalWithTax
69
+ }
70
+ refunds {
71
+ id
72
+ total
73
+ state
74
+ method
75
+ transactionId
76
+ reason
77
+ }
78
+ retained
79
+ refundPayouts {
80
+ refundId
81
+ paymentId
82
+ payout
83
+ }
84
+ creditedToAccount
85
+ creditedToStoreCredit
86
+ storeCredit { ${STORE_CREDIT_MOVE_FIELDS} }
87
+ voidedHolds {
88
+ paymentId
89
+ method
90
+ amount
91
+ }
92
+ position {
93
+ total
94
+ covered
95
+ settled
96
+ authorized
97
+ refunded
98
+ creditedToAccount
99
+ creditNoted
100
+ owed
101
+ outstanding
102
+ overpaid
103
+ availableToCharge
104
+ }
105
+ }
106
+ }
107
+ `;
108
+ /** An option as the SDK types it: `code` and `message` are null when it is open. */
109
+ function toOption(raw) {
110
+ return {
111
+ available: raw.available,
112
+ code: raw.code ?? null,
113
+ message: raw.message ?? null,
114
+ book: raw.book ?? null,
115
+ };
116
+ }
117
+ export function createOrderCancelWithMoneyModule(transport) {
118
+ return {
119
+ async cancelWithMoney(orderId, options) {
120
+ const data = await storeCreditAware(creditNotedAware(transport)).graphql({
121
+ api: 'admin',
122
+ query: CANCEL_ORDER_WITH_MONEY_MUTATION,
123
+ // `undefined`, never an explicit null: `JSON.stringify` drops it, so an option left out
124
+ // stays off the wire rather than arriving as a value.
125
+ variables: {
126
+ input: {
127
+ orderId,
128
+ reason: options?.reason,
129
+ overpayment: options?.overpayment,
130
+ retain: options?.retain,
131
+ customerAgreed: customerAgreedVariable(options?.customerAgreed),
132
+ },
133
+ idempotencyKey: options?.idempotencyKey,
134
+ },
135
+ }, options);
136
+ const outcome = data.cancelOrderWithMoney;
137
+ return {
138
+ ...outcome,
139
+ creditedToStoreCredit: outcome.creditedToStoreCredit ?? 0,
140
+ storeCredit: outcome.storeCredit ?? null,
141
+ };
142
+ },
143
+ async previewCancelWithMoney(orderId, options) {
144
+ const data = await storeCreditAware(creditNotedAware(transport)).graphql({ api: 'admin', query: CANCEL_ORDER_WITH_MONEY_PREVIEW_QUERY, variables: { orderId } }, options);
145
+ const preview = data.cancelOrderWithMoneyPreview;
146
+ return {
147
+ ...preview,
148
+ refund: toOption(preview.refund),
149
+ accountCredit: toOption(preview.accountCredit),
150
+ retain: toOption(preview.retain),
151
+ refusal: preview.refusal ?? null,
152
+ };
153
+ },
154
+ };
155
+ }