@sdflc/backend-helpers 1.0.23 → 1.0.26
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/apiContext.d.ts +2 -2
- package/build/apiContext.js +122 -65
- package/build/baseCore.d.ts +7 -3
- package/build/baseCore.js +67 -11
- package/build/baseGateway.d.ts +3 -2
- package/build/baseGateway.js +20 -8
- package/build/constants.js +5 -0
- package/build/dbMigratorAndSeeder.js +5 -1
- package/build/dbSeeder.js +5 -1
- package/build/dbTableHelpers.d.ts +3 -2
- package/build/dbTableHelpers.js +27 -2
- package/build/index.d.ts +1 -2
- package/build/index.js +8 -3
- package/build/interfaces/BaseCoreInterface.d.ts +6 -1
- package/build/interfaces/BaseGatewayInterface.d.ts +2 -1
- package/build/interfaces/CreateUserTokenArgs.d.ts +0 -3
- package/build/interfaces/VerifyUserTokenArgs.d.ts +0 -2
- package/build/interfaces/index.d.ts +0 -1
- package/build/userToken.d.ts +3 -3
- package/build/userToken.js +24 -19
- package/package.json +68 -68
- package/build/appBaseCore.d.ts +0 -9
- package/build/appBaseCore.js +0 -91
- package/build/interfaces/AppBaseCoreInterface.d.ts +0 -6
- package/build/interfaces/AppBaseCoreInterface.js +0 -2
package/README.md
CHANGED
|
@@ -1,3 +1,178 @@
|
|
|
1
1
|
# Backend Helpers
|
|
2
2
|
|
|
3
3
|
This library has a variety of classes and functions to simplify building backend applications with the specific architecture within `@sdflc` ecosystem.
|
|
4
|
+
|
|
5
|
+
## Classes
|
|
6
|
+
|
|
7
|
+
### BaseCore
|
|
8
|
+
|
|
9
|
+
This is the class that should be extended when you create a new core class. This is where all the business logic should be happeninng when processing request.
|
|
10
|
+
|
|
11
|
+
#### Constructor
|
|
12
|
+
|
|
13
|
+
Here are the props to be passed to the BaseCore constructor:
|
|
14
|
+
|
|
15
|
+
- db: Database - an object of Database class
|
|
16
|
+
- context?: any - the request context where you can add all you need, optional
|
|
17
|
+
- gateway?: any - main gateway class object that will be working with DB or 3rd part API
|
|
18
|
+
- gateways?: any - an object
|
|
19
|
+
- isProduction: boolean - true when the app is in production
|
|
20
|
+
- logLevel: LoggerLevels - log leves: 0 - none, 1 - errors, 2 - warnings, 3 - messages, 4 - all
|
|
21
|
+
- logger?: Logger - object of Logger class to be used as logger
|
|
22
|
+
- name?: string - name of the core
|
|
23
|
+
- requestId: string - Unique ID of a request processed, can be used for troubleshooting
|
|
24
|
+
- doAuth: boolean - call authorize method or not an incoming request
|
|
25
|
+
- doingWhat?: BaseCoreDoingWhatInterface - an object with text descriptions of each action, used to generate generic error message sent to user on an exception
|
|
26
|
+
- validators?: BaseCoreValidatorsInterface - an object with validator functions to be used to validate incoming data
|
|
27
|
+
- gwSpace?: BaseGateway - gateway to find a space, i.e. configration of the app. Each app can have several configurations to be used as one instance for different applications
|
|
28
|
+
- interserviceApiKey?: string - API key to be used to authenticate incoming request from another microservice, optional
|
|
29
|
+
- jwtSecret?: string - secret to be used to validate Authorize Bearer token on incoming request, optional
|
|
30
|
+
- verifytokenArgs?: VerifyUserTokenArgs - optional parameters for JWT token validation, like algorithm, etc
|
|
31
|
+
|
|
32
|
+
#### getDb()
|
|
33
|
+
|
|
34
|
+
#### getRequestId()
|
|
35
|
+
|
|
36
|
+
#### getContext(key?: string)
|
|
37
|
+
|
|
38
|
+
#### getGateways()
|
|
39
|
+
|
|
40
|
+
#### success(data: any, code?: number): any
|
|
41
|
+
|
|
42
|
+
#### failure(code: number, errorMsg: string, data?: any)
|
|
43
|
+
|
|
44
|
+
#### validationFailure(ex: any): any
|
|
45
|
+
|
|
46
|
+
#### exceptionFailure(ex: any, doingWhat: string | any, data?: any)
|
|
47
|
+
|
|
48
|
+
#### checkResult(args: any)
|
|
49
|
+
|
|
50
|
+
#### runAction(opt: CoreActionInterface)
|
|
51
|
+
|
|
52
|
+
#### Default Actions
|
|
53
|
+
|
|
54
|
+
##### list(args: any)
|
|
55
|
+
|
|
56
|
+
##### get(args: any)
|
|
57
|
+
|
|
58
|
+
##### getMany(args: any)
|
|
59
|
+
|
|
60
|
+
##### create(args: any)
|
|
61
|
+
|
|
62
|
+
##### createMany(args: any)
|
|
63
|
+
|
|
64
|
+
##### update(args: any)
|
|
65
|
+
|
|
66
|
+
##### updateMany(args: any)
|
|
67
|
+
|
|
68
|
+
##### set(args: any)
|
|
69
|
+
|
|
70
|
+
##### remove(args: any)
|
|
71
|
+
|
|
72
|
+
##### removeMany(args: any)
|
|
73
|
+
|
|
74
|
+
#### Default Action related events
|
|
75
|
+
|
|
76
|
+
##### beforeList(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
77
|
+
|
|
78
|
+
##### afterList(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
79
|
+
|
|
80
|
+
##### beforeCreate(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
81
|
+
|
|
82
|
+
##### afterCreate(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
83
|
+
|
|
84
|
+
##### beforeCreateMany(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
85
|
+
|
|
86
|
+
##### afterCreateMany(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
87
|
+
|
|
88
|
+
##### beforeUpdate(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
89
|
+
|
|
90
|
+
##### afterUpdate(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
91
|
+
|
|
92
|
+
##### beforeUpdateMany(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
93
|
+
|
|
94
|
+
#### afterUpdateMany(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
95
|
+
|
|
96
|
+
##### beforeSet(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
97
|
+
|
|
98
|
+
##### afterSet(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
99
|
+
|
|
100
|
+
##### beforeRemove(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
101
|
+
|
|
102
|
+
##### afterRemove(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
103
|
+
|
|
104
|
+
##### beforeRemoveMany(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
105
|
+
|
|
106
|
+
##### afterRemoveMany(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
107
|
+
|
|
108
|
+
##### onException(params: any, opt?: BaseCoreActionsInterface): Promise<any>
|
|
109
|
+
|
|
110
|
+
#### Authorization
|
|
111
|
+
|
|
112
|
+
#### authenticate(params: any, opt?: BaseCoreActionsInterface)
|
|
113
|
+
|
|
114
|
+
### BaseGateway
|
|
115
|
+
|
|
116
|
+
This is the class that should be extended when you create a new gateway class. This is where your code works with database or 3rd party API or do some works of the lowest level. Gateways are used by the core classes to actually do the job to implement one or another business logic.
|
|
117
|
+
|
|
118
|
+
#### constructor(props: BaseGatewayInterface)
|
|
119
|
+
|
|
120
|
+
#### generateId(args?: any)
|
|
121
|
+
|
|
122
|
+
#### onListFilter(query: any, filterParams: any)
|
|
123
|
+
|
|
124
|
+
#### onUpdateFilter(query: any, filterParams: any)
|
|
125
|
+
|
|
126
|
+
#### onRemoveFilter(query: any, filterParams: any)
|
|
127
|
+
|
|
128
|
+
#### transformOnCreate(args: any)
|
|
129
|
+
|
|
130
|
+
#### transformOnUpdate(params: any, where?: any)
|
|
131
|
+
|
|
132
|
+
#### transformOnRemove(args?: any)
|
|
133
|
+
|
|
134
|
+
#### getDb()
|
|
135
|
+
|
|
136
|
+
#### getBuilder()
|
|
137
|
+
|
|
138
|
+
#### getIdField()
|
|
139
|
+
|
|
140
|
+
#### getCore()
|
|
141
|
+
|
|
142
|
+
#### setCore(core: BaseCore)
|
|
143
|
+
|
|
144
|
+
#### get(id: any)
|
|
145
|
+
|
|
146
|
+
#### getMany(ids: any[])
|
|
147
|
+
|
|
148
|
+
#### list(args?: ListArgsInterface)
|
|
149
|
+
|
|
150
|
+
#### create(args: any)
|
|
151
|
+
|
|
152
|
+
#### update(where: any, params: any)
|
|
153
|
+
|
|
154
|
+
#### updateMany(params: any): Promise<any[]>
|
|
155
|
+
|
|
156
|
+
#### increment(where: any, params: any)
|
|
157
|
+
|
|
158
|
+
#### decrement(where: any, params: any)
|
|
159
|
+
|
|
160
|
+
#### set(params: any): Promise<any[]>
|
|
161
|
+
|
|
162
|
+
#### remove(where: any, hardRemove = false)
|
|
163
|
+
|
|
164
|
+
### buildDefaultGatewayProps = (args: any)
|
|
165
|
+
|
|
166
|
+
This function builds configuration object for a gateways inherited from the BaseGateway classs
|
|
167
|
+
|
|
168
|
+
### BaseController
|
|
169
|
+
|
|
170
|
+
Base constroller class is used to create request handlers for RESTful API and provides some methods to simplify the task of working with requests and responses
|
|
171
|
+
|
|
172
|
+
#### json(method: any)
|
|
173
|
+
|
|
174
|
+
### Application Context
|
|
175
|
+
|
|
176
|
+
#### createApiContext = async (args: ApiContextInterface)
|
|
177
|
+
|
|
178
|
+
#### createContextDefault = async (args: any)
|
package/build/apiContext.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { ApiContextInterface } from './interfaces';
|
|
|
3
3
|
* Creates a GraphQL context object with all available cores.
|
|
4
4
|
* @returns {object} A context object with all available cores
|
|
5
5
|
*/
|
|
6
|
-
export declare const createApiContext: (args: ApiContextInterface) => any
|
|
6
|
+
export declare const createApiContext: (args: ApiContextInterface) => Promise<any>;
|
|
7
7
|
/**
|
|
8
8
|
* Creates default a GraphQL context object with all avilable cores.
|
|
9
9
|
* @returns {object} A context object with all available cores
|
|
10
10
|
*/
|
|
11
|
-
export declare const createContextDefault: (args: any) => any
|
|
11
|
+
export declare const createContextDefault: (args: any) => Promise<any>;
|
package/build/apiContext.js
CHANGED
|
@@ -10,6 +10,42 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
13
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
50
|
exports.createContextDefault = exports.createApiContext = void 0;
|
|
15
51
|
var lodash_1 = require("lodash");
|
|
@@ -20,75 +56,96 @@ var database_1 = require("./database");
|
|
|
20
56
|
* Creates a GraphQL context object with all available cores.
|
|
21
57
|
* @returns {object} A context object with all available cores
|
|
22
58
|
*/
|
|
23
|
-
var createApiContext = function (args) {
|
|
24
|
-
var _a
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
59
|
+
var createApiContext = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
60
|
+
var _a, cores, req, getCoreContext, extendContext, inRequestId, keys, requestId, coreContext, _b, context;
|
|
61
|
+
return __generator(this, function (_c) {
|
|
62
|
+
switch (_c.label) {
|
|
63
|
+
case 0:
|
|
64
|
+
_a = args || {}, cores = _a.cores, req = _a.req, getCoreContext = _a.getCoreContext, extendContext = _a.extendContext, inRequestId = _a.requestId;
|
|
65
|
+
keys = Object.keys(cores || {});
|
|
66
|
+
requestId = inRequestId || (0, uuid_1.v4)();
|
|
67
|
+
if (!(typeof getCoreContext === 'function')) return [3 /*break*/, 2];
|
|
68
|
+
return [4 /*yield*/, getCoreContext({ req: req })];
|
|
69
|
+
case 1:
|
|
70
|
+
_b = _c.sent();
|
|
71
|
+
return [3 /*break*/, 3];
|
|
72
|
+
case 2:
|
|
73
|
+
_b = {};
|
|
74
|
+
_c.label = 3;
|
|
75
|
+
case 3:
|
|
76
|
+
coreContext = _b;
|
|
77
|
+
context = keys.reduce(function (acc, key) {
|
|
78
|
+
acc[(0, lodash_1.camelCase)(key)] = new cores[key](__assign(__assign({}, coreContext), { requestId: requestId }));
|
|
79
|
+
return acc;
|
|
80
|
+
}, {});
|
|
81
|
+
context.requestId = requestId;
|
|
82
|
+
if (!(typeof extendContext === 'function')) return [3 /*break*/, 5];
|
|
83
|
+
return [4 /*yield*/, extendContext({ context: context, req: req })];
|
|
84
|
+
case 4:
|
|
85
|
+
_c.sent();
|
|
86
|
+
_c.label = 5;
|
|
87
|
+
case 5: return [2 /*return*/, context];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}); };
|
|
38
91
|
exports.createApiContext = createApiContext;
|
|
39
92
|
/**
|
|
40
93
|
* Creates default a GraphQL context object with all avilable cores.
|
|
41
94
|
* @returns {object} A context object with all available cores
|
|
42
95
|
*/
|
|
43
|
-
var createContextDefault = function (args) {
|
|
44
|
-
var _a
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
var createContextDefault = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
+
var _a, knexConfig, dbSchema, cores, req, extendContext, getCoreContext, authorization, spaceId, apiKey, managementApiKey, accountId, roleId, userId, userAgent, referer, ipAddress, acceptLanguage, languages, requestedLang, requestId, db;
|
|
98
|
+
return __generator(this, function (_b) {
|
|
99
|
+
switch (_b.label) {
|
|
100
|
+
case 0:
|
|
101
|
+
_a = args || {}, knexConfig = _a.knexConfig, dbSchema = _a.dbSchema, cores = _a.cores, req = _a.req, extendContext = _a.extendContext, getCoreContext = _a.getCoreContext;
|
|
102
|
+
authorization = req.headers['authorization'] ? req.headers['authorization'].replace('Bearer ', '') : undefined;
|
|
103
|
+
spaceId = req.headers['x-space-id'];
|
|
104
|
+
apiKey = req.headers['x-api-key'];
|
|
105
|
+
managementApiKey = req.headers['x-management-api-key'];
|
|
106
|
+
accountId = req.headers['x-account-id'];
|
|
107
|
+
roleId = req.headers['x-role-id'];
|
|
108
|
+
userId = req.headers['x-user-id'];
|
|
109
|
+
userAgent = req.headers['user-agent'];
|
|
110
|
+
referer = req.headers['referer'];
|
|
111
|
+
ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
|
112
|
+
acceptLanguage = req.headers['accept-language'];
|
|
113
|
+
languages = (0, utils_1.extractLanguages)(acceptLanguage);
|
|
114
|
+
requestedLang = req.query['lang'];
|
|
115
|
+
requestId = (0, uuid_1.v4)();
|
|
116
|
+
db = new database_1.Database({
|
|
117
|
+
knexConfig: knexConfig,
|
|
118
|
+
dbSchema: dbSchema,
|
|
119
|
+
});
|
|
120
|
+
return [4 /*yield*/, (0, exports.createApiContext)({
|
|
121
|
+
cores: cores,
|
|
122
|
+
req: req,
|
|
123
|
+
requestId: requestId,
|
|
124
|
+
extendContext: function (_a) {
|
|
125
|
+
var context = _a.context, req = _a.req;
|
|
126
|
+
context.db = db;
|
|
127
|
+
if (typeof extendContext === 'function') {
|
|
128
|
+
extendContext({ context: context, req: req });
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
getCoreContext: function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
132
|
+
var extendCoreConext;
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
switch (_a.label) {
|
|
135
|
+
case 0:
|
|
136
|
+
extendCoreConext = {};
|
|
137
|
+
if (!(typeof getCoreContext === 'function')) return [3 /*break*/, 2];
|
|
138
|
+
return [4 /*yield*/, getCoreContext(args)];
|
|
139
|
+
case 1:
|
|
140
|
+
extendCoreConext = _a.sent();
|
|
141
|
+
_a.label = 2;
|
|
142
|
+
case 2: return [2 /*return*/, __assign(__assign({ db: db }, extendCoreConext), { context: __assign({ spaceId: spaceId, apiKey: apiKey, managementApiKey: managementApiKey, userAgent: userAgent, referer: referer, ipAddress: ipAddress, acceptLanguage: acceptLanguage, languages: languages, requestedLang: requestedLang, authorization: authorization, accountId: accountId, roleId: roleId, userId: userId }, (extendCoreConext.context || {})) })];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}); },
|
|
146
|
+
})];
|
|
147
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
148
|
+
}
|
|
92
149
|
});
|
|
93
|
-
};
|
|
150
|
+
}); };
|
|
94
151
|
exports.createContextDefault = createContextDefault;
|
package/build/baseCore.d.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { Logger } from '@sdflc/utils';
|
|
2
2
|
import { BaseCoreInterface, BaseCoreDoingWhatInterface, BaseCoreActionsInterface, CoreActionInterface, BaseCoreValidatorsInterface } from './interfaces';
|
|
3
|
-
import {
|
|
3
|
+
import { VerifyUserTokenArgs } from './interfaces/VerifyUserTokenArgs';
|
|
4
4
|
import { Database } from './database';
|
|
5
5
|
declare class BaseCore {
|
|
6
6
|
protected props: BaseCoreInterface;
|
|
7
7
|
protected db: Database;
|
|
8
8
|
protected context: any;
|
|
9
|
-
protected gateway?: BaseGateway;
|
|
10
9
|
protected doingWhat?: BaseCoreDoingWhatInterface;
|
|
11
10
|
protected logger: Logger;
|
|
12
11
|
protected name?: string;
|
|
12
|
+
protected gateway?: any;
|
|
13
13
|
protected gateways?: any;
|
|
14
|
+
protected gwSpace?: any;
|
|
15
|
+
protected interserviceApiKey?: string;
|
|
16
|
+
protected jwtSecret: string;
|
|
17
|
+
protected verifytokenArgs?: VerifyUserTokenArgs;
|
|
14
18
|
protected requestId: string;
|
|
15
19
|
protected validators: BaseCoreValidatorsInterface;
|
|
16
20
|
protected doAuth: boolean;
|
|
@@ -52,6 +56,6 @@ declare class BaseCore {
|
|
|
52
56
|
beforeRemoveMany(params: any, opt?: BaseCoreActionsInterface): Promise<any>;
|
|
53
57
|
afterRemoveMany(params: any, opt?: BaseCoreActionsInterface): Promise<any>;
|
|
54
58
|
onException(params: any, opt?: BaseCoreActionsInterface): Promise<any>;
|
|
55
|
-
authenticate(params: any, opt?: BaseCoreActionsInterface): Promise<any>;
|
|
59
|
+
authenticate(params: any, opt?: BaseCoreActionsInterface): Promise<any[]>;
|
|
56
60
|
}
|
|
57
61
|
export { BaseCore };
|
package/build/baseCore.js
CHANGED
|
@@ -50,11 +50,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
50
50
|
exports.BaseCore = void 0;
|
|
51
51
|
var api_helpers_1 = require("@sdflc/api-helpers");
|
|
52
52
|
var utils_1 = require("@sdflc/utils");
|
|
53
|
+
var userToken_1 = require("./userToken");
|
|
54
|
+
var baseGateway_1 = require("./baseGateway");
|
|
53
55
|
var utils_2 = require("./utils");
|
|
54
|
-
var defaultAfterAndBefore = function (params
|
|
56
|
+
var defaultAfterAndBefore = function (params /*, opt?: BaseCoreActionsInterface*/) {
|
|
55
57
|
return params;
|
|
56
58
|
};
|
|
57
|
-
var defaultValidate = function (params, opt) {
|
|
59
|
+
var defaultValidate = function ( /*params: any, opt?: BaseCoreActionsInterface*/) {
|
|
58
60
|
return [true, {}];
|
|
59
61
|
};
|
|
60
62
|
var defaultValidators = {
|
|
@@ -69,20 +71,31 @@ var defaultValidators = {
|
|
|
69
71
|
remove: defaultValidate,
|
|
70
72
|
removeMany: defaultValidate,
|
|
71
73
|
};
|
|
72
|
-
var defaultAuth = function (params) {
|
|
73
|
-
return [true, ''];
|
|
74
|
-
};
|
|
75
74
|
var BaseCore = /** @class */ (function () {
|
|
76
75
|
function BaseCore(props) {
|
|
76
|
+
var _this = this;
|
|
77
77
|
this.validators = defaultValidators;
|
|
78
78
|
this.props = props || {};
|
|
79
79
|
this.db = props.db;
|
|
80
80
|
this.name = props.name || '';
|
|
81
81
|
this.context = props.context || {};
|
|
82
|
-
this.gateway = props.gateway;
|
|
83
82
|
this.doingWhat = props.doingWhat;
|
|
84
83
|
this.logger = props.logger || new utils_1.Logger({ level: props.logLevel });
|
|
84
|
+
this.gateway = props.gateway;
|
|
85
85
|
this.gateways = __assign({ gateway: this.gateway }, (props.gateways || {}));
|
|
86
|
+
if (this.gateway instanceof baseGateway_1.BaseGateway) {
|
|
87
|
+
this.gateway.setCore(this);
|
|
88
|
+
}
|
|
89
|
+
Object.keys(this.gateways).forEach(function (gatewayName) {
|
|
90
|
+
var gateway = _this.gateways[gatewayName];
|
|
91
|
+
if (gateway instanceof baseGateway_1.BaseGateway) {
|
|
92
|
+
gateway.setCore(_this);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
this.gwSpace = props.gwSpace;
|
|
96
|
+
this.interserviceApiKey = props.interserviceApiKey;
|
|
97
|
+
this.jwtSecret = props.jwtSecret || '';
|
|
98
|
+
this.verifytokenArgs = props.verifytokenArgs;
|
|
86
99
|
this.validators = (0, utils_2.setFunctions)((props === null || props === void 0 ? void 0 : props.validators) || {}, this.validators);
|
|
87
100
|
this.doAuth = props.doAuth === true;
|
|
88
101
|
this.requestId = props.requestId || '';
|
|
@@ -142,7 +155,7 @@ var BaseCore = /** @class */ (function () {
|
|
|
142
155
|
msg = doingWhat['message'];
|
|
143
156
|
}
|
|
144
157
|
else {
|
|
145
|
-
msg = "Sorry, something went wrong on ".concat(doingWhat
|
|
158
|
+
msg = isOpResult ? ex.getErrorSummary() : "Sorry, something went wrong on ".concat(doingWhat);
|
|
146
159
|
}
|
|
147
160
|
this.logger.error(sysMsg, ex);
|
|
148
161
|
}
|
|
@@ -762,11 +775,54 @@ var BaseCore = /** @class */ (function () {
|
|
|
762
775
|
});
|
|
763
776
|
};
|
|
764
777
|
BaseCore.prototype.authenticate = function (params, opt) {
|
|
778
|
+
var _a;
|
|
765
779
|
return __awaiter(this, void 0, void 0, function () {
|
|
766
|
-
var
|
|
767
|
-
return __generator(this, function (
|
|
768
|
-
|
|
769
|
-
|
|
780
|
+
var context, authByToken, verifyResult, token, space;
|
|
781
|
+
return __generator(this, function (_b) {
|
|
782
|
+
switch (_b.label) {
|
|
783
|
+
case 0:
|
|
784
|
+
if (!(typeof this.props.authenticate === 'function')) return [3 /*break*/, 2];
|
|
785
|
+
return [4 /*yield*/, this.props.authenticate(params, opt)];
|
|
786
|
+
case 1:
|
|
787
|
+
// if we have an auth function passed to constructor then use it for the authentication
|
|
788
|
+
return [2 /*return*/, _b.sent()];
|
|
789
|
+
case 2:
|
|
790
|
+
context = this.context;
|
|
791
|
+
authByToken = false;
|
|
792
|
+
if (context.authorization && this.jwtSecret) {
|
|
793
|
+
verifyResult = (0, userToken_1.verifyUserToken)(context.authorization, this.jwtSecret, this.verifytokenArgs);
|
|
794
|
+
if (verifyResult.didFail()) {
|
|
795
|
+
return [2 /*return*/, [false, verifyResult.getErrorSummary('')]];
|
|
796
|
+
}
|
|
797
|
+
token = verifyResult.getDataFirst();
|
|
798
|
+
context.accountId = token.accountId;
|
|
799
|
+
context.roleId = token.roleId;
|
|
800
|
+
context.userId = token.userId;
|
|
801
|
+
context.spaceId = token.spaceId || context.spaceId;
|
|
802
|
+
authByToken = true;
|
|
803
|
+
}
|
|
804
|
+
space = null;
|
|
805
|
+
if (!this.gwSpace) return [3 /*break*/, 4];
|
|
806
|
+
return [4 /*yield*/, ((_a = this.gwSpace) === null || _a === void 0 ? void 0 : _a.get(context.spaceId || ''))];
|
|
807
|
+
case 3:
|
|
808
|
+
// Lookup space in case we have gateway
|
|
809
|
+
space = _b.sent();
|
|
810
|
+
if (!space) {
|
|
811
|
+
return [2 /*return*/, [false, 'Space Not Found']];
|
|
812
|
+
}
|
|
813
|
+
context.space = space;
|
|
814
|
+
_b.label = 4;
|
|
815
|
+
case 4:
|
|
816
|
+
if (!authByToken) {
|
|
817
|
+
if (this.interserviceApiKey && context.apiKey === this.interserviceApiKey) {
|
|
818
|
+
return [2 /*return*/, [true, '']];
|
|
819
|
+
}
|
|
820
|
+
else if ((space === null || space === void 0 ? void 0 : space.apiKey) && (space === null || space === void 0 ? void 0 : space.apiKey) !== context.apiKey) {
|
|
821
|
+
return [2 /*return*/, [false, 'API Key is invalid']];
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return [2 /*return*/, [true, '']];
|
|
825
|
+
}
|
|
770
826
|
});
|
|
771
827
|
});
|
|
772
828
|
};
|
package/build/baseGateway.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { BaseCore } from './baseCore';
|
|
|
3
3
|
declare class BaseGateway {
|
|
4
4
|
protected config: BaseGatewayInterface;
|
|
5
5
|
protected loader: any;
|
|
6
|
+
protected insertChunkSize: number;
|
|
6
7
|
protected returnFields: any[];
|
|
7
8
|
constructor(props: BaseGatewayInterface);
|
|
8
9
|
generateId(args?: any): Promise<any>;
|
|
@@ -15,12 +16,12 @@ declare class BaseGateway {
|
|
|
15
16
|
getDb(): import("./database").Database;
|
|
16
17
|
getBuilder(): any;
|
|
17
18
|
getIdField(): any;
|
|
18
|
-
getCore(): BaseCore;
|
|
19
|
+
getCore(): BaseCore | undefined;
|
|
19
20
|
setCore(core: BaseCore): void;
|
|
20
21
|
get(id: any): Promise<any>;
|
|
21
22
|
getMany(ids: any[]): Promise<any>;
|
|
22
23
|
list(args?: ListArgsInterface): Promise<any>;
|
|
23
|
-
create(args: any): Promise<any>;
|
|
24
|
+
create(args: any): Promise<any[]>;
|
|
24
25
|
update(where: any, params: any): Promise<any>;
|
|
25
26
|
updateMany(params: any): Promise<any[]>;
|
|
26
27
|
increment(where: any, params: any): Promise<any>;
|
package/build/baseGateway.js
CHANGED
|
@@ -52,6 +52,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.BaseGateway = void 0;
|
|
54
54
|
var lodash_1 = require("lodash");
|
|
55
|
+
var utils_1 = require("@sdflc/utils");
|
|
55
56
|
var dataCache_1 = require("./dataCache");
|
|
56
57
|
var constants_1 = __importDefault(require("./constants"));
|
|
57
58
|
var ID_FIELD = constants_1.default.ID_FIELD;
|
|
@@ -61,7 +62,9 @@ var defaultUpdateRemoveFilter = function (config) { return function (query, para
|
|
|
61
62
|
}; };
|
|
62
63
|
var BaseGateway = /** @class */ (function () {
|
|
63
64
|
function BaseGateway(props) {
|
|
65
|
+
var _a;
|
|
64
66
|
this.config = props;
|
|
67
|
+
this.insertChunkSize = (_a = props === null || props === void 0 ? void 0 : props.insertChunkSize) !== null && _a !== void 0 ? _a : 2500;
|
|
65
68
|
this.returnFields =
|
|
66
69
|
Array.isArray(this.config.returnFields) && this.config.returnFields.length > 0
|
|
67
70
|
? this.config.returnFields
|
|
@@ -238,15 +241,12 @@ var BaseGateway = /** @class */ (function () {
|
|
|
238
241
|
};
|
|
239
242
|
BaseGateway.prototype.create = function (args) {
|
|
240
243
|
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
-
var objects, idx, len, arg, id, obj, items;
|
|
244
|
+
var objects, idx, len, arg, id, obj, result, chunks, idx, len, items;
|
|
242
245
|
return __generator(this, function (_a) {
|
|
243
246
|
switch (_a.label) {
|
|
244
247
|
case 0:
|
|
245
|
-
objects =
|
|
246
|
-
if (!
|
|
247
|
-
args = [args];
|
|
248
|
-
}
|
|
249
|
-
if (args.length === 0) {
|
|
248
|
+
objects = (0, lodash_1.castArray)(args);
|
|
249
|
+
if (!args || objects.length === 0) {
|
|
250
250
|
return [2 /*return*/, []];
|
|
251
251
|
}
|
|
252
252
|
idx = 0, len = args.length;
|
|
@@ -265,10 +265,22 @@ var BaseGateway = /** @class */ (function () {
|
|
|
265
265
|
case 4:
|
|
266
266
|
++idx;
|
|
267
267
|
return [3 /*break*/, 1];
|
|
268
|
-
case 5:
|
|
268
|
+
case 5:
|
|
269
|
+
result = [];
|
|
270
|
+
chunks = (0, utils_1.arrToChunks)(objects, this.insertChunkSize);
|
|
271
|
+
idx = 0, len = chunks.length;
|
|
272
|
+
_a.label = 6;
|
|
269
273
|
case 6:
|
|
274
|
+
if (!(idx < len)) return [3 /*break*/, 9];
|
|
275
|
+
return [4 /*yield*/, this.getBuilder().insert(chunks[idx]).returning(this.returnFields)];
|
|
276
|
+
case 7:
|
|
270
277
|
items = _a.sent();
|
|
271
|
-
|
|
278
|
+
result.push.apply(result, items);
|
|
279
|
+
_a.label = 8;
|
|
280
|
+
case 8:
|
|
281
|
+
++idx;
|
|
282
|
+
return [3 /*break*/, 6];
|
|
283
|
+
case 9: return [2 /*return*/, result];
|
|
272
284
|
}
|
|
273
285
|
});
|
|
274
286
|
});
|
package/build/constants.js
CHANGED
|
@@ -17,6 +17,11 @@ var FIELDS = {
|
|
|
17
17
|
USER_ID: 'user_id',
|
|
18
18
|
ORDER_NO: 'order_no',
|
|
19
19
|
SPACE_ID: 'space_id',
|
|
20
|
+
DISPLAY_NAME: 'display_name',
|
|
21
|
+
NAME: 'name',
|
|
22
|
+
USERNAME: 'username',
|
|
23
|
+
EMAIL: 'email',
|
|
24
|
+
PHONE: 'phone',
|
|
20
25
|
};
|
|
21
26
|
var ID_FIELD = FIELDS.ID;
|
|
22
27
|
exports.default = {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/build/dbSeeder.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { DbFieldAddDefaultInterface } from './interfaces';
|
|
2
|
-
declare const dbFieldAddDefaults: (table: any, opt?: DbFieldAddDefaultInterface | undefined) => void;
|
|
2
|
+
export declare const dbFieldAddDefaults: (table: any, opt?: DbFieldAddDefaultInterface | undefined) => void;
|
|
3
3
|
export declare const addOrderNo: (table: any, opt?: any) => any;
|
|
4
4
|
export declare const addAmount: (table: any, fieldName: string) => any;
|
|
5
5
|
export declare const addSpaceId: (table: any, opt?: any) => any;
|
|
6
6
|
export declare const addUserId: (table: any, opt?: any) => any;
|
|
7
|
+
export declare const addAccountId: (table: any, opt?: any) => any;
|
|
8
|
+
export declare const addLang: (table: any, opt?: any) => any;
|
|
7
9
|
export declare const defaultFields: (opt?: any) => {
|
|
8
10
|
[x: number]: string;
|
|
9
11
|
};
|
|
10
|
-
export { dbFieldAddDefaults };
|
package/build/dbTableHelpers.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.defaultFields = exports.addLang = exports.addAccountId = exports.addUserId = exports.addSpaceId = exports.addAmount = exports.addOrderNo = exports.dbFieldAddDefaults = void 0;
|
|
7
7
|
var utils_1 = require("@sdflc/utils");
|
|
8
8
|
var constants_1 = __importDefault(require("./constants"));
|
|
9
9
|
var FIELDS = constants_1.default.FIELDS;
|
|
@@ -65,11 +65,36 @@ exports.addSpaceId = addSpaceId;
|
|
|
65
65
|
var addUserId = function (table, opt) {
|
|
66
66
|
var chain = table.uuid(FIELDS.USER_ID).notNullable().comment('Reference to the user table');
|
|
67
67
|
if ((opt === null || opt === void 0 ? void 0 : opt.addForeignKey) === true) {
|
|
68
|
-
table.foreign(FIELDS.
|
|
68
|
+
table.foreign(FIELDS.USER_ID).references("user.".concat(FIELDS.ID)).onUpdate('CASCADE').onDelete('CASCADE');
|
|
69
|
+
}
|
|
70
|
+
if ((opt === null || opt === void 0 ? void 0 : opt.addIndex) === true) {
|
|
71
|
+
table.index([FIELDS.USER_ID]);
|
|
69
72
|
}
|
|
70
73
|
return chain;
|
|
71
74
|
};
|
|
72
75
|
exports.addUserId = addUserId;
|
|
76
|
+
var addAccountId = function (table, opt) {
|
|
77
|
+
var chain = table.uuid(FIELDS.ACCOUNT_ID).notNullable().comment('Reference to the user table');
|
|
78
|
+
if ((opt === null || opt === void 0 ? void 0 : opt.addForeignKey) === true) {
|
|
79
|
+
table.foreign(FIELDS.ACCOUNT_ID).references("account.".concat(FIELDS.ID)).onUpdate('CASCADE').onDelete('CASCADE');
|
|
80
|
+
}
|
|
81
|
+
if ((opt === null || opt === void 0 ? void 0 : opt.addIndex) === true) {
|
|
82
|
+
table.index([FIELDS.ACCOUNT_ID]);
|
|
83
|
+
}
|
|
84
|
+
return chain;
|
|
85
|
+
};
|
|
86
|
+
exports.addAccountId = addAccountId;
|
|
87
|
+
var addLang = function (table, opt) {
|
|
88
|
+
var chain = table.text(FIELDS.LANG).defaultTo('en').notNullable().comment('Language, example: en, ru, en_CA, etc');
|
|
89
|
+
if ((opt === null || opt === void 0 ? void 0 : opt.addForeignKey) === true) {
|
|
90
|
+
table.foreign(FIELDS.LANG).references("language.".concat(FIELDS.ID)).onUpdate('CASCADE').onDelete('CASCADE');
|
|
91
|
+
}
|
|
92
|
+
if ((opt === null || opt === void 0 ? void 0 : opt.addIndex) === true) {
|
|
93
|
+
table.index([FIELDS.LANG]);
|
|
94
|
+
}
|
|
95
|
+
return chain;
|
|
96
|
+
};
|
|
97
|
+
exports.addLang = addLang;
|
|
73
98
|
var defaultFields = function (opt) {
|
|
74
99
|
var _a;
|
|
75
100
|
var addUserInfo = (opt || {}).addUserInfo;
|
package/build/index.d.ts
CHANGED
|
@@ -11,10 +11,9 @@ export { checkArray, createErrorOnCheckError } from './checkItHelpers';
|
|
|
11
11
|
export { DataCache } from './dataCache';
|
|
12
12
|
export { BaseGateway } from './baseGateway';
|
|
13
13
|
export { BaseCore } from './baseCore';
|
|
14
|
-
export { AppBaseCore } from './appBaseCore';
|
|
15
14
|
export { createApiContext, createContextDefault } from './apiContext';
|
|
16
15
|
export { BaseController } from './baseController';
|
|
17
|
-
export { dbFieldAddDefaults } from './dbTableHelpers';
|
|
16
|
+
export { dbFieldAddDefaults, addOrderNo, addAmount, addSpaceId, addUserId, addAccountId, addLang, defaultFields, } from './dbTableHelpers';
|
|
18
17
|
export { buildDefaultResolvers } from './resolversHelpers';
|
|
19
18
|
export { createUserToken, verifyUserToken } from './userToken';
|
|
20
19
|
export { constants };
|
package/build/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.checkPassword = exports.getSaltAndHash = exports.buildDefaultGatewayProps = exports.constants = exports.verifyUserToken = exports.createUserToken = exports.buildDefaultResolvers = exports.
|
|
6
|
+
exports.checkPassword = exports.getSaltAndHash = exports.buildDefaultGatewayProps = exports.constants = exports.verifyUserToken = exports.createUserToken = exports.buildDefaultResolvers = exports.defaultFields = exports.addLang = exports.addAccountId = exports.addUserId = exports.addSpaceId = exports.addAmount = exports.addOrderNo = exports.dbFieldAddDefaults = exports.BaseController = exports.createContextDefault = exports.createApiContext = exports.BaseCore = exports.BaseGateway = exports.DataCache = exports.createErrorOnCheckError = exports.checkArray = exports.createRedisClient = exports.buildKnexConfig = exports.dbSeed = exports.DbMigratorAndSeeder = exports.dbRunMigrations = exports.dbTransformSeedsToObject = exports.dbReset = exports.dbWipe = exports.dbClean = exports.dbListTables = exports.dbCleanTable = exports.Database = exports.buildConfig = void 0;
|
|
7
7
|
var constants_1 = __importDefault(require("./constants"));
|
|
8
8
|
exports.constants = constants_1.default;
|
|
9
9
|
var configBulder_1 = require("./configBulder");
|
|
@@ -35,8 +35,6 @@ var baseGateway_1 = require("./baseGateway");
|
|
|
35
35
|
Object.defineProperty(exports, "BaseGateway", { enumerable: true, get: function () { return baseGateway_1.BaseGateway; } });
|
|
36
36
|
var baseCore_1 = require("./baseCore");
|
|
37
37
|
Object.defineProperty(exports, "BaseCore", { enumerable: true, get: function () { return baseCore_1.BaseCore; } });
|
|
38
|
-
var appBaseCore_1 = require("./appBaseCore");
|
|
39
|
-
Object.defineProperty(exports, "AppBaseCore", { enumerable: true, get: function () { return appBaseCore_1.AppBaseCore; } });
|
|
40
38
|
var apiContext_1 = require("./apiContext");
|
|
41
39
|
Object.defineProperty(exports, "createApiContext", { enumerable: true, get: function () { return apiContext_1.createApiContext; } });
|
|
42
40
|
Object.defineProperty(exports, "createContextDefault", { enumerable: true, get: function () { return apiContext_1.createContextDefault; } });
|
|
@@ -44,6 +42,13 @@ var baseController_1 = require("./baseController");
|
|
|
44
42
|
Object.defineProperty(exports, "BaseController", { enumerable: true, get: function () { return baseController_1.BaseController; } });
|
|
45
43
|
var dbTableHelpers_1 = require("./dbTableHelpers");
|
|
46
44
|
Object.defineProperty(exports, "dbFieldAddDefaults", { enumerable: true, get: function () { return dbTableHelpers_1.dbFieldAddDefaults; } });
|
|
45
|
+
Object.defineProperty(exports, "addOrderNo", { enumerable: true, get: function () { return dbTableHelpers_1.addOrderNo; } });
|
|
46
|
+
Object.defineProperty(exports, "addAmount", { enumerable: true, get: function () { return dbTableHelpers_1.addAmount; } });
|
|
47
|
+
Object.defineProperty(exports, "addSpaceId", { enumerable: true, get: function () { return dbTableHelpers_1.addSpaceId; } });
|
|
48
|
+
Object.defineProperty(exports, "addUserId", { enumerable: true, get: function () { return dbTableHelpers_1.addUserId; } });
|
|
49
|
+
Object.defineProperty(exports, "addAccountId", { enumerable: true, get: function () { return dbTableHelpers_1.addAccountId; } });
|
|
50
|
+
Object.defineProperty(exports, "addLang", { enumerable: true, get: function () { return dbTableHelpers_1.addLang; } });
|
|
51
|
+
Object.defineProperty(exports, "defaultFields", { enumerable: true, get: function () { return dbTableHelpers_1.defaultFields; } });
|
|
47
52
|
var resolversHelpers_1 = require("./resolversHelpers");
|
|
48
53
|
Object.defineProperty(exports, "buildDefaultResolvers", { enumerable: true, get: function () { return resolversHelpers_1.buildDefaultResolvers; } });
|
|
49
54
|
var userToken_1 = require("./userToken");
|
|
@@ -4,10 +4,11 @@ import { Database } from '../database';
|
|
|
4
4
|
import { BaseGateway } from '../baseGateway';
|
|
5
5
|
import { BaseCoreValidatorsInterface } from './BaseCoreValidatorsInterface';
|
|
6
6
|
import { BaseCoreDoingWhatInterface } from './BaseCoreDoingWhatInterface';
|
|
7
|
+
import { VerifyUserTokenArgs } from './VerifyUserTokenArgs';
|
|
7
8
|
export interface BaseCoreInterface {
|
|
8
9
|
db: Database;
|
|
9
10
|
context?: any;
|
|
10
|
-
gateway?:
|
|
11
|
+
gateway?: any;
|
|
11
12
|
gateways?: any;
|
|
12
13
|
isProduction: boolean;
|
|
13
14
|
logLevel: LoggerLevels;
|
|
@@ -35,4 +36,8 @@ export interface BaseCoreInterface {
|
|
|
35
36
|
onException?(params: any, opt?: BaseCoreActionsInterface): any;
|
|
36
37
|
validators?: BaseCoreValidatorsInterface;
|
|
37
38
|
authenticate?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
39
|
+
gwSpace?: BaseGateway;
|
|
40
|
+
interserviceApiKey?: string;
|
|
41
|
+
jwtSecret?: string;
|
|
42
|
+
verifytokenArgs?: VerifyUserTokenArgs;
|
|
38
43
|
}
|
|
@@ -5,12 +5,13 @@ import { LoaderInterface } from './LoaderInterface';
|
|
|
5
5
|
import { SortItemInterface } from './SortItemInterface';
|
|
6
6
|
export interface BaseGatewayInterface {
|
|
7
7
|
db: Database;
|
|
8
|
-
core
|
|
8
|
+
core?: BaseCore;
|
|
9
9
|
table?: string;
|
|
10
10
|
idField?: string;
|
|
11
11
|
setFields?: string[] | string;
|
|
12
12
|
selectFields?: any[];
|
|
13
13
|
defaultSorting?: SortItemInterface[];
|
|
14
|
+
insertChunkSize?: number;
|
|
14
15
|
filter?(query: any, params: any): any;
|
|
15
16
|
loader?: LoaderInterface;
|
|
16
17
|
noCache?: boolean;
|
|
@@ -5,7 +5,6 @@ export { ListArgsInterface } from './ListArgsInterface';
|
|
|
5
5
|
export { SortItemInterface } from './SortItemInterface';
|
|
6
6
|
export { PaginationInterface } from './PaginationInterface';
|
|
7
7
|
export { BaseCoreInterface } from './BaseCoreInterface';
|
|
8
|
-
export { AppBaseCoreInterface } from './AppBaseCoreInterface';
|
|
9
8
|
export { CoreActionInterface } from './CoreActionInterface';
|
|
10
9
|
export { ApiContextInterface } from './ApiContextInterface';
|
|
11
10
|
export { DbFieldAddDefaultInterface } from './DbFieldAddDefaultInterface';
|
package/build/userToken.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { OpResult } from '@sdflc/api-helpers';
|
|
2
|
-
import { CreateUserTokenArgs, VerifyUserTokenArgs } from './interfaces';
|
|
3
|
-
export declare const createUserToken: (
|
|
4
|
-
export declare const verifyUserToken: (
|
|
2
|
+
import { UserTokenParams, CreateUserTokenArgs, VerifyUserTokenArgs } from './interfaces';
|
|
3
|
+
export declare const createUserToken: (params: UserTokenParams, secret: string, opt: CreateUserTokenArgs) => OpResult;
|
|
4
|
+
export declare const verifyUserToken: (token: string, secret: string, args?: VerifyUserTokenArgs | undefined) => OpResult;
|
package/build/userToken.js
CHANGED
|
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.verifyUserToken = exports.createUserToken = void 0;
|
|
7
7
|
var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
8
|
var api_helpers_1 = require("@sdflc/api-helpers");
|
|
9
|
-
var createUserToken = function (
|
|
10
|
-
var _a =
|
|
11
|
-
if (!
|
|
9
|
+
var createUserToken = function (params, secret, opt) {
|
|
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
|
+
if (!params || !secret) {
|
|
12
12
|
return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.VALIDATION_FAILED);
|
|
13
13
|
}
|
|
14
14
|
var token = jsonwebtoken_1.default.sign(params, secret, {
|
|
15
|
-
algorithm: algorithm,
|
|
15
|
+
algorithm: algorithm || 'HS256',
|
|
16
16
|
audience: audience,
|
|
17
17
|
issuer: issuer,
|
|
18
18
|
jwtid: jwtid,
|
|
@@ -25,23 +25,28 @@ var createUserToken = function (args) {
|
|
|
25
25
|
return api_helpers_1.OpResult.ok(token);
|
|
26
26
|
};
|
|
27
27
|
exports.createUserToken = createUserToken;
|
|
28
|
-
var verifyUserToken = function (args) {
|
|
29
|
-
var _a = args || {},
|
|
28
|
+
var verifyUserToken = function (token, secret, args) {
|
|
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
31
|
return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.VALIDATION_FAILED);
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
try {
|
|
34
|
+
var obj = jsonwebtoken_1.default.verify(token, secret, {
|
|
35
|
+
algorithms: algorithms || ['HS256'],
|
|
36
|
+
audience: audience,
|
|
37
|
+
issuer: issuer,
|
|
38
|
+
ignoreExpiration: ignoreExpiration,
|
|
39
|
+
ignoreNotBefore: ignoreNotBefore,
|
|
40
|
+
subject: subject,
|
|
41
|
+
clockTolerance: clockTolerance,
|
|
42
|
+
maxAge: maxAge,
|
|
43
|
+
clockTimestamp: clockTimestamp,
|
|
44
|
+
nonce: nonce,
|
|
45
|
+
});
|
|
46
|
+
return api_helpers_1.OpResult.ok(obj);
|
|
47
|
+
}
|
|
48
|
+
catch (ex) {
|
|
49
|
+
return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.UNAUTHORIZED);
|
|
50
|
+
}
|
|
46
51
|
};
|
|
47
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.
|
|
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.
|
|
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.
|
|
54
|
-
"@sdflc/utils": "^1.0.18",
|
|
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.26",
|
|
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.18",
|
|
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
|
+
}
|
package/build/appBaseCore.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AppBaseCoreInterface, BaseCoreActionsInterface } from './interfaces';
|
|
2
|
-
import { BaseCore } from './baseCore';
|
|
3
|
-
declare class AppBaseCore extends BaseCore {
|
|
4
|
-
private gwSpace;
|
|
5
|
-
private interserviceApiKey?;
|
|
6
|
-
constructor(props: AppBaseCoreInterface);
|
|
7
|
-
authenticate(params: any, opt?: BaseCoreActionsInterface): Promise<(string | boolean)[]>;
|
|
8
|
-
}
|
|
9
|
-
export { AppBaseCore };
|
package/build/appBaseCore.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.AppBaseCore = void 0;
|
|
55
|
-
var baseCore_1 = require("./baseCore");
|
|
56
|
-
var AppBaseCore = /** @class */ (function (_super) {
|
|
57
|
-
__extends(AppBaseCore, _super);
|
|
58
|
-
function AppBaseCore(props) {
|
|
59
|
-
var _this = _super.call(this, props) || this;
|
|
60
|
-
_this.gwSpace = props.gwSpace;
|
|
61
|
-
_this.interserviceApiKey = props.interserviceApiKey;
|
|
62
|
-
return _this;
|
|
63
|
-
}
|
|
64
|
-
AppBaseCore.prototype.authenticate = function (params, opt) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
-
var context, space;
|
|
67
|
-
return __generator(this, function (_a) {
|
|
68
|
-
switch (_a.label) {
|
|
69
|
-
case 0:
|
|
70
|
-
context = this.context;
|
|
71
|
-
return [4 /*yield*/, this.gwSpace.get(context.spaceId || '')];
|
|
72
|
-
case 1:
|
|
73
|
-
space = _a.sent();
|
|
74
|
-
if (!space) {
|
|
75
|
-
return [2 /*return*/, [false, 'Space Not Found']];
|
|
76
|
-
}
|
|
77
|
-
context.space = space;
|
|
78
|
-
if (this.interserviceApiKey && context.apiKey === this.interserviceApiKey) {
|
|
79
|
-
return [2 /*return*/, [true, '']];
|
|
80
|
-
}
|
|
81
|
-
else if (space.apiKey && space.apiKey !== context.apiKey) {
|
|
82
|
-
return [2 /*return*/, [false, 'API Key is invalid']];
|
|
83
|
-
}
|
|
84
|
-
return [2 /*return*/, [true, '']];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
return AppBaseCore;
|
|
90
|
-
}(baseCore_1.BaseCore));
|
|
91
|
-
exports.AppBaseCore = AppBaseCore;
|