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