@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
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { pageFromVendureList, readOffsetCursor, } from '@sixtyninecommerce/core';
|
|
2
|
+
export const SUPPLIER_RETURN_LINE_FIELDS = /* GraphQL */ `
|
|
3
|
+
id
|
|
4
|
+
supplierReturnId
|
|
5
|
+
position
|
|
6
|
+
goodsReceiptId
|
|
7
|
+
goodsReceiptCode
|
|
8
|
+
goodsReceiptLineId
|
|
9
|
+
purchaseOrderId
|
|
10
|
+
purchaseOrderCode
|
|
11
|
+
purchaseOrderLineId
|
|
12
|
+
productVariantId
|
|
13
|
+
sku
|
|
14
|
+
name
|
|
15
|
+
supplierSku
|
|
16
|
+
purchaseUnitLabel
|
|
17
|
+
purchaseUnitFactor
|
|
18
|
+
baseQuantity
|
|
19
|
+
reason
|
|
20
|
+
outcome
|
|
21
|
+
resolution
|
|
22
|
+
currencyCode
|
|
23
|
+
creditAmount
|
|
24
|
+
resolutionReference
|
|
25
|
+
unitCost
|
|
26
|
+
cancelledBaseQuantity
|
|
27
|
+
reopenedBaseQuantity
|
|
28
|
+
resolvedAt
|
|
29
|
+
resolvedByRef
|
|
30
|
+
stockMovementId
|
|
31
|
+
createdAt
|
|
32
|
+
`;
|
|
33
|
+
export const SUPPLIER_RETURN_FIELDS = /* GraphQL */ `
|
|
34
|
+
id
|
|
35
|
+
scopeId
|
|
36
|
+
legalEntityId
|
|
37
|
+
originChannelId
|
|
38
|
+
code
|
|
39
|
+
status
|
|
40
|
+
origin
|
|
41
|
+
supplierId
|
|
42
|
+
supplier { id code name status }
|
|
43
|
+
stockLocationId
|
|
44
|
+
stockLocation { id name }
|
|
45
|
+
supplierReference
|
|
46
|
+
notesToSupplier
|
|
47
|
+
carrier
|
|
48
|
+
trackingCode
|
|
49
|
+
shippedAt
|
|
50
|
+
resolvedAt
|
|
51
|
+
managedBy
|
|
52
|
+
externalId
|
|
53
|
+
createdByRef
|
|
54
|
+
documentIssuedAt
|
|
55
|
+
lines { ${SUPPLIER_RETURN_LINE_FIELDS} }
|
|
56
|
+
statusHistory { id fromStatus status actorRef reason metadata createdAt }
|
|
57
|
+
createdAt
|
|
58
|
+
updatedAt
|
|
59
|
+
`;
|
|
60
|
+
export const SUPPLIER_RETURNS_QUERY = /* GraphQL */ `
|
|
61
|
+
query SupplierReturns($options: SupplierReturnListOptions) {
|
|
62
|
+
supplierReturns(options: $options) {
|
|
63
|
+
items { ${SUPPLIER_RETURN_FIELDS} }
|
|
64
|
+
totalItems
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
export const SUPPLIER_RETURN_QUERY = /* GraphQL */ `
|
|
69
|
+
query SupplierReturn($id: ID!) {
|
|
70
|
+
supplierReturn(id: $id) { ${SUPPLIER_RETURN_FIELDS} }
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
export const CREATE_SUPPLIER_RETURN_MUTATION = /* GraphQL */ `
|
|
74
|
+
mutation CreateSupplierReturn($input: CreateSupplierReturnInput!, $idempotencyKey: String) {
|
|
75
|
+
createSupplierReturn(input: $input, idempotencyKey: $idempotencyKey) {
|
|
76
|
+
${SUPPLIER_RETURN_FIELDS}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
export const UPDATE_SUPPLIER_RETURN_MUTATION = /* GraphQL */ `
|
|
81
|
+
mutation UpdateSupplierReturn($input: UpdateSupplierReturnInput!, $idempotencyKey: String) {
|
|
82
|
+
updateSupplierReturn(input: $input, idempotencyKey: $idempotencyKey) {
|
|
83
|
+
${SUPPLIER_RETURN_FIELDS}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
export const SHIP_SUPPLIER_RETURN_MUTATION = /* GraphQL */ `
|
|
88
|
+
mutation ShipSupplierReturn($input: ShipSupplierReturnInput!, $idempotencyKey: String!) {
|
|
89
|
+
shipSupplierReturn(input: $input, idempotencyKey: $idempotencyKey) {
|
|
90
|
+
${SUPPLIER_RETURN_FIELDS}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
export const RESOLVE_SUPPLIER_RETURN_LINE_MUTATION = /* GraphQL */ `
|
|
95
|
+
mutation ResolveSupplierReturnLine(
|
|
96
|
+
$input: ResolveSupplierReturnLineInput!
|
|
97
|
+
$idempotencyKey: String
|
|
98
|
+
) {
|
|
99
|
+
resolveSupplierReturnLine(input: $input, idempotencyKey: $idempotencyKey) {
|
|
100
|
+
${SUPPLIER_RETURN_FIELDS}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
export const CANCEL_SUPPLIER_RETURN_MUTATION = /* GraphQL */ `
|
|
105
|
+
mutation CancelSupplierReturn($id: ID!, $reason: String, $idempotencyKey: String) {
|
|
106
|
+
cancelSupplierReturn(id: $id, reason: $reason, idempotencyKey: $idempotencyKey) {
|
|
107
|
+
${SUPPLIER_RETURN_FIELDS}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
export const CREATE_SUPPLIER_RETURN_DOCUMENT_URL_MUTATION = /* GraphQL */ `
|
|
112
|
+
mutation CreateSupplierReturnDocumentUrl($supplierReturnId: ID!) {
|
|
113
|
+
createSupplierReturnDocumentUrl(supplierReturnId: $supplierReturnId) {
|
|
114
|
+
url
|
|
115
|
+
expiresAt
|
|
116
|
+
filename
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
120
|
+
const DEFAULT_PAGE_SIZE = 25;
|
|
121
|
+
const LIST_FILTERS = [
|
|
122
|
+
'status',
|
|
123
|
+
'origin',
|
|
124
|
+
'supplierId',
|
|
125
|
+
'stockLocationId',
|
|
126
|
+
'purchaseOrderId',
|
|
127
|
+
'goodsReceiptId',
|
|
128
|
+
'term',
|
|
129
|
+
];
|
|
130
|
+
const LINE_INPUT_FIELDS = [
|
|
131
|
+
'goodsReceiptLineId',
|
|
132
|
+
'baseQuantity',
|
|
133
|
+
'reason',
|
|
134
|
+
'outcome',
|
|
135
|
+
];
|
|
136
|
+
const CREATE_INPUT_FIELDS = [
|
|
137
|
+
'origin',
|
|
138
|
+
'supplierId',
|
|
139
|
+
'stockLocationId',
|
|
140
|
+
'supplierReference',
|
|
141
|
+
'notesToSupplier',
|
|
142
|
+
'carrier',
|
|
143
|
+
'trackingCode',
|
|
144
|
+
];
|
|
145
|
+
const UPDATE_INPUT_FIELDS = [
|
|
146
|
+
'stockLocationId',
|
|
147
|
+
'supplierReference',
|
|
148
|
+
'notesToSupplier',
|
|
149
|
+
'carrier',
|
|
150
|
+
'trackingCode',
|
|
151
|
+
];
|
|
152
|
+
const SHIP_INPUT_FIELDS = [
|
|
153
|
+
'carrier',
|
|
154
|
+
'trackingCode',
|
|
155
|
+
'notifySupplier',
|
|
156
|
+
];
|
|
157
|
+
const RESOLVE_INPUT_FIELDS = [
|
|
158
|
+
'supplierReturnLineId',
|
|
159
|
+
'resolution',
|
|
160
|
+
'creditAmount',
|
|
161
|
+
'resolutionReference',
|
|
162
|
+
];
|
|
163
|
+
function picked(input, fields) {
|
|
164
|
+
const out = {};
|
|
165
|
+
for (const field of fields) {
|
|
166
|
+
const value = input[field];
|
|
167
|
+
if (value !== undefined)
|
|
168
|
+
out[field] = value;
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
export function createPurchasingReturnsModule(transport) {
|
|
173
|
+
const listPage = async (skip, take, options) => {
|
|
174
|
+
const filters = options ? picked(options, LIST_FILTERS) : {};
|
|
175
|
+
const data = await transport.graphql({
|
|
176
|
+
api: 'admin',
|
|
177
|
+
query: SUPPLIER_RETURNS_QUERY,
|
|
178
|
+
variables: { options: { skip, take, ...filters } },
|
|
179
|
+
}, options);
|
|
180
|
+
return pageFromVendureList(data.supplierReturns, skip, take, (cursor) => listPage(readOffsetCursor(cursor), take, options));
|
|
181
|
+
};
|
|
182
|
+
const mutate = async (field, query, variables, call) => {
|
|
183
|
+
const data = await transport.graphql({ api: 'admin', query, variables: { ...variables, idempotencyKey: call?.idempotencyKey } }, call);
|
|
184
|
+
return data[field];
|
|
185
|
+
};
|
|
186
|
+
return {
|
|
187
|
+
async list(options) {
|
|
188
|
+
const take = options?.limit ?? DEFAULT_PAGE_SIZE;
|
|
189
|
+
const skip = options?.after === undefined ? 0 : readOffsetCursor(options.after);
|
|
190
|
+
return listPage(skip, take, options);
|
|
191
|
+
},
|
|
192
|
+
async get(id, call) {
|
|
193
|
+
const data = await transport.graphql({ api: 'admin', query: SUPPLIER_RETURN_QUERY, variables: { id } }, call);
|
|
194
|
+
return data.supplierReturn;
|
|
195
|
+
},
|
|
196
|
+
create(input, call) {
|
|
197
|
+
return mutate('createSupplierReturn', CREATE_SUPPLIER_RETURN_MUTATION, {
|
|
198
|
+
input: {
|
|
199
|
+
...picked(input, CREATE_INPUT_FIELDS),
|
|
200
|
+
lines: input.lines.map((line) => picked(line, LINE_INPUT_FIELDS)),
|
|
201
|
+
},
|
|
202
|
+
}, call);
|
|
203
|
+
},
|
|
204
|
+
update(id, input, call) {
|
|
205
|
+
const fields = { ...picked(input, UPDATE_INPUT_FIELDS), id };
|
|
206
|
+
if (input.lines !== undefined) {
|
|
207
|
+
fields.lines = input.lines.map((line) => picked(line, LINE_INPUT_FIELDS));
|
|
208
|
+
}
|
|
209
|
+
return mutate('updateSupplierReturn', UPDATE_SUPPLIER_RETURN_MUTATION, { input: fields }, call);
|
|
210
|
+
},
|
|
211
|
+
ship(id, input, call) {
|
|
212
|
+
return mutate('shipSupplierReturn', SHIP_SUPPLIER_RETURN_MUTATION, { input: { ...picked(input, SHIP_INPUT_FIELDS), id } }, call);
|
|
213
|
+
},
|
|
214
|
+
resolveLine(input, call) {
|
|
215
|
+
return mutate('resolveSupplierReturnLine', RESOLVE_SUPPLIER_RETURN_LINE_MUTATION, { input: picked(input, RESOLVE_INPUT_FIELDS) }, call);
|
|
216
|
+
},
|
|
217
|
+
cancel(id, options) {
|
|
218
|
+
return mutate('cancelSupplierReturn', CANCEL_SUPPLIER_RETURN_MUTATION, { id, ...(options?.reason === undefined ? {} : { reason: options.reason }) }, options);
|
|
219
|
+
},
|
|
220
|
+
async document(id, call) {
|
|
221
|
+
const data = await transport.graphql({
|
|
222
|
+
api: 'admin',
|
|
223
|
+
query: CREATE_SUPPLIER_RETURN_DOCUMENT_URL_MUTATION,
|
|
224
|
+
variables: { supplierReturnId: id },
|
|
225
|
+
}, call);
|
|
226
|
+
return data.createSupplierReturnDocumentUrl;
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { type Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The purchasing settings of the active store's PURCHASING SCOPE (purchase-orders spec §6.1,
|
|
5
|
+
* §10.1): its legal entity, shared by every store of that entity, or a sandbox store's own scope.
|
|
6
|
+
* Before purchasing is first switched on, the defaults answer and `updatedAt` is null.
|
|
7
|
+
*/
|
|
8
|
+
export interface PurchasingSettings {
|
|
9
|
+
/** The legal entity's id, or `sandbox:<channelId>` for a sandbox store, which purchases alone. */
|
|
10
|
+
scopeId: string;
|
|
11
|
+
/** The legal entity (Seller) id; null for a sandbox store's own scope. */
|
|
12
|
+
legalEntityId: string | null;
|
|
13
|
+
/** Whether purchasing is switched on for the scope. */
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* ISO 4217: the scope's purchasing currency, set when purchasing is first switched on (the
|
|
17
|
+
* store's default currency unless another is given). Before that, the currency it would take.
|
|
18
|
+
*/
|
|
19
|
+
currencyCode: string;
|
|
20
|
+
/**
|
|
21
|
+
* `platform` with `providerKey` null is Standalone, the only mode until a provider can be
|
|
22
|
+
* connected. Read-only here. A string on the wire: more values may come.
|
|
23
|
+
*/
|
|
24
|
+
sourceOfTruth: 'platform' | 'provider' | (string & {});
|
|
25
|
+
/** The assigned purchasing provider; null in Standalone mode. Read-only here. */
|
|
26
|
+
providerKey: string | null;
|
|
27
|
+
/** Percent of an order line a receipt may exceed without the over-tolerance permission. */
|
|
28
|
+
defaultOverReceiptTolerancePct: number;
|
|
29
|
+
/** Days of sales the reorder suggestions measure velocity over. */
|
|
30
|
+
velocityWindowDays: number;
|
|
31
|
+
/** Days of demand a reorder suggestion covers. */
|
|
32
|
+
defaultCoverDays: number;
|
|
33
|
+
/** How often staff get the reorder digest. A string on the wire: more values may come. */
|
|
34
|
+
reorderDigest: 'off' | 'daily' | 'weekly' | (string & {});
|
|
35
|
+
/**
|
|
36
|
+
* Minor units of `currencyCode`: a purchase order whose net total is ABOVE it waits for an
|
|
37
|
+
* approver (`ApprovePurchaseOrder`) when submitted. Null: approval is off. Always null from an
|
|
38
|
+
* engine before purchase orders, which has no approval.
|
|
39
|
+
*/
|
|
40
|
+
approvalThreshold: number | null;
|
|
41
|
+
/** ISO-8601 UTC; null until purchasing is first switched on. */
|
|
42
|
+
updatedAt: string | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A PATCH: a field left out keeps its value. The scope's FIRST update creates its settings and
|
|
46
|
+
* switches purchasing on unless `enabled: false` is given.
|
|
47
|
+
*/
|
|
48
|
+
export interface UpdatePurchasingSettingsInput {
|
|
49
|
+
enabled?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* ISO 4217, upper case (`EUR`). Fixed once the legal entity has a purchase order
|
|
52
|
+
* (`PURCHASING_CURRENCY_LOCKED`, 422).
|
|
53
|
+
*/
|
|
54
|
+
currencyCode?: string;
|
|
55
|
+
/** 0 to 100, at most two decimals. */
|
|
56
|
+
defaultOverReceiptTolerancePct?: number;
|
|
57
|
+
/** 1 to 365. */
|
|
58
|
+
velocityWindowDays?: number;
|
|
59
|
+
/** 0 to 365. */
|
|
60
|
+
defaultCoverDays?: number;
|
|
61
|
+
reorderDigest?: 'off' | 'daily' | 'weekly';
|
|
62
|
+
/**
|
|
63
|
+
* 0 to 2,147,483,647 minor units of the purchasing currency; `null` switches approval off. Needs
|
|
64
|
+
* an engine with purchase orders.
|
|
65
|
+
*/
|
|
66
|
+
approvalThreshold?: number | null;
|
|
67
|
+
}
|
|
68
|
+
/** The documents purchasing numbers, each its own series. */
|
|
69
|
+
export type PurchasingNumberingKind = 'purchase_order' | 'goods_receipt' | 'supplier_return';
|
|
70
|
+
/**
|
|
71
|
+
* How one kind of purchasing document is numbered in the scope:
|
|
72
|
+
* `{testPrefix}{prefix}{year}-{number}{suffix}` (`PO-2026-0001`), or without the year and its
|
|
73
|
+
* dash when `yearFormat` is `none`. A format that prints the year counts from 1 each year of the
|
|
74
|
+
* legal entity's fiscal time zone; one without it counts on, never restarting.
|
|
75
|
+
*/
|
|
76
|
+
export interface PurchasingNumbering {
|
|
77
|
+
kind: PurchasingNumberingKind | (string & {});
|
|
78
|
+
/** Defaults: `PO-`, `GR-`, `RS-`. */
|
|
79
|
+
prefix: string;
|
|
80
|
+
suffix: string;
|
|
81
|
+
/** How many digits the number is padded to, 3 to 8. */
|
|
82
|
+
digits: number;
|
|
83
|
+
/** `none`, `short` (`26`) or `full` (`2026`). */
|
|
84
|
+
yearFormat: string;
|
|
85
|
+
/**
|
|
86
|
+
* Kept for the shared numbering contract: as for stock transfers, the count restarts each year
|
|
87
|
+
* exactly when the year is printed, whatever this says.
|
|
88
|
+
*/
|
|
89
|
+
yearReset: boolean;
|
|
90
|
+
/** `TEST-` for a sandbox store, before every number it issues; empty for a live store. */
|
|
91
|
+
testPrefix: string;
|
|
92
|
+
/** The value the next number takes on the counter it would draw from today. Read-only. */
|
|
93
|
+
nextNumber: number;
|
|
94
|
+
/** The next number as it would be issued today. Nothing is reserved. */
|
|
95
|
+
preview: string;
|
|
96
|
+
}
|
|
97
|
+
/** A format change of one kind: a field left out is kept. */
|
|
98
|
+
export interface UpdatePurchasingNumberingInput {
|
|
99
|
+
kind: PurchasingNumberingKind;
|
|
100
|
+
/** At most 30 characters; a live store's may not start with `TEST-` (`NUMBER_PREFIX_RESERVED`). */
|
|
101
|
+
prefix?: string;
|
|
102
|
+
/** At most 30 characters. */
|
|
103
|
+
suffix?: string;
|
|
104
|
+
/** 3 to 8. */
|
|
105
|
+
digits?: number;
|
|
106
|
+
yearFormat?: 'none' | 'short' | 'full';
|
|
107
|
+
yearReset?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export declare const PURCHASING_SETTINGS_FIELDS = "\n \n scopeId\n legalEntityId\n enabled\n currencyCode\n sourceOfTruth\n providerKey\n defaultOverReceiptTolerancePct\n velocityWindowDays\n defaultCoverDays\n reorderDigest\n updatedAt\n\n approvalThreshold\n";
|
|
110
|
+
export declare const PURCHASING_NUMBERING_FIELDS = "\n kind\n prefix\n suffix\n digits\n yearFormat\n yearReset\n testPrefix\n nextNumber\n preview\n";
|
|
111
|
+
export declare const PURCHASING_SETTINGS_QUERY = "\n query PurchasingSettings {\n purchasingSettings { \n \n scopeId\n legalEntityId\n enabled\n currencyCode\n sourceOfTruth\n providerKey\n defaultOverReceiptTolerancePct\n velocityWindowDays\n defaultCoverDays\n reorderDigest\n updatedAt\n\n approvalThreshold\n }\n }\n";
|
|
112
|
+
export declare const UPDATE_PURCHASING_SETTINGS_MUTATION = "\n mutation UpdatePurchasingSettings(\n $input: UpdatePurchasingSettingsInput!\n $idempotencyKey: String\n ) {\n updatePurchasingSettings(input: $input, idempotencyKey: $idempotencyKey) {\n \n \n scopeId\n legalEntityId\n enabled\n currencyCode\n sourceOfTruth\n providerKey\n defaultOverReceiptTolerancePct\n velocityWindowDays\n defaultCoverDays\n reorderDigest\n updatedAt\n\n approvalThreshold\n\n }\n }\n";
|
|
113
|
+
/**
|
|
114
|
+
* The settings documents without `approvalThreshold`, for an engine before purchase orders: the
|
|
115
|
+
* SDK retries once with these when the engine refuses the field, and answers the threshold null.
|
|
116
|
+
*/
|
|
117
|
+
export declare const LEGACY_PURCHASING_SETTINGS_QUERY = "\n query PurchasingSettingsLegacy {\n purchasingSettings { \n scopeId\n legalEntityId\n enabled\n currencyCode\n sourceOfTruth\n providerKey\n defaultOverReceiptTolerancePct\n velocityWindowDays\n defaultCoverDays\n reorderDigest\n updatedAt\n }\n }\n";
|
|
118
|
+
export declare const LEGACY_UPDATE_PURCHASING_SETTINGS_MUTATION = "\n mutation UpdatePurchasingSettingsLegacy(\n $input: UpdatePurchasingSettingsInput!\n $idempotencyKey: String\n ) {\n updatePurchasingSettings(input: $input, idempotencyKey: $idempotencyKey) {\n \n scopeId\n legalEntityId\n enabled\n currencyCode\n sourceOfTruth\n providerKey\n defaultOverReceiptTolerancePct\n velocityWindowDays\n defaultCoverDays\n reorderDigest\n updatedAt\n\n }\n }\n";
|
|
119
|
+
export declare const PURCHASING_NUMBERING_QUERY = "\n query PurchasingNumbering($kind: String!) {\n purchasingNumbering(kind: $kind) { \n kind\n prefix\n suffix\n digits\n yearFormat\n yearReset\n testPrefix\n nextNumber\n preview\n }\n }\n";
|
|
120
|
+
export declare const UPDATE_PURCHASING_NUMBERING_MUTATION = "\n mutation UpdatePurchasingNumbering(\n $input: UpdatePurchasingNumberingInput!\n $idempotencyKey: String\n ) {\n updatePurchasingNumbering(input: $input, idempotencyKey: $idempotencyKey) {\n \n kind\n prefix\n suffix\n digits\n yearFormat\n yearReset\n testPrefix\n nextNumber\n preview\n\n }\n }\n";
|
|
121
|
+
/** One kind's numbering: read and change its format. */
|
|
122
|
+
export interface PurchasingNumberingModule {
|
|
123
|
+
/** Refusals: `NUMBERING_KIND_INVALID` (400). */
|
|
124
|
+
get(kind: PurchasingNumberingKind, call?: Call): Promise<PurchasingNumbering>;
|
|
125
|
+
/**
|
|
126
|
+
* Changes the format of `input.kind` (`ManagePurchasingSettings`); counters never change.
|
|
127
|
+
* Refusals: `NUMBERING_KIND_INVALID`, `NUMBERING_AFFIX_INVALID`, `NUMBERING_DIGITS_INVALID`,
|
|
128
|
+
* `NUMBERING_YEAR_FORMAT_INVALID` (400); `NUMBER_PREFIX_RESERVED` (422).
|
|
129
|
+
*/
|
|
130
|
+
update(input: UpdatePurchasingNumberingInput, call?: Call): Promise<PurchasingNumbering>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* `admin.purchasing.settings` (spec §10.1). Every method needs the Purchasing plugin on the store
|
|
134
|
+
* (`PURCHASING_NOT_ENABLED`, 422; `PLUGIN_ACCESS_DENIED`, 403, from the engine's gate for an
|
|
135
|
+
* ordinary caller), and a store that purchases: an organization workspace is refused
|
|
136
|
+
* `HUB_HAS_NO_PURCHASING`, a store with no legal entity `LEGAL_ENTITY_REQUIRED` (422). Reads need
|
|
137
|
+
* `ManagePurchasingSettings`, `ReadSettings` or `ReadSupplier` on the store; writes need
|
|
138
|
+
* `ManagePurchasingSettings` on EVERY store of the legal entity, since every one of them shares the
|
|
139
|
+
* settings and the series (`SHARED_SELLER_NOT_ALLOWED`, 403; a sandbox store is its own scope).
|
|
140
|
+
*/
|
|
141
|
+
export interface PurchasingSettingsModule {
|
|
142
|
+
get(call?: Call): Promise<PurchasingSettings>;
|
|
143
|
+
/**
|
|
144
|
+
* The first update switches purchasing on for the scope (unless `enabled: false`), in the
|
|
145
|
+
* store's default currency unless `currencyCode` names another. Refusals:
|
|
146
|
+
* `PURCHASING_SETTINGS_INVALID` (400, the message names the field and its range),
|
|
147
|
+
* `PURCHASING_CURRENCY_LOCKED` (422, a currency change once a purchase order exists).
|
|
148
|
+
*/
|
|
149
|
+
update(input: UpdatePurchasingSettingsInput, call?: Call): Promise<PurchasingSettings>;
|
|
150
|
+
numbering: PurchasingNumberingModule;
|
|
151
|
+
}
|
|
152
|
+
export declare function createPurchasingSettingsModule(transport: Transport): PurchasingSettingsModule;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { ValidationError } from '@sixtyninecommerce/core';
|
|
2
|
+
/** The fields every engine with purchasing answers (phase 1). */
|
|
3
|
+
const PHASE_1_SETTINGS_FIELDS = /* GraphQL */ `
|
|
4
|
+
scopeId
|
|
5
|
+
legalEntityId
|
|
6
|
+
enabled
|
|
7
|
+
currencyCode
|
|
8
|
+
sourceOfTruth
|
|
9
|
+
providerKey
|
|
10
|
+
defaultOverReceiptTolerancePct
|
|
11
|
+
velocityWindowDays
|
|
12
|
+
defaultCoverDays
|
|
13
|
+
reorderDigest
|
|
14
|
+
updatedAt
|
|
15
|
+
`;
|
|
16
|
+
export const PURCHASING_SETTINGS_FIELDS = /* GraphQL */ `
|
|
17
|
+
${PHASE_1_SETTINGS_FIELDS}
|
|
18
|
+
approvalThreshold
|
|
19
|
+
`;
|
|
20
|
+
export const PURCHASING_NUMBERING_FIELDS = /* GraphQL */ `
|
|
21
|
+
kind
|
|
22
|
+
prefix
|
|
23
|
+
suffix
|
|
24
|
+
digits
|
|
25
|
+
yearFormat
|
|
26
|
+
yearReset
|
|
27
|
+
testPrefix
|
|
28
|
+
nextNumber
|
|
29
|
+
preview
|
|
30
|
+
`;
|
|
31
|
+
export const PURCHASING_SETTINGS_QUERY = /* GraphQL */ `
|
|
32
|
+
query PurchasingSettings {
|
|
33
|
+
purchasingSettings { ${PURCHASING_SETTINGS_FIELDS} }
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
export const UPDATE_PURCHASING_SETTINGS_MUTATION = /* GraphQL */ `
|
|
37
|
+
mutation UpdatePurchasingSettings(
|
|
38
|
+
$input: UpdatePurchasingSettingsInput!
|
|
39
|
+
$idempotencyKey: String
|
|
40
|
+
) {
|
|
41
|
+
updatePurchasingSettings(input: $input, idempotencyKey: $idempotencyKey) {
|
|
42
|
+
${PURCHASING_SETTINGS_FIELDS}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
/**
|
|
47
|
+
* The settings documents without `approvalThreshold`, for an engine before purchase orders: the
|
|
48
|
+
* SDK retries once with these when the engine refuses the field, and answers the threshold null.
|
|
49
|
+
*/
|
|
50
|
+
export const LEGACY_PURCHASING_SETTINGS_QUERY = /* GraphQL */ `
|
|
51
|
+
query PurchasingSettingsLegacy {
|
|
52
|
+
purchasingSettings { ${PHASE_1_SETTINGS_FIELDS} }
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
export const LEGACY_UPDATE_PURCHASING_SETTINGS_MUTATION = /* GraphQL */ `
|
|
56
|
+
mutation UpdatePurchasingSettingsLegacy(
|
|
57
|
+
$input: UpdatePurchasingSettingsInput!
|
|
58
|
+
$idempotencyKey: String
|
|
59
|
+
) {
|
|
60
|
+
updatePurchasingSettings(input: $input, idempotencyKey: $idempotencyKey) {
|
|
61
|
+
${PHASE_1_SETTINGS_FIELDS}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
export const PURCHASING_NUMBERING_QUERY = /* GraphQL */ `
|
|
66
|
+
query PurchasingNumbering($kind: String!) {
|
|
67
|
+
purchasingNumbering(kind: $kind) { ${PURCHASING_NUMBERING_FIELDS} }
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
export const UPDATE_PURCHASING_NUMBERING_MUTATION = /* GraphQL */ `
|
|
71
|
+
mutation UpdatePurchasingNumbering(
|
|
72
|
+
$input: UpdatePurchasingNumberingInput!
|
|
73
|
+
$idempotencyKey: String
|
|
74
|
+
) {
|
|
75
|
+
updatePurchasingNumbering(input: $input, idempotencyKey: $idempotencyKey) {
|
|
76
|
+
${PURCHASING_NUMBERING_FIELDS}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
const SETTINGS_INPUT_FIELDS = [
|
|
81
|
+
'enabled',
|
|
82
|
+
'currencyCode',
|
|
83
|
+
'defaultOverReceiptTolerancePct',
|
|
84
|
+
'velocityWindowDays',
|
|
85
|
+
'defaultCoverDays',
|
|
86
|
+
'reorderDigest',
|
|
87
|
+
];
|
|
88
|
+
/**
|
|
89
|
+
* Whether a failure is "this engine does not know that field yet": the document refused before
|
|
90
|
+
* it ran (the returns module's rule), never an execution-time refusal or a transient failure.
|
|
91
|
+
*/
|
|
92
|
+
function isUnknownFieldRejection(error) {
|
|
93
|
+
if (!(error instanceof ValidationError) || error.service !== 'vendure')
|
|
94
|
+
return false;
|
|
95
|
+
return (error.code === 'BAD_REQUEST' ||
|
|
96
|
+
error.code === 'GRAPHQL_VALIDATION_FAILED' ||
|
|
97
|
+
/Cannot query field/i.test(error.message));
|
|
98
|
+
}
|
|
99
|
+
/** The settings input: the picked fields, and `approvalThreshold` as given, `null` included. */
|
|
100
|
+
function settingsInputOf(input) {
|
|
101
|
+
const out = picked(input, SETTINGS_INPUT_FIELDS);
|
|
102
|
+
if (input.approvalThreshold !== undefined)
|
|
103
|
+
out.approvalThreshold = input.approvalThreshold;
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
/** An older engine's answer, with the threshold it does not have: approval off. */
|
|
107
|
+
function withoutThreshold(settings) {
|
|
108
|
+
return { ...settings, approvalThreshold: null };
|
|
109
|
+
}
|
|
110
|
+
const NUMBERING_INPUT_FIELDS = [
|
|
111
|
+
'kind',
|
|
112
|
+
'prefix',
|
|
113
|
+
'suffix',
|
|
114
|
+
'digits',
|
|
115
|
+
'yearFormat',
|
|
116
|
+
'yearReset',
|
|
117
|
+
];
|
|
118
|
+
/**
|
|
119
|
+
* Only the fields the engine's input declares, so a caller spreading what it read (which carries
|
|
120
|
+
* `scopeId`, `nextNumber`, …) sends just the change, and a field left out stays out.
|
|
121
|
+
*/
|
|
122
|
+
function picked(input, fields) {
|
|
123
|
+
const out = {};
|
|
124
|
+
for (const field of fields) {
|
|
125
|
+
const value = input[field];
|
|
126
|
+
if (value !== undefined && value !== null)
|
|
127
|
+
out[field] = value;
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
export function createPurchasingSettingsModule(transport) {
|
|
132
|
+
return {
|
|
133
|
+
async get(call) {
|
|
134
|
+
try {
|
|
135
|
+
const data = await transport.graphql({ api: 'admin', query: PURCHASING_SETTINGS_QUERY }, call);
|
|
136
|
+
return data.purchasingSettings;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (!isUnknownFieldRejection(error))
|
|
140
|
+
throw error;
|
|
141
|
+
const data = await transport.graphql({ api: 'admin', query: LEGACY_PURCHASING_SETTINGS_QUERY }, call);
|
|
142
|
+
return withoutThreshold(data.purchasingSettings);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
async update(input, call) {
|
|
146
|
+
const variables = {
|
|
147
|
+
input: settingsInputOf(input),
|
|
148
|
+
idempotencyKey: call?.idempotencyKey,
|
|
149
|
+
};
|
|
150
|
+
try {
|
|
151
|
+
const data = await transport.graphql({ api: 'admin', query: UPDATE_PURCHASING_SETTINGS_MUTATION, variables }, call);
|
|
152
|
+
return data.updatePurchasingSettings;
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
// A refused document ran nothing, so the retry is the one write. An input naming the
|
|
156
|
+
// threshold cannot be served by an engine without it: that refusal stands.
|
|
157
|
+
if (!isUnknownFieldRejection(error) || input.approvalThreshold !== undefined)
|
|
158
|
+
throw error;
|
|
159
|
+
const data = await transport.graphql({ api: 'admin', query: LEGACY_UPDATE_PURCHASING_SETTINGS_MUTATION, variables }, call);
|
|
160
|
+
return withoutThreshold(data.updatePurchasingSettings);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
numbering: {
|
|
164
|
+
async get(kind, call) {
|
|
165
|
+
const data = await transport.graphql({ api: 'admin', query: PURCHASING_NUMBERING_QUERY, variables: { kind } }, call);
|
|
166
|
+
return data.purchasingNumbering;
|
|
167
|
+
},
|
|
168
|
+
async update(input, call) {
|
|
169
|
+
const data = await transport.graphql({
|
|
170
|
+
api: 'admin',
|
|
171
|
+
query: UPDATE_PURCHASING_NUMBERING_MUTATION,
|
|
172
|
+
variables: {
|
|
173
|
+
input: picked(input, NUMBERING_INPUT_FIELDS),
|
|
174
|
+
idempotencyKey: call?.idempotencyKey,
|
|
175
|
+
},
|
|
176
|
+
}, call);
|
|
177
|
+
return data.updatePurchasingNumbering;
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|