@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.
- package/README.md +2739 -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 +650 -0
- package/dist/catalog/products.js +458 -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 +324 -0
- package/dist/catalog/variants.js +288 -0
- package/dist/catalog/visibility.d.ts +57 -0
- package/dist/catalog/visibility.js +59 -0
- package/dist/client.d.ts +192 -3
- package/dist/client.js +87 -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 +437 -0
- package/dist/fulfillments/index.js +534 -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 +95 -9
- package/dist/index.js +21 -1
- package/dist/integrations/index.d.ts +14 -0
- package/dist/integrations/index.js +9 -0
- package/dist/integrations/pipelines.d.ts +113 -0
- package/dist/integrations/pipelines.js +62 -0
- package/dist/integrations/types.d.ts +176 -0
- package/dist/integrations/types.js +8 -0
- package/dist/jobs/bulk-action-run.d.ts +74 -0
- package/dist/jobs/bulk-action-run.js +69 -0
- package/dist/locations/index.d.ts +6 -2
- package/dist/meta/index.d.ts +32 -0
- package/dist/orders/bulk.d.ts +75 -0
- package/dist/orders/bulk.js +150 -0
- package/dist/orders/commit-edit.d.ts +123 -0
- package/dist/orders/commit-edit.js +142 -0
- package/dist/orders/deposit-policy.d.ts +103 -0
- package/dist/orders/deposit-policy.js +202 -0
- package/dist/orders/get.d.ts +722 -0
- package/dist/orders/get.js +530 -0
- package/dist/orders/index.d.ts +186 -21
- package/dist/orders/index.js +57 -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 +141 -0
- package/dist/orders/manual-discounts.js +97 -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 +241 -9
- package/dist/payments/index.js +92 -0
- package/dist/payments/methods.d.ts +37 -0
- package/dist/payments/methods.js +33 -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 +408 -0
- package/dist/pricing/index.js +353 -0
- package/dist/pricing/vouchers.d.ts +103 -0
- package/dist/pricing/vouchers.js +69 -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/returns/index.d.ts +225 -0
- package/dist/returns/index.js +160 -0
- package/dist/search/index.d.ts +99 -0
- package/dist/search/index.js +62 -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
|
+
}
|