@sixtyninecommerce/admin 0.7.0 → 0.9.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 +2445 -17
- package/dist/api-tokens/index.d.ts +15 -5
- package/dist/api-tokens/index.js +1 -0
- package/dist/apps/event-subscription.d.ts +59 -0
- package/dist/apps/event-subscription.js +32 -0
- package/dist/apps/hook-secret.d.ts +22 -0
- package/dist/apps/hook-secret.js +36 -0
- package/dist/apps/index.d.ts +54 -3
- package/dist/apps/index.js +17 -0
- package/dist/audit/index.d.ts +7 -0
- package/dist/auth/queries.d.ts +5 -1
- package/dist/auth/queries.js +6 -0
- package/dist/bulk/index.d.ts +323 -0
- package/dist/bulk/index.js +162 -0
- package/dist/catalog/assets.d.ts +147 -0
- package/dist/catalog/assets.js +164 -0
- package/dist/catalog/collections.d.ts +109 -0
- package/dist/catalog/collections.js +91 -0
- package/dist/catalog/facets.d.ts +103 -0
- package/dist/catalog/facets.js +100 -0
- package/dist/catalog/index.d.ts +115 -0
- package/dist/catalog/index.js +21 -0
- package/dist/catalog/options.d.ts +89 -0
- package/dist/catalog/options.js +88 -0
- package/dist/catalog/products-bulk.d.ts +21 -0
- package/dist/catalog/products-bulk.js +58 -0
- package/dist/catalog/products.d.ts +489 -0
- package/dist/catalog/products.js +365 -0
- package/dist/catalog/properties.d.ts +234 -0
- package/dist/catalog/properties.js +158 -0
- package/dist/catalog/types.d.ts +174 -0
- package/dist/catalog/types.js +141 -0
- package/dist/catalog/variants.d.ts +274 -0
- package/dist/catalog/variants.js +258 -0
- package/dist/catalog/visibility.d.ts +57 -0
- package/dist/catalog/visibility.js +59 -0
- package/dist/client.d.ts +171 -3
- package/dist/client.js +81 -12
- package/dist/compliance/index.d.ts +88 -0
- package/dist/compliance/index.js +88 -0
- package/dist/customer-data-redaction.d.ts +14 -0
- package/dist/customer-data-redaction.js +22 -0
- package/dist/customers/index.d.ts +428 -17
- package/dist/customers/index.js +322 -15
- package/dist/documents/index.d.ts +513 -16
- package/dist/documents/index.js +229 -3
- package/dist/events/index.d.ts +259 -0
- package/dist/events/index.js +147 -0
- package/dist/feeds/ai.d.ts +46 -0
- package/dist/feeds/ai.js +43 -0
- package/dist/feeds/categories.d.ts +50 -0
- package/dist/feeds/categories.js +56 -0
- package/dist/feeds/configs.d.ts +54 -0
- package/dist/feeds/configs.js +85 -0
- package/dist/feeds/identifier-fields.d.ts +25 -0
- package/dist/feeds/identifier-fields.js +29 -0
- package/dist/feeds/index.d.ts +54 -0
- package/dist/feeds/index.js +46 -0
- package/dist/feeds/preserve.d.ts +38 -0
- package/dist/feeds/preserve.js +74 -0
- package/dist/feeds/rules.d.ts +42 -0
- package/dist/feeds/rules.js +56 -0
- package/dist/feeds/types.d.ts +654 -0
- package/dist/feeds/types.js +135 -0
- package/dist/fulfillments/index.d.ts +360 -0
- package/dist/fulfillments/index.js +425 -0
- package/dist/heads/index.d.ts +60 -0
- package/dist/heads/index.js +45 -0
- package/dist/hooks/assignments.d.ts +90 -0
- package/dist/hooks/assignments.js +53 -0
- package/dist/hooks/index.d.ts +97 -0
- package/dist/hooks/index.js +76 -0
- package/dist/index.d.ts +84 -9
- package/dist/index.js +16 -1
- package/dist/jobs/bulk-action-run.d.ts +65 -0
- package/dist/jobs/bulk-action-run.js +70 -0
- package/dist/locations/index.d.ts +6 -2
- package/dist/meta/index.d.ts +32 -0
- package/dist/orders/commit-edit.d.ts +123 -0
- package/dist/orders/commit-edit.js +142 -0
- package/dist/orders/get.d.ts +722 -0
- package/dist/orders/get.js +530 -0
- package/dist/orders/index.d.ts +105 -20
- package/dist/orders/index.js +44 -0
- package/dist/orders/line-price-preview.d.ts +297 -0
- package/dist/orders/line-price-preview.js +50 -0
- package/dist/orders/manual-discounts.d.ts +132 -0
- package/dist/orders/manual-discounts.js +95 -0
- package/dist/orders/manual-pricing.d.ts +192 -0
- package/dist/orders/manual-pricing.js +72 -0
- package/dist/orders/order-entry.d.ts +566 -0
- package/dist/orders/order-entry.js +129 -0
- package/dist/orders/parcel-charge.d.ts +45 -0
- package/dist/orders/parcel-charge.js +55 -0
- package/dist/orders/plan-edit.d.ts +489 -0
- package/dist/orders/plan-edit.js +93 -0
- package/dist/orders/status.d.ts +235 -0
- package/dist/orders/status.js +96 -0
- package/dist/orders/surcharges.d.ts +75 -2
- package/dist/orders/surcharges.js +110 -4
- package/dist/payments/account-credit.d.ts +171 -0
- package/dist/payments/account-credit.js +107 -0
- package/dist/payments/index.d.ts +368 -2
- package/dist/payments/index.js +138 -0
- package/dist/platform/catalog.d.ts +148 -0
- package/dist/platform/catalog.js +74 -0
- package/dist/platform/entitlements.d.ts +111 -0
- package/dist/platform/entitlements.js +86 -0
- package/dist/platform/legal-entities.d.ts +139 -0
- package/dist/platform/legal-entities.js +126 -0
- package/dist/platform/legal-entity-numbering.d.ts +103 -0
- package/dist/platform/legal-entity-numbering.js +101 -0
- package/dist/platform/organization-membership.d.ts +80 -0
- package/dist/platform/organization-membership.js +71 -0
- package/dist/platform/organization-settings.d.ts +33 -0
- package/dist/platform/organization-settings.js +42 -0
- package/dist/platform/organization-sharing.d.ts +172 -0
- package/dist/platform/organization-sharing.js +120 -0
- package/dist/platform/organizations.d.ts +205 -0
- package/dist/platform/organizations.js +180 -0
- package/dist/platform/provision-store.d.ts +88 -8
- package/dist/platform/provision-store.js +12 -0
- package/dist/platform/reports.d.ts +46 -0
- package/dist/platform/reports.js +31 -0
- package/dist/platform/server-metrics.d.ts +58 -0
- package/dist/platform/server-metrics.js +11 -0
- package/dist/pos/index.d.ts +567 -0
- package/dist/pos/index.js +205 -0
- package/dist/pricing/index.d.ts +405 -0
- package/dist/pricing/index.js +351 -0
- package/dist/provenance/index.d.ts +93 -0
- package/dist/provenance/index.js +53 -0
- package/dist/reports/index.d.ts +199 -0
- package/dist/reports/index.js +154 -0
- package/dist/shipping/parcel-count-suggestion.d.ts +52 -0
- package/dist/shipping/parcel-count-suggestion.js +73 -0
- package/dist/shipping/parcel-rule.d.ts +48 -0
- package/dist/shipping/parcel-rule.js +91 -0
- package/dist/stock/index.d.ts +166 -0
- package/dist/stock/index.js +115 -0
- package/dist/stock/transfers.d.ts +520 -0
- package/dist/stock/transfers.js +437 -0
- package/dist/stored-value/index.d.ts +154 -0
- package/dist/stored-value/index.js +130 -0
- package/dist/tenant/capabilities.d.ts +10 -0
- package/dist/tenant/entitlements.d.ts +35 -0
- package/dist/tenant/entitlements.js +15 -0
- package/dist/tenant/field-groups.d.ts +64 -0
- package/dist/tenant/field-groups.js +34 -0
- package/dist/tenant/legal-entity.d.ts +32 -0
- package/dist/tenant/legal-entity.js +41 -0
- package/dist/tenant/notifications.d.ts +148 -0
- package/dist/tenant/notifications.js +79 -0
- package/dist/tenant/retention.d.ts +10 -4
- package/dist/tenant/settings-sources.d.ts +103 -0
- package/dist/tenant/settings-sources.js +92 -0
- package/dist/types.d.ts +86 -11
- package/dist/uploads/index.d.ts +11 -7
- package/dist/users/index.d.ts +104 -0
- package/dist/users/index.js +80 -0
- package/package.json +3 -2
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `admin.orders.get(orderId)`: one order, typed (headless spec §9.2 `orders`
|
|
3
|
+
* "read", plan W9-9).
|
|
4
|
+
*
|
|
5
|
+
* The read has two layers. The CORE is what the engine itself serves for an
|
|
6
|
+
* order, and it is all a call without `include` asks for. Around it sit the
|
|
7
|
+
* blocks a plugin adds to an order (payment terms, delivery terms, the order's
|
|
8
|
+
* own price list, the ERP and carrier references). Each is asked for by name
|
|
9
|
+
* in `include`, so a caller reads only what it uses, and the core document
|
|
10
|
+
* names no field an engine without that plugin lacks.
|
|
11
|
+
*
|
|
12
|
+
* Money is an integer in minor units of the order's currency, with three
|
|
13
|
+
* exceptions that are NOT converted to it: a line's `productVariant.price` and
|
|
14
|
+
* `priceWithTax` (the catalogue price in the currency of the request, which is
|
|
15
|
+
* the store's default unless the call names another), and a line's
|
|
16
|
+
* `customFields.cost` (the store's default currency). An instant is an ISO-8601
|
|
17
|
+
* string with its offset.
|
|
18
|
+
*/
|
|
19
|
+
import { ValidationError } from '@sixtyninecommerce/core';
|
|
20
|
+
import { redactionWatcher } from '../customer-data-redaction.js';
|
|
21
|
+
/**
|
|
22
|
+
* The blocks a plugin adds to an order, in the order the document lists them.
|
|
23
|
+
*
|
|
24
|
+
* - `paymentTerms`: the payment terms the order was placed under, and the
|
|
25
|
+
* order's own override of them (the B2B credit plugin).
|
|
26
|
+
* - `deliveryTerms`: the delivery terms accepted at placement (the shipping
|
|
27
|
+
* calculator plugin).
|
|
28
|
+
* - `priceList`: the order's own price list, which is its one-time pricing
|
|
29
|
+
* (the price-list plugin).
|
|
30
|
+
* - `lineAllocations`: each line's raw allocation rows (the stock-transfer
|
|
31
|
+
* plugin). They never decrement: `OrderLine.outstandingAllocations` is what a
|
|
32
|
+
* line reserves now, and needs no include.
|
|
33
|
+
* - `fulfillmentDetails`: each fulfillment's handler (code, name, its detail
|
|
34
|
+
* rows) and packing slips (the order-documents plugin).
|
|
35
|
+
* - `vatValidation`: the customer's VAT number and its validation status (the
|
|
36
|
+
* VAT-validation plugin).
|
|
37
|
+
* - `afas`, `parasut`: the references those ERP plugins keep on the order, its
|
|
38
|
+
* customer and the customer's addresses.
|
|
39
|
+
* - `myparcel`: the MyParcel shipment and label state on each fulfillment.
|
|
40
|
+
*/
|
|
41
|
+
export const ORDER_INCLUDES = [
|
|
42
|
+
'paymentTerms',
|
|
43
|
+
'deliveryTerms',
|
|
44
|
+
'priceList',
|
|
45
|
+
'lineAllocations',
|
|
46
|
+
'fulfillmentDetails',
|
|
47
|
+
'vatValidation',
|
|
48
|
+
'afas',
|
|
49
|
+
'parasut',
|
|
50
|
+
'myparcel',
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* The order document with EVERY block, written out whole.
|
|
54
|
+
*
|
|
55
|
+
* One static literal on purpose. The repository's GraphQL cost guard
|
|
56
|
+
* (`services/vendure/src/rate-limit/__tests__/graphql-cost-fits-repo.spec.ts`)
|
|
57
|
+
* measures every document this package holds against the engine's caps, and it
|
|
58
|
+
* can only read a literal. This is the largest operation the dashboard sends,
|
|
59
|
+
* so it has to be the one that is measured: do not assemble it at run time.
|
|
60
|
+
*
|
|
61
|
+
* A block's fields sit between a `#[name` line and its `#]` line. Both are
|
|
62
|
+
* GraphQL comments, so the literal parses as it stands. `orderQuery` keeps a
|
|
63
|
+
* marked part when the call included the block, drops it otherwise, and drops
|
|
64
|
+
* the marker lines either way. `#[a|b` marks a part that is kept when ANY of
|
|
65
|
+
* the named blocks is included: an object whose every field belongs to a block
|
|
66
|
+
* (an empty selection is not valid GraphQL).
|
|
67
|
+
*/
|
|
68
|
+
export const ORDER_QUERY_EVERY_BLOCK = /* GraphQL */ `
|
|
69
|
+
query Order($id: ID!) {
|
|
70
|
+
order(id: $id) {
|
|
71
|
+
id
|
|
72
|
+
code
|
|
73
|
+
state
|
|
74
|
+
active
|
|
75
|
+
total
|
|
76
|
+
totalWithTax
|
|
77
|
+
subTotal
|
|
78
|
+
subTotalWithTax
|
|
79
|
+
shipping
|
|
80
|
+
shippingWithTax
|
|
81
|
+
currencyCode
|
|
82
|
+
orderPlacedAt
|
|
83
|
+
#[paymentTerms
|
|
84
|
+
paymentTerms {
|
|
85
|
+
source
|
|
86
|
+
managedExternally
|
|
87
|
+
status
|
|
88
|
+
conditionCode
|
|
89
|
+
conditionDescription
|
|
90
|
+
summary
|
|
91
|
+
classification
|
|
92
|
+
paymentDays
|
|
93
|
+
paymentEndOfMonths
|
|
94
|
+
paymentMethod
|
|
95
|
+
percentage
|
|
96
|
+
discountPaymentDays
|
|
97
|
+
discountPercentage
|
|
98
|
+
paymentDiscountType
|
|
99
|
+
stale
|
|
100
|
+
syncedAt
|
|
101
|
+
error
|
|
102
|
+
resolvedAt
|
|
103
|
+
remoteConditionCode
|
|
104
|
+
remoteConfirmedAt
|
|
105
|
+
remoteMismatch
|
|
106
|
+
}
|
|
107
|
+
#]
|
|
108
|
+
#[deliveryTerms
|
|
109
|
+
deliveryTerms {
|
|
110
|
+
source
|
|
111
|
+
sourceScope
|
|
112
|
+
governingCustomerId
|
|
113
|
+
sourceCustomerId
|
|
114
|
+
managedExternally
|
|
115
|
+
status
|
|
116
|
+
shippingMethodStatus
|
|
117
|
+
policyStatus
|
|
118
|
+
summary
|
|
119
|
+
selectionSource
|
|
120
|
+
selectedShippingMethodId
|
|
121
|
+
selectedShippingMethodCode
|
|
122
|
+
selectedShippingMethodName
|
|
123
|
+
platformShippingMethodCode
|
|
124
|
+
platformShippingMethodName
|
|
125
|
+
platformShippingMethodDescription
|
|
126
|
+
platformShippingPrice
|
|
127
|
+
platformShippingPriceWithTax
|
|
128
|
+
preferredShippingMethodId
|
|
129
|
+
incotermStatus
|
|
130
|
+
incotermCode
|
|
131
|
+
incotermVersion
|
|
132
|
+
incotermAddress
|
|
133
|
+
incotermDescription
|
|
134
|
+
shippingLeadDays
|
|
135
|
+
deliveryAdvice
|
|
136
|
+
stale
|
|
137
|
+
syncedAt
|
|
138
|
+
warning
|
|
139
|
+
resolvedAt
|
|
140
|
+
remoteShippingMethodCode
|
|
141
|
+
remoteShippingMethodName
|
|
142
|
+
remoteIncotermCode
|
|
143
|
+
remoteIncotermVersion
|
|
144
|
+
remoteIncotermAddress
|
|
145
|
+
remoteDeliveryDate
|
|
146
|
+
remoteConfirmedAt
|
|
147
|
+
remoteMismatch
|
|
148
|
+
}
|
|
149
|
+
#]
|
|
150
|
+
couponCodes
|
|
151
|
+
customer {
|
|
152
|
+
id
|
|
153
|
+
firstName
|
|
154
|
+
lastName
|
|
155
|
+
emailAddress
|
|
156
|
+
phoneNumber
|
|
157
|
+
#[vatValidation|afas|parasut
|
|
158
|
+
customFields {
|
|
159
|
+
#[vatValidation
|
|
160
|
+
vatNumber
|
|
161
|
+
vatValidationStatus
|
|
162
|
+
#]
|
|
163
|
+
#[afas
|
|
164
|
+
afasVrId
|
|
165
|
+
afasOrgId
|
|
166
|
+
afasContactId
|
|
167
|
+
afasPersId
|
|
168
|
+
#]
|
|
169
|
+
#[parasut
|
|
170
|
+
parasutContactId
|
|
171
|
+
#]
|
|
172
|
+
}
|
|
173
|
+
#]
|
|
174
|
+
addresses {
|
|
175
|
+
id
|
|
176
|
+
fullName
|
|
177
|
+
company
|
|
178
|
+
streetLine1
|
|
179
|
+
streetLine2
|
|
180
|
+
city
|
|
181
|
+
postalCode
|
|
182
|
+
country {
|
|
183
|
+
code
|
|
184
|
+
}
|
|
185
|
+
defaultShippingAddress
|
|
186
|
+
defaultBillingAddress
|
|
187
|
+
#[afas
|
|
188
|
+
customFields {
|
|
189
|
+
afasAddressId
|
|
190
|
+
}
|
|
191
|
+
#]
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
lines {
|
|
195
|
+
id
|
|
196
|
+
quantity
|
|
197
|
+
unitPrice
|
|
198
|
+
unitPriceWithTax
|
|
199
|
+
listPriceIncludesTax
|
|
200
|
+
discountedUnitPrice
|
|
201
|
+
discountedUnitPriceWithTax
|
|
202
|
+
linePrice
|
|
203
|
+
linePriceWithTax
|
|
204
|
+
discountedLinePrice
|
|
205
|
+
discountedLinePriceWithTax
|
|
206
|
+
proratedLinePrice
|
|
207
|
+
proratedLinePriceWithTax
|
|
208
|
+
taxRate
|
|
209
|
+
productVariant {
|
|
210
|
+
id
|
|
211
|
+
name
|
|
212
|
+
sku
|
|
213
|
+
price
|
|
214
|
+
priceWithTax
|
|
215
|
+
stockOnHand
|
|
216
|
+
stockAllocated
|
|
217
|
+
trackInventory
|
|
218
|
+
outOfStockThreshold
|
|
219
|
+
useGlobalOutOfStockThreshold
|
|
220
|
+
stockLevels {
|
|
221
|
+
stockLocationId
|
|
222
|
+
stockOnHand
|
|
223
|
+
stockAllocated
|
|
224
|
+
stockLocation {
|
|
225
|
+
id
|
|
226
|
+
name
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
product {
|
|
230
|
+
id
|
|
231
|
+
name
|
|
232
|
+
featuredAsset {
|
|
233
|
+
id
|
|
234
|
+
preview
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
featuredAsset {
|
|
239
|
+
id
|
|
240
|
+
preview
|
|
241
|
+
}
|
|
242
|
+
#[lineAllocations
|
|
243
|
+
allocations {
|
|
244
|
+
id
|
|
245
|
+
stockLocation {
|
|
246
|
+
id
|
|
247
|
+
name
|
|
248
|
+
}
|
|
249
|
+
quantity
|
|
250
|
+
}
|
|
251
|
+
#]
|
|
252
|
+
outstandingAllocatedQuantity
|
|
253
|
+
outstandingAllocations {
|
|
254
|
+
stockLocationId
|
|
255
|
+
stockLocationName
|
|
256
|
+
quantity
|
|
257
|
+
}
|
|
258
|
+
customFields {
|
|
259
|
+
unitPriceOverride
|
|
260
|
+
priceOverrideReason
|
|
261
|
+
unitPriceImported
|
|
262
|
+
priceListId
|
|
263
|
+
priceListName
|
|
264
|
+
retailPrice
|
|
265
|
+
priceListPrice
|
|
266
|
+
priceListDiscountType
|
|
267
|
+
priceListDiscountValue
|
|
268
|
+
priceListDiscountChain
|
|
269
|
+
cost
|
|
270
|
+
preferredStockLocationId
|
|
271
|
+
backorderedQuantity
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
surcharges {
|
|
275
|
+
id
|
|
276
|
+
description
|
|
277
|
+
sku
|
|
278
|
+
price
|
|
279
|
+
priceWithTax
|
|
280
|
+
taxRate
|
|
281
|
+
}
|
|
282
|
+
discounts {
|
|
283
|
+
description
|
|
284
|
+
amount
|
|
285
|
+
amountWithTax
|
|
286
|
+
}
|
|
287
|
+
shippingLines {
|
|
288
|
+
shippingMethod {
|
|
289
|
+
id
|
|
290
|
+
name
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
payments {
|
|
294
|
+
id
|
|
295
|
+
state
|
|
296
|
+
method
|
|
297
|
+
amount
|
|
298
|
+
transactionId
|
|
299
|
+
createdAt
|
|
300
|
+
refunds {
|
|
301
|
+
id
|
|
302
|
+
state
|
|
303
|
+
total
|
|
304
|
+
reason
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
fulfillments {
|
|
308
|
+
id
|
|
309
|
+
state
|
|
310
|
+
nextStates
|
|
311
|
+
method
|
|
312
|
+
trackingCode
|
|
313
|
+
lines {
|
|
314
|
+
orderLineId
|
|
315
|
+
quantity
|
|
316
|
+
}
|
|
317
|
+
#[fulfillmentDetails
|
|
318
|
+
handlerCode
|
|
319
|
+
handlerName
|
|
320
|
+
handlerDetails {
|
|
321
|
+
label
|
|
322
|
+
value
|
|
323
|
+
}
|
|
324
|
+
packingSlips {
|
|
325
|
+
id
|
|
326
|
+
packingSlipNumber
|
|
327
|
+
fulfillmentId
|
|
328
|
+
languageCode
|
|
329
|
+
storageKey
|
|
330
|
+
createdAt
|
|
331
|
+
}
|
|
332
|
+
#]
|
|
333
|
+
stockLocationName
|
|
334
|
+
linkedOrders {
|
|
335
|
+
id
|
|
336
|
+
code
|
|
337
|
+
}
|
|
338
|
+
customFields {
|
|
339
|
+
#[myparcel
|
|
340
|
+
myparcelShipmentId
|
|
341
|
+
myparcelLabelStatus
|
|
342
|
+
myparcelLabelFormat
|
|
343
|
+
myparcelLabelUrlA4
|
|
344
|
+
myparcelLabelUrlA6
|
|
345
|
+
myparcelLabelLastError
|
|
346
|
+
myparcelLabelHandoff
|
|
347
|
+
#]
|
|
348
|
+
bookingStatus
|
|
349
|
+
}
|
|
350
|
+
createdAt
|
|
351
|
+
}
|
|
352
|
+
shippingAddress {
|
|
353
|
+
fullName
|
|
354
|
+
company
|
|
355
|
+
streetLine1
|
|
356
|
+
streetLine2
|
|
357
|
+
city
|
|
358
|
+
province
|
|
359
|
+
postalCode
|
|
360
|
+
country
|
|
361
|
+
countryCode
|
|
362
|
+
phoneNumber
|
|
363
|
+
}
|
|
364
|
+
billingAddress {
|
|
365
|
+
fullName
|
|
366
|
+
company
|
|
367
|
+
streetLine1
|
|
368
|
+
streetLine2
|
|
369
|
+
city
|
|
370
|
+
province
|
|
371
|
+
postalCode
|
|
372
|
+
country
|
|
373
|
+
countryCode
|
|
374
|
+
phoneNumber
|
|
375
|
+
}
|
|
376
|
+
history(options: { take: 50, sort: { createdAt: DESC } }) {
|
|
377
|
+
items {
|
|
378
|
+
id
|
|
379
|
+
type
|
|
380
|
+
data
|
|
381
|
+
createdAt
|
|
382
|
+
isPublic
|
|
383
|
+
administrator {
|
|
384
|
+
id
|
|
385
|
+
firstName
|
|
386
|
+
lastName
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
taxSummary {
|
|
391
|
+
description
|
|
392
|
+
taxRate
|
|
393
|
+
taxBase
|
|
394
|
+
taxTotal
|
|
395
|
+
}
|
|
396
|
+
nextStates
|
|
397
|
+
createdAt
|
|
398
|
+
updatedAt
|
|
399
|
+
customFields {
|
|
400
|
+
isLocked
|
|
401
|
+
externalOrderId
|
|
402
|
+
externalPlatform
|
|
403
|
+
sourceFulfillmentHandedOff
|
|
404
|
+
originalPlacedAt
|
|
405
|
+
sourceWarehouse
|
|
406
|
+
pickupLocation
|
|
407
|
+
allocationExpiresAt
|
|
408
|
+
goodwillRoundingMinor
|
|
409
|
+
removeTax
|
|
410
|
+
isGift
|
|
411
|
+
giftNote
|
|
412
|
+
hidePricesOnPackingSlip
|
|
413
|
+
poNumber
|
|
414
|
+
requestedDeliveryDate
|
|
415
|
+
orderNotes
|
|
416
|
+
customerShippingAddressId
|
|
417
|
+
customerBillingAddressId
|
|
418
|
+
shippingAddressIsTemporary
|
|
419
|
+
billingAddressIsTemporary
|
|
420
|
+
paymentStatus
|
|
421
|
+
fulfillmentStatus
|
|
422
|
+
returnStatus
|
|
423
|
+
lifecycleStatus
|
|
424
|
+
#[paymentTerms
|
|
425
|
+
paymentTermsDays
|
|
426
|
+
paymentConditionCode
|
|
427
|
+
#]
|
|
428
|
+
#[afas
|
|
429
|
+
afasSalesOrderId
|
|
430
|
+
afasDirectInvoiceOrNu
|
|
431
|
+
afasInvoiceNumber
|
|
432
|
+
afasInvoiceDate
|
|
433
|
+
afasLocked
|
|
434
|
+
afasLockReason
|
|
435
|
+
afasLastSyncAt
|
|
436
|
+
#]
|
|
437
|
+
#[parasut
|
|
438
|
+
parasutInvoiceId
|
|
439
|
+
parasutEInvoiceStatus
|
|
440
|
+
parasutEInvoiceUuid
|
|
441
|
+
parasutLastError
|
|
442
|
+
#]
|
|
443
|
+
}
|
|
444
|
+
fulfillmentHold {
|
|
445
|
+
reason
|
|
446
|
+
note
|
|
447
|
+
heldAt
|
|
448
|
+
heldByUserId
|
|
449
|
+
heldBy
|
|
450
|
+
}
|
|
451
|
+
#[priceList
|
|
452
|
+
priceList {
|
|
453
|
+
id
|
|
454
|
+
name
|
|
455
|
+
description
|
|
456
|
+
defaultDiscountBps
|
|
457
|
+
defaultDiscountAmount
|
|
458
|
+
entries {
|
|
459
|
+
id
|
|
460
|
+
variantId
|
|
461
|
+
discountType
|
|
462
|
+
discountValue
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
#]
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
`;
|
|
469
|
+
const BLOCK_OPEN = '#[';
|
|
470
|
+
const BLOCK_CLOSE = '#]';
|
|
471
|
+
/**
|
|
472
|
+
* The document `get` sends for a set of blocks: {@link ORDER_QUERY_EVERY_BLOCK}
|
|
473
|
+
* without the blocks the call did not include, and without the marker lines.
|
|
474
|
+
* It depends on the SET only, never on the order the caller listed them in, so
|
|
475
|
+
* one set is one document.
|
|
476
|
+
*/
|
|
477
|
+
export function orderQuery(include = []) {
|
|
478
|
+
const asked = new Set(include);
|
|
479
|
+
const kept = [];
|
|
480
|
+
// One entry per marked part that is open: whether its lines are kept. A part
|
|
481
|
+
// inside a dropped part is dropped whatever it names.
|
|
482
|
+
const open = [];
|
|
483
|
+
for (const line of ORDER_QUERY_EVERY_BLOCK.split('\n')) {
|
|
484
|
+
const text = line.trim();
|
|
485
|
+
const outerKept = open.at(-1) ?? true;
|
|
486
|
+
if (text.startsWith(BLOCK_OPEN)) {
|
|
487
|
+
const names = text.slice(BLOCK_OPEN.length).split('|');
|
|
488
|
+
open.push(outerKept && names.some((name) => asked.has(name)));
|
|
489
|
+
}
|
|
490
|
+
else if (text === BLOCK_CLOSE) {
|
|
491
|
+
open.pop();
|
|
492
|
+
}
|
|
493
|
+
else if (outerKept) {
|
|
494
|
+
kept.push(line);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return kept.join('\n');
|
|
498
|
+
}
|
|
499
|
+
export function createOrderGetModule(transport) {
|
|
500
|
+
async function get(orderId, options) {
|
|
501
|
+
// Typed callers cannot get here wrong. A JavaScript caller can, and an
|
|
502
|
+
// unknown name would otherwise be dropped in silence: the read would
|
|
503
|
+
// answer an order without the block the caller believes it asked for.
|
|
504
|
+
const include = options?.include ?? [];
|
|
505
|
+
const known = (name) => ORDER_INCLUDES.includes(name);
|
|
506
|
+
if (!Array.isArray(include) || !include.every(known)) {
|
|
507
|
+
const given = Array.isArray(include)
|
|
508
|
+
? include.filter((name) => !known(name)).map((name) => `"${String(name)}"`)
|
|
509
|
+
: [String(include)];
|
|
510
|
+
throw new ValidationError({
|
|
511
|
+
code: 'INVALID_ORDER_INCLUDE',
|
|
512
|
+
message: `\`include\` takes a list of an order's blocks, and ${given.join(', ')} is not one. The blocks are: ${ORDER_INCLUDES.join(', ')}.`,
|
|
513
|
+
status: 400,
|
|
514
|
+
service: 'vendure',
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
const redaction = redactionWatcher();
|
|
518
|
+
const data = await transport.graphql({
|
|
519
|
+
api: 'admin',
|
|
520
|
+
query: orderQuery(include),
|
|
521
|
+
variables: { id: orderId },
|
|
522
|
+
onExtensions: redaction.onExtensions,
|
|
523
|
+
}, options);
|
|
524
|
+
return redaction.mark(data.order);
|
|
525
|
+
}
|
|
526
|
+
// The answer holds exactly the blocks asked for; `OrderGetAnswer` decides how
|
|
527
|
+
// many of them the caller's type of the options may rely on. The overloads
|
|
528
|
+
// narrow this one implementation, which TypeScript cannot check for them.
|
|
529
|
+
return { get: get };
|
|
530
|
+
}
|
package/dist/orders/index.d.ts
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Transport } from '@sixtyninecommerce/core';
|
|
2
2
|
import type { OrderPaymentPosition, PaidOrder } from '../payments/index.js';
|
|
3
3
|
import type { Call } from '../types.js';
|
|
4
|
+
import { type OrderCommitEditModule } from './commit-edit.js';
|
|
5
|
+
import { type OrderGetModule } from './get.js';
|
|
6
|
+
import { type OrderLinePricePreviewModule } from './line-price-preview.js';
|
|
7
|
+
import { type ManualDiscountsModule } from './manual-discounts.js';
|
|
8
|
+
import { type OrderManualPricingModule } from './manual-pricing.js';
|
|
9
|
+
import { type OrderEntryModule } from './order-entry.js';
|
|
10
|
+
import { type OrderParcelChargeModule } from './parcel-charge.js';
|
|
11
|
+
import { type OrderPlanEditModule } from './plan-edit.js';
|
|
12
|
+
import { type OrderStatusModule } from './status.js';
|
|
4
13
|
import { type SurchargesModule } from './surcharges.js';
|
|
5
14
|
export type { PaidOrder } from '../payments/index.js';
|
|
15
|
+
export type { DiscountPolicy, DiscountPolicyInput, DiscountPolicyModule, DiscountReason, DiscountReasonInput, DiscountReasonsModule, ManualDiscountsModule, OrderManualDiscount, } from './manual-discounts.js';
|
|
16
|
+
export type { ExternalLinePriceBasis, ExternalOrder, ExternalOrderAddressInput, ExternalOrderCall, ExternalOrderCatalogLine, ExternalOrderExternalLine, ExternalOrderFulfilment, ExternalOrderInput, ExternalOrderLine, ExternalOrderLineInput, ExternalOrderSurcharge, ExternalOrderSurchargeInput, ExternalOrderTargetState, ExternalOrderTaxLine, } from './order-entry.js';
|
|
17
|
+
/** An app provider an order is running without (`admin.orders.providerFallbacks`). */
|
|
18
|
+
export interface OrderProviderFallback {
|
|
19
|
+
/** `shipping.rates` or `tax.calculate`. */
|
|
20
|
+
kind: string;
|
|
21
|
+
installationId: string;
|
|
22
|
+
/**
|
|
23
|
+
* `timeout`, `network`, `tls`, `redirect`, `http_status`, `invalid_response`,
|
|
24
|
+
* `private_host`, `suspended`, `not_configured` — the app could not answer, or
|
|
25
|
+
* was not asked because it is switched off (`suspended`: after 20 failures, or
|
|
26
|
+
* the installation or app suspended) — or one the MERCHANT fixes, not the app
|
|
27
|
+
* vendor:
|
|
28
|
+
* - `tax_class` (`shipping.rates`): the app answered, but the store's tax
|
|
29
|
+
* classes cannot tax any rate it offered; map the class.
|
|
30
|
+
* - `withdrawn` (`tax.calculate`): the store's assigned tax provider no longer
|
|
31
|
+
* declares the hook, or its installation no longer consents to it; approve
|
|
32
|
+
* the app's pending consent, or unassign the provider.
|
|
33
|
+
*
|
|
34
|
+
* Treat an unknown value as "not available": reasons are added over time.
|
|
35
|
+
*/
|
|
36
|
+
reason: string;
|
|
37
|
+
/** ISO-8601 with offset: when the order started running without it. */
|
|
38
|
+
since: string;
|
|
39
|
+
}
|
|
6
40
|
/** The result of settling an order. */
|
|
7
41
|
export interface OrderSettlement {
|
|
8
42
|
order: PaidOrder;
|
|
@@ -21,8 +55,24 @@ export interface OrderSettlement {
|
|
|
21
55
|
* deposit flow: hold an order while the rest of the money is arranged, read
|
|
22
56
|
* what it stands at, and settle it once the money is really there.
|
|
23
57
|
*/
|
|
24
|
-
|
|
58
|
+
/**
|
|
59
|
+
* `OrderEntryModule`'s three methods sit DIRECTLY on `admin.orders` rather than
|
|
60
|
+
* under a nested namespace: composing an order and recovering it are order
|
|
61
|
+
* operations, not a sub-resource, and `admin.orders.byExternalRef(ref)` is the
|
|
62
|
+
* sentence a vertical's own code wants to write.
|
|
63
|
+
*
|
|
64
|
+
* The manual pricing doors (`setLinePrices`, `setOneTimeDiscounts`) sit there too, beside their
|
|
65
|
+
* read twin `previewLinePrices`, which prices the same changes without saving them.
|
|
66
|
+
*/
|
|
67
|
+
export interface OrdersModule extends OrderEntryModule, OrderGetModule, OrderParcelChargeModule, OrderLinePricePreviewModule, OrderManualPricingModule, OrderPlanEditModule, OrderCommitEditModule, OrderStatusModule {
|
|
25
68
|
surcharges: SurchargesModule;
|
|
69
|
+
/**
|
|
70
|
+
* Manual discounts with a reason (incentives spec §4 decision 6): read an order's records,
|
|
71
|
+
* and the store's reason list and policy (`reasons`, `policy`). A discount itself is given
|
|
72
|
+
* through the doors that move the money, each taking a reason code: `setLinePrices` and
|
|
73
|
+
* `setOneTimeDiscounts` on this module.
|
|
74
|
+
*/
|
|
75
|
+
manualDiscounts: ManualDiscountsModule;
|
|
26
76
|
/**
|
|
27
77
|
* Hold a placed order while the rest of its money is arranged. Needs
|
|
28
78
|
* `UpdateOrder`.
|
|
@@ -32,16 +82,21 @@ export interface OrdersModule {
|
|
|
32
82
|
* is off unless a merchant chose it. Refusals carry the order's position:
|
|
33
83
|
* `DEPOSITS_NOT_ENABLED` (the store has not turned deposits on — the default,
|
|
34
84
|
* so this is the first one you will meet), `DEPOSIT_REQUIRED` (nothing paid,
|
|
35
|
-
* and the store does not allow that), `DEPOSIT_BELOW_MINIMUM
|
|
36
|
-
*
|
|
37
|
-
*
|
|
85
|
+
* and the store does not allow that), `DEPOSIT_BELOW_MINIMUM` (the minimum is
|
|
86
|
+
* set in the store's default currency and converted into the order's),
|
|
87
|
+
* `EXCHANGE_RATE_UNAVAILABLE` (no exchange rate to convert it into the
|
|
88
|
+
* order's currency),
|
|
89
|
+
* `ORDER_NOT_PARKABLE` (wrong state), `INSUFFICIENT_STOCK` (the goods sold
|
|
90
|
+
* since the order reached payment; `extensions.lines` names each short line),
|
|
91
|
+
* `PARK_REASON_TOO_LONG` (500 characters).
|
|
38
92
|
*
|
|
39
|
-
* Parking
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
93
|
+
* Parking RESERVES the order's stock for the life of the park, without
|
|
94
|
+
* placing the order: no confirmation email, no `order.created`, no ERP push
|
|
95
|
+
* until it settles, and settling does not reserve twice. `unpark` and a
|
|
96
|
+
* cancellation give the stock back. A line's backorder or pre-order part is
|
|
97
|
+
* reserved as it would be at payment. The stock-allocation sweeper leaves a
|
|
98
|
+
* parked order alone, so an expiring allocation TTL cannot cancel an order a
|
|
99
|
+
* customer has already paid a deposit on.
|
|
45
100
|
*/
|
|
46
101
|
park(orderId: string, options?: Call & {
|
|
47
102
|
reason?: string;
|
|
@@ -55,11 +110,16 @@ export interface OrdersModule {
|
|
|
55
110
|
* parked it. `PARK_ORIGIN_UNKNOWN` is the refusal when that history does not
|
|
56
111
|
* say — move such an order on explicitly with a state transition instead.
|
|
57
112
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
113
|
+
* A shopper can pay a parked order's remainder from the storefront
|
|
114
|
+
* (`commerce.payParkedOrder` / `commerce.createParkedOrderPaymentIntent`),
|
|
115
|
+
* and a merchant records it WHERE IT STANDS with `payments.record`; the
|
|
116
|
+
* payment that clears it settles and places the order, keeping the stock the
|
|
117
|
+
* park reserved, without ever leaving `Parked` first. Use this when the order
|
|
118
|
+
* has to be EDITED, which is the one thing it cannot do while held; it gives
|
|
119
|
+
* the park's reserved stock back. On a paid order an installed app held for
|
|
120
|
+
* review it does NOT accept it: the hold goes back to `ArrangingPayment` with the
|
|
121
|
+
* order, and nothing places it until staff accept it with {@link OrdersModule.settle}
|
|
122
|
+
* (or it goes back to the cart and the apps are asked again).
|
|
63
123
|
*
|
|
64
124
|
* It moves no money and changes no payment. Other refusals:
|
|
65
125
|
* `ORDER_NOT_PARKED`, `UNPARK_TRANSITION_REFUSED` (the origin was known and
|
|
@@ -76,10 +136,27 @@ export interface OrdersModule {
|
|
|
76
136
|
* Refuses `COVERAGE_INSUFFICIENT` while the order's SETTLED money does not
|
|
77
137
|
* cover its total, with the position attached. Settled, not covered: an
|
|
78
138
|
* authorization is permission to take money, not money, so an order whose
|
|
79
|
-
* remainder is merely authorized
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
139
|
+
* remainder is merely authorized settles once that authorization is captured
|
|
140
|
+
* where it stands (`settlePayment` on the Admin API): the capture settles it,
|
|
141
|
+
* out of a park included, and a parked order never goes back to
|
|
142
|
+
* `ArrangingPayment` for it (that is {@link OrdersModule.unpark}, which gives
|
|
143
|
+
* the reserved stock back). `ORDER_NOT_SETTLEABLE` is the other refusal — a
|
|
144
|
+
* state a settlement cannot be reached from, which paying more can never fix.
|
|
145
|
+
*
|
|
146
|
+
* This is also how staff ACCEPT a paid order held for review — an installed
|
|
147
|
+
* app refused it after it was paid, or a check an ordinary checkout would have
|
|
148
|
+
* refused it for (it is `Parked`, or `ArrangingPayment` after an un-park or
|
|
149
|
+
* when it could not be parked; `admin.orders.status(orderId).hold` gives the
|
|
150
|
+
* refusal's code, and the app when an app refused). Nothing else settles such an order: money that lands on it meanwhile
|
|
151
|
+
* is recorded and the order stays where it is. A settled one settles here and
|
|
152
|
+
* is placed; one that still owes money is accepted WITHOUT settling — the hold
|
|
153
|
+
* ends and the answer's `order.state` stays where it was (for a parked order,
|
|
154
|
+
* an ordinary part-paid park the shopper can now pay off). One whose balance
|
|
155
|
+
* is covered only by an AUTHORIZED payment owes nothing and is refused
|
|
156
|
+
* `COVERAGE_INSUFFICIENT` with the hold kept: accept it by capturing that
|
|
157
|
+
* payment with `settlePayment`, which settles and places it. To turn the order
|
|
158
|
+
* down, refund the payment, then {@link OrdersModule.unpark} and cancel it: a
|
|
159
|
+
* refund alone leaves it parked, held and holding its stock.
|
|
83
160
|
*
|
|
84
161
|
* Calling this on an order the platform ALREADY settled succeeds rather than
|
|
85
162
|
* refusing. Expect that to be the common case: the engine settles an order as
|
|
@@ -98,6 +175,14 @@ export interface OrdersModule {
|
|
|
98
175
|
settle(orderId: string, options?: Call & {
|
|
99
176
|
fulfil?: boolean;
|
|
100
177
|
}): Promise<OrderSettlement>;
|
|
178
|
+
/**
|
|
179
|
+
* The app providers this order is currently running WITHOUT (spec §15.19): a
|
|
180
|
+
* rates or tax app that could not answer, so the platform's own behaviour was
|
|
181
|
+
* used instead. Empty when none. Needs `ReadOrder`; `ORDER_NOT_FOUND` for an
|
|
182
|
+
* order this store does not have. {@link OrderStatusModule.status} answers
|
|
183
|
+
* the same list beside everything else about the order.
|
|
184
|
+
*/
|
|
185
|
+
providerFallbacks(orderId: string, options?: Call): Promise<OrderProviderFallback[]>;
|
|
101
186
|
}
|
|
102
187
|
export declare const PARK_ORDER_MUTATION = "\n mutation ParkOrder($orderId: ID!, $reason: String, $idempotencyKey: String) {\n parkOrder(orderId: $orderId, reason: $reason, idempotencyKey: $idempotencyKey) {\n id\n code\n state\n currencyCode\n total\n totalWithTax\n }\n }\n";
|
|
103
188
|
export declare const UNPARK_ORDER_MUTATION = "\n mutation UnparkOrder($orderId: ID!, $idempotencyKey: String) {\n unparkOrder(orderId: $orderId, idempotencyKey: $idempotencyKey) {\n id\n code\n state\n currencyCode\n total\n totalWithTax\n }\n }\n";
|