@unchainedshop/core-assortments 4.3.4 → 4.4.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/README.md +132 -2
- package/lib/assortments-index.d.ts +9 -10
- package/lib/assortments-index.js +9 -10
- package/lib/assortments-settings.d.ts +1 -2
- package/lib/assortments-settings.js +3 -3
- package/lib/db/AssortmentMediaCollection.d.ts +1 -2
- package/lib/db/AssortmentMediaCollection.js +1 -4
- package/lib/db/AssortmentsCollection.d.ts +1 -2
- package/lib/db/AssortmentsCollection.js +1 -10
- package/lib/module/configureAssortmentFiltersModule.d.ts +1 -2
- package/lib/module/configureAssortmentFiltersModule.js +2 -4
- package/lib/module/configureAssortmentLinksModule.d.ts +1 -2
- package/lib/module/configureAssortmentLinksModule.js +3 -7
- package/lib/module/configureAssortmentMediaModule.d.ts +5 -4
- package/lib/module/configureAssortmentMediaModule.js +2 -10
- package/lib/module/configureAssortmentProductsModule.d.ts +1 -2
- package/lib/module/configureAssortmentProductsModule.js +2 -6
- package/lib/module/configureAssortmentTextsModule.d.ts +4 -3
- package/lib/module/configureAssortmentTextsModule.js +3 -5
- package/lib/module/configureAssortmentsModule.d.ts +29 -26
- package/lib/module/configureAssortmentsModule.js +9 -29
- package/lib/product-cache/mongodb.d.ts +0 -1
- package/lib/product-cache/mongodb.js +2 -2
- package/lib/utils/breadcrumbs/build-paths.d.ts +2 -3
- package/lib/utils/breadcrumbs/build-paths.js +1 -3
- package/lib/utils/breadcrumbs/makeAssortmentBreadcrumbsBuilder.d.ts +0 -1
- package/lib/utils/breadcrumbs/makeAssortmentBreadcrumbsBuilder.js +1 -2
- package/lib/utils/tree-zipper/zipTreeByDeepness.d.ts +1 -2
- package/lib/utils/tree-zipper/zipTreeByDeepness.js +1 -1
- package/lib/utils/tree-zipper/zipTreeBySimplyFlattening.d.ts +1 -2
- package/lib/utils/tree-zipper/zipTreeBySimplyFlattening.js +1 -1
- package/package.json +13 -11
- package/lib/assortments-index.d.ts.map +0 -1
- package/lib/assortments-index.js.map +0 -1
- package/lib/assortments-settings.d.ts.map +0 -1
- package/lib/assortments-settings.js.map +0 -1
- package/lib/db/AssortmentMediaCollection.d.ts.map +0 -1
- package/lib/db/AssortmentMediaCollection.js.map +0 -1
- package/lib/db/AssortmentsCollection.d.ts.map +0 -1
- package/lib/db/AssortmentsCollection.js.map +0 -1
- package/lib/module/configureAssortmentFiltersModule.d.ts.map +0 -1
- package/lib/module/configureAssortmentFiltersModule.js.map +0 -1
- package/lib/module/configureAssortmentLinksModule.d.ts.map +0 -1
- package/lib/module/configureAssortmentLinksModule.js.map +0 -1
- package/lib/module/configureAssortmentMediaModule.d.ts.map +0 -1
- package/lib/module/configureAssortmentMediaModule.js.map +0 -1
- package/lib/module/configureAssortmentProductsModule.d.ts.map +0 -1
- package/lib/module/configureAssortmentProductsModule.js.map +0 -1
- package/lib/module/configureAssortmentTextsModule.d.ts.map +0 -1
- package/lib/module/configureAssortmentTextsModule.js.map +0 -1
- package/lib/module/configureAssortmentsModule.d.ts.map +0 -1
- package/lib/module/configureAssortmentsModule.js.map +0 -1
- package/lib/product-cache/mongodb.d.ts.map +0 -1
- package/lib/product-cache/mongodb.js.map +0 -1
- package/lib/utils/breadcrumbs/build-paths.d.ts.map +0 -1
- package/lib/utils/breadcrumbs/build-paths.js.map +0 -1
- package/lib/utils/breadcrumbs/makeAssortmentBreadcrumbsBuilder.d.ts.map +0 -1
- package/lib/utils/breadcrumbs/makeAssortmentBreadcrumbsBuilder.js.map +0 -1
- package/lib/utils/tree-zipper/zipTreeByDeepness.d.ts.map +0 -1
- package/lib/utils/tree-zipper/zipTreeByDeepness.js.map +0 -1
- package/lib/utils/tree-zipper/zipTreeBySimplyFlattening.d.ts.map +0 -1
- package/lib/utils/tree-zipper/zipTreeBySimplyFlattening.js.map +0 -1
- package/src/assortments-index.ts +0 -11
- package/src/assortments-settings.ts +0 -36
- package/src/db/AssortmentMediaCollection.ts +0 -42
- package/src/db/AssortmentsCollection.ts +0 -167
- package/src/module/buildFindSelector.test.ts +0 -122
- package/src/module/configureAssortmentFiltersModule.ts +0 -167
- package/src/module/configureAssortmentLinksModule.ts +0 -260
- package/src/module/configureAssortmentMediaModule.ts +0 -263
- package/src/module/configureAssortmentProductsModule.ts +0 -265
- package/src/module/configureAssortmentTextsModule.ts +0 -178
- package/src/module/configureAssortmentsModule.ts +0 -526
- package/src/product-cache/mongodb.ts +0 -40
- package/src/utils/breadcrumbs/build-paths.ts +0 -65
- package/src/utils/breadcrumbs/makeAssortmentBreadcrumbsBuilder.ts +0 -20
- package/src/utils/tree-zipper/zipTreeByDeepness.test.ts +0 -68
- package/src/utils/tree-zipper/zipTreeByDeepness.ts +0 -73
- package/src/utils/tree-zipper/zipTreeBySimplyFlattening.test.ts +0 -13
- package/src/utils/tree-zipper/zipTreeBySimplyFlattening.ts +0 -5
- package/tsconfig.json +0 -10
package/README.md
CHANGED
|
@@ -1,3 +1,133 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://npmjs.com/package/@unchainedshop/core-assortments)
|
|
2
|
+
[](https://opensource.org/licenses/EUPL-1.2)
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
# @unchainedshop/core-assortments
|
|
5
|
+
|
|
6
|
+
Assortment (category) management module for the Unchained Engine. Handles product categorization with hierarchical structures, media, filters, and localized texts.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @unchainedshop/core-assortments
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { configureAssortmentsModule } from '@unchainedshop/core-assortments';
|
|
18
|
+
|
|
19
|
+
const assortmentsModule = await configureAssortmentsModule({ db });
|
|
20
|
+
|
|
21
|
+
// Create an assortment
|
|
22
|
+
const assortmentId = await assortmentsModule.create({
|
|
23
|
+
slugs: ['electronics'],
|
|
24
|
+
isRoot: true,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Find assortments
|
|
28
|
+
const assortments = await assortmentsModule.findAssortments({
|
|
29
|
+
includeInactive: false,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Add product to assortment
|
|
33
|
+
await assortmentsModule.products.create({
|
|
34
|
+
assortmentId,
|
|
35
|
+
productId: 'product-123',
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API Overview
|
|
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
|
|
124
|
+
|
|
125
|
+
| Event | Description |
|
|
126
|
+
|-------|-------------|
|
|
127
|
+
| `ASSORTMENT_CREATE` | Assortment created |
|
|
128
|
+
| `ASSORTMENT_UPDATE` | Assortment updated |
|
|
129
|
+
| `ASSORTMENT_REMOVE` | Assortment deleted |
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
EUPL-1.2
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export * from './db/AssortmentMediaCollection.
|
|
2
|
-
export * from './db/AssortmentsCollection.
|
|
3
|
-
export * from './module/configureAssortmentsModule.
|
|
4
|
-
export * from './module/configureAssortmentFiltersModule.
|
|
5
|
-
export * from './module/configureAssortmentLinksModule.
|
|
6
|
-
export * from './module/configureAssortmentMediaModule.
|
|
7
|
-
export * from './module/configureAssortmentProductsModule.
|
|
8
|
-
export * from './module/configureAssortmentTextsModule.
|
|
9
|
-
export * from './assortments-settings.
|
|
10
|
-
//# sourceMappingURL=assortments-index.d.ts.map
|
|
1
|
+
export * from './db/AssortmentMediaCollection.ts';
|
|
2
|
+
export * from './db/AssortmentsCollection.ts';
|
|
3
|
+
export * from './module/configureAssortmentsModule.ts';
|
|
4
|
+
export * from './module/configureAssortmentFiltersModule.ts';
|
|
5
|
+
export * from './module/configureAssortmentLinksModule.ts';
|
|
6
|
+
export * from './module/configureAssortmentMediaModule.ts';
|
|
7
|
+
export * from './module/configureAssortmentProductsModule.ts';
|
|
8
|
+
export * from './module/configureAssortmentTextsModule.ts';
|
|
9
|
+
export * from './assortments-settings.ts';
|
package/lib/assortments-index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
//# sourceMappingURL=assortments-index.js.map
|
|
1
|
+
export * from "./db/AssortmentMediaCollection.js";
|
|
2
|
+
export * from "./db/AssortmentsCollection.js";
|
|
3
|
+
export * from "./module/configureAssortmentsModule.js";
|
|
4
|
+
export * from "./module/configureAssortmentFiltersModule.js";
|
|
5
|
+
export * from "./module/configureAssortmentLinksModule.js";
|
|
6
|
+
export * from "./module/configureAssortmentMediaModule.js";
|
|
7
|
+
export * from "./module/configureAssortmentProductsModule.js";
|
|
8
|
+
export * from "./module/configureAssortmentTextsModule.js";
|
|
9
|
+
export * from "./assortments-settings.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tree } from '@unchainedshop/utils';
|
|
1
|
+
import { type Tree } from '@unchainedshop/utils';
|
|
2
2
|
import { mongodb } from '@unchainedshop/mongodb';
|
|
3
3
|
export interface AssortmentsSettings {
|
|
4
4
|
zipTree: (data: Tree<string>) => string[];
|
|
@@ -9,4 +9,3 @@ export interface AssortmentsSettings {
|
|
|
9
9
|
}
|
|
10
10
|
export type AssortmentsSettingsOptions = Partial<Omit<AssortmentsSettings, 'configureSettings'>>;
|
|
11
11
|
export declare const assortmentsSettings: AssortmentsSettings;
|
|
12
|
-
//# sourceMappingURL=assortments-settings.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { slugify as defaultSlugify } from '@unchainedshop/utils';
|
|
2
|
-
import zipTreeByDeepness from
|
|
3
|
-
import makeMongoDBCache from
|
|
2
|
+
import zipTreeByDeepness from "./utils/tree-zipper/zipTreeByDeepness.js";
|
|
3
|
+
import makeMongoDBCache from "./product-cache/mongodb.js";
|
|
4
|
+
import { mongodb } from '@unchainedshop/mongodb';
|
|
4
5
|
export const assortmentsSettings = {
|
|
5
6
|
setCachedProductIds: () => Promise.resolve(0),
|
|
6
7
|
getCachedProductIds: () => Promise.resolve(undefined),
|
|
@@ -14,4 +15,3 @@ export const assortmentsSettings = {
|
|
|
14
15
|
assortmentsSettings.getCachedProductIds = getCachedProductIds || defaultCache.getCachedProductIds;
|
|
15
16
|
},
|
|
16
17
|
};
|
|
17
|
-
//# sourceMappingURL=assortments-settings.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mongodb, TimestampFields } from '@unchainedshop/mongodb';
|
|
1
|
+
import { mongodb, type TimestampFields } from '@unchainedshop/mongodb';
|
|
2
2
|
export type AssortmentMediaText = {
|
|
3
3
|
_id: string;
|
|
4
4
|
assortmentMediaId: string;
|
|
@@ -18,4 +18,3 @@ export declare const AssortmentMediaCollection: (db: mongodb.Db) => Promise<{
|
|
|
18
18
|
AssortmentMedia: mongodb.Collection<AssortmentMediaType>;
|
|
19
19
|
AssortmentMediaTexts: mongodb.Collection<AssortmentMediaText>;
|
|
20
20
|
}>;
|
|
21
|
-
//# sourceMappingURL=AssortmentMediaCollection.d.ts.map
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { buildDbIndexes } from '@unchainedshop/mongodb';
|
|
1
|
+
import { mongodb, buildDbIndexes } from '@unchainedshop/mongodb';
|
|
2
2
|
export const AssortmentMediaCollection = async (db) => {
|
|
3
3
|
const AssortmentMedia = db.collection('assortment_media');
|
|
4
4
|
const AssortmentMediaTexts = db.collection('assortment_media_texts');
|
|
5
|
-
// Assortment Indexes
|
|
6
5
|
await buildDbIndexes(AssortmentMedia, [
|
|
7
6
|
{ index: { mediaId: 1 } },
|
|
8
7
|
{ index: { assortmentId: 1, sortKey: 1 } },
|
|
9
8
|
{ index: { tags: 1, sortKey: 1 } },
|
|
10
9
|
{ index: { assortmentId: 1, tags: 1, sortKey: 1 } },
|
|
11
10
|
]);
|
|
12
|
-
// AssortmentTexts indexes
|
|
13
11
|
await buildDbIndexes(AssortmentMediaTexts, [
|
|
14
12
|
{ index: { assortmentMediaId: 1 } },
|
|
15
13
|
{ index: { locale: 1 } },
|
|
@@ -19,4 +17,3 @@ export const AssortmentMediaCollection = async (db) => {
|
|
|
19
17
|
AssortmentMediaTexts,
|
|
20
18
|
};
|
|
21
19
|
};
|
|
22
|
-
//# sourceMappingURL=AssortmentMediaCollection.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mongodb, TimestampFields } from '@unchainedshop/mongodb';
|
|
1
|
+
import { mongodb, type TimestampFields } from '@unchainedshop/mongodb';
|
|
2
2
|
export type AssortmentProductIdCacheRecord = {
|
|
3
3
|
_id: string;
|
|
4
4
|
productIds: string[];
|
|
@@ -66,4 +66,3 @@ export declare const AssortmentsCollection: (db: mongodb.Db) => Promise<{
|
|
|
66
66
|
AssortmentFilters: mongodb.Collection<AssortmentFilter>;
|
|
67
67
|
AssortmentProductIdCache: mongodb.Collection<AssortmentProductIdCacheRecord>;
|
|
68
68
|
}>;
|
|
69
|
-
//# sourceMappingURL=AssortmentsCollection.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildDbIndexes, isDocumentDBCompatModeEnabled, } from '@unchainedshop/mongodb';
|
|
1
|
+
import { buildDbIndexes, isDocumentDBCompatModeEnabled, mongodb, } from '@unchainedshop/mongodb';
|
|
2
2
|
export const AssortmentsCollection = async (db) => {
|
|
3
3
|
const Assortments = db.collection('assortments');
|
|
4
4
|
const AssortmentTexts = db.collection('assortment_texts');
|
|
@@ -6,11 +6,7 @@ export const AssortmentsCollection = async (db) => {
|
|
|
6
6
|
const AssortmentLinks = db.collection('assortment_links');
|
|
7
7
|
const AssortmentFilters = db.collection('assortment_filters');
|
|
8
8
|
const AssortmentProductIdCache = db.collection('assortment_productId_cache');
|
|
9
|
-
// Assortment Indexes
|
|
10
9
|
if (!isDocumentDBCompatModeEnabled()) {
|
|
11
|
-
// Text indexes are not supported in DocumentDB
|
|
12
|
-
// Assortments full-text search index
|
|
13
|
-
// Note: This index is only created if not in DocumentDB compatibility mode
|
|
14
10
|
await buildDbIndexes(Assortments, [
|
|
15
11
|
{
|
|
16
12
|
index: { slugs: 'text' },
|
|
@@ -27,7 +23,6 @@ export const AssortmentsCollection = async (db) => {
|
|
|
27
23
|
{ index: { slugs: 1 } },
|
|
28
24
|
{ index: { tags: 1 } },
|
|
29
25
|
]);
|
|
30
|
-
// AssortmentTexts indexes
|
|
31
26
|
if (!isDocumentDBCompatModeEnabled()) {
|
|
32
27
|
await buildDbIndexes(AssortmentTexts, [
|
|
33
28
|
{
|
|
@@ -48,14 +43,12 @@ export const AssortmentsCollection = async (db) => {
|
|
|
48
43
|
{ index: { slug: 1 } },
|
|
49
44
|
{ index: { locale: 1, assortmentId: 1 } },
|
|
50
45
|
]);
|
|
51
|
-
// AssortmentProducts indexes
|
|
52
46
|
await buildDbIndexes(AssortmentProducts, [
|
|
53
47
|
{ index: { assortmentId: 1 } },
|
|
54
48
|
{ index: { productId: 1 } },
|
|
55
49
|
{ index: { tags: 1 } },
|
|
56
50
|
{ index: { assortmentId: 1, sortKey: 1 } },
|
|
57
51
|
]);
|
|
58
|
-
// AssortmentLinks indices
|
|
59
52
|
await buildDbIndexes(AssortmentLinks, [
|
|
60
53
|
{ index: { parentAssortmentId: 1 } },
|
|
61
54
|
{ index: { childAssortmentId: 1 } },
|
|
@@ -63,7 +56,6 @@ export const AssortmentsCollection = async (db) => {
|
|
|
63
56
|
{ index: { parentAssortmentId: 1, sortKey: 1 } },
|
|
64
57
|
{ index: { childAssortmentId: 1, parentAssortmentId: 1, sortKey: 1 } },
|
|
65
58
|
]);
|
|
66
|
-
// AssortmentFilter indices
|
|
67
59
|
await buildDbIndexes(AssortmentFilters, [
|
|
68
60
|
{ index: { assortmentId: 1 } },
|
|
69
61
|
{ index: { filterId: 1 } },
|
|
@@ -79,4 +71,3 @@ export const AssortmentsCollection = async (db) => {
|
|
|
79
71
|
AssortmentProductIdCache,
|
|
80
72
|
};
|
|
81
73
|
};
|
|
82
|
-
//# sourceMappingURL=AssortmentsCollection.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mongodb } from '@unchainedshop/mongodb';
|
|
2
|
-
import { AssortmentFilter } from '../db/AssortmentsCollection.
|
|
2
|
+
import { type AssortmentFilter } from '../db/AssortmentsCollection.ts';
|
|
3
3
|
export declare const configureAssortmentFiltersModule: ({ AssortmentFilters, }: {
|
|
4
4
|
AssortmentFilters: mongodb.Collection<AssortmentFilter>;
|
|
5
5
|
}) => {
|
|
@@ -24,4 +24,3 @@ export declare const configureAssortmentFiltersModule: ({ AssortmentFilters, }:
|
|
|
24
24
|
}) => Promise<AssortmentFilter[]>;
|
|
25
25
|
};
|
|
26
26
|
export type AssortmentFiltersModule = ReturnType<typeof configureAssortmentFiltersModule>;
|
|
27
|
-
//# sourceMappingURL=configureAssortmentFiltersModule.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { emit, registerEvents } from '@unchainedshop/events';
|
|
2
|
-
import { generateDbFilterById, generateDbObjectId } from '@unchainedshop/mongodb';
|
|
2
|
+
import { generateDbFilterById, generateDbObjectId, mongodb } from '@unchainedshop/mongodb';
|
|
3
|
+
import {} from "../db/AssortmentsCollection.js";
|
|
3
4
|
const ASSORTMENT_FILTER_EVENTS = [
|
|
4
5
|
'ASSORTMENT_ADD_FILTER',
|
|
5
6
|
'ASSORTMENT_REMOVE_FILTER',
|
|
@@ -40,7 +41,6 @@ export const configureAssortmentFiltersModule = ({ AssortmentFilters, }) => {
|
|
|
40
41
|
created: new Date(),
|
|
41
42
|
};
|
|
42
43
|
if (sortKey === undefined || sortKey === null) {
|
|
43
|
-
// Get next sort key
|
|
44
44
|
const lastAssortmentFilter = (await AssortmentFilters.findOne({ assortmentId }, { sort: { sortKey: -1 } })) || { sortKey: 0 };
|
|
45
45
|
$setOnInsert.sortKey = lastAssortmentFilter.sortKey + 1;
|
|
46
46
|
}
|
|
@@ -74,7 +74,6 @@ export const configureAssortmentFiltersModule = ({ AssortmentFilters, }) => {
|
|
|
74
74
|
})));
|
|
75
75
|
return deletionResult.deletedCount;
|
|
76
76
|
},
|
|
77
|
-
// This action is specifically used for the bulk migration scripts in the platform package
|
|
78
77
|
update: async (assortmentFilterId, doc) => {
|
|
79
78
|
const selector = generateDbFilterById(assortmentFilterId);
|
|
80
79
|
const modifier = { $set: doc };
|
|
@@ -100,4 +99,3 @@ export const configureAssortmentFiltersModule = ({ AssortmentFilters, }) => {
|
|
|
100
99
|
},
|
|
101
100
|
};
|
|
102
101
|
};
|
|
103
|
-
//# sourceMappingURL=configureAssortmentFiltersModule.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mongodb } from '@unchainedshop/mongodb';
|
|
2
|
-
import { AssortmentLink, InvalidateCacheFn } from '../db/AssortmentsCollection.
|
|
2
|
+
import { type AssortmentLink, type InvalidateCacheFn } from '../db/AssortmentsCollection.ts';
|
|
3
3
|
export declare const configureAssortmentLinksModule: ({ AssortmentLinks, invalidateCache, }: {
|
|
4
4
|
AssortmentLinks: mongodb.Collection<AssortmentLink>;
|
|
5
5
|
invalidateCache: InvalidateCacheFn;
|
|
@@ -37,4 +37,3 @@ export declare const configureAssortmentLinksModule: ({ AssortmentLinks, invalid
|
|
|
37
37
|
}) => Promise<AssortmentLink[]>;
|
|
38
38
|
};
|
|
39
39
|
export type AssortmentLinksModule = ReturnType<typeof configureAssortmentLinksModule>;
|
|
40
|
-
//# sourceMappingURL=configureAssortmentLinksModule.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { emit, registerEvents } from '@unchainedshop/events';
|
|
2
|
-
import { generateDbFilterById, generateDbObjectId } from '@unchainedshop/mongodb';
|
|
3
|
-
import { walkUpFromAssortment } from
|
|
2
|
+
import { generateDbFilterById, generateDbObjectId, mongodb } from '@unchainedshop/mongodb';
|
|
3
|
+
import { walkUpFromAssortment } from "../utils/breadcrumbs/build-paths.js";
|
|
4
|
+
import {} from "../db/AssortmentsCollection.js";
|
|
4
5
|
const ASSORTMENT_LINK_EVENTS = [
|
|
5
6
|
'ASSORTMENT_ADD_LINK',
|
|
6
7
|
'ASSORTMENT_REMOVE_LINK',
|
|
@@ -9,7 +10,6 @@ const ASSORTMENT_LINK_EVENTS = [
|
|
|
9
10
|
export const configureAssortmentLinksModule = ({ AssortmentLinks, invalidateCache, }) => {
|
|
10
11
|
registerEvents(ASSORTMENT_LINK_EVENTS);
|
|
11
12
|
return {
|
|
12
|
-
// Queries
|
|
13
13
|
findLink: async ({ assortmentLinkId, parentAssortmentId, childAssortmentId, }) => {
|
|
14
14
|
return AssortmentLinks.findOne(assortmentLinkId
|
|
15
15
|
? generateDbFilterById(assortmentLinkId)
|
|
@@ -31,7 +31,6 @@ export const configureAssortmentLinksModule = ({ AssortmentLinks, invalidateCach
|
|
|
31
31
|
});
|
|
32
32
|
return links.toArray();
|
|
33
33
|
},
|
|
34
|
-
// Mutations
|
|
35
34
|
create: async (doc, options) => {
|
|
36
35
|
const { _id: assortmentLinkId, parentAssortmentId, childAssortmentId, sortKey, ...rest } = doc;
|
|
37
36
|
const assortmentLinksPath = await walkUpFromAssortment({
|
|
@@ -57,7 +56,6 @@ export const configureAssortmentLinksModule = ({ AssortmentLinks, invalidateCach
|
|
|
57
56
|
created: new Date(),
|
|
58
57
|
};
|
|
59
58
|
if (sortKey === undefined || sortKey === null) {
|
|
60
|
-
// Get next sort key
|
|
61
59
|
const lastAssortmentLink = (await AssortmentLinks.findOne({ parentAssortmentId }, { sort: { sortKey: -1 } })) || { sortKey: 0 };
|
|
62
60
|
$setOnInsert.sortKey = lastAssortmentLink.sortKey + 1;
|
|
63
61
|
}
|
|
@@ -81,7 +79,6 @@ export const configureAssortmentLinksModule = ({ AssortmentLinks, invalidateCach
|
|
|
81
79
|
}
|
|
82
80
|
return assortmentLink;
|
|
83
81
|
},
|
|
84
|
-
// This action is specifically used for the bulk migration scripts in the platform package
|
|
85
82
|
update: async (assortmentLinkId, doc, options) => {
|
|
86
83
|
const selector = generateDbFilterById(assortmentLinkId);
|
|
87
84
|
const modifier = {
|
|
@@ -156,4 +153,3 @@ export const configureAssortmentLinksModule = ({ AssortmentLinks, invalidateCach
|
|
|
156
153
|
},
|
|
157
154
|
};
|
|
158
155
|
};
|
|
159
|
-
//# sourceMappingURL=configureAssortmentLinksModule.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mongodb, ModuleInput } from '@unchainedshop/mongodb';
|
|
2
|
-
import { AssortmentMediaText, AssortmentMediaType } from '../db/AssortmentMediaCollection.
|
|
1
|
+
import { mongodb, type ModuleInput } from '@unchainedshop/mongodb';
|
|
2
|
+
import { type AssortmentMediaText, type AssortmentMediaType } from '../db/AssortmentMediaCollection.ts';
|
|
3
3
|
export declare const configureAssortmentMediaModule: ({ db }: ModuleInput<Record<string, unknown>>) => Promise<{
|
|
4
4
|
findAssortmentMedia: ({ assortmentMediaId }: {
|
|
5
5
|
assortmentMediaId: string;
|
|
@@ -30,7 +30,9 @@ export declare const configureAssortmentMediaModule: ({ db }: ModuleInput<Record
|
|
|
30
30
|
assortmentMediaId: string;
|
|
31
31
|
locale: Intl.Locale;
|
|
32
32
|
}) => Promise<AssortmentMediaText>;
|
|
33
|
-
updateMediaTexts: (assortmentMediaId: string, texts:
|
|
33
|
+
updateMediaTexts: (assortmentMediaId: string, texts: ({
|
|
34
|
+
locale: AssortmentMediaText["locale"];
|
|
35
|
+
} & Omit<Partial<AssortmentMediaText>, "assortmentMediaId" | "locale">)[]) => Promise<({
|
|
34
36
|
_id: string;
|
|
35
37
|
assortmentMediaId: string;
|
|
36
38
|
locale: string;
|
|
@@ -40,4 +42,3 @@ export declare const configureAssortmentMediaModule: ({ db }: ModuleInput<Record
|
|
|
40
42
|
};
|
|
41
43
|
}>;
|
|
42
44
|
export type AssortmentMediaModule = Awaited<ReturnType<typeof configureAssortmentMediaModule>>;
|
|
43
|
-
//# sourceMappingURL=configureAssortmentMediaModule.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { emit, registerEvents } from '@unchainedshop/events';
|
|
2
|
-
import { findLocalizedText, generateDbFilterById, generateDbObjectId, } from '@unchainedshop/mongodb';
|
|
3
|
-
import { AssortmentMediaCollection } from
|
|
2
|
+
import { findLocalizedText, generateDbFilterById, generateDbObjectId, mongodb, } from '@unchainedshop/mongodb';
|
|
3
|
+
import { AssortmentMediaCollection, } from "../db/AssortmentMediaCollection.js";
|
|
4
4
|
const ASSORTMENT_MEDIA_EVENTS = [
|
|
5
5
|
'ASSORTMENT_ADD_MEDIA',
|
|
6
6
|
'ASSORTMENT_REMOVE_MEDIA',
|
|
@@ -37,7 +37,6 @@ export const configureAssortmentMediaModule = async ({ db }) => {
|
|
|
37
37
|
return assortmentMediaText;
|
|
38
38
|
};
|
|
39
39
|
return {
|
|
40
|
-
// Queries
|
|
41
40
|
findAssortmentMedia: async ({ assortmentMediaId }) => {
|
|
42
41
|
return AssortmentMedia.findOne(generateDbFilterById(assortmentMediaId), {});
|
|
43
42
|
},
|
|
@@ -56,7 +55,6 @@ export const configureAssortmentMediaModule = async ({ db }) => {
|
|
|
56
55
|
},
|
|
57
56
|
create: async ({ sortKey, tags = [], ...doc }) => {
|
|
58
57
|
if (sortKey === undefined || sortKey === null) {
|
|
59
|
-
// Get next sort key
|
|
60
58
|
const lastAssortmentMedia = (await AssortmentMedia.findOne({
|
|
61
59
|
assortmentId: doc.assortmentId,
|
|
62
60
|
}, {
|
|
@@ -104,7 +102,6 @@ export const configureAssortmentMediaModule = async ({ db }) => {
|
|
|
104
102
|
})));
|
|
105
103
|
return deletedResult.deletedCount;
|
|
106
104
|
},
|
|
107
|
-
// This action is specifically used for the bulk migration scripts in the platform package
|
|
108
105
|
update: async (assortmentMediaId, doc) => {
|
|
109
106
|
const selector = generateDbFilterById(assortmentMediaId);
|
|
110
107
|
const modifier = { $set: doc };
|
|
@@ -128,11 +125,7 @@ export const configureAssortmentMediaModule = async ({ db }) => {
|
|
|
128
125
|
await emit('ASSORTMENT_REORDER_MEDIA', { assortmentMedias });
|
|
129
126
|
return assortmentMedias;
|
|
130
127
|
},
|
|
131
|
-
/*
|
|
132
|
-
* Assortment Media Texts
|
|
133
|
-
*/
|
|
134
128
|
texts: {
|
|
135
|
-
// Queries
|
|
136
129
|
findMediaTexts: async ({ assortmentMediaId }, options) => {
|
|
137
130
|
return AssortmentMediaTexts.find({ assortmentMediaId }, options).toArray();
|
|
138
131
|
},
|
|
@@ -147,4 +140,3 @@ export const configureAssortmentMediaModule = async ({ db }) => {
|
|
|
147
140
|
},
|
|
148
141
|
};
|
|
149
142
|
};
|
|
150
|
-
//# sourceMappingURL=configureAssortmentMediaModule.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mongodb } from '@unchainedshop/mongodb';
|
|
2
|
-
import { InvalidateCacheFn, AssortmentProduct } from '../db/AssortmentsCollection.
|
|
2
|
+
import { type InvalidateCacheFn, type AssortmentProduct } from '../db/AssortmentsCollection.ts';
|
|
3
3
|
export declare const configureAssortmentProductsModule: ({ AssortmentProducts, invalidateCache, }: {
|
|
4
4
|
AssortmentProducts: mongodb.Collection<AssortmentProduct>;
|
|
5
5
|
invalidateCache: InvalidateCacheFn;
|
|
@@ -47,4 +47,3 @@ export declare const configureAssortmentProductsModule: ({ AssortmentProducts, i
|
|
|
47
47
|
}) => Promise<AssortmentProduct[]>;
|
|
48
48
|
};
|
|
49
49
|
export type AssortmentProductsModule = ReturnType<typeof configureAssortmentProductsModule>;
|
|
50
|
-
//# sourceMappingURL=configureAssortmentProductsModule.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { emit, registerEvents } from '@unchainedshop/events';
|
|
2
|
-
import { generateDbFilterById, generateDbObjectId } from '@unchainedshop/mongodb';
|
|
2
|
+
import { generateDbFilterById, generateDbObjectId, mongodb } from '@unchainedshop/mongodb';
|
|
3
|
+
import {} from "../db/AssortmentsCollection.js";
|
|
3
4
|
const ASSORTMENT_PRODUCT_EVENTS = [
|
|
4
5
|
'ASSORTMENT_ADD_PRODUCT',
|
|
5
6
|
'ASSORTMENT_REMOVE_PRODUCT',
|
|
@@ -8,7 +9,6 @@ const ASSORTMENT_PRODUCT_EVENTS = [
|
|
|
8
9
|
export const configureAssortmentProductsModule = ({ AssortmentProducts, invalidateCache, }) => {
|
|
9
10
|
registerEvents(ASSORTMENT_PRODUCT_EVENTS);
|
|
10
11
|
return {
|
|
11
|
-
// Queries
|
|
12
12
|
findAssortmentIds: async ({ productId, tags, }) => {
|
|
13
13
|
const selector = { productId };
|
|
14
14
|
if (tags) {
|
|
@@ -51,7 +51,6 @@ export const configureAssortmentProductsModule = ({ AssortmentProducts, invalida
|
|
|
51
51
|
}).toArray();
|
|
52
52
|
return assortmentProducts.map((product) => product.productId);
|
|
53
53
|
},
|
|
54
|
-
// Mutations
|
|
55
54
|
create: async (doc, options) => {
|
|
56
55
|
const { _id, assortmentId, productId, sortKey, ...rest } = doc;
|
|
57
56
|
const selector = {
|
|
@@ -70,7 +69,6 @@ export const configureAssortmentProductsModule = ({ AssortmentProducts, invalida
|
|
|
70
69
|
created: new Date(),
|
|
71
70
|
};
|
|
72
71
|
if (sortKey === undefined || sortKey === null) {
|
|
73
|
-
// Get next sort key
|
|
74
72
|
const lastAssortmentProduct = (await AssortmentProducts.findOne({ assortmentId }, { sort: { sortKey: -1 } })) || { sortKey: 0 };
|
|
75
73
|
$setOnInsert.sortKey = lastAssortmentProduct.sortKey + 1;
|
|
76
74
|
}
|
|
@@ -117,7 +115,6 @@ export const configureAssortmentProductsModule = ({ AssortmentProducts, invalida
|
|
|
117
115
|
}
|
|
118
116
|
return deletionResult.deletedCount;
|
|
119
117
|
},
|
|
120
|
-
// This action is specifically used for the bulk migration scripts in the platform package
|
|
121
118
|
update: async (assortmentProductId, doc, options) => {
|
|
122
119
|
const selector = generateDbFilterById(assortmentProductId);
|
|
123
120
|
const modifier = {
|
|
@@ -157,4 +154,3 @@ export const configureAssortmentProductsModule = ({ AssortmentProducts, invalida
|
|
|
157
154
|
},
|
|
158
155
|
};
|
|
159
156
|
};
|
|
160
|
-
//# sourceMappingURL=configureAssortmentProductsModule.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mongodb } from '@unchainedshop/mongodb';
|
|
2
|
-
import { Assortment, AssortmentText } from '../db/AssortmentsCollection.
|
|
2
|
+
import { type Assortment, type AssortmentText } from '../db/AssortmentsCollection.ts';
|
|
3
3
|
export declare const configureAssortmentTextsModule: ({ Assortments, AssortmentTexts, }: {
|
|
4
4
|
Assortments: mongodb.Collection<Assortment>;
|
|
5
5
|
AssortmentTexts: mongodb.Collection<AssortmentText>;
|
|
@@ -9,7 +9,9 @@ export declare const configureAssortmentTextsModule: ({ Assortments, AssortmentT
|
|
|
9
9
|
assortmentId: string;
|
|
10
10
|
locale: Intl.Locale;
|
|
11
11
|
}) => Promise<AssortmentText>;
|
|
12
|
-
updateTexts: (assortmentId: string, texts:
|
|
12
|
+
updateTexts: (assortmentId: string, texts: ({
|
|
13
|
+
locale: AssortmentText["locale"];
|
|
14
|
+
} & Omit<Partial<AssortmentText>, "assortmentId" | "locale">)[]) => Promise<AssortmentText[]>;
|
|
13
15
|
makeSlug: ({ slug, title, assortmentId, }: {
|
|
14
16
|
slug?: string;
|
|
15
17
|
title?: string;
|
|
@@ -21,4 +23,3 @@ export declare const configureAssortmentTextsModule: ({ Assortments, AssortmentT
|
|
|
21
23
|
}) => Promise<number>;
|
|
22
24
|
};
|
|
23
25
|
export type AssortmentTextsModule = ReturnType<typeof configureAssortmentTextsModule>;
|
|
24
|
-
//# sourceMappingURL=configureAssortmentTextsModule.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { emit, registerEvents } from '@unchainedshop/events';
|
|
2
|
-
import { findLocalizedText, generateDbObjectId } from '@unchainedshop/mongodb';
|
|
2
|
+
import { findLocalizedText, generateDbObjectId, mongodb } from '@unchainedshop/mongodb';
|
|
3
3
|
import { findUnusedSlug } from '@unchainedshop/utils';
|
|
4
|
-
import { assortmentsSettings } from
|
|
4
|
+
import { assortmentsSettings } from "../assortments-settings.js";
|
|
5
|
+
import {} from "../db/AssortmentsCollection.js";
|
|
5
6
|
const ASSORTMENT_TEXT_EVENTS = ['ASSORTMENT_UPDATE_TEXT'];
|
|
6
7
|
export const configureAssortmentTextsModule = ({ Assortments, AssortmentTexts, }) => {
|
|
7
8
|
registerEvents(ASSORTMENT_TEXT_EVENTS);
|
|
@@ -72,7 +73,6 @@ export const configureAssortmentTextsModule = ({ Assortments, AssortmentTexts, }
|
|
|
72
73
|
return assortmentText;
|
|
73
74
|
};
|
|
74
75
|
return {
|
|
75
|
-
// Queries
|
|
76
76
|
findTexts: async (query, options) => {
|
|
77
77
|
const texts = AssortmentTexts.find(query, options);
|
|
78
78
|
return texts.toArray();
|
|
@@ -81,7 +81,6 @@ export const configureAssortmentTextsModule = ({ Assortments, AssortmentTexts, }
|
|
|
81
81
|
const text = await findLocalizedText(AssortmentTexts, { assortmentId }, locale);
|
|
82
82
|
return text;
|
|
83
83
|
},
|
|
84
|
-
// Mutations
|
|
85
84
|
updateTexts: async (assortmentId, texts) => {
|
|
86
85
|
const assortmentTexts = (await Promise.all(texts.map(async ({ locale, ...text }) => upsertLocalizedText(assortmentId, new Intl.Locale(locale), text)))).filter(Boolean);
|
|
87
86
|
return assortmentTexts;
|
|
@@ -100,4 +99,3 @@ export const configureAssortmentTextsModule = ({ Assortments, AssortmentTexts, }
|
|
|
100
99
|
},
|
|
101
100
|
};
|
|
102
101
|
};
|
|
103
|
-
//# sourceMappingURL=configureAssortmentTextsModule.js.map
|