@sixtyninecommerce/admin 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4347 -171
- package/dist/catalog/assets.d.ts +120 -8
- package/dist/catalog/assets.js +98 -12
- package/dist/catalog/collections.d.ts +279 -14
- package/dist/catalog/collections.js +246 -15
- package/dist/catalog/index.d.ts +9 -2
- package/dist/catalog/index.js +4 -0
- package/dist/catalog/products.d.ts +159 -19
- package/dist/catalog/products.js +88 -13
- package/dist/catalog/properties.d.ts +102 -14
- package/dist/catalog/properties.js +13 -0
- package/dist/catalog/recommendations.d.ts +261 -0
- package/dist/catalog/recommendations.js +145 -0
- package/dist/catalog/reviews.d.ts +368 -0
- package/dist/catalog/reviews.js +318 -0
- package/dist/catalog/types.d.ts +17 -1
- package/dist/catalog/types.js +10 -0
- package/dist/catalog/variant-find.d.ts +136 -0
- package/dist/catalog/variant-find.js +239 -0
- package/dist/catalog/variants.d.ts +233 -26
- package/dist/catalog/variants.js +125 -7
- package/dist/catalog/visibility.d.ts +20 -5
- package/dist/catalog/visibility.js +19 -1
- package/dist/client.d.ts +95 -9
- package/dist/client.js +35 -7
- package/dist/content/assets.d.ts +286 -0
- package/dist/content/assets.js +181 -0
- package/dist/content/items.d.ts +269 -0
- package/dist/content/items.js +170 -0
- package/dist/content/types.d.ts +282 -0
- package/dist/content/types.js +100 -0
- package/dist/customers/age-verification.d.ts +66 -0
- package/dist/customers/age-verification.js +79 -0
- package/dist/customers/credit.d.ts +263 -0
- package/dist/customers/credit.js +244 -0
- package/dist/customers/delivery-preferences.d.ts +120 -0
- package/dist/customers/delivery-preferences.js +97 -0
- package/dist/customers/groups.d.ts +207 -0
- package/dist/customers/groups.js +438 -0
- package/dist/customers/index.d.ts +447 -37
- package/dist/customers/index.js +313 -40
- package/dist/customers/invitation-status.d.ts +57 -0
- package/dist/customers/invitation-status.js +21 -0
- package/dist/customers/notes.d.ts +67 -0
- package/dist/customers/notes.js +51 -0
- package/dist/customers/notification-recipients.d.ts +97 -0
- package/dist/customers/notification-recipients.js +84 -0
- package/dist/customers/saved-lists.d.ts +42 -0
- package/dist/customers/saved-lists.js +61 -0
- package/dist/customers/vat.d.ts +83 -0
- package/dist/customers/vat.js +46 -0
- package/dist/customers/wire.d.ts +20 -0
- package/dist/customers/wire.js +35 -0
- package/dist/documents/ar.d.ts +307 -0
- package/dist/documents/ar.js +254 -0
- package/dist/documents/index.d.ts +731 -21
- package/dist/documents/index.js +436 -24
- package/dist/documents/pdf.d.ts +2 -0
- package/dist/documents/pdf.js +11 -0
- package/dist/fulfillments/create.d.ts +167 -0
- package/dist/fulfillments/create.js +216 -0
- package/dist/fulfillments/index.d.ts +44 -10
- package/dist/fulfillments/index.js +11 -2
- package/dist/fulfillments/payment-policy.d.ts +64 -0
- package/dist/fulfillments/payment-policy.js +140 -0
- package/dist/fulfillments/warehouse.d.ts +724 -0
- package/dist/fulfillments/warehouse.js +914 -0
- package/dist/geo/index.d.ts +119 -0
- package/dist/geo/index.js +107 -0
- package/dist/index.d.ts +123 -35
- package/dist/index.js +45 -12
- package/dist/integrations/afas-actions.d.ts +234 -0
- package/dist/integrations/afas-actions.js +310 -0
- package/dist/integrations/afas-types.d.ts +483 -0
- package/dist/integrations/afas-types.js +5 -0
- package/dist/integrations/afas.d.ts +234 -0
- package/dist/integrations/afas.js +290 -0
- package/dist/integrations/connections.d.ts +103 -0
- package/dist/integrations/connections.js +55 -0
- package/dist/integrations/esp.d.ts +313 -0
- package/dist/integrations/esp.js +169 -0
- package/dist/integrations/exact-online-types.d.ts +423 -0
- package/dist/integrations/exact-online-types.js +6 -0
- package/dist/integrations/exact-online.d.ts +248 -0
- package/dist/integrations/exact-online.js +376 -0
- package/dist/integrations/index.d.ts +29 -3
- package/dist/integrations/index.js +18 -3
- package/dist/integrations/pipeline-keys.d.ts +13 -0
- package/dist/integrations/pipeline-keys.js +22 -0
- package/dist/integrations/pipelines.d.ts +15 -14
- package/dist/integrations/pipelines.js +6 -22
- package/dist/integrations/types.d.ts +146 -0
- package/dist/locations/index.d.ts +66 -0
- package/dist/locations/index.js +31 -0
- package/dist/meta/index.d.ts +162 -0
- package/dist/orders/cancel-with-money.d.ts +227 -0
- package/dist/orders/cancel-with-money.js +153 -0
- package/dist/orders/commit-edit.d.ts +7 -1
- package/dist/orders/commit-edit.js +5 -1
- package/dist/orders/drafts.d.ts +800 -0
- package/dist/orders/drafts.js +771 -0
- package/dist/orders/fields.d.ts +245 -0
- package/dist/orders/fields.js +188 -0
- package/dist/orders/get.d.ts +29 -19
- package/dist/orders/get.js +17 -8
- package/dist/orders/index.d.ts +49 -9
- package/dist/orders/index.js +22 -2
- package/dist/orders/lifecycle.d.ts +128 -0
- package/dist/orders/lifecycle.js +158 -0
- package/dist/orders/line-price-preview.d.ts +7 -2
- package/dist/orders/list.d.ts +222 -0
- package/dist/orders/list.js +377 -0
- package/dist/orders/manual-pricing.d.ts +5 -0
- package/dist/orders/order-entry.d.ts +20 -7
- package/dist/orders/plan-edit.d.ts +1 -1
- package/dist/orders/plan-edit.js +4 -1
- package/dist/orders/settings.d.ts +201 -0
- package/dist/orders/settings.js +325 -0
- package/dist/orders/status.d.ts +159 -13
- package/dist/orders/status.js +21 -0
- package/dist/orders/surcharges.d.ts +8 -1
- package/dist/orders/surcharges.js +3 -2
- package/dist/payments/account-credit.d.ts +30 -0
- package/dist/payments/account-credit.js +19 -0
- package/dist/payments/ar.d.ts +292 -0
- package/dist/payments/ar.js +223 -0
- package/dist/payments/connected-account.d.ts +47 -0
- package/dist/payments/connected-account.js +61 -0
- package/dist/payments/credit-noted-fields.d.ts +12 -0
- package/dist/payments/credit-noted-fields.js +37 -0
- package/dist/payments/index.d.ts +257 -11
- package/dist/payments/index.js +131 -1
- package/dist/payments/methods.d.ts +303 -8
- package/dist/payments/methods.js +337 -7
- package/dist/payments/mollie-methods.d.ts +159 -0
- package/dist/payments/mollie-methods.js +141 -0
- package/dist/payments/payment-links.d.ts +180 -0
- package/dist/payments/payment-links.js +97 -0
- package/dist/payments/provider-keys.d.ts +150 -0
- package/dist/payments/provider-keys.js +118 -0
- package/dist/payments/providers.d.ts +86 -11
- package/dist/payments/providers.js +29 -0
- package/dist/payments/requests.d.ts +144 -0
- package/dist/payments/requests.js +92 -0
- package/dist/payments/store-credit-fields.d.ts +15 -0
- package/dist/payments/store-credit-fields.js +51 -0
- package/dist/pickups/index.d.ts +104 -0
- package/dist/pickups/index.js +105 -0
- package/dist/platform/channels.d.ts +132 -0
- package/dist/platform/channels.js +128 -0
- package/dist/platform/geo.d.ts +123 -0
- package/dist/platform/geo.js +144 -0
- package/dist/platform/tax.d.ts +154 -0
- package/dist/platform/tax.js +139 -0
- package/dist/pos/anomalies.d.ts +158 -0
- package/dist/pos/anomalies.js +64 -0
- package/dist/pos/assisted-selling.d.ts +79 -0
- package/dist/pos/assisted-selling.js +38 -0
- package/dist/pos/exchanges.d.ts +103 -0
- package/dist/pos/exchanges.js +22 -0
- package/dist/pos/gift-cards.d.ts +135 -0
- package/dist/pos/gift-cards.js +47 -0
- package/dist/pos/index.d.ts +2125 -32
- package/dist/pos/index.js +742 -4
- package/dist/pos/no-receipt.d.ts +94 -0
- package/dist/pos/no-receipt.js +25 -0
- package/dist/pos/offline-sales.d.ts +187 -0
- package/dist/pos/offline-sales.js +116 -0
- package/dist/pos/pay-by-link.d.ts +143 -0
- package/dist/pos/pay-by-link.js +57 -0
- package/dist/pos/quick-keys.d.ts +103 -0
- package/dist/pos/quick-keys.js +45 -0
- package/dist/pos/reports.d.ts +360 -0
- package/dist/pos/reports.js +62 -0
- package/dist/pos/returns.d.ts +217 -0
- package/dist/pos/returns.js +53 -0
- package/dist/pricing/bulk-coupons.d.ts +139 -0
- package/dist/pricing/bulk-coupons.js +112 -0
- package/dist/pricing/index.d.ts +174 -4
- package/dist/pricing/index.js +174 -1
- package/dist/pricing/price-lists.d.ts +604 -0
- package/dist/pricing/price-lists.js +600 -0
- package/dist/purchasing/alerts.d.ts +89 -0
- package/dist/purchasing/alerts.js +62 -0
- package/dist/purchasing/cost.d.ts +110 -0
- package/dist/purchasing/cost.js +86 -0
- package/dist/purchasing/index.d.ts +36 -0
- package/dist/purchasing/index.js +16 -0
- package/dist/purchasing/purchase-orders.d.ts +548 -0
- package/dist/purchasing/purchase-orders.js +491 -0
- package/dist/purchasing/replenishment.d.ts +281 -0
- package/dist/purchasing/replenishment.js +240 -0
- package/dist/purchasing/settings.d.ts +152 -0
- package/dist/purchasing/settings.js +181 -0
- package/dist/purchasing/suppliers.d.ts +476 -0
- package/dist/purchasing/suppliers.js +438 -0
- package/dist/quotes/index.d.ts +501 -0
- package/dist/quotes/index.js +439 -0
- package/dist/reports/index.d.ts +71 -8
- package/dist/reports/index.js +74 -11
- package/dist/returns/index.d.ts +614 -21
- package/dist/returns/index.js +695 -11
- package/dist/search/index.d.ts +76 -1
- package/dist/search/index.js +63 -0
- package/dist/shipping/definitions.d.ts +29 -0
- package/dist/shipping/definitions.js +47 -0
- package/dist/shipping/fulfillment-profiles.d.ts +174 -0
- package/dist/shipping/fulfillment-profiles.js +104 -0
- package/dist/shipping/hendriks.d.ts +97 -0
- package/dist/shipping/hendriks.js +50 -0
- package/dist/shipping/index.d.ts +48 -0
- package/dist/shipping/index.js +25 -0
- package/dist/shipping/methods.d.ts +198 -0
- package/dist/shipping/methods.js +240 -0
- package/dist/shipping/myparcel.d.ts +254 -0
- package/dist/shipping/myparcel.js +178 -0
- package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
- package/dist/shipping/parcel-rule.d.ts +6 -5
- package/dist/shipping/parcel-rule.js +21 -23
- package/dist/shipping/rate-tables.d.ts +179 -0
- package/dist/shipping/rate-tables.js +184 -0
- package/dist/stock/index.d.ts +10 -3
- package/dist/stock/index.js +3 -0
- package/dist/stock/locations.d.ts +144 -0
- package/dist/stock/locations.js +168 -0
- package/dist/stock/transfers.d.ts +216 -43
- package/dist/stock/transfers.js +140 -13
- package/dist/stored-value/index.d.ts +214 -4
- package/dist/stored-value/index.js +152 -0
- package/dist/subscriptions/index.d.ts +682 -0
- package/dist/subscriptions/index.js +815 -0
- package/dist/tax/index.d.ts +76 -1
- package/dist/tax/index.js +50 -0
- package/dist/tenant/email-style.d.ts +102 -0
- package/dist/tenant/email-style.js +72 -0
- package/dist/tenant/email-templates.d.ts +66 -0
- package/dist/tenant/email-templates.js +54 -0
- package/dist/tenant/notifications.d.ts +23 -17
- package/dist/tenant/settings-sources.d.ts +1 -1
- package/dist/tenant/time-zone.d.ts +17 -0
- package/dist/tenant/time-zone.js +11 -0
- package/dist/types.d.ts +50 -3
- package/dist/users/index.d.ts +3 -0
- package/dist/users/index.js +2 -0
- package/dist/users/warehouses.d.ts +50 -0
- package/dist/users/warehouses.js +51 -0
- package/package.json +2 -2
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import { pageFromVendureList, readOffsetCursor, } from '@sixtyninecommerce/core';
|
|
2
|
+
export const SUPPLIER_CONTACT_FIELDS = /* GraphQL */ `
|
|
3
|
+
id
|
|
4
|
+
supplierId
|
|
5
|
+
name
|
|
6
|
+
email
|
|
7
|
+
phone
|
|
8
|
+
role
|
|
9
|
+
isOrderContact
|
|
10
|
+
createdAt
|
|
11
|
+
updatedAt
|
|
12
|
+
`;
|
|
13
|
+
export const SUPPLIER_FIELDS = /* GraphQL */ `
|
|
14
|
+
id
|
|
15
|
+
scopeId
|
|
16
|
+
legalEntityId
|
|
17
|
+
originChannelId
|
|
18
|
+
code
|
|
19
|
+
name
|
|
20
|
+
legalName
|
|
21
|
+
vatNumber
|
|
22
|
+
vatTreatment
|
|
23
|
+
countryCode
|
|
24
|
+
currencyCode
|
|
25
|
+
paymentTerms
|
|
26
|
+
paymentTermsDays
|
|
27
|
+
incoterm
|
|
28
|
+
defaultLeadTimeDays
|
|
29
|
+
overReceiptTolerancePct
|
|
30
|
+
noBackorders
|
|
31
|
+
orderEmail
|
|
32
|
+
address { streetLine1 streetLine2 postalCode city province countryCode }
|
|
33
|
+
notes
|
|
34
|
+
status
|
|
35
|
+
managedBy
|
|
36
|
+
contacts { ${SUPPLIER_CONTACT_FIELDS} }
|
|
37
|
+
createdAt
|
|
38
|
+
updatedAt
|
|
39
|
+
`;
|
|
40
|
+
export const SUPPLIERS_QUERY = /* GraphQL */ `
|
|
41
|
+
query Suppliers($options: SupplierListOptions) {
|
|
42
|
+
suppliers(options: $options) {
|
|
43
|
+
totalItems
|
|
44
|
+
items { ${SUPPLIER_FIELDS} }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
export const SUPPLIER_QUERY = /* GraphQL */ `
|
|
49
|
+
query Supplier($id: ID!) {
|
|
50
|
+
supplier(id: $id) { ${SUPPLIER_FIELDS} }
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
export const CREATE_SUPPLIER_MUTATION = /* GraphQL */ `
|
|
54
|
+
mutation CreateSupplier($input: CreateSupplierInput!, $idempotencyKey: String) {
|
|
55
|
+
createSupplier(input: $input, idempotencyKey: $idempotencyKey) { ${SUPPLIER_FIELDS} }
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
export const UPDATE_SUPPLIER_MUTATION = /* GraphQL */ `
|
|
59
|
+
mutation UpdateSupplier($input: UpdateSupplierInput!, $idempotencyKey: String) {
|
|
60
|
+
updateSupplier(input: $input, idempotencyKey: $idempotencyKey) { ${SUPPLIER_FIELDS} }
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
export const ARCHIVE_SUPPLIER_MUTATION = /* GraphQL */ `
|
|
64
|
+
mutation ArchiveSupplier($id: ID!, $reason: String, $idempotencyKey: String) {
|
|
65
|
+
archiveSupplier(id: $id, reason: $reason, idempotencyKey: $idempotencyKey) {
|
|
66
|
+
${SUPPLIER_FIELDS}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
export const RESTORE_SUPPLIER_MUTATION = /* GraphQL */ `
|
|
71
|
+
mutation RestoreSupplier($id: ID!, $reason: String, $idempotencyKey: String) {
|
|
72
|
+
restoreSupplier(id: $id, reason: $reason, idempotencyKey: $idempotencyKey) {
|
|
73
|
+
${SUPPLIER_FIELDS}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
export const CREATE_SUPPLIER_CONTACT_MUTATION = /* GraphQL */ `
|
|
78
|
+
mutation CreateSupplierContact($input: CreateSupplierContactInput!, $idempotencyKey: String) {
|
|
79
|
+
createSupplierContact(input: $input, idempotencyKey: $idempotencyKey) {
|
|
80
|
+
${SUPPLIER_CONTACT_FIELDS}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
export const UPDATE_SUPPLIER_CONTACT_MUTATION = /* GraphQL */ `
|
|
85
|
+
mutation UpdateSupplierContact($input: UpdateSupplierContactInput!, $idempotencyKey: String) {
|
|
86
|
+
updateSupplierContact(input: $input, idempotencyKey: $idempotencyKey) {
|
|
87
|
+
${SUPPLIER_CONTACT_FIELDS}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
export const DELETE_SUPPLIER_CONTACT_MUTATION = /* GraphQL */ `
|
|
92
|
+
mutation DeleteSupplierContact($id: ID!, $idempotencyKey: String) {
|
|
93
|
+
deleteSupplierContact(id: $id, idempotencyKey: $idempotencyKey)
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
export const SUPPLIER_ITEM_FIELDS = /* GraphQL */ `
|
|
97
|
+
id
|
|
98
|
+
supplierId
|
|
99
|
+
supplier { id code name status currencyCode }
|
|
100
|
+
scopeId
|
|
101
|
+
legalEntityId
|
|
102
|
+
productVariantId
|
|
103
|
+
productVariant { id sku name }
|
|
104
|
+
supplierSku
|
|
105
|
+
supplierBarcode
|
|
106
|
+
purchaseUnitLabel
|
|
107
|
+
purchaseUnitFactor
|
|
108
|
+
minimumQuantity
|
|
109
|
+
orderMultiple
|
|
110
|
+
leadTimeDays
|
|
111
|
+
preferred
|
|
112
|
+
dropShip
|
|
113
|
+
managedBy
|
|
114
|
+
prices { id currencyCode minQuantity unitPrice validFrom validUntil }
|
|
115
|
+
createdAt
|
|
116
|
+
updatedAt
|
|
117
|
+
`;
|
|
118
|
+
export const SUPPLIER_ITEMS_QUERY = /* GraphQL */ `
|
|
119
|
+
query SupplierItems($supplierId: ID!, $options: SupplierItemListOptions) {
|
|
120
|
+
supplierItems(supplierId: $supplierId, options: $options) {
|
|
121
|
+
totalItems
|
|
122
|
+
items { ${SUPPLIER_ITEM_FIELDS} }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
`;
|
|
126
|
+
export const VARIANT_SUPPLIER_ITEMS_QUERY = /* GraphQL */ `
|
|
127
|
+
query VariantSupplierItems($productVariantId: ID!) {
|
|
128
|
+
variantSupplierItems(productVariantId: $productVariantId) { ${SUPPLIER_ITEM_FIELDS} }
|
|
129
|
+
}
|
|
130
|
+
`;
|
|
131
|
+
export const UPSERT_SUPPLIER_ITEM_MUTATION = /* GraphQL */ `
|
|
132
|
+
mutation UpsertSupplierItem($input: UpsertSupplierItemInput!, $idempotencyKey: String) {
|
|
133
|
+
upsertSupplierItem(input: $input, idempotencyKey: $idempotencyKey) { ${SUPPLIER_ITEM_FIELDS} }
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
export const DELETE_SUPPLIER_ITEM_MUTATION = /* GraphQL */ `
|
|
137
|
+
mutation DeleteSupplierItem($id: ID!, $idempotencyKey: String) {
|
|
138
|
+
deleteSupplierItem(id: $id, idempotencyKey: $idempotencyKey)
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
export const SET_SUPPLIER_ITEM_PRICES_MUTATION = /* GraphQL */ `
|
|
142
|
+
mutation SetSupplierItemPrices(
|
|
143
|
+
$supplierItemId: ID!
|
|
144
|
+
$prices: [SupplierItemPriceInput!]!
|
|
145
|
+
$currencyCode: CurrencyCode
|
|
146
|
+
$idempotencyKey: String
|
|
147
|
+
) {
|
|
148
|
+
setSupplierItemPrices(
|
|
149
|
+
supplierItemId: $supplierItemId
|
|
150
|
+
prices: $prices
|
|
151
|
+
currencyCode: $currencyCode
|
|
152
|
+
idempotencyKey: $idempotencyKey
|
|
153
|
+
) { ${SUPPLIER_ITEM_FIELDS} }
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
156
|
+
export const SUPPLIER_ITEM_IMPORT_RESULT_FIELDS = /* GraphQL */ `
|
|
157
|
+
dryRun
|
|
158
|
+
contentHash
|
|
159
|
+
ignoredColumns
|
|
160
|
+
totalRows
|
|
161
|
+
created
|
|
162
|
+
updated
|
|
163
|
+
unchanged
|
|
164
|
+
failed
|
|
165
|
+
rows { row supplierCode sku outcome supplierItemId errorCode message }
|
|
166
|
+
`;
|
|
167
|
+
export const IMPORT_SUPPLIER_PRICE_LIST_MUTATION = /* GraphQL */ `
|
|
168
|
+
mutation ImportSupplierPriceList(
|
|
169
|
+
$input: ImportSupplierPriceListInput!
|
|
170
|
+
$idempotencyKey: String
|
|
171
|
+
) {
|
|
172
|
+
importSupplierPriceList(input: $input, idempotencyKey: $idempotencyKey) {
|
|
173
|
+
${SUPPLIER_ITEM_IMPORT_RESULT_FIELDS}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
`;
|
|
177
|
+
export const BULK_UPSERT_SUPPLIER_ITEMS_MUTATION = /* GraphQL */ `
|
|
178
|
+
mutation BulkUpsertSupplierItems(
|
|
179
|
+
$input: BulkUpsertSupplierItemsInput!
|
|
180
|
+
$idempotencyKey: String
|
|
181
|
+
) {
|
|
182
|
+
bulkUpsertSupplierItems(input: $input, idempotencyKey: $idempotencyKey) {
|
|
183
|
+
${SUPPLIER_ITEM_IMPORT_RESULT_FIELDS}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
`;
|
|
187
|
+
/** The engine's own default page; it refuses a page above 100. */
|
|
188
|
+
const DEFAULT_PAGE_SIZE = 50;
|
|
189
|
+
const SUPPLIER_INPUT_FIELDS = [
|
|
190
|
+
'code',
|
|
191
|
+
'name',
|
|
192
|
+
'legalName',
|
|
193
|
+
'vatNumber',
|
|
194
|
+
'vatTreatment',
|
|
195
|
+
'countryCode',
|
|
196
|
+
'currencyCode',
|
|
197
|
+
'paymentTerms',
|
|
198
|
+
'paymentTermsDays',
|
|
199
|
+
'incoterm',
|
|
200
|
+
'defaultLeadTimeDays',
|
|
201
|
+
'overReceiptTolerancePct',
|
|
202
|
+
'noBackorders',
|
|
203
|
+
'orderEmail',
|
|
204
|
+
'address',
|
|
205
|
+
'notes',
|
|
206
|
+
];
|
|
207
|
+
const ADDRESS_INPUT_FIELDS = [
|
|
208
|
+
'streetLine1',
|
|
209
|
+
'streetLine2',
|
|
210
|
+
'postalCode',
|
|
211
|
+
'city',
|
|
212
|
+
'province',
|
|
213
|
+
'countryCode',
|
|
214
|
+
];
|
|
215
|
+
const CONTACT_INPUT_FIELDS = [
|
|
216
|
+
'name',
|
|
217
|
+
'email',
|
|
218
|
+
'phone',
|
|
219
|
+
'role',
|
|
220
|
+
'isOrderContact',
|
|
221
|
+
];
|
|
222
|
+
const LIST_FILTERS = ['status', 'name', 'code', 'term'];
|
|
223
|
+
const ITEM_INPUT_FIELDS = [
|
|
224
|
+
'supplierSku',
|
|
225
|
+
'supplierBarcode',
|
|
226
|
+
'purchaseUnitLabel',
|
|
227
|
+
'purchaseUnitFactor',
|
|
228
|
+
'minimumQuantity',
|
|
229
|
+
'orderMultiple',
|
|
230
|
+
'leadTimeDays',
|
|
231
|
+
'preferred',
|
|
232
|
+
'dropShip',
|
|
233
|
+
];
|
|
234
|
+
const PRICE_INPUT_FIELDS = [
|
|
235
|
+
'currencyCode',
|
|
236
|
+
'minQuantity',
|
|
237
|
+
'unitPrice',
|
|
238
|
+
'validFrom',
|
|
239
|
+
'validUntil',
|
|
240
|
+
];
|
|
241
|
+
const ROW_INPUT_FIELDS = [
|
|
242
|
+
'supplierCode',
|
|
243
|
+
'sku',
|
|
244
|
+
...ITEM_INPUT_FIELDS,
|
|
245
|
+
...PRICE_INPUT_FIELDS,
|
|
246
|
+
];
|
|
247
|
+
/**
|
|
248
|
+
* Only the fields the engine's input declares, so a caller spreading what it read (which carries
|
|
249
|
+
* `id`, `contacts`, `createdAt`, …) sends just the fields, and a field left out stays out. `null`
|
|
250
|
+
* is sent as `null` (cleared).
|
|
251
|
+
*/
|
|
252
|
+
function picked(input, fields) {
|
|
253
|
+
const out = {};
|
|
254
|
+
for (const field of fields) {
|
|
255
|
+
const value = input[field];
|
|
256
|
+
if (value !== undefined)
|
|
257
|
+
out[field] = value;
|
|
258
|
+
}
|
|
259
|
+
return out;
|
|
260
|
+
}
|
|
261
|
+
function supplierInputOf(input) {
|
|
262
|
+
const out = picked(input, SUPPLIER_INPUT_FIELDS);
|
|
263
|
+
if (out.address !== undefined && out.address !== null) {
|
|
264
|
+
out.address = picked(out.address, ADDRESS_INPUT_FIELDS);
|
|
265
|
+
}
|
|
266
|
+
return out;
|
|
267
|
+
}
|
|
268
|
+
export function createPurchasingSuppliersModule(transport) {
|
|
269
|
+
const listPage = async (skip, take, options) => {
|
|
270
|
+
const filters = options ? picked(options, LIST_FILTERS) : {};
|
|
271
|
+
const data = await transport.graphql({ api: 'admin', query: SUPPLIERS_QUERY, variables: { options: { skip, take, ...filters } } }, options);
|
|
272
|
+
return pageFromVendureList(data.suppliers, skip, take, (cursor) => listPage(readOffsetCursor(cursor), take, options));
|
|
273
|
+
};
|
|
274
|
+
const status = async (mutation, field, id, options) => {
|
|
275
|
+
const data = await transport.graphql({
|
|
276
|
+
api: 'admin',
|
|
277
|
+
query: mutation,
|
|
278
|
+
variables: {
|
|
279
|
+
id,
|
|
280
|
+
...(options?.reason === undefined ? {} : { reason: options.reason }),
|
|
281
|
+
idempotencyKey: options?.idempotencyKey,
|
|
282
|
+
},
|
|
283
|
+
}, options);
|
|
284
|
+
return data[field];
|
|
285
|
+
};
|
|
286
|
+
const itemsPage = async (supplierId, skip, take, options) => {
|
|
287
|
+
const data = await transport.graphql({
|
|
288
|
+
api: 'admin',
|
|
289
|
+
query: SUPPLIER_ITEMS_QUERY,
|
|
290
|
+
variables: {
|
|
291
|
+
supplierId,
|
|
292
|
+
options: { skip, take, ...(options?.term === undefined ? {} : { term: options.term }) },
|
|
293
|
+
},
|
|
294
|
+
}, options);
|
|
295
|
+
return pageFromVendureList(data.supplierItems, skip, take, (cursor) => itemsPage(supplierId, readOffsetCursor(cursor), take, options));
|
|
296
|
+
};
|
|
297
|
+
return {
|
|
298
|
+
async list(options) {
|
|
299
|
+
const take = options?.limit ?? DEFAULT_PAGE_SIZE;
|
|
300
|
+
const skip = options?.after === undefined ? 0 : readOffsetCursor(options.after);
|
|
301
|
+
return listPage(skip, take, options);
|
|
302
|
+
},
|
|
303
|
+
async get(id, call) {
|
|
304
|
+
const data = await transport.graphql({ api: 'admin', query: SUPPLIER_QUERY, variables: { id } }, call);
|
|
305
|
+
return data.supplier;
|
|
306
|
+
},
|
|
307
|
+
async create(input, call) {
|
|
308
|
+
const data = await transport.graphql({
|
|
309
|
+
api: 'admin',
|
|
310
|
+
query: CREATE_SUPPLIER_MUTATION,
|
|
311
|
+
variables: { input: supplierInputOf(input), idempotencyKey: call?.idempotencyKey },
|
|
312
|
+
}, call);
|
|
313
|
+
return data.createSupplier;
|
|
314
|
+
},
|
|
315
|
+
async update(id, input, call) {
|
|
316
|
+
const data = await transport.graphql({
|
|
317
|
+
api: 'admin',
|
|
318
|
+
query: UPDATE_SUPPLIER_MUTATION,
|
|
319
|
+
variables: {
|
|
320
|
+
input: { ...supplierInputOf(input), id },
|
|
321
|
+
idempotencyKey: call?.idempotencyKey,
|
|
322
|
+
},
|
|
323
|
+
}, call);
|
|
324
|
+
return data.updateSupplier;
|
|
325
|
+
},
|
|
326
|
+
archive(id, options) {
|
|
327
|
+
return status(ARCHIVE_SUPPLIER_MUTATION, 'archiveSupplier', id, options);
|
|
328
|
+
},
|
|
329
|
+
restore(id, options) {
|
|
330
|
+
return status(RESTORE_SUPPLIER_MUTATION, 'restoreSupplier', id, options);
|
|
331
|
+
},
|
|
332
|
+
contacts: {
|
|
333
|
+
async create(supplierId, input, call) {
|
|
334
|
+
const data = await transport.graphql({
|
|
335
|
+
api: 'admin',
|
|
336
|
+
query: CREATE_SUPPLIER_CONTACT_MUTATION,
|
|
337
|
+
variables: {
|
|
338
|
+
input: { ...picked(input, CONTACT_INPUT_FIELDS), supplierId },
|
|
339
|
+
idempotencyKey: call?.idempotencyKey,
|
|
340
|
+
},
|
|
341
|
+
}, call);
|
|
342
|
+
return data.createSupplierContact;
|
|
343
|
+
},
|
|
344
|
+
async update(id, input, call) {
|
|
345
|
+
const data = await transport.graphql({
|
|
346
|
+
api: 'admin',
|
|
347
|
+
query: UPDATE_SUPPLIER_CONTACT_MUTATION,
|
|
348
|
+
variables: {
|
|
349
|
+
input: { ...picked(input, CONTACT_INPUT_FIELDS), id },
|
|
350
|
+
idempotencyKey: call?.idempotencyKey,
|
|
351
|
+
},
|
|
352
|
+
}, call);
|
|
353
|
+
return data.updateSupplierContact;
|
|
354
|
+
},
|
|
355
|
+
async delete(id, call) {
|
|
356
|
+
const data = await transport.graphql({
|
|
357
|
+
api: 'admin',
|
|
358
|
+
query: DELETE_SUPPLIER_CONTACT_MUTATION,
|
|
359
|
+
variables: { id, idempotencyKey: call?.idempotencyKey },
|
|
360
|
+
}, call);
|
|
361
|
+
return data.deleteSupplierContact;
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
items: {
|
|
365
|
+
async list(supplierId, options) {
|
|
366
|
+
const take = options?.limit ?? DEFAULT_PAGE_SIZE;
|
|
367
|
+
const skip = options?.after === undefined ? 0 : readOffsetCursor(options.after);
|
|
368
|
+
return itemsPage(supplierId, skip, take, options);
|
|
369
|
+
},
|
|
370
|
+
async forVariant(productVariantId, call) {
|
|
371
|
+
const data = await transport.graphql({ api: 'admin', query: VARIANT_SUPPLIER_ITEMS_QUERY, variables: { productVariantId } }, call);
|
|
372
|
+
return data.variantSupplierItems;
|
|
373
|
+
},
|
|
374
|
+
async upsert(supplierId, productVariantId, input = {}, call) {
|
|
375
|
+
const data = await transport.graphql({
|
|
376
|
+
api: 'admin',
|
|
377
|
+
query: UPSERT_SUPPLIER_ITEM_MUTATION,
|
|
378
|
+
variables: {
|
|
379
|
+
input: { ...picked(input, ITEM_INPUT_FIELDS), supplierId, productVariantId },
|
|
380
|
+
idempotencyKey: call?.idempotencyKey,
|
|
381
|
+
},
|
|
382
|
+
}, call);
|
|
383
|
+
return data.upsertSupplierItem;
|
|
384
|
+
},
|
|
385
|
+
async delete(id, call) {
|
|
386
|
+
const data = await transport.graphql({
|
|
387
|
+
api: 'admin',
|
|
388
|
+
query: DELETE_SUPPLIER_ITEM_MUTATION,
|
|
389
|
+
variables: { id, idempotencyKey: call?.idempotencyKey },
|
|
390
|
+
}, call);
|
|
391
|
+
return data.deleteSupplierItem;
|
|
392
|
+
},
|
|
393
|
+
prices: {
|
|
394
|
+
async set(supplierItemId, prices, options) {
|
|
395
|
+
const data = await transport.graphql({
|
|
396
|
+
api: 'admin',
|
|
397
|
+
query: SET_SUPPLIER_ITEM_PRICES_MUTATION,
|
|
398
|
+
variables: {
|
|
399
|
+
supplierItemId,
|
|
400
|
+
// A spread read carries `id`: only the input's fields are sent.
|
|
401
|
+
prices: prices.map((price) => picked(price, PRICE_INPUT_FIELDS)),
|
|
402
|
+
...(options?.currencyCode === undefined
|
|
403
|
+
? {}
|
|
404
|
+
: { currencyCode: options.currencyCode }),
|
|
405
|
+
idempotencyKey: options?.idempotencyKey,
|
|
406
|
+
},
|
|
407
|
+
}, options);
|
|
408
|
+
return data.setSupplierItemPrices;
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
async import(input, call) {
|
|
412
|
+
const data = await transport.graphql({
|
|
413
|
+
api: 'admin',
|
|
414
|
+
query: IMPORT_SUPPLIER_PRICE_LIST_MUTATION,
|
|
415
|
+
variables: {
|
|
416
|
+
input: picked(input, ['content', 'supplierId', 'dryRun']),
|
|
417
|
+
idempotencyKey: call?.idempotencyKey,
|
|
418
|
+
},
|
|
419
|
+
}, call);
|
|
420
|
+
return data.importSupplierPriceList;
|
|
421
|
+
},
|
|
422
|
+
async bulkUpsert(input, call) {
|
|
423
|
+
const data = await transport.graphql({
|
|
424
|
+
api: 'admin',
|
|
425
|
+
query: BULK_UPSERT_SUPPLIER_ITEMS_MUTATION,
|
|
426
|
+
variables: {
|
|
427
|
+
input: {
|
|
428
|
+
...picked(input, ['supplierId', 'dryRun']),
|
|
429
|
+
rows: input.rows.map((row) => picked(row, ROW_INPUT_FIELDS)),
|
|
430
|
+
},
|
|
431
|
+
idempotencyKey: call?.idempotencyKey,
|
|
432
|
+
},
|
|
433
|
+
}, call);
|
|
434
|
+
return data.bulkUpsertSupplierItems;
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
};
|
|
438
|
+
}
|