@unchainedshop/platform 2.0.0-beta6 → 2.0.0-beta8
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/lib/bulk-importer/createBulkImporter.js +1 -1
- package/lib/bulk-importer/createBulkImporter.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/create.js +6 -3
- package/lib/bulk-importer/handlers/assortment/create.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/remove.js +2 -2
- package/lib/bulk-importer/handlers/assortment/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/update.js +3 -5
- package/lib/bulk-importer/handlers/assortment/update.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +2 -2
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentContent.js +0 -3
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentContent.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +2 -2
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js +2 -31
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/create.js +7 -5
- package/lib/bulk-importer/handlers/filter/create.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/remove.js +2 -2
- package/lib/bulk-importer/handlers/filter/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/update.js +12 -13
- package/lib/bulk-importer/handlers/filter/update.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/upsertFilterContent.d.ts +2 -2
- package/lib/bulk-importer/handlers/filter/upsertFilterContent.js +2 -2
- 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.js +3 -0
- package/lib/bulk-importer/handlers/product/create.js.map +1 -1
- package/lib/bulk-importer/handlers/product/remove.js +3 -3
- package/lib/bulk-importer/handlers/product/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/product/update.js +3 -5
- package/lib/bulk-importer/handlers/product/update.js.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.js +2 -31
- package/lib/bulk-importer/handlers/product/upsertMedia.js.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertProductContent.js +0 -3
- package/lib/bulk-importer/handlers/product/upsertProductContent.js.map +1 -1
- package/lib/bulk-importer/upsertAsset.d.ts +7 -0
- package/lib/bulk-importer/upsertAsset.js +34 -0
- package/lib/bulk-importer/upsertAsset.js.map +1 -0
- package/lib/context/setAccessToken.d.ts +2 -2
- package/lib/context/setAccessToken.js.map +1 -1
- package/lib/context/withAccessToken.d.ts +2 -1
- package/lib/context/withAccessToken.js.map +1 -1
- package/lib/platform-index.d.ts +4 -0
- package/lib/platform-index.js +3 -0
- package/lib/platform-index.js.map +1 -1
- package/lib/setup/setupAccounts.js +0 -2
- package/lib/setup/setupAccounts.js.map +1 -1
- package/lib/startPlatform.d.ts +6 -2
- package/lib/startPlatform.js +3 -5
- package/lib/startPlatform.js.map +1 -1
- package/lib/templates/resolveQuotationStatusTemplate.js +1 -1
- package/lib/templates/resolveQuotationStatusTemplate.js.map +1 -1
- package/lib/templates/utils/getOrderAttachmentsData.js +3 -10
- package/lib/templates/utils/getOrderAttachmentsData.js.map +1 -1
- package/package.json +14 -14
- package/src/bulk-importer/createBulkImporter.ts +1 -1
- package/src/bulk-importer/handlers/assortment/create.ts +7 -3
- package/src/bulk-importer/handlers/assortment/remove.ts +2 -2
- package/src/bulk-importer/handlers/assortment/update.ts +4 -7
- package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +1 -2
- package/src/bulk-importer/handlers/assortment/upsertAssortmentContent.ts +0 -3
- package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +1 -2
- package/src/bulk-importer/handlers/assortment/upsertMedia.ts +2 -38
- package/src/bulk-importer/handlers/filter/create.ts +8 -5
- package/src/bulk-importer/handlers/filter/remove.ts +2 -2
- package/src/bulk-importer/handlers/filter/update.ts +18 -17
- package/src/bulk-importer/handlers/filter/upsertFilterContent.ts +5 -2
- package/src/bulk-importer/handlers/filter/upsertFilterOptionContent.ts +2 -2
- package/src/bulk-importer/handlers/product/create.ts +4 -0
- package/src/bulk-importer/handlers/product/remove.ts +3 -3
- package/src/bulk-importer/handlers/product/update.ts +4 -6
- package/src/bulk-importer/handlers/product/upsertMedia.ts +2 -38
- package/src/bulk-importer/handlers/product/upsertProductContent.ts +0 -3
- package/src/bulk-importer/upsertAsset.ts +45 -0
- package/src/context/setAccessToken.ts +2 -2
- package/src/context/withAccessToken.ts +2 -1
- package/src/platform-index.ts +6 -0
- package/src/setup/setupAccounts.ts +0 -2
- package/src/startPlatform.ts +8 -8
- package/src/templates/resolveQuotationStatusTemplate.ts +2 -2
- package/src/templates/utils/getOrderAttachmentsData.ts +6 -13
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const upsertAsset = async (directoryName, asset, unchainedAPI) => {
|
|
2
|
+
const { modules, services, userId } = unchainedAPI;
|
|
3
|
+
const { _id: fileId, fileName, url, meta, headers, ...assetData } = asset;
|
|
4
|
+
try {
|
|
5
|
+
const existingFile = fileId && (await modules.files.findFile({ fileId }));
|
|
6
|
+
if (existingFile) {
|
|
7
|
+
const newMeta = { ...meta, fileId };
|
|
8
|
+
if (JSON.stringify(newMeta) === JSON.stringify(existingFile.meta)) {
|
|
9
|
+
return existingFile;
|
|
10
|
+
}
|
|
11
|
+
await modules.files.update(fileId, { meta: newMeta, ...assetData }, userId);
|
|
12
|
+
const updatedFile = await modules.files.findFile({ fileId });
|
|
13
|
+
return updatedFile;
|
|
14
|
+
}
|
|
15
|
+
const assetObject = await services.files.uploadFileFromURL({
|
|
16
|
+
directoryName,
|
|
17
|
+
fileInput: {
|
|
18
|
+
fileLink: url,
|
|
19
|
+
fileName,
|
|
20
|
+
headers,
|
|
21
|
+
},
|
|
22
|
+
meta: { ...meta, fileId },
|
|
23
|
+
userId,
|
|
24
|
+
}, unchainedAPI);
|
|
25
|
+
if (!assetObject)
|
|
26
|
+
throw new Error('Media not created');
|
|
27
|
+
return assetObject;
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export default upsertAsset;
|
|
34
|
+
//# sourceMappingURL=upsertAsset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upsertAsset.js","sourceRoot":"","sources":["../../src/bulk-importer/upsertAsset.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,GAAG,KAAK,EACvB,aAAqB,EACrB,KAAqE,EACrE,YAAqB,EACrB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC;IACnD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAE1E,IAAI;QACF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC1E,IAAI,YAAY,EAAE;YAChB,MAAM,OAAO,GAAG,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;YACpC,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;gBACjE,OAAO,YAAY,CAAC;aACrB;YACD,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;YAC5E,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7D,OAAO,WAAW,CAAC;SACpB;QAED,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CACxD;YACE,aAAa;YACb,SAAS,EAAE;gBACT,QAAQ,EAAE,GAAG;gBACb,QAAQ;gBACR,OAAO;aACR;YACD,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE;YACzB,MAAM;SACP,EACD,YAAY,CACb,CAAC;QAEF,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvD,OAAO,WAAW,CAAC;KACpB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,IAAI,CAAC;KACb;AACH,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: (unchainedAPI:
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
declare const _default: (unchainedAPI: UnchainedCore, username: string, secret: string) => Promise<void>;
|
|
3
3
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setAccessToken.js","sourceRoot":"","sources":["../../src/context/setAccessToken.ts"],"names":[],"mappings":"AAEA,eAAe,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"setAccessToken.js","sourceRoot":"","sources":["../../src/context/setAccessToken.ts"],"names":[],"mappings":"AAEA,eAAe,KAAK,EAAE,YAA2B,EAAE,QAAgB,EAAE,MAAc,EAAiB,EAAE;IACpG,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CACzC,EAAE,QAAQ,EAAE,EACZ;QACE,IAAI,EAAE;YACJ,gBAAgB,EAAE;gBAChB,MAAM;aACP;SACF;KACK,EACR,EAAE,CACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withAccessToken.js","sourceRoot":"","sources":["../../src/context/withAccessToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"withAccessToken.js","sourceRoot":"","sources":["../../src/context/withAccessToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,MAAM,MAAM,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAAC;AAElD,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;AAE3C,eAAe,CAAC,KAAgC,eAAe,EAAO,EAAE;IACtE,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,EAAE;QAC1C,MAAM,gBAAgB,GAAG,MAAM,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAC1D,MAAM,UAAU,GAAG;YACjB,MAAM,EAAE,gBAAgB,CAAC,MAAM;YAC/B,IAAI,EAAE,gBAAgB,CAAC,IAAI;SAC5B,CAAC;QACF,IAAI,CAAC,gBAAgB,CAAC,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE;YAChE,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtE,IAAI,IAAI,KAAK,QAAQ,IAAI,SAAS,EAAE;gBAClC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAChD,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;oBACzD,QAAQ;iBACT,CAAC,CAAC;gBACH,IAAI,MAAM,IAAI,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EAAE;oBACrD,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;oBAC7B,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;iBACxB;qBAAM;oBACL,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;iBACnC;aACF;SACF;QACD,OAAO,EAAE,CAAC;YACR,GAAG,gBAAgB;YACnB,GAAG,UAAU;SACd,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/platform-index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export * from './startPlatform';
|
|
2
2
|
export * from './context';
|
|
3
|
+
declare const connectPlatformToExpress4: (expressApp: import("express").Express, { apolloGraphQLServer }: {
|
|
4
|
+
apolloGraphQLServer: import("@apollo/server").ApolloServer<import("@apollo/server").BaseContext>;
|
|
5
|
+
}) => void;
|
|
6
|
+
export { connectPlatformToExpress4 };
|
package/lib/platform-index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-index.js","sourceRoot":"","sources":["../src/platform-index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"platform-index.js","sourceRoot":"","sources":["../src/platform-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAE1B,MAAM,yBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -31,10 +31,8 @@ export const setupAccounts = (unchainedAPI) => {
|
|
|
31
31
|
const guestUserId = await unchainedAPI.modules.accounts.createUser({
|
|
32
32
|
email: params.email || `${guestname}@unchained.local`,
|
|
33
33
|
guest: true,
|
|
34
|
-
profile: {},
|
|
35
34
|
password: null,
|
|
36
35
|
initialPassword: true,
|
|
37
|
-
lastBillingAddress: {},
|
|
38
36
|
}, {});
|
|
39
37
|
return unchainedAPI.modules.users.findUserById(guestUserId);
|
|
40
38
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupAccounts.js","sourceRoot":"","sources":["../../src/setup/setupAccounts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,YAA2B,EAAE,EAAE;IAC3D,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAEzE,cAAc,CAAC,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC;IAElD,cAAc,CAAC,OAAO,CAAC,WAAW,GAAG,CACnC,EAAU,EACV,KAAa,EACb,IAA2B,EAC3B,YAAoB,EACpB,EAAE;QACF,OAAO;YACL,QAAQ,EAAE,gBAAgB;YAC1B,cAAc,EAAE,EAAE;YAClB,MAAM,EAAE,YAAY;YACpB,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG;YAC3B,KAAK;YACL,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,YAAY,KAAK,cAAc;SAC/D,CAAC;IACJ,CAAC,CAAC;IAEF,cAAc,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,KAAU,EAAE,EAAE;QAC/C,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACxB,IAAI,KAAK,CAAC,aAAa;YAAE,OAAO,IAAI,CA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,SAAS,CAAC,gBAAgB,CACpD;gBACE,QAAQ,EAAE,eAAe;gBACzB,MAAM,EAAE,IAAI;gBACZ,WAAW,EAAE,gBAAgB,CAAC,qBAAqB;gBACnD,cAAc;aACf,EACD,YAAY,CACb,CAAC;SACH;QAED,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CACjD;YACE,IAAI;YACJ,WAAW,EAAE,cAAc;SAC5B,EACD,YAAY,CACb,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,cAAc,CAAC,EAAE,CAAC,sBAAsB,EAAE,KAAK,EAAE,IAAU,EAAE,EAAE;QAC7D,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,cAAc,CAAC,EAAE,CAAC,uBAAuB,EAAE,KAAK,EAAE,IAAU,EAAE,EAAE;QAC9D,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,cAAc,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAuC,EAAE,EAAE;QACnF,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE;YACnD,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAClE;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
|
package/lib/startPlatform.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { PlatformOptions, MessageTypes } from '@unchainedshop/types/platform';
|
|
2
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
3
|
export { MessageTypes };
|
|
3
|
-
export declare const queueWorkers: any
|
|
4
|
-
export declare const startPlatform: ({ modules, services, typeDefs, resolvers, options, rolesOptions,
|
|
4
|
+
export declare const queueWorkers: Array<any>;
|
|
5
|
+
export declare const startPlatform: ({ modules, services, typeDefs, resolvers, options, rolesOptions, bulkImporter: bulkImporterOptions, schema, plugins, cache, workQueueOptions, context, introspection, playground, tracing, cacheControl, }: PlatformOptions) => Promise<{
|
|
6
|
+
unchainedAPI: UnchainedCore;
|
|
7
|
+
apolloGraphQLServer: any;
|
|
8
|
+
}>;
|
package/lib/startPlatform.js
CHANGED
|
@@ -30,7 +30,7 @@ const checkWorkQueueEnabled = (options) => {
|
|
|
30
30
|
return !UNCHAINED_DISABLE_WORKER;
|
|
31
31
|
};
|
|
32
32
|
export const queueWorkers = [];
|
|
33
|
-
export const startPlatform = async ({ modules = {}, services = {}, typeDefs = [], resolvers = [], options = {}, rolesOptions = {},
|
|
33
|
+
export const startPlatform = async ({ modules = {}, services = {}, typeDefs = [], resolvers = [], options = {}, rolesOptions = {}, bulkImporter: bulkImporterOptions, schema, plugins, cache, workQueueOptions, context, introspection, playground, tracing, cacheControl, }) => {
|
|
34
34
|
exitOnMissingEnvironmentVariables();
|
|
35
35
|
// Configure database
|
|
36
36
|
const db = await initDb();
|
|
@@ -62,20 +62,18 @@ export const startPlatform = async ({ modules = {}, services = {}, typeDefs = []
|
|
|
62
62
|
...generateRoleActionTypeDefs(),
|
|
63
63
|
];
|
|
64
64
|
// Start the graphQL server
|
|
65
|
-
startAPIServer({
|
|
65
|
+
const apolloGraphQLServer = await startAPIServer({
|
|
66
66
|
unchainedAPI,
|
|
67
67
|
roles: configuredRoles,
|
|
68
68
|
typeDefs: [...generatedTypeDefs, ...typeDefs],
|
|
69
69
|
resolvers,
|
|
70
70
|
schema,
|
|
71
71
|
plugins,
|
|
72
|
-
expressApp,
|
|
73
72
|
cache,
|
|
74
73
|
context,
|
|
75
74
|
introspection,
|
|
76
75
|
playground,
|
|
77
76
|
tracing,
|
|
78
|
-
corsOrigins,
|
|
79
77
|
cacheControl,
|
|
80
78
|
});
|
|
81
79
|
// Setup work queues for scheduled work
|
|
@@ -88,6 +86,6 @@ export const startPlatform = async ({ modules = {}, services = {}, typeDefs = []
|
|
|
88
86
|
if (!options.filters?.skipInvalidationOnStartup) {
|
|
89
87
|
setImmediate(() => unchainedAPI.modules.filters.invalidateCache({}, unchainedAPI));
|
|
90
88
|
}
|
|
91
|
-
return unchainedAPI;
|
|
89
|
+
return { unchainedAPI, apolloGraphQLServer };
|
|
92
90
|
};
|
|
93
91
|
//# sourceMappingURL=startPlatform.js.map
|
package/lib/startPlatform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startPlatform.js","sourceRoot":"","sources":["../src/startPlatform.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"startPlatform.js","sourceRoot":"","sources":["../src/startPlatform.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3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B,GAAG,MAAM,cAAc,CAAC;QAC/C,YAAY;QACZ,KAAK,EAAE,eAAe;QACtB,QAAQ,EAAE,CAAC,GAAG,iBAAiB,EAAE,GAAG,QAAQ,CAAC;QAC7C,SAAS;QACT,MAAM;QACN,OAAO;QACP,KAAK;QACL,OAAO;QACP,aAAa;QACb,UAAU;QACV,OAAO;QACP,YAAY;KACb,CAAC,CAAC;IAEH,uCAAuC;IACvC,IAAI,kBAAkB,EAAE;QACtB,MAAM,QAAQ,GAAG,cAAc,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;QAChE,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1D,MAAM,UAAU,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;KAClD;IAED,qBAAqB;IACrB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,yBAAyB,EAAE;QAC/C,YAAY,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC;KACpF;IAED,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAC/C,CAAC,CAAC"}
|
|
@@ -11,7 +11,7 @@ const textTemplate = `
|
|
|
11
11
|
export const resolveQuotationStatusTemplate = async ({ quotationId, locale }, { modules }) => {
|
|
12
12
|
const quotation = await modules.quotations.findQuotation({ quotationId });
|
|
13
13
|
const user = await modules.users.findUserById(quotation.userId);
|
|
14
|
-
const attachments = (await modules.files.
|
|
14
|
+
const attachments = (await modules.files.findFiles({ 'meta.quotationId': quotation._id, 'meta.type': 'PROPOSAL' }, { sort: { 'meta.date': -1 } }))
|
|
15
15
|
.filter(Boolean)
|
|
16
16
|
.map((file) => ({
|
|
17
17
|
filename: `${quotation.quotationNumber}_${file.name}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveQuotationStatusTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveQuotationStatusTemplate.ts"],"names":[],"mappings":"AAEA,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE1E,MAAM,YAAY,GAAG;;;;;;;;CAQpB,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAqB,KAAK,EACnE,EAAE,WAAW,EAAE,MAAM,EAAE,EACvB,EAAE,OAAO,EAAE,EACX,EAAE;IACF,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,CAClB,MAAM,OAAO,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"resolveQuotationStatusTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveQuotationStatusTemplate.ts"],"names":[],"mappings":"AAEA,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE1E,MAAM,YAAY,GAAG;;;;;;;;CAQpB,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAqB,KAAK,EACnE,EAAE,WAAW,EAAE,MAAM,EAAE,EACvB,EAAE,OAAO,EAAE,EACX,EAAE;IACF,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,CAClB,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAC3B,EAAE,kBAAkB,EAAE,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,EAC9D,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAC9B,CACF;SACE,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACd,QAAQ,EAAE,GAAG,SAAS,CAAC,eAAe,IAAI,IAAI,CAAC,IAAI,EAAE;QACrD,IAAI,EAAE,IAAI,CAAC,GAAG;KACf,CAAC,CAAC,CAAC;IAEN,MAAM,OAAO,GAAG,GAAG,kBAAkB,yBAAyB,SAAS,CAAC,eAAe,EAAE,CAAC;IAE1F,MAAM,IAAI,GAAG;QACX,MAAM;QACN,SAAS;QACT,OAAO;QACP,GAAG,EAAE,GAAG,iBAAiB,kBAAkB,SAAS,CAAC,GAAG,EAAE;KAC3D,CAAC;IAEF,OAAO;QACL;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,UAAU;gBAChB,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO;gBAC7C,OAAO;gBACP,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC;gBACxD,WAAW;aACZ;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
export const getOrderAttachmentsData = async (order, params, { modules }) => {
|
|
2
|
-
const orderId = order._id;
|
|
3
2
|
const attachments = [];
|
|
4
|
-
const orderFiles = await modules.files.
|
|
5
|
-
meta: { orderId: order._id, type: params.fileType },
|
|
6
|
-
}, { limit: 1 });
|
|
3
|
+
const orderFiles = await modules.files.findFiles({ 'meta.orderId': order._id, 'meta.type': params.fileType }, { limit: 1 });
|
|
7
4
|
attachments.concat(orderFiles);
|
|
8
5
|
const payment = await modules.orders.payments.findOrderPayment({
|
|
9
6
|
orderPaymentId: order.paymentId,
|
|
10
7
|
}, { limit: 1 });
|
|
11
8
|
if (modules.orders.payments.isBlockingOrderFullfillment(payment)) {
|
|
12
|
-
const invoices = await modules.files.
|
|
13
|
-
meta: { orderId, type: 'INVOICE' },
|
|
14
|
-
}, { limit: 1 });
|
|
9
|
+
const invoices = await modules.files.findFiles({ 'meta.orderId': order._id, 'meta.type': 'INVOICE' }, { limit: 1 });
|
|
15
10
|
attachments.concat(invoices);
|
|
16
11
|
}
|
|
17
12
|
else {
|
|
18
|
-
const receipts = await modules.files.
|
|
19
|
-
meta: { orderId, type: 'RECEIPT' },
|
|
20
|
-
}, { limit: 1 });
|
|
13
|
+
const receipts = await modules.files.findFiles({ 'meta.orderId': order._id, 'meta.type': 'RECEIPT' }, { limit: 1 });
|
|
21
14
|
attachments.concat(receipts);
|
|
22
15
|
}
|
|
23
16
|
return attachments.map((file) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOrderAttachmentsData.js","sourceRoot":"","sources":["../../../src/templates/utils/getOrderAttachmentsData.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAC1C,KAAY,EACZ,MAA4B,EAC5B,EAAE,OAAO,EAAW,EACpB,EAAE;IACF,MAAM,
|
|
1
|
+
{"version":3,"file":"getOrderAttachmentsData.js","sourceRoot":"","sources":["../../../src/templates/utils/getOrderAttachmentsData.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAC1C,KAAY,EACZ,MAA4B,EAC5B,EAAE,OAAO,EAAW,EACpB,EAAE;IACF,MAAM,WAAW,GAAG,EAAE,CAAC;IAEvB,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAC9C,EAAE,cAAc,EAAE,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,EAC3D,EAAE,KAAK,EAAE,CAAC,EAAE,CACb,CAAC;IACF,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC/B,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAC5D;QACE,cAAc,EAAE,KAAK,CAAC,SAAS;KAChC,EACD,EAAE,KAAK,EAAE,CAAC,EAAE,CACb,CAAC;IACF,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,EAAE;QAChE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAC5C,EAAE,cAAc,EAAE,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,EACrD,EAAE,KAAK,EAAE,CAAC,EAAE,CACb,CAAC;QACF,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;KAC9B;SAAM;QACL,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAC5C,EAAE,cAAc,EAAE,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,EACrD,EAAE,KAAK,EAAE,CAAC,EAAE,CACb,CAAC;QACF,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;KAC9B;IAED,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAChC,QAAQ,EAAE,GAAG,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE;QAC7C,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC,CAAC,CAAC;AACN,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/platform",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta8",
|
|
4
4
|
"main": "lib/platform-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/platform-index.js",
|
|
@@ -30,26 +30,26 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@unchainedshop/api": "^2.0.0-
|
|
34
|
-
"@unchainedshop/core": "^2.0.0-
|
|
35
|
-
"@unchainedshop/events": "^2.0.0-
|
|
36
|
-
"@unchainedshop/file-upload": "^2.0.0-
|
|
37
|
-
"@unchainedshop/logger": "^2.0.0-
|
|
38
|
-
"@unchainedshop/mongodb": "^2.0.0-
|
|
39
|
-
"@unchainedshop/plugins": "^2.0.0-
|
|
40
|
-
"@unchainedshop/roles": "^2.0.0-
|
|
41
|
-
"@unchainedshop/utils": "^2.0.0-
|
|
33
|
+
"@unchainedshop/api": "^2.0.0-beta8",
|
|
34
|
+
"@unchainedshop/core": "^2.0.0-beta8",
|
|
35
|
+
"@unchainedshop/events": "^2.0.0-beta8",
|
|
36
|
+
"@unchainedshop/file-upload": "^2.0.0-beta8",
|
|
37
|
+
"@unchainedshop/logger": "^2.0.0-beta8",
|
|
38
|
+
"@unchainedshop/mongodb": "^2.0.0-beta8",
|
|
39
|
+
"@unchainedshop/plugins": "^2.0.0-beta8",
|
|
40
|
+
"@unchainedshop/roles": "^2.0.0-beta8",
|
|
41
|
+
"@unchainedshop/utils": "^2.0.0-beta8",
|
|
42
42
|
"event-iterator": "^2.0.0",
|
|
43
43
|
"JSONStream": "^1.3.5",
|
|
44
44
|
"moniker": "0.1.2",
|
|
45
45
|
"open": "^8.4.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/node": "^
|
|
49
|
-
"@unchainedshop/types": "^2.0.0-
|
|
48
|
+
"@types/node": "^18.11.9",
|
|
49
|
+
"@unchainedshop/types": "^2.0.0-beta8",
|
|
50
50
|
"cross-env": "^7.0.3",
|
|
51
|
-
"jest": "^29.
|
|
51
|
+
"jest": "^29.3.1",
|
|
52
52
|
"ts-jest": "^29.0.3",
|
|
53
|
-
"typescript": "^4.
|
|
53
|
+
"typescript": "^4.9.3"
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -107,7 +107,7 @@ export const createBulkImporterFactory = (db, bulkImporterOptions: any): BulkImp
|
|
|
107
107
|
},
|
|
108
108
|
invalidateCaches: async (unchainedAPI: UnchainedCore) => {
|
|
109
109
|
if (skipCacheInvalidation) return;
|
|
110
|
-
await unchainedAPI.modules.assortments.invalidateCache({});
|
|
110
|
+
await unchainedAPI.modules.assortments.invalidateCache({}, { skipUpstreamTraversal: true });
|
|
111
111
|
await unchainedAPI.modules.filters.invalidateCache({}, unchainedAPI);
|
|
112
112
|
},
|
|
113
113
|
};
|
|
@@ -36,6 +36,10 @@ export default async function createAssortment(
|
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
if (!(await modules.assortments.assortmentExists({ assortmentId: _id }))) {
|
|
40
|
+
throw new Error(`Can't create assortment ${_id}, fields missing?`);
|
|
41
|
+
}
|
|
42
|
+
|
|
39
43
|
logger.debug('create localized content for assortment', specification.content);
|
|
40
44
|
await upsertAssortmentContent(
|
|
41
45
|
{
|
|
@@ -46,7 +50,7 @@ export default async function createAssortment(
|
|
|
46
50
|
unchainedAPI,
|
|
47
51
|
);
|
|
48
52
|
|
|
49
|
-
logger.debug('create
|
|
53
|
+
logger.debug('create assortment products', products);
|
|
50
54
|
await upsertAssortmentProducts(
|
|
51
55
|
{
|
|
52
56
|
products: products || [],
|
|
@@ -56,7 +60,7 @@ export default async function createAssortment(
|
|
|
56
60
|
unchainedAPI,
|
|
57
61
|
);
|
|
58
62
|
|
|
59
|
-
logger.debug('create assortment children',
|
|
63
|
+
logger.debug('create assortment children', children);
|
|
60
64
|
await upsertAssortmentChildren(
|
|
61
65
|
{
|
|
62
66
|
children: children || [],
|
|
@@ -66,7 +70,7 @@ export default async function createAssortment(
|
|
|
66
70
|
unchainedAPI,
|
|
67
71
|
);
|
|
68
72
|
|
|
69
|
-
logger.debug('create assortment filters',
|
|
73
|
+
logger.debug('create assortment filters', filters);
|
|
70
74
|
await upsertAssortmentFilters(
|
|
71
75
|
{
|
|
72
76
|
filters: filters || [],
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Context } from '@unchainedshop/types/api';
|
|
2
2
|
|
|
3
3
|
export default async function removeAssortment(payload, { logger }, unchainedAPI: Context) {
|
|
4
|
-
const { modules
|
|
4
|
+
const { modules } = unchainedAPI;
|
|
5
5
|
const { _id } = payload;
|
|
6
6
|
logger.debug('remove assortment');
|
|
7
|
-
await modules.assortments.delete(_id, { skipInvalidation: true }
|
|
7
|
+
await modules.assortments.delete(_id, { skipInvalidation: true });
|
|
8
8
|
|
|
9
9
|
return {
|
|
10
10
|
entity: 'ASSORTMENT',
|
|
@@ -14,13 +14,16 @@ export default async function updateAssortment(
|
|
|
14
14
|
const { modules, userId } = unchainedAPI;
|
|
15
15
|
const { media, specification, products, children, filters, _id } = payload;
|
|
16
16
|
|
|
17
|
+
if (!(await modules.assortments.assortmentExists({ assortmentId: _id }))) {
|
|
18
|
+
throw new Error(`Can't update non-existing assortment ${_id}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
if (specification) {
|
|
18
22
|
logger.debug('update assortment object', specification);
|
|
19
23
|
|
|
20
24
|
specification.tags = convertTagsToLowerCase(specification?.tags);
|
|
21
25
|
|
|
22
26
|
await unchainedAPI.modules.assortments.update(_id, { ...specification, authorId }, userId);
|
|
23
|
-
|
|
24
27
|
if (specification.content) {
|
|
25
28
|
logger.debug('replace localized content for assortment', specification.content);
|
|
26
29
|
await upsertAssortmentContent(
|
|
@@ -34,12 +37,6 @@ export default async function updateAssortment(
|
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
if (products || children || filters || media) {
|
|
38
|
-
if (!(await modules.assortments.assortmentExists({ assortmentId: _id }))) {
|
|
39
|
-
throw new Error(`Can't update non-existing assortment ${_id}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
40
|
if (products) {
|
|
44
41
|
logger.debug('update product products', products);
|
|
45
42
|
await upsertAssortmentProducts(
|
|
@@ -31,7 +31,7 @@ export default async (
|
|
|
31
31
|
{ children, authorId, assortmentId: parentAssortmentId },
|
|
32
32
|
unchainedAPI: Context,
|
|
33
33
|
) => {
|
|
34
|
-
const { modules
|
|
34
|
+
const { modules } = unchainedAPI;
|
|
35
35
|
const assortmentLinkIds = await Promise.all(
|
|
36
36
|
children.map(async ({ assortmentId: childAssortmentId, ...childrenRest }) => {
|
|
37
37
|
const tags = convertTagsToLowerCase(childrenRest?.tags);
|
|
@@ -54,6 +54,5 @@ export default async (
|
|
|
54
54
|
parentAssortmentId,
|
|
55
55
|
},
|
|
56
56
|
{ skipInvalidation: true },
|
|
57
|
-
userId,
|
|
58
57
|
);
|
|
59
58
|
};
|
|
@@ -2,9 +2,6 @@ import { Context } from '@unchainedshop/types/api';
|
|
|
2
2
|
import { AssortmentText } from '@unchainedshop/types/assortments';
|
|
3
3
|
|
|
4
4
|
export default async ({ assortmentId, content, authorId }, { modules, userId }: Context) => {
|
|
5
|
-
const assortment = await modules.assortments.findAssortment({ assortmentId });
|
|
6
|
-
if (!assortment) throw new Error(`Can't update content of non-existing assortment ${assortmentId}`);
|
|
7
|
-
|
|
8
5
|
await Promise.all(
|
|
9
6
|
Object.entries(content).map(
|
|
10
7
|
async ([locale, { authorId: tAuthorId, ...localizedData }]: [string, AssortmentText]) => {
|
|
@@ -31,7 +31,7 @@ const upsert = async (assortmentProduct: AssortmentProduct, unchainedAPI: Contex
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export default async ({ products, authorId, assortmentId }, unchainedAPI: Context) => {
|
|
34
|
-
const { modules
|
|
34
|
+
const { modules } = unchainedAPI;
|
|
35
35
|
const assortmentProductIds = await Promise.all(
|
|
36
36
|
products.map(async (product: AssortmentProduct) => {
|
|
37
37
|
const tags = convertTagsToLowerCase(product?.tags);
|
|
@@ -54,6 +54,5 @@ export default async ({ products, authorId, assortmentId }, unchainedAPI: Contex
|
|
|
54
54
|
assortmentId,
|
|
55
55
|
},
|
|
56
56
|
{ skipInvalidation: true },
|
|
57
|
-
userId,
|
|
58
57
|
);
|
|
59
58
|
};
|
|
@@ -1,43 +1,6 @@
|
|
|
1
1
|
import { Context } from '@unchainedshop/types/api';
|
|
2
2
|
import { AssortmentMediaText } from '@unchainedshop/types/assortments.media';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const upsertAsset = async (
|
|
6
|
-
asset: File & { fileName: string; headers?: Record<string, unknown> },
|
|
7
|
-
unchainedAPI: Context,
|
|
8
|
-
) => {
|
|
9
|
-
const { modules, services, userId } = unchainedAPI;
|
|
10
|
-
const { _id, fileName, url, meta, headers, ...assetData } = asset;
|
|
11
|
-
const fileId = _id;
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
if (_id && (await modules.files.findFile({ fileId }))) throw new Error('Media already exists');
|
|
15
|
-
|
|
16
|
-
const assetObject = await services.files.uploadFileFromURL(
|
|
17
|
-
{
|
|
18
|
-
directoryName: 'assortment-media',
|
|
19
|
-
fileInput: {
|
|
20
|
-
fileLink: url,
|
|
21
|
-
fileName,
|
|
22
|
-
headers,
|
|
23
|
-
},
|
|
24
|
-
meta: { ...meta, fileId },
|
|
25
|
-
userId,
|
|
26
|
-
},
|
|
27
|
-
unchainedAPI,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
if (!assetObject) throw new Error('Media not created');
|
|
31
|
-
return assetObject;
|
|
32
|
-
} catch (e) {
|
|
33
|
-
if (fileId) {
|
|
34
|
-
await modules.files.update(fileId, { meta: { ...meta, fileId }, ...assetData }, userId);
|
|
35
|
-
const file = await modules.files.findFile({ fileId });
|
|
36
|
-
return file;
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
3
|
+
import upsertAsset from '../../upsertAsset';
|
|
41
4
|
|
|
42
5
|
const upsertMediaObject = async (media, unchainedAPI: Context) => {
|
|
43
6
|
const { modules, userId } = unchainedAPI;
|
|
@@ -55,6 +18,7 @@ export default async ({ media, authorId, assortmentId }, unchainedAPI: Context)
|
|
|
55
18
|
const mediaObjects = await Promise.all(
|
|
56
19
|
media.map(async ({ asset, content, ...mediaData }) => {
|
|
57
20
|
const file = await upsertAsset(
|
|
21
|
+
'assortment-media',
|
|
58
22
|
{ meta: { ...(asset.meta || {}), assortmentId }, ...asset },
|
|
59
23
|
unchainedAPI,
|
|
60
24
|
);
|
|
@@ -17,9 +17,8 @@ export default async function createFilter(
|
|
|
17
17
|
if (!content) throw new Error(`Localizable content is required when creating new filter${_id}`);
|
|
18
18
|
|
|
19
19
|
logger.debug('create filter object', specification);
|
|
20
|
-
let filter;
|
|
21
20
|
try {
|
|
22
|
-
|
|
21
|
+
await unchainedAPI.modules.filters.create(
|
|
23
22
|
{
|
|
24
23
|
...filterData,
|
|
25
24
|
_id,
|
|
@@ -34,7 +33,7 @@ export default async function createFilter(
|
|
|
34
33
|
if (!createShouldUpsertIfIDExists) throw e;
|
|
35
34
|
|
|
36
35
|
logger.debug('entity already exists, falling back to update', specification);
|
|
37
|
-
|
|
36
|
+
await modules.filters.update(
|
|
38
37
|
_id,
|
|
39
38
|
{
|
|
40
39
|
...filterData,
|
|
@@ -47,11 +46,15 @@ export default async function createFilter(
|
|
|
47
46
|
);
|
|
48
47
|
}
|
|
49
48
|
|
|
49
|
+
if (!(await modules.filters.filterExists({ filterId: _id }))) {
|
|
50
|
+
throw new Error(`Can't upsert filter ${_id}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
50
53
|
logger.debug('create localized content for filter', content);
|
|
51
|
-
await upsertFilterContent({ content,
|
|
54
|
+
await upsertFilterContent({ content, filterId: _id, authorId }, unchainedAPI);
|
|
52
55
|
|
|
53
56
|
logger.debug('create localized content for filter options', content);
|
|
54
|
-
await upsertFilterOptionContent({ options,
|
|
57
|
+
await upsertFilterOptionContent({ options, filterId: _id }, unchainedAPI);
|
|
55
58
|
|
|
56
59
|
return {
|
|
57
60
|
entity: 'FILTER',
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Context } from '@unchainedshop/types/api';
|
|
2
2
|
|
|
3
3
|
export default async function removeFilter(payload: any, { logger }, unchainedAPI: Context) {
|
|
4
|
-
const { modules
|
|
4
|
+
const { modules } = unchainedAPI;
|
|
5
5
|
const { _id } = payload;
|
|
6
6
|
logger.debug('remove filter');
|
|
7
|
-
await modules.assortments.filters.deleteMany({ filterId: _id }
|
|
7
|
+
await modules.assortments.filters.deleteMany({ filterId: _id });
|
|
8
8
|
await modules.filters.delete(_id);
|
|
9
9
|
|
|
10
10
|
return {
|
|
@@ -10,34 +10,35 @@ export default async function updateFilter(
|
|
|
10
10
|
const { modules } = unchainedAPI;
|
|
11
11
|
const { specification, _id } = payload;
|
|
12
12
|
|
|
13
|
-
if (!
|
|
13
|
+
if (!(await modules.filters.filterExists({ filterId: _id }))) {
|
|
14
|
+
throw new Error(`Can't update non-existing filter ${_id}`);
|
|
15
|
+
}
|
|
14
16
|
|
|
15
|
-
logger.debug('update filter object', specification);
|
|
16
17
|
const { content, options, ...filterData } = specification;
|
|
17
|
-
const filter = await modules.filters.update(
|
|
18
|
-
_id,
|
|
19
|
-
{
|
|
20
|
-
...filterData,
|
|
21
|
-
options: options?.map((option) => option.value) || [],
|
|
22
|
-
authorId,
|
|
23
|
-
},
|
|
24
|
-
unchainedAPI,
|
|
25
|
-
{ skipInvalidation: true },
|
|
26
|
-
unchainedAPI.userId,
|
|
27
|
-
);
|
|
28
18
|
|
|
29
|
-
if (
|
|
30
|
-
|
|
19
|
+
if (specification) {
|
|
20
|
+
logger.debug('update filter object', specification);
|
|
21
|
+
await modules.filters.update(
|
|
22
|
+
_id,
|
|
23
|
+
{
|
|
24
|
+
...filterData,
|
|
25
|
+
options: options?.map((option) => option.value) || [],
|
|
26
|
+
authorId,
|
|
27
|
+
},
|
|
28
|
+
unchainedAPI,
|
|
29
|
+
{ skipInvalidation: true },
|
|
30
|
+
unchainedAPI.userId,
|
|
31
|
+
);
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
if (content) {
|
|
34
35
|
logger.debug('replace localized content for filter', content);
|
|
35
|
-
await upsertFilterContent({ content,
|
|
36
|
+
await upsertFilterContent({ content, filterId: _id, authorId }, unchainedAPI);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
if (options) {
|
|
39
40
|
logger.debug('replace localized content for filter options', content);
|
|
40
|
-
await upsertFilterOptionContent({ options,
|
|
41
|
+
await upsertFilterOptionContent({ options, filterId: _id }, unchainedAPI);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
return {
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Context } from '@unchainedshop/types/api';
|
|
2
2
|
import { FilterText } from '@unchainedshop/types/filters';
|
|
3
3
|
|
|
4
|
-
export default async function upsertFilterContent(
|
|
4
|
+
export default async function upsertFilterContent(
|
|
5
|
+
{ content, filterId, authorId },
|
|
6
|
+
unchainedAPI: Context,
|
|
7
|
+
) {
|
|
5
8
|
return Promise.all(
|
|
6
9
|
Object.entries(content).map(
|
|
7
10
|
async ([locale, { authorId: tAuthorId, ...localizedData }]: [string, FilterText]) => {
|
|
8
11
|
return unchainedAPI.modules.filters.texts.upsertLocalizedText(
|
|
9
|
-
{ filterId
|
|
12
|
+
{ filterId },
|
|
10
13
|
locale,
|
|
11
14
|
localizedData,
|
|
12
15
|
tAuthorId || authorId || unchainedAPI.userId,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Context } from '@unchainedshop/types/api';
|
|
2
2
|
import { FilterText } from '@unchainedshop/types/filters';
|
|
3
3
|
|
|
4
|
-
export default async function upsertFilterOptionContent({ options,
|
|
4
|
+
export default async function upsertFilterOptionContent({ options, filterId }, unchainedAPI: Context) {
|
|
5
5
|
return Promise.all(
|
|
6
6
|
(options || []).map(async ({ content: optionContent, value: optionValue }) => {
|
|
7
7
|
await Promise.all(
|
|
8
8
|
Object.entries(optionContent).map(
|
|
9
9
|
async ([locale, { authorId, ...localizedData }]: [string, FilterText]) => {
|
|
10
10
|
return unchainedAPI.modules.filters.texts.upsertLocalizedText(
|
|
11
|
-
{ filterId
|
|
11
|
+
{ filterId, filterOptionValue: optionValue },
|
|
12
12
|
locale,
|
|
13
13
|
localizedData,
|
|
14
14
|
authorId || unchainedAPI.userId,
|