softkave-node-utils 0.1.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 +3 -0
- package/build/src/contexts/SessionContext.d.ts +15 -0
- package/build/src/contexts/SessionContext.js +70 -0
- package/build/src/contexts/SessionContext.js.map +1 -0
- package/build/src/contexts/asyncLocalStorage.d.ts +27 -0
- package/build/src/contexts/asyncLocalStorage.js +115 -0
- package/build/src/contexts/asyncLocalStorage.js.map +1 -0
- package/build/src/contexts/config.d.ts +49 -0
- package/build/src/contexts/config.js +25 -0
- package/build/src/contexts/config.js.map +1 -0
- package/build/src/contexts/data/BaseMongoDataProvider.d.ts +21 -0
- package/build/src/contexts/data/BaseMongoDataProvider.js +157 -0
- package/build/src/contexts/data/BaseMongoDataProvider.js.map +1 -0
- package/build/src/contexts/data/MongoDataProviderUtils.d.ts +6 -0
- package/build/src/contexts/data/MongoDataProviderUtils.js +35 -0
- package/build/src/contexts/data/MongoDataProviderUtils.js.map +1 -0
- package/build/src/contexts/data/dataQueryToMongoQuery.d.ts +3 -0
- package/build/src/contexts/data/dataQueryToMongoQuery.js +85 -0
- package/build/src/contexts/data/dataQueryToMongoQuery.js.map +1 -0
- package/build/src/contexts/data/types.d.ts +114 -0
- package/build/src/contexts/data/types.js +15 -0
- package/build/src/contexts/data/types.js.map +1 -0
- package/build/src/contexts/data/utils.d.ts +2 -0
- package/build/src/contexts/data/utils.js +24 -0
- package/build/src/contexts/data/utils.js.map +1 -0
- package/build/src/contexts/email/SESEmailProviderContext.d.ts +9 -0
- package/build/src/contexts/email/SESEmailProviderContext.js +49 -0
- package/build/src/contexts/email/SESEmailProviderContext.js.map +1 -0
- package/build/src/contexts/email/types.d.ts +13 -0
- package/build/src/contexts/email/types.js +3 -0
- package/build/src/contexts/email/types.js.map +1 -0
- package/build/src/contexts/encryption/AWSSecretsManagerProvider.d.ts +12 -0
- package/build/src/contexts/encryption/AWSSecretsManagerProvider.js +51 -0
- package/build/src/contexts/encryption/AWSSecretsManagerProvider.js.map +1 -0
- package/build/src/contexts/encryption/MemorySecretsManagerProvider.d.ts +12 -0
- package/build/src/contexts/encryption/MemorySecretsManagerProvider.js +35 -0
- package/build/src/contexts/encryption/MemorySecretsManagerProvider.js.map +1 -0
- package/build/src/contexts/encryption/types.d.ts +29 -0
- package/build/src/contexts/encryption/types.js +3 -0
- package/build/src/contexts/encryption/types.js.map +1 -0
- package/build/src/contexts/globalUtils.d.ts +2 -0
- package/build/src/contexts/globalUtils.js +17 -0
- package/build/src/contexts/globalUtils.js.map +1 -0
- package/build/src/contexts/injection/injectables.d.ts +56 -0
- package/build/src/contexts/injection/injectables.js +26 -0
- package/build/src/contexts/injection/injectables.js.map +1 -0
- package/build/src/contexts/injection/keys.d.ts +22 -0
- package/build/src/contexts/injection/keys.js +33 -0
- package/build/src/contexts/injection/keys.js.map +1 -0
- package/build/src/contexts/injection/register.d.ts +33 -0
- package/build/src/contexts/injection/register.js +107 -0
- package/build/src/contexts/injection/register.js.map +1 -0
- package/build/src/contexts/logger/noop.d.ts +5 -0
- package/build/src/contexts/logger/noop.js +12 -0
- package/build/src/contexts/logger/noop.js.map +1 -0
- package/build/src/contexts/logger/types.d.ts +11 -0
- package/build/src/contexts/logger/types.js +8 -0
- package/build/src/contexts/logger/types.js.map +1 -0
- package/build/src/contexts/logger/utils.d.ts +2 -0
- package/build/src/contexts/logger/utils.js +15 -0
- package/build/src/contexts/logger/utils.js.map +1 -0
- package/build/src/contexts/semantic/DataSemanticDataAccessBaseProvider.d.ts +28 -0
- package/build/src/contexts/semantic/DataSemanticDataAccessBaseProvider.js +115 -0
- package/build/src/contexts/semantic/DataSemanticDataAccessBaseProvider.js.map +1 -0
- package/build/src/contexts/semantic/types.d.ts +48 -0
- package/build/src/contexts/semantic/types.js +3 -0
- package/build/src/contexts/semantic/types.js.map +1 -0
- package/build/src/contexts/semantic/utils.d.ts +16 -0
- package/build/src/contexts/semantic/utils.js +68 -0
- package/build/src/contexts/semantic/utils.js.map +1 -0
- package/build/src/contexts/types.d.ts +6 -0
- package/build/src/contexts/types.js +3 -0
- package/build/src/contexts/types.js.map +1 -0
- package/build/src/definitions/agent.d.ts +10 -0
- package/build/src/definitions/agent.js +3 -0
- package/build/src/definitions/agent.js.map +1 -0
- package/build/src/definitions/resource.d.ts +17 -0
- package/build/src/definitions/resource.js +3 -0
- package/build/src/definitions/resource.js.map +1 -0
- package/build/src/definitions/resourceTypes.d.ts +10 -0
- package/build/src/definitions/resourceTypes.js +19 -0
- package/build/src/definitions/resourceTypes.js.map +1 -0
- package/build/src/definitions/token.d.ts +17 -0
- package/build/src/definitions/token.js +10 -0
- package/build/src/definitions/token.js.map +1 -0
- package/build/src/endpoints/RequestData.d.ts +20 -0
- package/build/src/endpoints/RequestData.js +52 -0
- package/build/src/endpoints/RequestData.js.map +1 -0
- package/build/src/endpoints/constants.d.ts +20 -0
- package/build/src/endpoints/constants.js +24 -0
- package/build/src/endpoints/constants.js.map +1 -0
- package/build/src/endpoints/endpoints.d.ts +7 -0
- package/build/src/endpoints/endpoints.js +33 -0
- package/build/src/endpoints/endpoints.js.map +1 -0
- package/build/src/endpoints/endpoints.mddoc.d.ts +62 -0
- package/build/src/endpoints/endpoints.mddoc.js +437 -0
- package/build/src/endpoints/endpoints.mddoc.js.map +1 -0
- package/build/src/endpoints/extractors.d.ts +9 -0
- package/build/src/endpoints/extractors.js +24 -0
- package/build/src/endpoints/extractors.js.map +1 -0
- package/build/src/endpoints/jobs/types.d.ts +6 -0
- package/build/src/endpoints/jobs/types.js +3 -0
- package/build/src/endpoints/jobs/types.js.map +1 -0
- package/build/src/endpoints/pagination.d.ts +3 -0
- package/build/src/endpoints/pagination.js +27 -0
- package/build/src/endpoints/pagination.js.map +1 -0
- package/build/src/endpoints/types.d.ts +68 -0
- package/build/src/endpoints/types.js +13 -0
- package/build/src/endpoints/types.js.map +1 -0
- package/build/src/endpoints/utils.d.ts +23 -0
- package/build/src/endpoints/utils.js +131 -0
- package/build/src/endpoints/utils.js.map +1 -0
- package/build/src/endpoints/validation.d.ts +47 -0
- package/build/src/endpoints/validation.js +73 -0
- package/build/src/endpoints/validation.js.map +1 -0
- package/build/src/errors/OperationError.d.ts +20 -0
- package/build/src/errors/OperationError.js +38 -0
- package/build/src/errors/OperationError.js.map +1 -0
- package/build/src/errors/commonErrors.d.ts +24 -0
- package/build/src/errors/commonErrors.js +72 -0
- package/build/src/errors/commonErrors.js.map +1 -0
- package/build/src/errors/endpointErrors.d.ts +31 -0
- package/build/src/errors/endpointErrors.js +83 -0
- package/build/src/errors/endpointErrors.js.map +1 -0
- package/build/src/errors/messages.d.ts +11 -0
- package/build/src/errors/messages.js +27 -0
- package/build/src/errors/messages.js.map +1 -0
- package/build/src/errors/reusableErrors.d.ts +12 -0
- package/build/src/errors/reusableErrors.js +25 -0
- package/build/src/errors/reusableErrors.js.map +1 -0
- package/build/src/errors/sessionErrors.d.ts +18 -0
- package/build/src/errors/sessionErrors.js +60 -0
- package/build/src/errors/sessionErrors.js.map +1 -0
- package/build/src/index.d.ts +0 -0
- package/build/src/index.js +2 -0
- package/build/src/index.js.map +1 -0
- package/build/src/mddoc/jsSdkCodeGen.d.ts +7 -0
- package/build/src/mddoc/jsSdkCodeGen.js +546 -0
- package/build/src/mddoc/jsSdkCodeGen.js.map +1 -0
- package/build/src/mddoc/mddoc.d.ts +206 -0
- package/build/src/mddoc/mddoc.js +142 -0
- package/build/src/mddoc/mddoc.js.map +1 -0
- package/build/src/mddoc/restApiEndpointsInfoGen.d.ts +10 -0
- package/build/src/mddoc/restApiEndpointsInfoGen.js +92 -0
- package/build/src/mddoc/restApiEndpointsInfoGen.js.map +1 -0
- package/build/src/mddoc/restApiTableOfContentGen.d.ts +2 -0
- package/build/src/mddoc/restApiTableOfContentGen.js +51 -0
- package/build/src/mddoc/restApiTableOfContentGen.js.map +1 -0
- package/build/src/mongodb/connection.d.ts +26 -0
- package/build/src/mongodb/connection.js +50 -0
- package/build/src/mongodb/connection.js.map +1 -0
- package/build/src/mongodb/constants.d.ts +4 -0
- package/build/src/mongodb/constants.js +7 -0
- package/build/src/mongodb/constants.js.map +1 -0
- package/build/src/mongodb/utils.d.ts +20 -0
- package/build/src/mongodb/utils.js +26 -0
- package/build/src/mongodb/utils.js.map +1 -0
- package/build/src/testUtils/context/email/MockTestEmailProviderContext.d.ts +6 -0
- package/build/src/testUtils/context/email/MockTestEmailProviderContext.js +10 -0
- package/build/src/testUtils/context/email/MockTestEmailProviderContext.js.map +1 -0
- package/build/src/testUtils/context/email/NoopEmailProviderContext.d.ts +6 -0
- package/build/src/testUtils/context/email/NoopEmailProviderContext.js +11 -0
- package/build/src/testUtils/context/email/NoopEmailProviderContext.js.map +1 -0
- package/build/src/testUtils/context/email/TestSESEmailProviderContext.d.ts +8 -0
- package/build/src/testUtils/context/email/TestSESEmailProviderContext.js +14 -0
- package/build/src/testUtils/context/email/TestSESEmailProviderContext.js.map +1 -0
- package/build/src/testUtils/context/types.d.ts +9 -0
- package/build/src/testUtils/context/types.js +3 -0
- package/build/src/testUtils/context/types.js.map +1 -0
- package/build/src/testUtils/generate/utils.d.ts +37 -0
- package/build/src/testUtils/generate/utils.js +79 -0
- package/build/src/testUtils/generate/utils.js.map +1 -0
- package/build/src/testUtils/helpers/assertion.d.ts +25 -0
- package/build/src/testUtils/helpers/assertion.js +63 -0
- package/build/src/testUtils/helpers/assertion.js.map +1 -0
- package/build/src/testUtils/helpers/binary.d.ts +4 -0
- package/build/src/testUtils/helpers/binary.js +19 -0
- package/build/src/testUtils/helpers/binary.js.map +1 -0
- package/build/src/testUtils/helpers/error.d.ts +3 -0
- package/build/src/testUtils/helpers/error.js +43 -0
- package/build/src/testUtils/helpers/error.js.map +1 -0
- package/build/src/testUtils/helpers/mock.d.ts +2 -0
- package/build/src/testUtils/helpers/mock.js +15 -0
- package/build/src/testUtils/helpers/mock.js.map +1 -0
- package/build/src/testUtils/helpers/mongodb.d.ts +3 -0
- package/build/src/testUtils/helpers/mongodb.js +17 -0
- package/build/src/testUtils/helpers/mongodb.js.map +1 -0
- package/build/src/testUtils/helpers/testFns.d.ts +30 -0
- package/build/src/testUtils/helpers/testFns.js +96 -0
- package/build/src/testUtils/helpers/testFns.js.map +1 -0
- package/build/src/testUtils/testUtils.d.ts +13 -0
- package/build/src/testUtils/testUtils.js +50 -0
- package/build/src/testUtils/testUtils.js.map +1 -0
- package/build/src/utils/assertion.d.ts +2 -0
- package/build/src/utils/assertion.js +31 -0
- package/build/src/utils/assertion.js.map +1 -0
- package/build/src/utils/aws.d.ts +5 -0
- package/build/src/utils/aws.js +3 -0
- package/build/src/utils/aws.js.map +1 -0
- package/build/src/utils/streamToBuffer.d.ts +4 -0
- package/build/src/utils/streamToBuffer.js +19 -0
- package/build/src/utils/streamToBuffer.js.map +1 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseTokenData, TokenAccessScope, TokenSubjectDefault } from '../definitions/token';
|
|
2
|
+
export interface SessionContextType {
|
|
3
|
+
decodeToken: (token: string) => BaseTokenData<TokenSubjectDefault>;
|
|
4
|
+
tokenContainsScope: (tokenData: {
|
|
5
|
+
scope: string[];
|
|
6
|
+
}, expectedTokenScopes: TokenAccessScope | TokenAccessScope[]) => boolean;
|
|
7
|
+
encodeToken: (tokenId: string, expires?: string | Date | number | null, issuedAt?: string | Date | number | null) => string;
|
|
8
|
+
}
|
|
9
|
+
export default class SessionContext implements SessionContextType {
|
|
10
|
+
decodeToken: (token: string) => BaseTokenData<TokenSubjectDefault>;
|
|
11
|
+
tokenContainsScope: (tokenData: {
|
|
12
|
+
scope: string[];
|
|
13
|
+
}, expectedTokenScopes: TokenAccessScope | TokenAccessScope[]) => boolean;
|
|
14
|
+
encodeToken: (tokenId: string, expires?: string | Date | number | null, issuedAt?: string | Date | number | null) => string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const date_fns_1 = require("date-fns");
|
|
27
|
+
const jwt = __importStar(require("jsonwebtoken"));
|
|
28
|
+
const lodash_1 = require("lodash");
|
|
29
|
+
const softkave_js_utils_1 = require("softkave-js-utils");
|
|
30
|
+
const token_1 = require("../definitions/token");
|
|
31
|
+
const assertion_1 = require("../utils/assertion");
|
|
32
|
+
const injectables_1 = require("./injection/injectables");
|
|
33
|
+
const sessionErrors_1 = require("../errors/sessionErrors");
|
|
34
|
+
class SessionContext {
|
|
35
|
+
constructor() {
|
|
36
|
+
this.decodeToken = (token) => {
|
|
37
|
+
const suppliedConfig = injectables_1.kUtilsInjectables.suppliedConfig();
|
|
38
|
+
(0, assertion_1.appAssert)(suppliedConfig.jwtSecret);
|
|
39
|
+
const tokenData = (0, softkave_js_utils_1.cast)(jwt.verify(token, suppliedConfig.jwtSecret, { complete: false }));
|
|
40
|
+
if (tokenData.version < token_1.kCurrentJWTTokenVersion) {
|
|
41
|
+
throw new sessionErrors_1.CredentialsExpiredError();
|
|
42
|
+
}
|
|
43
|
+
return tokenData;
|
|
44
|
+
};
|
|
45
|
+
this.tokenContainsScope = (tokenData, expectedTokenScopes) => {
|
|
46
|
+
var _a;
|
|
47
|
+
const tokenScopes = (_a = tokenData.scope) !== null && _a !== void 0 ? _a : [];
|
|
48
|
+
const expectedTokenScopesMap = (0, softkave_js_utils_1.indexArray)((0, softkave_js_utils_1.convertToArray)(expectedTokenScopes), { reducer: () => true, indexer: lodash_1.identity });
|
|
49
|
+
const hasTokenAccessScope = !!tokenScopes.find(nextScope => expectedTokenScopesMap[nextScope]);
|
|
50
|
+
return hasTokenAccessScope;
|
|
51
|
+
};
|
|
52
|
+
this.encodeToken = (tokenId, expires, issuedAt) => {
|
|
53
|
+
const suppliedConfig = injectables_1.kUtilsInjectables.suppliedConfig();
|
|
54
|
+
(0, assertion_1.appAssert)(suppliedConfig.jwtSecret);
|
|
55
|
+
const payload = {
|
|
56
|
+
version: token_1.kCurrentJWTTokenVersion,
|
|
57
|
+
sub: { id: tokenId },
|
|
58
|
+
};
|
|
59
|
+
if (expires) {
|
|
60
|
+
payload.exp = (0, date_fns_1.millisecondsToSeconds)((0, date_fns_1.toDate)(expires).valueOf());
|
|
61
|
+
}
|
|
62
|
+
if (issuedAt) {
|
|
63
|
+
payload.iat = (0, date_fns_1.millisecondsToSeconds)((0, date_fns_1.toDate)(issuedAt).valueOf());
|
|
64
|
+
}
|
|
65
|
+
return jwt.sign(payload, suppliedConfig.jwtSecret);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.default = SessionContext;
|
|
70
|
+
//# sourceMappingURL=SessionContext.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CACZ,OAAe,EACf,OAAuC,EACvC,QAAwC,EACxC,EAAE;YACF,MAAM,cAAc,GAAG,+BAAiB,CAAC,cAAc,EAAE,CAAC;YAC1D,IAAA,qBAAS,EAAC,cAAc,CAAC,SAAS,CAAC,CAAC;YAEpC,MAAM,OAAO,GAAgD;gBAC3D,OAAO,EAAE,+BAAuB;gBAChC,GAAG,EAAE,EAAC,EAAE,EAAE,OAAO,EAAC;aACnB,CAAC;YAEF,IAAI,OAAO,EAAE;gBACX,OAAO,CAAC,GAAG,GAAG,IAAA,gCAAqB,EAAC,IAAA,iBAAM,EAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;aAChE;YAED,IAAI,QAAQ,EAAE;gBACZ,OAAO,CAAC,GAAG,GAAG,IAAA,gCAAqB,EAAC,IAAA,iBAAM,EAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;aACjE;YAED,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;QACrD,CAAC,CAAC;IACJ,CAAC;CAAA;AAtDD,iCAsDC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
|
+
import { AnyFn, AnyObject, DisposablesStore } from 'softkave-js-utils';
|
|
4
|
+
import { ReadonlyDeep } from 'type-fest';
|
|
5
|
+
export type FimidaraAsyncLocalStorageStore = Record<string, unknown>;
|
|
6
|
+
export type FimidaraAsyncLocalStorage = AsyncLocalStorage<FimidaraAsyncLocalStorageStore>;
|
|
7
|
+
export interface AsyncLocalStorageUtils {
|
|
8
|
+
run: <TFn extends AnyFn>(cb: TFn, store?: AnyObject) => Promise<ReturnType<TFn>>;
|
|
9
|
+
inheritAndRun: <TFn extends AnyFn>(cb: TFn, store?: AnyObject) => Promise<ReturnType<TFn>>;
|
|
10
|
+
get: <T = unknown>(key: string) => T | undefined;
|
|
11
|
+
getStore: () => ReadonlyDeep<AnyObject>;
|
|
12
|
+
set: <T = unknown>(key: string, value: T) => T;
|
|
13
|
+
/** Set if `key` does not exist in store, or use `run()` inheriting parent
|
|
14
|
+
* store to shadow set `key`. Shadow setting means shadow keys are stored in a
|
|
15
|
+
* separate store so they don't collide, but other keys are store in the
|
|
16
|
+
* closest real parent store. */
|
|
17
|
+
shadowSet: <TFn extends AnyFn>(key: string, value: unknown, cb: TFn) => Promise<ReturnType<TFn>>;
|
|
18
|
+
/** Like `shadowSet` but creates a shadow store whether key exists or not. */
|
|
19
|
+
shadowSetForce: <TFn extends AnyFn>(key: string, value: unknown, cb: TFn) => Promise<ReturnType<TFn>>;
|
|
20
|
+
delete: (key: string) => void;
|
|
21
|
+
disposables: () => DisposablesStore;
|
|
22
|
+
}
|
|
23
|
+
export declare const kAsyncLocalStorageUtils: AsyncLocalStorageUtils;
|
|
24
|
+
export declare const kAsyncLocalStorageKeys: {
|
|
25
|
+
txn: string;
|
|
26
|
+
disposables: string;
|
|
27
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.kAsyncLocalStorageKeys = exports.kAsyncLocalStorageUtils = void 0;
|
|
4
|
+
const async_hooks_1 = require("async_hooks");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const softkave_js_utils_1 = require("softkave-js-utils");
|
|
7
|
+
const injectables_1 = require("./injection/injectables");
|
|
8
|
+
const asyncLocalStorage = new async_hooks_1.AsyncLocalStorage();
|
|
9
|
+
const kInternalKeys = {
|
|
10
|
+
realStore: Symbol.for('realStore'),
|
|
11
|
+
};
|
|
12
|
+
function getAsyncLocalStore() {
|
|
13
|
+
var _a;
|
|
14
|
+
return (_a = asyncLocalStorage.getStore()) !== null && _a !== void 0 ? _a : {};
|
|
15
|
+
}
|
|
16
|
+
function startShadowStore(realStore) {
|
|
17
|
+
const shadowStore = {};
|
|
18
|
+
shadowStore[kInternalKeys.realStore] = realStore;
|
|
19
|
+
return shadowStore;
|
|
20
|
+
}
|
|
21
|
+
/** Returns immedaite real store from shadow store. The real store returned may
|
|
22
|
+
* itself be a shadow of another store. */
|
|
23
|
+
function getImmediateRealStore(shadowStore) {
|
|
24
|
+
return shadowStore ? shadowStore[kInternalKeys.realStore] : undefined;
|
|
25
|
+
}
|
|
26
|
+
function shadowGet(store, key) {
|
|
27
|
+
let item;
|
|
28
|
+
for (; store && !item; store = getImmediateRealStore(store)) {
|
|
29
|
+
item = (0, lodash_1.get)(store, key);
|
|
30
|
+
}
|
|
31
|
+
return item;
|
|
32
|
+
}
|
|
33
|
+
function getDeepestRealStore(store) {
|
|
34
|
+
let realStore;
|
|
35
|
+
for (; store; store = getImmediateRealStore(store)) {
|
|
36
|
+
realStore = store;
|
|
37
|
+
}
|
|
38
|
+
return realStore;
|
|
39
|
+
}
|
|
40
|
+
function shadowSet(store, key, value) {
|
|
41
|
+
const realStore = getDeepestRealStore(store);
|
|
42
|
+
if (realStore) {
|
|
43
|
+
(0, lodash_1.set)(realStore, key, value);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function shadowDelete(store, key) {
|
|
47
|
+
const realStore = getDeepestRealStore(store);
|
|
48
|
+
if (realStore) {
|
|
49
|
+
delete realStore[key];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function isShadowStore(store) {
|
|
53
|
+
return !!getImmediateRealStore(store);
|
|
54
|
+
}
|
|
55
|
+
exports.kAsyncLocalStorageUtils = {
|
|
56
|
+
run: (cb, store = {}) => {
|
|
57
|
+
return asyncLocalStorage.run(store, async () => {
|
|
58
|
+
try {
|
|
59
|
+
return await cb();
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
if (!isShadowStore(getAsyncLocalStore())) {
|
|
63
|
+
exports.kAsyncLocalStorageUtils.disposables().disposeAll();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
inheritAndRun: (cb, store = {}) => {
|
|
69
|
+
return exports.kAsyncLocalStorageUtils.run(cb, (0, softkave_js_utils_1.mergeObjects)(store, getAsyncLocalStore(), {
|
|
70
|
+
arrayUpdateStrategy: 'replace',
|
|
71
|
+
}));
|
|
72
|
+
},
|
|
73
|
+
get: (key) => {
|
|
74
|
+
var _a;
|
|
75
|
+
return shadowGet((_a = asyncLocalStorage.getStore()) !== null && _a !== void 0 ? _a : {}, key);
|
|
76
|
+
},
|
|
77
|
+
set: (key, value) => {
|
|
78
|
+
var _a;
|
|
79
|
+
shadowSet((_a = asyncLocalStorage.getStore()) !== null && _a !== void 0 ? _a : {}, key, value);
|
|
80
|
+
return value;
|
|
81
|
+
},
|
|
82
|
+
delete: (key) => {
|
|
83
|
+
var _a;
|
|
84
|
+
// TODO: delete deep
|
|
85
|
+
const store = (_a = asyncLocalStorage.getStore()) !== null && _a !== void 0 ? _a : {};
|
|
86
|
+
shadowDelete(store, key);
|
|
87
|
+
},
|
|
88
|
+
disposables() {
|
|
89
|
+
return (this.get(exports.kAsyncLocalStorageKeys.disposables) ||
|
|
90
|
+
this.set(exports.kAsyncLocalStorageKeys.disposables, new softkave_js_utils_1.DisposablesStore(injectables_1.kUtilsInjectables.promises())));
|
|
91
|
+
},
|
|
92
|
+
getStore() {
|
|
93
|
+
var _a;
|
|
94
|
+
return (_a = asyncLocalStorage.getStore()) !== null && _a !== void 0 ? _a : {};
|
|
95
|
+
},
|
|
96
|
+
shadowSet: (key, value, cb) => {
|
|
97
|
+
if (exports.kAsyncLocalStorageUtils.get(key)) {
|
|
98
|
+
return exports.kAsyncLocalStorageUtils.shadowSetForce(key, value, cb);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
exports.kAsyncLocalStorageUtils.set(key, value);
|
|
102
|
+
return cb();
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
shadowSetForce: async (key, value, cb) => {
|
|
106
|
+
const shadowStore = startShadowStore(getAsyncLocalStore());
|
|
107
|
+
(0, lodash_1.set)(shadowStore, key, value);
|
|
108
|
+
return await exports.kAsyncLocalStorageUtils.run(cb, shadowStore);
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
exports.kAsyncLocalStorageKeys = {
|
|
112
|
+
txn: 'txn',
|
|
113
|
+
disposables: 'disposables',
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=asyncLocalStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asyncLocalStorage.js","sourceRoot":"","sources":["../../../src/contexts/asyncLocalStorage.ts"],"names":[],"mappings":";;;AAAA,6CAA8C;AAC9C,mCAAgC;AAChC,yDAK2B;AAE3B,yDAA0D;AAqC1D,MAAM,iBAAiB,GACrB,IAAI,+BAAiB,EAAkC,CAAC;AAE1D,MAAM,aAAa,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC;CACnC,CAAC;AAEF,SAAS,kBAAkB;;IACzB,OAAO,MAAA,iBAAiB,CAAC,QAAQ,EAAE,mCAAI,EAAE,CAAC;AAC5C,CAAC;AAED,SAAS,gBAAgB,CAAC,SAAqB;IAC7C,MAAM,WAAW,GAAc,EAAE,CAAC;IAClC,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IACjD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;0CAC0C;AAC1C,SAAS,qBAAqB,CAC5B,WAAkC;IAElC,OAAO,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACxE,CAAC;AAED,SAAS,SAAS,CAAC,KAA4B,EAAE,GAAW;IAC1D,IAAI,IAAyB,CAAC;IAE9B,OAAO,KAAK,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,EAAE;QAC3D,IAAI,GAAG,IAAA,YAAG,EAAC,KAAK,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,GAAG,EAAE,KAAK,CAAC,CAAC;YACxC,OAAO,EAAE,EAAE,CAAC;SACb;IACH,CAAC;IAED,cAAc,EAAE,KAAK,EACnB,GAAW,EACX,KAAc,EACd,EAAO,EACP,EAAE;QACF,MAAM,WAAW,GAAG,gBAAgB,CAAC,kBAAkB,EAAE,CAAC,CAAC;QAC3D,IAAA,YAAG,EAAC,WAAW,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7B,OAAO,MAAM,+BAAuB,CAAC,GAAG,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IAC5D,CAAC;CACF,CAAC;AAEW,QAAA,sBAAsB,GAAG;IACpC,GAAG,EAAE,KAAK;IACV,WAAW,EAAE,aAAa;CAC3B,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LoggerType } from 'softkave-js-utils';
|
|
2
|
+
import { ValueOf } from 'type-fest';
|
|
3
|
+
import { AWSConfig } from '../utils/aws';
|
|
4
|
+
export declare const kFimidaraConfigEmailProvider: {
|
|
5
|
+
readonly ses: "ses";
|
|
6
|
+
readonly noop: "noop";
|
|
7
|
+
};
|
|
8
|
+
export type FimidaraConfigEmailProvider = ValueOf<typeof kFimidaraConfigEmailProvider>;
|
|
9
|
+
export declare const kFimidaraConfigSecretsManagerProvider: {
|
|
10
|
+
readonly awsSecretsManager: "awsSecretsManager";
|
|
11
|
+
readonly memory: "memory";
|
|
12
|
+
};
|
|
13
|
+
export type FimidaraConfigSecretsManagerProvider = ValueOf<typeof kFimidaraConfigSecretsManagerProvider>;
|
|
14
|
+
export declare const kFimidaraConfigDbType: {
|
|
15
|
+
readonly mongoDb: "mongoDb";
|
|
16
|
+
readonly noop: "noop";
|
|
17
|
+
};
|
|
18
|
+
export type FimidaraConfigDbType = ValueOf<typeof kFimidaraConfigDbType>;
|
|
19
|
+
export type FimidaraSuppliedConfig = Partial<{
|
|
20
|
+
clientDomain: string;
|
|
21
|
+
dbType: FimidaraConfigDbType;
|
|
22
|
+
mongoDbURI: string;
|
|
23
|
+
mongoDbDatabaseName: string;
|
|
24
|
+
jwtSecret: string;
|
|
25
|
+
exposeHttpServer: boolean;
|
|
26
|
+
httpPort: string;
|
|
27
|
+
exposeHttpsServer: boolean;
|
|
28
|
+
httpsPort: string;
|
|
29
|
+
httpsPublicKeyFilepath: string;
|
|
30
|
+
httpsPrivateKeyFilepath: string;
|
|
31
|
+
emailProvider: FimidaraConfigEmailProvider;
|
|
32
|
+
secretsManagerProvider: FimidaraConfigSecretsManagerProvider;
|
|
33
|
+
awsConfig: AWSConfig;
|
|
34
|
+
appName: string;
|
|
35
|
+
appDefaultEmailAddressFrom: string;
|
|
36
|
+
awsEmailEncoding: string;
|
|
37
|
+
dateFormat: string;
|
|
38
|
+
clientLoginLink: string;
|
|
39
|
+
clientSignupLink: string;
|
|
40
|
+
changePasswordLink: string;
|
|
41
|
+
verifyEmailLink: string;
|
|
42
|
+
test: {
|
|
43
|
+
awsConfig?: AWSConfig;
|
|
44
|
+
bucket?: string;
|
|
45
|
+
};
|
|
46
|
+
loggerType: LoggerType;
|
|
47
|
+
}>;
|
|
48
|
+
export type FimidaraConfig = FimidaraSuppliedConfig;
|
|
49
|
+
export declare function getSuppliedConfig(): FimidaraSuppliedConfig;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getSuppliedConfig = exports.kFimidaraConfigDbType = exports.kFimidaraConfigSecretsManagerProvider = exports.kFimidaraConfigEmailProvider = void 0;
|
|
7
|
+
const config_1 = __importDefault(require("config"));
|
|
8
|
+
exports.kFimidaraConfigEmailProvider = {
|
|
9
|
+
ses: 'ses',
|
|
10
|
+
noop: 'noop',
|
|
11
|
+
};
|
|
12
|
+
exports.kFimidaraConfigSecretsManagerProvider = {
|
|
13
|
+
awsSecretsManager: 'awsSecretsManager',
|
|
14
|
+
memory: 'memory',
|
|
15
|
+
};
|
|
16
|
+
exports.kFimidaraConfigDbType = {
|
|
17
|
+
mongoDb: 'mongoDb',
|
|
18
|
+
noop: 'noop',
|
|
19
|
+
};
|
|
20
|
+
function getSuppliedConfig() {
|
|
21
|
+
const envSuppliedConfig = config_1.default.util.toObject();
|
|
22
|
+
return envSuppliedConfig;
|
|
23
|
+
}
|
|
24
|
+
exports.getSuppliedConfig = getSuppliedConfig;
|
|
25
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/contexts/config.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAKf,QAAA,4BAA4B,GAAG;IAC1C,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;CACJ,CAAC;AAME,QAAA,qCAAqC,GAAG;IACnD,iBAAiB,EAAE,mBAAmB;IACtC,MAAM,EAAE,QAAQ;CACR,CAAC;AAME,QAAA,qBAAqB,GAAG;IACnC,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;CACJ,CAAC;AAoCX,SAAgB,iBAAiB;IAC/B,MAAM,iBAAiB,GAAG,gBAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;IACjD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAHD,8CAGC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AnyObject, Model } from 'mongoose';
|
|
2
|
+
import { BaseDataProvider, BulkOpItem, DataProviderOpParams, DataProviderQueryListParams, DataProviderQueryParams, DataQuery } from './types';
|
|
3
|
+
export declare abstract class BaseMongoDataProvider<T extends AnyObject, TQuery extends DataQuery<AnyObject> = DataQuery<T>> implements BaseDataProvider<T, TQuery> {
|
|
4
|
+
abstract throwNotFound: () => void;
|
|
5
|
+
model: Model<T>;
|
|
6
|
+
constructor(model: Model<T>);
|
|
7
|
+
insertItem: (item: T, otherProps?: DataProviderOpParams | undefined) => Promise<T>;
|
|
8
|
+
insertList: (items: T[], otherProps?: DataProviderOpParams | undefined) => Promise<void>;
|
|
9
|
+
getManyByQuery: (query: TQuery, otherProps?: DataProviderQueryListParams<T> | undefined) => Promise<T[]>;
|
|
10
|
+
getOneByQuery: (query: TQuery, otherProps?: DataProviderQueryParams<T> | undefined) => Promise<T | null>;
|
|
11
|
+
assertGetOneByQuery: (query: TQuery, otherProps?: DataProviderQueryParams<T> | undefined) => Promise<T>;
|
|
12
|
+
updateManyByQuery: (query: TQuery, data: Partial<T>, otherProps?: DataProviderOpParams | undefined) => Promise<void>;
|
|
13
|
+
updateOneByQuery: (query: TQuery, data: Partial<T>, otherProps?: DataProviderOpParams | undefined) => Promise<void>;
|
|
14
|
+
getAndUpdateOneByQuery: (query: TQuery, data: Partial<T>, otherProps?: DataProviderQueryParams<T> | undefined) => Promise<T>;
|
|
15
|
+
assertGetAndUpdateOneByQuery: (query: TQuery, data: Partial<T>, otherProps?: DataProviderQueryParams<T> | undefined) => Promise<T>;
|
|
16
|
+
existsByQuery: <ExtendedQueryType extends TQuery = TQuery>(query: ExtendedQueryType, otherProps?: DataProviderOpParams | undefined) => Promise<boolean>;
|
|
17
|
+
countByQuery: <ExtendedQueryType extends TQuery = TQuery>(query: ExtendedQueryType, otherProps?: DataProviderOpParams | undefined) => Promise<number>;
|
|
18
|
+
deleteManyByQuery: <ExtendedQueryType extends TQuery = TQuery>(query: ExtendedQueryType, otherProps?: DataProviderOpParams | undefined) => Promise<void>;
|
|
19
|
+
deleteOneByQuery: <ExtendedQueryType extends TQuery = TQuery>(query: ExtendedQueryType, otherProps?: DataProviderOpParams | undefined) => Promise<void>;
|
|
20
|
+
bulkWrite(ops: BulkOpItem<T>[], otherProps?: DataProviderOpParams | undefined): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseMongoDataProvider = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
// eslint-disable-next-line node/no-extraneous-import
|
|
7
|
+
const dataQueryToMongoQuery_1 = require("./dataQueryToMongoQuery");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
function getMongoQueryOptionsForOp(params) {
|
|
10
|
+
return { session: params === null || params === void 0 ? void 0 : params.txn, lean: true };
|
|
11
|
+
}
|
|
12
|
+
function getMongoBulkWriteOptions(params) {
|
|
13
|
+
return { session: params === null || params === void 0 ? void 0 : params.txn };
|
|
14
|
+
}
|
|
15
|
+
function getMongoQueryOptionsForOne(
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
params) {
|
|
18
|
+
return { ...getMongoQueryOptionsForOp(params), projection: params === null || params === void 0 ? void 0 : params.projection };
|
|
19
|
+
}
|
|
20
|
+
function getMongoQueryOptionsForMany(
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
params) {
|
|
23
|
+
const page = (0, utils_1.getPage)(params === null || params === void 0 ? void 0 : params.page);
|
|
24
|
+
const pageSize = (0, utils_1.getPageSize)(params === null || params === void 0 ? void 0 : params.pageSize, page);
|
|
25
|
+
const skip = (0, lodash_1.isNumber)(page) && (0, lodash_1.isNumber)(pageSize)
|
|
26
|
+
? Math.max(page, 0) * pageSize
|
|
27
|
+
: undefined;
|
|
28
|
+
return {
|
|
29
|
+
...getMongoQueryOptionsForOp(params),
|
|
30
|
+
skip,
|
|
31
|
+
limit: pageSize,
|
|
32
|
+
projection: params === null || params === void 0 ? void 0 : params.projection,
|
|
33
|
+
sort: params === null || params === void 0 ? void 0 : params.sort,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
class BaseMongoDataProvider {
|
|
37
|
+
constructor(model) {
|
|
38
|
+
this.insertItem = async (item, otherProps) => {
|
|
39
|
+
await this.insertList([item], otherProps);
|
|
40
|
+
return item;
|
|
41
|
+
};
|
|
42
|
+
this.insertList = async (items, otherProps) => {
|
|
43
|
+
await this.model.insertMany(items, getMongoQueryOptionsForOp(otherProps));
|
|
44
|
+
};
|
|
45
|
+
this.getManyByQuery = async (query, otherProps) => {
|
|
46
|
+
const mongoQuery = (0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(query);
|
|
47
|
+
const items = await this.model
|
|
48
|
+
.find(mongoQuery, otherProps === null || otherProps === void 0 ? void 0 : otherProps.projection, getMongoQueryOptionsForMany(otherProps))
|
|
49
|
+
.lean()
|
|
50
|
+
.exec();
|
|
51
|
+
return items;
|
|
52
|
+
};
|
|
53
|
+
this.getOneByQuery = async (query, otherProps) => {
|
|
54
|
+
const opts = getMongoQueryOptionsForOne(otherProps);
|
|
55
|
+
const mQuery = (0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(query);
|
|
56
|
+
const item = await this.model
|
|
57
|
+
.findOne(mQuery, opts.projection, opts)
|
|
58
|
+
.lean()
|
|
59
|
+
.exec();
|
|
60
|
+
return item;
|
|
61
|
+
};
|
|
62
|
+
this.assertGetOneByQuery = async (query, otherProps) => {
|
|
63
|
+
const item = await this.getOneByQuery(query, otherProps);
|
|
64
|
+
if (!item)
|
|
65
|
+
this.throwNotFound();
|
|
66
|
+
return item;
|
|
67
|
+
};
|
|
68
|
+
this.updateManyByQuery = async (query, data, otherProps) => {
|
|
69
|
+
await this.model
|
|
70
|
+
.updateMany((0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(query), data, getMongoQueryOptionsForOp(otherProps))
|
|
71
|
+
.exec();
|
|
72
|
+
};
|
|
73
|
+
this.updateOneByQuery = async (query, data, otherProps) => {
|
|
74
|
+
await this.model
|
|
75
|
+
.updateOne((0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(query), data, getMongoQueryOptionsForOp(otherProps))
|
|
76
|
+
.exec();
|
|
77
|
+
};
|
|
78
|
+
this.getAndUpdateOneByQuery = async (query, data, otherProps) => {
|
|
79
|
+
const item = await this.model
|
|
80
|
+
.findOneAndUpdate((0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(query), data, {
|
|
81
|
+
...getMongoQueryOptionsForOne(otherProps),
|
|
82
|
+
new: true,
|
|
83
|
+
})
|
|
84
|
+
.exec();
|
|
85
|
+
return item;
|
|
86
|
+
};
|
|
87
|
+
this.assertGetAndUpdateOneByQuery = async (query, data, otherProps) => {
|
|
88
|
+
const item = await this.getAndUpdateOneByQuery(query, data, otherProps);
|
|
89
|
+
if (!item)
|
|
90
|
+
this.throwNotFound();
|
|
91
|
+
return item;
|
|
92
|
+
};
|
|
93
|
+
this.existsByQuery = async (query, otherProps) => {
|
|
94
|
+
return !!(await this.getOneByQuery(query, {
|
|
95
|
+
...otherProps,
|
|
96
|
+
projection: '_id',
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
this.countByQuery = async (query, otherProps) => {
|
|
100
|
+
return await this.model
|
|
101
|
+
.countDocuments((0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(query), getMongoQueryOptionsForOp(otherProps))
|
|
102
|
+
.exec();
|
|
103
|
+
};
|
|
104
|
+
this.deleteManyByQuery = async (query, otherProps) => {
|
|
105
|
+
await this.model
|
|
106
|
+
.deleteMany((0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(query), getMongoQueryOptionsForOp(otherProps))
|
|
107
|
+
.exec();
|
|
108
|
+
};
|
|
109
|
+
this.deleteOneByQuery = async (query, otherProps) => {
|
|
110
|
+
await this.model
|
|
111
|
+
.deleteOne((0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(query), getMongoQueryOptionsForOp(otherProps))
|
|
112
|
+
.exec();
|
|
113
|
+
};
|
|
114
|
+
this.model = model;
|
|
115
|
+
}
|
|
116
|
+
async bulkWrite(ops, otherProps) {
|
|
117
|
+
const mongoOps = [];
|
|
118
|
+
ops.forEach(op => {
|
|
119
|
+
let mongoOp = null;
|
|
120
|
+
switch (op.type) {
|
|
121
|
+
case types_1.BulkOpType.InsertOne:
|
|
122
|
+
mongoOp = { insertOne: { document: op.item } };
|
|
123
|
+
break;
|
|
124
|
+
case types_1.BulkOpType.UpdateOne:
|
|
125
|
+
mongoOp = {
|
|
126
|
+
updateOne: {
|
|
127
|
+
filter: (0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(op.query),
|
|
128
|
+
update: op.update,
|
|
129
|
+
upsert: op.upsert,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
break;
|
|
133
|
+
case types_1.BulkOpType.UpdateMany:
|
|
134
|
+
mongoOp = {
|
|
135
|
+
updateMany: {
|
|
136
|
+
filter: (0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(op.query),
|
|
137
|
+
update: op.update,
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
break;
|
|
141
|
+
case types_1.BulkOpType.DeleteOne:
|
|
142
|
+
mongoOp = { deleteOne: { filter: (0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(op.query) } };
|
|
143
|
+
break;
|
|
144
|
+
case types_1.BulkOpType.DeleteMany:
|
|
145
|
+
mongoOp = { deleteMany: { filter: (0, dataQueryToMongoQuery_1.dataQueryToMongoQuery)(op.query) } };
|
|
146
|
+
break;
|
|
147
|
+
default: // do nothing
|
|
148
|
+
}
|
|
149
|
+
if (mongoOp) {
|
|
150
|
+
mongoOps.push(mongoOp);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
await this.model.bulkWrite(mongoOps, getMongoBulkWriteOptions(otherProps));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.BaseMongoDataProvider = BaseMongoDataProvider;
|
|
157
|
+
//# sourceMappingURL=BaseMongoDataProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseMongoDataProvider.js","sourceRoot":"","sources":["../../../../src/contexts/data/BaseMongoDataProvider.ts"],"names":[],"mapp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ientSession } from 'mongoose';
|
|
2
|
+
import { AnyFn } from 'softkave-js-utils';
|
|
3
|
+
import { DataProviderUtils } from './types';
|
|
4
|
+
export declare class MongoDataProviderUtils implements DataProviderUtils {
|
|
5
|
+
withTxn<TResult>(fn: AnyFn<[txn: ClientSession], Promise<TResult>>, reuseAsyncLocalTxn?: boolean, existingSession?: unknown): Promise<TResult>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongoDataProviderUtils = void 0;
|
|
4
|
+
const connection_1 = require("../../mongodb/connection");
|
|
5
|
+
const assertion_1 = require("../../utils/assertion");
|
|
6
|
+
const asyncLocalStorage_1 = require("../asyncLocalStorage");
|
|
7
|
+
const injectables_1 = require("../injection/injectables");
|
|
8
|
+
class MongoDataProviderUtils {
|
|
9
|
+
async withTxn(fn, reuseAsyncLocalTxn = true, existingSession) {
|
|
10
|
+
let result = undefined;
|
|
11
|
+
if (!existingSession && reuseAsyncLocalTxn) {
|
|
12
|
+
existingSession = injectables_1.kUtilsInjectables
|
|
13
|
+
.asyncLocalStorage()
|
|
14
|
+
.get(asyncLocalStorage_1.kAsyncLocalStorageKeys.txn);
|
|
15
|
+
}
|
|
16
|
+
if (existingSession) {
|
|
17
|
+
(0, assertion_1.appAssert)((0, connection_1.isMongoClientSession)(existingSession));
|
|
18
|
+
result = await fn(existingSession);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const connection = injectables_1.kUtilsInjectables.dbConnection().get();
|
|
22
|
+
(0, assertion_1.appAssert)((0, connection_1.isMongoConnection)(connection));
|
|
23
|
+
const session = await connection.startSession();
|
|
24
|
+
await session.withTransaction(async () => injectables_1.kUtilsInjectables
|
|
25
|
+
.asyncLocalStorage()
|
|
26
|
+
.shadowSetForce(asyncLocalStorage_1.kAsyncLocalStorageKeys.txn, session, async () => (result = await fn(session))));
|
|
27
|
+
await session.endSession();
|
|
28
|
+
}
|
|
29
|
+
// `connection.transaction` throws if error occurs so if the control flow
|
|
30
|
+
// gets here, `result` is set.
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.MongoDataProviderUtils = MongoDataProviderUtils;
|
|
35
|
+
//# sourceMappingURL=MongoDataProviderUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MongoDataProviderUtils.js","sourceRoot":"","sources":["../../../../src/contexts/data/MongoDataProviderUtils.ts"],"names":[],"mappings":";;;AAEA,yDAGkC;AAClC,qDAAgD;AAChD,4DAA4D;AAC5D,0DAA2D;AAG3D,MAAa,sBAAsB;IACjC,KAAK,CAAC,OAAO,CACX,EAAiD,EACjD,kBAAkB,GAAG,IAAI,EACzB,eAAyB;QAEzB,IAAI,MAAM,GAAwB,SAAS,CAAC;QAE5C,IAAI,CAAC,eAAe,IAAI,kBAAkB,EAAE;YAC1C,eAAe,GAAG,+BAAiB;iBAChC,iBAAiB,EAAE;iBACnB,GAAG,CAAgB,0CAAsB,CAAC,GAAG,CAAC,CAAC;SACnD;QAED,IAAI,eAAe,EAAE;YACnB,IAAA,qBAAS,EAAC,IAAA,iCAAoB,EAAC,eAAe,CAAC,CAAC,CAAC;YACjD,MAAM,GAAG,MAAM,EAAE,CAAC,eAAe,CAAC,CAAC;SACpC;aAAM;YACL,MAAM,UAAU,GAAG,+BAAiB,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,CAAC;YAC1D,IAAA,qBAAS,EAAC,IAAA,8BAAiB,EAAC,UAAU,CAAC,CAAC,CAAC;YACzC,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,YAAY,EAAE,CAAC;YAChD,MAAM,OAAO,CAAC,eAAe,CAAC,KAAK,IAAI,EAAE,CACvC,+BAAiB;iBACd,iBAAiB,EAAE;iBACnB,cAAc,CACb,0CAAsB,CAAC,GAAG,EAC1B,OAAO,EACP,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CACzC,CACJ,CAAC;YACF,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;SAC5B;QAED,yEAAyE;QACzE,8BAA8B;QAC9B,OAAO,MAA4B,CAAC;IACtC,CAAC;CACF;AArCD,wDAqCC"}
|