@sixtyninecommerce/admin 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5772 -118
- package/dist/auth/index.d.ts +7 -1
- package/dist/auth/index.js +8 -1
- 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/documents.d.ts +142 -0
- package/dist/catalog/documents.js +114 -0
- package/dist/catalog/index.d.ts +54 -6
- package/dist/catalog/index.js +10 -1
- package/dist/catalog/metadata.d.ts +244 -0
- package/dist/catalog/metadata.js +220 -0
- package/dist/catalog/products.d.ts +159 -19
- package/dist/catalog/products.js +88 -13
- package/dist/catalog/properties.d.ts +140 -14
- package/dist/catalog/properties.js +65 -1
- package/dist/catalog/recommendations.d.ts +288 -0
- package/dist/catalog/recommendations.js +237 -0
- package/dist/catalog/reviews.d.ts +381 -0
- package/dist/catalog/reviews.js +325 -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 +293 -26
- package/dist/catalog/variants.js +164 -7
- package/dist/catalog/visibility.d.ts +38 -7
- package/dist/catalog/visibility.js +19 -1
- package/dist/client.d.ts +121 -9
- package/dist/client.js +53 -14
- package/dist/content/assets.d.ts +285 -0
- package/dist/content/assets.js +181 -0
- package/dist/content/forms.d.ts +332 -1
- package/dist/content/forms.js +140 -4
- package/dist/content/items.d.ts +292 -0
- package/dist/content/items.js +170 -0
- package/dist/content/menus.d.ts +254 -0
- package/dist/content/menus.js +70 -0
- package/dist/content/strings.d.ts +137 -0
- package/dist/content/strings.js +82 -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/delivery-terms.d.ts +44 -0
- package/dist/customers/delivery-terms.js +32 -0
- package/dist/customers/groups.d.ts +207 -0
- package/dist/customers/groups.js +438 -0
- package/dist/customers/index.d.ts +462 -37
- package/dist/customers/index.js +317 -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/emails.d.ts +150 -0
- package/dist/documents/emails.js +220 -0
- package/dist/documents/index.d.ts +744 -21
- package/dist/documents/index.js +438 -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 +163 -11
- package/dist/fulfillments/index.js +135 -6
- 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 +147 -39
- package/dist/index.js +51 -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 +965 -0
- package/dist/integrations/exact-online-types.js +6 -0
- package/dist/integrations/exact-online.d.ts +784 -0
- package/dist/integrations/exact-online.js +1089 -0
- package/dist/integrations/index.d.ts +44 -3
- package/dist/integrations/index.js +23 -3
- package/dist/integrations/pipeline-discoveries.d.ts +65 -0
- package/dist/integrations/pipeline-discoveries.js +65 -0
- package/dist/integrations/pipeline-keys.d.ts +13 -0
- package/dist/integrations/pipeline-keys.js +22 -0
- package/dist/integrations/pipeline-runs.d.ts +119 -0
- package/dist/integrations/pipeline-runs.js +87 -0
- package/dist/integrations/pipelines.d.ts +87 -15
- package/dist/integrations/pipelines.js +41 -22
- package/dist/integrations/price-import.d.ts +223 -0
- package/dist/integrations/price-import.js +124 -0
- package/dist/integrations/types.d.ts +367 -3
- package/dist/integrations/types.js +4 -3
- package/dist/locations/index.d.ts +66 -0
- package/dist/locations/index.js +31 -0
- package/dist/meta/index.d.ts +172 -0
- package/dist/metafields/index.d.ts +8 -1
- package/dist/metafields/index.js +10 -0
- package/dist/orders/cancel-with-money.d.ts +237 -0
- package/dist/orders/cancel-with-money.js +155 -0
- package/dist/orders/commit-edit.d.ts +23 -1
- package/dist/orders/commit-edit.js +19 -2
- package/dist/orders/deposit-policy.d.ts +3 -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 +66 -15
- package/dist/orders/index.js +25 -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 +243 -0
- package/dist/orders/list.js +487 -0
- package/dist/orders/manual-discounts.d.ts +13 -5
- package/dist/orders/manual-pricing.d.ts +5 -0
- package/dist/orders/money-view.d.ts +149 -0
- package/dist/orders/money-view.js +99 -0
- package/dist/orders/order-entry.d.ts +20 -7
- package/dist/orders/plan-edit.d.ts +34 -2
- package/dist/orders/plan-edit.js +112 -11
- 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 +20 -1
- package/dist/orders/surcharges.js +37 -11
- package/dist/payments/account-credit.d.ts +46 -0
- package/dist/payments/account-credit.js +42 -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 +19 -0
- package/dist/payments/credit-noted-fields.js +69 -0
- package/dist/payments/customer-consent.d.ts +30 -0
- package/dist/payments/customer-consent.js +49 -0
- package/dist/payments/index.d.ts +340 -19
- package/dist/payments/index.js +151 -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 +147 -0
- package/dist/payments/requests.js +93 -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 +106 -0
- package/dist/pickups/index.js +108 -0
- package/dist/platform/channels.d.ts +132 -0
- package/dist/platform/channels.js +128 -0
- package/dist/platform/email-gateways.d.ts +165 -0
- package/dist/platform/email-gateways.js +78 -0
- package/dist/platform/geo.d.ts +123 -0
- package/dist/platform/geo.js +144 -0
- package/dist/platform/tax.d.ts +162 -0
- package/dist/platform/tax.js +169 -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 +108 -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 +2370 -58
- package/dist/pos/index.js +854 -7
- package/dist/pos/no-receipt.d.ts +94 -0
- package/dist/pos/no-receipt.js +25 -0
- package/dist/pos/offline-sales.d.ts +228 -0
- package/dist/pos/offline-sales.js +170 -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 +244 -0
- package/dist/pos/returns.js +83 -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 +606 -0
- package/dist/pricing/price-lists.js +600 -0
- package/dist/purchasing/alerts.d.ts +104 -0
- package/dist/purchasing/alerts.js +88 -0
- package/dist/purchasing/backorders.d.ts +61 -0
- package/dist/purchasing/backorders.js +92 -0
- package/dist/purchasing/cost.d.ts +110 -0
- package/dist/purchasing/cost.js +86 -0
- package/dist/purchasing/index.d.ts +54 -0
- package/dist/purchasing/index.js +24 -0
- package/dist/purchasing/links.d.ts +263 -0
- package/dist/purchasing/links.js +192 -0
- package/dist/purchasing/purchase-orders.d.ts +551 -0
- package/dist/purchasing/purchase-orders.js +491 -0
- package/dist/purchasing/receipts.d.ts +396 -0
- package/dist/purchasing/receipts.js +287 -0
- package/dist/purchasing/replenishment.d.ts +281 -0
- package/dist/purchasing/replenishment.js +240 -0
- package/dist/purchasing/returns.d.ts +273 -0
- package/dist/purchasing/returns.js +229 -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 +518 -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 +675 -21
- package/dist/returns/index.js +756 -11
- package/dist/search/index.d.ts +76 -1
- package/dist/search/index.js +63 -0
- package/dist/seo/config.d.ts +128 -0
- package/dist/seo/config.js +95 -0
- package/dist/seo/redirects.d.ts +125 -0
- package/dist/seo/redirects.js +60 -1
- package/dist/seo/settings.d.ts +147 -0
- package/dist/seo/settings.js +209 -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 +54 -0
- package/dist/shipping/index.js +27 -0
- package/dist/shipping/methods.d.ts +205 -0
- package/dist/shipping/methods.js +240 -0
- package/dist/shipping/myparcel.d.ts +668 -0
- package/dist/shipping/myparcel.js +466 -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 +324 -0
- package/dist/shipping/rate-tables.js +390 -0
- package/dist/shipping/ship-to-countries.d.ts +75 -0
- package/dist/shipping/ship-to-countries.js +47 -0
- package/dist/stock/by-location.d.ts +86 -0
- package/dist/stock/by-location.js +94 -0
- package/dist/stock/index.d.ts +18 -4
- package/dist/stock/index.js +7 -0
- package/dist/stock/locations.d.ts +144 -0
- package/dist/stock/locations.js +168 -0
- package/dist/stock/settings.d.ts +106 -0
- package/dist/stock/settings.js +103 -0
- package/dist/stock/transfers.d.ts +386 -52
- package/dist/stock/transfers.js +222 -17
- package/dist/stored-value/index.d.ts +312 -11
- package/dist/stored-value/index.js +223 -4
- package/dist/subscriptions/index.d.ts +682 -0
- package/dist/subscriptions/index.js +815 -0
- package/dist/tax/display-policy.d.ts +105 -0
- package/dist/tax/display-policy.js +84 -0
- package/dist/tax/index.d.ts +79 -1
- package/dist/tax/index.js +52 -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 +287 -0
- package/dist/tenant/email-templates.js +271 -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/stock/transfers.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { pageFromVendureList, readOffsetCursor, } from '@sixtyninecommerce/core';
|
|
2
2
|
import { decodeBase64, MYPARCEL_LABEL_TIMEOUT_MS, toUnretractedShipments, UNRETRACTED_SHIPMENT_FIELDS, } from '../fulfillments/index.js';
|
|
3
|
+
import { isUnknownFieldRejection } from '../payments/store-credit-fields.js';
|
|
3
4
|
const TRANSFER_FIELDS = /* GraphQL */ `
|
|
4
5
|
id
|
|
5
6
|
code
|
|
@@ -29,14 +30,74 @@ const TRANSFER_FIELDS = /* GraphQL */ `
|
|
|
29
30
|
}
|
|
30
31
|
createdAt
|
|
31
32
|
updatedAt
|
|
33
|
+
initiatedBy { id firstName lastName }
|
|
32
34
|
items {
|
|
33
35
|
id
|
|
34
|
-
productVariant { id sku }
|
|
36
|
+
productVariant { id name sku }
|
|
35
37
|
quantity
|
|
36
38
|
receivedQuantity
|
|
37
39
|
lostQuantity
|
|
38
40
|
outstandingQuantity
|
|
39
41
|
}
|
|
42
|
+
totalLines
|
|
43
|
+
totalQuantity
|
|
44
|
+
totalReceivedQuantity
|
|
45
|
+
totalLostQuantity
|
|
46
|
+
`;
|
|
47
|
+
/**
|
|
48
|
+
* What `get` and every write answer. Every field is one the transfer module has always served
|
|
49
|
+
* (the dashboard's own transfer pages read them all), so no engine refuses it.
|
|
50
|
+
*/
|
|
51
|
+
const TRANSFER_DETAIL_FIELDS = /* GraphQL */ `
|
|
52
|
+
id
|
|
53
|
+
code
|
|
54
|
+
kind
|
|
55
|
+
state
|
|
56
|
+
sourceLocation { id name }
|
|
57
|
+
destinationLocation { id name customFields { address } }
|
|
58
|
+
label
|
|
59
|
+
note
|
|
60
|
+
carrier
|
|
61
|
+
trackingCode
|
|
62
|
+
estimatedArrivalAt
|
|
63
|
+
shippedAt
|
|
64
|
+
receivedAt
|
|
65
|
+
cancelledAt
|
|
66
|
+
cancelReason
|
|
67
|
+
deliveryAddress {
|
|
68
|
+
contactName
|
|
69
|
+
company
|
|
70
|
+
streetLine1
|
|
71
|
+
streetLine2
|
|
72
|
+
city
|
|
73
|
+
province
|
|
74
|
+
postalCode
|
|
75
|
+
countryCode
|
|
76
|
+
phoneNumber
|
|
77
|
+
}
|
|
78
|
+
createdAt
|
|
79
|
+
updatedAt
|
|
80
|
+
initiatedBy { id firstName lastName }
|
|
81
|
+
shippedBy { id firstName lastName }
|
|
82
|
+
receivedBy { id firstName lastName }
|
|
83
|
+
consumptionTotalValue
|
|
84
|
+
consumptionHasUnpricedLines
|
|
85
|
+
pdfStorageKey
|
|
86
|
+
fulfillmentHandlerCode
|
|
87
|
+
handlerArgs
|
|
88
|
+
myparcelShipmentId
|
|
89
|
+
myparcelBarcode
|
|
90
|
+
hendriksRemotePath
|
|
91
|
+
items {
|
|
92
|
+
id
|
|
93
|
+
productVariant { id name sku }
|
|
94
|
+
quantity
|
|
95
|
+
receivedQuantity
|
|
96
|
+
lostQuantity
|
|
97
|
+
outstandingQuantity
|
|
98
|
+
unitCost
|
|
99
|
+
}
|
|
100
|
+
totalLines
|
|
40
101
|
totalQuantity
|
|
41
102
|
totalReceivedQuantity
|
|
42
103
|
totalLostQuantity
|
|
@@ -47,36 +108,36 @@ export const STOCK_TRANSFERS_QUERY = /* GraphQL */ `
|
|
|
47
108
|
}
|
|
48
109
|
`;
|
|
49
110
|
export const STOCK_TRANSFER_QUERY = /* GraphQL */ `
|
|
50
|
-
query StockTransfer($id: ID!) { stockTransfer(id: $id) { ${
|
|
111
|
+
query StockTransfer($id: ID!) { stockTransfer(id: $id) { ${TRANSFER_DETAIL_FIELDS} } }
|
|
51
112
|
`;
|
|
52
113
|
export const CREATE_STOCK_TRANSFER_MUTATION = /* GraphQL */ `
|
|
53
114
|
mutation CreateStockTransfer($input: CreateStockTransferInput!) {
|
|
54
|
-
createStockTransfer(input: $input) { ${
|
|
115
|
+
createStockTransfer(input: $input) { ${TRANSFER_DETAIL_FIELDS} }
|
|
55
116
|
}
|
|
56
117
|
`;
|
|
57
118
|
export const UPDATE_STOCK_TRANSFER_MUTATION = /* GraphQL */ `
|
|
58
119
|
mutation UpdateStockTransfer($id: ID!, $input: UpdateStockTransferInput!) {
|
|
59
|
-
updateStockTransfer(id: $id, input: $input) { ${
|
|
120
|
+
updateStockTransfer(id: $id, input: $input) { ${TRANSFER_DETAIL_FIELDS} }
|
|
60
121
|
}
|
|
61
122
|
`;
|
|
62
123
|
export const SHIP_STOCK_TRANSFER_MUTATION = /* GraphQL */ `
|
|
63
124
|
mutation ShipStockTransfer($id: ID!, $input: ShipStockTransferInput) {
|
|
64
|
-
shipStockTransfer(id: $id, input: $input) { ${
|
|
125
|
+
shipStockTransfer(id: $id, input: $input) { ${TRANSFER_DETAIL_FIELDS} }
|
|
65
126
|
}
|
|
66
127
|
`;
|
|
67
128
|
export const POST_STOCK_TRANSFER_CONSUMPTION_MUTATION = /* GraphQL */ `
|
|
68
129
|
mutation PostStockTransferConsumption($id: ID!) {
|
|
69
|
-
postStockTransferConsumption(id: $id) { ${
|
|
130
|
+
postStockTransferConsumption(id: $id) { ${TRANSFER_DETAIL_FIELDS} }
|
|
70
131
|
}
|
|
71
132
|
`;
|
|
72
133
|
export const RECEIVE_STOCK_TRANSFER_LINES_MUTATION = /* GraphQL */ `
|
|
73
134
|
mutation ReceiveStockTransferLines($id: ID!, $lines: [ReceiveStockTransferLineInput!]!) {
|
|
74
|
-
receiveStockTransferLines(id: $id, lines: $lines) { ${
|
|
135
|
+
receiveStockTransferLines(id: $id, lines: $lines) { ${TRANSFER_DETAIL_FIELDS} }
|
|
75
136
|
}
|
|
76
137
|
`;
|
|
77
138
|
export const CLOSE_STOCK_TRANSFER_MUTATION = /* GraphQL */ `
|
|
78
139
|
mutation CloseStockTransfer($id: ID!, $acceptShortfallAsLost: Boolean) {
|
|
79
|
-
closeStockTransfer(id: $id, acceptShortfallAsLost: $acceptShortfallAsLost) { ${
|
|
140
|
+
closeStockTransfer(id: $id, acceptShortfallAsLost: $acceptShortfallAsLost) { ${TRANSFER_DETAIL_FIELDS} }
|
|
80
141
|
}
|
|
81
142
|
`;
|
|
82
143
|
/**
|
|
@@ -94,17 +155,49 @@ export const CLOSE_STOCK_TRANSFER_WITH_SHORTFALL_MUTATION = /* GraphQL */ `
|
|
|
94
155
|
id: $id
|
|
95
156
|
acceptShortfallAsLost: $acceptShortfallAsLost
|
|
96
157
|
shortfall: $shortfall
|
|
97
|
-
) { ${
|
|
158
|
+
) { ${TRANSFER_DETAIL_FIELDS} }
|
|
98
159
|
}
|
|
99
160
|
`;
|
|
100
161
|
export const CANCEL_STOCK_TRANSFER_MUTATION = /* GraphQL */ `
|
|
101
162
|
mutation CancelStockTransfer($id: ID!, $reason: String) {
|
|
102
|
-
cancelStockTransfer(id: $id, reason: $reason) { ${
|
|
163
|
+
cancelStockTransfer(id: $id, reason: $reason) { ${TRANSFER_DETAIL_FIELDS} }
|
|
103
164
|
}
|
|
104
165
|
`;
|
|
105
166
|
export const CREATE_STOCK_TRANSFER_RETURN_MUTATION = /* GraphQL */ `
|
|
106
167
|
mutation CreateStockTransferReturn($id: ID!, $input: CreateStockTransferReturnInput!) {
|
|
107
|
-
createStockTransferReturn(id: $id, input: $input) { ${
|
|
168
|
+
createStockTransferReturn(id: $id, input: $input) { ${TRANSFER_DETAIL_FIELDS} }
|
|
169
|
+
}
|
|
170
|
+
`;
|
|
171
|
+
export const REMOVE_STOCK_TRANSFER_SHIPMENT_MUTATION = /* GraphQL */ `
|
|
172
|
+
mutation RemoveStockTransferShipment($id: ID!) {
|
|
173
|
+
removeStockTransferShipment(id: $id) { ${TRANSFER_DETAIL_FIELDS} }
|
|
174
|
+
}
|
|
175
|
+
`;
|
|
176
|
+
export const RETRY_STOCK_TRANSFER_HENDRIKS_EXPORT_MUTATION = /* GraphQL */ `
|
|
177
|
+
mutation RetryStockTransferHendriksExport($id: ID!) {
|
|
178
|
+
retryStockTransferHendriksExport(id: $id) { ${TRANSFER_DETAIL_FIELDS} }
|
|
179
|
+
}
|
|
180
|
+
`;
|
|
181
|
+
export const REGENERATE_STOCK_TRANSFER_PDF_MUTATION = /* GraphQL */ `
|
|
182
|
+
mutation RegenerateStockTransferPdf($id: ID!) {
|
|
183
|
+
regenerateStockTransferPdf(id: $id) { ${TRANSFER_DETAIL_FIELDS} }
|
|
184
|
+
}
|
|
185
|
+
`;
|
|
186
|
+
const NUMBERING_FIELDS = /* GraphQL */ `
|
|
187
|
+
prefix
|
|
188
|
+
suffix
|
|
189
|
+
digits
|
|
190
|
+
yearFormat
|
|
191
|
+
yearReset
|
|
192
|
+
`;
|
|
193
|
+
export const STOCK_TRANSFER_NUMBERING_QUERY = /* GraphQL */ `
|
|
194
|
+
query StockTransferNumberingConfig {
|
|
195
|
+
stockTransferNumberingConfig { ${NUMBERING_FIELDS} }
|
|
196
|
+
}
|
|
197
|
+
`;
|
|
198
|
+
export const UPDATE_STOCK_TRANSFER_NUMBERING_MUTATION = /* GraphQL */ `
|
|
199
|
+
mutation UpdateStockTransferNumberingConfig($input: UpdateStockTransferNumberingConfigInput!) {
|
|
200
|
+
updateStockTransferNumberingConfig(input: $input) { ${NUMBERING_FIELDS} }
|
|
108
201
|
}
|
|
109
202
|
`;
|
|
110
203
|
/**
|
|
@@ -134,9 +227,19 @@ export const STOCK_TRANSFER_RETURNS_QUERY = /* GraphQL */ `
|
|
|
134
227
|
returnedQuantity
|
|
135
228
|
returnableQuantity
|
|
136
229
|
}
|
|
230
|
+
returnAvailability { available reasonCode }
|
|
137
231
|
}
|
|
138
232
|
}
|
|
139
233
|
`;
|
|
234
|
+
/**
|
|
235
|
+
* The availability verdicts (W10-71) are newer than the documents that carry them: an engine
|
|
236
|
+
* before them refuses the whole document, so the read is sent once more without them and
|
|
237
|
+
* answers the verdict as null.
|
|
238
|
+
*/
|
|
239
|
+
const AVAILABILITY_SELECTION = /\s*(?:cancelAvailability|returnAvailability) \{ available reasonCode \}/g;
|
|
240
|
+
function withoutAvailability(document) {
|
|
241
|
+
return document.replace(AVAILABILITY_SELECTION, '');
|
|
242
|
+
}
|
|
140
243
|
/** The per-line settlement fields, in a document of their own like the return fields. */
|
|
141
244
|
export const STOCK_TRANSFER_SHORTFALL_QUERY = /* GraphQL */ `
|
|
142
245
|
query StockTransferShortfall($id: ID!) {
|
|
@@ -187,6 +290,7 @@ export const STOCK_TRANSFER_CANCELLATION_QUERY = /* GraphQL */ `
|
|
|
187
290
|
fulfillmentHandlerCode
|
|
188
291
|
hendriksRemotePath
|
|
189
292
|
hendriksBluJayOrderNumber
|
|
293
|
+
cancelAvailability { available reasonCode }
|
|
190
294
|
}
|
|
191
295
|
}
|
|
192
296
|
`;
|
|
@@ -233,9 +337,10 @@ const MYPARCEL_HANDLER_CODE = 'myparcel';
|
|
|
233
337
|
/**
|
|
234
338
|
* A MyParcel ship and its retry book every parcel at MyParcel before they
|
|
235
339
|
* answer (per parcel an adopt-by-reference lookup of up to 3 × 10s plus two
|
|
236
|
-
* capped waits, and a 30s POST),
|
|
340
|
+
* capped waits, and a 30s POST), a cancel or a shipment removal voids every
|
|
341
|
+
* parcel there, and a Hendriks ship or export retry uploads its export. The
|
|
237
342
|
* default 15s aborted calls the engine went on to finish, so the caller saw a
|
|
238
|
-
* failure for a ship, booking or
|
|
343
|
+
* failure for a ship, booking, cancel or removal that succeeded.
|
|
239
344
|
*/
|
|
240
345
|
const CARRIER_CALL_TIMEOUT_MS = 120_000;
|
|
241
346
|
/**
|
|
@@ -286,6 +391,7 @@ function toCancellation(raw) {
|
|
|
286
391
|
cancelReason: raw.cancelReason,
|
|
287
392
|
cancelledBy: raw.cancelledBy,
|
|
288
393
|
hendriksExport: exported ? { bluJayOrderNumber: raw.hendriksBluJayOrderNumber } : null,
|
|
394
|
+
cancelAvailability: raw.cancelAvailability ?? null,
|
|
289
395
|
};
|
|
290
396
|
}
|
|
291
397
|
function toTransfer(raw) {
|
|
@@ -295,9 +401,73 @@ function toTransfer(raw) {
|
|
|
295
401
|
...line,
|
|
296
402
|
variantId: productVariant.id,
|
|
297
403
|
sku: productVariant.sku,
|
|
404
|
+
variantName: productVariant.name,
|
|
298
405
|
})),
|
|
299
406
|
};
|
|
300
407
|
}
|
|
408
|
+
const ADDRESS_KEYS = [
|
|
409
|
+
'contactName',
|
|
410
|
+
'company',
|
|
411
|
+
'streetLine1',
|
|
412
|
+
'streetLine2',
|
|
413
|
+
'city',
|
|
414
|
+
'province',
|
|
415
|
+
'postalCode',
|
|
416
|
+
'countryCode',
|
|
417
|
+
'phoneNumber',
|
|
418
|
+
];
|
|
419
|
+
/**
|
|
420
|
+
* A location's `customFields.address`: JSON text earlier writers filled freely. Only its string
|
|
421
|
+
* fields are taken. Text that is not a JSON object, or one with no string field, reads as no
|
|
422
|
+
* address; the engine reads such a column the same way, and refuses to address a parcel to it.
|
|
423
|
+
*/
|
|
424
|
+
function locationAddress(raw) {
|
|
425
|
+
if (!raw?.trim())
|
|
426
|
+
return null;
|
|
427
|
+
let parsed;
|
|
428
|
+
try {
|
|
429
|
+
parsed = JSON.parse(raw);
|
|
430
|
+
}
|
|
431
|
+
catch {
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
435
|
+
return null;
|
|
436
|
+
const source = parsed;
|
|
437
|
+
const address = {};
|
|
438
|
+
let any = false;
|
|
439
|
+
for (const key of ADDRESS_KEYS) {
|
|
440
|
+
const value = source[key];
|
|
441
|
+
address[key] = typeof value === 'string' ? value : null;
|
|
442
|
+
any ||= typeof value === 'string' && value.trim() !== '';
|
|
443
|
+
}
|
|
444
|
+
return any ? address : null;
|
|
445
|
+
}
|
|
446
|
+
function toHandlerArgs(raw) {
|
|
447
|
+
if (Array.isArray(raw))
|
|
448
|
+
return raw;
|
|
449
|
+
if (raw && typeof raw === 'object')
|
|
450
|
+
return raw;
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
function toDetail(raw) {
|
|
454
|
+
const { destinationLocation, items, handlerArgs, ...rest } = raw;
|
|
455
|
+
return {
|
|
456
|
+
...rest,
|
|
457
|
+
destinationLocation: destinationLocation && {
|
|
458
|
+
id: destinationLocation.id,
|
|
459
|
+
name: destinationLocation.name,
|
|
460
|
+
address: locationAddress(destinationLocation.customFields?.address),
|
|
461
|
+
},
|
|
462
|
+
items: items.map(({ productVariant, ...line }) => ({
|
|
463
|
+
...line,
|
|
464
|
+
variantId: productVariant.id,
|
|
465
|
+
sku: productVariant.sku,
|
|
466
|
+
variantName: productVariant.name,
|
|
467
|
+
})),
|
|
468
|
+
handlerArgs: toHandlerArgs(handlerArgs),
|
|
469
|
+
};
|
|
470
|
+
}
|
|
301
471
|
function toReturns(raw) {
|
|
302
472
|
return {
|
|
303
473
|
returnOfTransferId: raw.returnOfTransferId,
|
|
@@ -309,14 +479,26 @@ function toReturns(raw) {
|
|
|
309
479
|
variantName: productVariant.name,
|
|
310
480
|
...quantities,
|
|
311
481
|
})),
|
|
482
|
+
returnAvailability: raw.returnAvailability ?? null,
|
|
312
483
|
};
|
|
313
484
|
}
|
|
485
|
+
/** Read the document, and once more without the availability verdicts when the engine does not know them. */
|
|
486
|
+
async function readWithoutAvailabilityOnOlderEngine(transport, query, id, options) {
|
|
487
|
+
try {
|
|
488
|
+
return await transport.graphql({ api: 'admin', query, variables: { id } }, options);
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
if (!isUnknownFieldRejection(error))
|
|
492
|
+
throw error;
|
|
493
|
+
return transport.graphql({ api: 'admin', query: withoutAvailability(query), variables: { id } }, options);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
314
496
|
const toLines = (lines) => lines.map((line) => ({ productVariantId: line.variantId, quantity: line.quantity }));
|
|
315
497
|
const DEFAULT_PAGE_SIZE = 25;
|
|
316
498
|
export function createStockTransfersModule(transport) {
|
|
317
499
|
const one = async (field, query, variables, options) => {
|
|
318
500
|
const data = await transport.graphql({ api: 'admin', query, variables }, options);
|
|
319
|
-
return
|
|
501
|
+
return toDetail(data[field]);
|
|
320
502
|
};
|
|
321
503
|
const listPage = async (skip, take, filter) => {
|
|
322
504
|
const data = await transport.graphql({
|
|
@@ -333,6 +515,9 @@ export function createStockTransfersModule(transport) {
|
|
|
333
515
|
dateFrom: filter?.dateFrom,
|
|
334
516
|
dateTo: filter?.dateTo,
|
|
335
517
|
search: filter?.search,
|
|
518
|
+
// Only when set, as the return filters below: a caller that never names a mode
|
|
519
|
+
// keeps sending the document every engine since the transfer module accepts.
|
|
520
|
+
...(filter?.searchMode === undefined ? {} : { searchMode: filter.searchMode }),
|
|
336
521
|
// Only when set: an engine without returns refuses an unknown
|
|
337
522
|
// input field, which would fail every list against it.
|
|
338
523
|
...(filter?.returnOfTransferId === undefined
|
|
@@ -355,7 +540,7 @@ export function createStockTransfersModule(transport) {
|
|
|
355
540
|
},
|
|
356
541
|
async get(id, options) {
|
|
357
542
|
const data = await transport.graphql({ api: 'admin', query: STOCK_TRANSFER_QUERY, variables: { id } }, options);
|
|
358
|
-
return data.stockTransfer === null ? null :
|
|
543
|
+
return data.stockTransfer === null ? null : toDetail(data.stockTransfer);
|
|
359
544
|
},
|
|
360
545
|
create(input, options) {
|
|
361
546
|
const { lines, ...rest } = input;
|
|
@@ -393,7 +578,7 @@ export function createStockTransfersModule(transport) {
|
|
|
393
578
|
return one('createStockTransferReturn', CREATE_STOCK_TRANSFER_RETURN_MUTATION, { id, input: { ...rest, lines: toLines(lines) } }, options);
|
|
394
579
|
},
|
|
395
580
|
async returns(id, options) {
|
|
396
|
-
const data = await transport
|
|
581
|
+
const data = await readWithoutAvailabilityOnOlderEngine(transport, STOCK_TRANSFER_RETURNS_QUERY, id, options);
|
|
397
582
|
return data.stockTransfer === null ? null : toReturns(data.stockTransfer);
|
|
398
583
|
},
|
|
399
584
|
async shortfall(id, options) {
|
|
@@ -401,7 +586,7 @@ export function createStockTransfersModule(transport) {
|
|
|
401
586
|
return data.stockTransfer === null ? null : toShortfall(data.stockTransfer);
|
|
402
587
|
},
|
|
403
588
|
async cancellation(id, options) {
|
|
404
|
-
const data = await transport
|
|
589
|
+
const data = await readWithoutAvailabilityOnOlderEngine(transport, STOCK_TRANSFER_CANCELLATION_QUERY, id, options);
|
|
405
590
|
return data.stockTransfer === null ? null : toCancellation(data.stockTransfer);
|
|
406
591
|
},
|
|
407
592
|
async parcels(id, options) {
|
|
@@ -433,5 +618,25 @@ export function createStockTransfersModule(transport) {
|
|
|
433
618
|
const { base64, ...document } = data.getMyparcelStockTransferLabel;
|
|
434
619
|
return { ...document, bytes: decodeBase64(base64) };
|
|
435
620
|
},
|
|
621
|
+
removeShipment(id, options) {
|
|
622
|
+
return one('removeStockTransferShipment', REMOVE_STOCK_TRANSFER_SHIPMENT_MUTATION, { id }, { timeoutMs: CARRIER_CALL_TIMEOUT_MS, ...options });
|
|
623
|
+
},
|
|
624
|
+
retryHendriksExport(id, options) {
|
|
625
|
+
// The ship's budget: the same upload runs inside the call.
|
|
626
|
+
return one('retryStockTransferHendriksExport', RETRY_STOCK_TRANSFER_HENDRIKS_EXPORT_MUTATION, { id }, { timeoutMs: CARRIER_CALL_TIMEOUT_MS, ...options });
|
|
627
|
+
},
|
|
628
|
+
regeneratePdf(id, options) {
|
|
629
|
+
return one('regenerateStockTransferPdf', REGENERATE_STOCK_TRANSFER_PDF_MUTATION, { id }, options);
|
|
630
|
+
},
|
|
631
|
+
numbering: {
|
|
632
|
+
async get(options) {
|
|
633
|
+
const data = await transport.graphql({ api: 'admin', query: STOCK_TRANSFER_NUMBERING_QUERY }, options);
|
|
634
|
+
return data.stockTransferNumberingConfig;
|
|
635
|
+
},
|
|
636
|
+
async set(input, options) {
|
|
637
|
+
const data = await transport.graphql({ api: 'admin', query: UPDATE_STOCK_TRANSFER_NUMBERING_MUTATION, variables: { input } }, options);
|
|
638
|
+
return data.updateStockTransferNumberingConfig;
|
|
639
|
+
},
|
|
640
|
+
},
|
|
436
641
|
};
|
|
437
642
|
}
|