@sdflc/backend-helpers 1.0.25 → 1.0.28
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 +175 -0
- package/build/{baseController.d.ts → BaseController.d.ts} +0 -0
- package/build/{baseController.js → BaseController.js} +0 -0
- package/build/{baseCore.d.ts → BaseCore.d.ts} +13 -19
- package/build/{baseCore.js → BaseCore.js} +115 -157
- package/build/{baseGateway.d.ts → BaseGateway.d.ts} +15 -11
- package/build/{baseGateway.js → BaseGateway.js} +148 -97
- package/build/{dataCache.d.ts → DataCache.d.ts} +0 -0
- package/build/{dataCache.js → DataCache.js} +2 -2
- package/build/{database.d.ts → Database.d.ts} +0 -0
- package/build/{database.js → Database.js} +0 -0
- package/build/{dbMigratorAndSeeder.d.ts → DbMigratorAndSeeder.d.ts} +0 -0
- package/build/{dbMigratorAndSeeder.js → DbMigratorAndSeeder.js} +5 -1
- package/build/apiContext.d.ts +3 -3
- package/build/apiContext.js +89 -32
- package/build/constants.d.ts +4 -5
- package/build/constants.js +23 -4
- package/build/dbSeeder.js +5 -1
- package/build/dbTableHelpers.d.ts +2 -0
- package/build/dbTableHelpers.js +48 -27
- package/build/index.d.ts +9 -11
- package/build/index.js +19 -20
- package/build/interfaces/ApiContext.d.ts +23 -0
- package/build/interfaces/{BaseCoreInterface.js → ApiContext.js} +0 -0
- package/build/interfaces/ApiContextInterface.d.ts +5 -1
- package/build/interfaces/BaseCorePropsInterface.d.ts +31 -0
- package/build/interfaces/{BaseGatewayInterface.js → BaseCorePropsInterface.js} +0 -0
- package/build/interfaces/BaseGatewayPropsInterface.d.ts +29 -0
- package/build/interfaces/BaseGatewayPropsInterface.js +2 -0
- package/build/interfaces/CacheInterface.d.ts +3 -3
- package/build/interfaces/CoreActionInterface.d.ts +1 -1
- package/build/interfaces/JwtTokenSecretAndSettings.d.ts +5 -0
- package/build/interfaces/JwtTokenSecretAndSettings.js +2 -0
- package/build/interfaces/index.d.ts +4 -2
- package/build/resolversHelpers.js +11 -10
- package/build/userToken.js +3 -3
- package/package.json +68 -68
- package/build/baseGatewayHelpers.d.ts +0 -20
- package/build/baseGatewayHelpers.js +0 -87
- package/build/interfaces/BaseCoreInterface.d.ts +0 -43
- package/build/interfaces/BaseGatewayInterface.d.ts +0 -26
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export { CacheInterface } from './CacheInterface';
|
|
2
2
|
export { LoaderInterface } from './LoaderInterface';
|
|
3
|
-
export {
|
|
3
|
+
export { BaseGatewayPropsInterface } from './BaseGatewayPropsInterface';
|
|
4
4
|
export { ListArgsInterface } from './ListArgsInterface';
|
|
5
5
|
export { SortItemInterface } from './SortItemInterface';
|
|
6
6
|
export { PaginationInterface } from './PaginationInterface';
|
|
7
|
-
export {
|
|
7
|
+
export { BaseCorePropsInterface } from './BaseCorePropsInterface';
|
|
8
8
|
export { CoreActionInterface } from './CoreActionInterface';
|
|
9
9
|
export { ApiContextInterface } from './ApiContextInterface';
|
|
10
|
+
export { ApiContext } from './ApiContext';
|
|
10
11
|
export { DbFieldAddDefaultInterface } from './DbFieldAddDefaultInterface';
|
|
11
12
|
export { BuildConfigOptions } from './BuildConfigOptions';
|
|
12
13
|
export { DatabaseOptions } from './DatabaseOptions';
|
|
@@ -18,3 +19,4 @@ export { CreateUserTokenArgs } from './CreateUserTokenArgs';
|
|
|
18
19
|
export { VerifyUserTokenArgs } from './VerifyUserTokenArgs';
|
|
19
20
|
export { BaseCoreActionsInterface } from './BaseCoreActionsInterface';
|
|
20
21
|
export { BaseCoreDoingWhatInterface } from './BaseCoreDoingWhatInterface';
|
|
22
|
+
export { JwtTokenSecretAndSettings } from './JwtTokenSecretAndSettings';
|
|
@@ -16,54 +16,55 @@ var buildDefaultResolvers = function (args) {
|
|
|
16
16
|
var _a = args || {}, prefix = _a.prefix, core = _a.core, query = _a.query, mutation = _a.mutation, types = _a.types, disableList = _a.disableList, disableGet = _a.disableGet, disableGetMany = _a.disableGetMany, disableCreate = _a.disableCreate, disableCreateMany = _a.disableCreateMany, disableUpdate = _a.disableUpdate, disableUpdateMany = _a.disableUpdateMany, disableSet = _a.disableSet, disableRemove = _a.disableRemove, disableRemoveMany = _a.disableRemoveMany;
|
|
17
17
|
var Query = __assign({}, (query || {}));
|
|
18
18
|
var Mutation = __assign({}, (mutation || {}));
|
|
19
|
+
var coreToUse = core || "".concat(prefix, "Core");
|
|
19
20
|
if (disableList !== true) {
|
|
20
21
|
Query["".concat(prefix, "List")] = function (parent, args, context) {
|
|
21
|
-
return context[
|
|
22
|
+
return context.cores[coreToUse].list(args);
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
if (disableGet !== true) {
|
|
25
26
|
Query["".concat(prefix, "Get")] = function (parent, args, context) {
|
|
26
|
-
return context[
|
|
27
|
+
return context.cores[coreToUse].get(args);
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
if (disableGetMany !== true) {
|
|
30
31
|
Query["".concat(prefix, "GetMany")] = function (parent, args, context) {
|
|
31
|
-
return context[
|
|
32
|
+
return context.cores[coreToUse].getMany(args);
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
if (disableCreate !== true) {
|
|
35
36
|
Mutation["".concat(prefix, "Create")] = function (parent, args, context) {
|
|
36
|
-
return context[
|
|
37
|
+
return context.cores[coreToUse].create(args);
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
if (disableCreateMany !== true) {
|
|
40
41
|
Mutation["".concat(prefix, "CreateMany")] = function (parent, args, context) {
|
|
41
|
-
return context[
|
|
42
|
+
return context.cores[coreToUse].createMany(args);
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
if (disableUpdate !== true) {
|
|
45
46
|
Mutation["".concat(prefix, "Update")] = function (parent, args, context) {
|
|
46
|
-
return context[
|
|
47
|
+
return context.cores[coreToUse].update(args);
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
if (disableUpdateMany !== true) {
|
|
50
51
|
Mutation["".concat(prefix, "UpdateMany")] = function (parent, args, context) {
|
|
51
|
-
return context[
|
|
52
|
+
return context.cores[coreToUse].updateMany(args);
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
if (disableSet !== true) {
|
|
55
56
|
Mutation["".concat(prefix, "Set")] = function (parent, args, context) {
|
|
56
|
-
return context[
|
|
57
|
+
return context.cores[coreToUse].set(args);
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
if (disableRemove !== true) {
|
|
60
61
|
Mutation["".concat(prefix, "Remove")] = function (parent, args, context) {
|
|
61
|
-
return context[
|
|
62
|
+
return context.cores[coreToUse].remove(args);
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
if (disableRemoveMany !== true) {
|
|
65
66
|
Mutation["".concat(prefix, "RemoveMany")] = function (parent, args, context) {
|
|
66
|
-
return context[
|
|
67
|
+
return context.cores[coreToUse].removeMany(args);
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
70
|
return __assign({ Query: Query, Mutation: Mutation }, (types || {}));
|
package/build/userToken.js
CHANGED
|
@@ -9,7 +9,7 @@ var api_helpers_1 = require("@sdflc/api-helpers");
|
|
|
9
9
|
var createUserToken = function (params, secret, opt) {
|
|
10
10
|
var _a = opt || {}, algorithm = _a.algorithm, audience = _a.audience, issuer = _a.issuer, jwtid = _a.jwtid, subject = _a.subject, noTimestamp = _a.noTimestamp, header = _a.header, keyid = _a.keyid, expiresIn = _a.expiresIn;
|
|
11
11
|
if (!params || !secret) {
|
|
12
|
-
return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.VALIDATION_FAILED);
|
|
12
|
+
return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.VALIDATION_FAILED, null, 'Failed to create user JWT');
|
|
13
13
|
}
|
|
14
14
|
var token = jsonwebtoken_1.default.sign(params, secret, {
|
|
15
15
|
algorithm: algorithm || 'HS256',
|
|
@@ -28,7 +28,7 @@ exports.createUserToken = createUserToken;
|
|
|
28
28
|
var verifyUserToken = function (token, secret, args) {
|
|
29
29
|
var _a = args || {}, algorithms = _a.algorithms, audience = _a.audience, issuer = _a.issuer, ignoreExpiration = _a.ignoreExpiration, ignoreNotBefore = _a.ignoreNotBefore, subject = _a.subject, clockTolerance = _a.clockTolerance, maxAge = _a.maxAge, clockTimestamp = _a.clockTimestamp, nonce = _a.nonce;
|
|
30
30
|
if (!args) {
|
|
31
|
-
return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.VALIDATION_FAILED);
|
|
31
|
+
return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.VALIDATION_FAILED, null, 'Cannot verify user token as there are no parameters specified');
|
|
32
32
|
}
|
|
33
33
|
try {
|
|
34
34
|
var obj = jsonwebtoken_1.default.verify(token, secret, {
|
|
@@ -46,7 +46,7 @@ var verifyUserToken = function (token, secret, args) {
|
|
|
46
46
|
return api_helpers_1.OpResult.ok(obj);
|
|
47
47
|
}
|
|
48
48
|
catch (ex) {
|
|
49
|
-
return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.UNAUTHORIZED);
|
|
49
|
+
return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.UNAUTHORIZED, null, 'User unauthenticated');
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
exports.verifyUserToken = verifyUserToken;
|
package/package.json
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@sdflc/backend-helpers",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Set of helper functions and classes to simplify building backend apps within @sdflc ecosystem",
|
|
5
|
-
"main": "build/index.js",
|
|
6
|
-
"types": "build/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"build/**/*"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "rimraf ./build && tsc",
|
|
12
|
-
"lint": "eslint . --ext .ts --fix",
|
|
13
|
-
"test": "echo No Tests Available Yet",
|
|
14
|
-
"testToDo": "jest --config jest.config.ts",
|
|
15
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
16
|
-
"prepare": "husky install && npm run build",
|
|
17
|
-
"prepare1": "husky install",
|
|
18
|
-
"prepublishOnly": "npm test && npm run lint",
|
|
19
|
-
"preversion": "npm run lint",
|
|
20
|
-
"version": "npm run format && git add -A src",
|
|
21
|
-
"postversion": "git push && git push --tags"
|
|
22
|
-
},
|
|
23
|
-
"author": "Sergey Demidenko",
|
|
24
|
-
"license": "ISC",
|
|
25
|
-
"peerDependencies": {},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/bcrypt": "^5.0.0",
|
|
28
|
-
"@types/bluebird": "^3.5.36",
|
|
29
|
-
"@types/dotenv-safe": "^8.1.2",
|
|
30
|
-
"@types/jest": "^26.0.24",
|
|
31
|
-
"@types/jsonwebtoken": "^8.5.8",
|
|
32
|
-
"@types/lodash": "^4.14.179",
|
|
33
|
-
"@types/node": "^14.18.12",
|
|
34
|
-
"@types/redis": "^2.8.32",
|
|
35
|
-
"@types/uuid": "^8.3.4",
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
37
|
-
"@typescript-eslint/parser": "^4.33.0",
|
|
38
|
-
"eslint": "^7.32.0",
|
|
39
|
-
"eslint-config-prettier": "^6.15.0",
|
|
40
|
-
"eslint-plugin-jest": "^24.7.0",
|
|
41
|
-
"eslint-plugin-prettier": "^3.4.1",
|
|
42
|
-
"eslint-plugin-react": "^7.29.1",
|
|
43
|
-
"husky": "^6.0.0",
|
|
44
|
-
"jest": "^26.6.3",
|
|
45
|
-
"prettier": "^2.5.1",
|
|
46
|
-
"rimraf": "^3.0.2",
|
|
47
|
-
"run-script-os": "^1.1.3",
|
|
48
|
-
"ts-jest": "^26.4.4",
|
|
49
|
-
"ts-node": "^9.0.0",
|
|
50
|
-
"typescript": "^4.5.5"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@sdflc/api-helpers": "^1.1.8",
|
|
54
|
-
"@sdflc/utils": "^1.0.
|
|
55
|
-
"bcrypt": "^5.0.1",
|
|
56
|
-
"bluebird": "^3.7.2",
|
|
57
|
-
"dataloader": "^2.0.0",
|
|
58
|
-
"dayjs": "^1.10.7",
|
|
59
|
-
"dotenv-safe": "^8.2.0",
|
|
60
|
-
"jsonwebtoken": "^8.5.1",
|
|
61
|
-
"knex": "^0.95.15",
|
|
62
|
-
"lodash": "^4.17.20",
|
|
63
|
-
"pg": "^8.7.3",
|
|
64
|
-
"redis": "^3.1.2",
|
|
65
|
-
"redis-dataloader": "^1.0.2",
|
|
66
|
-
"uuid": "^8.3.2"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@sdflc/backend-helpers",
|
|
3
|
+
"version": "1.0.28",
|
|
4
|
+
"description": "Set of helper functions and classes to simplify building backend apps within @sdflc ecosystem",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"build/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rimraf ./build && tsc",
|
|
12
|
+
"lint": "eslint . --ext .ts --fix",
|
|
13
|
+
"test": "echo No Tests Available Yet",
|
|
14
|
+
"testToDo": "jest --config jest.config.ts",
|
|
15
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
16
|
+
"prepare": "husky install && npm run build",
|
|
17
|
+
"prepare1": "husky install",
|
|
18
|
+
"prepublishOnly": "npm test && npm run lint",
|
|
19
|
+
"preversion": "npm run lint",
|
|
20
|
+
"version": "npm run format && git add -A src",
|
|
21
|
+
"postversion": "git push && git push --tags"
|
|
22
|
+
},
|
|
23
|
+
"author": "Sergey Demidenko",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"peerDependencies": {},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/bcrypt": "^5.0.0",
|
|
28
|
+
"@types/bluebird": "^3.5.36",
|
|
29
|
+
"@types/dotenv-safe": "^8.1.2",
|
|
30
|
+
"@types/jest": "^26.0.24",
|
|
31
|
+
"@types/jsonwebtoken": "^8.5.8",
|
|
32
|
+
"@types/lodash": "^4.14.179",
|
|
33
|
+
"@types/node": "^14.18.12",
|
|
34
|
+
"@types/redis": "^2.8.32",
|
|
35
|
+
"@types/uuid": "^8.3.4",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
37
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
38
|
+
"eslint": "^7.32.0",
|
|
39
|
+
"eslint-config-prettier": "^6.15.0",
|
|
40
|
+
"eslint-plugin-jest": "^24.7.0",
|
|
41
|
+
"eslint-plugin-prettier": "^3.4.1",
|
|
42
|
+
"eslint-plugin-react": "^7.29.1",
|
|
43
|
+
"husky": "^6.0.0",
|
|
44
|
+
"jest": "^26.6.3",
|
|
45
|
+
"prettier": "^2.5.1",
|
|
46
|
+
"rimraf": "^3.0.2",
|
|
47
|
+
"run-script-os": "^1.1.3",
|
|
48
|
+
"ts-jest": "^26.4.4",
|
|
49
|
+
"ts-node": "^9.0.0",
|
|
50
|
+
"typescript": "^4.5.5"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@sdflc/api-helpers": "^1.1.8",
|
|
54
|
+
"@sdflc/utils": "^1.0.19",
|
|
55
|
+
"bcrypt": "^5.0.1",
|
|
56
|
+
"bluebird": "^3.7.2",
|
|
57
|
+
"dataloader": "^2.0.0",
|
|
58
|
+
"dayjs": "^1.10.7",
|
|
59
|
+
"dotenv-safe": "^8.2.0",
|
|
60
|
+
"jsonwebtoken": "^8.5.1",
|
|
61
|
+
"knex": "^0.95.15",
|
|
62
|
+
"lodash": "^4.17.20",
|
|
63
|
+
"pg": "^8.7.3",
|
|
64
|
+
"redis": "^3.1.2",
|
|
65
|
+
"redis-dataloader": "^1.0.2",
|
|
66
|
+
"uuid": "^8.3.2"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare const buildDefaultGatewayProps: (args: any) => {
|
|
2
|
-
filter: (query: any, params: any) => any;
|
|
3
|
-
keyPrefix: any;
|
|
4
|
-
context: any;
|
|
5
|
-
buildKey: any;
|
|
6
|
-
table: any;
|
|
7
|
-
idField: any;
|
|
8
|
-
setFields: any;
|
|
9
|
-
readAll: boolean;
|
|
10
|
-
redisClient: any;
|
|
11
|
-
cacheTtl: any;
|
|
12
|
-
noCache: boolean;
|
|
13
|
-
idGenerator: () => string;
|
|
14
|
-
insertFormatter: (args?: any) => any;
|
|
15
|
-
updateFormatter: (args?: any) => any;
|
|
16
|
-
updateFilter: (query: any, params: any) => void;
|
|
17
|
-
removeFormatter: () => any;
|
|
18
|
-
removeFilter: (query: any, params: any) => void;
|
|
19
|
-
returnFields: any;
|
|
20
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
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.buildDefaultGatewayProps = void 0;
|
|
7
|
-
var uuid_1 = require("uuid");
|
|
8
|
-
var dayjs_1 = __importDefault(require("dayjs"));
|
|
9
|
-
var lodash_1 = require("lodash");
|
|
10
|
-
var utils_1 = require("@sdflc/utils");
|
|
11
|
-
var constants_1 = __importDefault(require("./constants"));
|
|
12
|
-
var FIELDS = constants_1.default.FIELDS;
|
|
13
|
-
var buildDefaultGatewayProps = function (args) {
|
|
14
|
-
var config = args.config, tableName = args.tableName, filter = args.filter, updateFilter = args.updateFilter, hasStatus = args.hasStatus, hasRemovedAt = args.hasRemovedAt, hasRemovedAtStr = args.hasRemovedAtStr, setFields = args.setFields, idField = args.idField, activeStatuses = args.activeStatuses, redisClient = args.redisClient, context = args.context, buildKey = args.buildKey, returnFields = args.returnFields;
|
|
15
|
-
return {
|
|
16
|
-
filter: function (query, params) {
|
|
17
|
-
if (hasStatus === undefined || hasStatus === true) {
|
|
18
|
-
query.whereIn(FIELDS.STATUS, activeStatuses);
|
|
19
|
-
}
|
|
20
|
-
else if (hasRemovedAt === undefined || hasRemovedAt === true) {
|
|
21
|
-
query.whereNull(FIELDS.REMOVED_AT);
|
|
22
|
-
}
|
|
23
|
-
if (typeof filter === 'function') {
|
|
24
|
-
filter(query, params);
|
|
25
|
-
}
|
|
26
|
-
return query;
|
|
27
|
-
},
|
|
28
|
-
keyPrefix: tableName,
|
|
29
|
-
context: context,
|
|
30
|
-
buildKey: buildKey,
|
|
31
|
-
table: tableName,
|
|
32
|
-
idField: idField || FIELDS.ID,
|
|
33
|
-
setFields: setFields,
|
|
34
|
-
readAll: false,
|
|
35
|
-
redisClient: redisClient,
|
|
36
|
-
cacheTtl: config.cacheTtl,
|
|
37
|
-
noCache: false,
|
|
38
|
-
idGenerator: function () {
|
|
39
|
-
var id = (0, uuid_1.v4)();
|
|
40
|
-
return id;
|
|
41
|
-
},
|
|
42
|
-
insertFormatter: function (args) {
|
|
43
|
-
return args;
|
|
44
|
-
},
|
|
45
|
-
updateFormatter: function (args) {
|
|
46
|
-
return args;
|
|
47
|
-
},
|
|
48
|
-
updateFilter: function (query, params) {
|
|
49
|
-
var id = (params || {}).id;
|
|
50
|
-
if (id) {
|
|
51
|
-
query.whereIn(FIELDS.ID, (0, lodash_1.castArray)(id));
|
|
52
|
-
}
|
|
53
|
-
if (typeof updateFilter === 'function') {
|
|
54
|
-
updateFilter(query, params);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
removeFormatter: function () {
|
|
58
|
-
var removalTime = (0, dayjs_1.default)();
|
|
59
|
-
var removedAt = removalTime.toDate();
|
|
60
|
-
var obj = {
|
|
61
|
-
removedAt: removedAt,
|
|
62
|
-
};
|
|
63
|
-
if (hasRemovedAtStr === undefined || hasRemovedAtStr === true) {
|
|
64
|
-
obj[FIELDS.REMOVED_AT_STR] = removalTime.format('YYYYMMDDTHHmmssZ');
|
|
65
|
-
}
|
|
66
|
-
if (hasStatus === undefined || hasStatus === true) {
|
|
67
|
-
obj[FIELDS.STATUS] = utils_1.STATUSES.REMOVED;
|
|
68
|
-
}
|
|
69
|
-
return obj;
|
|
70
|
-
},
|
|
71
|
-
removeFilter: function (query, params) {
|
|
72
|
-
var arr = [];
|
|
73
|
-
if (Array.isArray(params)) {
|
|
74
|
-
arr.push.apply(arr, params);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
arr.push(params);
|
|
78
|
-
}
|
|
79
|
-
query = query.whereIn(FIELDS.ID, arr.map(function (item) { return item[FIELDS.ID]; }));
|
|
80
|
-
if (hasStatus === undefined || hasStatus === true) {
|
|
81
|
-
query.where(FIELDS.STATUS, '!=', utils_1.STATUSES.REMOVED);
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
returnFields: returnFields || [FIELDS.ID],
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
exports.buildDefaultGatewayProps = buildDefaultGatewayProps;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { BaseCoreActionsInterface } from './BaseCoreActionsInterface';
|
|
2
|
-
import { LoggerLevels, Logger } from '@sdflc/utils';
|
|
3
|
-
import { Database } from '../database';
|
|
4
|
-
import { BaseGateway } from '../baseGateway';
|
|
5
|
-
import { BaseCoreValidatorsInterface } from './BaseCoreValidatorsInterface';
|
|
6
|
-
import { BaseCoreDoingWhatInterface } from './BaseCoreDoingWhatInterface';
|
|
7
|
-
import { VerifyUserTokenArgs } from './VerifyUserTokenArgs';
|
|
8
|
-
export interface BaseCoreInterface {
|
|
9
|
-
db: Database;
|
|
10
|
-
context?: any;
|
|
11
|
-
gateway?: any;
|
|
12
|
-
gateways?: any;
|
|
13
|
-
isProduction: boolean;
|
|
14
|
-
logLevel: LoggerLevels;
|
|
15
|
-
logger?: Logger;
|
|
16
|
-
name?: string;
|
|
17
|
-
requestId: string;
|
|
18
|
-
doAuth: boolean;
|
|
19
|
-
doingWhat?: BaseCoreDoingWhatInterface;
|
|
20
|
-
beforeList?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
21
|
-
beforeCreate?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
22
|
-
beforeCreateMany?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
23
|
-
beforeUpdate?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
24
|
-
beforeUpdateMany?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
25
|
-
beforeSet?(params: any, opt?: any): BaseCoreActionsInterface;
|
|
26
|
-
beforeRemove?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
27
|
-
beforeRemoveMany?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
28
|
-
afterList?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
29
|
-
afterCreate?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
30
|
-
afterCreateMany?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
31
|
-
afterUpdate?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
32
|
-
afterUpdateMany?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
33
|
-
afterSet?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
34
|
-
afterRemove?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
35
|
-
afterRemoveMany?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
36
|
-
onException?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
37
|
-
validators?: BaseCoreValidatorsInterface;
|
|
38
|
-
authenticate?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
39
|
-
gwSpace?: BaseGateway;
|
|
40
|
-
interserviceApiKey?: string;
|
|
41
|
-
jwtSecret?: string;
|
|
42
|
-
verifytokenArgs?: VerifyUserTokenArgs;
|
|
43
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { LoggerLevels, Logger } from '@sdflc/utils';
|
|
2
|
-
import { BaseCore } from '../baseCore';
|
|
3
|
-
import { Database } from '../database';
|
|
4
|
-
import { LoaderInterface } from './LoaderInterface';
|
|
5
|
-
import { SortItemInterface } from './SortItemInterface';
|
|
6
|
-
export interface BaseGatewayInterface {
|
|
7
|
-
db: Database;
|
|
8
|
-
core?: BaseCore;
|
|
9
|
-
table?: string;
|
|
10
|
-
idField?: string;
|
|
11
|
-
setFields?: string[] | string;
|
|
12
|
-
selectFields?: any[];
|
|
13
|
-
defaultSorting?: SortItemInterface[];
|
|
14
|
-
filter?(query: any, params: any): any;
|
|
15
|
-
loader?: LoaderInterface;
|
|
16
|
-
noCache?: boolean;
|
|
17
|
-
idGenerator?(args?: any): any;
|
|
18
|
-
insertFormatter?(args?: any): any;
|
|
19
|
-
updateFormatter?(args?: any, where?: any): any;
|
|
20
|
-
updateFilter?(query: any, params: any): any;
|
|
21
|
-
removeFormatter?(args?: any): any;
|
|
22
|
-
removeFilter?(query: any, params: any): any;
|
|
23
|
-
returnFields?: any[];
|
|
24
|
-
logLevel: LoggerLevels;
|
|
25
|
-
logger?: Logger;
|
|
26
|
-
}
|