@unchainedshop/api 2.5.12 → 2.6.1
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/createGraphQLServer.js +1 -9
- package/lib/createGraphQLServer.js.map +1 -1
- package/lib/express/createBulkImportMiddleware.js +16 -43
- package/lib/express/createBulkImportMiddleware.js.map +1 -1
- package/lib/hashPassword.d.ts +1 -1
- package/lib/hashPassword.js.map +1 -1
- package/lib/locale-context.js +2 -2
- package/lib/locale-context.js.map +1 -1
- package/lib/resolvers/queries/events/event.d.ts +1 -2
- package/lib/resolvers/queries/events/event.js.map +1 -1
- package/lib/resolvers/queries/events/events.d.ts +4 -7
- package/lib/resolvers/queries/events/events.js.map +1 -1
- package/lib/resolvers/queries/events/eventsCounts.d.ts +3 -2
- package/lib/resolvers/queries/events/eventsCounts.js.map +1 -1
- package/lib/resolvers/queries/payment/paymentProviders.d.ts +3 -2
- package/lib/resolvers/queries/payment/paymentProviders.js.map +1 -1
- package/lib/resolvers/queries/payment/paymentProvidersCount.d.ts +3 -2
- package/lib/resolvers/queries/payment/paymentProvidersCount.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-types.js +2 -3
- package/lib/resolvers/type/assortment/assortment-types.js.map +1 -1
- package/lib/resolvers/type/event-types.d.ts +1 -1
- package/lib/resolvers/type/work-types.d.ts +3 -0
- package/lib/resolvers/type/work-types.js +10 -0
- package/lib/resolvers/type/work-types.js.map +1 -1
- package/lib/roles/index.d.ts +1 -2
- package/lib/roles/index.js +1 -2
- package/lib/roles/index.js.map +1 -1
- package/lib/schema/index.js +7 -11
- package/lib/schema/index.js.map +1 -1
- package/package.json +13 -13
- package/src/createGraphQLServer.ts +0 -10
- package/src/express/createBulkImportMiddleware.ts +26 -45
- package/src/hashPassword.ts +1 -1
- package/src/locale-context.ts +2 -2
- package/src/resolvers/queries/events/event.ts +1 -2
- package/src/resolvers/queries/events/events.ts +4 -7
- package/src/resolvers/queries/events/eventsCounts.ts +7 -2
- package/src/resolvers/queries/payment/paymentProviders.ts +3 -2
- package/src/resolvers/queries/payment/paymentProvidersCount.ts +3 -2
- package/src/resolvers/type/assortment/assortment-types.ts +2 -5
- package/src/resolvers/type/event-types.ts +1 -1
- package/src/resolvers/type/work-types.ts +16 -0
- package/src/roles/index.ts +1 -4
- package/src/schema/index.ts +7 -11
|
@@ -3,7 +3,6 @@ import { log, LogLevel } from '@unchainedshop/logger';
|
|
|
3
3
|
import { buildDefaultTypeDefs } from './schema/index.js';
|
|
4
4
|
import resolvers from './resolvers/index.js';
|
|
5
5
|
import { actions } from './roles/index.js';
|
|
6
|
-
const { APOLLO_ENGINE_KEY } = process.env;
|
|
7
6
|
const logGraphQLServerError = (error) => {
|
|
8
7
|
try {
|
|
9
8
|
const { message, extensions: { stacktrace, ...parameters }, ...rest } = error;
|
|
@@ -19,7 +18,7 @@ const logGraphQLServerError = (error) => {
|
|
|
19
18
|
catch (e) { } // eslint-disable-line
|
|
20
19
|
};
|
|
21
20
|
export default async (options) => {
|
|
22
|
-
const { typeDefs: additionalTypeDefs = [], resolvers: additionalResolvers = [],
|
|
21
|
+
const { typeDefs: additionalTypeDefs = [], resolvers: additionalResolvers = [], events = [], workTypes = [], ...apolloServerOptions } = options || {};
|
|
23
22
|
const server = new ApolloServer({
|
|
24
23
|
typeDefs: [
|
|
25
24
|
...buildDefaultTypeDefs({
|
|
@@ -34,13 +33,6 @@ export default async (options) => {
|
|
|
34
33
|
logGraphQLServerError(error);
|
|
35
34
|
return error;
|
|
36
35
|
},
|
|
37
|
-
apollo: APOLLO_ENGINE_KEY
|
|
38
|
-
? {
|
|
39
|
-
key: APOLLO_ENGINE_KEY,
|
|
40
|
-
privateVariables: ['email', 'plainPassword', 'oldPlainPassword', 'newPlainPassword'],
|
|
41
|
-
...engine,
|
|
42
|
-
}
|
|
43
|
-
: undefined,
|
|
44
36
|
...apolloServerOptions,
|
|
45
37
|
});
|
|
46
38
|
return server;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGraphQLServer.js","sourceRoot":"","sources":["../src/createGraphQLServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,
|
|
1
|
+
{"version":3,"file":"createGraphQLServer.js","sourceRoot":"","sources":["../src/createGraphQLServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,qBAAqB,GAAG,CAAC,KAA4B,EAAE,EAAE;IAC7D,IAAI,CAAC;QACH,MAAM,EACJ,OAAO,EACP,UAAU,EAAE,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,EACzC,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;QAEV,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QACvC,WAAW,CAAC,KAAK,GAAI,UAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxD,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC,IAAc,CAAC;QAC7C,GAAG,CAAC,WAAW,EAAE;YACf,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,GAAG,UAAU;YACb,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,sBAAsB;AACvC,CAAC,CAAC;AAEF,eAAe,KAAK,EAAE,OAAO,EAAE,EAAE;IAC/B,MAAM,EACJ,QAAQ,EAAE,kBAAkB,GAAG,EAAE,EACjC,SAAS,EAAE,mBAAmB,GAAG,EAAE,EACnC,MAAM,GAAG,EAAE,EACX,SAAS,GAAG,EAAE,EACd,GAAG,mBAAmB,EACvB,GAAG,OAAO,IAAI,EAAE,CAAC;IAElB,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC;QAC9B,QAAQ,EAAE;YACR,GAAG,oBAAoB,CAAC;gBACtB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;gBAC7B,MAAM;gBACN,SAAS;aACV,CAAC;YACF,GAAG,kBAAkB;SACtB;QACD,SAAS,EAAE,CAAC,SAAS,EAAE,GAAG,mBAAmB,CAAC;QAC9C,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YACrB,qBAAqB,CAAC,KAAK,CAAC,CAAC;YAC7B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,GAAG,mBAAmB;KACvB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
2
|
import { checkAction } from '../acl.js';
|
|
4
3
|
import { actions } from '../roles/index.js';
|
|
5
4
|
const logger = createLogger('unchained:bulk-import');
|
|
6
|
-
const { BULK_IMPORT_PAYLOAD_CACHE_DIRECTORY } = process.env;
|
|
7
5
|
const errorHandler = (res) => (e) => {
|
|
8
6
|
logger.error(e.message);
|
|
9
7
|
res.writeHead(503);
|
|
@@ -14,19 +12,6 @@ const methodWrongHandler = (res) => () => {
|
|
|
14
12
|
res.writeHead(404);
|
|
15
13
|
res.end();
|
|
16
14
|
};
|
|
17
|
-
const createWriteStreamToFilesystem = (cacheDirectory) => {
|
|
18
|
-
const date = new Date().toISOString();
|
|
19
|
-
const payloadFilePath = `${cacheDirectory}/${date}.json`;
|
|
20
|
-
const stream = fs.createWriteStream(payloadFilePath, { flags: 'a' });
|
|
21
|
-
return stream;
|
|
22
|
-
};
|
|
23
|
-
const createWriteStreamToMongoDB = (BulkImportPayloads) => {
|
|
24
|
-
const date = new Date().toISOString();
|
|
25
|
-
const stream = BulkImportPayloads.openUploadStreamWithId(date, `${date}.json`, {
|
|
26
|
-
contentType: 'application/json',
|
|
27
|
-
});
|
|
28
|
-
return stream;
|
|
29
|
-
};
|
|
30
15
|
export default function bulkImportMiddleware(contextResolver) {
|
|
31
16
|
return async (req, res) => {
|
|
32
17
|
try {
|
|
@@ -39,37 +24,25 @@ export default function bulkImportMiddleware(contextResolver) {
|
|
|
39
24
|
const input = {
|
|
40
25
|
createShouldUpsertIfIDExists: !!req.query?.createShouldUpsertIfIDExists,
|
|
41
26
|
skipCacheInvalidation: !!req.query?.skipCacheInvalidation,
|
|
42
|
-
fsPayloadCacheDirectory: BULK_IMPORT_PAYLOAD_CACHE_DIRECTORY,
|
|
43
27
|
remoteAddress: context.remoteAddress,
|
|
44
28
|
};
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
const work = await context.modules.worker.addWork({
|
|
61
|
-
type: 'BULK_IMPORT',
|
|
62
|
-
input: Object.fromEntries(Object.entries(input).filter(([, value]) => Boolean(value))),
|
|
63
|
-
retries: 0,
|
|
64
|
-
priority: 10,
|
|
65
|
-
});
|
|
66
|
-
res.writeHead(200);
|
|
67
|
-
res.end(JSON.stringify(work));
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
errorHandler(res)(e);
|
|
71
|
-
}
|
|
29
|
+
const date = new Date().toISOString();
|
|
30
|
+
const file = await context.services.files.uploadFileFromStream({
|
|
31
|
+
directoryName: 'bulk-import-streams',
|
|
32
|
+
rawFile: Promise.resolve({ filename: `${date}.json`, createReadStream: () => req }),
|
|
33
|
+
meta: {},
|
|
34
|
+
}, context);
|
|
35
|
+
input.payloadId = file._id;
|
|
36
|
+
input.payloadSize = file.size;
|
|
37
|
+
const purgedInput = Object.fromEntries(Object.entries(input).filter(([, value]) => Boolean(value)));
|
|
38
|
+
const work = await context.modules.worker.addWork({
|
|
39
|
+
type: 'BULK_IMPORT',
|
|
40
|
+
input: purgedInput,
|
|
41
|
+
retries: 0,
|
|
42
|
+
priority: 10,
|
|
72
43
|
});
|
|
44
|
+
res.writeHead(200);
|
|
45
|
+
res.end(JSON.stringify(work));
|
|
73
46
|
}
|
|
74
47
|
catch (e) {
|
|
75
48
|
errorHandler(res)(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBulkImportMiddleware.js","sourceRoot":"","sources":["../../src/express/createBulkImportMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"createBulkImportMiddleware.js","sourceRoot":"","sources":["../../src/express/createBulkImportMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,MAAM,MAAM,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAErD,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;IAClC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACxB,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACnB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EA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,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;gBACnF,IAAI,EAAE,EAAE;aACT,EACD,OAAO,CACR,CAAC;YAEF,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC;YAC3B,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC;YAE9B,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CACpC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAC5D,CAAC;YAEF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;gBAChD,IAAI,EAAE,aAAa;gBACnB,KAAK,EAAE,WAAW;gBAClB,OAAO,EAAE,CAAC;gBACV,QAAQ,EAAE,EAAE;aACb,CAAC,CAAC;YAEH,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACnB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/hashPassword.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const hashPassword: (password:
|
|
1
|
+
export declare const hashPassword: (password: string) => string;
|
package/lib/hashPassword.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashPassword.js","sourceRoot":"","sources":["../src/hashPassword.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"hashPassword.js","sourceRoot":"","sources":["../src/hashPassword.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAU,EAAE;IACvD,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC,CAAC"}
|
package/lib/locale-context.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import localePkg from 'locale';
|
|
2
2
|
import 'abort-controller/polyfill.js';
|
|
3
|
-
import { LRUCache } from 'lru-cache';
|
|
4
3
|
import { log, LogLevel } from '@unchainedshop/logger';
|
|
5
4
|
import { resolveBestCountry, resolveBestSupported, resolveUserRemoteAddress, systemLocale, } from '@unchainedshop/utils';
|
|
5
|
+
import * as lruCache from 'lru-cache';
|
|
6
6
|
const { Locales } = localePkg;
|
|
7
7
|
const { NODE_ENV } = process.env;
|
|
8
8
|
const ttl = NODE_ENV === 'production' ? 1000 * 60 : 0; // minute or second
|
|
9
|
-
const localeContextCache = new LRUCache({
|
|
9
|
+
const localeContextCache = new lruCache.LRUCache({
|
|
10
10
|
max: 500,
|
|
11
11
|
ttl,
|
|
12
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale-context.js","sourceRoot":"","sources":["../src/locale-context.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,QAAQ,CAAC;AAC/B,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"locale-context.js","sourceRoot":"","sources":["../src/locale-context.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,QAAQ,CAAC;AAC/B,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EAC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 -1,5 +1,4 @@
|
|
|
1
|
-
import { _ID } from '@unchainedshop/types/common.js';
|
|
2
1
|
import { Root, Context } from '@unchainedshop/types/api.js';
|
|
3
2
|
export default function event(root: Root, { eventId }: {
|
|
4
|
-
eventId:
|
|
3
|
+
eventId: string;
|
|
5
4
|
}, { modules, userId }: Context): Promise<import("@unchainedshop/types/events.js").Event>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/events/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/events/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAG5C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CACjC,IAAU,EACV,EAAE,OAAO,EAAuB,EAChC,EAAE,OAAO,EAAE,MAAM,EAAW;IAE5B,GAAG,CAAC,eAAe,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAE1C,OAAO,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { Root, Context
|
|
2
|
-
|
|
3
|
-
export default function events(root: Root, params:
|
|
4
|
-
|
|
5
|
-
offset?: number;
|
|
6
|
-
sort: Array<SortOption>;
|
|
7
|
-
}, { modules, userId }: Context): Promise<import("@unchainedshop/types/events.js").Event[]>;
|
|
1
|
+
import { Root, Context } from '@unchainedshop/types/api.js';
|
|
2
|
+
type FindEventsParams = Parameters<Context['modules']['events']['findEvents']>['0'];
|
|
3
|
+
export default function events(root: Root, params: FindEventsParams, { modules, userId }: Context): Promise<import("@unchainedshop/types/events.js").Event[]>;
|
|
4
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/events/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/events/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAK5C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,MAAM,CAClC,IAAU,EACV,MAAwB,EACxB,EAAE,OAAO,EAAE,MAAM,EAAW;IAE5B,GAAG,CACD,gBAAgB,MAAM,CAAC,KAAK,YAAY,MAAM,CAAC,KAAK,YAAY,MAAM,CAAC,MAAM,iBAAiB,MAAM,CAAC,WAAW,EAAE,EAClH;QACE,MAAM;KACP,CACF,CAAC;IAEF,OAAO,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Root, Context } from '@unchainedshop/types/api.js';
|
|
2
|
-
|
|
3
|
-
export default function eventsCount(root: Root, params:
|
|
2
|
+
type CountEventsParams = Parameters<Context['modules']['events']['count']>['0'];
|
|
3
|
+
export default function eventsCount(root: Root, params: CountEventsParams, { modules, userId }: Context): Promise<number>;
|
|
4
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventsCounts.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/events/eventsCounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"eventsCounts.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/events/eventsCounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAK5C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,WAAW,CACvC,IAAU,EACV,MAAyB,EACzB,EAAE,OAAO,EAAE,MAAM,EAAW;IAE5B,GAAG,CAAC,mCAAmC,MAAM,CAAC,WAAW,YAAY,MAAM,CAAC,KAAK,KAAK,MAAM,EAAE,EAAE;QAC9F,MAAM;KACP,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mongodb } from '@unchainedshop/mongodb';
|
|
2
2
|
import { Context, Root } from '@unchainedshop/types/api.js';
|
|
3
|
-
|
|
3
|
+
import { PaymentProvider } from '@unchainedshop/types/payments.js';
|
|
4
|
+
export default function paymentProviders(root: Root, params: mongodb.Filter<PaymentProvider>, { modules, userId }: Context): Promise<PaymentProvider[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymentProviders.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/payment/paymentProviders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"paymentProviders.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/payment/paymentProviders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAK5C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAC5C,IAAU,EACV,MAAuC,EACvC,EAAE,OAAO,EAAE,MAAM,EAAW;IAE5B,GAAG,CAAC,yBAAyB,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAExD,OAAO,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mongodb } from '@unchainedshop/mongodb';
|
|
2
2
|
import { Context, Root } from '@unchainedshop/types/api.js';
|
|
3
|
-
|
|
3
|
+
import { PaymentProvider } from '@unchainedshop/types/payments.js';
|
|
4
|
+
export default function paymentProvidersCount(root: Root, params: mongodb.Filter<PaymentProvider>, { modules, userId }: Context): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymentProvidersCount.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/payment/paymentProvidersCount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"paymentProvidersCount.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/payment/paymentProvidersCount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAK5C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,qBAAqB,CACjD,IAAU,EACV,MAAuC,EACvC,EAAE,OAAO,EAAE,MAAM,EAAW;IAE5B,GAAG,CAAC,+BAA+B,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAE9D,OAAO,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -16,12 +16,11 @@ export const Assortment = {
|
|
|
16
16
|
parentAssortmentId: assortment._id,
|
|
17
17
|
});
|
|
18
18
|
const assortmentIds = assortmentChildLinks.map(({ childAssortmentId }) => childAssortmentId);
|
|
19
|
-
|
|
19
|
+
return modules.assortments.count({
|
|
20
20
|
assortmentIds,
|
|
21
21
|
includeInactive,
|
|
22
22
|
includeLeaves: true,
|
|
23
|
-
};
|
|
24
|
-
return modules.assortments.count(selector);
|
|
23
|
+
});
|
|
25
24
|
},
|
|
26
25
|
filterAssignments: async (obj, _, { modules }) => {
|
|
27
26
|
// TODO: Loader & move default sort to module
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assortment-types.js","sourceRoot":"","sources":["../../../../src/resolvers/type/assortment/assortment-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assortment-types.js","sourceRoot":"","sources":["../../../../src/resolvers/type/assortment/assortment-types.ts"],"names":[],"mappings":"AAgDA,MAAM,CAAC,MAAM,UAAU,GAA0B;IAC/C,eAAe,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACvC,OAAO,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC;YACrC,YAAY,EAAE,GAAG,CAAC,GAAG;SACtB,CAAC,CAAC;IACL,CAAC;IAED,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACxD,OAAO,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC;YAClC,YAAY,EAAE,GAAG,CAAC,GAAG;YACrB,eAAe;SAChB,CAAC,CAAC;IACL,CAAC;IAED,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,eAAe,GAAG,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC5E,eAAe;QACf,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC;YACrE,kBAAkB,EAAE,UAAU,CAAC,GAAG;SACnC,CAAC,CAAC;QACH,MAAM,aAAa,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC;QAE7F,OAAO,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC;YAC/B,aAAa;YACb,eAAe;YACf,aAAa,EAAE,IAAI;SACpB,CAAC,CAAC;IACL,CAAC;IAED,iBAAiB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC/C,6CAA6C;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AAO,EAAE,EAAE;QAC5C,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC;YAClE,YAAY,EAAE,GAAG,CAAC,GAAG;YACrB,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;SACrD,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC;YACxE,YAAY,EAAE,GAAG,CAAC,GAAG;SACtB,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAClD,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,EACnC,EAAE,EACF,OAAO,CACR,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from '@unchainedshop/types/api.js';
|
|
2
|
-
import { Event as EventType } from '@unchainedshop/
|
|
2
|
+
import { Event as EventType } from '@unchainedshop/core-events';
|
|
3
3
|
export type HelperType<P, T> = (work: EventType, params: P, context: Context) => T;
|
|
4
4
|
export interface EventHelperTypes {
|
|
5
5
|
type: HelperType<never, string>;
|
|
@@ -4,6 +4,9 @@ type HelperType<P, T> = (work: WorkType, params: P, context: Context) => T;
|
|
|
4
4
|
export interface WorkHelperTypes {
|
|
5
5
|
status: HelperType<never, string>;
|
|
6
6
|
type: HelperType<never, string>;
|
|
7
|
+
result: HelperType<never, any>;
|
|
8
|
+
input: HelperType<never, any>;
|
|
9
|
+
error: HelperType<never, any>;
|
|
7
10
|
original: HelperType<never, Promise<WorkType>>;
|
|
8
11
|
}
|
|
9
12
|
export declare const Work: WorkHelperTypes;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildObfuscatedFieldsFilter } from '@unchainedshop/utils';
|
|
1
2
|
export const Work = {
|
|
2
3
|
status: (obj, _, { modules }) => {
|
|
3
4
|
return modules.worker.status(obj);
|
|
@@ -10,5 +11,14 @@ export const Work = {
|
|
|
10
11
|
return null;
|
|
11
12
|
return modules.worker.findWork({ workId: obj.originalWorkId });
|
|
12
13
|
},
|
|
14
|
+
input: (obj, _, { options }) => {
|
|
15
|
+
return buildObfuscatedFieldsFilter(options.worker?.blacklistedVariables)(obj.input);
|
|
16
|
+
},
|
|
17
|
+
result: (obj, _, { options }) => {
|
|
18
|
+
return buildObfuscatedFieldsFilter(options.worker?.blacklistedVariables)(obj.result);
|
|
19
|
+
},
|
|
20
|
+
error: (obj, _, { options }) => {
|
|
21
|
+
return buildObfuscatedFieldsFilter(options.worker?.blacklistedVariables)(obj.error);
|
|
22
|
+
},
|
|
13
23
|
};
|
|
14
24
|
//# sourceMappingURL=work-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/work-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"work-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/work-types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAanE,MAAM,CAAC,MAAM,IAAI,GAAoB;IACnC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC9B,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC5B,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACtC,IAAI,CAAC,GAAG,CAAC,cAAc;YAAE,OAAO,IAAI,CAAC;QACrC,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,EAAW,EAAE,EAAE;QACtC,OAAO,2BAA2B,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,EAAW,EAAE,EAAE;QACvC,OAAO,2BAA2B,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACvF,CAAC;IAED,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,EAAW,EAAE,EAAE;QACtC,OAAO,2BAA2B,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACtF,CAAC;CACF,CAAC"}
|
package/lib/roles/index.d.ts
CHANGED
|
@@ -12,5 +12,4 @@ declare const configureRoles: ({ additionalRoles, additionalActions }: {
|
|
|
12
12
|
LOGGEDIN: import("@unchainedshop/types/roles.js").RoleInterface;
|
|
13
13
|
ALL: import("@unchainedshop/types/roles.js").RoleInterface;
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
export { allRoles, actions, configureRoles, updateUserRole };
|
|
15
|
+
export { allRoles, actions, configureRoles };
|
package/lib/roles/index.js
CHANGED
|
@@ -131,6 +131,5 @@ const configureRoles = ({ additionalRoles = {}, additionalActions = [] }) => {
|
|
|
131
131
|
admin(allRoles.ADMIN, actions);
|
|
132
132
|
return allRoles;
|
|
133
133
|
};
|
|
134
|
-
|
|
135
|
-
export { allRoles, actions, configureRoles, updateUserRole };
|
|
134
|
+
export { allRoles, actions, configureRoles };
|
|
136
135
|
//# sourceMappingURL=index.js.map
|
package/lib/roles/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/roles/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/roles/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,KAAK,GAAG;IACZ,KAAK,EAAE,KAAK,CAAC,SAAS;IACtB,QAAQ,EAAE,KAAK,CAAC,YAAY;IAC5B,GAAG,EAAE,KAAK,CAAC,OAAO;CACnB,CAAC;AAEF,MAAM,QAAQ,GAAG,KAAK,CAAC;AAEvB,MAAM,OAAO,GAA2B;IACtC,WAAW;IACX,YAAY;IACZ,eAAe;IACf,gBAAgB;IAChB,oBAAoB;IACpB,qBAAqB;IACrB,sBAAsB;IACtB,qBAAqB;IACrB,gBAAgB;IAChB,UAAU;IACV,UAAU;IACV,WAAW;IACX,aAAa;IACb,cAAc;IACd,eAAe;IACf,cAAc;IACd,eAAe;IACf,aAAa;IACb,gBAAgB;IAChB,cAAc;IACd,sBAAsB;IACtB,qBAAqB;IACrB,uBAAuB;IACvB,uBAAuB;IACvB,sBAAsB;IACtB,wBAAwB;IACxB,0BAA0B;IAC1B,yBAAyB;IACzB,2BAA2B;IAC3B,kBAAkB;IAClB,YAAY;IACZ,WAAW;IACX,cAAc;IACd,YAAY;IACZ,gBAAgB;IAChB,WAAW;IACX,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;IAClB,w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B,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAgB,EAAE,EAAE;QACpE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9B,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACrC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAE/B,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/lib/schema/index.js
CHANGED
|
@@ -5,17 +5,13 @@ import inputTypes from './inputTypes.js';
|
|
|
5
5
|
import query from './query.js';
|
|
6
6
|
import mutation from './mutation.js';
|
|
7
7
|
export const buildDefaultTypeDefs = ({ actions = [], events = [], workTypes = [] }) => {
|
|
8
|
-
const dynamicTypeDefs =
|
|
9
|
-
|
|
10
|
-
${
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
extend enum WorkType {
|
|
16
|
-
${workTypes.join(',')}
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
8
|
+
const dynamicTypeDefs = [
|
|
9
|
+
actions?.length && `extend enum RoleAction { ${actions.join(',')} }`,
|
|
10
|
+
events?.length && `extend enum EventType { ${events.join(',')} }`,
|
|
11
|
+
workTypes?.length && `extend enum WorkType { ${workTypes.join(',')} }`,
|
|
12
|
+
]
|
|
13
|
+
.filter(Boolean)
|
|
14
|
+
.join('\n');
|
|
19
15
|
return [...scalars, ...directives, ...types, ...inputTypes, ...query, ...mutation, dynamicTypeDefs];
|
|
20
16
|
};
|
|
21
17
|
//# sourceMappingURL=index.js.map
|
package/lib/schema/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,QAAQ,MAAM,eAAe,CAAC;AAErC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,OAAO,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE;IACpF,MAAM,eAAe,GAAG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,QAAQ,MAAM,eAAe,CAAC;AAErC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,OAAO,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE;IACpF,MAAM,eAAe,GAAG;QACtB,OAAO,EAAE,MAAM,IAAI,4BAA4B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI;QACpE,MAAM,EAAE,MAAM,IAAI,2BAA2B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI;QACjE,SAAS,EAAE,MAAM,IAAI,0BAA0B,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI;KACvE;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO,CAAC,GAAG,OAAO,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,EAAE,GAAG,QAAQ,EAAE,eAAe,CAAC,CAAC;AACtG,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"main": "lib/api-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/api-index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@apollo/server": "^4.
|
|
43
|
+
"@apollo/server": "^4.10.0",
|
|
44
44
|
"cookie": "^0.6.0",
|
|
45
45
|
"graphql": "^16.6.0"
|
|
46
46
|
},
|
|
@@ -49,28 +49,28 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@metamask/eth-sig-util": "^7.0.1",
|
|
52
|
-
"@unchainedshop/core": "^2.
|
|
53
|
-
"@unchainedshop/events": "^2.
|
|
54
|
-
"@unchainedshop/logger": "^2.
|
|
55
|
-
"@unchainedshop/roles": "^2.
|
|
56
|
-
"@unchainedshop/utils": "^2.
|
|
52
|
+
"@unchainedshop/core": "^2.6.1",
|
|
53
|
+
"@unchainedshop/events": "^2.6.1",
|
|
54
|
+
"@unchainedshop/logger": "^2.6.1",
|
|
55
|
+
"@unchainedshop/roles": "^2.6.1",
|
|
56
|
+
"@unchainedshop/utils": "^2.6.1",
|
|
57
57
|
"accounting": "0.4.1",
|
|
58
58
|
"dataloader": "^2.2.2",
|
|
59
59
|
"graphql-scalars": "^1.22.4",
|
|
60
60
|
"graphql-upload": "^16.0.2",
|
|
61
61
|
"locale": "0.1.0",
|
|
62
62
|
"lodash.isnumber": "3.0.3",
|
|
63
|
-
"lru-cache": "^10.
|
|
63
|
+
"lru-cache": "^10.2.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@types/graphql-upload": "^16.0.
|
|
66
|
+
"@types/graphql-upload": "^16.0.7",
|
|
67
67
|
"@types/locale": "^0.1.4",
|
|
68
|
-
"@types/node": "^20.10
|
|
69
|
-
"@unchainedshop/types": "^2.
|
|
68
|
+
"@types/node": "^20.11.10",
|
|
69
|
+
"@unchainedshop/types": "^2.6.1",
|
|
70
70
|
"express": "^4.18.2",
|
|
71
71
|
"graphql": "^16.8.1",
|
|
72
72
|
"jest": "^29.7.0",
|
|
73
|
-
"ts-jest": "^29.1.
|
|
74
|
-
"typescript": "^5.3.
|
|
73
|
+
"ts-jest": "^29.1.2",
|
|
74
|
+
"typescript": "^5.3.3"
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -5,8 +5,6 @@ import { buildDefaultTypeDefs } from './schema/index.js';
|
|
|
5
5
|
import resolvers from './resolvers/index.js';
|
|
6
6
|
import { actions } from './roles/index.js';
|
|
7
7
|
|
|
8
|
-
const { APOLLO_ENGINE_KEY } = process.env;
|
|
9
|
-
|
|
10
8
|
const logGraphQLServerError = (error: GraphQLFormattedError) => {
|
|
11
9
|
try {
|
|
12
10
|
const {
|
|
@@ -30,7 +28,6 @@ export default async (options) => {
|
|
|
30
28
|
const {
|
|
31
29
|
typeDefs: additionalTypeDefs = [],
|
|
32
30
|
resolvers: additionalResolvers = [],
|
|
33
|
-
engine = {},
|
|
34
31
|
events = [],
|
|
35
32
|
workTypes = [],
|
|
36
33
|
...apolloServerOptions
|
|
@@ -50,13 +47,6 @@ export default async (options) => {
|
|
|
50
47
|
logGraphQLServerError(error);
|
|
51
48
|
return error;
|
|
52
49
|
},
|
|
53
|
-
apollo: APOLLO_ENGINE_KEY
|
|
54
|
-
? {
|
|
55
|
-
key: APOLLO_ENGINE_KEY,
|
|
56
|
-
privateVariables: ['email', 'plainPassword', 'oldPlainPassword', 'newPlainPassword'],
|
|
57
|
-
...engine,
|
|
58
|
-
}
|
|
59
|
-
: undefined,
|
|
60
50
|
...apolloServerOptions,
|
|
61
51
|
});
|
|
62
52
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
2
|
import { UnchainedContextResolver } from '@unchainedshop/types/api.js';
|
|
4
3
|
import { checkAction } from '../acl.js';
|
|
@@ -6,8 +5,6 @@ import { actions } from '../roles/index.js';
|
|
|
6
5
|
|
|
7
6
|
const logger = createLogger('unchained:bulk-import');
|
|
8
7
|
|
|
9
|
-
const { BULK_IMPORT_PAYLOAD_CACHE_DIRECTORY } = process.env;
|
|
10
|
-
|
|
11
8
|
const errorHandler = (res) => (e) => {
|
|
12
9
|
logger.error(e.message);
|
|
13
10
|
res.writeHead(503);
|
|
@@ -20,21 +17,6 @@ const methodWrongHandler = (res) => () => {
|
|
|
20
17
|
res.end();
|
|
21
18
|
};
|
|
22
19
|
|
|
23
|
-
const createWriteStreamToFilesystem = (cacheDirectory) => {
|
|
24
|
-
const date = new Date().toISOString();
|
|
25
|
-
const payloadFilePath = `${cacheDirectory}/${date}.json`;
|
|
26
|
-
const stream = fs.createWriteStream(payloadFilePath, { flags: 'a' });
|
|
27
|
-
return stream;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const createWriteStreamToMongoDB = (BulkImportPayloads) => {
|
|
31
|
-
const date = new Date().toISOString();
|
|
32
|
-
const stream = BulkImportPayloads.openUploadStreamWithId(date, `${date}.json`, {
|
|
33
|
-
contentType: 'application/json',
|
|
34
|
-
});
|
|
35
|
-
return stream;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
20
|
export default function bulkImportMiddleware(contextResolver: UnchainedContextResolver) {
|
|
39
21
|
return async (req, res) => {
|
|
40
22
|
try {
|
|
@@ -49,37 +31,36 @@ export default function bulkImportMiddleware(contextResolver: UnchainedContextRe
|
|
|
49
31
|
const input: any = {
|
|
50
32
|
createShouldUpsertIfIDExists: !!req.query?.createShouldUpsertIfIDExists,
|
|
51
33
|
skipCacheInvalidation: !!req.query?.skipCacheInvalidation,
|
|
52
|
-
fsPayloadCacheDirectory: BULK_IMPORT_PAYLOAD_CACHE_DIRECTORY,
|
|
53
34
|
remoteAddress: context.remoteAddress,
|
|
54
35
|
};
|
|
55
36
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
37
|
+
const date = new Date().toISOString();
|
|
38
|
+
|
|
39
|
+
const file = await context.services.files.uploadFileFromStream(
|
|
40
|
+
{
|
|
41
|
+
directoryName: 'bulk-import-streams',
|
|
42
|
+
rawFile: Promise.resolve({ filename: `${date}.json`, createReadStream: () => req }),
|
|
43
|
+
meta: {},
|
|
44
|
+
},
|
|
45
|
+
context,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
input.payloadId = file._id;
|
|
49
|
+
input.payloadSize = file.size;
|
|
50
|
+
|
|
51
|
+
const purgedInput = Object.fromEntries(
|
|
52
|
+
Object.entries(input).filter(([, value]) => Boolean(value)),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const work = await context.modules.worker.addWork({
|
|
56
|
+
type: 'BULK_IMPORT',
|
|
57
|
+
input: purgedInput,
|
|
58
|
+
retries: 0,
|
|
59
|
+
priority: 10,
|
|
60
|
+
});
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.on('error', errorHandler(res))
|
|
63
|
-
.on('finish', async (file) => {
|
|
64
|
-
try {
|
|
65
|
-
if (input.fsPayloadCacheDirectory) {
|
|
66
|
-
input.payloadFilePath = stream.path;
|
|
67
|
-
} else {
|
|
68
|
-
input.payloadId = file._id;
|
|
69
|
-
input.payloadSize = file.length;
|
|
70
|
-
}
|
|
71
|
-
const work = await context.modules.worker.addWork({
|
|
72
|
-
type: 'BULK_IMPORT',
|
|
73
|
-
input: Object.fromEntries(Object.entries(input).filter(([, value]) => Boolean(value))),
|
|
74
|
-
retries: 0,
|
|
75
|
-
priority: 10,
|
|
76
|
-
});
|
|
77
|
-
res.writeHead(200);
|
|
78
|
-
res.end(JSON.stringify(work));
|
|
79
|
-
} catch (e) {
|
|
80
|
-
errorHandler(res)(e);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
62
|
+
res.writeHead(200);
|
|
63
|
+
res.end(JSON.stringify(work));
|
|
83
64
|
} catch (e) {
|
|
84
65
|
errorHandler(res)(e);
|
|
85
66
|
}
|
package/src/hashPassword.ts
CHANGED
package/src/locale-context.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { IncomingMessage, OutgoingMessage } from 'http';
|
|
|
2
2
|
import { UnchainedLocaleContext } from '@unchainedshop/types/api.js';
|
|
3
3
|
import localePkg from 'locale';
|
|
4
4
|
import 'abort-controller/polyfill.js';
|
|
5
|
-
import { LRUCache } from 'lru-cache';
|
|
6
5
|
import { log, LogLevel } from '@unchainedshop/logger';
|
|
7
6
|
import {
|
|
8
7
|
resolveBestCountry,
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
systemLocale,
|
|
12
11
|
} from '@unchainedshop/utils';
|
|
13
12
|
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
13
|
+
import * as lruCache from 'lru-cache';
|
|
14
14
|
|
|
15
15
|
const { Locales } = localePkg;
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ const { NODE_ENV } = process.env;
|
|
|
18
18
|
|
|
19
19
|
const ttl = NODE_ENV === 'production' ? 1000 * 60 : 0; // minute or second
|
|
20
20
|
|
|
21
|
-
const localeContextCache = new LRUCache({
|
|
21
|
+
const localeContextCache = new lruCache.LRUCache({
|
|
22
22
|
max: 500,
|
|
23
23
|
ttl,
|
|
24
24
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
-
import { _ID } from '@unchainedshop/types/common.js';
|
|
3
2
|
import { Root, Context } from '@unchainedshop/types/api.js';
|
|
4
3
|
|
|
5
4
|
export default async function event(
|
|
6
5
|
root: Root,
|
|
7
|
-
{ eventId }: { eventId:
|
|
6
|
+
{ eventId }: { eventId: string },
|
|
8
7
|
{ modules, userId }: Context,
|
|
9
8
|
) {
|
|
10
9
|
log(`query event ${eventId}`, { userId });
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
-
import { Root, Context
|
|
3
|
-
|
|
2
|
+
import { Root, Context } from '@unchainedshop/types/api.js';
|
|
3
|
+
|
|
4
|
+
type FindEventsParams = Parameters<Context['modules']['events']['findEvents']>['0'];
|
|
4
5
|
|
|
5
6
|
export default async function events(
|
|
6
7
|
root: Root,
|
|
7
|
-
params:
|
|
8
|
-
limit?: number;
|
|
9
|
-
offset?: number;
|
|
10
|
-
sort: Array<SortOption>;
|
|
11
|
-
},
|
|
8
|
+
params: FindEventsParams,
|
|
12
9
|
{ modules, userId }: Context,
|
|
13
10
|
) {
|
|
14
11
|
log(
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
2
|
import { Root, Context } from '@unchainedshop/types/api.js';
|
|
3
|
-
import { EventQuery } from '@unchainedshop/types/events.js';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
type CountEventsParams = Parameters<Context['modules']['events']['count']>['0'];
|
|
5
|
+
|
|
6
|
+
export default async function eventsCount(
|
|
7
|
+
root: Root,
|
|
8
|
+
params: CountEventsParams,
|
|
9
|
+
{ modules, userId }: Context,
|
|
10
|
+
) {
|
|
6
11
|
log(`query eventsCount queryString: ${params.queryString} types: ${params.types} ${userId}`, {
|
|
7
12
|
userId,
|
|
8
13
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
-
import {
|
|
2
|
+
import { mongodb } from '@unchainedshop/mongodb';
|
|
3
3
|
import { Context, Root } from '@unchainedshop/types/api.js';
|
|
4
|
+
import { PaymentProvider } from '@unchainedshop/types/payments.js';
|
|
4
5
|
|
|
5
6
|
export default async function paymentProviders(
|
|
6
7
|
root: Root,
|
|
7
|
-
params:
|
|
8
|
+
params: mongodb.Filter<PaymentProvider>,
|
|
8
9
|
{ modules, userId }: Context,
|
|
9
10
|
) {
|
|
10
11
|
log(`query paymentProvider ${params.type}`, { userId });
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
-
import {
|
|
2
|
+
import { mongodb } from '@unchainedshop/mongodb';
|
|
3
3
|
import { Context, Root } from '@unchainedshop/types/api.js';
|
|
4
|
+
import { PaymentProvider } from '@unchainedshop/types/payments.js';
|
|
4
5
|
|
|
5
6
|
export default async function paymentProvidersCount(
|
|
6
7
|
root: Root,
|
|
7
|
-
params:
|
|
8
|
+
params: mongodb.Filter<PaymentProvider>,
|
|
8
9
|
{ modules, userId }: Context,
|
|
9
10
|
) {
|
|
10
11
|
log(`query paymentProvidersCount ${params.type}`, { userId });
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
AssortmentText,
|
|
9
9
|
} from '@unchainedshop/types/assortments.js';
|
|
10
10
|
import { AssortmentMedia } from '@unchainedshop/types/assortments.media.js';
|
|
11
|
-
import { Query } from '@unchainedshop/types/common.js';
|
|
12
11
|
import { SearchFilterQuery, SearchProducts } from '@unchainedshop/types/filters.js';
|
|
13
12
|
|
|
14
13
|
type HelperType<P, T> = (assortment: AssortmentType, params: P, context: Context) => T;
|
|
@@ -68,13 +67,11 @@ export const Assortment: AssortmentHelperTypes = {
|
|
|
68
67
|
});
|
|
69
68
|
const assortmentIds = assortmentChildLinks.map(({ childAssortmentId }) => childAssortmentId);
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
return modules.assortments.count({
|
|
72
71
|
assortmentIds,
|
|
73
72
|
includeInactive,
|
|
74
73
|
includeLeaves: true,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
return modules.assortments.count(selector);
|
|
74
|
+
});
|
|
78
75
|
},
|
|
79
76
|
|
|
80
77
|
filterAssignments: async (obj, _, { modules }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from '@unchainedshop/types/api.js';
|
|
2
|
-
import { Event as EventType } from '@unchainedshop/
|
|
2
|
+
import { Event as EventType } from '@unchainedshop/core-events';
|
|
3
3
|
|
|
4
4
|
export type HelperType<P, T> = (work: EventType, params: P, context: Context) => T;
|
|
5
5
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Context } from '@unchainedshop/types/api.js';
|
|
2
2
|
import { Work as WorkType } from '@unchainedshop/types/worker.js';
|
|
3
|
+
import { buildObfuscatedFieldsFilter } from '@unchainedshop/utils';
|
|
3
4
|
|
|
4
5
|
type HelperType<P, T> = (work: WorkType, params: P, context: Context) => T;
|
|
5
6
|
|
|
6
7
|
export interface WorkHelperTypes {
|
|
7
8
|
status: HelperType<never, string>;
|
|
8
9
|
type: HelperType<never, string>;
|
|
10
|
+
result: HelperType<never, any>;
|
|
11
|
+
input: HelperType<never, any>;
|
|
12
|
+
error: HelperType<never, any>;
|
|
9
13
|
original: HelperType<never, Promise<WorkType>>;
|
|
10
14
|
}
|
|
11
15
|
|
|
@@ -22,4 +26,16 @@ export const Work: WorkHelperTypes = {
|
|
|
22
26
|
if (!obj.originalWorkId) return null;
|
|
23
27
|
return modules.worker.findWork({ workId: obj.originalWorkId });
|
|
24
28
|
},
|
|
29
|
+
|
|
30
|
+
input: (obj, _, { options }: Context) => {
|
|
31
|
+
return buildObfuscatedFieldsFilter(options.worker?.blacklistedVariables)(obj.input);
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
result: (obj, _, { options }: Context) => {
|
|
35
|
+
return buildObfuscatedFieldsFilter(options.worker?.blacklistedVariables)(obj.result);
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
error: (obj, _, { options }: Context) => {
|
|
39
|
+
return buildObfuscatedFieldsFilter(options.worker?.blacklistedVariables)(obj.error);
|
|
40
|
+
},
|
|
25
41
|
};
|
package/src/roles/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Roles, Role } from '@unchainedshop/roles';
|
|
2
|
-
|
|
3
2
|
import { all } from './all.js';
|
|
4
3
|
import { loggedIn } from './loggedIn.js';
|
|
5
4
|
import { admin } from './admin.js';
|
|
@@ -139,6 +138,4 @@ const configureRoles = ({ additionalRoles = {}, additionalActions = [] }) => {
|
|
|
139
138
|
return allRoles;
|
|
140
139
|
};
|
|
141
140
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
export { allRoles, actions, configureRoles, updateUserRole };
|
|
141
|
+
export { allRoles, actions, configureRoles };
|
package/src/schema/index.ts
CHANGED
|
@@ -6,17 +6,13 @@ import query from './query.js';
|
|
|
6
6
|
import mutation from './mutation.js';
|
|
7
7
|
|
|
8
8
|
export const buildDefaultTypeDefs = ({ actions = [], events = [], workTypes = [] }) => {
|
|
9
|
-
const dynamicTypeDefs =
|
|
10
|
-
extend enum RoleAction {
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
extend enum WorkType {
|
|
17
|
-
${workTypes.join(',')}
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
9
|
+
const dynamicTypeDefs = [
|
|
10
|
+
actions?.length && `extend enum RoleAction { ${actions.join(',')} }`,
|
|
11
|
+
events?.length && `extend enum EventType { ${events.join(',')} }`,
|
|
12
|
+
workTypes?.length && `extend enum WorkType { ${workTypes.join(',')} }`,
|
|
13
|
+
]
|
|
14
|
+
.filter(Boolean)
|
|
15
|
+
.join('\n');
|
|
20
16
|
|
|
21
17
|
return [...scalars, ...directives, ...types, ...inputTypes, ...query, ...mutation, dynamicTypeDefs];
|
|
22
18
|
};
|