@scayle/storefront-product-detail 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 SCAYLE GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # @scayle/storefront-product-detail
2
+
3
+ <div align="center">
4
+ <img src="https://cdn-prod.scayle.com/public/media/general/SCAYLE-Commerce-Engine-header.png" />
5
+ </div>
6
+
7
+ <div align="center">
8
+ <h1>@scayle/storefront-product-detail</h1>
9
+ </div>
10
+
11
+ <div align="center">
12
+ <h4><a href="https://www.scayle.com/">Website</a></h4>
13
+ </div>
14
+
15
+ <div align="center">
16
+ A Nuxt module for product detail integration.
17
+ </div>
18
+ <br/>
19
+ <div align="center">
20
+ <a href="https://www.npmjs.com/package/@scayle/storefront-product-detail"><img src="https://img.shields.io/npm/v/@scayle/storefront-product-detail/latest.svg?style=flat&colorB=007ec6" /></a>
21
+ <a href="https://www.npmjs.com/package/@scayle/storefront-product-detail"><img src="https://img.shields.io/npm/dm/@scayle/storefront-product-detail.svg?style=flat&colorB=007ec6" /></a>
22
+ <a href="https://www.npmjs.com/package/@scayle/storefront-product-detail"><img src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
23
+ <a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js" /></a>
24
+ </div>
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ # Using pnpm
30
+ pnpm add @scayle/storefront-product-detail
31
+
32
+ # Using yarn
33
+ yarn add @scayle/storefront-product-detail
34
+
35
+ # Using npm
36
+ npm install @scayle/storefront-product-detail
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ```ts
42
+ export default defineNuxtConfig({
43
+ modules: ['@scayle/storefront-product-detail'],
44
+ })
45
+ ```
46
+
47
+ ## Module Configuration
48
+
49
+ ## License
50
+
51
+ Licensed under the [MIT License](https://opensource.org/license/mit/)
52
+
53
+ ## What is SCAYLE?
54
+
55
+ [SCAYLE](https://scayle.com) is a full-featured e-commerce software solution that comes with flexible APIs.
56
+ Within SCAYLE, you can manage all aspects of your shop, such as products, stocks, customers, and transactions.
57
+
58
+ Learn more about [SCAYLE’s architecture](https://scayle.dev/en/getting-started) and commerce modules in the Docs.
59
+
60
+ ## Other channels
61
+
62
+ - [LinkedIn](https://www.linkedin.com/company/scaylecommerce/)
63
+ - [Jobs](https://careers.smartrecruiters.com/ABOUTYOUGmbH/scayle)
64
+
65
+ <!-- Badges -->
66
+
67
+ [npm-version-src]: https://img.shields.io/npm/v/@scayle/storefront-product-detail/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
68
+ [npm-version-href]: https://npmjs.com/package/@scayle/storefront-product-detail
69
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@scayle/storefront-product-detail.svg?style=flat&colorA=18181B&colorB=28CF8D
70
+ [npm-downloads-href]: https://npmjs.com/package/@scayle/storefront-product-detail
71
+ [license-src]: https://img.shields.io/npm/l/@scayle/storefront-product-detail.svg?style=flat&colorA=18181B&colorB=28CF8D
72
+ [license-href]: https://npmjs.com/package/@scayle/storefront-product-detail
73
+
74
+ ## License
75
+
76
+ Licensed under the [MIT License](https://opensource.org/license/mit/)
77
+
78
+ ---
@@ -0,0 +1,5 @@
1
+ module.exports = function(...args) {
2
+ return import('./module.mjs').then(m => m.default.call(this, ...args))
3
+ }
4
+ const _meta = module.exports.meta = require('./module.json')
5
+ module.exports.getMeta = () => Promise.resolve(_meta)
@@ -0,0 +1,8 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ interface ModuleOptions {
4
+ autoImports?: boolean;
5
+ }
6
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
7
+
8
+ export { _default as default };
@@ -0,0 +1,8 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ interface ModuleOptions {
4
+ autoImports?: boolean;
5
+ }
6
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
7
+
8
+ export { _default as default };
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@scayle/storefront-product-detail",
3
+ "configKey": "product-detail",
4
+ "version": "0.0.1",
5
+ "compatibility": {
6
+ "bridge": false,
7
+ "nuxt": ">=3.13"
8
+ },
9
+ "builder": {
10
+ "@nuxt/module-builder": "0.8.4",
11
+ "unbuild": "2.0.0"
12
+ }
13
+ }
@@ -0,0 +1,24 @@
1
+ import { defineNuxtModule, createResolver, addImportsDir } from '@nuxt/kit';
2
+
3
+ const module = defineNuxtModule({
4
+ meta: {
5
+ name: "@scayle/storefront-product-detail",
6
+ configKey: "product-detail",
7
+ version: "0.0.1",
8
+ compatibility: {
9
+ bridge: false,
10
+ nuxt: ">=3.13"
11
+ }
12
+ },
13
+ defaults: {},
14
+ setup(options, nuxt) {
15
+ const { resolve } = createResolver(import.meta.url);
16
+ nuxt.options.alias["#storefront-product-detail"] = resolve("./runtime");
17
+ nuxt.options.build.transpile.push("#storefront-product-detail/runtime");
18
+ if (options.autoImports) {
19
+ addImportsDir(resolve("./runtime/utils"));
20
+ }
21
+ }
22
+ });
23
+
24
+ export { module as default };
@@ -0,0 +1 @@
1
+ export * from './utils/product.js';
@@ -0,0 +1 @@
1
+ export * from "./utils/product.js";
@@ -0,0 +1,2 @@
1
+ import { type AdvancedAttribute } from '@scayle/storefront-nuxt';
2
+ export declare const getCombineWithProductIds: (attribute?: AdvancedAttribute) => number[];
@@ -0,0 +1,9 @@
1
+ import {
2
+ getFlattenedAdvancedAttribute
3
+ } from "@scayle/storefront-nuxt";
4
+ export const getCombineWithProductIds = (attribute) => {
5
+ if (!attribute) {
6
+ return [];
7
+ }
8
+ return getFlattenedAdvancedAttribute(attribute.values)?.map((item) => Number.parseInt(item.value))?.filter((value) => !Number.isNaN(value)) || [];
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,97 @@
1
+ import { it, describe } from "vitest";
2
+ import { getCombineWithProductIds } from "~/src/runtime/utils/product";
3
+ import { advancedAttributeFactory } from "@scayle/storefront-nuxt";
4
+ describe("getCombineWithProductIds", () => {
5
+ it("should return productIds from data", ({ expect }) => {
6
+ const combineWithAttribute = advancedAttributeFactory.build({
7
+ key: "combineWith",
8
+ label: "Kombiniere mit",
9
+ values: [
10
+ {
11
+ fieldSet: [
12
+ [
13
+ {
14
+ value: "206131"
15
+ }
16
+ ]
17
+ ],
18
+ groupSet: []
19
+ },
20
+ {
21
+ fieldSet: [
22
+ [
23
+ {
24
+ value: "206017"
25
+ }
26
+ ]
27
+ ],
28
+ groupSet: []
29
+ },
30
+ {
31
+ fieldSet: [
32
+ [
33
+ {
34
+ value: "206012"
35
+ }
36
+ ]
37
+ ],
38
+ groupSet: []
39
+ }
40
+ ]
41
+ });
42
+ expect(getCombineWithProductIds(combineWithAttribute)).toStrictEqual([
43
+ 206131,
44
+ 206017,
45
+ 206012
46
+ ]);
47
+ });
48
+ it("should return empty array when attribute is not available", ({ expect }) => {
49
+ expect(getCombineWithProductIds(void 0)).toStrictEqual([]);
50
+ });
51
+ it("should return productIds ignore invalid data", ({ expect }) => {
52
+ const combineWithAttributeWithInvalidData = advancedAttributeFactory.build({
53
+ key: "combineWith",
54
+ label: "Kombiniere mit",
55
+ values: [
56
+ {
57
+ fieldSet: [
58
+ [
59
+ {
60
+ value: "206131"
61
+ }
62
+ ],
63
+ [
64
+ {
65
+ value: "TEST"
66
+ }
67
+ ]
68
+ ],
69
+ groupSet: []
70
+ },
71
+ {
72
+ fieldSet: [
73
+ [
74
+ {
75
+ value: "206017"
76
+ }
77
+ ]
78
+ ],
79
+ groupSet: []
80
+ },
81
+ {
82
+ fieldSet: [
83
+ [
84
+ {
85
+ value: "206012"
86
+ }
87
+ ]
88
+ ],
89
+ groupSet: []
90
+ }
91
+ ]
92
+ });
93
+ expect(
94
+ getCombineWithProductIds(combineWithAttributeWithInvalidData)
95
+ ).toStrictEqual([206131, 206017, 206012]);
96
+ });
97
+ });
@@ -0,0 +1,7 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module.js'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { default } from './module.js'
@@ -0,0 +1,7 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { default } from './module'
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@scayle/storefront-product-detail",
3
+ "version": "0.1.0",
4
+ "description": "Collection of essential composables and utilities to work with product detail",
5
+ "author": "SCAYLE Commerce Engine",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "publishConfig": {
9
+ "access": "public",
10
+ "registry": "https://registry.npmjs.org/"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/types.d.ts",
15
+ "import": "./dist/module.mjs",
16
+ "require": "./dist/module.cjs"
17
+ }
18
+ },
19
+ "main": "./dist/module.cjs",
20
+ "types": "./dist/types.d.ts",
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "imports": {
25
+ "#storefront-product-detail": "./dist/runtime/index.js"
26
+ },
27
+ "scripts": {
28
+ "build": "nuxt-module-build build",
29
+ "dev": "nuxi dev playground",
30
+ "dev:build": "nuxi build playground",
31
+ "prep": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
32
+ "lint": "eslint . --format gitlab",
33
+ "lint:fix": "eslint . --fix",
34
+ "format": "dprint check",
35
+ "format:fix": "dprint fmt",
36
+ "test": "vitest --run --passWithNoTests",
37
+ "test:watch": "vitest --passWithNoTests",
38
+ "test:ci": "vitest --run --passWithNoTests --coverage --reporter=default --reporter=junit --outputFile=./junit.xml",
39
+ "typecheck": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
40
+ "package:lint": "publint"
41
+ },
42
+ "peerDependencies": {
43
+ "@nuxt/kit": "^3.13.0",
44
+ "@scayle/storefront-nuxt": "^7.93.0",
45
+ "@vue/test-utils": "2.4.6",
46
+ "@vueuse/core": "11.2.0",
47
+ "vue-router": "4.4.5"
48
+ },
49
+ "devDependencies": {
50
+ "@nuxt/kit": "3.13.2",
51
+ "@nuxt/module-builder": "0.8.4",
52
+ "@nuxt/schema": "3.13.2",
53
+ "@nuxt/test-utils": "3.14.4",
54
+ "@scayle/eslint-config-storefront": "4.3.2",
55
+ "@scayle/storefront-nuxt": "7.94.0",
56
+ "@types/node": "22.9.0",
57
+ "@vue/test-utils": "2.4.6",
58
+ "@vueuse/core": "11.2.0",
59
+ "dprint": "0.47.5",
60
+ "eslint": "9.14.0",
61
+ "happy-dom": "15.11.0",
62
+ "eslint-formatter-gitlab": "5.1.0",
63
+ "nuxt": "3.13.2",
64
+ "publint": "0.2.12",
65
+ "typescript": "5.6.3",
66
+ "vitest": "2.1.4",
67
+ "vue-router": "4.4.5",
68
+ "vue-tsc": "2.1.10"
69
+ }
70
+ }