@scayle/storefront-product-listing 1.3.2 → 1.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @scayle/storefront-product-listing
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - **\[Utilities\]** Added `getCategoryAncestors`, `isSaleCategory`, and `flattenCategoryTree` utilities to enhance functionality.
8
+
9
+ ## 1.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Update to `@nuxt/module-builder@1`. This version of Nuxt Module Builder is ESM-only, so CommonJS (`.cjs`) files will no longer be built or distributed with the package. However as of Nuxt 3, only esm is used so this should not have any impact as this module does not support Nuxt 2.
14
+
3
15
  ## 1.3.2
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -4,9 +4,9 @@ import { FilterItemWithValues } from '@scayle/storefront-api';
4
4
 
5
5
  type RangeTuple = [start: number, end: number];
6
6
 
7
- declare const breadcrumbsFactory: Factory<BreadcrumbItem[], any, BreadcrumbItem[]>;
7
+ declare const breadcrumbsFactory: Factory<BreadcrumbItem[], any, BreadcrumbItem[], BreadcrumbItem[]>;
8
8
 
9
- declare const filtersFactory: Factory<FilterItemWithValues[], any, FilterItemWithValues[]>;
9
+ declare const filtersFactory: Factory<FilterItemWithValues[], any, FilterItemWithValues[], FilterItemWithValues[]>;
10
10
 
11
11
  export { breadcrumbsFactory, filtersFactory };
12
12
  export type { RangeTuple };
package/dist/module.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@scayle/storefront-product-listing",
3
3
  "configKey": "product-listing",
4
- "version": "1.3.2",
4
+ "version": "1.5.0",
5
5
  "compatibility": {
6
6
  "bridge": false,
7
7
  "nuxt": ">=3.13"
8
8
  },
9
9
  "builder": {
10
- "@nuxt/module-builder": "0.8.4",
11
- "unbuild": "2.0.0"
10
+ "@nuxt/module-builder": "1.0.1",
11
+ "unbuild": "3.5.0"
12
12
  }
13
13
  }
package/dist/module.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineNuxtModule, createResolver, addImportsDir } from '@nuxt/kit';
2
2
 
3
3
  const PACKAGE_NAME = "@scayle/storefront-product-listing";
