@sixtyninecommerce/admin 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +2739 -17
  2. package/dist/api-tokens/index.d.ts +15 -5
  3. package/dist/api-tokens/index.js +1 -0
  4. package/dist/apps/event-subscription.d.ts +59 -0
  5. package/dist/apps/event-subscription.js +32 -0
  6. package/dist/apps/hook-secret.d.ts +22 -0
  7. package/dist/apps/hook-secret.js +36 -0
  8. package/dist/apps/index.d.ts +54 -3
  9. package/dist/apps/index.js +17 -0
  10. package/dist/audit/index.d.ts +7 -0
  11. package/dist/auth/queries.d.ts +5 -1
  12. package/dist/auth/queries.js +6 -0
  13. package/dist/bulk/index.d.ts +323 -0
  14. package/dist/bulk/index.js +162 -0
  15. package/dist/catalog/assets.d.ts +147 -0
  16. package/dist/catalog/assets.js +164 -0
  17. package/dist/catalog/collections.d.ts +109 -0
  18. package/dist/catalog/collections.js +91 -0
  19. package/dist/catalog/facets.d.ts +103 -0
  20. package/dist/catalog/facets.js +100 -0
  21. package/dist/catalog/index.d.ts +115 -0
  22. package/dist/catalog/index.js +21 -0
  23. package/dist/catalog/options.d.ts +89 -0
  24. package/dist/catalog/options.js +88 -0
  25. package/dist/catalog/products-bulk.d.ts +21 -0
  26. package/dist/catalog/products-bulk.js +58 -0
  27. package/dist/catalog/products.d.ts +650 -0
  28. package/dist/catalog/products.js +458 -0
  29. package/dist/catalog/properties.d.ts +234 -0
  30. package/dist/catalog/properties.js +158 -0
  31. package/dist/catalog/types.d.ts +174 -0
  32. package/dist/catalog/types.js +141 -0
  33. package/dist/catalog/variants.d.ts +324 -0
  34. package/dist/catalog/variants.js +288 -0
  35. package/dist/catalog/visibility.d.ts +57 -0
  36. package/dist/catalog/visibility.js +59 -0
  37. package/dist/client.d.ts +192 -3
  38. package/dist/client.js +87 -12
  39. package/dist/compliance/index.d.ts +88 -0
  40. package/dist/compliance/index.js +88 -0
  41. package/dist/customer-data-redaction.d.ts +14 -0
  42. package/dist/customer-data-redaction.js +22 -0
  43. package/dist/customers/index.d.ts +428 -17
  44. package/dist/customers/index.js +322 -15
  45. package/dist/documents/index.d.ts +513 -16
  46. package/dist/documents/index.js +229 -3
  47. package/dist/events/index.d.ts +259 -0
  48. package/dist/events/index.js +147 -0
  49. package/dist/feeds/ai.d.ts +46 -0
  50. package/dist/feeds/ai.js +43 -0
  51. package/dist/feeds/categories.d.ts +50 -0
  52. package/dist/feeds/categories.js +56 -0
  53. package/dist/feeds/configs.d.ts +54 -0
  54. package/dist/feeds/configs.js +85 -0
  55. package/dist/feeds/identifier-fields.d.ts +25 -0
  56. package/dist/feeds/identifier-fields.js +29 -0
  57. package/dist/feeds/index.d.ts +54 -0
  58. package/dist/feeds/index.js +46 -0
  59. package/dist/feeds/preserve.d.ts +38 -0
  60. package/dist/feeds/preserve.js +74 -0
  61. package/dist/feeds/rules.d.ts +42 -0
  62. package/dist/feeds/rules.js +56 -0
  63. package/dist/feeds/types.d.ts +654 -0
  64. package/dist/feeds/types.js +135 -0
  65. package/dist/fulfillments/index.d.ts +437 -0
  66. package/dist/fulfillments/index.js +534 -0
  67. package/dist/heads/index.d.ts +60 -0
  68. package/dist/heads/index.js +45 -0
  69. package/dist/hooks/assignments.d.ts +90 -0
  70. package/dist/hooks/assignments.js +53 -0
  71. package/dist/hooks/index.d.ts +97 -0
  72. package/dist/hooks/index.js +76 -0
  73. package/dist/index.d.ts +95 -9
  74. package/dist/index.js +21 -1
  75. package/dist/integrations/index.d.ts +14 -0
  76. package/dist/integrations/index.js +9 -0
  77. package/dist/integrations/pipelines.d.ts +113 -0
  78. package/dist/integrations/pipelines.js +62 -0
  79. package/dist/integrations/types.d.ts +176 -0
  80. package/dist/integrations/types.js +8 -0
  81. package/dist/jobs/bulk-action-run.d.ts +74 -0
  82. package/dist/jobs/bulk-action-run.js +69 -0
  83. package/dist/locations/index.d.ts +6 -2
  84. package/dist/meta/index.d.ts +32 -0
  85. package/dist/orders/bulk.d.ts +75 -0
  86. package/dist/orders/bulk.js +150 -0
  87. package/dist/orders/commit-edit.d.ts +123 -0
  88. package/dist/orders/commit-edit.js +142 -0
  89. package/dist/orders/deposit-policy.d.ts +103 -0
  90. package/dist/orders/deposit-policy.js +202 -0
  91. package/dist/orders/get.d.ts +722 -0
  92. package/dist/orders/get.js +530 -0
  93. package/dist/orders/index.d.ts +186 -21
  94. package/dist/orders/index.js +57 -0
  95. package/dist/orders/line-price-preview.d.ts +297 -0
  96. package/dist/orders/line-price-preview.js +50 -0
  97. package/dist/orders/manual-discounts.d.ts +141 -0
  98. package/dist/orders/manual-discounts.js +97 -0
  99. package/dist/orders/manual-pricing.d.ts +192 -0
  100. package/dist/orders/manual-pricing.js +72 -0
  101. package/dist/orders/order-entry.d.ts +566 -0
  102. package/dist/orders/order-entry.js +129 -0
  103. package/dist/orders/parcel-charge.d.ts +45 -0
  104. package/dist/orders/parcel-charge.js +55 -0
  105. package/dist/orders/plan-edit.d.ts +489 -0
  106. package/dist/orders/plan-edit.js +93 -0
  107. package/dist/orders/status.d.ts +235 -0
  108. package/dist/orders/status.js +96 -0
  109. package/dist/orders/surcharges.d.ts +75 -2
  110. package/dist/orders/surcharges.js +110 -4
  111. package/dist/payments/account-credit.d.ts +171 -0
  112. package/dist/payments/account-credit.js +107 -0
  113. package/dist/payments/index.d.ts +241 -9
  114. package/dist/payments/index.js +92 -0
  115. package/dist/payments/methods.d.ts +37 -0
  116. package/dist/payments/methods.js +33 -0
  117. package/dist/platform/catalog.d.ts +148 -0
  118. package/dist/platform/catalog.js +74 -0
  119. package/dist/platform/entitlements.d.ts +111 -0
  120. package/dist/platform/entitlements.js +86 -0
  121. package/dist/platform/legal-entities.d.ts +139 -0
  122. package/dist/platform/legal-entities.js +126 -0
  123. package/dist/platform/legal-entity-numbering.d.ts +103 -0
  124. package/dist/platform/legal-entity-numbering.js +101 -0
  125. package/dist/platform/organization-membership.d.ts +80 -0
  126. package/dist/platform/organization-membership.js +71 -0
  127. package/dist/platform/organization-settings.d.ts +33 -0
  128. package/dist/platform/organization-settings.js +42 -0
  129. package/dist/platform/organization-sharing.d.ts +172 -0
  130. package/dist/platform/organization-sharing.js +120 -0
  131. package/dist/platform/organizations.d.ts +205 -0
  132. package/dist/platform/organizations.js +180 -0
  133. package/dist/platform/provision-store.d.ts +88 -8
  134. package/dist/platform/provision-store.js +12 -0
  135. package/dist/platform/reports.d.ts +46 -0
  136. package/dist/platform/reports.js +31 -0
  137. package/dist/platform/server-metrics.d.ts +58 -0
  138. package/dist/platform/server-metrics.js +11 -0
  139. package/dist/pos/index.d.ts +567 -0
  140. package/dist/pos/index.js +205 -0
  141. package/dist/pricing/index.d.ts +408 -0
  142. package/dist/pricing/index.js +353 -0
  143. package/dist/pricing/vouchers.d.ts +103 -0
  144. package/dist/pricing/vouchers.js +69 -0
  145. package/dist/provenance/index.d.ts +93 -0
  146. package/dist/provenance/index.js +53 -0
  147. package/dist/reports/index.d.ts +199 -0
  148. package/dist/reports/index.js +154 -0
  149. package/dist/returns/index.d.ts +225 -0
  150. package/dist/returns/index.js +160 -0
  151. package/dist/search/index.d.ts +99 -0
  152. package/dist/search/index.js +62 -0
  153. package/dist/shipping/parcel-count-suggestion.d.ts +52 -0
  154. package/dist/shipping/parcel-count-suggestion.js +73 -0
  155. package/dist/shipping/parcel-rule.d.ts +48 -0
  156. package/dist/shipping/parcel-rule.js +91 -0
  157. package/dist/stock/index.d.ts +166 -0
  158. package/dist/stock/index.js +115 -0
  159. package/dist/stock/transfers.d.ts +520 -0
  160. package/dist/stock/transfers.js +437 -0
  161. package/dist/stored-value/index.d.ts +154 -0
  162. package/dist/stored-value/index.js +130 -0
  163. package/dist/tenant/capabilities.d.ts +10 -0
  164. package/dist/tenant/entitlements.d.ts +35 -0
  165. package/dist/tenant/entitlements.js +15 -0
  166. package/dist/tenant/field-groups.d.ts +64 -0
  167. package/dist/tenant/field-groups.js +34 -0
  168. package/dist/tenant/legal-entity.d.ts +32 -0
  169. package/dist/tenant/legal-entity.js +41 -0
  170. package/dist/tenant/notifications.d.ts +148 -0
  171. package/dist/tenant/notifications.js +79 -0
  172. package/dist/tenant/retention.d.ts +10 -4
  173. package/dist/tenant/settings-sources.d.ts +103 -0
  174. package/dist/tenant/settings-sources.js +92 -0
  175. package/dist/types.d.ts +86 -11
  176. package/dist/uploads/index.d.ts +11 -7
  177. package/dist/users/index.d.ts +104 -0
  178. package/dist/users/index.js +80 -0
  179. package/package.json +3 -2
