@sdflc/backend-helpers 1.0.71 → 1.0.73
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/build/BaseCore.js
CHANGED
|
@@ -719,7 +719,7 @@ class BaseCore {
|
|
|
719
719
|
return __awaiter(this, void 0, void 0, function* () {
|
|
720
720
|
const { req, space, authorization } = args;
|
|
721
721
|
const token = ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a[space.cookieName]) || authorization;
|
|
722
|
-
const fingerprint = ((_b = req.cookies) === null || _b === void 0 ? void 0 : _b[space.fingerprintCookieName]) || '';
|
|
722
|
+
const fingerprint = ((_b = req.cookies) === null || _b === void 0 ? void 0 : _b[space.fingerprintCookieName]) || args.fingerprint || '';
|
|
723
723
|
return {
|
|
724
724
|
token,
|
|
725
725
|
fingerprint,
|
|
@@ -737,7 +737,13 @@ class BaseCore {
|
|
|
737
737
|
if (spaceResult !== true) {
|
|
738
738
|
return [spaceResult, space];
|
|
739
739
|
}
|
|
740
|
-
const { token, fingerprint } = yield this.extractCredentials({
|
|
740
|
+
const { token, fingerprint } = yield this.extractCredentials({
|
|
741
|
+
req,
|
|
742
|
+
authorization,
|
|
743
|
+
fingerprint: context.fingerprint,
|
|
744
|
+
space,
|
|
745
|
+
params,
|
|
746
|
+
});
|
|
741
747
|
const { jwtSecret, verifyTokenArgs } = yield this.getJwtTokenSecretAndSettings(params);
|
|
742
748
|
if (token && jwtSecret) {
|
|
743
749
|
const verifyResult = (0, userToken_1.verifyUserToken)(token, jwtSecret, Object.assign(Object.assign({}, verifyTokenArgs), { algorithms: (verifyTokenArgs === null || verifyTokenArgs === void 0 ? void 0 : verifyTokenArgs.algorithms) || [(0, userToken_1.getDefaultJwtAlgorithm)()], audience: (verifyTokenArgs === null || verifyTokenArgs === void 0 ? void 0 : verifyTokenArgs.audience) || space.id, issuer: (verifyTokenArgs === null || verifyTokenArgs === void 0 ? void 0 : verifyTokenArgs.issuer) || (0, userToken_1.getDefaultJwtIssuer)(), fingerprint }));
|
package/build/BaseGateway.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DateTimeHelpers, Logger } from '@sdflc/utils';
|
|
2
|
-
import { ApiContext, BaseGatewayPropsInterface, BuildListQueryArgsInterface, ListArgsInterface } from './interfaces';
|
|
2
|
+
import { ApiContext, BaseGatewayPropsInterface, BuildListQueryArgsInterface, CacheInterface, ListArgsInterface, LoaderInterface } from './interfaces';
|
|
3
3
|
import { Database } from './Database';
|
|
4
4
|
declare class BaseGateway {
|
|
5
5
|
protected config: BaseGatewayPropsInterface;
|
|
@@ -8,7 +8,10 @@ declare class BaseGateway {
|
|
|
8
8
|
protected dateTime: DateTimeHelpers;
|
|
9
9
|
protected dateTimeNow: Date;
|
|
10
10
|
constructor(props: BaseGatewayPropsInterface);
|
|
11
|
+
getConfig(): BaseGatewayPropsInterface;
|
|
11
12
|
setConfigPart(props: BaseGatewayPropsInterface): this;
|
|
13
|
+
setLoader(loader: LoaderInterface): this;
|
|
14
|
+
setLoaderConfig(config: CacheInterface): this;
|
|
12
15
|
generateId(args?: any): Promise<string>;
|
|
13
16
|
onListFilter(query: any, filterParams: any): Promise<void>;
|
|
14
17
|
onUpdateFilter(query: any, filterParams: any): Promise<number>;
|
package/build/BaseGateway.js
CHANGED
|
@@ -15,11 +15,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.BaseGateway = void 0;
|
|
16
16
|
const uuid_1 = require("uuid");
|
|
17
17
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
18
|
+
const check_types_1 = __importDefault(require("check-types"));
|
|
18
19
|
const lodash_1 = require("lodash");
|
|
19
20
|
const utils_1 = require("@sdflc/utils");
|
|
20
21
|
const DataCache_1 = require("./DataCache");
|
|
21
22
|
const constants_1 = require("./constants");
|
|
22
|
-
const check_types_1 = __importDefault(require("check-types"));
|
|
23
23
|
const DEFAULT_CHUNCK_SIZE = 2500;
|
|
24
24
|
class BaseGateway {
|
|
25
25
|
constructor(props) {
|
|
@@ -42,10 +42,21 @@ class BaseGateway {
|
|
|
42
42
|
this.logger = (props === null || props === void 0 ? void 0 : props.logger) instanceof utils_1.Logger ? props.logger : new utils_1.Logger({ level: utils_1.LoggerLevels.WARNING });
|
|
43
43
|
this.loader = check_types_1.default.function((_c = this.config) === null || _c === void 0 ? void 0 : _c.loader) ? this.config.loader : new DataCache_1.DataCache(this.config);
|
|
44
44
|
}
|
|
45
|
+
getConfig() {
|
|
46
|
+
return this.config;
|
|
47
|
+
}
|
|
45
48
|
setConfigPart(props) {
|
|
46
49
|
Object.assign(this.config, props);
|
|
47
50
|
return this;
|
|
48
51
|
}
|
|
52
|
+
setLoader(loader) {
|
|
53
|
+
this.loader = loader;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
setLoaderConfig(config) {
|
|
57
|
+
this.loader = new DataCache_1.DataCache(Object.assign(Object.assign({}, this.config), config));
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
49
60
|
// eslint-disable-next-line
|
|
50
61
|
generateId(args) {
|
|
51
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -297,7 +308,7 @@ class BaseGateway {
|
|
|
297
308
|
}
|
|
298
309
|
const shouldUseCache = useCache != null ? useCache : !this.config.noCache;
|
|
299
310
|
const fieldsToUse = !shouldUseCache && Array.isArray(this.config.selectFields) ? this.config.selectFields : this.getIdField();
|
|
300
|
-
const query = this.buildListQuery({ filter, params, fieldsToUse });
|
|
311
|
+
const query = this.buildListQuery({ filter, params, fieldsToUse, useCache: shouldUseCache });
|
|
301
312
|
yield this.onListFilter(query, filter);
|
|
302
313
|
if (limit && !isNaN(limit) && limit > 0) {
|
|
303
314
|
query.offset(offset).limit(limit);
|
package/package.json
CHANGED