@minimaltech/node-infra 0.5.9-26 → 0.5.9-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/dist/base/controllers/relational.controller.d.ts +25 -11
- package/dist/base/controllers/relational.controller.js +42 -18
- package/dist/base/repositories/tz-crud.repository.js +1 -1
- package/dist/components/authenticate/component.js +0 -1
- package/dist/mixins/tz.mixin.d.ts +3 -0
- package/dist/mixins/tz.mixin.js +22 -5
- package/package.json +1 -1
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { ControllerClass } from '@loopback/core';
|
|
2
2
|
import { SchemaObject } from '@loopback/rest';
|
|
3
3
|
import { NullableType, TRelationType } from '../../common/types';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { BaseController } from './common';
|
|
7
|
-
export interface IRelationCrudControllerOptions {
|
|
4
|
+
import { BaseEntity, TBaseTzEntity } from '../models';
|
|
5
|
+
export interface IRelationCrudControllerOptions<S, T> {
|
|
8
6
|
association: {
|
|
9
7
|
entities: {
|
|
10
|
-
source:
|
|
11
|
-
|
|
8
|
+
source: typeof BaseEntity & {
|
|
9
|
+
prototype: S;
|
|
10
|
+
};
|
|
11
|
+
target: typeof BaseEntity & {
|
|
12
|
+
prototype: T;
|
|
13
|
+
};
|
|
12
14
|
};
|
|
13
15
|
repositories?: {
|
|
14
16
|
source: string;
|
|
@@ -34,10 +36,14 @@ export interface IRelationCrudControllerOptions {
|
|
|
34
36
|
export declare const defineRelationViewController: <S extends TBaseTzEntity, // Source Entity Type
|
|
35
37
|
T extends TBaseTzEntity, // Target Entity Type
|
|
36
38
|
TE extends TBaseTzEntity = any>(opts: {
|
|
37
|
-
baseClass?:
|
|
39
|
+
baseClass?: ControllerClass;
|
|
38
40
|
entities: {
|
|
39
|
-
source:
|
|
40
|
-
|
|
41
|
+
source: typeof BaseEntity & {
|
|
42
|
+
prototype: S;
|
|
43
|
+
};
|
|
44
|
+
target: typeof BaseEntity & {
|
|
45
|
+
prototype: T;
|
|
46
|
+
};
|
|
41
47
|
};
|
|
42
48
|
relation: {
|
|
43
49
|
name: string;
|
|
@@ -48,7 +54,15 @@ TE extends TBaseTzEntity = any>(opts: {
|
|
|
48
54
|
schema?: SchemaObject;
|
|
49
55
|
}) => ControllerClass;
|
|
50
56
|
export declare const defineAssociateController: <S extends TBaseTzEntity, T extends TBaseTzEntity, R extends TBaseTzEntity | NullableType>(opts: {
|
|
51
|
-
baseClass:
|
|
57
|
+
baseClass: ControllerClass;
|
|
58
|
+
entities: {
|
|
59
|
+
source: typeof BaseEntity & {
|
|
60
|
+
prototype: S;
|
|
61
|
+
};
|
|
62
|
+
target: typeof BaseEntity & {
|
|
63
|
+
prototype: T;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
52
66
|
relation: {
|
|
53
67
|
name: string;
|
|
54
68
|
type: TRelationType;
|
|
@@ -57,4 +71,4 @@ export declare const defineAssociateController: <S extends TBaseTzEntity, T exte
|
|
|
57
71
|
endPoint?: string;
|
|
58
72
|
schema?: SchemaObject;
|
|
59
73
|
}) => ControllerClass;
|
|
60
|
-
export declare const defineRelationCrudController: <S extends TBaseTzEntity, T extends TBaseTzEntity, R extends TBaseTzEntity | NullableType>(controllerOptions: IRelationCrudControllerOptions) => ControllerClass;
|
|
74
|
+
export declare const defineRelationCrudController: <S extends TBaseTzEntity, T extends TBaseTzEntity, R extends TBaseTzEntity | NullableType>(controllerOptions: IRelationCrudControllerOptions<S, T>) => ControllerClass;
|
|
@@ -38,6 +38,11 @@ const defineRelationViewController = (opts) => {
|
|
|
38
38
|
const { baseClass, entities, relation, defaultLimit = common_1.App.DEFAULT_QUERY_LIMIT, endPoint = '', schema, } = opts;
|
|
39
39
|
const restPath = `/{id}/${endPoint ? endPoint : relation.name}`;
|
|
40
40
|
const BaseClass = baseClass !== null && baseClass !== void 0 ? baseClass : common_2.BaseController;
|
|
41
|
+
const sourceIdPathParam = {
|
|
42
|
+
name: 'id',
|
|
43
|
+
in: 'path',
|
|
44
|
+
schema: (0, utilities_1.getIdSchema)(entities.source),
|
|
45
|
+
};
|
|
41
46
|
class ViewController extends BaseClass {
|
|
42
47
|
constructor(sourceRepository, targetRepository, getCurrentUser) {
|
|
43
48
|
super({ scope: `ViewController.${relation.name}` });
|
|
@@ -197,7 +202,7 @@ const defineRelationViewController = (opts) => {
|
|
|
197
202
|
},
|
|
198
203
|
},
|
|
199
204
|
}),
|
|
200
|
-
__param(0, rest_1.param
|
|
205
|
+
__param(0, (0, rest_1.param)(sourceIdPathParam)),
|
|
201
206
|
__param(1, rest_1.param.query.object('filter')),
|
|
202
207
|
__metadata("design:type", Function),
|
|
203
208
|
__metadata("design:paramtypes", [Object, Object]),
|
|
@@ -215,7 +220,7 @@ const defineRelationViewController = (opts) => {
|
|
|
215
220
|
},
|
|
216
221
|
},
|
|
217
222
|
}),
|
|
218
|
-
__param(0, rest_1.param
|
|
223
|
+
__param(0, (0, rest_1.param)(sourceIdPathParam)),
|
|
219
224
|
__param(1, rest_1.param.query.object('where')),
|
|
220
225
|
__metadata("design:type", Function),
|
|
221
226
|
__metadata("design:paramtypes", [Object, Object]),
|
|
@@ -226,8 +231,18 @@ const defineRelationViewController = (opts) => {
|
|
|
226
231
|
exports.defineRelationViewController = defineRelationViewController;
|
|
227
232
|
// --------------------------------------------------------------------------------------------------------------
|
|
228
233
|
const defineAssociateController = (opts) => {
|
|
229
|
-
const { baseClass, relation, defaultLimit = common_1.App.DEFAULT_QUERY_LIMIT, endPoint = '', schema, } = opts;
|
|
234
|
+
const { baseClass, entities, relation, defaultLimit = common_1.App.DEFAULT_QUERY_LIMIT, endPoint = '', schema, } = opts;
|
|
230
235
|
const restPath = `/{id}/${endPoint ? endPoint : relation.name}`;
|
|
236
|
+
const sourceIdPathParam = {
|
|
237
|
+
name: 'id',
|
|
238
|
+
in: 'path',
|
|
239
|
+
schema: (0, utilities_1.getIdSchema)(entities.source),
|
|
240
|
+
};
|
|
241
|
+
const targetIdPathParam = {
|
|
242
|
+
name: 'id',
|
|
243
|
+
in: 'path',
|
|
244
|
+
schema: (0, utilities_1.getIdSchema)(entities.target),
|
|
245
|
+
};
|
|
231
246
|
class AssociationController extends baseClass {
|
|
232
247
|
constructor(sourceRepository, targetRepository, getCurrentUser) {
|
|
233
248
|
super(sourceRepository, targetRepository, getCurrentUser);
|
|
@@ -275,10 +290,10 @@ const defineAssociateController = (opts) => {
|
|
|
275
290
|
},
|
|
276
291
|
},
|
|
277
292
|
}),
|
|
278
|
-
__param(0, rest_1.param
|
|
279
|
-
__param(1, rest_1.param
|
|
293
|
+
__param(0, (0, rest_1.param)(sourceIdPathParam)),
|
|
294
|
+
__param(1, (0, rest_1.param)(targetIdPathParam)),
|
|
280
295
|
__metadata("design:type", Function),
|
|
281
|
-
__metadata("design:paramtypes", [
|
|
296
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
282
297
|
__metadata("design:returntype", Promise)
|
|
283
298
|
], AssociationController.prototype, "link", null);
|
|
284
299
|
__decorate([
|
|
@@ -290,10 +305,10 @@ const defineAssociateController = (opts) => {
|
|
|
290
305
|
},
|
|
291
306
|
},
|
|
292
307
|
}),
|
|
293
|
-
__param(0, rest_1.param
|
|
294
|
-
__param(1, rest_1.param
|
|
308
|
+
__param(0, (0, rest_1.param)(sourceIdPathParam)),
|
|
309
|
+
__param(1, (0, rest_1.param)(targetIdPathParam)),
|
|
295
310
|
__metadata("design:type", Function),
|
|
296
|
-
__metadata("design:paramtypes", [
|
|
311
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
297
312
|
__metadata("design:returntype", Promise)
|
|
298
313
|
], AssociationController.prototype, "unlink", null);
|
|
299
314
|
return AssociationController;
|
|
@@ -320,7 +335,10 @@ const defineRelationCrudController = (controllerOptions) => {
|
|
|
320
335
|
const restPath = `{id}/${endPoint}`;
|
|
321
336
|
const ViewController = (0, exports.defineRelationViewController)({
|
|
322
337
|
baseClass: common_2.BaseController,
|
|
323
|
-
entities
|
|
338
|
+
entities: {
|
|
339
|
+
source: entities.source,
|
|
340
|
+
target: entities.target,
|
|
341
|
+
},
|
|
324
342
|
relation,
|
|
325
343
|
defaultLimit,
|
|
326
344
|
endPoint,
|
|
@@ -328,6 +346,7 @@ const defineRelationCrudController = (controllerOptions) => {
|
|
|
328
346
|
});
|
|
329
347
|
const AssociationController = (0, exports.defineAssociateController)({
|
|
330
348
|
baseClass: ViewController,
|
|
349
|
+
entities,
|
|
331
350
|
relation,
|
|
332
351
|
defaultLimit,
|
|
333
352
|
endPoint,
|
|
@@ -338,6 +357,11 @@ const defineRelationCrudController = (controllerOptions) => {
|
|
|
338
357
|
if (!useControlTarget) {
|
|
339
358
|
return ExtendsableClass;
|
|
340
359
|
}
|
|
360
|
+
const sourceIdPathParam = {
|
|
361
|
+
name: 'id',
|
|
362
|
+
in: 'path',
|
|
363
|
+
schema: (0, utilities_1.getIdSchema)(entities.source),
|
|
364
|
+
};
|
|
341
365
|
// -----------------------------------------------------------------------------------------------
|
|
342
366
|
class Controller extends ExtendsableClass {
|
|
343
367
|
constructor(sourceRepository, targetRepository, getCurrentUser) {
|
|
@@ -405,7 +429,7 @@ const defineRelationCrudController = (controllerOptions) => {
|
|
|
405
429
|
},
|
|
406
430
|
},
|
|
407
431
|
}),
|
|
408
|
-
__param(0, rest_1.param
|
|
432
|
+
__param(0, (0, rest_1.param)(sourceIdPathParam)),
|
|
409
433
|
__param(1, (0, rest_1.requestBody)({
|
|
410
434
|
required: true,
|
|
411
435
|
content: {
|
|
@@ -413,7 +437,7 @@ const defineRelationCrudController = (controllerOptions) => {
|
|
|
413
437
|
},
|
|
414
438
|
})),
|
|
415
439
|
__metadata("design:type", Function),
|
|
416
|
-
__metadata("design:paramtypes", [
|
|
440
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
417
441
|
__metadata("design:returntype", Promise)
|
|
418
442
|
], Controller.prototype, "create", null);
|
|
419
443
|
__decorate([
|
|
@@ -425,7 +449,7 @@ const defineRelationCrudController = (controllerOptions) => {
|
|
|
425
449
|
},
|
|
426
450
|
},
|
|
427
451
|
}),
|
|
428
|
-
__param(0, rest_1.param
|
|
452
|
+
__param(0, (0, rest_1.param)(sourceIdPathParam)),
|
|
429
453
|
__param(1, (0, rest_1.requestBody)({
|
|
430
454
|
required: true,
|
|
431
455
|
content: {
|
|
@@ -434,7 +458,7 @@ const defineRelationCrudController = (controllerOptions) => {
|
|
|
434
458
|
})),
|
|
435
459
|
__param(2, rest_1.param.query.object('where')),
|
|
436
460
|
__metadata("design:type", Function),
|
|
437
|
-
__metadata("design:paramtypes", [
|
|
461
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
438
462
|
__metadata("design:returntype", Promise)
|
|
439
463
|
], Controller.prototype, "patch", null);
|
|
440
464
|
__decorate([
|
|
@@ -446,14 +470,14 @@ const defineRelationCrudController = (controllerOptions) => {
|
|
|
446
470
|
},
|
|
447
471
|
},
|
|
448
472
|
}),
|
|
449
|
-
__param(0, rest_1.param
|
|
473
|
+
__param(0, (0, rest_1.param)(sourceIdPathParam)),
|
|
450
474
|
__param(1, rest_1.param.query.object('where')),
|
|
451
475
|
__metadata("design:type", Function),
|
|
452
|
-
__metadata("design:paramtypes", [
|
|
476
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
453
477
|
__metadata("design:returntype", Promise)
|
|
454
478
|
], Controller.prototype, "delete", null);
|
|
455
|
-
(0, core_1.inject)(`repositories.${(_a = repositories === null || repositories === void 0 ? void 0 : repositories.source) !== null && _a !== void 0 ? _a : `${entities.source}Repository`}`)(Controller, undefined, 0);
|
|
456
|
-
(0, core_1.inject)(`repositories.${(_b = repositories === null || repositories === void 0 ? void 0 : repositories.target) !== null && _b !== void 0 ? _b : `${entities.target}Repository`}`)(Controller, undefined, 1);
|
|
479
|
+
(0, core_1.inject)(`repositories.${(_a = repositories === null || repositories === void 0 ? void 0 : repositories.source) !== null && _a !== void 0 ? _a : `${entities.source.name}Repository`}`)(Controller, undefined, 0);
|
|
480
|
+
(0, core_1.inject)(`repositories.${(_b = repositories === null || repositories === void 0 ? void 0 : repositories.target) !== null && _b !== void 0 ? _b : `${entities.target.name}Repository`}`)(Controller, undefined, 1);
|
|
457
481
|
if (options.doInjectCurrentUser) {
|
|
458
482
|
core_1.inject.getter(security_1.SecurityBindings.USER, { optional: true })(Controller, undefined, 2);
|
|
459
483
|
}
|
|
@@ -204,7 +204,7 @@ class TzCrudRepository extends base_repository_1.AbstractTzRepository {
|
|
|
204
204
|
if (options === null || options === void 0 ? void 0 : options.newInstance) {
|
|
205
205
|
entity.createdAt = new Date();
|
|
206
206
|
}
|
|
207
|
-
if (!options.ignoreModified) {
|
|
207
|
+
if (!options.ignoreModified && 'modifiedAt' in entity) {
|
|
208
208
|
entity.modifiedAt = new Date();
|
|
209
209
|
}
|
|
210
210
|
return entity;
|
|
@@ -104,7 +104,6 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
|
|
|
104
104
|
const oauth2Controller = (0, controllers_1.defineOAuth2Controller)(oauth2Options.restOptions);
|
|
105
105
|
this.application.controller(oauth2Controller);
|
|
106
106
|
this.application.mountExpressRouter((_b = (_a = oauth2Options.restOptions) === null || _a === void 0 ? void 0 : _a.restPath) !== null && _b !== void 0 ? _b : '/oauth2', controllers_1.DefaultOAuth2ExpressServer.getInstance({
|
|
107
|
-
context: this.application,
|
|
108
107
|
viewFolder,
|
|
109
108
|
authServiceKey: handler.authServiceKey,
|
|
110
109
|
injectionGetter: this.application.getInjectionGetter(),
|
package/dist/mixins/tz.mixin.js
CHANGED
|
@@ -12,15 +12,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.TzMixin = void 0;
|
|
13
13
|
const repository_1 = require("@loopback/repository");
|
|
14
14
|
const TzMixin = (superClass, opts) => {
|
|
15
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
15
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
16
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.modifiedAt.enable)) {
|
|
17
|
+
class Mixed extends superClass {
|
|
18
|
+
}
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, repository_1.property)({
|
|
21
|
+
type: 'date',
|
|
22
|
+
postgresql: {
|
|
23
|
+
columnName: (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.createdAt) === null || _a === void 0 ? void 0 : _a.columnName) !== null && _b !== void 0 ? _b : 'created_at',
|
|
24
|
+
dataType: (_d = (_c = opts === null || opts === void 0 ? void 0 : opts.createdAt) === null || _c === void 0 ? void 0 : _c.dataType) !== null && _d !== void 0 ? _d : 'TIMESTAMPTZ',
|
|
25
|
+
default: 'NOW()',
|
|
26
|
+
nullable: 'NO',
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
__metadata("design:type", Date)
|
|
30
|
+
], Mixed.prototype, "createdAt", void 0);
|
|
31
|
+
return Mixed;
|
|
32
|
+
}
|
|
16
33
|
class Mixed extends superClass {
|
|
17
34
|
}
|
|
18
35
|
__decorate([
|
|
19
36
|
(0, repository_1.property)({
|
|
20
37
|
type: 'date',
|
|
21
38
|
postgresql: {
|
|
22
|
-
columnName: (
|
|
23
|
-
dataType: (
|
|
39
|
+
columnName: (_f = (_e = opts === null || opts === void 0 ? void 0 : opts.createdAt) === null || _e === void 0 ? void 0 : _e.columnName) !== null && _f !== void 0 ? _f : 'created_at',
|
|
40
|
+
dataType: (_h = (_g = opts === null || opts === void 0 ? void 0 : opts.createdAt) === null || _g === void 0 ? void 0 : _g.dataType) !== null && _h !== void 0 ? _h : 'TIMESTAMPTZ',
|
|
24
41
|
default: 'NOW()',
|
|
25
42
|
nullable: 'NO',
|
|
26
43
|
},
|
|
@@ -31,8 +48,8 @@ const TzMixin = (superClass, opts) => {
|
|
|
31
48
|
(0, repository_1.property)({
|
|
32
49
|
type: 'date',
|
|
33
50
|
postgresql: {
|
|
34
|
-
columnName: (
|
|
35
|
-
dataType: (
|
|
51
|
+
columnName: (_k = (_j = opts === null || opts === void 0 ? void 0 : opts.modifiedAt) === null || _j === void 0 ? void 0 : _j.columnName) !== null && _k !== void 0 ? _k : 'modified_at',
|
|
52
|
+
dataType: (_m = (_l = opts === null || opts === void 0 ? void 0 : opts.modifiedAt) === null || _l === void 0 ? void 0 : _l.dataType) !== null && _m !== void 0 ? _m : 'TIMESTAMPTZ',
|
|
36
53
|
default: 'NOW()',
|
|
37
54
|
nullable: 'NO',
|
|
38
55
|
},
|