4
- const PACKAGE_VERSION = "1.3.2";
4
+ const PACKAGE_VERSION = "1.5.0";
5
5
  const module = defineNuxtModule({
6
6
  meta: {
7
7
  name: PACKAGE_NAME,
@@ -4,3 +4,4 @@ export * from './composables/useFiltersForListing.js';
4
4
  export * from './composables/useProductListingSeoData.js';
5
5
  export * from './composables/useProductsForListing.js';
6
6
  export * from './utils/filters.js';
7
+ export * from './utils/category.js';
@@ -4,3 +4,4 @@ export * from "./composables/useFiltersForListing.js";
4
4
  export * from "./composables/useProductListingSeoData.js";
5
5
  export * from "./composables/useProductsForListing.js";
6
6
  export * from "./utils/filters.js";
7
+ export * from "./utils/category.js";
@@ -0,0 +1,19 @@
1
+ import type { Category } from '@scayle/storefront-nuxt';
2
+ /**
3
+ * Get all ancestors of a category.
4
+ * @param category - The category to get the ancestors of.
5
+ * @returns An array of all ancestors of the category.
6
+ */
7
+ export declare const getCategoryAncestors: (category: Category) => Category[];
8
+ /**
9
+ * Check if a category is a sale category.
10
+ * @param category - The category to check.
11
+ * @returns True if the category is the sale category, false otherwise.
12
+ */
13
+ export declare const isSaleCategory: (category: Category) => boolean;
14
+ /**
15
+ * Flatten a category tree.
16
+ * @param categoryTree - The category tree to flatten.
17
+ * @returns A flattened array of all categories in the tree.
18
+ */
19
+ export declare const flattenCategoryTree: (categoryTree: Category[]) => Category[];
@@ -0,0 +1,23 @@
1
+ export const getCategoryAncestors = (category) => {
2
+ if (!category?.parent) {
3
+ return [];
4
+ }
5
+ return [...getCategoryAncestors(category.parent), category.parent];
6
+ };
7
+ export const isSaleCategory = (category) => {
8
+ return category.properties.some(({ name }) => name === "sale");
9
+ };
10
+ export const flattenCategoryTree = (categoryTree) => {
11
+ const flattenedCategoryTreeList = categoryTree.reduce(
12
+ (categories, categoryNode) => {
13
+ const children = categoryNode?.children ?? [];
14
+ return categories.concat(categoryNode, ...flattenCategoryTree(children));
15
+ },
16
+ []
17
+ );
18
+ return [
19
+ ...new Map(
20
+ flattenedCategoryTreeList.map((item) => [item?.id ?? item, item])
21
+ ).values()
22
+ ];
23
+ };
package/dist/types.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { NuxtModule } from '@nuxt/schema'
2
2
 
3
- import type { default as Module } from './module.js'
3
+ import type { default as Module } from './module.mjs'
4
4
 
5
5
  export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
6
 
7
- export { default } from './module.js'
7
+ export { default } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-product-listing",
3
- "version": "1.3.2",
3
+ "version": "1.5.0",
4
4
  "description": "Collection of essential composables and utilities to work with product listing",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -11,12 +11,11 @@
11
11
  },
12
12
  "exports": {
13
13
  ".": {
14
- "types": "./dist/index.d.ts",
14
+ "types": "./dist/index.d.mts",
15
15
  "default": "./dist/index.mjs"
16
16
  },
17
17
  "./module": {
18
- "types": "./dist/module.d.ts",
19
- "require": "./dist/module.cjs",
18
+ "types": "./dist/module.d.mts",
20
19
  "import": "./dist/module.mjs"
21
20
  },
22
21
  "./composables": {
@@ -25,7 +24,6 @@
25
24
  }
26
25
  },
27
26
  "main": "./dist/index.mjs",
28
- "types": "./dist/index.d.ts",
29
27
  "files": [
30
28
  "CHANGELOG.md",
31
29
  "dist"
@@ -37,8 +35,9 @@
37
35
  "build": "nuxt-module-build build",
38
36
  "dev": "nuxi dev playground",
39
37
  "dev:build": "nuxi build playground",
40
- "prep": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
41
- "lint": "eslint . --format gitlab",
38
+ "prep": "nuxt-module-build prepare && nuxi prepare playground",
39
+ "lint": "eslint .",
40
+ "lint:ci": "eslint . --format gitlab",
42
41
  "lint:fix": "eslint . --fix",
43
42
  "format": "dprint check",
44
43
  "format:fix": "dprint fmt",
@@ -46,7 +45,8 @@
46
45
  "test:watch": "vitest --passWithNoTests",
47
46
  "test:ci": "vitest --run --passWithNoTests --coverage --reporter=default --reporter=junit --outputFile=./coverage/junit.xml",
48
47
  "typecheck": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
49
- "package:lint": "publint"
48
+ "package:lint": "publint",
49
+ "verify-packaging": "attw --pack . --profile esm-only"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@nuxt/kit": ">=3.13.0",
@@ -59,29 +59,30 @@
59
59
  "vue": "^3.5.13"
60
60
  },
61
61
  "devDependencies": {
62
- "@nuxt/kit": "3.15.4",
63
- "@nuxt/module-builder": "0.8.4",
64
- "@nuxt/schema": "3.15.4",
65
- "@nuxt/test-utils": "3.17.2",
66
- "@scayle/eslint-config-storefront": "4.5.0",
67
- "@scayle/storefront-api": "18.2.1",
68
- "@scayle/storefront-nuxt": "8.16.0",
69
- "@types/node": "22.14.0",
62
+ "@arethetypeswrong/cli": "0.18.1",
63
+ "@nuxt/kit": "3.16.2",
64
+ "@nuxt/module-builder": "1.0.1",
65
+ "@nuxt/schema": "3.16.2",
66
+ "@nuxt/test-utils": "3.18.0",
67
+ "@scayle/eslint-config-storefront": "4.5.2",
68
+ "@scayle/storefront-api": "18.3.1",
69
+ "@scayle/storefront-nuxt": "8.25.4",
70
+ "@types/node": "22.15.17",
70
71
  "@vue/test-utils": "2.4.6",
71
- "@vueuse/core": "13.0.0",
72
+ "@vueuse/core": "13.1.0",
72
73
  "dprint": "0.49.1",
73
- "eslint-formatter-gitlab": "5.1.0",
74
- "eslint": "9.23.0",
75
- "fishery": "2.2.3",
76
- "happy-dom": "17.4.4",
77
- "nuxt": "3.15.4",
74
+ "eslint-formatter-gitlab": "6.0.0",
75
+ "eslint": "9.26.0",
76
+ "fishery": "2.3.1",
77
+ "happy-dom": "17.4.7",
78
+ "nuxt": "3.16.2",
78
79
  "publint": "0.2.12",
79
80
  "schema-dts": "1.1.5",
80
- "typescript": "5.8.2",
81
- "unbuild": "2.0.0",
82
- "vitest": "2.1.9",
83
- "vue-router": "4.5.0",
84
- "vue-tsc": "2.2.8",
81
+ "typescript": "5.8.3",
82
+ "unbuild": "3.5.0",
83
+ "vitest": "3.1.3",
84
+ "vue-router": "4.5.1",
85
+ "vue-tsc": "2.2.10",
85
86
  "vue": "3.5.13"
86
87
  }
87
88
  }
package/dist/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import { BreadcrumbItem } from '@scayle/storefront-nuxt';
2
- import { Factory } from 'fishery';
3
- import { FilterItemWithValues } from '@scayle/storefront-api';
4
-
5
- type RangeTuple = [start: number, end: number];
6
-
7
- declare const breadcrumbsFactory: Factory<BreadcrumbItem[], any, BreadcrumbItem[]>;
8
-
9
- declare const filtersFactory: Factory<FilterItemWithValues[], any, FilterItemWithValues[]>;
10
-
11
- export { breadcrumbsFactory, filtersFactory };
12
- export type { RangeTuple };
package/dist/module.cjs DELETED
@@ -1,5 +0,0 @@
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)
package/dist/module.d.ts DELETED
@@ -1,8 +0,0 @@
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 };
package/dist/types.d.ts DELETED
@@ -1,7 +0,0 @@
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'