@unchainedshop/platform 4.3.3 → 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 +149 -2
- package/lib/context/index.d.ts +1 -2
- package/lib/context/index.js +1 -2
- package/lib/context/setAccessToken.d.ts +1 -2
- package/lib/context/setAccessToken.js +0 -1
- package/lib/migrations/createMigrationRunner.d.ts +0 -1
- package/lib/migrations/createMigrationRunner.js +0 -3
- package/lib/migrations/migrationRepository.d.ts +1 -2
- package/lib/migrations/migrationRepository.js +1 -1
- package/lib/migrations/runMigrations.d.ts +2 -3
- package/lib/migrations/runMigrations.js +1 -2
- package/lib/platform-index.d.ts +4 -5
- package/lib/platform-index.js +4 -5
- package/lib/setup/setupAccounts.d.ts +1 -2
- package/lib/setup/setupAccounts.js +0 -1
- package/lib/setup/setupTemplates.d.ts +11 -11
- package/lib/setup/setupTemplates.js +16 -19
- package/lib/setup/setupUploadHandlers.d.ts +1 -2
- package/lib/setup/setupUploadHandlers.js +0 -1
- package/lib/setup/setupWorkqueue.d.ts +2 -3
- package/lib/setup/setupWorkqueue.js +1 -7
- package/lib/startPlatform.d.ts +6 -7
- package/lib/startPlatform.js +15 -16
- package/lib/templates/index.d.ts +8 -9
- package/lib/templates/index.js +8 -9
- package/lib/templates/order-parser/getOrderPositionsData.d.ts +2 -3
- package/lib/templates/order-parser/getOrderPositionsData.js +0 -1
- package/lib/templates/order-parser/getOrderSummaryData.d.ts +2 -3
- package/lib/templates/order-parser/getOrderSummaryData.js +0 -1
- package/lib/templates/order-parser/index.d.ts +4 -5
- package/lib/templates/order-parser/index.js +2 -3
- package/lib/templates/resolveAccountActionTemplate.d.ts +1 -2
- package/lib/templates/resolveAccountActionTemplate.js +0 -2
- package/lib/templates/resolveEnrollmentStatusTemplate.d.ts +1 -2
- package/lib/templates/resolveEnrollmentStatusTemplate.js +0 -1
- package/lib/templates/resolveErrorReportTemplate.d.ts +1 -2
- package/lib/templates/resolveErrorReportTemplate.js +0 -1
- package/lib/templates/resolveForwardDeliveryTemplate.d.ts +1 -2
- package/lib/templates/resolveForwardDeliveryTemplate.js +1 -2
- package/lib/templates/resolveOrderConfirmationTemplate.d.ts +1 -2
- package/lib/templates/resolveOrderConfirmationTemplate.js +1 -2
- package/lib/templates/resolveOrderRejectionTemplate.d.ts +1 -2
- package/lib/templates/resolveOrderRejectionTemplate.js +1 -2
- package/lib/templates/resolveQuotationStatusTemplate.d.ts +1 -2
- package/lib/templates/resolveQuotationStatusTemplate.js +0 -1
- package/package.json +17 -16
- package/lib/bulk-importer/createBulkImporter.d.ts +0 -20
- package/lib/bulk-importer/createBulkImporter.d.ts.map +0 -1
- package/lib/bulk-importer/createBulkImporter.js +0 -97
- package/lib/bulk-importer/createBulkImporter.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/create.d.ts +0 -11
- package/lib/bulk-importer/handlers/assortment/create.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/create.js +0 -60
- package/lib/bulk-importer/handlers/assortment/create.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/index.d.ts +0 -4
- package/lib/bulk-importer/handlers/assortment/index.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/index.js +0 -4
- package/lib/bulk-importer/handlers/assortment/index.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/remove.d.ts +0 -10
- package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/remove.js +0 -13
- package/lib/bulk-importer/handlers/assortment/remove.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/update.d.ts +0 -12
- package/lib/bulk-importer/handlers/assortment/update.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/update.js +0 -62
- package/lib/bulk-importer/handlers/assortment/update.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +0 -7
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +0 -37
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +0 -7
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +0 -32
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +0 -7
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +0 -37
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +0 -7
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js +0 -39
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +0 -1
- package/lib/bulk-importer/handlers/filter/create.d.ts +0 -11
- package/lib/bulk-importer/handlers/filter/create.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/filter/create.js +0 -54
- package/lib/bulk-importer/handlers/filter/create.js.map +0 -1
- package/lib/bulk-importer/handlers/filter/index.d.ts +0 -4
- package/lib/bulk-importer/handlers/filter/index.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/filter/index.js +0 -4
- package/lib/bulk-importer/handlers/filter/index.js.map +0 -1
- package/lib/bulk-importer/handlers/filter/remove.d.ts +0 -10
- package/lib/bulk-importer/handlers/filter/remove.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/filter/remove.js +0 -14
- package/lib/bulk-importer/handlers/filter/remove.js.map +0 -1
- package/lib/bulk-importer/handlers/filter/update.d.ts +0 -11
- package/lib/bulk-importer/handlers/filter/update.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/filter/update.js +0 -44
- package/lib/bulk-importer/handlers/filter/update.js.map +0 -1
- package/lib/bulk-importer/handlers/product/create.d.ts +0 -11
- package/lib/bulk-importer/handlers/product/create.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/create.js +0 -51
- package/lib/bulk-importer/handlers/product/create.js.map +0 -1
- package/lib/bulk-importer/handlers/product/index.d.ts +0 -4
- package/lib/bulk-importer/handlers/product/index.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/index.js +0 -4
- package/lib/bulk-importer/handlers/product/index.js.map +0 -1
- package/lib/bulk-importer/handlers/product/remove.d.ts +0 -10
- package/lib/bulk-importer/handlers/product/remove.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/remove.js +0 -13
- package/lib/bulk-importer/handlers/product/remove.js.map +0 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts +0 -3
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js +0 -16
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js.map +0 -1
- package/lib/bulk-importer/handlers/product/update.d.ts +0 -11
- package/lib/bulk-importer/handlers/product/update.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/update.js +0 -48
- package/lib/bulk-importer/handlers/product/update.js.map +0 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +0 -6
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.js +0 -45
- package/lib/bulk-importer/handlers/product/upsertMedia.js.map +0 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +0 -6
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.js +0 -42
- package/lib/bulk-importer/handlers/product/upsertVariations.js.map +0 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +0 -3
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js +0 -6
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +0 -1
- package/lib/bulk-importer/upsertAsset.d.ts +0 -8
- package/lib/bulk-importer/upsertAsset.d.ts.map +0 -1
- package/lib/bulk-importer/upsertAsset.js +0 -33
- package/lib/bulk-importer/upsertAsset.js.map +0 -1
- package/lib/context/index.d.ts.map +0 -1
- package/lib/context/index.js.map +0 -1
- package/lib/context/setAccessToken.d.ts.map +0 -1
- package/lib/context/setAccessToken.js.map +0 -1
- package/lib/context/withAccessToken.d.ts +0 -4
- package/lib/context/withAccessToken.d.ts.map +0 -1
- package/lib/context/withAccessToken.js +0 -42
- package/lib/context/withAccessToken.js.map +0 -1
- package/lib/migrations/createMigrationRunner.d.ts.map +0 -1
- package/lib/migrations/createMigrationRunner.js.map +0 -1
- package/lib/migrations/migrationRepository.d.ts.map +0 -1
- package/lib/migrations/migrationRepository.js.map +0 -1
- package/lib/migrations/runMigrations.d.ts.map +0 -1
- package/lib/migrations/runMigrations.js.map +0 -1
- package/lib/platform-index.d.ts.map +0 -1
- package/lib/platform-index.js.map +0 -1
- package/lib/setup/setupAccounts.d.ts.map +0 -1
- package/lib/setup/setupAccounts.js.map +0 -1
- package/lib/setup/setupCarts.d.ts +0 -8
- package/lib/setup/setupCarts.d.ts.map +0 -1
- package/lib/setup/setupCarts.js +0 -17
- package/lib/setup/setupCarts.js.map +0 -1
- package/lib/setup/setupTemplates.d.ts.map +0 -1
- package/lib/setup/setupTemplates.js.map +0 -1
- package/lib/setup/setupUploadHandlers.d.ts.map +0 -1
- package/lib/setup/setupUploadHandlers.js.map +0 -1
- package/lib/setup/setupWorkqueue.d.ts.map +0 -1
- package/lib/setup/setupWorkqueue.js.map +0 -1
- package/lib/startPlatform.d.ts.map +0 -1
- package/lib/startPlatform.js.map +0 -1
- package/lib/templates/index.d.ts.map +0 -1
- package/lib/templates/index.js.map +0 -1
- package/lib/templates/order-parser/formatAddress.d.ts +0 -3
- package/lib/templates/order-parser/formatAddress.d.ts.map +0 -1
- package/lib/templates/order-parser/formatAddress.js +0 -14
- package/lib/templates/order-parser/formatAddress.js.map +0 -1
- package/lib/templates/order-parser/formatPrice.d.ts +0 -6
- package/lib/templates/order-parser/formatPrice.d.ts.map +0 -1
- package/lib/templates/order-parser/formatPrice.js +0 -6
- package/lib/templates/order-parser/formatPrice.js.map +0 -1
- package/lib/templates/order-parser/getOrderPositionsData.d.ts.map +0 -1
- package/lib/templates/order-parser/getOrderPositionsData.js.map +0 -1
- package/lib/templates/order-parser/getOrderSummaryData.d.ts.map +0 -1
- package/lib/templates/order-parser/getOrderSummaryData.js.map +0 -1
- package/lib/templates/order-parser/index.d.ts.map +0 -1
- package/lib/templates/order-parser/index.js.map +0 -1
- package/lib/templates/resolveAccountActionTemplate.d.ts.map +0 -1
- package/lib/templates/resolveAccountActionTemplate.js.map +0 -1
- package/lib/templates/resolveEnrollmentStatusTemplate.d.ts.map +0 -1
- package/lib/templates/resolveEnrollmentStatusTemplate.js.map +0 -1
- package/lib/templates/resolveErrorReportTemplate.d.ts.map +0 -1
- package/lib/templates/resolveErrorReportTemplate.js.map +0 -1
- package/lib/templates/resolveForwardDeliveryTemplate.d.ts.map +0 -1
- package/lib/templates/resolveForwardDeliveryTemplate.js.map +0 -1
- package/lib/templates/resolveOrderConfirmationTemplate.d.ts.map +0 -1
- package/lib/templates/resolveOrderConfirmationTemplate.js.map +0 -1
- package/lib/templates/resolveOrderRejectionTemplate.d.ts.map +0 -1
- package/lib/templates/resolveOrderRejectionTemplate.js.map +0 -1
- package/lib/templates/resolveQuotationStatusTemplate.d.ts.map +0 -1
- package/lib/templates/resolveQuotationStatusTemplate.js.map +0 -1
- package/src/context/index.ts +0 -1
- package/src/context/setAccessToken.ts +0 -22
- package/src/migrations/createMigrationRunner.ts +0 -65
- package/src/migrations/migrationRepository.ts +0 -22
- package/src/migrations/runMigrations.ts +0 -68
- package/src/platform-index.ts +0 -19
- package/src/setup/setupAccounts.ts +0 -11
- package/src/setup/setupTemplates.ts +0 -67
- package/src/setup/setupUploadHandlers.ts +0 -22
- package/src/setup/setupWorkqueue.ts +0 -104
- package/src/startPlatform.ts +0 -128
- package/src/templates/index.ts +0 -9
- package/src/templates/order-parser/getOrderPositionsData.ts +0 -50
- package/src/templates/order-parser/getOrderSummaryData.ts +0 -91
- package/src/templates/order-parser/index.ts +0 -65
- package/src/templates/resolveAccountActionTemplate.ts +0 -127
- package/src/templates/resolveEnrollmentStatusTemplate.ts +0 -34
- package/src/templates/resolveErrorReportTemplate.ts +0 -47
- package/src/templates/resolveForwardDeliveryTemplate.ts +0 -42
- package/src/templates/resolveOrderConfirmationTemplate.ts +0 -40
- package/src/templates/resolveOrderRejectionTemplate.ts +0 -41
- package/src/templates/resolveQuotationStatusTemplate.ts +0 -45
- package/tests/platform-index.test.ts +0 -7
- package/tsconfig.json +0 -9
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
2
|
-
const upsert = async (assortmentFilter, { modules }) => {
|
|
3
|
-
if (!(await modules.filters.filterExists({
|
|
4
|
-
filterId: assortmentFilter.filterId,
|
|
5
|
-
}))) {
|
|
6
|
-
throw new Error(`Can't link non-existing filter ${assortmentFilter.filterId}`);
|
|
7
|
-
}
|
|
8
|
-
try {
|
|
9
|
-
const newAssortmentFilter = await modules.assortments.filters.create(assortmentFilter);
|
|
10
|
-
return newAssortmentFilter;
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return modules.assortments.filters.update(assortmentFilter._id, assortmentFilter);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
export default async ({ filters, assortmentId }, unchainedAPI) => {
|
|
17
|
-
const { modules } = unchainedAPI;
|
|
18
|
-
const assortmentFilterIds = await Promise.all(filters.map(async (filter) => {
|
|
19
|
-
const tags = convertTagsToLowerCase(filter?.tags);
|
|
20
|
-
const assortmentFilter = await upsert({
|
|
21
|
-
...filter,
|
|
22
|
-
tags,
|
|
23
|
-
assortmentId,
|
|
24
|
-
}, unchainedAPI);
|
|
25
|
-
return assortmentFilter._id;
|
|
26
|
-
}));
|
|
27
|
-
await modules.assortments.filters.deleteMany({
|
|
28
|
-
_id: { $nin: assortmentFilterIds },
|
|
29
|
-
assortmentId,
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=upsertAssortmentFilters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upsertAssortmentFilters.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,MAAM,oCAAoC,CAAC;AAExE,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,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,kCAAkC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjF,CAAC;IACD,IAAI,CAAC;QACH,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACvF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IACpF,CAAC;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 +0,0 @@
|
|
|
1
|
-
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
2
|
-
declare const _default: ({ products, assortmentId }: {
|
|
3
|
-
products: any;
|
|
4
|
-
assortmentId: any;
|
|
5
|
-
}, unchainedAPI: UnchainedCore) => Promise<void>;
|
|
6
|
-
export default _default;
|
|
7
|
-
//# sourceMappingURL=upsertAssortmentProducts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upsertAssortmentProducts.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;;;;iBAwBG,aAAa;AAA7E,wBAwBE"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
2
|
-
const upsert = async (assortmentProduct, unchainedAPI) => {
|
|
3
|
-
const { modules } = unchainedAPI;
|
|
4
|
-
if (!(await modules.products.productExists({
|
|
5
|
-
productId: assortmentProduct.productId,
|
|
6
|
-
}))) {
|
|
7
|
-
throw new Error(`Can't link non-existing product ${assortmentProduct.productId}`);
|
|
8
|
-
}
|
|
9
|
-
try {
|
|
10
|
-
const newAssortmentProduct = await modules.assortments.products.create(assortmentProduct, {
|
|
11
|
-
skipInvalidation: true,
|
|
12
|
-
});
|
|
13
|
-
return newAssortmentProduct;
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
return modules.assortments.products.update(assortmentProduct._id, assortmentProduct, {
|
|
17
|
-
skipInvalidation: true,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export default async ({ products, assortmentId }, unchainedAPI) => {
|
|
22
|
-
const { modules } = unchainedAPI;
|
|
23
|
-
const assortmentProductIds = await Promise.all(products.map(async (product) => {
|
|
24
|
-
const tags = convertTagsToLowerCase(product?.tags);
|
|
25
|
-
const assortmentProduct = await upsert({
|
|
26
|
-
...product,
|
|
27
|
-
tags,
|
|
28
|
-
assortmentId,
|
|
29
|
-
}, unchainedAPI);
|
|
30
|
-
return assortmentProduct._id;
|
|
31
|
-
}));
|
|
32
|
-
await modules.assortments.products.deleteMany({
|
|
33
|
-
_id: { $nin: assortmentProductIds },
|
|
34
|
-
assortmentId,
|
|
35
|
-
}, { skipInvalidation: true });
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=upsertAssortmentProducts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upsertAssortmentProducts.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,MAAM,oCAAoC,CAAC;AAExE,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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CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
2
|
-
declare const _default: ({ media, assortmentId }: {
|
|
3
|
-
media: any;
|
|
4
|
-
assortmentId: any;
|
|
5
|
-
}, unchainedAPI: UnchainedCore) => Promise<void>;
|
|
6
|
-
export default _default;
|
|
7
|
-
//# sourceMappingURL=upsertMedia.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upsertMedia.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertMedia.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;;;;iBAcA,aAAa;AAA1E,wBAuCE"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import upsertAsset from '../../upsertAsset.js';
|
|
2
|
-
const upsertMediaObject = async (media, unchainedAPI) => {
|
|
3
|
-
const { modules } = unchainedAPI;
|
|
4
|
-
try {
|
|
5
|
-
const assortmentMedia = await modules.assortments.media.create(media);
|
|
6
|
-
return assortmentMedia;
|
|
7
|
-
}
|
|
8
|
-
catch {
|
|
9
|
-
const { _id, ...mediaData } = media;
|
|
10
|
-
return modules.assortments.media.update(_id, mediaData);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
export default async ({ media, assortmentId }, unchainedAPI) => {
|
|
14
|
-
const { modules } = unchainedAPI;
|
|
15
|
-
const mediaObjects = await Promise.all(media.map(async ({ asset, content, ...mediaData }) => {
|
|
16
|
-
const file = await upsertAsset('assortment-media', { meta: { ...(asset.meta || {}), assortmentId }, ...asset }, unchainedAPI);
|
|
17
|
-
if (!file)
|
|
18
|
-
throw new Error(`Unable to create binary ${asset._id}`);
|
|
19
|
-
const mediaObject = await upsertMediaObject({
|
|
20
|
-
...mediaData,
|
|
21
|
-
assortmentId,
|
|
22
|
-
mediaId: file._id,
|
|
23
|
-
}, unchainedAPI);
|
|
24
|
-
if (!mediaObject)
|
|
25
|
-
throw new Error(`Unable to create media object ${mediaObject._id}`);
|
|
26
|
-
if (content) {
|
|
27
|
-
await modules.assortments.media.texts.updateMediaTexts(mediaObject._id, Object.entries(content).map(([locale, localizedData]) => ({
|
|
28
|
-
locale,
|
|
29
|
-
...localizedData,
|
|
30
|
-
})));
|
|
31
|
-
}
|
|
32
|
-
return mediaObject;
|
|
33
|
-
}));
|
|
34
|
-
await modules.assortments.media.deleteMediaFiles({
|
|
35
|
-
assortmentId,
|
|
36
|
-
excludedAssortmentMediaIds: mediaObjects.map((obj) => obj._id),
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=upsertMedia.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upsertMedia.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertMedia.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAE/C,MAAM,iBAAiB,GAAG,KAAK,EAAE,KAAK,EAAE,YAA2B,EAAE,EAAE;IACrE,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,OAAO,eAAe,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;QACpC,OAAO,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,KAAK,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,YAA2B,EAAE,EAAE;IAC5E,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,MAAM,YAAY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CAAC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
2
|
-
export default function createFilter(payload: any, { logger, createShouldUpsertIfIDExists }: {
|
|
3
|
-
logger: any;
|
|
4
|
-
createShouldUpsertIfIDExists: any;
|
|
5
|
-
}, unchainedAPI: UnchainedCore): Promise<{
|
|
6
|
-
entity: string;
|
|
7
|
-
operation: string;
|
|
8
|
-
_id: any;
|
|
9
|
-
success: boolean;
|
|
10
|
-
}>;
|
|
11
|
-
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,wBAA8B,YAAY,CACxC,OAAO,EAAE,GAAG,EACZ,EAAE,MAAM,EAAE,4BAA4B,EAAE;;;CAAA,EACxC,YAAY,EAAE,aAAa;;;;;GA6E5B"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export default async function createFilter(payload, { logger, createShouldUpsertIfIDExists }, unchainedAPI) {
|
|
2
|
-
const { modules } = unchainedAPI;
|
|
3
|
-
const { specification, _id } = payload;
|
|
4
|
-
if (!specification)
|
|
5
|
-
throw new Error(`Specification is required when creating new filter ${_id}`);
|
|
6
|
-
const { content, options, ...filterData } = specification;
|
|
7
|
-
if (!content)
|
|
8
|
-
throw new Error(`Localizable content is required when creating new filter${_id}`);
|
|
9
|
-
logger.debug('create filter object', specification);
|
|
10
|
-
try {
|
|
11
|
-
await unchainedAPI.modules.filters.create({
|
|
12
|
-
...filterData,
|
|
13
|
-
_id,
|
|
14
|
-
options: options?.map((option) => option.value) || [],
|
|
15
|
-
}, unchainedAPI, { skipInvalidation: true });
|
|
16
|
-
}
|
|
17
|
-
catch (e) {
|
|
18
|
-
if (!createShouldUpsertIfIDExists)
|
|
19
|
-
throw e;
|
|
20
|
-
logger.debug('entity already exists, falling back to update', specification);
|
|
21
|
-
await modules.filters.update(_id, {
|
|
22
|
-
...filterData,
|
|
23
|
-
options: options?.map((option) => option.value) || [],
|
|
24
|
-
}, unchainedAPI, { skipInvalidation: true });
|
|
25
|
-
}
|
|
26
|
-
if (!(await modules.filters.filterExists({ filterId: _id }))) {
|
|
27
|
-
throw new Error(`Can't upsert filter ${_id}`);
|
|
28
|
-
}
|
|
29
|
-
if (content) {
|
|
30
|
-
logger.debug('create localized content for filter', content);
|
|
31
|
-
await modules.filters.texts.updateTexts({ filterId: _id }, Object.entries(content).map(([locale, localizedData]) => {
|
|
32
|
-
return {
|
|
33
|
-
locale,
|
|
34
|
-
...localizedData,
|
|
35
|
-
};
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
if (options) {
|
|
39
|
-
logger.debug('create localized content for filter options', content);
|
|
40
|
-
await Promise.all(options.map(async ({ content: optionContent, value: optionValue }) => modules.filters.texts.updateTexts({ filterId: _id, filterOptionValue: optionValue }, Object.entries(optionContent).map(([locale, localizedData]) => {
|
|
41
|
-
return {
|
|
42
|
-
locale,
|
|
43
|
-
...localizedData,
|
|
44
|
-
};
|
|
45
|
-
}))));
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
entity: 'FILTER',
|
|
49
|
-
operation: 'create',
|
|
50
|
-
_id,
|
|
51
|
-
success: true,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=create.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/create.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CACxC,OAAY,EACZ,EAAE,MAAM,EAAE,4BAA4B,EAAE,EACxC,YAA2B;IAE3B,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,MAAM,EAA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AO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
2
|
-
export default function removeFilter(payload: any, { logger }: {
|
|
3
|
-
logger: any;
|
|
4
|
-
}, unchainedAPI: UnchainedCore): Promise<{
|
|
5
|
-
entity: string;
|
|
6
|
-
operation: string;
|
|
7
|
-
_id: any;
|
|
8
|
-
success: boolean;
|
|
9
|
-
}>;
|
|
10
|
-
//# sourceMappingURL=remove.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/remove.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,wBAA8B,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE;;CAAA,EAAE,YAAY,EAAE,aAAa;;;;;GAa/F"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default async function removeFilter(payload, { logger }, unchainedAPI) {
|
|
2
|
-
const { modules } = unchainedAPI;
|
|
3
|
-
const { _id } = payload;
|
|
4
|
-
logger.debug('remove filter');
|
|
5
|
-
await modules.assortments.filters.deleteMany({ filterId: _id });
|
|
6
|
-
await modules.filters.delete(_id);
|
|
7
|
-
return {
|
|
8
|
-
entity: 'FILTER',
|
|
9
|
-
operation: 'remove',
|
|
10
|
-
_id,
|
|
11
|
-
success: true,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=remove.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,11 +0,0 @@
|
|
|
1
|
-
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
2
|
-
export default function updateFilter(payload: any, { logger, updateShouldUpsertIfIDNotExists }: {
|
|
3
|
-
logger: any;
|
|
4
|
-
updateShouldUpsertIfIDNotExists: boolean;
|
|
5
|
-
}, unchainedAPI: UnchainedCore): Promise<{
|
|
6
|
-
entity: string;
|
|
7
|
-
operation: string;
|
|
8
|
-
_id: any;
|
|
9
|
-
success: boolean;
|
|
10
|
-
}>;
|
|
11
|
-
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,wBAA8B,YAAY,CACxC,OAAO,EAAE,GAAG,EACZ,EAAE,MAAM,EAAE,+BAA+B,EAAE,EAAE;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,+BAA+B,EAAE,OAAO,CAAA;CAAE,EACtG,YAAY,EAAE,aAAa;;;;;GA+D5B"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import createFilter from './create.js';
|
|
2
|
-
export default async function updateFilter(payload, { logger, updateShouldUpsertIfIDNotExists }, unchainedAPI) {
|
|
3
|
-
const { modules } = unchainedAPI;
|
|
4
|
-
const { specification, _id } = payload;
|
|
5
|
-
if (!(await modules.filters.filterExists({ filterId: _id }))) {
|
|
6
|
-
if (updateShouldUpsertIfIDNotExists) {
|
|
7
|
-
return createFilter(payload, { logger, createShouldUpsertIfIDExists: false }, unchainedAPI);
|
|
8
|
-
}
|
|
9
|
-
throw new Error(`Can't update non-existing filter ${_id}`);
|
|
10
|
-
}
|
|
11
|
-
const { content, options, ...filterData } = specification;
|
|
12
|
-
if (specification) {
|
|
13
|
-
logger.debug('update filter object', specification);
|
|
14
|
-
await modules.filters.update(_id, {
|
|
15
|
-
...filterData,
|
|
16
|
-
options: options?.map((option) => option.value) || [],
|
|
17
|
-
}, unchainedAPI, { skipInvalidation: true });
|
|
18
|
-
}
|
|
19
|
-
if (content) {
|
|
20
|
-
logger.debug('replace localized content for filter', content);
|
|
21
|
-
await modules.filters.texts.updateTexts({ filterId: _id }, Object.entries(content).map(([locale, localizedData]) => {
|
|
22
|
-
return {
|
|
23
|
-
locale,
|
|
24
|
-
...localizedData,
|
|
25
|
-
};
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
if (options) {
|
|
29
|
-
logger.debug('replace localized content for filter options', content);
|
|
30
|
-
await Promise.all(options.map(async ({ content: optionContent, value: optionValue }) => modules.filters.texts.updateTexts({ filterId: _id, filterOptionValue: optionValue }, Object.entries(optionContent).map(([locale, localizedData]) => {
|
|
31
|
-
return {
|
|
32
|
-
locale,
|
|
33
|
-
...localizedData,
|
|
34
|
-
};
|
|
35
|
-
}))));
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
entity: 'FILTER',
|
|
39
|
-
operation: 'update',
|
|
40
|
-
_id,
|
|
41
|
-
success: true,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=update.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/filter/update.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,aAAa,CAAC;AAEvC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CACxC,OAAY,EACZ,EAAE,MAAM,EAAE,+BAA+B,EAA6D,EACtG,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,CAAC;QAC7D,IAAI,+BAA+B,EAAE,CAAC;YACpC,OAAO,YAAY,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,4BAA4B,EAAE,KAAK,EAAE,EAAE,YAAY,CAAC,CAAC;QAC9F,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,GAAG,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,GAAG,aAAa,CAAC;IAE1D,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,CAAC,KAAK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CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
2
|
-
export default function createProduct(payload: any, { logger, createShouldUpsertIfIDExists }: {
|
|
3
|
-
logger: any;
|
|
4
|
-
createShouldUpsertIfIDExists: any;
|
|
5
|
-
}, unchainedAPI: UnchainedCore): Promise<{
|
|
6
|
-
entity: string;
|
|
7
|
-
operation: string;
|
|
8
|
-
_id: any;
|
|
9
|
-
success: boolean;
|
|
10
|
-
}>;
|
|
11
|
-
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/product/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAK7D,wBAA8B,aAAa,CACzC,OAAO,EAAE,GAAG,EACZ,EAAE,MAAM,EAAE,4BAA4B,EAAE;;;CAAA,EACxC,YAAY,EAAE,aAAa;;;;;GA0D5B"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import upsertVariations from './upsertVariations.js';
|
|
2
|
-
import upsertMedia from './upsertMedia.js';
|
|
3
|
-
import transformSpecificationToProductStructure from './transformSpecificationToProductStructure.js';
|
|
4
|
-
export default async function createProduct(payload, { logger, createShouldUpsertIfIDExists }, unchainedAPI) {
|
|
5
|
-
const { modules } = unchainedAPI;
|
|
6
|
-
const { specification, media, variations, _id } = payload;
|
|
7
|
-
if (!specification)
|
|
8
|
-
throw new Error(`Specification is required when creating new product ${_id}`);
|
|
9
|
-
if (!specification.content)
|
|
10
|
-
throw new Error(`Content is required when creating new product ${_id}`);
|
|
11
|
-
const productData = transformSpecificationToProductStructure(specification);
|
|
12
|
-
logger.debug('create product object', productData);
|
|
13
|
-
try {
|
|
14
|
-
await modules.products.create({
|
|
15
|
-
...productData,
|
|
16
|
-
_id,
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
if (!createShouldUpsertIfIDExists)
|
|
21
|
-
throw e;
|
|
22
|
-
logger.debug('entity already exists, falling back to update', specification);
|
|
23
|
-
await modules.products.update(_id, {
|
|
24
|
-
...productData,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
if (!(await modules.products.productExists({ productId: _id }))) {
|
|
28
|
-
throw new Error(`Can't create product ${_id}, fields missing?`);
|
|
29
|
-
}
|
|
30
|
-
logger.debug('create localized content for product', specification.content);
|
|
31
|
-
await modules.products.texts.updateTexts(_id, Object.entries(specification.content).map(([locale, localizedData]) => {
|
|
32
|
-
return {
|
|
33
|
-
locale,
|
|
34
|
-
...localizedData,
|
|
35
|
-
};
|
|
36
|
-
}));
|
|
37
|
-
logger.debug('create product variations', variations);
|
|
38
|
-
await upsertVariations({
|
|
39
|
-
variations: variations || [],
|
|
40
|
-
productId: _id,
|
|
41
|
-
}, unchainedAPI);
|
|
42
|
-
logger.debug('create product media', media);
|
|
43
|
-
await upsertMedia({ media: media || [], productId: _id }, unchainedAPI);
|
|
44
|
-
return {
|
|
45
|
-
entity: 'PRODUCT',
|
|
46
|
-
operation: 'create',
|
|
47
|
-
_id,
|
|
48
|
-
success: true,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=create.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/product/create.ts"],"names":[],"mappings":"AACA,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,wCAAwC,MAAM,+CAA+C,CAAC;AAErG,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAA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M,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,aAAa,CAAgB,EAAE,EAAE;QACnF,OAAO;YACL,MAAM;YACN,GAAG,aAAa;SACjB,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,UAAU,CAAC,CAAC;IACtD,MAAM,gBAAgB,CACpB;QACE,UAAU,EAAE,UAAU,IAAI,EAAE;QAC5B,SAAS,EAAE,GAAG;KACf,EACD,YAAY,CACb,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;IAC5C,MAAM,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;IAExE,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/product/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/product/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
2
|
-
export default function removeProduct(payload: any, { logger }: {
|
|
3
|
-
logger: any;
|
|
4
|
-
}, unchainedAPI: UnchainedCore): Promise<{
|
|
5
|
-
entity: string;
|
|
6
|
-
operation: string;
|
|
7
|
-
_id: any;
|
|
8
|
-
success: boolean;
|
|
9
|
-
}>;
|
|
10
|
-
//# sourceMappingURL=remove.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/product/remove.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,wBAA8B,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE;;CAAA,EAAE,YAAY,EAAE,aAAa;;;;;GAahG"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export default async function removeProduct(payload, { logger }, unchainedAPI) {
|
|
2
|
-
const { services } = unchainedAPI;
|
|
3
|
-
const { _id } = payload;
|
|
4
|
-
logger.debug(`remove product ${_id}`);
|
|
5
|
-
await services.products.removeProduct({ productId: _id }, unchainedAPI);
|
|
6
|
-
return {
|
|
7
|
-
entity: 'PRODUCT',
|
|
8
|
-
operation: 'remove',
|
|
9
|
-
_id,
|
|
10
|
-
success: true,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=remove.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/product/remove.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAAa,CAAC,OAAY,EAAE,EAAE,MAAM,EAAE,EAAE,YAA2B;IAC/F,MAAM,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAC;IAClC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,MAAM,CAAC,KAAK,CAAC,kBAAkB,GAAG,EAAE,CAAC,CAAC;IAEtC,MAAM,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;IAExE,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformSpecificationToProductStructure.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/product/transformSpecificationToProductStructure.ts"],"names":[],"mappings":";AAEA,wBAmBE"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
2
|
-
export default (specification) => {
|
|
3
|
-
const { variationResolvers: assignments, content, // eslint-disable-line
|
|
4
|
-
warehousing: warehousingEmbeddedSupply, ...productData } = specification;
|
|
5
|
-
const { dimensions: supply, ...warehousing } = warehousingEmbeddedSupply || {};
|
|
6
|
-
const tags = convertTagsToLowerCase(productData?.tags);
|
|
7
|
-
const proxy = assignments ? { assignments } : undefined;
|
|
8
|
-
return {
|
|
9
|
-
...productData,
|
|
10
|
-
tags,
|
|
11
|
-
warehousing,
|
|
12
|
-
supply,
|
|
13
|
-
proxy,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=transformSpecificationToProductStructure.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformSpecificationToProductStructure.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/product/transformSpecificationToProductStructure.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,MAAM,oCAAoC,CAAC;AAExE,eAAe,CAAC,aAAa,EAAE,EAAE;IAC/B,MAAM,EACJ,kBAAkB,EAAE,WAAW,EAC/B,OAAO,EAAE,sBAAsB;IAC/B,WAAW,EAAE,yBAAyB,EACtC,GAAG,WAAW,EACf,GAAG,aAAa,CAAC;IAElB,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,GAAG,yBAAyB,IAAI,EAAE,CAAC;IAC/E,MAAM,IAAI,GAAG,sBAAsB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAExD,OAAO;QACL,GAAG,WAAW;QACd,IAAI;QACJ,WAAW;QACX,MAAM;QACN,KAAK;KACN,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
2
|
-
export default function updateProduct(payload: any, { logger, updateShouldUpsertIfIDNotExists }: {
|
|
3
|
-
logger: any;
|
|
4
|
-
updateShouldUpsertIfIDNotExists: any;
|
|
5
|
-
}, unchainedAPI: UnchainedCore): Promise<{
|
|
6
|
-
entity: string;
|
|
7
|
-
operation: string;
|
|
8
|
-
_id: any;
|
|
9
|
-
success: boolean;
|
|
10
|
-
}>;
|
|
11
|
-
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/product/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAM7D,wBAA8B,aAAa,CACzC,OAAO,EAAE,GAAG,EACZ,EAAE,MAAM,EAAE,+BAA+B,EAAE;;;CAAA,EAC3C,YAAY,EAAE,aAAa;;;;;GAuD5B"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import upsertVariations from './upsertVariations.js';
|
|
2
|
-
import upsertMedia from './upsertMedia.js';
|
|
3
|
-
import transformSpecificationToProductStructure from './transformSpecificationToProductStructure.js';
|
|
4
|
-
import createProduct from './create.js';
|
|
5
|
-
export default async function updateProduct(payload, { logger, updateShouldUpsertIfIDNotExists }, unchainedAPI) {
|
|
6
|
-
const { modules } = unchainedAPI;
|
|
7
|
-
const { specification, media, variations, _id } = payload;
|
|
8
|
-
if (!(await modules.products.productExists({ productId: _id }))) {
|
|
9
|
-
if (updateShouldUpsertIfIDNotExists) {
|
|
10
|
-
return createProduct(payload, { logger, createShouldUpsertIfIDExists: false }, unchainedAPI);
|
|
11
|
-
}
|
|
12
|
-
throw new Error(`Can't update non-existing product ${_id}`);
|
|
13
|
-
}
|
|
14
|
-
if (specification) {
|
|
15
|
-
const productData = transformSpecificationToProductStructure(specification);
|
|
16
|
-
logger.debug('update product object', productData);
|
|
17
|
-
await modules.products.update(_id, {
|
|
18
|
-
...productData,
|
|
19
|
-
});
|
|
20
|
-
if (specification.content) {
|
|
21
|
-
logger.debug('replace localized content for product', specification.content);
|
|
22
|
-
await modules.products.texts.updateTexts(_id, Object.entries(specification.content).map(([locale, localizedData]) => {
|
|
23
|
-
return {
|
|
24
|
-
locale,
|
|
25
|
-
...localizedData,
|
|
26
|
-
};
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (variations) {
|
|
31
|
-
logger.debug('replace variations', variations);
|
|
32
|
-
await upsertVariations({
|
|
33
|
-
variations: variations || [],
|
|
34
|
-
productId: _id,
|
|
35
|
-
}, unchainedAPI);
|
|
36
|
-
}
|
|
37
|
-
if (media) {
|
|
38
|
-
logger.debug('replace product media', media);
|
|
39
|
-
await upsertMedia({ media, productId: _id }, unchainedAPI);
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
entity: 'PRODUCT',
|
|
43
|
-
operation: 'update',
|
|
44
|
-
_id,
|
|
45
|
-
success: true,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=update.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/product/update.ts"],"names":[],"mappings":"AACA,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,wCAAwC,MAAM,+CAA+C,CAAC;AACrG,OAAO,aAAa,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAAa,CACzC,OAAY,EACZ,EAAE,MAAM,EAAE,+BAA+B,EAAE,EAC3C,YAA2B;IAE3B,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAE1D,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;QAChE,IAAI,+BAA+B,EAAE,CAAC;YACpC,OAAO,aAAa,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,4BAA4B,EAAE,KAAK,EAAE,EAAE,YAAY,CAAC,CAAC;QAC/F,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,WAAW,GAAG,wCAAwC,CAAC,aAAa,CAAC,CAAC;QAC5E,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,WAAW,CAAC,CAAC;QACnD,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE;YACjC,GAAG,WAAW;SACf,CAAC,CAAC;QAEH,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC;YAC1B,MAAM,C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