@epcc-sdk/sdks-shopper 0.0.13 → 0.0.15
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 +22 -0
- package/dist/client/@tanstack/react-query.gen.d.ts +409 -12
- package/dist/client/@tanstack/react-query.gen.js +229 -1
- package/dist/client/sdk.gen.d.ts +161 -4
- package/dist/client/sdk.gen.js +195 -0
- package/dist/client/transformers.gen.d.ts +2 -1
- package/dist/client/transformers.gen.js +16 -0
- package/dist/client/types.gen.d.ts +1481 -431
- package/dist/utils/extract-media.d.ts +15 -0
- package/dist/utils/extract-media.js +54 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ElasticPathFile, ProductData } from "../client";
|
|
2
|
+
export interface ExtractedMedia {
|
|
3
|
+
mainImage?: ElasticPathFile;
|
|
4
|
+
allImages: ElasticPathFile[];
|
|
5
|
+
otherImages: ElasticPathFile[];
|
|
6
|
+
allFiles: ElasticPathFile[];
|
|
7
|
+
otherFiles: ElasticPathFile[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Extracts the main product image and organizes all files/images into separate arrays.
|
|
11
|
+
*
|
|
12
|
+
* @param productData - The product data containing included files.
|
|
13
|
+
* @returns An object with the main image, all images, other images, all files, and other files.
|
|
14
|
+
*/
|
|
15
|
+
export declare function extractProductMedia(productData: ProductData): ExtractedMedia;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Extracts the main product image and organizes all files/images into separate arrays.
|
|
12
|
+
*
|
|
13
|
+
* @param productData - The product data containing included files.
|
|
14
|
+
* @returns An object with the main image, all images, other images, all files, and other files.
|
|
15
|
+
*/
|
|
16
|
+
export function extractProductMedia(productData) {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
18
|
+
// Retrieve the main image id from the product's relationships if it exists
|
|
19
|
+
var mainImageId = (_d = (_c = (_b = (_a = productData.data) === null || _a === void 0 ? void 0 : _a.relationships) === null || _b === void 0 ? void 0 : _b.main_image) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.id;
|
|
20
|
+
// Combine the main_images and files arrays from the included object
|
|
21
|
+
// If either is undefined, we default to an empty array.
|
|
22
|
+
var mainImages = (_f = (_e = productData.included) === null || _e === void 0 ? void 0 : _e.main_images) !== null && _f !== void 0 ? _f : [];
|
|
23
|
+
var otherFiles = (_h = (_g = productData.included) === null || _g === void 0 ? void 0 : _g.files) !== null && _h !== void 0 ? _h : [];
|
|
24
|
+
var combinedFiles = __spreadArray(__spreadArray([], mainImages, true), otherFiles, true);
|
|
25
|
+
var mainImage;
|
|
26
|
+
var allImages = [];
|
|
27
|
+
// Single pass over combined files
|
|
28
|
+
for (var _i = 0, combinedFiles_1 = combinedFiles; _i < combinedFiles_1.length; _i++) {
|
|
29
|
+
var file = combinedFiles_1[_i];
|
|
30
|
+
// Check if this file is the main image
|
|
31
|
+
if (mainImageId && file.id === mainImageId) {
|
|
32
|
+
mainImage = file;
|
|
33
|
+
}
|
|
34
|
+
// Check if file is an image by its mime type (adjust the condition as needed)
|
|
35
|
+
if (file.mime_type && file.mime_type.startsWith("image/")) {
|
|
36
|
+
allImages.push(file);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Exclude the main image from the arrays (if one was found)
|
|
40
|
+
var otherImages = mainImage
|
|
41
|
+
? allImages.filter(function (file) { return file.id !== mainImage.id; })
|
|
42
|
+
: allImages;
|
|
43
|
+
var allFiles = combinedFiles;
|
|
44
|
+
var otherFilesFiltered = mainImage
|
|
45
|
+
? combinedFiles.filter(function (file) { return file.id !== mainImage.id; })
|
|
46
|
+
: combinedFiles;
|
|
47
|
+
return {
|
|
48
|
+
mainImage: mainImage,
|
|
49
|
+
allImages: allImages,
|
|
50
|
+
otherImages: otherImages,
|
|
51
|
+
allFiles: allFiles,
|
|
52
|
+
otherFiles: otherFilesFiltered,
|
|
53
|
+
};
|
|
54
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epcc-sdk/sdks-shopper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"oas:openapi-ts": "openapi-ts",
|
|
50
50
|
"oas:redocly": "redocly --config ./redocly.json",
|
|
51
51
|
"oas:redocly:lint": "redocly lint --config ../specs/config/redocly.yaml",
|
|
52
|
-
"oas:redocly:join:shopper": "redocly join --config ../specs/config/redocly.yaml --output ../specs/shopper.yaml ../specs/bundled/catalog_view_3.1.yaml ../specs/bundled/cart_checkout.yaml ../specs/bundled/subscriptions_3.1.yaml ../specs/bundled/inventories_3.1.yaml ../specs/bundled/authentication.yaml",
|
|
52
|
+
"oas:redocly:join:shopper": "redocly join --config ../specs/config/redocly.yaml --output ../specs/shopper.yaml ../specs/bundled/catalog_view_3.1.yaml ../specs/bundled/cart_checkout.yaml ../specs/bundled/subscriptions_3.1.yaml ../specs/bundled/inventories_3.1.yaml ../specs/bundled/authentication.yaml ../specs/bundled/account-addresses.yaml ../specs/bundled/account_management.yaml",
|
|
53
53
|
"oas:redocly:bundle": "redocly bundle --config ../specs/config/redocly.yaml",
|
|
54
54
|
"oas:openapi-format:convert": "pnpm dlx openapi-format ../specs/bundled/catalog_view.yaml -o ../specs/bundled/catalog_view_3.1.yaml --convertTo \"3.1\" && pnpm dlx openapi-format ../specs/bundled/subscriptions.yaml -o ../specs/bundled/subscriptions_3.1.yaml --convertTo \"3.1\" && pnpm dlx openapi-format ../specs/bundled/inventories.yaml -o ../specs/bundled/inventories_3.1.yaml --convertTo \"3.1\""
|
|
55
55
|
}
|