taon 19.0.52 → 19.0.54
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/browser/fesm2022/taon.mjs +407 -239
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-angular-service.d.ts +3 -6
- package/browser/lib/base-classes/base-controller.d.ts +11 -0
- package/browser/lib/base-classes/base-file-upload.middleware.d.ts +15 -0
- package/browser/lib/base-classes/base-middleware.d.ts +30 -8
- package/browser/lib/decorators/classes/controller-config.d.ts +10 -0
- package/browser/lib/decorators/classes/controller-decorator.d.ts +2 -12
- package/browser/lib/decorators/classes/controller-options.d.ts +12 -0
- package/browser/lib/decorators/classes/entity-decorator.d.ts +2 -2
- package/browser/lib/decorators/classes/middleware-decorator.d.ts +2 -2
- package/browser/lib/decorators/classes/migration-decorator.d.ts +2 -2
- package/browser/lib/decorators/classes/provider-decorator.d.ts +2 -2
- package/browser/lib/decorators/classes/repository-decorator.d.ts +2 -2
- package/browser/lib/decorators/classes/subscriber-decorator.d.ts +2 -2
- package/browser/lib/decorators/decorator-abstract-opt.d.ts +4 -0
- package/browser/lib/decorators/http/http-methods-decorators.d.ts +8 -5
- package/browser/lib/endpoint-context.d.ts +4 -3
- package/browser/lib/helpers/class-helpers.d.ts +7 -3
- package/browser/lib/helpers/taon-helpers.d.ts +2 -1
- package/browser/lib/index.d.ts +2 -1
- package/browser/lib/models.d.ts +15 -22
- package/browser/package.json +1 -1
- package/lib/base-classes/base-angular-service.d.ts +3 -6
- package/lib/base-classes/base-angular-service.js +12 -16
- package/lib/base-classes/base-angular-service.js.map +1 -1
- package/lib/base-classes/base-context.js +4 -0
- package/lib/base-classes/base-context.js.map +1 -1
- package/lib/base-classes/base-controller.d.ts +12 -0
- package/lib/base-classes/base-controller.js +56 -1
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/base-classes/base-file-upload.middleware.d.ts +14 -0
- package/lib/base-classes/base-file-upload.middleware.js +85 -0
- package/lib/base-classes/base-file-upload.middleware.js.map +1 -0
- package/lib/base-classes/base-middleware.d.ts +30 -12
- package/lib/base-classes/base-middleware.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/decorators/classes/controller-config.d.ts +9 -0
- package/lib/decorators/classes/controller-config.js +11 -0
- package/lib/decorators/classes/controller-config.js.map +1 -0
- package/lib/decorators/classes/controller-decorator.d.ts +2 -12
- package/lib/decorators/classes/controller-decorator.js +0 -13
- package/lib/decorators/classes/controller-decorator.js.map +1 -1
- package/lib/decorators/classes/controller-options.d.ts +11 -0
- package/lib/decorators/classes/controller-options.js +16 -0
- package/lib/decorators/classes/controller-options.js.map +1 -0
- package/lib/decorators/classes/entity-decorator.d.ts +2 -2
- package/lib/decorators/classes/entity-decorator.js +7 -9
- package/lib/decorators/classes/entity-decorator.js.map +1 -1
- package/lib/decorators/classes/middleware-decorator.d.ts +2 -2
- package/lib/decorators/classes/middleware-decorator.js +2 -2
- package/lib/decorators/classes/middleware-decorator.js.map +1 -1
- package/lib/decorators/classes/migration-decorator.d.ts +2 -2
- package/lib/decorators/classes/migration-decorator.js +2 -2
- package/lib/decorators/classes/migration-decorator.js.map +1 -1
- package/lib/decorators/classes/provider-decorator.d.ts +2 -2
- package/lib/decorators/classes/provider-decorator.js +2 -2
- package/lib/decorators/classes/provider-decorator.js.map +1 -1
- package/lib/decorators/classes/repository-decorator.d.ts +2 -2
- package/lib/decorators/classes/repository-decorator.js +2 -2
- package/lib/decorators/classes/repository-decorator.js.map +1 -1
- package/lib/decorators/classes/subscriber-decorator.d.ts +2 -2
- package/lib/decorators/classes/subscriber-decorator.js +2 -2
- package/lib/decorators/classes/subscriber-decorator.js.map +1 -1
- package/lib/decorators/decorator-abstract-opt.d.ts +3 -0
- package/lib/decorators/decorator-abstract-opt.js +8 -0
- package/lib/decorators/decorator-abstract-opt.js.map +1 -0
- package/lib/decorators/http/http-methods-decorators.d.ts +8 -5
- package/lib/decorators/http/http-methods-decorators.js +3 -2
- package/lib/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib/endpoint-context.d.ts +4 -3
- package/lib/endpoint-context.js +128 -75
- package/lib/endpoint-context.js.map +1 -1
- package/lib/helpers/class-helpers.d.ts +7 -3
- package/lib/helpers/class-helpers.js +12 -6
- package/lib/helpers/class-helpers.js.map +1 -1
- package/lib/helpers/taon-helpers.d.ts +2 -1
- package/lib/helpers/taon-helpers.js +1 -1
- package/lib/helpers/taon-helpers.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +16 -24
- package/lib/models.js +4 -31
- package/lib/models.js.map +1 -1
- package/lib/realtime/realtime-client.js +2 -1
- package/lib/realtime/realtime-client.js.map +1 -1
- package/lib/ui/directives/index.d.ts +3 -0
- package/lib/ui/directives/index.js +5 -0
- package/lib/ui/directives/index.js.map +1 -0
- package/lib/ui/directives/safe.pipe.d.ts +7 -0
- package/lib/ui/directives/taon-inject-html.directive.d.ts +6 -0
- package/lib/ui/directives/taon-long-press.directive.d.ts +22 -0
- package/lib/ui/directives/view-mode.d.ts +5 -0
- package/lib/ui/directives/view-mode.js +10 -0
- package/lib/ui/directives/view-mode.js.map +1 -0
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +43 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.d.ts +5 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js +3 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +1 -0
- package/lib/ui/taon-full-material.module.d.ts +5 -0
- package/lib/ui/taon-github-fork-me-corner/index.d.ts +2 -0
- package/lib/ui/taon-github-fork-me-corner/index.js +5 -0
- package/lib/ui/taon-github-fork-me-corner/index.js.map +1 -0
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.d.ts +3 -0
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.d.ts +2 -0
- package/lib/ui/taon-github-fork-me-ribbon/index.d.ts +2 -0
- package/lib/ui/taon-github-fork-me-ribbon/index.js +5 -0
- package/lib/ui/taon-github-fork-me-ribbon/index.js.map +1 -0
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.component.d.ts +3 -0
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.module.d.ts +2 -0
- package/lib/ui/taon-notifications/index.d.ts +4 -0
- package/lib/ui/taon-notifications/index.js +24 -0
- package/lib/ui/taon-notifications/index.js.map +1 -0
- package/lib/ui/taon-notifications/taon-notifications.component.d.ts +9 -0
- package/lib/ui/taon-notifications/taon-notifications.models.d.ts +6 -0
- package/lib/ui/taon-notifications/taon-notifications.models.js +5 -0
- package/lib/ui/taon-notifications/taon-notifications.models.js.map +1 -0
- package/lib/ui/taon-notifications/taon-notifications.module.d.ts +2 -0
- package/lib/ui/taon-notifications/taon-notifications.service.d.ts +11 -0
- package/lib/ui/taon-progress-bar/index.d.ts +2 -0
- package/lib/ui/taon-progress-bar/index.js +5 -0
- package/lib/ui/taon-progress-bar/index.js.map +1 -0
- package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +13 -0
- package/lib/ui/taon-progress-bar/taon-progress-bar.module.d.ts +2 -0
- package/lib/ui/taon-session-passcode/index.d.ts +1 -0
- package/lib/ui/taon-session-passcode/index.js +5 -0
- package/lib/ui/taon-session-passcode/index.js.map +1 -0
- package/lib/ui/taon-session-passcode/taon-session-passcode.component.d.ts +35 -0
- package/lib/ui/taon-table/index.d.ts +2 -0
- package/lib/ui/taon-table/index.js +5 -0
- package/lib/ui/taon-table/index.js.map +1 -0
- package/lib/ui/taon-table/taon-table.component.d.ts +34 -0
- package/lib/ui/taon-table/taon-table.module.d.ts +2 -0
- package/lib/ui/taon.models.d.ts +11 -0
- package/lib/ui/taon.models.js +3 -0
- package/lib/ui/taon.models.js.map +1 -0
- package/package.json +1 -1
- package/tmp-environment.json +39 -0
- package/websql/fesm2022/taon.mjs +407 -235
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-angular-service.d.ts +3 -6
- package/websql/lib/base-classes/base-controller.d.ts +11 -0
- package/websql/lib/base-classes/base-file-upload.middleware.d.ts +15 -0
- package/websql/lib/base-classes/base-middleware.d.ts +30 -12
- package/websql/lib/decorators/classes/controller-config.d.ts +10 -0
- package/websql/lib/decorators/classes/controller-decorator.d.ts +2 -12
- package/websql/lib/decorators/classes/controller-options.d.ts +12 -0
- package/websql/lib/decorators/classes/entity-decorator.d.ts +2 -2
- package/websql/lib/decorators/classes/middleware-decorator.d.ts +2 -2
- package/websql/lib/decorators/classes/migration-decorator.d.ts +2 -2
- package/websql/lib/decorators/classes/provider-decorator.d.ts +2 -2
- package/websql/lib/decorators/classes/repository-decorator.d.ts +2 -2
- package/websql/lib/decorators/classes/subscriber-decorator.d.ts +2 -2
- package/websql/lib/decorators/decorator-abstract-opt.d.ts +4 -0
- package/websql/lib/decorators/http/http-methods-decorators.d.ts +8 -5
- package/websql/lib/endpoint-context.d.ts +4 -3
- package/websql/lib/helpers/class-helpers.d.ts +7 -3
- package/websql/lib/helpers/taon-helpers.d.ts +2 -1
- package/websql/lib/index.d.ts +2 -1
- package/websql/lib/models.d.ts +16 -24
- package/websql/package.json +1 -1
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import * as coreHelpers from 'tnp-core/browser';
|
|
3
|
-
import { _, Utils, Helpers, UtilsOs } from 'tnp-core/browser';
|
|
3
|
+
import { _, Utils, Helpers, UtilsOs, crossPlatformPath } from 'tnp-core/browser';
|
|
4
4
|
import { __decorate, __metadata, __param } from 'tslib';
|
|
5
5
|
import { walk } from 'lodash-walk-object/browser';
|
|
6
|
-
import { OrignalClassKey, Table } from 'taon-typeorm/browser';
|
|
7
6
|
import { SYMBOL, CLASS } from 'typescript-class-helpers/browser';
|
|
8
|
-
import {
|
|
7
|
+
import { OrignalClassKey, Table } from 'taon-typeorm/browser';
|
|
9
8
|
import * as i0 from '@angular/core';
|
|
10
9
|
import { InjectionToken, inject as inject$1, Injectable } from '@angular/core';
|
|
11
10
|
import axios from 'axios';
|
|
12
11
|
import { JSON10 } from 'json10/browser';
|
|
12
|
+
import { Models as Models$1, Resource, RestHeaders, Mapping } from 'ng2-rest/browser';
|
|
13
13
|
import { Observable, from, Subject } from 'rxjs';
|
|
14
14
|
import * as JSON5 from 'json5';
|
|
15
15
|
import { io } from 'socket.io-client';
|
|
16
16
|
|
|
17
|
+
class DecoratorAbstractOpt {
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class TaonControllerOptions extends DecoratorAbstractOpt {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class ControllerConfig extends TaonControllerOptions {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.methods = {};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
17
30
|
var Symbols;
|
|
18
31
|
(function (Symbols) {
|
|
19
32
|
Symbols.ctxInClassOrClassObj = Symbol();
|
|
@@ -204,127 +217,9 @@ var Validators;
|
|
|
204
217
|
};
|
|
205
218
|
})(Validators || (Validators = {}));
|
|
206
219
|
|
|
207
|
-
|
|
208
|
-
(function (Models) {
|
|
209
|
-
//#region models / class types
|
|
210
|
-
let ClassType;
|
|
211
|
-
(function (ClassType) {
|
|
212
|
-
ClassType["ENTITY"] = "ENTITY";
|
|
213
|
-
ClassType["CONTROLLER"] = "CONTROLLER";
|
|
214
|
-
ClassType["REPOSITORY"] = "REPOSITORY";
|
|
215
|
-
ClassType["PROVIDER"] = "PROVIDER";
|
|
216
|
-
ClassType["SUBSCRIBER"] = "SUBSCRIBER";
|
|
217
|
-
ClassType["MIGRATION"] = "MIGRATION";
|
|
218
|
-
ClassType["MIDDLEWARE"] = "MIDDLEWARE";
|
|
219
|
-
})(ClassType = Models.ClassType || (Models.ClassType = {}));
|
|
220
|
-
Models.ClassTypeKey = {
|
|
221
|
-
[ClassType.ENTITY]: 'entities',
|
|
222
|
-
[ClassType.CONTROLLER]: 'controllers',
|
|
223
|
-
[ClassType.REPOSITORY]: 'repositories',
|
|
224
|
-
[ClassType.PROVIDER]: 'providers',
|
|
225
|
-
[ClassType.SUBSCRIBER]: 'subscribers',
|
|
226
|
-
[ClassType.MIGRATION]: 'migrations',
|
|
227
|
-
[ClassType.MIDDLEWARE]: 'middlewares',
|
|
228
|
-
};
|
|
229
|
-
//#endregion
|
|
230
|
-
//#region models / database connection options
|
|
231
|
-
class DatabaseConfigTypeOrm {
|
|
232
|
-
}
|
|
233
|
-
Models.DatabaseConfigTypeOrm = DatabaseConfigTypeOrm;
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region models / database config
|
|
236
|
-
class DatabaseConfig extends DatabaseConfigTypeOrm {
|
|
237
|
-
static from(databasePartialConfig) {
|
|
238
|
-
return _.merge(new DatabaseConfig(), databasePartialConfig);
|
|
239
|
-
}
|
|
240
|
-
get databaseConfigTypeORM() {
|
|
241
|
-
/* */
|
|
242
|
-
/* */
|
|
243
|
-
/* */
|
|
244
|
-
/* */
|
|
245
|
-
/* */
|
|
246
|
-
/* */
|
|
247
|
-
/* */
|
|
248
|
-
/* */
|
|
249
|
-
/* */
|
|
250
|
-
/* */
|
|
251
|
-
/* */
|
|
252
|
-
/* */
|
|
253
|
-
/* */
|
|
254
|
-
/* */
|
|
255
|
-
return (void 0);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
Models.DatabaseConfig = DatabaseConfig;
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region models / decorator abstract options
|
|
261
|
-
class DecoratorAbstractOpt {
|
|
262
|
-
}
|
|
263
|
-
Models.DecoratorAbstractOpt = DecoratorAbstractOpt;
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region models / param config
|
|
266
|
-
class ParamConfig {
|
|
267
|
-
}
|
|
268
|
-
Models.ParamConfig = ParamConfig;
|
|
269
|
-
//#endregion
|
|
270
|
-
//#region models / method config
|
|
271
|
-
class MethodConfig {
|
|
272
|
-
constructor() {
|
|
273
|
-
/* */
|
|
274
|
-
/* */
|
|
275
|
-
this.parameters = {};
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
Models.MethodConfig = MethodConfig;
|
|
279
|
-
//#endregion
|
|
280
|
-
//#region models / controller config
|
|
281
|
-
class ControllerConfig extends DecoratorAbstractOpt {
|
|
282
|
-
constructor() {
|
|
283
|
-
super(...arguments);
|
|
284
|
-
this.methods = {};
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
Models.ControllerConfig = ControllerConfig;
|
|
288
|
-
//#endregion
|
|
289
|
-
//#region models / runtime controller config
|
|
290
|
-
class RuntimeControllerConfig extends ControllerConfig {
|
|
291
|
-
}
|
|
292
|
-
Models.RuntimeControllerConfig = RuntimeControllerConfig;
|
|
293
|
-
//#endregion
|
|
294
|
-
//#region models / http
|
|
295
|
-
let Http;
|
|
296
|
-
(function (Http) {
|
|
297
|
-
Http.Rest = Models$1;
|
|
298
|
-
class Errors {
|
|
299
|
-
constructor(message, code = 400) {
|
|
300
|
-
this.message = message;
|
|
301
|
-
this.code = code;
|
|
302
|
-
this.toString = () => {
|
|
303
|
-
return this.message;
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
static create(message, code = 400) {
|
|
307
|
-
return new Errors(message, code);
|
|
308
|
-
}
|
|
309
|
-
static entityNotFound(entity) {
|
|
310
|
-
return Errors.create(`Entity ${ClassHelpers.getName(entity)} not found`);
|
|
311
|
-
}
|
|
312
|
-
static custom(message, code = 400) {
|
|
313
|
-
return Errors.create(message, code);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
Http.Errors = Errors;
|
|
317
|
-
/* */
|
|
318
|
-
/* */
|
|
319
|
-
/* */
|
|
320
|
-
/* */
|
|
321
|
-
/* */
|
|
322
|
-
})(Http = Models.Http || (Models.Http = {}));
|
|
323
|
-
//#endregion
|
|
324
|
-
})(Models || (Models = {}));
|
|
325
|
-
|
|
326
|
-
/* */
|
|
220
|
+
//#region imports
|
|
327
221
|
/* */
|
|
222
|
+
//#endregion
|
|
328
223
|
var ClassHelpers;
|
|
329
224
|
(function (ClassHelpers) {
|
|
330
225
|
//#region get class from name
|
|
@@ -429,7 +324,7 @@ var ClassHelpers;
|
|
|
429
324
|
//#region get all metadata for controller
|
|
430
325
|
ClassHelpers.getControllerConfig = (target) => {
|
|
431
326
|
const classMetadataOptions = Reflect.getMetadata(Symbols.metadata.options.controller, target);
|
|
432
|
-
const classMetadata = _.merge(new
|
|
327
|
+
const classMetadata = _.merge(new ControllerConfig(), classMetadataOptions);
|
|
433
328
|
// Iterate over all methods of the class
|
|
434
329
|
const methodNames = ClassHelpers.getMethodsNames(target); // Object.getOwnPropertyNames(target.prototype);
|
|
435
330
|
// console.log(`methodNames for ${ClassHelpers.getName(target)} `, methodNames)
|
|
@@ -467,6 +362,12 @@ var ClassHelpers;
|
|
|
467
362
|
'toLocaleString',
|
|
468
363
|
];
|
|
469
364
|
//#endregion
|
|
365
|
+
/**
|
|
366
|
+
* Express async handler for middleware functions.
|
|
367
|
+
*/
|
|
368
|
+
ClassHelpers.asyncHandler = fn => (req, res, next) => {
|
|
369
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
370
|
+
};
|
|
470
371
|
ClassHelpers.getMethodsNames = (classOrClassInstance, allMethodsNames = []) => {
|
|
471
372
|
if (!classOrClassInstance) {
|
|
472
373
|
return Utils.uniqArray(allMethodsNames);
|
|
@@ -718,29 +619,26 @@ const inject = (entity) => {
|
|
|
718
619
|
//#region @browser
|
|
719
620
|
//#endregion
|
|
720
621
|
class BaseAngularsService {
|
|
622
|
+
//#endregion
|
|
721
623
|
constructor() {
|
|
722
624
|
//#region @browser
|
|
723
625
|
this.currentContext = inject$1(TAON_CONTEXT);
|
|
724
|
-
//#region @browser
|
|
725
|
-
this.CURRENT_HOST_BACKEND_PORT = inject$1(CURRENT_HOST_BACKEND_PORT, {
|
|
726
|
-
optional: true,
|
|
727
|
-
});
|
|
728
|
-
// #endregion
|
|
729
626
|
}
|
|
627
|
+
injectController(ctor,
|
|
730
628
|
/**
|
|
731
|
-
*
|
|
732
|
-
* Returns the host URL for the backend service
|
|
733
|
-
* that is running on localhost (normal NodeJS/ExpressJS mode).
|
|
629
|
+
* optional override context
|
|
734
630
|
*/
|
|
735
|
-
|
|
736
|
-
return
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
631
|
+
overrideCurrentContext) {
|
|
632
|
+
return inject(() => {
|
|
633
|
+
let currentContext;
|
|
634
|
+
//#region @browser
|
|
635
|
+
currentContext = overrideCurrentContext ? overrideCurrentContext : this.currentContext;
|
|
636
|
+
//#endregion
|
|
637
|
+
if (!currentContext) {
|
|
638
|
+
throw new Error('No context available. Make sure to initialize the context before injecting controllers.');
|
|
639
|
+
}
|
|
640
|
+
return currentContext ? currentContext.getClass(ctor) : void 0;
|
|
641
|
+
});
|
|
744
642
|
}
|
|
745
643
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: BaseAngularsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
746
644
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: BaseAngularsService }); }
|
|
@@ -1393,6 +1291,107 @@ var TaonHelpers;
|
|
|
1393
1291
|
//#endregion
|
|
1394
1292
|
})(TaonHelpers || (TaonHelpers = {}));
|
|
1395
1293
|
|
|
1294
|
+
var Models;
|
|
1295
|
+
(function (Models) {
|
|
1296
|
+
//#region models / class types
|
|
1297
|
+
let ClassType;
|
|
1298
|
+
(function (ClassType) {
|
|
1299
|
+
ClassType["ENTITY"] = "ENTITY";
|
|
1300
|
+
ClassType["CONTROLLER"] = "CONTROLLER";
|
|
1301
|
+
ClassType["REPOSITORY"] = "REPOSITORY";
|
|
1302
|
+
ClassType["PROVIDER"] = "PROVIDER";
|
|
1303
|
+
ClassType["SUBSCRIBER"] = "SUBSCRIBER";
|
|
1304
|
+
ClassType["MIGRATION"] = "MIGRATION";
|
|
1305
|
+
ClassType["MIDDLEWARE"] = "MIDDLEWARE";
|
|
1306
|
+
})(ClassType = Models.ClassType || (Models.ClassType = {}));
|
|
1307
|
+
Models.ClassTypeKey = {
|
|
1308
|
+
[ClassType.ENTITY]: 'entities',
|
|
1309
|
+
[ClassType.CONTROLLER]: 'controllers',
|
|
1310
|
+
[ClassType.REPOSITORY]: 'repositories',
|
|
1311
|
+
[ClassType.PROVIDER]: 'providers',
|
|
1312
|
+
[ClassType.SUBSCRIBER]: 'subscribers',
|
|
1313
|
+
[ClassType.MIGRATION]: 'migrations',
|
|
1314
|
+
[ClassType.MIDDLEWARE]: 'middlewares',
|
|
1315
|
+
};
|
|
1316
|
+
//#endregion
|
|
1317
|
+
//#region models / database connection options
|
|
1318
|
+
class DatabaseConfigTypeOrm {
|
|
1319
|
+
}
|
|
1320
|
+
Models.DatabaseConfigTypeOrm = DatabaseConfigTypeOrm;
|
|
1321
|
+
//#endregion
|
|
1322
|
+
//#region models / database config
|
|
1323
|
+
class DatabaseConfig extends DatabaseConfigTypeOrm {
|
|
1324
|
+
static from(databasePartialConfig) {
|
|
1325
|
+
return _.merge(new DatabaseConfig(), databasePartialConfig);
|
|
1326
|
+
}
|
|
1327
|
+
get databaseConfigTypeORM() {
|
|
1328
|
+
/* */
|
|
1329
|
+
/* */
|
|
1330
|
+
/* */
|
|
1331
|
+
/* */
|
|
1332
|
+
/* */
|
|
1333
|
+
/* */
|
|
1334
|
+
/* */
|
|
1335
|
+
/* */
|
|
1336
|
+
/* */
|
|
1337
|
+
/* */
|
|
1338
|
+
/* */
|
|
1339
|
+
/* */
|
|
1340
|
+
/* */
|
|
1341
|
+
/* */
|
|
1342
|
+
return (void 0);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
Models.DatabaseConfig = DatabaseConfig;
|
|
1346
|
+
//#endregion
|
|
1347
|
+
//#region models / param config
|
|
1348
|
+
class ParamConfig {
|
|
1349
|
+
}
|
|
1350
|
+
Models.ParamConfig = ParamConfig;
|
|
1351
|
+
//#endregion
|
|
1352
|
+
//#region models / method config
|
|
1353
|
+
/**
|
|
1354
|
+
* @link './decorators/http/http-methods-decorators.ts' TaonHttpDecoratorOptions
|
|
1355
|
+
*/
|
|
1356
|
+
class MethodConfig {
|
|
1357
|
+
constructor() {
|
|
1358
|
+
this.parameters = {};
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
Models.MethodConfig = MethodConfig;
|
|
1362
|
+
//#endregion
|
|
1363
|
+
//#region models / http
|
|
1364
|
+
let Http;
|
|
1365
|
+
(function (Http) {
|
|
1366
|
+
Http.Rest = Models$1;
|
|
1367
|
+
class Errors {
|
|
1368
|
+
constructor(message, code = 400) {
|
|
1369
|
+
this.message = message;
|
|
1370
|
+
this.code = code;
|
|
1371
|
+
this.toString = () => {
|
|
1372
|
+
return this.message;
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
static create(message, code = 400) {
|
|
1376
|
+
return new Errors(message, code);
|
|
1377
|
+
}
|
|
1378
|
+
static entityNotFound(entity) {
|
|
1379
|
+
return Errors.create(`Entity ${ClassHelpers.getName(entity)} not found`);
|
|
1380
|
+
}
|
|
1381
|
+
static custom(message, code = 400) {
|
|
1382
|
+
return Errors.create(message, code);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
Http.Errors = Errors;
|
|
1386
|
+
/* */
|
|
1387
|
+
/* */
|
|
1388
|
+
/* */
|
|
1389
|
+
/* */
|
|
1390
|
+
/* */
|
|
1391
|
+
})(Http = Models.Http || (Models.Http = {}));
|
|
1392
|
+
//#endregion
|
|
1393
|
+
})(Models || (Models = {}));
|
|
1394
|
+
|
|
1396
1395
|
//#region imports
|
|
1397
1396
|
/* */
|
|
1398
1397
|
/* */
|
|
@@ -1513,7 +1512,8 @@ class RealtimeClient {
|
|
|
1513
1512
|
};
|
|
1514
1513
|
// console.log('[browser] nspPath', nspPath);
|
|
1515
1514
|
if (this.core.ctx.config.frontendHost &&
|
|
1516
|
-
this.core.ctx.config.frontendHost !== ''
|
|
1515
|
+
this.core.ctx.config.frontendHost !== '' &&
|
|
1516
|
+
this.core.ctx.isRunningInsideDocker) {
|
|
1517
1517
|
console.log(`[${this.core.ctx.contextName}] USING FRONTEND HOST ${this.core.ctx.config.frontendHost}`);
|
|
1518
1518
|
nspPath.global = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.global.pathname}`);
|
|
1519
1519
|
nspPath.realtime = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.realtime.pathname}`);
|
|
@@ -3119,7 +3119,12 @@ class EndpointContext {
|
|
|
3119
3119
|
/* */
|
|
3120
3120
|
/* */
|
|
3121
3121
|
/* */
|
|
3122
|
-
|
|
3122
|
+
/* */
|
|
3123
|
+
/* */
|
|
3124
|
+
/* */
|
|
3125
|
+
/* */
|
|
3126
|
+
/* */
|
|
3127
|
+
await this.initCustomClientMiddlewares();
|
|
3123
3128
|
}
|
|
3124
3129
|
//#endregion
|
|
3125
3130
|
//#region prepare realtime
|
|
@@ -3712,6 +3717,9 @@ class EndpointContext {
|
|
|
3712
3717
|
return this.config.contextName;
|
|
3713
3718
|
}
|
|
3714
3719
|
//#endregion
|
|
3720
|
+
get cwd() {
|
|
3721
|
+
return this.config.cwd || process.cwd();
|
|
3722
|
+
}
|
|
3715
3723
|
get activeContext() {
|
|
3716
3724
|
return this.config.activeContext || null;
|
|
3717
3725
|
}
|
|
@@ -3948,6 +3956,7 @@ class EndpointContext {
|
|
|
3948
3956
|
const configs = ClassHelpers.getControllerConfigs(controllerClassFn);
|
|
3949
3957
|
// console.log(`Class config for ${ClassHelpers.getName(controllerClassFn)}`, configs)
|
|
3950
3958
|
const classConfig = configs[0];
|
|
3959
|
+
//#region update class calculate path
|
|
3951
3960
|
const parentscalculatedPath = _.slice(configs, 1)
|
|
3952
3961
|
.reverse()
|
|
3953
3962
|
.map(bc => {
|
|
@@ -3971,6 +3980,7 @@ class EndpointContext {
|
|
|
3971
3980
|
}, [])
|
|
3972
3981
|
.join('/');
|
|
3973
3982
|
}
|
|
3983
|
+
//#endregion
|
|
3974
3984
|
// console.log('calculatedPath', classConfig.calculatedPath);
|
|
3975
3985
|
_.slice(configs, 1).forEach(bc => {
|
|
3976
3986
|
const alreadyIs = classConfig.methods;
|
|
@@ -4094,44 +4104,29 @@ class EndpointContext {
|
|
|
4094
4104
|
}
|
|
4095
4105
|
//#endregion
|
|
4096
4106
|
//#region methods & getters / init middlewares
|
|
4097
|
-
async
|
|
4098
|
-
const middlewares = this.getClassesInstancesArrBy(Models.ClassType.MIDDLEWARE)
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
});
|
|
4119
|
-
})(middlewareInstance, this.contextName, apiPrefix, this.uriPathnameOrNothingIfRoot);
|
|
4120
|
-
}
|
|
4121
|
-
}
|
|
4107
|
+
async initCustomClientMiddlewares() {
|
|
4108
|
+
const middlewares = this.getClassesInstancesArrBy(Models.ClassType.MIDDLEWARE)
|
|
4109
|
+
.map(f => f)
|
|
4110
|
+
.filter(f => _.isFunction(f.interceptClient));
|
|
4111
|
+
middlewares.forEach(instance => {
|
|
4112
|
+
const contextName = this.contextName;
|
|
4113
|
+
const interceptorName = `${contextName}-${ClassHelpers.getName(instance)}`;
|
|
4114
|
+
Resource.request.interceptors.set(interceptorName, {
|
|
4115
|
+
intercept: ({ req, next }) => {
|
|
4116
|
+
const url = new URL(req.url);
|
|
4117
|
+
if (url.pathname.startsWith(`${this.uriPathnameOrNothingIfRoot}/${apiPrefix}/${contextName}/`)) {
|
|
4118
|
+
// console.log('intercepting', url.pathname, req);
|
|
4119
|
+
return instance.interceptClient({
|
|
4120
|
+
req,
|
|
4121
|
+
next,
|
|
4122
|
+
});
|
|
4123
|
+
}
|
|
4124
|
+
return next.handle(req);
|
|
4125
|
+
},
|
|
4126
|
+
});
|
|
4127
|
+
});
|
|
4122
4128
|
}
|
|
4123
|
-
async
|
|
4124
|
-
/* */
|
|
4125
|
-
/* */
|
|
4126
|
-
/* */
|
|
4127
|
-
/* */
|
|
4128
|
-
/* */
|
|
4129
|
-
/* */
|
|
4130
|
-
/* */
|
|
4131
|
-
/* */
|
|
4132
|
-
/* */
|
|
4133
|
-
/* */
|
|
4134
|
-
/* */
|
|
4129
|
+
async initCustomBackendMiddlewares() {
|
|
4135
4130
|
/* */
|
|
4136
4131
|
/* */
|
|
4137
4132
|
/* */
|
|
@@ -4166,6 +4161,8 @@ class EndpointContext {
|
|
|
4166
4161
|
/* */
|
|
4167
4162
|
/* */
|
|
4168
4163
|
/* */
|
|
4164
|
+
}
|
|
4165
|
+
async initBackendMiddlewares() {
|
|
4169
4166
|
/* */
|
|
4170
4167
|
/* */
|
|
4171
4168
|
/* */
|
|
@@ -4275,16 +4272,31 @@ class EndpointContext {
|
|
|
4275
4272
|
//#region methods & getters / init methods node
|
|
4276
4273
|
initServer(
|
|
4277
4274
|
//#region parameters
|
|
4278
|
-
|
|
4275
|
+
httpMethodType, methodConfig, classConfig, expressPath, target) {
|
|
4279
4276
|
//#region resolve variables
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4277
|
+
const middlewareHandlers = (Array.isArray(methodConfig.middlewares) &&
|
|
4278
|
+
methodConfig.middlewares?.length > 0
|
|
4279
|
+
? methodConfig.middlewares
|
|
4280
|
+
: [])
|
|
4281
|
+
.map(middlewareClassFun => {
|
|
4282
|
+
const middlewareInstance = this.getInstanceBy(middlewareClassFun);
|
|
4283
|
+
if (middlewareInstance &&
|
|
4284
|
+
_.isFunction(middlewareInstance.interceptServerMethod)) {
|
|
4285
|
+
const middlewareFn = ClassHelpers.asyncHandler(async (req, res, next) => {
|
|
4286
|
+
await middlewareInstance.interceptServerMethod({
|
|
4287
|
+
req,
|
|
4288
|
+
res,
|
|
4289
|
+
next,
|
|
4290
|
+
}, {
|
|
4291
|
+
methodName: methodConfig.methodName,
|
|
4292
|
+
expressPath,
|
|
4293
|
+
httpRequestType: methodConfig.type,
|
|
4294
|
+
});
|
|
4295
|
+
});
|
|
4296
|
+
return middlewareFn;
|
|
4297
|
+
}
|
|
4298
|
+
})
|
|
4299
|
+
.filter(f => !!f);
|
|
4288
4300
|
// const url = this.uri;
|
|
4289
4301
|
//#region get result
|
|
4290
4302
|
const getResult = async (resolvedParams, req, res) => {
|
|
@@ -4294,7 +4306,7 @@ class EndpointContext {
|
|
|
4294
4306
|
*/
|
|
4295
4307
|
this.getInstanceBy(target),
|
|
4296
4308
|
/**
|
|
4297
|
-
* Params for
|
|
4309
|
+
* Params for method @GET, @PUT etc.
|
|
4298
4310
|
*/
|
|
4299
4311
|
resolvedParams);
|
|
4300
4312
|
let result = await getResponseValue(response, { req, res });
|
|
@@ -4337,6 +4349,7 @@ class EndpointContext {
|
|
|
4337
4349
|
/* */
|
|
4338
4350
|
/* */
|
|
4339
4351
|
/* */
|
|
4352
|
+
/* */
|
|
4340
4353
|
//#endregion
|
|
4341
4354
|
/* */
|
|
4342
4355
|
/* */
|
|
@@ -4552,6 +4565,7 @@ class EndpointContext {
|
|
|
4552
4565
|
/* */
|
|
4553
4566
|
/* */
|
|
4554
4567
|
/* */
|
|
4568
|
+
/* */
|
|
4555
4569
|
}
|
|
4556
4570
|
return {
|
|
4557
4571
|
expressPath: expressPath,
|
|
@@ -4565,10 +4579,31 @@ class EndpointContext {
|
|
|
4565
4579
|
*/
|
|
4566
4580
|
async initClient(
|
|
4567
4581
|
//#region parameters
|
|
4568
|
-
target,
|
|
4582
|
+
target, httpRequestType, methodConfig, // Models.Http.Rest.MethodConfig,
|
|
4583
|
+
expressPath) {
|
|
4569
4584
|
const ctx = this;
|
|
4585
|
+
//#region init middlewares
|
|
4586
|
+
const middlewares = methodConfig.middlewares
|
|
4587
|
+
.map(f => this.getInstanceBy(f))
|
|
4588
|
+
.filter(f => _.isFunction(f.interceptClientMethod));
|
|
4589
|
+
middlewares.forEach(instance => {
|
|
4590
|
+
Resource.request.methodsInterceptors.set(`${methodConfig.type?.toUpperCase()}-${expressPath}`, {
|
|
4591
|
+
intercept: ({ req, next }) => {
|
|
4592
|
+
return instance.interceptClientMethod({
|
|
4593
|
+
req,
|
|
4594
|
+
next,
|
|
4595
|
+
}, {
|
|
4596
|
+
methodName: methodConfig.methodName,
|
|
4597
|
+
expressPath,
|
|
4598
|
+
httpRequestType: httpRequestType,
|
|
4599
|
+
});
|
|
4600
|
+
},
|
|
4601
|
+
});
|
|
4602
|
+
});
|
|
4603
|
+
//#endregion
|
|
4570
4604
|
// : { received: any; /* Rest<any, any> */ }
|
|
4571
|
-
this.logHttp &&
|
|
4605
|
+
this.logHttp &&
|
|
4606
|
+
console.log(`${httpRequestType?.toUpperCase()} ${expressPath} `);
|
|
4572
4607
|
// console.log('INITING', methodConfig); // TODO inject in static
|
|
4573
4608
|
//#region resolve storage
|
|
4574
4609
|
// TODO not a good idea
|
|
@@ -4610,6 +4645,9 @@ class EndpointContext {
|
|
|
4610
4645
|
received['observable'] = from(received);
|
|
4611
4646
|
return {
|
|
4612
4647
|
received,
|
|
4648
|
+
request(axiosConfig) {
|
|
4649
|
+
return received;
|
|
4650
|
+
},
|
|
4613
4651
|
};
|
|
4614
4652
|
};
|
|
4615
4653
|
return;
|
|
@@ -4761,6 +4799,11 @@ class EndpointContext {
|
|
|
4761
4799
|
/* */
|
|
4762
4800
|
/* */
|
|
4763
4801
|
/* */
|
|
4802
|
+
/* */
|
|
4803
|
+
/* */
|
|
4804
|
+
/* */
|
|
4805
|
+
/* */
|
|
4806
|
+
/* */
|
|
4764
4807
|
//#endregion
|
|
4765
4808
|
//#region handle normal request
|
|
4766
4809
|
target.prototype[methodConfig.methodName] = function (...args) {
|
|
@@ -4801,8 +4844,7 @@ class EndpointContext {
|
|
|
4801
4844
|
else {
|
|
4802
4845
|
rest = endpoints[ctx.uriOrigin][expressPath];
|
|
4803
4846
|
}
|
|
4804
|
-
const method =
|
|
4805
|
-
const isWithBody = method === 'put' || method === 'post';
|
|
4847
|
+
const method = httpRequestType.toLowerCase();
|
|
4806
4848
|
const pathPrams = {};
|
|
4807
4849
|
let queryParams = {};
|
|
4808
4850
|
let bodyObject = {};
|
|
@@ -4900,9 +4942,11 @@ instead
|
|
|
4900
4942
|
}
|
|
4901
4943
|
//#endregion
|
|
4902
4944
|
const httpResultObj = {
|
|
4903
|
-
received:
|
|
4904
|
-
|
|
4905
|
-
|
|
4945
|
+
received: rest.model(pathPrams)[method](bodyObject, [queryParams]),
|
|
4946
|
+
request(axiosConfig) {
|
|
4947
|
+
return rest
|
|
4948
|
+
.model(pathPrams)[method](bodyObject, [queryParams], axiosConfig);
|
|
4949
|
+
},
|
|
4906
4950
|
};
|
|
4907
4951
|
return httpResultObj;
|
|
4908
4952
|
};
|
|
@@ -5175,16 +5219,16 @@ const createContext = (configFn) => {
|
|
|
5175
5219
|
};
|
|
5176
5220
|
|
|
5177
5221
|
/**
|
|
5178
|
-
*
|
|
5222
|
+
* Provider decorator
|
|
5179
5223
|
*/
|
|
5180
|
-
function
|
|
5224
|
+
function TaonMiddleware(options) {
|
|
5181
5225
|
return function (constructor) {
|
|
5182
|
-
Reflect.defineMetadata(Symbols.metadata.options.
|
|
5226
|
+
Reflect.defineMetadata(Symbols.metadata.options.provider, options, constructor);
|
|
5183
5227
|
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
5184
|
-
ClassHelpers.setName(constructor, options?.className);
|
|
5228
|
+
ClassHelpers.setName(constructor, options?.className || constructor.name);
|
|
5185
5229
|
};
|
|
5186
5230
|
}
|
|
5187
|
-
class
|
|
5231
|
+
class TaonMiddlewareOptions extends DecoratorAbstractOpt {
|
|
5188
5232
|
}
|
|
5189
5233
|
|
|
5190
5234
|
//#endregion
|
|
@@ -5371,6 +5415,95 @@ class BaseInjector {
|
|
|
5371
5415
|
}
|
|
5372
5416
|
}
|
|
5373
5417
|
|
|
5418
|
+
/**
|
|
5419
|
+
* TODO
|
|
5420
|
+
* - global provider available in all contexts
|
|
5421
|
+
* - provider available in own context
|
|
5422
|
+
*/
|
|
5423
|
+
class BaseMiddleware extends BaseInjector {
|
|
5424
|
+
}
|
|
5425
|
+
|
|
5426
|
+
//#endregion
|
|
5427
|
+
/**
|
|
5428
|
+
* Configurable file upload middleware (multer based)
|
|
5429
|
+
*/
|
|
5430
|
+
let BaseFileUploadMiddleware = class BaseFileUploadMiddleware extends BaseMiddleware {
|
|
5431
|
+
async interceptServerMethod({ req, res, next }, { methodName, expressPath }) {
|
|
5432
|
+
return this.middleware()(req, res, next);
|
|
5433
|
+
}
|
|
5434
|
+
//#region upload Dir
|
|
5435
|
+
uploadDir() {
|
|
5436
|
+
return crossPlatformPath([this.ctx.cwd, 'uploaded-files']);
|
|
5437
|
+
}
|
|
5438
|
+
//#endregion
|
|
5439
|
+
//#region storage
|
|
5440
|
+
storage() {
|
|
5441
|
+
/* */
|
|
5442
|
+
/* */
|
|
5443
|
+
/* */
|
|
5444
|
+
/* */
|
|
5445
|
+
/* */
|
|
5446
|
+
/* */
|
|
5447
|
+
/* */
|
|
5448
|
+
/* */
|
|
5449
|
+
/* */
|
|
5450
|
+
/* */
|
|
5451
|
+
/* */
|
|
5452
|
+
/* */
|
|
5453
|
+
/* */
|
|
5454
|
+
/* */
|
|
5455
|
+
/* */
|
|
5456
|
+
/* */
|
|
5457
|
+
/* */
|
|
5458
|
+
/* */
|
|
5459
|
+
/* */
|
|
5460
|
+
return (void 0);
|
|
5461
|
+
}
|
|
5462
|
+
//#endregion
|
|
5463
|
+
//#region upload
|
|
5464
|
+
upload() {
|
|
5465
|
+
/* */
|
|
5466
|
+
/* */
|
|
5467
|
+
/* */
|
|
5468
|
+
/* */
|
|
5469
|
+
/* */
|
|
5470
|
+
/* */
|
|
5471
|
+
/* */
|
|
5472
|
+
/* */
|
|
5473
|
+
/* */
|
|
5474
|
+
/* */
|
|
5475
|
+
/* */
|
|
5476
|
+
/* */
|
|
5477
|
+
/* */
|
|
5478
|
+
return (void 0);
|
|
5479
|
+
}
|
|
5480
|
+
//#endregion
|
|
5481
|
+
//#region middleware
|
|
5482
|
+
middleware() {
|
|
5483
|
+
/* */
|
|
5484
|
+
/* */
|
|
5485
|
+
return (void 0);
|
|
5486
|
+
}
|
|
5487
|
+
};
|
|
5488
|
+
BaseFileUploadMiddleware = __decorate([
|
|
5489
|
+
TaonMiddleware({
|
|
5490
|
+
className: 'BaseFileUploadMiddleware',
|
|
5491
|
+
})
|
|
5492
|
+
], BaseFileUploadMiddleware);
|
|
5493
|
+
|
|
5494
|
+
/**
|
|
5495
|
+
* Repository decorator
|
|
5496
|
+
*/
|
|
5497
|
+
function TaonRepository(options) {
|
|
5498
|
+
return function (constructor) {
|
|
5499
|
+
Reflect.defineMetadata(Symbols.metadata.options.repository, options, constructor);
|
|
5500
|
+
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
5501
|
+
ClassHelpers.setName(constructor, options?.className);
|
|
5502
|
+
};
|
|
5503
|
+
}
|
|
5504
|
+
class TaonRepositoryOptions extends DecoratorAbstractOpt {
|
|
5505
|
+
}
|
|
5506
|
+
|
|
5374
5507
|
//#endregion
|
|
5375
5508
|
let BaseCustomRepository = class BaseCustomRepository extends BaseInjector {
|
|
5376
5509
|
};
|
|
@@ -5991,6 +6124,9 @@ BaseRepository = __decorate([
|
|
|
5991
6124
|
const BaseContext = createContext(() => ({
|
|
5992
6125
|
contextName: 'BaseContext',
|
|
5993
6126
|
abstract: true,
|
|
6127
|
+
middlewares: {
|
|
6128
|
+
BaseFileUploadMiddleware,
|
|
6129
|
+
},
|
|
5994
6130
|
repositories: {
|
|
5995
6131
|
// @ts-ignore
|
|
5996
6132
|
BaseRepository,
|
|
@@ -6012,14 +6148,6 @@ function TaonController(options) {
|
|
|
6012
6148
|
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
6013
6149
|
};
|
|
6014
6150
|
}
|
|
6015
|
-
class TaonControllerOptions extends Models.DecoratorAbstractOpt {
|
|
6016
|
-
}
|
|
6017
|
-
|
|
6018
|
-
let BaseController = class BaseController extends BaseInjector {
|
|
6019
|
-
};
|
|
6020
|
-
BaseController = __decorate([
|
|
6021
|
-
TaonController({ className: 'BaseController' })
|
|
6022
|
-
], BaseController);
|
|
6023
6151
|
|
|
6024
6152
|
const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
|
|
6025
6153
|
let options;
|
|
@@ -6032,13 +6160,14 @@ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, p
|
|
|
6032
6160
|
else {
|
|
6033
6161
|
options = { pathOrOptions, pathIsGlobal };
|
|
6034
6162
|
}
|
|
6035
|
-
const { overrideContentType,
|
|
6163
|
+
const { overrideContentType, overrideResponseType, middlewares } = options;
|
|
6036
6164
|
let methodConfig = Reflect.getMetadata(Symbols.metadata.options.controllerMethod, target.constructor, propertyKey);
|
|
6037
6165
|
if (!methodConfig) {
|
|
6038
6166
|
methodConfig = new Models.MethodConfig();
|
|
6039
6167
|
Reflect.defineMetadata(Symbols.metadata.options.controllerMethod, methodConfig, target.constructor, propertyKey);
|
|
6040
6168
|
}
|
|
6041
6169
|
methodConfig.methodName = propertyKey;
|
|
6170
|
+
methodConfig.middlewares = middlewares || [];
|
|
6042
6171
|
methodConfig.type = method;
|
|
6043
6172
|
if (!path) {
|
|
6044
6173
|
let paramsPathConcatedPath = '';
|
|
@@ -6060,7 +6189,7 @@ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, p
|
|
|
6060
6189
|
methodConfig.descriptor = descriptor;
|
|
6061
6190
|
methodConfig.global = pathIsGlobal;
|
|
6062
6191
|
methodConfig.contentType = overrideContentType;
|
|
6063
|
-
methodConfig.responseType =
|
|
6192
|
+
methodConfig.responseType = overrideResponseType;
|
|
6064
6193
|
Reflect.defineMetadata(Symbols.metadata.options.controllerMethod, methodConfig, target.constructor, propertyKey);
|
|
6065
6194
|
// console.log('methods updated', methodConfig);
|
|
6066
6195
|
};
|
|
@@ -6139,6 +6268,68 @@ function Body(name) {
|
|
|
6139
6268
|
};
|
|
6140
6269
|
}
|
|
6141
6270
|
|
|
6271
|
+
/* */
|
|
6272
|
+
/* */
|
|
6273
|
+
let BaseController = class BaseController extends BaseInjector {
|
|
6274
|
+
//#region upload form data to server
|
|
6275
|
+
uploadFormDataToServer(formData) {
|
|
6276
|
+
/* */
|
|
6277
|
+
/* */
|
|
6278
|
+
/* */
|
|
6279
|
+
/* */
|
|
6280
|
+
/* */
|
|
6281
|
+
/* */
|
|
6282
|
+
/* */
|
|
6283
|
+
/* */
|
|
6284
|
+
/* */
|
|
6285
|
+
/* */
|
|
6286
|
+
/* */
|
|
6287
|
+
/* */
|
|
6288
|
+
/* */
|
|
6289
|
+
/* */
|
|
6290
|
+
/* */
|
|
6291
|
+
/* */
|
|
6292
|
+
/* */
|
|
6293
|
+
/* */
|
|
6294
|
+
/* */
|
|
6295
|
+
/* */
|
|
6296
|
+
/* */
|
|
6297
|
+
return (void 0);
|
|
6298
|
+
}
|
|
6299
|
+
//#endregion
|
|
6300
|
+
//#region upload local file to server
|
|
6301
|
+
async uploadLocalFileToServer(absFilePath) {
|
|
6302
|
+
/* */
|
|
6303
|
+
/* */
|
|
6304
|
+
/* */
|
|
6305
|
+
/* */
|
|
6306
|
+
/* */
|
|
6307
|
+
/* */
|
|
6308
|
+
/* */
|
|
6309
|
+
/* */
|
|
6310
|
+
/* */
|
|
6311
|
+
/* */
|
|
6312
|
+
/* */
|
|
6313
|
+
/* */
|
|
6314
|
+
return (void 0);
|
|
6315
|
+
}
|
|
6316
|
+
};
|
|
6317
|
+
__decorate([
|
|
6318
|
+
POST({
|
|
6319
|
+
overrideContentType: 'multipart/form-data',
|
|
6320
|
+
middlewares: [BaseFileUploadMiddleware],
|
|
6321
|
+
}),
|
|
6322
|
+
__param(0, Body()),
|
|
6323
|
+
__metadata("design:type", Function),
|
|
6324
|
+
__metadata("design:paramtypes", [FormData]),
|
|
6325
|
+
__metadata("design:returntype", Object)
|
|
6326
|
+
], BaseController.prototype, "uploadFormDataToServer", null);
|
|
6327
|
+
BaseController = __decorate([
|
|
6328
|
+
TaonController({
|
|
6329
|
+
className: 'BaseController',
|
|
6330
|
+
})
|
|
6331
|
+
], BaseController);
|
|
6332
|
+
|
|
6142
6333
|
//#endregion
|
|
6143
6334
|
/**
|
|
6144
6335
|
* Please override property entityClassFn with entity class.
|
|
@@ -6423,14 +6614,6 @@ BaseCrudController = __decorate([
|
|
|
6423
6614
|
TaonController({ className: 'BaseCrudController' })
|
|
6424
6615
|
], BaseCrudController);
|
|
6425
6616
|
|
|
6426
|
-
/**
|
|
6427
|
-
* TODO
|
|
6428
|
-
* - global provider available in all contexts
|
|
6429
|
-
* - provider available in own context
|
|
6430
|
-
*/
|
|
6431
|
-
class BaseMiddleware extends BaseInjector {
|
|
6432
|
-
}
|
|
6433
|
-
|
|
6434
6617
|
class BaseMigration extends BaseInjector {
|
|
6435
6618
|
/**
|
|
6436
6619
|
* by default is READY to run
|
|
@@ -6467,7 +6650,7 @@ function TaonSubscriber(options) {
|
|
|
6467
6650
|
ClassHelpers.setName(constructor, options?.className);
|
|
6468
6651
|
};
|
|
6469
6652
|
}
|
|
6470
|
-
class TaonSubscriberOptions extends
|
|
6653
|
+
class TaonSubscriberOptions extends DecoratorAbstractOpt {
|
|
6471
6654
|
}
|
|
6472
6655
|
|
|
6473
6656
|
let BaseSubscriberForEntity = class BaseSubscriberForEntity extends BaseInjector {
|
|
@@ -6630,8 +6813,6 @@ var Base;
|
|
|
6630
6813
|
Base.Context = BaseContext;
|
|
6631
6814
|
})(Base || (Base = {}));
|
|
6632
6815
|
|
|
6633
|
-
/* */
|
|
6634
|
-
/* */
|
|
6635
6816
|
/**
|
|
6636
6817
|
* Entity decorator
|
|
6637
6818
|
*/
|
|
@@ -6650,20 +6831,7 @@ function TaonEntity(options) {
|
|
|
6650
6831
|
CLASS.setName(constructor, options?.className); // TODO QUICK_FIX for ng2-rest
|
|
6651
6832
|
};
|
|
6652
6833
|
}
|
|
6653
|
-
class TaonEntityOptions extends
|
|
6654
|
-
}
|
|
6655
|
-
|
|
6656
|
-
/**
|
|
6657
|
-
* Provider decorator
|
|
6658
|
-
*/
|
|
6659
|
-
function TaonMiddleware(options) {
|
|
6660
|
-
return function (constructor) {
|
|
6661
|
-
Reflect.defineMetadata(Symbols.metadata.options.provider, options, constructor);
|
|
6662
|
-
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
6663
|
-
ClassHelpers.setName(constructor, options?.className || constructor.name);
|
|
6664
|
-
};
|
|
6665
|
-
}
|
|
6666
|
-
class TaonMiddlewareOptions extends Models.DecoratorAbstractOpt {
|
|
6834
|
+
class TaonEntityOptions extends DecoratorAbstractOpt {
|
|
6667
6835
|
}
|
|
6668
6836
|
|
|
6669
6837
|
/**
|
|
@@ -6676,7 +6844,7 @@ function TaonMigration(options) {
|
|
|
6676
6844
|
ClassHelpers.setName(constructor, options?.className);
|
|
6677
6845
|
};
|
|
6678
6846
|
}
|
|
6679
|
-
class TaonMigrationOptions extends
|
|
6847
|
+
class TaonMigrationOptions extends DecoratorAbstractOpt {
|
|
6680
6848
|
}
|
|
6681
6849
|
|
|
6682
6850
|
/**
|
|
@@ -6689,7 +6857,7 @@ function TaonProvider(options) {
|
|
|
6689
6857
|
ClassHelpers.setName(constructor, options?.className || constructor.name);
|
|
6690
6858
|
};
|
|
6691
6859
|
}
|
|
6692
|
-
class TaonProviderOptions extends
|
|
6860
|
+
class TaonProviderOptions extends DecoratorAbstractOpt {
|
|
6693
6861
|
}
|
|
6694
6862
|
|
|
6695
6863
|
var Http;
|