@unchainedshop/core-assortments 5.0.0-alpha.5 → 5.0.0-alpha.7
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 +12 -105
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -13,120 +13,27 @@ npm install @unchainedshop/core-assortments
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
import { configureAssortmentsModule } from '@unchainedshop/core-assortments';
|
|
16
|
+
The platform initializes this module as `platform.unchainedAPI.modules.assortments`. For startup and options, see [Platform Configuration](https://docs.unchained.shop/platform-configuration/).
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
```typescript
|
|
19
|
+
const { assortments } = platform.unchainedAPI.modules;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
const assortmentId = await assortmentsModule.create({
|
|
23
|
-
slugs: ['electronics'],
|
|
21
|
+
const assortment = await assortments.create({
|
|
24
22
|
isRoot: true,
|
|
23
|
+
isActive: true,
|
|
24
|
+
sequence: 10,
|
|
25
|
+
tags: [],
|
|
25
26
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const assortments = await assortmentsModule.findAssortments({
|
|
29
|
-
includeInactive: false,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Add product to assortment
|
|
33
|
-
await assortmentsModule.products.create({
|
|
34
|
-
assortmentId,
|
|
27
|
+
await assortments.products.create({
|
|
28
|
+
assortmentId: assortment._id,
|
|
35
29
|
productId: 'product-123',
|
|
36
30
|
});
|
|
31
|
+
const roots = await assortments.findAssortments({ includeLeaves: false, includeInactive: false });
|
|
37
32
|
```
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Module Configuration
|
|
42
|
-
|
|
43
|
-
| Export | Description |
|
|
44
|
-
|--------|-------------|
|
|
45
|
-
| `configureAssortmentsModule` | Configure and return the assortments module |
|
|
46
|
-
|
|
47
|
-
### Queries
|
|
48
|
-
|
|
49
|
-
| Method | Description |
|
|
50
|
-
|--------|-------------|
|
|
51
|
-
| `findAssortment` | Find assortment by ID or slug |
|
|
52
|
-
| `findAssortments` | Find assortments with filtering and pagination |
|
|
53
|
-
| `count` | Count assortments matching query |
|
|
54
|
-
| `assortmentExists` | Check if assortment exists |
|
|
55
|
-
| `findProductIds` | Get all product IDs in an assortment tree |
|
|
56
|
-
|
|
57
|
-
### Mutations
|
|
58
|
-
|
|
59
|
-
| Method | Description |
|
|
60
|
-
|--------|-------------|
|
|
61
|
-
| `create` | Create a new assortment |
|
|
62
|
-
| `update` | Update assortment data |
|
|
63
|
-
| `delete` | Soft delete an assortment |
|
|
64
|
-
| `setBase` | Set base assortment |
|
|
65
|
-
| `invalidateCache` | Clear assortment cache |
|
|
66
|
-
|
|
67
|
-
### Submodules
|
|
68
|
-
|
|
69
|
-
#### Products (`assortments.products`)
|
|
70
|
-
| Method | Description |
|
|
71
|
-
|--------|-------------|
|
|
72
|
-
| `findProducts` | Find products in assortment |
|
|
73
|
-
| `create` | Add product to assortment |
|
|
74
|
-
| `delete` | Remove product from assortment |
|
|
75
|
-
| `reorder` | Reorder products |
|
|
76
|
-
|
|
77
|
-
#### Links (`assortments.links`)
|
|
78
|
-
| Method | Description |
|
|
79
|
-
|--------|-------------|
|
|
80
|
-
| `findLinks` | Find assortment links (parent-child) |
|
|
81
|
-
| `create` | Create link between assortments |
|
|
82
|
-
| `delete` | Remove link |
|
|
83
|
-
| `reorder` | Reorder child assortments |
|
|
84
|
-
|
|
85
|
-
#### Media (`assortments.media`)
|
|
86
|
-
| Method | Description |
|
|
87
|
-
|--------|-------------|
|
|
88
|
-
| `findMedia` | Find assortment media |
|
|
89
|
-
| `create` | Add media to assortment |
|
|
90
|
-
| `delete` | Remove media |
|
|
91
|
-
| `reorder` | Reorder media |
|
|
92
|
-
|
|
93
|
-
#### Texts (`assortments.texts`)
|
|
94
|
-
| Method | Description |
|
|
95
|
-
|--------|-------------|
|
|
96
|
-
| `findTexts` | Find localized texts |
|
|
97
|
-
| `updateTexts` | Update assortment texts |
|
|
98
|
-
|
|
99
|
-
#### Filters (`assortments.filters`)
|
|
100
|
-
| Method | Description |
|
|
101
|
-
|--------|-------------|
|
|
102
|
-
| `findFilters` | Find filters for assortment |
|
|
103
|
-
| `create` | Add filter to assortment |
|
|
104
|
-
| `delete` | Remove filter |
|
|
105
|
-
| `reorder` | Reorder filters |
|
|
106
|
-
|
|
107
|
-
### Settings
|
|
108
|
-
|
|
109
|
-
| Export | Description |
|
|
110
|
-
|--------|-------------|
|
|
111
|
-
| `assortmentsSettings` | Access assortment module settings |
|
|
112
|
-
|
|
113
|
-
### Types
|
|
114
|
-
|
|
115
|
-
| Export | Description |
|
|
116
|
-
|--------|-------------|
|
|
117
|
-
| `Assortment` | Assortment document type |
|
|
118
|
-
| `AssortmentProduct` | Assortment-product link type |
|
|
119
|
-
| `AssortmentLink` | Parent-child link type |
|
|
120
|
-
| `AssortmentMedia` | Media attachment type |
|
|
121
|
-
| `AssortmentsModule` | Module interface type |
|
|
122
|
-
|
|
123
|
-
## Events
|
|
34
|
+
Product links, child links, media, texts, and filters live in the `products`, `links`, `media`, `texts`, and `filters` submodules. Creation returns the assortment document; use its `_id` when linking products.
|
|
124
35
|
|
|
125
|
-
|
|
126
|
-
|-------|-------------|
|
|
127
|
-
| `ASSORTMENT_CREATE` | Assortment created |
|
|
128
|
-
| `ASSORTMENT_UPDATE` | Assortment updated |
|
|
129
|
-
| `ASSORTMENT_REMOVE` | Assortment deleted |
|
|
36
|
+
See the [module guide](https://docs.unchained.shop/platform-configuration/modules/assortments) for caching, tree ordering, options, and events. The [public exports](src/assortments-index.ts) and [module implementation](src/module/configureAssortmentsModule.ts) define the available types and methods.
|
|
130
37
|
|
|
131
38
|
## License
|
|
132
39
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-assortments",
|
|
3
3
|
"description": "Assortment and category management module for the Unchained Engine",
|
|
4
|
-
"version": "5.0.0-alpha.
|
|
4
|
+
"version": "5.0.0-alpha.7",
|
|
5
5
|
"main": "lib/assortments-index.js",
|
|
6
6
|
"types": "lib/assortments-index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@unchainedshop/events": "^5.0.0-alpha.
|
|
39
|
-
"@unchainedshop/logger": "^5.0.0-alpha.
|
|
40
|
-
"@unchainedshop/mongodb": "^5.0.0-alpha.
|
|
41
|
-
"@unchainedshop/utils": "^5.0.0-alpha.
|
|
38
|
+
"@unchainedshop/events": "^5.0.0-alpha.7",
|
|
39
|
+
"@unchainedshop/logger": "^5.0.0-alpha.7",
|
|
40
|
+
"@unchainedshop/mongodb": "^5.0.0-alpha.7",
|
|
41
|
+
"@unchainedshop/utils": "^5.0.0-alpha.7"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^26.2.0",
|