@@ -0,0 +1,566 @@
1
+ import type { Transport } from '@sixtyninecommerce/core';
2
+ import type { MetafieldAttachment } from '../metafields/index.js';
3
+ import type { Call } from '../types.js';
4
+ /**
5
+ * How a caller states a price (spec §8.1).
6
+ *
7
+ * There is NO default and there never will be: a vertical's €121 is either the
8
+ * net or the gross of a 21 % line, and the two differ by a whole VAT rate. The
9
+ * platform refuses rather than guesses, so every input that carries a price
10
+ * carries its basis beside it.
11
+ */
12
+ export type ExternalLinePriceBasis = 'net' | 'gross';
13
+ /**
14
+ * What is going to happen to the goods.
15
+ *
16
+ * A fact the vertical STATES about the order rather than an instruction
17
+ * commerce acts on in this release: nothing here creates a fulfilment or picks
18
+ * a shipping method. It is recorded as the order's `platform.fulfilment`
19
+ * metafield so a document, a WMS push or a later fulfilment flow can read back
20
+ * what the caller actually asked for.
21
+ *
22
+ * - `pickup` — collected at a location. Needs no shipping method and no
23
+ * address.
24
+ * - `ship` — shipped. The order still needs a shipping method before it can
25
+ * leave `Draft`, and `transitionTo: 'ArrangingPayment'` on an order that has
26
+ * none is refused by the platform's own placement gate, not by this call.
27
+ * - `none` — neither shipped nor collected: a service, a subscription set-up,
28
+ * a fee.
29
+ */
30
+ export type ExternalOrderFulfilment = 'pickup' | 'ship' | 'none';
31
+ /**
32
+ * Where the composed order should end up.
33
+ *
34
+ * `Draft` is the default and the only state that needs nothing else to be true.
35
+ * `ArrangingPayment` runs the platform's ordinary placement gate — a shipping
36
+ * method for a shipped order, a customer, stock — and a refusal there is
37
+ * `ORDER_TRANSITION_REFUSED` carrying the state machine's own reason, with the
38
+ * whole order rolled back.
39
+ *
40
+ * `Parked` is accepted by the type and REFUSED by the engine, deliberately and
41
+ * always. Every deposit rule — whether the store has deposits on at all, the
42
+ * minimum, whether a zero-deposit park is allowed — lives in {@link
43
+ * OrdersModule.park}, and a direct transition would walk past all of them while
44
+ * taking the stock-allocation sweeper's park exemption for good. A freshly
45
+ * composed order has no payment on it to be a deposit either. Compose the order
46
+ * here, record the deposit with `payments.record`, then call `orders.park`.
47
+ */
48
+ export type ExternalOrderTargetState = 'Draft' | 'ArrangingPayment' | 'Parked';
49
+ /**
50
+ * A line the STORE prices: the catalogue decides what it costs.
51
+ *
52
+ * `kind` is the SDK's discriminant, not a wire field — see
53
+ * {@link ExternalOrderLineInput} for what goes over the wire.
54
+ */
55
+ export interface ExternalOrderCatalogLine {
56
+ kind: 'catalog';
57
+ /** A product variant of this channel. */
58
+ productVariantId: string;
59
+ /** A whole number of at least 1. */
60
+ quantity: number;
61
+ /**
62
+ * What the caller believes one unit costs INCLUDING tax, in minor units.
63
+ *
64
+ * Optional, and a mismatch is `LINE_MISPRICED` with the line's position —
65
+ * NEVER a silent re-price, and never a "close enough" comparison either, since
66
+ * both sides are integers of the same currency. A vertical that quoted a price
67
+ * to a customer an hour ago has to learn that the catalogue moved now, not
68
+ * discover it on the invoice; and because the whole call is atomic, the order
69
+ * is not created at all when one line is off.
70
+ *
71
+ * Send it whenever the caller showed a price to somebody. Omit it and the
72
+ * store's current price is accepted without question.
73
+ */
74
+ expectedUnitPriceWithTax?: number | null;
75
+ /** Written to this LINE's `platform.attachments` metafield. */
76
+ attachments?: MetafieldAttachment[] | null;
77
+ }
78
+ /**
79
+ * A line the VERTICAL prices: it has no catalogue entry at all, so the label,
80
+ * the price, the basis and the tax class all come from the caller.
81
+ *
82
+ * Needs the `ImportExternalLines` permission on top of `CreateOrder`. An order
83
+ * of nothing but catalog lines does not, which is why the check is per request
84
+ * rather than on the mutation: an integration that never prices a line should
85
+ * not have to ask for the permission that lets one.
86
+ *
87
+ * The line lands on a hidden carrier variant, and price lists and line-level
88
+ * promotions never re-price it (spec §8.3). An ORDER-level promotion — a
89
+ * percentage or fixed discount on the whole order, including the pay-now
90
+ * discount — is shared across every line of an order by the engine itself, with
91
+ * no way to leave one out, so an order that ends up with one on an externally
92
+ * priced line is REFUSED with `EXTERNAL_LINE_PROMOTION_UNSUPPORTED` rather than
93
+ * invoiced with your stated price quietly reduced.
94
+ */
95
+ export interface ExternalOrderExternalLine {
96
+ kind: 'external';
97
+ /**
98
+ * What the customer reads on the invoice — the vertical's own words, 1 to 255
99
+ * characters. It is the line's name everywhere the platform prints one; the
100
+ * carrier variant behind it is an implementation detail nobody sees.
101
+ */
102
+ label: string;
103
+ /** A whole number of at least 1. */
104
+ quantity: number;
105
+ /**
106
+ * Unit price in minor units (`1999` is 19.99), stated in
107
+ * {@link ExternalOrderExternalLine.priceBasis}.
108
+ *
109
+ * Zero is refused as `LINE_ZERO_PRICE`, separately from a negative price and
110
+ * for a different reason: a caller that means "free" is usually missing a
111
+ * price it failed to compute, and a zero line silently widens every total, tax
112
+ * summary and document by something nobody is charged for. A line given away
113
+ * is a discount on a priced line.
114
+ *
115
+ * Negative is refused too — money coming back off an order is a surcharge or a
116
+ * refund, not a line.
117
+ */
118
+ unitPrice: number;
119
+ /**
120
+ * Required. The platform will not guess whether the price is net or gross —
121
+ * and the side you state is the side that is held FIXED.
122
+ *
123
+ * A line stated `net: 10000` is invoiced at 100.00 net whatever the order's
124
+ * tax situation turns out to be: 100.00 plus 21.00 VAT at the standard rate,
125
+ * 100.00 at 0% under an EU intra-community reverse charge, 100.00 at 0% on a
126
+ * tax-removed order. A line stated `gross: 12100` is 121.00 to the customer in
127
+ * all three, so at 0% its NET rises to 121.00 — the platform's own behaviour
128
+ * for gross-priced money, not a rounding artefact.
129
+ *
130
+ * The stated side survives every later edit of the order. A merchant may
131
+ * re-price the line in the back office, and their number is then charged in
132
+ * the basis you stated; they cannot UN-price it. An edit that would leave the
133
+ * line with no price at all is refused with `EXTERNAL_LINE_UNPRICED`, because
134
+ * the line has no catalogue price to fall back to and the alternative is
135
+ * invoicing your line at zero.
136
+ */
137
+ priceBasis: ExternalLinePriceBasis;
138
+ /**
139
+ * A `taxClass.key` of this store (spec §8.6), resolved PER ORDER: the order's
140
+ * shipping COUNTRY picks the class's mapping, the order's tax ZONE picks the
141
+ * rate. A class that says nothing about this order's country is
142
+ * `TAX_CLASS_UNMAPPED`, and one mapped to a category with no rate in the
143
+ * order's zone is `TAX_CLASS_RATE_MISSING` — the merchant's own configuration
144
+ * gap, refused rather than priced at a rate nobody chose.
145
+ */
146
+ taxClass: string;
147
+ /**
148
+ * The vertical's own JSON for this line — a configurator's answers, a
149
+ * measurement sheet, a booking's parameters.
150
+ *
151
+ * Opaque: never interpreted, never indexed, never searched, size-capped, and
152
+ * stored verbatim as the line's `platform.configuration` metafield. Its keys
153
+ * are the CALLER's, and they travel BYTE-FOR-BYTE — this SDK's GraphQL path
154
+ * does no case conversion whatsoever, so `serial_number`, `SKU_REF` and
155
+ * `größe` come back spelled exactly as they were sent. (The SDK's
156
+ * `preserveKeys` option is a REST-only concern and has no bearing here.)
157
+ *
158
+ * `undefined` and `null` are NOT the same: omit the field for "no
159
+ * configuration", and note that an explicit JSON `null` is refused by the
160
+ * metafield writer as a value. Omitting it also keeps it out of the request
161
+ * fingerprint in the same way the engine's own recovery check does.
162
+ */
163
+ configuration?: unknown;
164
+ /** Written to this LINE's `platform.attachments` metafield. */
165
+ attachments?: MetafieldAttachment[] | null;
166
+ /** The caller's own article code for the line, when it has one. */
167
+ sku?: string | null;
168
+ }
169
+ /**
170
+ * One line of the order: a catalog line or an externally priced one.
171
+ *
172
+ * **This is a nicer shape than the wire's.** GraphQL has no input union, so the
173
+ * Admin API models a line as `ExternalOrderLineInput { catalog, external }` with
174
+ * exactly one member set — a shape in which "both" and "neither" are
175
+ * representable and have to be refused at runtime. The SDK takes a real
176
+ * discriminated union on `kind` instead, so neither mistake type-checks, and
177
+ * {@link toWireLine} wraps it back into the member the engine expects. The
178
+ * engine's own service layer holds the identical `kind`-tagged union behind its
179
+ * resolver, so the two ends agree and only the transport hop is wrapped.
180
+ */
181
+ export type ExternalOrderLineInput = ExternalOrderCatalogLine | ExternalOrderExternalLine;
182
+ /**
183
+ * An order-level adjustment that is not a line: a delivery charge, a negotiated
184
+ * discount, a handling fee.
185
+ *
186
+ * Priced by the caller like an external line, so it needs `ImportExternalLines`
187
+ * too. Its tax lines are written ONCE, through the store's configured tax-line
188
+ * strategy, so a tax-removed or reverse-charged order gets the right answer
189
+ * rather than the class's raw rate frozen onto the order for good.
190
+ */
191
+ export interface ExternalOrderSurchargeInput {
192
+ /** What the customer reads, 1 to 255 characters. */
193
+ label: string;
194
+ /**
195
+ * Minor units, stated in {@link ExternalOrderSurchargeInput.priceBasis}.
196
+ * NEGATIVE for a deduction. Zero is refused (`LINE_ZERO_PRICE`): an
197
+ * adjustment that moves no money is almost always an amount that failed to
198
+ * compute.
199
+ */
200
+ amount: number;
201
+ /** Required, for the same reason it is required on a line. */
202
+ priceBasis: ExternalLinePriceBasis;
203
+ /** A `taxClass.key` of this store, resolved per order exactly as a line's is. */
204
+ taxClass: string;
205
+ /**
206
+ * The caller's own classification of the charge, stored as the surcharge's
207
+ * SKU. Unrelated to the `kind` discriminant on {@link ExternalOrderLineInput}
208
+ * — this one is the SDL's field name and carries the caller's data.
209
+ */
210
+ kind?: string | null;
211
+ }
212
+ /**
213
+ * A whole order, composed in one call.
214
+ *
215
+ * Every money figure in and out of this surface is an INTEGER of MINOR UNITS in
216
+ * the order's currency (`1999` is 19.99). There are no decimals anywhere on this
217
+ * API and a fractional value is refused rather than rounded.
218
+ */
219
+ export interface ExternalOrderInput {
220
+ /**
221
+ * The vertical's own aggregate id for this order — an ERP number, a booking
222
+ * reference, a contract id. 1 to 255 characters, unique per store, trimmed but
223
+ * NOT case-folded: two systems that disagree about case disagree about
224
+ * identity.
225
+ *
226
+ * It is the handle {@link OrdersModule.byExternalRef} recovers by, and it
227
+ * never expires. See {@link OrdersModule.createOrRecover} for what happens
228
+ * when the same ref arrives twice.
229
+ */
230
+ externalRef: string;
231
+ /**
232
+ * An EXISTING customer of this channel. A customer of another store reads as
233
+ * absent, which is the same answer a bad id gets.
234
+ *
235
+ * There is no "create the customer too" here on purpose: core's
236
+ * customer-creation path reuses a row with the same email from ANY channel,
237
+ * which would hand a second tenant a handle on the first tenant's customer.
238
+ * Create the customer with `admin.customers.create` first.
239
+ */
240
+ customerId?: string | null;
241
+ /**
242
+ * A stock location of THIS channel, recorded as the order's
243
+ * `platform.location` metafield. A location id belonging to another store is
244
+ * `LOCATION_NOT_IN_CHANNEL` — the same code the `x-location` header gate and
245
+ * the API-token restriction writer answer with, because it is one rule
246
+ * enforced at three boundaries.
247
+ */
248
+ location?: string | null;
249
+ /**
250
+ * The order's billing address. Written to the order, and the first step of
251
+ * the country that selects each tax class's category mapping.
252
+ *
253
+ * Send it whenever your store maps a tax class differently per country. A
254
+ * composed order has no shipping address of its own, so the country is
255
+ * resolved in this order and stops at the first answer:
256
+ *
257
+ * 1. the order's shipping address, if something else has already set one;
258
+ * 2. this billing address;
259
+ * 3. for `fulfilment: 'pickup'`, the country of the `location` you named;
260
+ * 4. the store's default tax zone, when that zone names exactly ONE country
261
+ * (an "EU" zone names 27 and therefore names none);
262
+ * 5. otherwise no country, which resolves through the class's `*` mapping.
263
+ *
264
+ * A class that says nothing about the resolved country and has no `*` mapping
265
+ * is `TAX_CLASS_UNMAPPED`.
266
+ */
267
+ billingAddress?: ExternalOrderAddressInput | null;
268
+ /**
269
+ * At least one line, at most 500. An empty order is refused rather than
270
+ * created: nothing on this API can add to an order afterwards, so an order
271
+ * with no lines is not a draft to fill in later.
272
+ *
273
+ * ORDER IS SIGNIFICANT. The position of a line in this array is what every
274
+ * refusal about a line names (`extensions.details.position`), and it is what
275
+ * each returned line carries back as `customFields.externalEntryPosition` —
276
+ * the handle to map a response line onto the request line that produced it,
277
+ * since a line has no id until it exists. Match on that FIELD rather than on
278
+ * array order; the response is sorted by it, but the field is the contract.
279
+ *
280
+ * ONE REQUEST LINE IS ONE ORDER LINE. Two externally priced lines that differ
281
+ * only in their `configuration` stay two lines, and two byte-identical ones
282
+ * stay two lines of quantity 1 rather than becoming one of quantity 2. If you
283
+ * mean two of something, send a quantity — which is also why two CATALOG
284
+ * lines naming the same variant are refused with `LINE_DUPLICATE_VARIANT`.
285
+ */
286
+ lines: ExternalOrderLineInput[];
287
+ /** Order-level adjustments. Refusals about one carry `collection: 'surcharges'`. */
288
+ surcharges?: ExternalOrderSurchargeInput[] | null;
289
+ /** Required: what is going to happen to the goods. */
290
+ fulfilment: ExternalOrderFulfilment;
291
+ /** Defaults to `Draft`. `Parked` is always refused — see {@link ExternalOrderTargetState}. */
292
+ transitionTo?: ExternalOrderTargetState | null;
293
+ /** Written to the ORDER's `platform.attachments` metafield. At most 50. */
294
+ attachments?: MetafieldAttachment[] | null;
295
+ }
296
+ /**
297
+ * A postal address, as the platform spells one.
298
+ *
299
+ * `countryCode` is required whenever an address is given at all: it is what
300
+ * selects this order's tax-class mapping, and the platform will not infer it
301
+ * from the rest of the address.
302
+ */
303
+ export interface ExternalOrderAddressInput {
304
+ fullName?: string | null;
305
+ company?: string | null;
306
+ streetLine1?: string | null;
307
+ streetLine2?: string | null;
308
+ city?: string | null;
309
+ province?: string | null;
310
+ postalCode?: string | null;
311
+ /** ISO 3166-1 alpha-2. */
312
+ countryCode: string;
313
+ phoneNumber?: string | null;
314
+ }
315
+ /** One rate applied to a line, as the order's tax strategy resolved it. */
316
+ export interface ExternalOrderTaxLine {
317
+ /** The store's own words for the rate, printed on documents. */
318
+ description: string;
319
+ /** Whole-number percent: `21` is 21 %. */
320
+ taxRate: number;
321
+ }
322
+ /**
323
+ * A line of the composed order.
324
+ *
325
+ * `productVariant` is present on EVERY line, including an externally priced one
326
+ * — that one names the hidden per-tax-class carrier variant it landed on, whose
327
+ * `name` and `sku` are platform bookkeeping and not what the customer reads. The
328
+ * customer reads the label the caller sent, which is what the platform prints.
329
+ */
330
+ export interface ExternalOrderLine {
331
+ /** The handle every later call about this line uses. */
332
+ id: string;
333
+ quantity: number;
334
+ /** Minor units, excluding tax. */
335
+ unitPrice: number;
336
+ /** Minor units, including tax. */
337
+ unitPriceWithTax: number;
338
+ /** Minor units, excluding tax, for the whole line. */
339
+ linePrice: number;
340
+ /** Minor units, including tax, for the whole line. */
341
+ linePriceWithTax: number;
342
+ taxLines: ExternalOrderTaxLine[];
343
+ productVariant: {
344
+ id: string;
345
+ sku: string;
346
+ name: string;
347
+ };
348
+ /**
349
+ * `externalEntryPosition` is the zero-based index of the REQUEST line that
350
+ * produced this order line — the handle to map the response back onto what
351
+ * you sent. `externalEntryKey` is a hash of that request line's content, for a
352
+ * caller that would rather match on content than on position.
353
+ * `externalLineLabel` is your own words for an externally priced line, and is
354
+ * null on a catalog line.
355
+ */
356
+ customFields: {
357
+ externalEntryPosition: number | null;
358
+ externalEntryKey: string | null;
359
+ externalLineLabel: string | null;
360
+ } | null;
361
+ }
362
+ /** A surcharge as it sits on the composed order. */
363
+ export interface ExternalOrderSurcharge {
364
+ id: string;
365
+ description: string;
366
+ /** The caller's `kind`, or null. */
367
+ sku: string | null;
368
+ /** Minor units, excluding tax. Negative for a deduction. */
369
+ price: number;
370
+ /** Minor units, including tax. */
371
+ priceWithTax: number;
372
+ /** Whole-number percent. */
373
+ taxRate: number;
374
+ }
375
+ /**
376
+ * The composed order, as much of it as this surface projects.
377
+ *
378
+ * The figures are the order's own persisted state after composition, not a
379
+ * projection of the request: an external line's price has been through the
380
+ * store's tax-line strategy, and a catalog line's through the catalogue.
381
+ */
382
+ export interface ExternalOrder {
383
+ id: string;
384
+ /** The store's human-readable order code. */
385
+ code: string;
386
+ /** The order's state, `Draft` unless `transitionTo` asked for another. */
387
+ state: string;
388
+ currencyCode: string;
389
+ /** Minor units: all lines, excluding tax. */
390
+ subTotal: number;
391
+ subTotalWithTax: number;
392
+ /** Minor units: `subTotal` plus shipping. */
393
+ total: number;
394
+ /** Minor units: the final payable amount. */
395
+ totalWithTax: number;
396
+ lines: ExternalOrderLine[];
397
+ surcharges: ExternalOrderSurcharge[];
398
+ /**
399
+ * `externalRef` is on the ADMIN schema although the custom field is declared
400
+ * `public: false` — that flag withholds it from the SHOP API, where another
401
+ * system's order id has no business being, and says nothing about this one.
402
+ * Null on an order that was never composed through this surface.
403
+ */
404
+ customFields: {
405
+ externalRef: string | null;
406
+ } | null;
407
+ }
408
+ /**
409
+ * Options for {@link OrdersModule.createOrRecover}.
410
+ *
411
+ * `idempotencyKey` is REQUIRED, unlike everywhere else in this SDK: the engine
412
+ * declares it `String!`, so a caller that omitted it would be refused by GraphQL
413
+ * validation with the whole document 400ing rather than by anything actionable.
414
+ * Making it required here turns that into a compile error.
415
+ */
416
+ export interface ExternalOrderCall extends Call {
417
+ /**
418
+ * A key the CALLER generates, valid for 24 hours. A UUIDv7 is ideal. Reuse it
419
+ * only when retrying that exact request — see {@link
420
+ * OrdersModule.createOrRecover} for how it differs from `externalRef`.
421
+ */
422
+ idempotencyKey: string;
423
+ }
424
+ /**
425
+ * External order entry (spec §8.1, §8.3, §8.4).
426
+ *
427
+ * One call composes a whole order — catalog lines at the store's prices,
428
+ * externally priced lines at the vertical's, surcharges, attachments — or
429
+ * composes nothing at all. The atomicity is the point: the caller is a
430
+ * vertical's trading system, and an order that exists with half its lines is
431
+ * worse for it than an order that does not exist.
432
+ */
433
+ export interface OrderEntryModule {
434
+ /**
435
+ * Compose an order, or hand back the one this `externalRef` already names.
436
+ * Needs `CreateOrder`, plus `ImportExternalLines` when any line or surcharge
437
+ * is priced by the caller.
438
+ *
439
+ * ## Two different questions, two different keys
440
+ *
441
+ * `idempotencyKey` answers **"is this the same REQUEST I already made?"** — a
442
+ * key the caller generated, valid for 24 hours, replaying the first call's
443
+ * order on a repeat and refused with a `ConflictError` coded
444
+ * `IDEMPOTENCY_CONFLICT` when the same key arrives with a different body.
445
+ *
446
+ * `externalRef` answers **"is this the same ORDER?"** — the vertical's own
447
+ * aggregate id, valid for ever. A caller that lost its response, restarted and
448
+ * generated a fresh key still must not create a second order for the same
449
+ * trade, which is why recovery is keyed on the ref as well.
450
+ *
451
+ * **Recovery by ref is CONDITIONAL on the request being the same one.** The
452
+ * engine fingerprints the composed order against the ref, so re-posting a ref
453
+ * with different lines is a `ConflictError` coded `EXTERNAL_REF_CONFLICT`
454
+ * rather than a silent hand-back of an order that no longer matches what the
455
+ * caller thinks it sent.
456
+ * Read the existing one with {@link OrdersModule.byExternalRef}, or post the
457
+ * new order under its own reference. The same code answers a ref claimed by a
458
+ * concurrent call while this one was composing — the remedy is identical.
459
+ *
460
+ * ## What it refuses, and why none of it is a silent correction
461
+ *
462
+ * Everything below rolls the whole order back; there is never a half-composed
463
+ * order to clean up. Each refusal about a line or a surcharge carries the
464
+ * caller's own zero-based INDEX on `extensions.details`
465
+ * (`{ position, collection }`), because a vertical posting a basket of ten
466
+ * lines cannot act on "one of them is mispriced", and a line has no id yet to
467
+ * be named by.
468
+ *
469
+ * - `LINE_MISPRICED` — a catalog line's `expectedUnitPriceWithTax` is not what
470
+ * the store charges. Never re-priced, never rounded to.
471
+ * - `LINE_ZERO_PRICE` — an external line or a surcharge priced at zero.
472
+ * - `LINE_NOT_SALEABLE` — the catalogue refused the line: no stock, not
473
+ * orderable, an order that cannot take items. The engine's own message rides
474
+ * along.
475
+ * - `INVALID_EXTERNAL_LINE` / `INVALID_EXTERNAL_REF` — structurally bad input:
476
+ * a quantity below 1, a blank label, a missing basis, a line carrying both
477
+ * `catalog` and `external` data or neither, a ref over 255 characters.
478
+ * - `LINE_DUPLICATE_VARIANT` — two catalog lines name the same variant.
479
+ * `details` carries the second one's `position` and the first one's
480
+ * `firstPosition`. Send one line with the quantity you want.
481
+ * - `EXTERNAL_LINE_PROMOTION_UNSUPPORTED` — a promotion discounted one of your
482
+ * externally priced lines. An order-level promotion is shared across every
483
+ * line of an order by the engine, so the platform refuses rather than
484
+ * invoicing a price you did not state.
485
+ * - `LOCATION_NOT_IN_CHANNEL` — the location belongs to another store.
486
+ * - `TAX_CLASS_UNMAPPED` / `TAX_CLASS_RATE_MISSING` — the store's tax setup
487
+ * cannot price this line for this order's country and zone.
488
+ * - `ORDER_TRANSITION_REFUSED` — `transitionTo` could not be reached, with the
489
+ * state machine's own reason; also the answer to `Parked`, which is what
490
+ * {@link OrdersModule.park} is for.
491
+ * - `HOOK_REJECTED` (`HookRejectedError`) — an app the store installed refused
492
+ * the order through its `order.validate` hook, whatever `transitionTo` is
493
+ * (a Draft is asked too). `appSlug`, `appCode` and `customerMessage` (the
494
+ * app's own sentence) are typed on the error; `details` names the lines or
495
+ * fields it pointed at. Nothing is created.
496
+ * - `HOOK_UNAVAILABLE` (`HookUnavailableError`) — such an app could not be
497
+ * asked (timeout, failure, or suspended after repeated failures), and the
498
+ * order is refused rather than placed unchecked. Not retried automatically;
499
+ * the same `idempotencyKey` may be retried once the app answers again. With
500
+ * `transitionTo: 'ArrangingPayment'` the store's tax provider app answers it
501
+ * too when it cannot be asked (`details[1]` is `kind` / `tax.calculate`).
502
+ * - `TAX_CHANGED` (`ConflictError`) — with `transitionTo: 'ArrangingPayment'`,
503
+ * the store's tax provider app answered different tax while the order was
504
+ * being placed. Nothing is created; repeat the same call (same
505
+ * `idempotencyKey`): the repeat composes the order afresh at the provider's
506
+ * current tax.
507
+ *
508
+ * @param input the whole order. Money is integer minor units throughout.
509
+ * @param options must carry `idempotencyKey`; the engine declares it non-null.
510
+ */
511
+ createOrRecover(input: ExternalOrderInput, options: ExternalOrderCall): Promise<ExternalOrder>;
512
+ /**
513
+ * The order this store filed under `externalRef`, or null. Needs `ReadOrder`.
514
+ *
515
+ * The recovery read that never expires, and the one to reach for after an
516
+ * `EXTERNAL_REF_CONFLICT` or a lost response. Channel-scoped twice over, so a
517
+ * ref that names another store's order reads as null rather than leaking that
518
+ * it exists.
519
+ *
520
+ * Null means this store has nothing under that ref — it is not an error, and a
521
+ * caller that treats it as one will retry a ref it never successfully posted.
522
+ */
523
+ byExternalRef(externalRef: string, options?: Call): Promise<ExternalOrder | null>;
524
+ /**
525
+ * The order a previous {@link OrderEntryModule.createOrRecover} created under
526
+ * this idempotency key, or null. Needs `ReadOrder`.
527
+ *
528
+ * Null once the key's 24-hour window has passed and the record is swept — a
529
+ * caller that waited that long has the `externalRef`, which does not expire.
530
+ * Null is also what another tenant's or another principal's key gets: the key
531
+ * is scoped to `(channel, principal, key)`, never global.
532
+ *
533
+ * So null here is NEVER proof that no order was created. Fall back to
534
+ * {@link OrderEntryModule.byExternalRef} before deciding to post again.
535
+ */
536
+ byIdempotencyKey(key: string, options?: Call): Promise<ExternalOrder | null>;
537
+ }
538
+ export declare const CREATE_OR_RECOVER_ORDER_MUTATION = "\n mutation CreateOrRecoverOrder($input: ExternalOrderInput!, $idempotencyKey: String!) {\n createOrRecoverOrder(input: $input, idempotencyKey: $idempotencyKey) {\n \n id\n code\n state\n currencyCode\n subTotal\n subTotalWithTax\n total\n totalWithTax\n lines {\n id\n quantity\n unitPrice\n unitPriceWithTax\n linePrice\n linePriceWithTax\n taxLines {\n description\n taxRate\n }\n productVariant {\n id\n sku\n name\n }\n customFields {\n externalEntryPosition\n externalEntryKey\n externalLineLabel\n }\n }\n surcharges {\n id\n description\n sku\n price\n priceWithTax\n taxRate\n }\n customFields {\n externalRef\n }\n\n }\n }\n";
539
+ export declare const ORDER_BY_EXTERNAL_REF_QUERY = "\n query OrderByExternalRef($externalRef: String!) {\n orderByExternalRef(externalRef: $externalRef) {\n \n id\n code\n state\n currencyCode\n subTotal\n subTotalWithTax\n total\n totalWithTax\n lines {\n id\n quantity\n unitPrice\n unitPriceWithTax\n linePrice\n linePriceWithTax\n taxLines {\n description\n taxRate\n }\n productVariant {\n id\n sku\n name\n }\n customFields {\n externalEntryPosition\n externalEntryKey\n externalLineLabel\n }\n }\n surcharges {\n id\n description\n sku\n price\n priceWithTax\n taxRate\n }\n customFields {\n externalRef\n }\n\n }\n }\n";
540
+ export declare const ORDER_BY_IDEMPOTENCY_KEY_QUERY = "\n query OrderByIdempotencyKey($key: String!) {\n orderByIdempotencyKey(key: $key) {\n \n id\n code\n state\n currencyCode\n subTotal\n subTotalWithTax\n total\n totalWithTax\n lines {\n id\n quantity\n unitPrice\n unitPriceWithTax\n linePrice\n linePriceWithTax\n taxLines {\n description\n taxRate\n }\n productVariant {\n id\n sku\n name\n }\n customFields {\n externalEntryPosition\n externalEntryKey\n externalLineLabel\n }\n }\n surcharges {\n id\n description\n sku\n price\n priceWithTax\n taxRate\n }\n customFields {\n externalRef\n }\n\n }\n }\n";
541
+ /** The wire shape of one line: exactly one of the two members set. */
542
+ interface WireLine {
543
+ catalog?: Omit<ExternalOrderCatalogLine, 'kind'>;
544
+ external?: Omit<ExternalOrderExternalLine, 'kind'>;
545
+ }
546
+ /**
547
+ * The SDK's discriminated line → the wrapper member the SDL declares.
548
+ *
549
+ * `kind` is stripped rather than sent: it is not a field of either input type,
550
+ * and the Admin API runs `forbidNonWhitelisted`-equivalent GraphQL input
551
+ * coercion, so leaving it on would 400 the whole document.
552
+ *
553
+ * Every other key is copied ACROSS, never rebuilt field by field: `configuration`
554
+ * is the caller's own JSON and must reach the engine byte-for-byte, and a
555
+ * hand-written field list would also silently drop a field added to the input
556
+ * type later. Nothing on this path converts case — see
557
+ * {@link ExternalOrderExternalLine.configuration}.
558
+ *
559
+ * An absent optional stays ABSENT rather than becoming an explicit null:
560
+ * `JSON.stringify` drops `undefined`, and the engine's request fingerprint is
561
+ * taken from the raw wire arguments, so coercing one to null here would make two
562
+ * identical requests look different to the idempotency store.
563
+ */
564
+ export declare function toWireLine(line: ExternalOrderLineInput): WireLine;
565
+ export declare function createOrderEntryModule(transport: Transport): OrderEntryModule;
566
+ export {};