@sixtyninecommerce/admin 0.9.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 +4598 -128
- 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 +318 -17
- package/dist/catalog/products.js +182 -14
- 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 +282 -25
- package/dist/catalog/variants.js +173 -25
- package/dist/catalog/visibility.d.ts +20 -5
- package/dist/catalog/visibility.js +19 -1
- package/dist/client.d.ts +116 -9
- package/dist/client.js +41 -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 +121 -10
- package/dist/fulfillments/index.js +120 -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 +129 -30
- package/dist/index.js +47 -9
- 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 +40 -0
- package/dist/integrations/index.js +24 -0
- package/dist/integrations/pipeline-keys.d.ts +13 -0
- package/dist/integrations/pipeline-keys.js +22 -0
- package/dist/integrations/pipelines.d.ts +114 -0
- package/dist/integrations/pipelines.js +46 -0
- package/dist/integrations/types.d.ts +322 -0
- package/dist/integrations/types.js +8 -0
- package/dist/jobs/bulk-action-run.d.ts +11 -2
- package/dist/jobs/bulk-action-run.js +4 -5
- 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/bulk.d.ts +75 -0
- package/dist/orders/bulk.js +150 -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/deposit-policy.d.ts +103 -0
- package/dist/orders/deposit-policy.js +202 -0
- 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 +125 -5
- package/dist/orders/index.js +35 -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-discounts.d.ts +11 -2
- package/dist/orders/manual-discounts.js +2 -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 +263 -10
- package/dist/payments/index.js +133 -1
- package/dist/payments/methods.d.ts +332 -0
- package/dist/payments/methods.js +363 -0
- 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 +177 -4
- package/dist/pricing/index.js +176 -1
- package/dist/pricing/price-lists.d.ts +604 -0
- package/dist/pricing/price-lists.js +600 -0
- package/dist/pricing/vouchers.d.ts +103 -0
- package/dist/pricing/vouchers.js +69 -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 +818 -0
- package/dist/returns/index.js +844 -0
- package/dist/search/index.d.ts +174 -0
- package/dist/search/index.js +125 -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 +51 -4
- 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/catalog/products.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ValidationError } from '@sixtyninecommerce/core';
|
|
2
2
|
import { bulkProducts, readProductBulkRun, } from './products-bulk.js';
|
|
3
|
-
import { ASSET_REF_FIELDS, assertDeleted, availabilityCustomFields, CATALOGUE_OWNERSHIP_FIELDS, DELETION_FIELDS, FACET_VALUE_REF_FIELDS, fieldOf, unwrapResult, vendureListPage, } from './types.js';
|
|
3
|
+
import { ASSET_REF_FIELDS, assertDeleted, availabilityCustomFields, CATALOGUE_OWNERSHIP_FIELDS, DELETION_FIELDS, FACET_VALUE_REF_FIELDS, fieldOf, toAssetRef, unwrapResult, vendureListPage, } from './types.js';
|
|
4
|
+
import { assertPricesStateBasis, } from './variants.js';
|
|
4
5
|
/** The engine's bound on one `exclude` or `include` call (`STORE_EXCLUSION_BATCH_LIMIT`). */
|
|
5
6
|
export const MAX_STORE_EXCLUSION_PRODUCTS = 500;
|
|
7
|
+
/** At most this many distinct products per {@link ProductsModule.storePriceRanges} call. */
|
|
8
|
+
export const MAX_STORE_PRICE_RANGE_PRODUCTS = 100;
|
|
6
9
|
/**
|
|
7
10
|
* The engine's bounds on one `setAvailabilityInStores` or `availabilityInStores` call
|
|
8
11
|
* (`AVAILABILITY_*_LIMIT`).
|
|
@@ -28,11 +31,19 @@ export const PRODUCT_FIELDS = /* GraphQL */ `
|
|
|
28
31
|
id
|
|
29
32
|
code
|
|
30
33
|
name
|
|
34
|
+
customFields {
|
|
35
|
+
isShared
|
|
36
|
+
}
|
|
31
37
|
options {
|
|
32
38
|
id
|
|
33
39
|
code
|
|
34
40
|
name
|
|
35
41
|
}
|
|
42
|
+
translations {
|
|
43
|
+
id
|
|
44
|
+
languageCode
|
|
45
|
+
name
|
|
46
|
+
}
|
|
36
47
|
}
|
|
37
48
|
translations {
|
|
38
49
|
id
|
|
@@ -49,6 +60,8 @@ export const PRODUCT_FIELDS = /* GraphQL */ `
|
|
|
49
60
|
availabilityState
|
|
50
61
|
availableFrom
|
|
51
62
|
preorderLimit
|
|
63
|
+
brand
|
|
64
|
+
condition
|
|
52
65
|
}
|
|
53
66
|
`;
|
|
54
67
|
export const PRODUCTS_QUERY = /* GraphQL */ `
|
|
@@ -59,9 +72,36 @@ export const PRODUCTS_QUERY = /* GraphQL */ `
|
|
|
59
72
|
}
|
|
60
73
|
}
|
|
61
74
|
`;
|
|
75
|
+
const STORE_PRICE_FIELDS = 'price priceWithTax currencyCode';
|
|
76
|
+
export const PRODUCT_STORE_PRICE_RANGES_QUERY = /* GraphQL */ `
|
|
77
|
+
query CatalogProductStorePriceRanges($options: ProductListOptions) {
|
|
78
|
+
products(options: $options) {
|
|
79
|
+
items {
|
|
80
|
+
id
|
|
81
|
+
storePriceRange {
|
|
82
|
+
min { ${STORE_PRICE_FIELDS} }
|
|
83
|
+
max { ${STORE_PRICE_FIELDS} }
|
|
84
|
+
someVariantsUnpriced
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
/**
|
|
91
|
+
* One product, with the collections it is in. No variant data beyond `variantList`'s count: a
|
|
92
|
+
* product can have 100,000 variants, and core's `variants` would hand back the first 1,000 with
|
|
93
|
+
* no sign of the rest (`catalog.variants.list` pages them).
|
|
94
|
+
*/
|
|
62
95
|
export const PRODUCT_QUERY = /* GraphQL */ `
|
|
63
96
|
query CatalogProduct($id: ID!) {
|
|
64
|
-
product(id: $id) {
|
|
97
|
+
product(id: $id) {
|
|
98
|
+
${PRODUCT_FIELDS}
|
|
99
|
+
collections {
|
|
100
|
+
id
|
|
101
|
+
name
|
|
102
|
+
slug
|
|
103
|
+
}
|
|
104
|
+
}
|
|
65
105
|
}
|
|
66
106
|
`;
|
|
67
107
|
export const CREATE_PRODUCT_MUTATION = /* GraphQL */ `
|
|
@@ -168,28 +208,66 @@ export const SET_PRODUCT_COLLECTIONS_MUTATION = /* GraphQL */ `
|
|
|
168
208
|
}
|
|
169
209
|
}
|
|
170
210
|
`;
|
|
211
|
+
export const SAVE_PRODUCT_MUTATION = /* GraphQL */ `
|
|
212
|
+
mutation CatalogSaveProduct($input: SaveProductInput!, $idempotencyKey: String) {
|
|
213
|
+
saveProduct(input: $input, idempotencyKey: $idempotencyKey) {
|
|
214
|
+
product { ${PRODUCT_FIELDS} }
|
|
215
|
+
collections {
|
|
216
|
+
added
|
|
217
|
+
removed
|
|
218
|
+
unchanged
|
|
219
|
+
notRemoved {
|
|
220
|
+
collectionId
|
|
221
|
+
reason
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
warnings {
|
|
225
|
+
code
|
|
226
|
+
message
|
|
227
|
+
propertyIds
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
`;
|
|
171
232
|
/**
|
|
172
233
|
* Lift the availability custom fields to first-class fields. A server older
|
|
173
234
|
* than the pre-order engine has no such fields and would refuse the document
|
|
174
235
|
* outright, so the defaults below only cover a NULL value, never an absent one.
|
|
175
236
|
*/
|
|
176
237
|
export function toProduct(wire) {
|
|
177
|
-
const { variantList, customFields, ...rest } = wire;
|
|
238
|
+
const { variantList, customFields, featuredAsset, assets, optionGroups, ...rest } = wire;
|
|
178
239
|
return {
|
|
179
240
|
...rest,
|
|
241
|
+
featuredAsset: featuredAsset ? toAssetRef(featuredAsset) : null,
|
|
242
|
+
assets: assets.map(toAssetRef),
|
|
243
|
+
optionGroups: optionGroups.map(({ customFields: groupFields, ...group }) => ({
|
|
244
|
+
...group,
|
|
245
|
+
isShared: groupFields?.isShared === true,
|
|
246
|
+
})),
|
|
180
247
|
variantCount: variantList.totalItems,
|
|
181
248
|
availabilityState: customFields?.availabilityState ?? 'none',
|
|
182
249
|
availableFrom: customFields?.availableFrom ?? null,
|
|
183
250
|
preorderLimit: customFields?.preorderLimit ?? null,
|
|
251
|
+
brand: customFields?.brand ?? null,
|
|
252
|
+
condition: customFields?.condition ?? null,
|
|
184
253
|
};
|
|
185
254
|
}
|
|
255
|
+
/** {@link toProduct}, plus the collections. */
|
|
256
|
+
function toProductDetail(wire) {
|
|
257
|
+
const { collections, ...rest } = wire;
|
|
258
|
+
return { ...toProduct(rest), collections };
|
|
259
|
+
}
|
|
186
260
|
function toWireInput(input) {
|
|
187
|
-
const { availabilityState, availableFrom, preorderLimit, ...rest } = input;
|
|
261
|
+
const { availabilityState, availableFrom, preorderLimit, brand, condition, ...rest } = input;
|
|
188
262
|
const customFields = availabilityCustomFields({
|
|
189
263
|
availabilityState,
|
|
190
264
|
availableFrom,
|
|
191
265
|
preorderLimit,
|
|
192
266
|
});
|
|
267
|
+
if (brand !== undefined)
|
|
268
|
+
customFields.brand = brand;
|
|
269
|
+
if (condition !== undefined)
|
|
270
|
+
customFields.condition = condition;
|
|
193
271
|
return Object.keys(customFields).length > 0 ? { ...rest, customFields } : rest;
|
|
194
272
|
}
|
|
195
273
|
export function productFilter(filter) {
|
|
@@ -211,6 +289,16 @@ export function productFilter(filter) {
|
|
|
211
289
|
}
|
|
212
290
|
return out;
|
|
213
291
|
}
|
|
292
|
+
/** The engine's `ProductListOptions` for one page of {@link ProductListOptions}. */
|
|
293
|
+
export function productListOptions(options, skip, take) {
|
|
294
|
+
const filter = productFilter(options?.filter);
|
|
295
|
+
return {
|
|
296
|
+
skip,
|
|
297
|
+
take,
|
|
298
|
+
...(Object.keys(filter).length > 0 ? { filter, filterOperator: 'AND' } : {}),
|
|
299
|
+
...(options?.sort ? { sort: { [options.sort.field]: options.sort.direction } } : {}),
|
|
300
|
+
};
|
|
301
|
+
}
|
|
214
302
|
function refuse(code, message) {
|
|
215
303
|
return new ValidationError({ code, message, status: 400, service: 'vendure' });
|
|
216
304
|
}
|
|
@@ -264,19 +352,11 @@ export function createProductsModule(transport) {
|
|
|
264
352
|
};
|
|
265
353
|
return {
|
|
266
354
|
async list(options) {
|
|
267
|
-
|
|
268
|
-
return vendureListPage(transport, PRODUCTS_QUERY, 'products', (skip, take) => ({
|
|
269
|
-
options: {
|
|
270
|
-
skip,
|
|
271
|
-
take,
|
|
272
|
-
...(Object.keys(filter).length > 0 ? { filter, filterOperator: 'AND' } : {}),
|
|
273
|
-
...(options?.sort ? { sort: { [options.sort.field]: options.sort.direction } } : {}),
|
|
274
|
-
},
|
|
275
|
-
}), options, toProduct);
|
|
355
|
+
return vendureListPage(transport, PRODUCTS_QUERY, 'products', (skip, take) => ({ options: productListOptions(options, skip, take) }), options, toProduct);
|
|
276
356
|
},
|
|
277
357
|
async get(id, options) {
|
|
278
358
|
const product = await fieldOf(transport, PRODUCT_QUERY, 'product', { id }, options);
|
|
279
|
-
return product ?
|
|
359
|
+
return product ? toProductDetail(product) : null;
|
|
280
360
|
},
|
|
281
361
|
// `async` so every refusal below — including `toWireInput`'s datetime
|
|
282
362
|
// check — arrives as a rejection, never as a synchronous throw a caller's
|
|
@@ -336,6 +416,27 @@ export function createProductsModule(transport) {
|
|
|
336
416
|
assertAvailabilityInput(input, 'read');
|
|
337
417
|
return fieldOf(transport, ORGANIZATION_PRODUCT_AVAILABILITY_QUERY, 'organizationProductAvailability', { productIds: input.productIds, channelIds: input.channelIds }, options);
|
|
338
418
|
},
|
|
419
|
+
async storePriceRanges(productIds, options) {
|
|
420
|
+
// The engine stores a uuid lower-case, so an upper-case repeat is the same product.
|
|
421
|
+
const named = new Map();
|
|
422
|
+
for (const id of productIds) {
|
|
423
|
+
const key = String(id).toLowerCase();
|
|
424
|
+
if (!named.has(key))
|
|
425
|
+
named.set(key, id);
|
|
426
|
+
}
|
|
427
|
+
if (named.size > MAX_STORE_PRICE_RANGE_PRODUCTS) {
|
|
428
|
+
throw refuse('PRODUCT_STORE_PRICE_RANGE_INPUT_INVALID', `Ask for at most ${String(MAX_STORE_PRICE_RANGE_PRODUCTS)} products per call; this one named ${String(named.size)}. Nothing was sent.`);
|
|
429
|
+
}
|
|
430
|
+
if (named.size === 0)
|
|
431
|
+
return [];
|
|
432
|
+
const ids = [...named.values()];
|
|
433
|
+
const page = await fieldOf(transport, PRODUCT_STORE_PRICE_RANGES_QUERY, 'products', { options: { filter: { id: { in: ids } }, take: ids.length } }, options);
|
|
434
|
+
const answered = new Map(page.items.map((item) => [item.id.toLowerCase(), item]));
|
|
435
|
+
return [...named.keys()].flatMap((key) => {
|
|
436
|
+
const item = answered.get(key);
|
|
437
|
+
return item ? [{ productId: item.id, range: item.storePriceRange }] : [];
|
|
438
|
+
});
|
|
439
|
+
},
|
|
339
440
|
async makeLocalCopy(productId, options) {
|
|
340
441
|
const { skus, ...call } = options ?? {};
|
|
341
442
|
const result = await fieldOf(transport, MAKE_LOCAL_COPY_MUTATION, 'makeLocalCopy', {
|
|
@@ -355,6 +456,15 @@ export function createProductsModule(transport) {
|
|
|
355
456
|
fromCollectionIds: from === undefined ? null : [...from],
|
|
356
457
|
}, call);
|
|
357
458
|
},
|
|
459
|
+
async save(input, options) {
|
|
460
|
+
assertCollectionLists({
|
|
461
|
+
collectionIds: input.collectionIds,
|
|
462
|
+
fromCollectionIds: input.fromCollectionIds,
|
|
463
|
+
});
|
|
464
|
+
await assertPricesStateBasis(transport, input.variants ?? [], options);
|
|
465
|
+
const result = await fieldOf(transport, SAVE_PRODUCT_MUTATION, 'saveProduct', { input: toWireSaveInput(input), idempotencyKey: options?.idempotencyKey ?? null }, options);
|
|
466
|
+
return { ...result, product: toProduct(result.product) };
|
|
467
|
+
},
|
|
358
468
|
bulk(input, options) {
|
|
359
469
|
return bulkProducts(transport, input, options);
|
|
360
470
|
},
|
|
@@ -363,3 +473,61 @@ export function createProductsModule(transport) {
|
|
|
363
473
|
},
|
|
364
474
|
};
|
|
365
475
|
}
|
|
476
|
+
/** The variant fields a save writes as custom fields on the wire. */
|
|
477
|
+
const SAVE_VARIANT_CUSTOM_FIELDS = [
|
|
478
|
+
'minOrderQuantity',
|
|
479
|
+
'salesUnit',
|
|
480
|
+
'cost',
|
|
481
|
+
'packageWeightGrams',
|
|
482
|
+
'packageLengthCm',
|
|
483
|
+
'packageWidthCm',
|
|
484
|
+
'packageHeightCm',
|
|
485
|
+
'parcelCapacity',
|
|
486
|
+
'parcelPacking',
|
|
487
|
+
'backorderPolicy',
|
|
488
|
+
'backorderLimit',
|
|
489
|
+
'gtin',
|
|
490
|
+
'mpn',
|
|
491
|
+
];
|
|
492
|
+
/** The SDK's flat save as the engine's `SaveProductInput`: custom fields nested, no basis. */
|
|
493
|
+
function toWireSaveInput(input) {
|
|
494
|
+
const wire = { id: input.id, languageCode: input.languageCode };
|
|
495
|
+
if (input.product) {
|
|
496
|
+
const { availabilityState, availableFrom, preorderLimit, brand, condition, ...rest } = input.product;
|
|
497
|
+
const customFields = availabilityCustomFields({
|
|
498
|
+
availabilityState,
|
|
499
|
+
availableFrom,
|
|
500
|
+
preorderLimit,
|
|
501
|
+
});
|
|
502
|
+
if (brand !== undefined)
|
|
503
|
+
customFields.brand = brand;
|
|
504
|
+
if (condition !== undefined)
|
|
505
|
+
customFields.condition = condition;
|
|
506
|
+
wire.product = Object.keys(customFields).length > 0 ? { ...rest, customFields } : rest;
|
|
507
|
+
}
|
|
508
|
+
if (input.variants) {
|
|
509
|
+
wire.variants = input.variants.map((variant) => {
|
|
510
|
+
const { availabilityState, availableFrom, preorderLimit, priceBasis, ...rest } = variant;
|
|
511
|
+
void priceBasis;
|
|
512
|
+
const customFields = availabilityCustomFields({
|
|
513
|
+
availabilityState,
|
|
514
|
+
availableFrom,
|
|
515
|
+
preorderLimit,
|
|
516
|
+
});
|
|
517
|
+
const out = { ...rest };
|
|
518
|
+
for (const key of SAVE_VARIANT_CUSTOM_FIELDS) {
|
|
519
|
+
if (key in out) {
|
|
520
|
+
if (out[key] !== undefined)
|
|
521
|
+
customFields[key] = out[key];
|
|
522
|
+
delete out[key];
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return Object.keys(customFields).length > 0 ? { ...out, customFields } : out;
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
for (const key of ['collectionIds', 'fromCollectionIds', 'propertyValues']) {
|
|
529
|
+
if (input[key] !== undefined)
|
|
530
|
+
wire[key] = input[key];
|
|
531
|
+
}
|
|
532
|
+
return wire;
|
|
533
|
+
}
|
|
@@ -33,6 +33,11 @@ export interface Property {
|
|
|
33
33
|
position: number;
|
|
34
34
|
config: PropertyConfig | null;
|
|
35
35
|
facetId: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* A filterable `content_item` property's field-level facets, one per content field it filters
|
|
38
|
+
* by, as `configureFieldFacets` last wrote them; null when it has none.
|
|
39
|
+
*/
|
|
40
|
+
fieldFacets: PropertyFieldFacet[] | null;
|
|
36
41
|
translations: Array<{
|
|
37
42
|
id: string;
|
|
38
43
|
languageCode: LanguageCode;
|
|
@@ -40,6 +45,25 @@ export interface Property {
|
|
|
40
45
|
helpText: string | null;
|
|
41
46
|
}>;
|
|
42
47
|
}
|
|
48
|
+
/** One field-level facet of a `content_item` property: the facet a content field's values fill. */
|
|
49
|
+
export interface PropertyFieldFacet {
|
|
50
|
+
fieldSlug: string;
|
|
51
|
+
/** The content field's type (`enum`, `multi_enum`, `boolean`). */
|
|
52
|
+
fieldType: string;
|
|
53
|
+
facetId: string;
|
|
54
|
+
}
|
|
55
|
+
/** A content field a `content_item` property filters by (`configureFieldFacets`). */
|
|
56
|
+
export interface FieldFacetDefinition {
|
|
57
|
+
/** The content type's field slug. */
|
|
58
|
+
fieldSlug: string;
|
|
59
|
+
/** The content field's type (`enum`, `multi_enum`, `boolean`). */
|
|
60
|
+
fieldType: string;
|
|
61
|
+
/** For an `enum` / `multi_enum` field: its options, each becoming one facet value. */
|
|
62
|
+
options?: Array<{
|
|
63
|
+
value: string;
|
|
64
|
+
label: string;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
43
67
|
export interface PropertyGroup {
|
|
44
68
|
id: string;
|
|
45
69
|
createdAt: string;
|
|
@@ -186,47 +210,111 @@ export interface ContentFacetSyncResult {
|
|
|
186
210
|
*/
|
|
187
211
|
export interface PropertiesModule {
|
|
188
212
|
groups: {
|
|
189
|
-
/**
|
|
213
|
+
/**
|
|
214
|
+
* The store's own groups, the complete list as one terminal page (the query takes no paging).
|
|
215
|
+
*
|
|
216
|
+
* @effect read
|
|
217
|
+
*/
|
|
190
218
|
list(options?: Call): Promise<Page<PropertyGroup>>;
|
|
219
|
+
/**
|
|
220
|
+
* One of the store's own groups, or null.
|
|
221
|
+
*
|
|
222
|
+
* @effect read
|
|
223
|
+
*/
|
|
191
224
|
get(id: string, options?: Call): Promise<PropertyGroup | null>;
|
|
225
|
+
/** @effect write */
|
|
192
226
|
create(input: CreatePropertyGroupInput, options?: Call): Promise<PropertyGroup>;
|
|
227
|
+
/** @effect write */
|
|
193
228
|
update(input: UpdatePropertyGroupInput, options?: Call): Promise<PropertyGroup>;
|
|
194
|
-
/**
|
|
229
|
+
/**
|
|
230
|
+
* Deletes the group AND every property in it, with their values on every product and the
|
|
231
|
+
* filter values (facets) the filterable ones mirror. Not undoable.
|
|
232
|
+
*
|
|
233
|
+
* @effect destructive
|
|
234
|
+
*/
|
|
195
235
|
delete(id: string, options?: Call): Promise<void>;
|
|
196
236
|
/**
|
|
197
237
|
* Pass EVERY group id of the store, in the order wanted. Only the store's own groups:
|
|
198
238
|
* a workspace group (`editableHere` false) or another store's id refuses the whole call.
|
|
239
|
+
*
|
|
240
|
+
* @effect write
|
|
199
241
|
*/
|
|
200
242
|
reorder(ids: string[], options?: Call): Promise<PropertyGroup[]>;
|
|
201
243
|
};
|
|
244
|
+
/** @effect write */
|
|
202
245
|
create(input: CreatePropertyInput, options?: Call): Promise<Property>;
|
|
246
|
+
/** @effect write */
|
|
203
247
|
update(input: UpdatePropertyInput, options?: Call): Promise<Property>;
|
|
248
|
+
/**
|
|
249
|
+
* Deletes the property with its values on every product, and the filter values (facets) a
|
|
250
|
+
* filterable one mirrors. Not undoable.
|
|
251
|
+
*
|
|
252
|
+
* @effect destructive
|
|
253
|
+
*/
|
|
204
254
|
delete(id: string, options?: Call): Promise<void>;
|
|
205
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* Pass every property id of the group, in the order wanted.
|
|
257
|
+
*
|
|
258
|
+
* @effect write
|
|
259
|
+
*/
|
|
206
260
|
reorder(groupId: string, propertyIds: string[], options?: Call): Promise<Property[]>;
|
|
261
|
+
/**
|
|
262
|
+
* Sets which content fields a filterable `content_item` property filters by: one field-level
|
|
263
|
+
* facet per field named, its values the field's options (an `enum` / `multi_enum` field) or
|
|
264
|
+
* yes/no (a `boolean` one). Needs `UpdateCatalog`.
|
|
265
|
+
*
|
|
266
|
+
* `fields` is the WHOLE set: a field already configured keeps its facet (its values follow the
|
|
267
|
+
* options sent), a new one gets a facet, and a field left out loses its facet, which is removed
|
|
268
|
+
* from every product of the store. `[]` removes them all. Send the fields the property was
|
|
269
|
+
* SAVED with (`config.filterableFieldSlugs`), never an unsaved form's. The products' field
|
|
270
|
+
* values are filled by `catalog.syncContentFacets`, not here. It resolves with nothing (the
|
|
271
|
+
* engine answers only that it is done): the property's `fieldFacets`, read again through
|
|
272
|
+
* `groups.get`, holds what was written.
|
|
273
|
+
*
|
|
274
|
+
* Refusals (nothing is written):
|
|
275
|
+
* - `PROPERTY_NOT_FOUND` → `NotFoundError` (404): no such property among the store's own groups.
|
|
276
|
+
* - `PROPERTY_FACET_SYNC_INVALID` → `ValidationError` (400): not a `content_item` property, or
|
|
277
|
+
* not saved as filterable.
|
|
278
|
+
* - `MANAGED_BY_ORGANIZATION` → `BusinessRuleError` (422): in a store of an organization, a
|
|
279
|
+
* property of the workspace's groups (`editableHere` false): configure it in the workspace.
|
|
280
|
+
*
|
|
281
|
+
* Not idempotent by key; repeating the same `fields` writes the same facets again.
|
|
282
|
+
*
|
|
283
|
+
* Destructive: a dropped field's facet and a dropped option's filter value leave every product.
|
|
284
|
+
*
|
|
285
|
+
* @effect destructive
|
|
286
|
+
*/
|
|
287
|
+
configureFieldFacets(propertyId: string, fields: FieldFacetDefinition[], options?: Call): Promise<void>;
|
|
207
288
|
values: {
|
|
208
289
|
/**
|
|
209
290
|
* Every group of the store, each with this product's stored values in every language. For a
|
|
210
291
|
* product the store holds from its organization, the workspace's groups and values come too,
|
|
211
292
|
* with `group.editableHere` false.
|
|
293
|
+
*
|
|
294
|
+
* @effect read
|
|
212
295
|
*/
|
|
213
296
|
get(productId: string, options?: Call): Promise<ProductPropertyGroupValues[]>;
|
|
214
|
-
/**
|
|
297
|
+
/**
|
|
298
|
+
* Upsert the given values; properties not named keep theirs.
|
|
299
|
+
*
|
|
300
|
+
* @effect write
|
|
301
|
+
*/
|
|
215
302
|
set(productId: string, values: SetPropertyValueInput[], options?: Call): Promise<void>;
|
|
216
303
|
};
|
|
217
304
|
}
|
|
218
|
-
export declare const PROPERTY_GROUP_FIELDS = "\n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n";
|
|
219
|
-
export declare const PROPERTY_GROUPS_QUERY = "\n query CatalogPropertyGroups {\n propertyGroups { \n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n }\n }\n";
|
|
220
|
-
export declare const PROPERTY_GROUP_QUERY = "\n query CatalogPropertyGroup($id: ID!) {\n propertyGroup(id: $id) { \n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n }\n }\n";
|
|
221
|
-
export declare const CREATE_PROPERTY_GROUP_MUTATION = "\n mutation CatalogCreatePropertyGroup($input: CreatePropertyGroupInput!) {\n createPropertyGroup(input: $input) { \n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n }\n }\n";
|
|
222
|
-
export declare const UPDATE_PROPERTY_GROUP_MUTATION = "\n mutation CatalogUpdatePropertyGroup($input: UpdatePropertyGroupInput!) {\n updatePropertyGroup(input: $input) { \n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n }\n }\n";
|
|
305
|
+
export declare const PROPERTY_GROUP_FIELDS = "\n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n fieldFacets {\n fieldSlug\n fieldType\n facetId\n }\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n";
|
|
306
|
+
export declare const PROPERTY_GROUPS_QUERY = "\n query CatalogPropertyGroups {\n propertyGroups { \n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n fieldFacets {\n fieldSlug\n fieldType\n facetId\n }\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n }\n }\n";
|
|
307
|
+
export declare const PROPERTY_GROUP_QUERY = "\n query CatalogPropertyGroup($id: ID!) {\n propertyGroup(id: $id) { \n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n fieldFacets {\n fieldSlug\n fieldType\n facetId\n }\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n }\n }\n";
|
|
308
|
+
export declare const CREATE_PROPERTY_GROUP_MUTATION = "\n mutation CatalogCreatePropertyGroup($input: CreatePropertyGroupInput!) {\n createPropertyGroup(input: $input) { \n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n fieldFacets {\n fieldSlug\n fieldType\n facetId\n }\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n }\n }\n";
|
|
309
|
+
export declare const UPDATE_PROPERTY_GROUP_MUTATION = "\n mutation CatalogUpdatePropertyGroup($input: UpdatePropertyGroupInput!) {\n updatePropertyGroup(input: $input) { \n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n fieldFacets {\n fieldSlug\n fieldType\n facetId\n }\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n }\n }\n";
|
|
223
310
|
export declare const DELETE_PROPERTY_GROUP_MUTATION = "\n mutation CatalogDeletePropertyGroup($id: ID!) {\n deletePropertyGroup(id: $id) { \n result\n message\n }\n }\n";
|
|
224
|
-
export declare const REORDER_PROPERTY_GROUPS_MUTATION = "\n mutation CatalogReorderPropertyGroups($ids: [ID!]!) {\n reorderPropertyGroups(ids: $ids) { \n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n }\n }\n";
|
|
225
|
-
export declare const CREATE_PROPERTY_MUTATION = "\n mutation CatalogCreateProperty($input: CreatePropertyInput!) {\n createProperty(input: $input) { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n }\n";
|
|
226
|
-
export declare const UPDATE_PROPERTY_MUTATION = "\n mutation CatalogUpdateProperty($input: UpdatePropertyInput!) {\n updateProperty(input: $input) { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n }\n";
|
|
311
|
+
export declare const REORDER_PROPERTY_GROUPS_MUTATION = "\n mutation CatalogReorderPropertyGroups($ids: [ID!]!) {\n reorderPropertyGroups(ids: $ids) { \n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n fieldFacets {\n fieldSlug\n fieldType\n facetId\n }\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n }\n }\n";
|
|
312
|
+
export declare const CREATE_PROPERTY_MUTATION = "\n mutation CatalogCreateProperty($input: CreatePropertyInput!) {\n createProperty(input: $input) { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n fieldFacets {\n fieldSlug\n fieldType\n facetId\n }\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n }\n";
|
|
313
|
+
export declare const UPDATE_PROPERTY_MUTATION = "\n mutation CatalogUpdateProperty($input: UpdatePropertyInput!) {\n updateProperty(input: $input) { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n fieldFacets {\n fieldSlug\n fieldType\n facetId\n }\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n }\n";
|
|
227
314
|
export declare const DELETE_PROPERTY_MUTATION = "\n mutation CatalogDeleteProperty($id: ID!) {\n deleteProperty(id: $id) { \n result\n message\n }\n }\n";
|
|
228
|
-
export declare const REORDER_PROPERTIES_MUTATION = "\n mutation CatalogReorderProperties($groupId: ID!, $propertyIds: [ID!]!) {\n reorderProperties(groupId: $groupId, propertyIds: $propertyIds) { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n }\n";
|
|
229
|
-
export declare const
|
|
315
|
+
export declare const REORDER_PROPERTIES_MUTATION = "\n mutation CatalogReorderProperties($groupId: ID!, $propertyIds: [ID!]!) {\n reorderProperties(groupId: $groupId, propertyIds: $propertyIds) { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n fieldFacets {\n fieldSlug\n fieldType\n facetId\n }\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n }\n";
|
|
316
|
+
export declare const CONFIGURE_FIELD_FACETS_MUTATION = "\n mutation CatalogConfigureFieldFacets($propertyId: ID!, $fields: [FieldFacetDefinitionInput!]!) {\n configureFieldFacets(propertyId: $propertyId, fields: $fields)\n }\n";
|
|
317
|
+
export declare const PRODUCT_PROPERTY_VALUES_QUERY = "\n query CatalogProductPropertyValues($productId: ID!) {\n productPropertyValues(productId: $productId) {\n group { \n id\n createdAt\n updatedAt\n position\n translations {\n id\n languageCode\n name\n }\n properties { \n id\n createdAt\n updatedAt\n slug\n fieldType\n isFilterable\n isRequired\n position\n config {\n options {\n value\n label\n }\n min\n max\n maxLength\n allowedCollectionIds\n filterableFieldSlugs\n productFilter\n }\n facetId\n fieldFacets {\n fieldSlug\n fieldType\n facetId\n }\n translations {\n id\n languageCode\n name\n helpText\n }\n }\n editableHere\n }\n values {\n id\n propertyId\n languageCode\n value\n }\n }\n }\n";
|
|
230
318
|
export declare const SET_PRODUCT_PROPERTY_VALUES_MUTATION = "\n mutation CatalogSetProductPropertyValues($productId: ID!, $values: [SetProductPropertyValueInput!]!) {\n setProductPropertyValues(productId: $productId, values: $values)\n }\n";
|
|
231
319
|
export declare const SYNC_PROPERTY_FACETS_MUTATION = "\n mutation CatalogSyncPropertyFacets($propertyId: ID!) {\n syncPropertyFacets(propertyId: $propertyId) {\n propertyId\n items\n unresolved\n fieldFacets\n }\n }\n";
|
|
232
320
|
/** `catalog.syncContentFacets`; its contract is on {@link CatalogModule.syncContentFacets}. */
|
|
@@ -22,6 +22,11 @@ const PROPERTY_FIELDS = /* GraphQL */ `
|
|
|
22
22
|
productFilter
|
|
23
23
|
}
|
|
24
24
|
facetId
|
|
25
|
+
fieldFacets {
|
|
26
|
+
fieldSlug
|
|
27
|
+
fieldType
|
|
28
|
+
facetId
|
|
29
|
+
}
|
|
25
30
|
translations {
|
|
26
31
|
id
|
|
27
32
|
languageCode
|
|
@@ -92,6 +97,11 @@ export const REORDER_PROPERTIES_MUTATION = /* GraphQL */ `
|
|
|
92
97
|
reorderProperties(groupId: $groupId, propertyIds: $propertyIds) { ${PROPERTY_FIELDS} }
|
|
93
98
|
}
|
|
94
99
|
`;
|
|
100
|
+
export const CONFIGURE_FIELD_FACETS_MUTATION = /* GraphQL */ `
|
|
101
|
+
mutation CatalogConfigureFieldFacets($propertyId: ID!, $fields: [FieldFacetDefinitionInput!]!) {
|
|
102
|
+
configureFieldFacets(propertyId: $propertyId, fields: $fields)
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
95
105
|
export const PRODUCT_PROPERTY_VALUES_QUERY = /* GraphQL */ `
|
|
96
106
|
query CatalogProductPropertyValues($productId: ID!) {
|
|
97
107
|
productPropertyValues(productId: $productId) {
|
|
@@ -148,6 +158,9 @@ export function createPropertiesModule(transport) {
|
|
|
148
158
|
update: (input, options) => call(UPDATE_PROPERTY_MUTATION, 'updateProperty', { input }, options),
|
|
149
159
|
delete: (id, options) => deleted(DELETE_PROPERTY_MUTATION, 'deleteProperty', 'PROPERTY_NOT_DELETED', id, options),
|
|
150
160
|
reorder: (groupId, propertyIds, options) => call(REORDER_PROPERTIES_MUTATION, 'reorderProperties', { groupId, propertyIds }, options),
|
|
161
|
+
async configureFieldFacets(propertyId, fields, options) {
|
|
162
|
+
await call(CONFIGURE_FIELD_FACETS_MUTATION, 'configureFieldFacets', { propertyId, fields }, options);
|
|
163
|
+
},
|
|
151
164
|
values: {
|
|
152
165
|
get: (productId, options) => call(PRODUCT_PROPERTY_VALUES_QUERY, 'productPropertyValues', { productId }, options),
|
|
153
166
|
async set(productId, values, options) {
|