@faststore/api 1.10.6 → 1.10.8
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/CHANGELOG.md +11 -0
- package/dist/api.cjs.development.js +38 -3
- package/dist/api.cjs.development.js.map +1 -1
- package/dist/api.cjs.production.min.js +1 -1
- package/dist/api.cjs.production.min.js.map +1 -1
- package/dist/api.esm.js +38 -3
- package/dist/api.esm.js.map +1 -1
- package/dist/platforms/vtex/clients/commerce/index.d.ts +4 -2
- package/dist/platforms/vtex/clients/commerce/types/SalesChannel.d.ts +24 -0
- package/dist/platforms/vtex/clients/index.d.ts +1 -0
- package/dist/platforms/vtex/loaders/index.d.ts +1 -0
- package/dist/platforms/vtex/loaders/salesChannel.d.ts +5 -0
- package/package.json +2 -2
- package/src/platforms/vtex/clients/commerce/index.ts +8 -4
- package/src/platforms/vtex/clients/commerce/types/SalesChannel.ts +25 -0
- package/src/platforms/vtex/loaders/index.ts +3 -0
- package/src/platforms/vtex/loaders/salesChannel.ts +15 -0
- package/src/platforms/vtex/resolvers/aggregateOffer.ts +10 -1
- package/src/platforms/vtex/resolvers/offer.ts +10 -1
package/dist/api.esm.js
CHANGED
|
@@ -32,6 +32,7 @@ const VtexCommerce = ({
|
|
|
32
32
|
const base = `https://${account}.${environment}.com.br`;
|
|
33
33
|
return {
|
|
34
34
|
catalog: {
|
|
35
|
+
salesChannel: sc => fetchAPI(`${base}/api/catalog_system/pub/saleschannel/${sc}`),
|
|
35
36
|
brand: {
|
|
36
37
|
list: () => fetchAPI(`${base}/api/catalog_system/pub/brand/list`)
|
|
37
38
|
},
|
|
@@ -322,6 +323,12 @@ const getClients = (options, ctx) => {
|
|
|
322
323
|
};
|
|
323
324
|
};
|
|
324
325
|
|
|
326
|
+
const getSalesChannelLoader = (_, clients) => {
|
|
327
|
+
const loader = async channels => Promise.all(channels.map(sc => clients.commerce.catalog.salesChannel(sc)));
|
|
328
|
+
|
|
329
|
+
return new DataLoader(loader);
|
|
330
|
+
};
|
|
331
|
+
|
|
325
332
|
const CONCURRENT_REQUESTS_MAX = 1;
|
|
326
333
|
const getSimulationLoader = (_, clients) => {
|
|
327
334
|
const limit = pLimit(CONCURRENT_REQUESTS_MAX);
|
|
@@ -459,10 +466,12 @@ const getLoaders = (options, {
|
|
|
459
466
|
const skuLoader = getSkuLoader(options, clients);
|
|
460
467
|
const simulationLoader = getSimulationLoader(options, clients);
|
|
461
468
|
const collectionLoader = getCollectionLoader(options, clients);
|
|
469
|
+
const salesChannelLoader = getSalesChannelLoader(options, clients);
|
|
462
470
|
return {
|
|
463
471
|
skuLoader,
|
|
464
472
|
simulationLoader,
|
|
465
|
-
collectionLoader
|
|
473
|
+
collectionLoader,
|
|
474
|
+
salesChannelLoader
|
|
466
475
|
};
|
|
467
476
|
};
|
|
468
477
|
|
|
@@ -503,7 +512,20 @@ const StoreAggregateOffer = {
|
|
|
503
512
|
return lowOffer ? price(lowOffer) : 0;
|
|
504
513
|
},
|
|
505
514
|
offerCount: offers => offers.length,
|
|
506
|
-
priceCurrency: () =>
|
|
515
|
+
priceCurrency: async (_, __, ctx) => {
|
|
516
|
+
var _sc$CurrencyCode;
|
|
517
|
+
|
|
518
|
+
const {
|
|
519
|
+
loaders: {
|
|
520
|
+
salesChannelLoader
|
|
521
|
+
},
|
|
522
|
+
storage: {
|
|
523
|
+
channel
|
|
524
|
+
}
|
|
525
|
+
} = ctx;
|
|
526
|
+
const sc = await salesChannelLoader.load(channel.salesChannel);
|
|
527
|
+
return (_sc$CurrencyCode = sc.CurrencyCode) != null ? _sc$CurrencyCode : '';
|
|
528
|
+
},
|
|
507
529
|
offers: offers => offers
|
|
508
530
|
};
|
|
509
531
|
|
|
@@ -1198,7 +1220,20 @@ const isSearchItem = item => 'Price' in item && 'seller' in item && 'product' in
|
|
|
1198
1220
|
const isOrderFormItem = item => 'skuName' in item;
|
|
1199
1221
|
|
|
1200
1222
|
const StoreOffer = {
|
|
1201
|
-
priceCurrency: () =>
|
|
1223
|
+
priceCurrency: async (_, __, ctx) => {
|
|
1224
|
+
var _sc$CurrencyCode;
|
|
1225
|
+
|
|
1226
|
+
const {
|
|
1227
|
+
loaders: {
|
|
1228
|
+
salesChannelLoader
|
|
1229
|
+
},
|
|
1230
|
+
storage: {
|
|
1231
|
+
channel
|
|
1232
|
+
}
|
|
1233
|
+
} = ctx;
|
|
1234
|
+
const sc = await salesChannelLoader.load(channel.salesChannel);
|
|
1235
|
+
return (_sc$CurrencyCode = sc.CurrencyCode) != null ? _sc$CurrencyCode : '';
|
|
1236
|
+
},
|
|
1202
1237
|
priceValidUntil: root => {
|
|
1203
1238
|
if (isSearchItem(root)) {
|
|
1204
1239
|
var _root$PriceValidUntil;
|