@faststore/api 1.9.5 → 1.9.6
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 +40 -11
- 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 +36 -12
- package/dist/api.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/platforms/errors.d.ts +19 -0
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/platforms/errors.ts +34 -0
- package/src/platforms/vtex/loaders/collection.ts +1 -1
- package/src/platforms/vtex/loaders/sku.ts +4 -4
- package/dist/platforms/vtex/utils/errors.d.ts +0 -6
- package/src/platforms/vtex/utils/errors.ts +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.9.6](https://github.com/vtex/faststore/compare/v1.9.5...v1.9.6) (2022-06-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Export API Errors ([#1361](https://github.com/vtex/faststore/issues/1361)) ([853035a](https://github.com/vtex/faststore/commit/853035aec1ad94cefaf9eae340b625fb6c920ec2))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.9.5](https://github.com/vtex/faststore/compare/v1.9.4...v1.9.5) (2022-06-10)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @faststore/api
|
|
@@ -348,24 +348,48 @@ const getSimulationLoader = (_, clients) => {
|
|
|
348
348
|
});
|
|
349
349
|
};
|
|
350
350
|
|
|
351
|
-
|
|
352
|
-
|
|
351
|
+
const enhanceSku = (item, product) => ({ ...item,
|
|
352
|
+
isVariantOf: product
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
class FastStoreError extends Error {
|
|
356
|
+
constructor(extensions, message) {
|
|
353
357
|
super(message);
|
|
354
|
-
this.
|
|
358
|
+
this.extensions = extensions;
|
|
359
|
+
this.name = 'FastStoreError';
|
|
355
360
|
}
|
|
356
361
|
|
|
357
362
|
}
|
|
358
|
-
|
|
363
|
+
|
|
364
|
+
class BadRequestError extends FastStoreError {
|
|
359
365
|
constructor(message) {
|
|
360
|
-
super(
|
|
361
|
-
|
|
366
|
+
super({
|
|
367
|
+
status: 400,
|
|
368
|
+
type: 'BadRequestError'
|
|
369
|
+
}, message);
|
|
362
370
|
}
|
|
363
371
|
|
|
364
372
|
}
|
|
373
|
+
class NotFoundError extends FastStoreError {
|
|
374
|
+
constructor(message) {
|
|
375
|
+
super({
|
|
376
|
+
status: 404,
|
|
377
|
+
type: 'NotFoundError'
|
|
378
|
+
}, message);
|
|
379
|
+
}
|
|
365
380
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
381
|
+
}
|
|
382
|
+
const isFastStoreError = error => (error == null ? void 0 : error.name) === 'FastStoreError';
|
|
383
|
+
const isNotFoundError = error => {
|
|
384
|
+
var _error$extensions;
|
|
385
|
+
|
|
386
|
+
return (error == null ? void 0 : (_error$extensions = error.extensions) == null ? void 0 : _error$extensions.type) === 'NotFoundError';
|
|
387
|
+
};
|
|
388
|
+
const isBadRequestError = error => {
|
|
389
|
+
var _error$extensions2;
|
|
390
|
+
|
|
391
|
+
return (error == null ? void 0 : (_error$extensions2 = error.extensions) == null ? void 0 : _error$extensions2.type) === 'BadRequestError';
|
|
392
|
+
};
|
|
369
393
|
|
|
370
394
|
const getSkuLoader = (_, clients) => {
|
|
371
395
|
const loader = async facetsList => {
|
|
@@ -395,10 +419,10 @@ const getSkuLoader = (_, clients) => {
|
|
|
395
419
|
return acc;
|
|
396
420
|
}, {});
|
|
397
421
|
const skus = skuIds.map(skuId => skuBySkuId[skuId]);
|
|
398
|
-
const missingSkus =
|
|
422
|
+
const missingSkus = skuIds.filter(skuId => !skuBySkuId[skuId]);
|
|
399
423
|
|
|
400
424
|
if (missingSkus.length > 0) {
|
|
401
|
-
throw new
|
|
425
|
+
throw new NotFoundError(`Search API did not found the following skus: ${missingSkus.join(',')}`);
|
|
402
426
|
}
|
|
403
427
|
|
|
404
428
|
return skus;
|
|
@@ -1738,8 +1762,13 @@ const getSchema = async options => schema.makeExecutableSchema({
|
|
|
1738
1762
|
typeDefs
|
|
1739
1763
|
});
|
|
1740
1764
|
|
|
1765
|
+
exports.BadRequestError = BadRequestError;
|
|
1766
|
+
exports.NotFoundError = NotFoundError;
|
|
1741
1767
|
exports.getContextFactory = getContextFactory$1;
|
|
1742
1768
|
exports.getResolvers = getResolvers$1;
|
|
1743
1769
|
exports.getSchema = getSchema;
|
|
1744
1770
|
exports.getTypeDefs = getTypeDefs;
|
|
1771
|
+
exports.isBadRequestError = isBadRequestError;
|
|
1772
|
+
exports.isFastStoreError = isFastStoreError;
|
|
1773
|
+
exports.isNotFoundError = isNotFoundError;
|
|
1745
1774
|
//# sourceMappingURL=api.cjs.development.js.map
|