@unchainedshop/platform 2.0.0-beta8 → 2.0.0-beta9
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/jest.config.js +9 -0
- package/lib/bulk-importer/handlers/assortment/create.d.ts +3 -4
- package/lib/bulk-importer/handlers/assortment/create.js +5 -10
- package/lib/bulk-importer/handlers/assortment/create.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/remove.d.ts +2 -2
- package/lib/bulk-importer/handlers/assortment/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/update.d.ts +3 -4
- package/lib/bulk-importer/handlers/assortment/update.js +4 -8
- package/lib/bulk-importer/handlers/assortment/update.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +3 -4
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +8 -5
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentContent.d.ts +3 -4
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentContent.js +3 -3
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentContent.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +3 -4
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +3 -4
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +3 -4
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +6 -5
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +3 -4
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js +6 -7
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/create.d.ts +3 -4
- package/lib/bulk-importer/handlers/filter/create.js +4 -6
- package/lib/bulk-importer/handlers/filter/create.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/remove.d.ts +2 -2
- package/lib/bulk-importer/handlers/filter/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/update.d.ts +3 -4
- package/lib/bulk-importer/handlers/filter/update.js +3 -4
- package/lib/bulk-importer/handlers/filter/update.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/upsertFilterContent.d.ts +3 -5
- package/lib/bulk-importer/handlers/filter/upsertFilterContent.js +3 -3
- package/lib/bulk-importer/handlers/filter/upsertFilterContent.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/upsertFilterOptionContent.d.ts +2 -2
- package/lib/bulk-importer/handlers/filter/upsertFilterOptionContent.js +2 -2
- package/lib/bulk-importer/handlers/filter/upsertFilterOptionContent.js.map +1 -1
- package/lib/bulk-importer/handlers/product/create.d.ts +3 -4
- package/lib/bulk-importer/handlers/product/create.js +5 -9
- package/lib/bulk-importer/handlers/product/create.js.map +1 -1
- package/lib/bulk-importer/handlers/product/remove.d.ts +2 -2
- package/lib/bulk-importer/handlers/product/remove.js +2 -2
- package/lib/bulk-importer/handlers/product/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/product/update.d.ts +3 -4
- package/lib/bulk-importer/handlers/product/update.js +4 -7
- package/lib/bulk-importer/handlers/product/update.js.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +3 -4
- package/lib/bulk-importer/handlers/product/upsertMedia.js +6 -7
- package/lib/bulk-importer/handlers/product/upsertMedia.js.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertProductContent.d.ts +3 -4
- package/lib/bulk-importer/handlers/product/upsertProductContent.js +3 -3
- package/lib/bulk-importer/handlers/product/upsertProductContent.js.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +3 -4
- package/lib/bulk-importer/handlers/product/upsertVariations.js +16 -13
- package/lib/bulk-importer/handlers/product/upsertVariations.js.map +1 -1
- package/lib/bulk-importer/upsertAsset.d.ts +2 -2
- package/lib/bulk-importer/upsertAsset.js +2 -3
- package/lib/bulk-importer/upsertAsset.js.map +1 -1
- package/lib/setup/setupAccounts.js +2 -1
- package/lib/setup/setupAccounts.js.map +1 -1
- package/lib/setup/setupCarts.js.map +1 -1
- package/lib/templates/utils/getOrderAttachmentsData.d.ts +2 -2
- package/lib/templates/utils/getOrderAttachmentsData.js.map +1 -1
- package/lib/templates/utils/getOrderPositionsData.d.ts +2 -2
- package/lib/templates/utils/getOrderPositionsData.js.map +1 -1
- package/package.json +15 -14
- package/src/bulk-importer/handlers/assortment/create.ts +9 -18
- package/src/bulk-importer/handlers/assortment/remove.ts +2 -2
- package/src/bulk-importer/handlers/assortment/update.ts +5 -13
- package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +9 -18
- package/src/bulk-importer/handlers/assortment/upsertAssortmentContent.ts +5 -12
- package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +4 -5
- package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +10 -18
- package/src/bulk-importer/handlers/assortment/upsertMedia.ts +13 -20
- package/src/bulk-importer/handlers/filter/create.ts +4 -8
- package/src/bulk-importer/handlers/filter/remove.ts +2 -2
- package/src/bulk-importer/handlers/filter/update.ts +4 -6
- package/src/bulk-importer/handlers/filter/upsertFilterContent.ts +5 -15
- package/src/bulk-importer/handlers/filter/upsertFilterOptionContent.ts +12 -12
- package/src/bulk-importer/handlers/product/create.ts +12 -23
- package/src/bulk-importer/handlers/product/remove.ts +4 -4
- package/src/bulk-importer/handlers/product/update.ts +7 -14
- package/src/bulk-importer/handlers/product/upsertMedia.ts +12 -16
- package/src/bulk-importer/handlers/product/upsertProductContent.ts +5 -15
- package/src/bulk-importer/handlers/product/upsertVariations.ts +26 -34
- package/src/bulk-importer/upsertAsset.ts +4 -5
- package/src/setup/setupAccounts.ts +7 -8
- package/src/setup/setupCarts.ts +1 -0
- package/src/templates/utils/getOrderAttachmentsData.ts +2 -2
- package/src/templates/utils/getOrderPositionsData.ts +2 -2
- package/tests/platform-index.test.ts +5 -0
package/jest.config.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function createAssortment(payload: any, { logger,
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
export default function createAssortment(payload: any, { logger, createShouldUpsertIfIDExists }: {
|
|
3
3
|
logger: any;
|
|
4
|
-
authorId: any;
|
|
5
4
|
createShouldUpsertIfIDExists: any;
|
|
6
|
-
}, unchainedAPI:
|
|
5
|
+
}, unchainedAPI: UnchainedCore): Promise<{
|
|
7
6
|
entity: string;
|
|
8
7
|
operation: string;
|
|
9
8
|
_id: any;
|
|
@@ -4,8 +4,8 @@ import upsertAssortmentContent from './upsertAssortmentContent';
|
|
|
4
4
|
import upsertAssortmentFilters from './upsertAssortmentFilters';
|
|
5
5
|
import upsertAssortmentProducts from './upsertAssortmentProducts';
|
|
6
6
|
import upsertMedia from './upsertMedia';
|
|
7
|
-
export default async function createAssortment(payload, { logger,
|
|
8
|
-
const { modules
|
|
7
|
+
export default async function createAssortment(payload, { logger, createShouldUpsertIfIDExists }, unchainedAPI) {
|
|
8
|
+
const { modules } = unchainedAPI;
|
|
9
9
|
const { media, specification, products, children, filters, _id } = payload;
|
|
10
10
|
if (!specification)
|
|
11
11
|
throw new Error(`Specification is required when creating new assortment ${_id}`);
|
|
@@ -14,7 +14,7 @@ export default async function createAssortment(payload, { logger, authorId, crea
|
|
|
14
14
|
specification.tags = convertTagsToLowerCase(specification?.tags);
|
|
15
15
|
logger.debug('create assortment object', specification);
|
|
16
16
|
try {
|
|
17
|
-
await modules.assortments.create({ ...specification, _id
|
|
17
|
+
await modules.assortments.create({ ...specification, _id });
|
|
18
18
|
}
|
|
19
19
|
catch (e) {
|
|
20
20
|
if (!createShouldUpsertIfIDExists)
|
|
@@ -22,8 +22,7 @@ export default async function createAssortment(payload, { logger, authorId, crea
|
|
|
22
22
|
logger.debug('entity already exists, falling back to update', specification);
|
|
23
23
|
await modules.assortments.update(_id, {
|
|
24
24
|
...specification,
|
|
25
|
-
|
|
26
|
-
}, userId);
|
|
25
|
+
});
|
|
27
26
|
}
|
|
28
27
|
if (!(await modules.assortments.assortmentExists({ assortmentId: _id }))) {
|
|
29
28
|
throw new Error(`Can't create assortment ${_id}, fields missing?`);
|
|
@@ -32,28 +31,24 @@ export default async function createAssortment(payload, { logger, authorId, crea
|
|
|
32
31
|
await upsertAssortmentContent({
|
|
33
32
|
content: specification.content,
|
|
34
33
|
assortmentId: _id,
|
|
35
|
-
authorId,
|
|
36
34
|
}, unchainedAPI);
|
|
37
35
|
logger.debug('create assortment products', products);
|
|
38
36
|
await upsertAssortmentProducts({
|
|
39
37
|
products: products || [],
|
|
40
38
|
assortmentId: _id,
|
|
41
|
-
authorId,
|
|
42
39
|
}, unchainedAPI);
|
|
43
40
|
logger.debug('create assortment children', children);
|
|
44
41
|
await upsertAssortmentChildren({
|
|
45
42
|
children: children || [],
|
|
46
43
|
assortmentId: _id,
|
|
47
|
-
authorId,
|
|
48
44
|
}, unchainedAPI);
|
|
49
45
|
logger.debug('create assortment filters', filters);
|
|
50
46
|
await upsertAssortmentFilters({
|
|
51
47
|
filters: filters || [],
|
|
52
48
|
assortmentId: _id,
|
|
53
|
-
authorId,
|
|
54
49
|
}, unchainedAPI);
|
|
55
50
|
logger.debug('create assortment media', media);
|
|
56
|
-
await upsertMedia({ media: media || [], assortmentId: _id
|
|
51
|
+
await upsertMedia({ media: media || [], assortmentId: _id }, unchainedAPI);
|
|
57
52
|
return {
|
|
58
53
|
entity: 'ASSORTMENT',
|
|
59
54
|
operation: 'create',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/create.ts"],"names":[],"mappings":"AACA,OAAO,sBAAsB,MAAM,iCAAiC,CAAC;AACrE,OAAO,wBAAwB,MAAM,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AEF,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;IAC/C,MAAM,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;IAE3E,OAAO;QACL,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
2
|
export default function removeAssortment(payload: any, { logger }: {
|
|
3
3
|
logger: any;
|
|
4
|
-
}, unchainedAPI:
|
|
4
|
+
}, unchainedAPI: UnchainedCore): Promise<{
|
|
5
5
|
entity: string;
|
|
6
6
|
operation: string;
|
|
7
7
|
_id: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/remove.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"remove.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/remove.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,YAA2B;IAC7F,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAClC,MAAM,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;IAElE,OAAO;QACL,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function updateAssortment(payload: any, { logger
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
export default function updateAssortment(payload: any, { logger }: {
|
|
3
3
|
logger: any;
|
|
4
|
-
|
|
5
|
-
}, unchainedAPI: Context): Promise<{
|
|
4
|
+
}, unchainedAPI: UnchainedCore): Promise<{
|
|
6
5
|
entity: string;
|
|
7
6
|
operation: string;
|
|
8
7
|
_id: any;
|
|
@@ -4,8 +4,8 @@ import upsertAssortmentChildren from './upsertAssortmentChildren';
|
|
|
4
4
|
import upsertAssortmentFilters from './upsertAssortmentFilters';
|
|
5
5
|
import upsertMedia from './upsertMedia';
|
|
6
6
|
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase';
|
|
7
|
-
export default async function updateAssortment(payload, { logger
|
|
8
|
-
const { modules
|
|
7
|
+
export default async function updateAssortment(payload, { logger }, unchainedAPI) {
|
|
8
|
+
const { modules } = unchainedAPI;
|
|
9
9
|
const { media, specification, products, children, filters, _id } = payload;
|
|
10
10
|
if (!(await modules.assortments.assortmentExists({ assortmentId: _id }))) {
|
|
11
11
|
throw new Error(`Can't update non-existing assortment ${_id}`);
|
|
@@ -13,13 +13,12 @@ export default async function updateAssortment(payload, { logger, authorId }, un
|
|
|
13
13
|
if (specification) {
|
|
14
14
|
logger.debug('update assortment object', specification);
|
|
15
15
|
specification.tags = convertTagsToLowerCase(specification?.tags);
|
|
16
|
-
await unchainedAPI.modules.assortments.update(_id, { ...specification
|
|
16
|
+
await unchainedAPI.modules.assortments.update(_id, { ...specification });
|
|
17
17
|
if (specification.content) {
|
|
18
18
|
logger.debug('replace localized content for assortment', specification.content);
|
|
19
19
|
await upsertAssortmentContent({
|
|
20
20
|
content: specification.content,
|
|
21
21
|
assortmentId: _id,
|
|
22
|
-
authorId,
|
|
23
22
|
}, unchainedAPI);
|
|
24
23
|
}
|
|
25
24
|
}
|
|
@@ -28,7 +27,6 @@ export default async function updateAssortment(payload, { logger, authorId }, un
|
|
|
28
27
|
await upsertAssortmentProducts({
|
|
29
28
|
products: products || [],
|
|
30
29
|
assortmentId: _id,
|
|
31
|
-
authorId,
|
|
32
30
|
}, unchainedAPI);
|
|
33
31
|
}
|
|
34
32
|
if (children) {
|
|
@@ -36,7 +34,6 @@ export default async function updateAssortment(payload, { logger, authorId }, un
|
|
|
36
34
|
await upsertAssortmentChildren({
|
|
37
35
|
children: children || [],
|
|
38
36
|
assortmentId: _id,
|
|
39
|
-
authorId,
|
|
40
37
|
}, unchainedAPI);
|
|
41
38
|
}
|
|
42
39
|
if (filters) {
|
|
@@ -44,12 +41,11 @@ export default async function updateAssortment(payload, { logger, authorId }, un
|
|
|
44
41
|
await upsertAssortmentFilters({
|
|
45
42
|
filters: filters || [],
|
|
46
43
|
assortmentId: _id,
|
|
47
|
-
authorId,
|
|
48
44
|
}, unchainedAPI);
|
|
49
45
|
}
|
|
50
46
|
if (media) {
|
|
51
47
|
logger.debug('update assortment media', media);
|
|
52
|
-
await upsertMedia({ media: media || [], assortmentId: _id
|
|
48
|
+
await upsertMedia({ media: media || [], assortmentId: _id }, unchainedAPI);
|
|
53
49
|
}
|
|
54
50
|
return {
|
|
55
51
|
entity: 'ASSORTMENT',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/update.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,sBAAsB,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,MAAM,uBAAuB,CAC3B;gBACE,OAAO,EAAE,aAAa,CAAC,OAAO;gBAC9B,YAAY,EAAE,GAAG;aAClB,EACD,YAAY,CACb,CAAC;SACH;KACF;IAED,IAAI,QAAQ,EAAE;QACZ,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;QAClD,MAAM,wBAAwB,CAC5B;YACE,QAAQ,EAAE,QAAQ,IAAI,EAAE;YACxB,YAAY,EAAE,GAAG;SAClB,EACD,YAAY,CACb,CAAC;KACH;IAED,IAAI,QAAQ,EAAE;QACZ,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC;QACrD,MAAM,wBAAwB,CAC5B;YACE,QAAQ,EAAE,QAAQ,IAAI,EAAE;YACxB,YAAY,EAAE,GAAG;SAClB,EACD,YAAY,CACb,CAAC;KACH;IAED,IAAI,OAAO,EAAE;QACX,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;QACnD,MAAM,uBAAuB,CAC3B;YACE,OAAO,EAAE,OAAO,IAAI,EAAE;YACtB,YAAY,EAAE,GAAG;SAClB,EACD,YAAY,CACb,CAAC;KACH;IACD,IAAI,KAAK,EAAE;QACT,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAC/C,MAAM,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;KAC5E;IAED,OAAO;QACL,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: ({ children,
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
declare const _default: ({ children, assortmentId: parentAssortmentId }: {
|
|
3
3
|
children: any;
|
|
4
|
-
authorId: any;
|
|
5
4
|
assortmentId: any;
|
|
6
|
-
}, unchainedAPI:
|
|
5
|
+
}, unchainedAPI: UnchainedCore) => Promise<void>;
|
|
7
6
|
export default _default;
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase';
|
|
2
|
-
const upsert = async (assortmentLink, { modules
|
|
2
|
+
const upsert = async (assortmentLink, { modules }) => {
|
|
3
3
|
if (!(await modules.assortments.assortmentExists({
|
|
4
4
|
assortmentId: assortmentLink.childAssortmentId,
|
|
5
5
|
}))) {
|
|
6
6
|
throw new Error(`Can't link non-existing assortment ${assortmentLink.childAssortmentId}`);
|
|
7
7
|
}
|
|
8
8
|
try {
|
|
9
|
-
const newAssortmentLink = await modules.assortments.links.create(assortmentLink, {
|
|
9
|
+
const newAssortmentLink = await modules.assortments.links.create(assortmentLink, {
|
|
10
|
+
skipInvalidation: true,
|
|
11
|
+
});
|
|
10
12
|
return newAssortmentLink;
|
|
11
13
|
}
|
|
12
14
|
catch (e) {
|
|
13
|
-
return modules.assortments.links.update(assortmentLink._id, assortmentLink, {
|
|
15
|
+
return modules.assortments.links.update(assortmentLink._id, assortmentLink, {
|
|
16
|
+
skipInvalidation: true,
|
|
17
|
+
});
|
|
14
18
|
}
|
|
15
19
|
};
|
|
16
|
-
export default async ({ children,
|
|
20
|
+
export default async ({ children, assortmentId: parentAssortmentId }, unchainedAPI) => {
|
|
17
21
|
const { modules } = unchainedAPI;
|
|
18
22
|
const assortmentLinkIds = await Promise.all(children.map(async ({ assortmentId: childAssortmentId, ...childrenRest }) => {
|
|
19
23
|
const tags = convertTagsToLowerCase(childrenRest?.tags);
|
|
20
24
|
const assortmentLink = await upsert({
|
|
21
25
|
...childrenRest,
|
|
22
26
|
tags,
|
|
23
|
-
authorId,
|
|
24
27
|
parentAssortmentId,
|
|
25
28
|
childAssortmentId,
|
|
26
29
|
}, unchainedAPI);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertAssortmentChildren.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,MAAM,iCAAiC,CAAC;AAErE,MAAM,MAAM,GAAG,KAAK,EAAE,cAA8B,EAAE,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"upsertAssortmentChildren.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,MAAM,iCAAiC,CAAC;AAErE,MAAM,MAAM,GAAG,KAAK,EAAE,cAA8B,EAAE,EAAE,OAAO,EAAiB,EAAE,EAAE;IAClF,IACE,CAAC,CAAC,MAAM,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC;QAC3C,YAAY,EAAE,cAAc,CAAC,iBAAiB;KAC/C,CAAC,CAAC,EACH;QACA,MAAM,IAAI,KAAK,CAAC,sCAAsC,cAAc,CAAC,iBAAiB,EAAE,CAAC,CAAC;KAC3F;IACD,IAAI;QACF,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,EAAE;YAC/E,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,OAAO,iBAAiB,CAAC;KAC1B;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE;YAC1E,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;KACJ;AACH,CAAC,CAAC;AAEF,eAAe,KAAK,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,EAAE,YAA2B,EAAE,EAAE;IACnG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CACzC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,YAAY,EAAE,EAAE,EAAE;QAC1E,MAAM,IAAI,GAAG,sBAAsB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QACxD,MAAM,cAAc,GAAG,MAAM,MAAM,CACjC;YACE,GAAG,YAAY;YACf,IAAI;YACJ,kBAAkB;YAClB,iBAAiB;SACA,EACnB,YAAY,CACb,CAAC;QACF,OAAO,cAAc,CAAC,GAAG,CAAC;IAC5B,CAAC,CAAC,CACH,CAAC;IACF,MAAM,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CACxC;QACE,GAAG,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;QAChC,kBAAkB;KACnB,EACD,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAC3B,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: ({ assortmentId, content
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
declare const _default: ({ assortmentId, content }: {
|
|
3
3
|
assortmentId: any;
|
|
4
4
|
content: any;
|
|
5
|
-
|
|
6
|
-
}, { modules, userId }: Context) => Promise<void>;
|
|
5
|
+
}, { modules }: UnchainedCore) => Promise<void>;
|
|
7
6
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export default async ({ assortmentId, content
|
|
2
|
-
await Promise.all(Object.entries(content).map(async ([locale,
|
|
3
|
-
return modules.assortments.texts.upsertLocalizedText(assortmentId, locale, localizedData
|
|
1
|
+
export default async ({ assortmentId, content }, { modules }) => {
|
|
2
|
+
await Promise.all(Object.entries(content).map(async ([locale, localizedData]) => {
|
|
3
|
+
return modules.assortments.texts.upsertLocalizedText(assortmentId, locale, localizedData);
|
|
4
4
|
}));
|
|
5
5
|
};
|
|
6
6
|
//# sourceMappingURL=upsertAssortmentContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertAssortmentContent.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentContent.ts"],"names":[],"mappings":"AAGA,eAAe,KAAK,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"upsertAssortmentContent.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentContent.ts"],"names":[],"mappings":"AAGA,eAAe,KAAK,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAiB,EAAE,EAAE;IAC7E,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,aAAa,CAA2B,EAAE,EAAE;QACtF,OAAO,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IAC5F,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: ({ filters,
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
declare const _default: ({ filters, assortmentId }: {
|
|
3
3
|
filters: any;
|
|
4
|
-
authorId: any;
|
|
5
4
|
assortmentId: any;
|
|
6
|
-
}, unchainedAPI:
|
|
5
|
+
}, unchainedAPI: UnchainedCore) => Promise<void>;
|
|
7
6
|
export default _default;
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase';
|
|
2
|
-
const upsert = async (assortmentFilter, { modules
|
|
2
|
+
const upsert = async (assortmentFilter, { modules }) => {
|
|
3
3
|
if (!(await modules.filters.filterExists({
|
|
4
4
|
filterId: assortmentFilter.filterId,
|
|
5
5
|
}))) {
|
|
6
6
|
throw new Error(`Can't link non-existing filter ${assortmentFilter.filterId}`);
|
|
7
7
|
}
|
|
8
8
|
try {
|
|
9
|
-
const newAssortmentFilter = await modules.assortments.filters.create(assortmentFilter
|
|
9
|
+
const newAssortmentFilter = await modules.assortments.filters.create(assortmentFilter);
|
|
10
10
|
return newAssortmentFilter;
|
|
11
11
|
}
|
|
12
12
|
catch (e) {
|
|
13
13
|
return modules.assortments.filters.update(assortmentFilter._id, assortmentFilter);
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
export default async ({ filters,
|
|
16
|
+
export default async ({ filters, assortmentId }, unchainedAPI) => {
|
|
17
17
|
const { modules } = unchainedAPI;
|
|
18
18
|
const assortmentFilterIds = await Promise.all(filters.map(async (filter) => {
|
|
19
19
|
const tags = convertTagsToLowerCase(filter?.tags);
|
|
20
20
|
const assortmentFilter = await upsert({
|
|
21
21
|
...filter,
|
|
22
22
|
tags,
|
|
23
|
-
authorId,
|
|
24
23
|
assortmentId,
|
|
25
24
|
}, unchainedAPI);
|
|
26
25
|
return assortmentFilter._id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertAssortmentFilters.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,MAAM,iCAAiC,CAAC;AAErE,MAAM,MAAM,GAAG,KAAK,EAAE,gBAAkC,EAAE,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"upsertAssortmentFilters.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,MAAM,iCAAiC,CAAC;AAErE,MAAM,MAAM,GAAG,KAAK,EAAE,gBAAkC,EAAE,EAAE,OAAO,EAAiB,EAAE,EAAE;IACtF,IACE,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;QACnC,QAAQ,EAAE,gBAAgB,CAAC,QAAQ;KACpC,CAAC,CAAC,EACH;QACA,MAAM,IAAI,KAAK,CAAC,kCAAkC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC;KAChF;IACD,IAAI;QACF,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACvF,OAAO,mBAAmB,CAAC;KAC5B;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;KACnF;AACH,CAAC,CAAC;AAEF,eAAe,KAAK,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,YAA2B,EAAE,EAAE;IAC9E,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,GAAG,CAC3C,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAwB,EAAE,EAAE;QAC7C,MAAM,IAAI,GAAG,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClD,MAAM,gBAAgB,GAAG,MAAM,MAAM,CACnC;YACE,GAAG,MAAM;YACT,IAAI;YACJ,YAAY;SACb,EACD,YAAY,CACb,CAAC;QACF,OAAO,gBAAgB,CAAC,GAAG,CAAC;IAC9B,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC;QAC3C,GAAG,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE;QAClC,YAAY;KACb,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: ({ products,
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
declare const _default: ({ products, assortmentId }: {
|
|
3
3
|
products: any;
|
|
4
|
-
authorId: any;
|
|
5
4
|
assortmentId: any;
|
|
6
|
-
}, unchainedAPI:
|
|
5
|
+
}, unchainedAPI: UnchainedCore) => Promise<void>;
|
|
7
6
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase';
|
|
2
2
|
const upsert = async (assortmentProduct, unchainedAPI) => {
|
|
3
|
-
const { modules
|
|
3
|
+
const { modules } = unchainedAPI;
|
|
4
4
|
if (!(await modules.products.productExists({
|
|
5
5
|
productId: assortmentProduct.productId,
|
|
6
6
|
}))) {
|
|
@@ -9,20 +9,21 @@ const upsert = async (assortmentProduct, unchainedAPI) => {
|
|
|
9
9
|
try {
|
|
10
10
|
const newAssortmentProduct = await modules.assortments.products.create(assortmentProduct, {
|
|
11
11
|
skipInvalidation: true,
|
|
12
|
-
}
|
|
12
|
+
});
|
|
13
13
|
return newAssortmentProduct;
|
|
14
14
|
}
|
|
15
15
|
catch (e) {
|
|
16
|
-
return modules.assortments.products.update(assortmentProduct._id, assortmentProduct, {
|
|
16
|
+
return modules.assortments.products.update(assortmentProduct._id, assortmentProduct, {
|
|
17
|
+
skipInvalidation: true,
|
|
18
|
+
});
|
|
17
19
|
}
|
|
18
20
|
};
|
|
19
|
-
export default async ({ products,
|
|
21
|
+
export default async ({ products, assortmentId }, unchainedAPI) => {
|
|
20
22
|
const { modules } = unchainedAPI;
|
|
21
23
|
const assortmentProductIds = await Promise.all(products.map(async (product) => {
|
|
22
24
|
const tags = convertTagsToLowerCase(product?.tags);
|
|
23
25
|
const assortmentProduct = await upsert({
|
|
24
26
|
...product,
|
|
25
|
-
authorId,
|
|
26
27
|
tags,
|
|
27
28
|
assortmentId,
|
|
28
29
|
}, unchainedAPI);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertAssortmentProducts.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,MAAM,iCAAiC,CAAC;AAErE,MAAM,MAAM,GAAG,KAAK,EAAE,iBAAoC,EAAE,
|
|
1
|
+
{"version":3,"file":"upsertAssortmentProducts.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,MAAM,iCAAiC,CAAC;AAErE,MAAM,MAAM,GAAG,KAAK,EAAE,iBAAoC,EAAE,YAA2B,EAAE,EAAE;IACzF,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,IACE,CAAC,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;QACrC,SAAS,EAAE,iBAAiB,CAAC,SAAS;KACvC,CAAC,CAAC,EACH;QACA,MAAM,IAAI,KAAK,CAAC,mCAAmC,iBAAiB,CAAC,SAAS,EAAE,CAAC,CAAC;KACnF;IACD,IAAI;QACF,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE;YACxF,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,OAAO,oBAAoB,CAAC;KAC7B;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,iBAAiB,EAAE;YACnF,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;KACJ;AACH,CAAC,CAAC;AAEF,eAAe,KAAK,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,YAA2B,EAAE,EAAE;IAC/E,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,GAAG,CAC5C,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAA0B,EAAE,EAAE;QAChD,MAAM,IAAI,GAAG,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACnD,MAAM,iBAAiB,GAAG,MAAM,MAAM,CACpC;YACE,GAAG,OAAO;YACV,IAAI;YACJ,YAAY;SACb,EACD,YAAY,CACb,CAAC;QACF,OAAO,iBAAiB,CAAC,GAAG,CAAC;IAC/B,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAC3C;QACE,GAAG,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE;QACnC,YAAY;KACb,EACD,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAC3B,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: ({ media,
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
declare const _default: ({ media, assortmentId }: {
|
|
3
3
|
media: any;
|
|
4
|
-
authorId: any;
|
|
5
4
|
assortmentId: any;
|
|
6
|
-
}, unchainedAPI:
|
|
5
|
+
}, unchainedAPI: UnchainedCore) => Promise<void>;
|
|
7
6
|
export default _default;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import upsertAsset from '../../upsertAsset';
|
|
2
2
|
const upsertMediaObject = async (media, unchainedAPI) => {
|
|
3
|
-
const { modules
|
|
3
|
+
const { modules } = unchainedAPI;
|
|
4
4
|
try {
|
|
5
|
-
const assortmentMedia = await modules.assortments.media.create(media
|
|
5
|
+
const assortmentMedia = await modules.assortments.media.create(media);
|
|
6
6
|
return assortmentMedia;
|
|
7
7
|
}
|
|
8
8
|
catch (e) {
|
|
@@ -10,14 +10,13 @@ const upsertMediaObject = async (media, unchainedAPI) => {
|
|
|
10
10
|
return modules.assortments.media.update(_id, mediaData);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
export default async ({ media,
|
|
14
|
-
const { modules
|
|
13
|
+
export default async ({ media, assortmentId }, unchainedAPI) => {
|
|
14
|
+
const { modules } = unchainedAPI;
|
|
15
15
|
const mediaObjects = await Promise.all(media.map(async ({ asset, content, ...mediaData }) => {
|
|
16
16
|
const file = await upsertAsset('assortment-media', { meta: { ...(asset.meta || {}), assortmentId }, ...asset }, unchainedAPI);
|
|
17
17
|
if (!file)
|
|
18
18
|
throw new Error(`Unable to create binary ${asset._id}`);
|
|
19
19
|
const mediaObject = await upsertMediaObject({
|
|
20
|
-
authorId,
|
|
21
20
|
...mediaData,
|
|
22
21
|
assortmentId,
|
|
23
22
|
mediaId: file._id,
|
|
@@ -25,8 +24,8 @@ export default async ({ media, authorId, assortmentId }, unchainedAPI) => {
|
|
|
25
24
|
if (!mediaObject)
|
|
26
25
|
throw new Error(`Unable to create media object ${mediaObject._id}`);
|
|
27
26
|
if (content) {
|
|
28
|
-
await Promise.all(Object.entries(content).map(async ([locale,
|
|
29
|
-
return modules.assortments.media.texts.upsertLocalizedText(mediaObject._id, locale, localizedData
|
|
27
|
+
await Promise.all(Object.entries(content).map(async ([locale, localizedData]) => {
|
|
28
|
+
return modules.assortments.media.texts.upsertLocalizedText(mediaObject._id, locale, localizedData);
|
|
30
29
|
}));
|
|
31
30
|
}
|
|
32
31
|
return mediaObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertMedia.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertMedia.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,MAAM,iBAAiB,GAAG,KAAK,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"upsertMedia.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertMedia.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,MAAM,iBAAiB,GAAG,KAAK,EAAE,KAAK,EAAE,YAA2B,EAAE,EAAE;IACrE,MAAM,EAAE,OAAO,EAAE,GAAG,Y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AAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,aAAa,CAAgC,EAAE,EAAE;gBAC3F,OAAO,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,CACxD,WAAW,CAAC,GAAG,EACf,MAAM,EACN,aAAa,CACd,CAAC;YACJ,CAAC,CAAC,CACH,CAAC;SACH;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,gBAAgB,CAAC;QAC/C,YAAY;QACZ,0BAA0B,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC;KAC/D,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function createFilter(payload: any, { logger,
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
export default function createFilter(payload: any, { logger, createShouldUpsertIfIDExists }: {
|
|
3
3
|
logger: any;
|
|
4
|
-
authorId: any;
|
|
5
4
|
createShouldUpsertIfIDExists: any;
|
|
6
|
-
}, unchainedAPI:
|
|
5
|
+
}, unchainedAPI: UnchainedCore): Promise<{
|
|
7
6
|
entity: string;
|
|
8
7
|
operation: string;
|
|
9
8
|
_id: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import upsertFilterContent from './upsertFilterContent';
|
|
2
2
|
import upsertFilterOptionContent from './upsertFilterOptionContent';
|
|
3
|
-
export default async function createFilter(payload, { logger,
|
|
3
|
+
export default async function createFilter(payload, { logger, createShouldUpsertIfIDExists }, unchainedAPI) {
|
|
4
4
|
const { modules } = unchainedAPI;
|
|
5
5
|
const { specification, _id } = payload;
|
|
6
6
|
if (!specification)
|
|
@@ -14,8 +14,7 @@ export default async function createFilter(payload, { logger, authorId, createSh
|
|
|
14
14
|
...filterData,
|
|
15
15
|
_id,
|
|
16
16
|
options: options?.map((option) => option.value) || [],
|
|
17
|
-
|
|
18
|
-
}, unchainedAPI, { skipInvalidation: true }, unchainedAPI.userId);
|
|
17
|
+
}, unchainedAPI, { skipInvalidation: true });
|
|
19
18
|
}
|
|
20
19
|
catch (e) {
|
|
21
20
|
if (!createShouldUpsertIfIDExists)
|
|
@@ -24,14 +23,13 @@ export default async function createFilter(payload, { logger, authorId, createSh
|
|
|
24
23
|
await modules.filters.update(_id, {
|
|
25
24
|
...filterData,
|
|
26
25
|
options: options?.map((option) => option.value) || [],
|
|
27
|
-
|
|
28
|
-
}, unchainedAPI, { skipInvalidation: true }, unchainedAPI.userId);
|
|
26
|
+
}, unchainedAPI, { skipInvalidation: true });
|
|
29
27
|
}
|
|
30
28
|
if (!(await modules.filters.filterExists({ filterId: _id }))) {
|
|
31
29
|
throw new Error(`Can't upsert filter ${_id}`);
|
|
32
30
|
}
|
|
33
31
|
logger.debug('create localized content for filter', content);
|
|
34
|
-
await upsertFilterContent({ content, filterId: _id
|
|
32
|
+
await upsertFilterContent({ content, filterId: _id }, unchainedAPI);
|
|
35
33
|
logger.debug('create localized content for filter options', content);
|
|
36
34
|
await upsertFilterOptionContent({ options, filterId: _id }, unchainedAPI);
|
|
37
35
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/create.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AAEpE,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CACxC,OAAY,EACZ,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/create.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,y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,CAAC;KACH;IAED,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE;QAC5D,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,EAAE,CAAC,CAAC;KAC/C;IAED,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;IAC7D,MAAM,mBAAmB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;IAEpE,MAAM,CAAC,KAAK,CAAC,6CAA6C,EAAE,OAAO,CAAC,CAAC;IACrE,MAAM,yBAAyB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;IAE1E,OAAO;QACL,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
2
|
export default function removeFilter(payload: any, { logger }: {
|
|
3
3
|
logger: any;
|
|
4
|
-
}, unchainedAPI:
|
|
4
|
+
}, unchainedAPI: UnchainedCore): Promise<{
|
|
5
5
|
entity: string;
|
|
6
6
|
operation: string;
|
|
7
7
|
_id: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/remove.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CAAC,OAAY,EAAE,EAAE,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"remove.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/remove.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CAAC,OAAY,EAAE,EAAE,MAAM,EAAE,EAAE,YAA2B;IAC9F,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC9B,MAAM,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;IAChE,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAElC,OAAO;QACL,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function updateFilter(payload: any, {
|
|
3
|
-
authorId: string;
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
export default function updateFilter(payload: any, { logger }: {
|
|
4
3
|
logger: any;
|
|
5
|
-
}, unchainedAPI:
|
|
4
|
+
}, unchainedAPI: UnchainedCore): Promise<{
|
|
6
5
|
entity: string;
|
|
7
6
|
operation: string;
|
|
8
7
|
_id: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import upsertFilterContent from './upsertFilterContent';
|
|
2
2
|
import upsertFilterOptionContent from './upsertFilterOptionContent';
|
|
3
|
-
export default async function updateFilter(payload, {
|
|
3
|
+
export default async function updateFilter(payload, { logger }, unchainedAPI) {
|
|
4
4
|
const { modules } = unchainedAPI;
|
|
5
5
|
const { specification, _id } = payload;
|
|
6
6
|
if (!(await modules.filters.filterExists({ filterId: _id }))) {
|
|
@@ -12,12 +12,11 @@ export default async function updateFilter(payload, { authorId, logger }, unchai
|
|
|
12
12
|
await modules.filters.update(_id, {
|
|
13
13
|
...filterData,
|
|
14
14
|
options: options?.map((option) => option.value) || [],
|
|
15
|
-
|
|
16
|
-
}, unchainedAPI, { skipInvalidation: true }, unchainedAPI.userId);
|
|
15
|
+
}, unchainedAPI, { skipInvalidation: true });
|
|
17
16
|
}
|
|
18
17
|
if (content) {
|
|
19
18
|
logger.debug('replace localized content for filter', content);
|
|
20
|
-
await upsertFilterContent({ content, filterId: _id
|
|
19
|
+
await upsertFilterContent({ content, filterId: _id }, unchainedAPI);
|
|
21
20
|
}
|
|
22
21
|
if (options) {
|
|
23
22
|
logger.debug('replace localized content for filter options', content);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/update.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AAEpE,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CACxC,OAAY,EACZ,EAAE,
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/update.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AAEpE,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CACxC,OAAY,EACZ,EAAE,MAAM,EAAmB,EAC3B,YAA2B;IAE3B,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE;QAC5D,MAAM,IAAI,KAAK,CAAC,oCAAoC,GAAG,EAAE,CAAC,CAAC;KAC5D;IAED,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,GAAG,aAAa,CAAC;IAE1D,IAAI,aAAa,EAAE;QACjB,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,aAAa,CAAC,CAAC;QACpD,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAC1B,GAAG,EACH;YACE,GAAG,UAAU;YACb,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;SACtD,EACD,YAAY,EACZ,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAC3B,CAAC;KACH;IAED,IAAI,OAAO,EAAE;QACX,MAAM,CAAC,KAAK,CAAC,sCAAsC,EAAE,OAAO,CAAC,CAAC;QAC9D,MAAM,mBAAmB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;KACrE;IAED,IAAI,OAAO,EAAE;QACX,MAAM,CAAC,KAAK,CAAC,8CAA8C,EAAE,OAAO,CAAC,CAAC;QACtE,MAAM,yBAAyB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;KAC3E;IAED,OAAO;QACL,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function upsertFilterContent({ content, filterId
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
export default function upsertFilterContent({ content, filterId }: {
|
|
3
3
|
content: any;
|
|
4
4
|
filterId: any;
|
|
5
|
-
|
|
6
|
-
}, unchainedAPI: Context): Promise<({
|
|
7
|
-
authorId: string;
|
|
5
|
+
}, unchainedAPI: UnchainedCore): Promise<({
|
|
8
6
|
filterId: string;
|
|
9
7
|
filterOptionValue?: string;
|
|
10
8
|
locale?: string;
|