taon 21.0.89 → 21.0.91
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/VERIFIED-BUILD-DATA.jsonc +5 -0
- package/bin/taon +5 -5
- package/bin/taon-debug +5 -5
- package/bin/taon-debug-brk +4 -4
- package/browser/fesm2022/taon-browser.mjs +1097 -1190
- package/browser/fesm2022/taon-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/taon-browser.d.ts +261 -256
- package/browser-prod/fesm2022/taon-browser-prod.mjs +1098 -1191
- package/browser-prod/fesm2022/taon-browser-prod.mjs.map +1 -1
- package/browser-prod/package.json +1 -1
- package/browser-prod/types/taon-browser-prod.d.ts +259 -254
- package/icon-menu-taon.svg +15 -15
- package/lib/base-classes/base-context.js +1 -2
- package/lib/base-classes/base-context.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/create-context.js +6 -0
- package/lib/create-context.js.map +1 -1
- package/lib/endpoint-context.d.ts +7 -1
- package/lib/endpoint-context.js +18 -1
- package/lib/endpoint-context.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/realtime/realtime-client.js +20 -9
- package/lib/realtime/realtime-client.js.map +1 -1
- package/lib/realtime/realtime-core.js +9 -4
- package/lib/realtime/realtime-core.js.map +1 -1
- package/lib/realtime/realtime-server.js +8 -2
- package/lib/realtime/realtime-server.js.map +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/base-classes/base-context.js +1 -2
- package/lib-prod/base-classes/base-context.js.map +1 -1
- package/lib-prod/base-classes/base-controller.js.map +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +1 -1
- package/lib-prod/build-info._auto-generated_.js +1 -1
- package/lib-prod/create-context.js +6 -0
- package/lib-prod/create-context.js.map +1 -1
- package/lib-prod/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib-prod/endpoint-context-storage.js.map +1 -1
- package/lib-prod/endpoint-context.d.ts +7 -1
- package/lib-prod/endpoint-context.js +18 -1
- package/lib-prod/endpoint-context.js.map +1 -1
- package/lib-prod/helpers/class-helpers.js.map +1 -1
- package/lib-prod/index.js.map +1 -1
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.js +20 -9
- package/lib-prod/realtime/realtime-client.js.map +1 -1
- package/lib-prod/realtime/realtime-core.js +9 -4
- package/lib-prod/realtime/realtime-core.js.map +1 -1
- package/lib-prod/realtime/realtime-server.js +8 -2
- package/lib-prod/realtime/realtime-server.js.map +1 -1
- package/lib-prod/ui/index.d.ts +1 -1
- package/lib-prod/ui/index.js +1 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.d.ts +1 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -1
- package/package.json +1 -1
- package/websql/fesm2022/taon-websql.mjs +835 -1024
- package/websql/fesm2022/taon-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/taon-websql.d.ts +261 -256
- package/websql-prod/fesm2022/taon-websql-prod.mjs +837 -1025
- package/websql-prod/fesm2022/taon-websql-prod.mjs.map +1 -1
- package/websql-prod/package.json +1 -1
- package/websql-prod/types/taon-websql-prod.d.ts +259 -254
|
@@ -3,7 +3,7 @@ import { _, CoreModels, Utils, Helpers, UtilsOs, config, crossPlatformPath, Util
|
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { JSON10 } from 'json10/browser';
|
|
5
5
|
import { walk } from 'lodash-walk-object/browser';
|
|
6
|
-
import { RestResponseWrapper, Resource, HttpResponse, RestHeaders, decodeMappingForHeaderJson, DefaultMapping, DefaultModel
|
|
6
|
+
import { RestResponseWrapper, Resource, HttpResponse, RestHeaders, decodeMappingForHeaderJson, HttpResponseError, DefaultMapping, DefaultModel } from 'ng2-rest/browser';
|
|
7
7
|
import { Observable, from, Subject } from 'rxjs';
|
|
8
8
|
import * as i0 from '@angular/core';
|
|
9
9
|
import { InjectionToken, Injectable, signal, inject as inject$1, PLATFORM_ID, ViewContainerRef, ViewChild, Component } from '@angular/core';
|
|
@@ -15,7 +15,7 @@ import { io } from 'socket.io-client';
|
|
|
15
15
|
import { TaonStor } from 'taon-storage/browser';
|
|
16
16
|
import * as i1 from '@angular/cdk/layout';
|
|
17
17
|
import { isPlatformServer, isPlatformBrowser } from '@angular/common';
|
|
18
|
-
import { __decorate,
|
|
18
|
+
import { __decorate, __metadata, __param } from 'tslib';
|
|
19
19
|
import * as i1$1 from '@ngx-formly/core';
|
|
20
20
|
import { FieldWrapper, FieldArrayType } from '@ngx-formly/core';
|
|
21
21
|
|
|
@@ -1345,18 +1345,29 @@ class RealtimeClient {
|
|
|
1345
1345
|
realtime: this.core.pathFor(Symbols.REALTIME.NAMESPACE(this.core.ctx.contextName)),
|
|
1346
1346
|
};
|
|
1347
1347
|
// console.log('[browser] nspPath', nspPath);
|
|
1348
|
-
if (this.core.ctx.
|
|
1349
|
-
|
|
1350
|
-
this.core.ctx.
|
|
1348
|
+
if (this.core.ctx.isRemoteHost) {
|
|
1349
|
+
// NEED for remote host
|
|
1350
|
+
const nodeClientHostOrigin = this.core.ctx.host;
|
|
1351
1351
|
this.core.ctx.logRealtime &&
|
|
1352
|
-
Helpers.logInfo(`[${this.core.ctx.contextName}] USING FRONTEND HOST` +
|
|
1353
|
-
` ${
|
|
1354
|
-
nspPath.global = new URL(`${
|
|
1355
|
-
nspPath.realtime = new URL(`${
|
|
1352
|
+
Helpers.logInfo(`[${this.core.ctx.contextName}] USING REMOTE FRONTEND HOST` +
|
|
1353
|
+
` ${nodeClientHostOrigin} FOR REMOTE REALTIME`);
|
|
1354
|
+
nspPath.global = new URL(`${nodeClientHostOrigin}${nspPath.global.pathname}`);
|
|
1355
|
+
nspPath.realtime = new URL(`${nodeClientHostOrigin}${nspPath.realtime.pathname}`);
|
|
1356
1356
|
}
|
|
1357
1357
|
else {
|
|
1358
|
-
this.core.ctx.
|
|
1359
|
-
|
|
1358
|
+
if (this.core.ctx.config.frontendHost &&
|
|
1359
|
+
this.core.ctx.config.frontendHost !== '' &&
|
|
1360
|
+
this.core.ctx.isRunningInsideDocker) {
|
|
1361
|
+
this.core.ctx.logRealtime &&
|
|
1362
|
+
Helpers.logInfo(`[${this.core.ctx.contextName}] USING FRONTEND HOST` +
|
|
1363
|
+
` ${this.core.ctx.config.frontendHost} FOR REALTIME`);
|
|
1364
|
+
nspPath.global = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.global.pathname}`);
|
|
1365
|
+
nspPath.realtime = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.realtime.pathname}`);
|
|
1366
|
+
}
|
|
1367
|
+
else {
|
|
1368
|
+
this.core.ctx.logRealtime &&
|
|
1369
|
+
Helpers.logInfo(`[${this.core.ctx.contextName}] Not using frontend host for realtime`);
|
|
1370
|
+
}
|
|
1360
1371
|
}
|
|
1361
1372
|
this.core.ctx.logRealtime &&
|
|
1362
1373
|
console.info('[CLIENT] NAMESPACE GLOBAL ', nspPath.global.href + ` host: ${this.core.ctx.host}`);
|
|
@@ -1526,7 +1537,7 @@ class RealtimeServer {
|
|
|
1526
1537
|
constructor(core) {
|
|
1527
1538
|
this.core = core;
|
|
1528
1539
|
this.core = core;
|
|
1529
|
-
if (core.ctx.disabledRealtime
|
|
1540
|
+
if (core.ctx.disabledRealtime) {
|
|
1530
1541
|
return;
|
|
1531
1542
|
}
|
|
1532
1543
|
/* */
|
|
@@ -1764,6 +1775,16 @@ class RealtimeServer {
|
|
|
1764
1775
|
/* */
|
|
1765
1776
|
/* */
|
|
1766
1777
|
/* */
|
|
1778
|
+
/* */
|
|
1779
|
+
/* */
|
|
1780
|
+
/* */
|
|
1781
|
+
/* */
|
|
1782
|
+
/* */
|
|
1783
|
+
/* */
|
|
1784
|
+
/* */
|
|
1785
|
+
/* */
|
|
1786
|
+
/* */
|
|
1787
|
+
/* */
|
|
1767
1788
|
}
|
|
1768
1789
|
//#endregion
|
|
1769
1790
|
//#region entity changes
|
|
@@ -2472,10 +2493,15 @@ class RealtimeCore {
|
|
|
2472
2493
|
];
|
|
2473
2494
|
this.ctx = ctx;
|
|
2474
2495
|
this.strategy = this.resolveStrategy();
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2496
|
+
this.ctx.logRealtime &&
|
|
2497
|
+
console.log(`
|
|
2498
|
+
|
|
2499
|
+
[ctx=${this.ctx.contextName}]
|
|
2500
|
+
mode = ${this.ctx.mode}
|
|
2501
|
+
realtime strategy = ${this.strategy}
|
|
2502
|
+
context type = ${this.ctx.contextType}
|
|
2503
|
+
|
|
2504
|
+
`);
|
|
2479
2505
|
if (UtilsOs.isWebSQL) {
|
|
2480
2506
|
this.server = new RealtimeServer(this);
|
|
2481
2507
|
// console.log('DONE INITING SERVER');
|
|
@@ -2553,9 +2579,23 @@ class EndpointContext {
|
|
|
2553
2579
|
get isRunOrRevertOnlyMigrationAppStart() {
|
|
2554
2580
|
return !!(this.onlyMigrationRun || this.onlyMigrationRevertToTimestamp);
|
|
2555
2581
|
}
|
|
2582
|
+
get realtime() {
|
|
2583
|
+
if (!this._realtime) {
|
|
2584
|
+
throw new Error(`Please initialize context before accessing
|
|
2585
|
+
.realtime.client or realtime.server properties.
|
|
2586
|
+
|
|
2587
|
+
`);
|
|
2588
|
+
}
|
|
2589
|
+
return this._realtime;
|
|
2590
|
+
}
|
|
2591
|
+
set realtime(v) {
|
|
2592
|
+
this._realtime = v;
|
|
2593
|
+
}
|
|
2594
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
2556
2595
|
get realtimeClient() {
|
|
2557
2596
|
return this.realtime.client;
|
|
2558
2597
|
}
|
|
2598
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
2559
2599
|
get realtimeServer() {
|
|
2560
2600
|
return this.realtime.server;
|
|
2561
2601
|
}
|
|
@@ -3499,6 +3539,8 @@ class EndpointContext {
|
|
|
3499
3539
|
/* */
|
|
3500
3540
|
/* */
|
|
3501
3541
|
/* */
|
|
3542
|
+
/* */
|
|
3543
|
+
/* */
|
|
3502
3544
|
for (const classTypeName of [
|
|
3503
3545
|
Models.ClassType.MIDDLEWARE,
|
|
3504
3546
|
Models.ClassType.PROVIDER,
|
|
@@ -3706,6 +3748,9 @@ class EndpointContext {
|
|
|
3706
3748
|
}
|
|
3707
3749
|
//#endregion
|
|
3708
3750
|
//#region methods & getters / init subscribers
|
|
3751
|
+
/**
|
|
3752
|
+
* init typeorm subscribers
|
|
3753
|
+
*/
|
|
3709
3754
|
async initSubscribers() {
|
|
3710
3755
|
/* */
|
|
3711
3756
|
/* */
|
|
@@ -5485,9 +5530,15 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
5485
5530
|
get realtime() {
|
|
5486
5531
|
return {
|
|
5487
5532
|
get client() {
|
|
5533
|
+
if (!endpointContextRef) {
|
|
5534
|
+
throw new Error(`Please .initialize() context before using <context>.realtime.client.<anything> `);
|
|
5535
|
+
}
|
|
5488
5536
|
return endpointContextRef.realtimeClient;
|
|
5489
5537
|
},
|
|
5490
5538
|
get server() {
|
|
5539
|
+
if (!endpointContextRef) {
|
|
5540
|
+
throw new Error(`Please .initialize() context before using <context>.realtime.server.<anything> `);
|
|
5541
|
+
}
|
|
5491
5542
|
return endpointContextRef.realtimeServer;
|
|
5492
5543
|
},
|
|
5493
5544
|
};
|
|
@@ -5961,208 +6012,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImpor
|
|
|
5961
6012
|
type: Injectable
|
|
5962
6013
|
}], ctorParameters: () => [] });
|
|
5963
6014
|
|
|
5964
|
-
/**
|
|
5965
|
-
* Entity decorator
|
|
5966
|
-
*/
|
|
5967
|
-
function TaonEntity(options) {
|
|
5968
|
-
return function (constructor) {
|
|
5969
|
-
options = options || {};
|
|
5970
|
-
options.uniqueKeyProp = options.uniqueKeyProp || 'id';
|
|
5971
|
-
if (!options.className) {
|
|
5972
|
-
const nameForClass = constructor?.name || 'AnyClass';
|
|
5973
|
-
throw `Please define 'classname' property inside decorator of class '${nameForClass}':
|
|
5974
|
-
|
|
5975
|
-
@TaonEntity({
|
|
5976
|
-
className: '${nameForClass}'
|
|
5977
|
-
})
|
|
5978
|
-
class ${constructor?.name} {
|
|
5979
|
-
//...
|
|
5980
|
-
|
|
5981
|
-
`;
|
|
5982
|
-
}
|
|
5983
|
-
ClassHelpers.setName(constructor, options?.className);
|
|
5984
|
-
DefaultMapping(options?.defaultModelMapping)(constructor);
|
|
5985
|
-
DefaultModel(options.defaultModelMapping)(constructor);
|
|
5986
|
-
Reflect.defineMetadata(Symbols.metadata.options.entity, options, constructor);
|
|
5987
|
-
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
5988
|
-
/* */
|
|
5989
|
-
/* */
|
|
5990
|
-
CLASS.setName(constructor, options?.className); // TODO QUICK_FIX for ng2-rest
|
|
5991
|
-
};
|
|
5992
|
-
}
|
|
5993
|
-
class TaonEntityOptions extends DecoratorAbstractOpt {
|
|
5994
|
-
}
|
|
5995
|
-
|
|
5996
|
-
//#region imports
|
|
5997
|
-
//#endregion
|
|
5998
|
-
let TAON_GLOBAL_STATE = class TAON_GLOBAL_STATE extends TaonBaseAbstractEntity {
|
|
5999
|
-
};
|
|
6000
|
-
TAON_GLOBAL_STATE = __decorate([
|
|
6001
|
-
TaonEntity({
|
|
6002
|
-
className: 'TAON_GLOBAL_STATE',
|
|
6003
|
-
createTable: true,
|
|
6004
|
-
})
|
|
6005
|
-
], TAON_GLOBAL_STATE);
|
|
6006
|
-
|
|
6007
|
-
/**
|
|
6008
|
-
* Controller decorator
|
|
6009
|
-
*/
|
|
6010
|
-
function TaonController(options) {
|
|
6011
|
-
return function (constructor) {
|
|
6012
|
-
ClassHelpers.setName(constructor, options?.className);
|
|
6013
|
-
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
6014
|
-
const cfg = ClassHelpers.ensureClassConfig(constructor);
|
|
6015
|
-
options = options || {};
|
|
6016
|
-
cfg.className = options.className || constructor.name;
|
|
6017
|
-
cfg.path = options.path || '';
|
|
6018
|
-
cfg.realtime = options.realtime;
|
|
6019
|
-
cfg.middlewares = options.middlewares;
|
|
6020
|
-
};
|
|
6021
|
-
}
|
|
6022
|
-
|
|
6023
|
-
const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
|
|
6024
|
-
const methodConfig = ClassHelpers.ensureMethodConfig(target, propertyKey);
|
|
6025
|
-
let options;
|
|
6026
|
-
if (typeof pathOrOptions === 'object') {
|
|
6027
|
-
options = pathOrOptions;
|
|
6028
|
-
pathOrOptions = options.path;
|
|
6029
|
-
pathIsGlobal = !!options.pathIsGlobal;
|
|
6030
|
-
path = options.path;
|
|
6031
|
-
}
|
|
6032
|
-
else {
|
|
6033
|
-
options = { pathOrOptions, pathIsGlobal };
|
|
6034
|
-
}
|
|
6035
|
-
const { overrideContentType, overrideResponseType, overrideExpressSendAsHtml, middlewares, } = options;
|
|
6036
|
-
methodConfig.methodName = propertyKey;
|
|
6037
|
-
methodConfig.middlewares = middlewares;
|
|
6038
|
-
methodConfig.type = method;
|
|
6039
|
-
if (!path) {
|
|
6040
|
-
let paramsPathConcatedPath = '';
|
|
6041
|
-
for (const key in methodConfig.parameters) {
|
|
6042
|
-
if (methodConfig.parameters.hasOwnProperty(key)) {
|
|
6043
|
-
const element = methodConfig.parameters[key];
|
|
6044
|
-
if (element.paramType === 'Path' &&
|
|
6045
|
-
_.isString(element.paramName) &&
|
|
6046
|
-
element.paramName.trim().length > 0) {
|
|
6047
|
-
paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
|
|
6048
|
-
}
|
|
6049
|
-
}
|
|
6050
|
-
}
|
|
6051
|
-
methodConfig.path = `/${propertyKey}${paramsPathConcatedPath}`;
|
|
6052
|
-
}
|
|
6053
|
-
else {
|
|
6054
|
-
methodConfig.path = path;
|
|
6055
|
-
}
|
|
6056
|
-
methodConfig.descriptor = descriptor;
|
|
6057
|
-
methodConfig.global = pathIsGlobal;
|
|
6058
|
-
methodConfig.contentType = overrideContentType;
|
|
6059
|
-
methodConfig.responseType = overrideResponseType;
|
|
6060
|
-
methodConfig.overrideExpressSendAsHtml = overrideExpressSendAsHtml;
|
|
6061
|
-
};
|
|
6062
|
-
function GET(pathOrOptions, pathIsGlobal = false) {
|
|
6063
|
-
return function (target, propertyKey, descriptor) {
|
|
6064
|
-
metaReq('get', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
6065
|
-
};
|
|
6066
|
-
}
|
|
6067
|
-
/**
|
|
6068
|
-
* Method for sending html website from text
|
|
6069
|
-
* Example
|
|
6070
|
-
*
|
|
6071
|
-
* ```ts
|
|
6072
|
-
* ...
|
|
6073
|
-
* // in your taon controller
|
|
6074
|
-
* ..Taon.Http.HTML()
|
|
6075
|
-
* sendHtmlDummyWebsite(): Taon.ResponseHtml {
|
|
6076
|
-
* return `
|
|
6077
|
-
<html>
|
|
6078
|
-
<head>
|
|
6079
|
-
<title>Dummy website</title>
|
|
6080
|
-
</head>
|
|
6081
|
-
<body>
|
|
6082
|
-
<h1>This is dummy website</h1>
|
|
6083
|
-
<p>Served as HTML string from Taon controller method</p>
|
|
6084
|
-
</body>
|
|
6085
|
-
</html>
|
|
6086
|
-
* `; *
|
|
6087
|
-
* }
|
|
6088
|
-
* ...
|
|
6089
|
-
* ```
|
|
6090
|
-
*/
|
|
6091
|
-
function HTML(pathOrOptions) {
|
|
6092
|
-
return function (target, propertyKey, descriptor) {
|
|
6093
|
-
const opt = pathOrOptions;
|
|
6094
|
-
opt.overrideExpressSendAsHtml = true;
|
|
6095
|
-
metaReq('get', opt, target, propertyKey, descriptor, pathOrOptions, opt.pathIsGlobal);
|
|
6096
|
-
};
|
|
6097
|
-
}
|
|
6098
|
-
function HEAD(pathOrOptions, pathIsGlobal = false) {
|
|
6099
|
-
return function (target, propertyKey, descriptor) {
|
|
6100
|
-
metaReq('head', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
6101
|
-
};
|
|
6102
|
-
}
|
|
6103
|
-
function POST(pathOrOptions, pathIsGlobal = false) {
|
|
6104
|
-
return function (target, propertyKey, descriptor) {
|
|
6105
|
-
metaReq('post', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
6106
|
-
};
|
|
6107
|
-
}
|
|
6108
|
-
function PUT(pathOrOptions, pathIsGlobal = false) {
|
|
6109
|
-
return function (target, propertyKey, descriptor) {
|
|
6110
|
-
metaReq('put', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
6111
|
-
};
|
|
6112
|
-
}
|
|
6113
|
-
function PATCH(pathOrOptions, pathIsGlobal = false) {
|
|
6114
|
-
return function (target, propertyKey, descriptor) {
|
|
6115
|
-
metaReq('patch', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
6116
|
-
};
|
|
6117
|
-
}
|
|
6118
|
-
function DELETE(pathOrOptions, pathIsGlobal = false) {
|
|
6119
|
-
return function (target, propertyKey, descriptor) {
|
|
6120
|
-
metaReq('delete', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
6121
|
-
};
|
|
6122
|
-
}
|
|
6123
|
-
|
|
6124
|
-
function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
|
|
6125
|
-
const methodCfg = ClassHelpers.ensureMethodConfig(target, propertyKey);
|
|
6126
|
-
const nameKey = name ? name : param;
|
|
6127
|
-
// const key = name || `${param}_${parameterIndex}`;
|
|
6128
|
-
methodCfg.parameters[nameKey] = {
|
|
6129
|
-
index: parameterIndex,
|
|
6130
|
-
paramName: name,
|
|
6131
|
-
paramType: param,
|
|
6132
|
-
defaultType: defaultValue,
|
|
6133
|
-
expireInSeconds: expire,
|
|
6134
|
-
};
|
|
6135
|
-
// console.log('params updated', methodConfig);
|
|
6136
|
-
}
|
|
6137
|
-
/**
|
|
6138
|
-
* @deprecated use Taon.Http.Param.Path (is more safe and cleaner)
|
|
6139
|
-
*/
|
|
6140
|
-
function Path(name) {
|
|
6141
|
-
return function (target, propertyKey, parameterIndex) {
|
|
6142
|
-
metaParam('Path', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
6143
|
-
};
|
|
6144
|
-
}
|
|
6145
|
-
function Query(name) {
|
|
6146
|
-
return function (target, propertyKey, parameterIndex) {
|
|
6147
|
-
metaParam('Query', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
6148
|
-
};
|
|
6149
|
-
}
|
|
6150
|
-
function Cookie(name, expireInSecond = 3600) {
|
|
6151
|
-
return function (target, propertyKey, parameterIndex) {
|
|
6152
|
-
metaParam('Cookie', name, expireInSecond, {}, target, propertyKey, parameterIndex);
|
|
6153
|
-
};
|
|
6154
|
-
}
|
|
6155
|
-
function Header(name) {
|
|
6156
|
-
return function (target, propertyKey, parameterIndex) {
|
|
6157
|
-
metaParam('Header', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
6158
|
-
};
|
|
6159
|
-
}
|
|
6160
|
-
function Body(name) {
|
|
6161
|
-
return function (target, propertyKey, parameterIndex) {
|
|
6162
|
-
metaParam('Body', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
6163
|
-
};
|
|
6164
|
-
}
|
|
6165
|
-
|
|
6166
6015
|
/**
|
|
6167
6016
|
* Provider decorator
|
|
6168
6017
|
*/
|
|
@@ -6437,53 +6286,44 @@ TaonBaseFileUploadMiddleware = __decorate([
|
|
|
6437
6286
|
})
|
|
6438
6287
|
], TaonBaseFileUploadMiddleware);
|
|
6439
6288
|
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6289
|
+
/**
|
|
6290
|
+
* Repository decorator
|
|
6291
|
+
*/
|
|
6292
|
+
function TaonRepository(options) {
|
|
6293
|
+
return function (constructor) {
|
|
6294
|
+
Reflect.defineMetadata(Symbols.metadata.options.repository, options, constructor);
|
|
6295
|
+
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
6296
|
+
ClassHelpers.setName(constructor, options?.className);
|
|
6297
|
+
};
|
|
6298
|
+
}
|
|
6299
|
+
class TaonRepositoryOptions extends DecoratorAbstractOpt {
|
|
6300
|
+
}
|
|
6301
|
+
|
|
6302
|
+
//#endregion
|
|
6303
|
+
let TaonBaseCustomRepository = class TaonBaseCustomRepository extends TaonBaseInjector {
|
|
6304
|
+
};
|
|
6305
|
+
TaonBaseCustomRepository = __decorate([
|
|
6306
|
+
TaonRepository({ className: 'TaonBaseCustomRepository' })
|
|
6307
|
+
], TaonBaseCustomRepository);
|
|
6308
|
+
|
|
6309
|
+
//#endregion
|
|
6310
|
+
const INDEX_KEYS_NO_FOR_UPDATE = ['id'];
|
|
6311
|
+
let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomRepository {
|
|
6312
|
+
constructor(
|
|
6313
|
+
// Injected through TaonBaseCrudController
|
|
6314
|
+
__entityClassResolveFn) {
|
|
6315
|
+
super();
|
|
6316
|
+
this.REPOS_CACHE_KEY = Symbol('repository cache inside instance');
|
|
6317
|
+
this.allowedTypesToUpdate = ['simple-json', 'simple-array', 'json'];
|
|
6318
|
+
// @ts-ignore
|
|
6319
|
+
this.entityClassResolveFn = __entityClassResolveFn;
|
|
6320
|
+
}
|
|
6321
|
+
get dbQuery() {
|
|
6469
6322
|
/* */
|
|
6470
6323
|
/* */
|
|
6471
6324
|
/* */
|
|
6472
6325
|
/* */
|
|
6473
6326
|
/* */
|
|
6474
|
-
return (void 0);
|
|
6475
|
-
}
|
|
6476
|
-
//#endregion
|
|
6477
|
-
//#region after file upload hook
|
|
6478
|
-
/**
|
|
6479
|
-
* Hook after file is uploaded
|
|
6480
|
-
* through `uploadFormDataToServer` or `uploadLocalFileToServer`
|
|
6481
|
-
*/
|
|
6482
|
-
afterFileUploadAction(file, queryParams) {
|
|
6483
|
-
// empty
|
|
6484
|
-
}
|
|
6485
|
-
//#region upload local file to server
|
|
6486
|
-
async uploadLocalFileToServer(absFilePath, options, queryParams) {
|
|
6487
6327
|
/* */
|
|
6488
6328
|
/* */
|
|
6489
6329
|
/* */
|
|
@@ -6501,156 +6341,15 @@ let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
|
|
|
6501
6341
|
return (void 0);
|
|
6502
6342
|
}
|
|
6503
6343
|
//#endregion
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
// request: () => this.uploadFormDataToServer(void 0, void 0).request(),
|
|
6507
|
-
// statusCheck: resp => resp.body.json[0].ok,
|
|
6508
|
-
// });
|
|
6509
|
-
// }
|
|
6510
|
-
/**
|
|
6511
|
-
* Easy way to wait for status change with http (1s default) pooling.
|
|
6512
|
-
*
|
|
6513
|
-
* example (in sub class):
|
|
6514
|
-
* ```ts
|
|
6515
|
-
async check() {
|
|
6516
|
-
await this.waitForProperStatusChange({
|
|
6517
|
-
request: () => this.uploadFormDataToServer(void 0, void 0).request(),
|
|
6518
|
-
statusCheck: resp => resp.body.json[0].ok,
|
|
6519
|
-
});
|
|
6520
|
-
}
|
|
6521
|
-
* ```
|
|
6522
|
-
*/
|
|
6523
|
-
async _waitForProperStatusChange(options) {
|
|
6524
|
-
const poolingInterval = options.poolingInterval || 1000;
|
|
6525
|
-
const taonRequest = options.request;
|
|
6526
|
-
let maxTries = options.maxTries || Number.POSITIVE_INFINITY;
|
|
6527
|
-
let i = 0;
|
|
6528
|
-
let httpErrorsCount = 0;
|
|
6529
|
-
while (true) {
|
|
6530
|
-
await UtilsTerminal.waitMilliseconds(poolingInterval);
|
|
6531
|
-
try {
|
|
6532
|
-
const resp = await taonRequest({
|
|
6533
|
-
reqIndexNum: i,
|
|
6534
|
-
httpErrorsCount,
|
|
6535
|
-
});
|
|
6536
|
-
if (options.statusCheck && options.statusCheck(resp)) {
|
|
6537
|
-
return;
|
|
6538
|
-
}
|
|
6539
|
-
}
|
|
6540
|
-
catch (error) {
|
|
6541
|
-
httpErrorsCount++;
|
|
6542
|
-
if (options.loopRequestsOnBackendError) {
|
|
6543
|
-
const isProperTaonError = error instanceof HttpResponseError &&
|
|
6544
|
-
error.body.json[CoreModels.TaonHttpErrorCustomProp];
|
|
6545
|
-
const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
|
|
6546
|
-
const isUnknownError = !(error instanceof HttpResponseError);
|
|
6547
|
-
const resBool = await options.loopRequestsOnBackendError({
|
|
6548
|
-
taonError: isProperTaonError ? error : void 0,
|
|
6549
|
-
unknownHttpError: isHttpError ? error : void 0,
|
|
6550
|
-
unknownError: isUnknownError ? error : void 0,
|
|
6551
|
-
reqIndexNum: i,
|
|
6552
|
-
httpErrorsCount,
|
|
6553
|
-
});
|
|
6554
|
-
if (resBool) {
|
|
6555
|
-
i++;
|
|
6556
|
-
continue;
|
|
6557
|
-
}
|
|
6558
|
-
else {
|
|
6559
|
-
return;
|
|
6560
|
-
}
|
|
6561
|
-
}
|
|
6562
|
-
if (httpErrorsCount >
|
|
6563
|
-
(options.allowedHttpErrors || Number.POSITIVE_INFINITY)) {
|
|
6564
|
-
throw new Error(`Too many http errors (${httpErrorsCount}) for "${options.actionName}".`);
|
|
6565
|
-
}
|
|
6566
|
-
}
|
|
6567
|
-
if (i++ > maxTries) {
|
|
6568
|
-
throw new Error(`Timeout waiting for "${options.actionName}" to be finished. Waited for ${maxTries} seconds`);
|
|
6569
|
-
}
|
|
6570
|
-
}
|
|
6571
|
-
}
|
|
6572
|
-
};
|
|
6573
|
-
__decorate([
|
|
6574
|
-
POST({
|
|
6575
|
-
overrideContentType: 'multipart/form-data',
|
|
6576
|
-
middlewares: ({ parentMiddlewares }) => ({
|
|
6577
|
-
...parentMiddlewares,
|
|
6578
|
-
TaonBaseFileUploadMiddleware,
|
|
6579
|
-
}),
|
|
6580
|
-
}),
|
|
6581
|
-
__param(0, Body()),
|
|
6582
|
-
__param(1, Query()),
|
|
6583
|
-
__metadata("design:type", Function),
|
|
6584
|
-
__metadata("design:paramtypes", [FormData, Object]),
|
|
6585
|
-
__metadata("design:returntype", Object)
|
|
6586
|
-
], TaonBaseController.prototype, "uploadFormDataToServer", null);
|
|
6587
|
-
TaonBaseController = __decorate([
|
|
6588
|
-
TaonController({
|
|
6589
|
-
className: 'TaonBaseController',
|
|
6590
|
-
})
|
|
6591
|
-
], TaonBaseController);
|
|
6592
|
-
|
|
6593
|
-
//#endregion
|
|
6594
|
-
/**
|
|
6595
|
-
* Please override property entityClassFn with entity class.
|
|
6596
|
-
*/
|
|
6597
|
-
let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseController {
|
|
6598
|
-
//#endregion
|
|
6599
|
-
//#region init
|
|
6600
|
-
async _() {
|
|
6601
|
-
if (!_.isFunction(this.entityClassResolveFn)) {
|
|
6602
|
-
Helpers.warn(`Skipping initing CRUD controller ${ClassHelpers.getName(this)} because entityClassResolveFn is not provided.`);
|
|
6603
|
-
return;
|
|
6604
|
-
}
|
|
6605
|
-
let entityClassFn = this.entityClassResolveFn();
|
|
6606
|
-
this.db = this.injectRepo(entityClassFn);
|
|
6607
|
-
if (entityClassFn) {
|
|
6608
|
-
const configEntity = Reflect.getMetadata(Symbols.metadata.options.entity, ClassHelpers.getClassFnFromObject(this));
|
|
6609
|
-
if (configEntity?.createTable === false) {
|
|
6610
|
-
Helpers.warn(`Table for entity ${ClassHelpers.getName(entityClassFn)} will not be created. Crud will not work properly.`);
|
|
6611
|
-
}
|
|
6612
|
-
}
|
|
6613
|
-
else {
|
|
6614
|
-
Helpers.error(`Entity class not provided for controller ${ClassHelpers.getName(this)}.
|
|
6615
|
-
|
|
6616
|
-
Please provide entity as class property entityClassFn:
|
|
6617
|
-
|
|
6618
|
-
class ${ClassHelpers.getName(this)} extends TaonBaseCrudController<Entity> {
|
|
6619
|
-
// ...
|
|
6620
|
-
entityClassResolveFn = ()=> MyEntityClass;
|
|
6621
|
-
// ...
|
|
6622
|
-
}
|
|
6623
|
-
|
|
6624
|
-
`);
|
|
6625
|
-
}
|
|
6626
|
-
await super._();
|
|
6627
|
-
}
|
|
6628
|
-
//#endregion
|
|
6629
|
-
//#region bufferd changes
|
|
6630
|
-
bufforedChanges(id, property, alreadyLength) {
|
|
6631
|
-
/* */
|
|
6632
|
-
/* */
|
|
6633
|
-
/* */
|
|
6634
|
-
/* */
|
|
6635
|
-
/* */
|
|
6636
|
-
/* */
|
|
6637
|
-
/* */
|
|
6638
|
-
/* */
|
|
6639
|
-
/* */
|
|
6640
|
-
/* */
|
|
6641
|
-
/* */
|
|
6642
|
-
/* */
|
|
6643
|
-
/* */
|
|
6344
|
+
//#region connection
|
|
6345
|
+
get connection() {
|
|
6644
6346
|
/* */
|
|
6645
6347
|
/* */
|
|
6646
6348
|
return (void 0);
|
|
6647
6349
|
}
|
|
6648
6350
|
//#endregion
|
|
6649
|
-
//#region
|
|
6650
|
-
|
|
6651
|
-
/* */
|
|
6652
|
-
/* */
|
|
6653
|
-
/* */
|
|
6351
|
+
//#region repository
|
|
6352
|
+
get repository() {
|
|
6654
6353
|
/* */
|
|
6655
6354
|
/* */
|
|
6656
6355
|
/* */
|
|
@@ -6680,17 +6379,53 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6680
6379
|
/* */
|
|
6681
6380
|
/* */
|
|
6682
6381
|
/* */
|
|
6382
|
+
return (void 0);
|
|
6383
|
+
}
|
|
6384
|
+
/**
|
|
6385
|
+
* target for repository
|
|
6386
|
+
*/
|
|
6387
|
+
get target() {
|
|
6683
6388
|
/* */
|
|
6684
6389
|
/* */
|
|
6390
|
+
return (void 0);
|
|
6391
|
+
}
|
|
6392
|
+
/**
|
|
6393
|
+
* alias to repository
|
|
6394
|
+
*/
|
|
6395
|
+
get repo() {
|
|
6685
6396
|
/* */
|
|
6686
6397
|
/* */
|
|
6398
|
+
return (void 0);
|
|
6399
|
+
}
|
|
6400
|
+
get repositoryExists() {
|
|
6687
6401
|
/* */
|
|
6688
6402
|
/* */
|
|
6689
6403
|
return (void 0);
|
|
6690
6404
|
}
|
|
6691
6405
|
//#endregion
|
|
6692
|
-
//#region
|
|
6693
|
-
|
|
6406
|
+
//#region crud operations / typeorm / has id
|
|
6407
|
+
/**
|
|
6408
|
+
* Checks if entity has an id.
|
|
6409
|
+
* If entity composite compose ids, it will check them all.
|
|
6410
|
+
*/
|
|
6411
|
+
hasId(entity) {
|
|
6412
|
+
return this.repo.hasId(entity);
|
|
6413
|
+
}
|
|
6414
|
+
//#endregion
|
|
6415
|
+
//#region crud operations / typeorm / get id
|
|
6416
|
+
/**
|
|
6417
|
+
* Gets entity mixed id.
|
|
6418
|
+
*/
|
|
6419
|
+
getId(entity) {
|
|
6420
|
+
return this.repo.getId(entity);
|
|
6421
|
+
}
|
|
6422
|
+
//#endregion
|
|
6423
|
+
//#region crud operations / typeorm / create & bulk create
|
|
6424
|
+
/**
|
|
6425
|
+
Saves a given entity in the database.
|
|
6426
|
+
* If entity does not exist in the database then inserts, otherwise updates.
|
|
6427
|
+
*/
|
|
6428
|
+
async save(item, options) {
|
|
6694
6429
|
/* */
|
|
6695
6430
|
/* */
|
|
6696
6431
|
/* */
|
|
@@ -6700,11 +6435,6 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6700
6435
|
/* */
|
|
6701
6436
|
/* */
|
|
6702
6437
|
/* */
|
|
6703
|
-
return (void 0);
|
|
6704
|
-
}
|
|
6705
|
-
//#endregion
|
|
6706
|
-
//#region get by id
|
|
6707
|
-
getBy(id) {
|
|
6708
6438
|
/* */
|
|
6709
6439
|
/* */
|
|
6710
6440
|
/* */
|
|
@@ -6712,9 +6442,17 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6712
6442
|
/* */
|
|
6713
6443
|
return (void 0);
|
|
6714
6444
|
}
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6445
|
+
/**
|
|
6446
|
+
* Creates a new entity instance or instances.
|
|
6447
|
+
* Can copy properties from the given object into new entities.
|
|
6448
|
+
*/
|
|
6449
|
+
create(plainEntityLikeOrPlainEntityLikes) {
|
|
6450
|
+
return this.repo.create(plainEntityLikeOrPlainEntityLikes);
|
|
6451
|
+
}
|
|
6452
|
+
async bulkSave(items, options) {
|
|
6453
|
+
/* */
|
|
6454
|
+
/* */
|
|
6455
|
+
/* */
|
|
6718
6456
|
/* */
|
|
6719
6457
|
/* */
|
|
6720
6458
|
/* */
|
|
@@ -6723,20 +6461,89 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6723
6461
|
/* */
|
|
6724
6462
|
return (void 0);
|
|
6725
6463
|
}
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6464
|
+
/**
|
|
6465
|
+
* @deprecated use bulkSave instead
|
|
6466
|
+
*/
|
|
6467
|
+
async bulkCreate(items, options) {
|
|
6468
|
+
return this.bulkSave(items, options);
|
|
6469
|
+
}
|
|
6470
|
+
//#region old typeorm version
|
|
6471
|
+
/**
|
|
6472
|
+
* Saves all given entities in the database.
|
|
6473
|
+
* If entities do not exist in the database then inserts, otherwise updates.
|
|
6474
|
+
*/
|
|
6475
|
+
// save<T extends DeepPartial<Entity>>(
|
|
6476
|
+
// entities: T[],
|
|
6477
|
+
// options: SaveOptions & {
|
|
6478
|
+
// reload: false;
|
|
6479
|
+
// },
|
|
6480
|
+
// ): Promise<T[]>;
|
|
6481
|
+
// /**
|
|
6482
|
+
// * Saves all given entities in the database.
|
|
6483
|
+
// * If entities do not exist in the database then inserts, otherwise updates.
|
|
6484
|
+
// */
|
|
6485
|
+
// save<T extends DeepPartial<Entity>>(
|
|
6486
|
+
// entities: T[],
|
|
6487
|
+
// options?: SaveOptions,
|
|
6488
|
+
// ): Promise<(T & Entity)[]>;
|
|
6489
|
+
// /**
|
|
6490
|
+
// * Saves a given entity in the database.
|
|
6491
|
+
// * If entity does not exist in the database then inserts, otherwise updates.
|
|
6492
|
+
// */
|
|
6493
|
+
// save<T extends DeepPartial<Entity>>(
|
|
6494
|
+
// entity: T,
|
|
6495
|
+
// options: SaveOptions & {
|
|
6496
|
+
// reload: false;
|
|
6497
|
+
// },
|
|
6498
|
+
// ): Promise<T>;
|
|
6499
|
+
// /**
|
|
6500
|
+
// * Saves a given entity in the database.
|
|
6501
|
+
// * If entity does not exist in the database then inserts, otherwise updates.
|
|
6502
|
+
// */
|
|
6503
|
+
// save<T extends DeepPartial<Entity>>(
|
|
6504
|
+
// entity: T,
|
|
6505
|
+
// options?: SaveOptions,
|
|
6506
|
+
// ): Promise<T & Entity> {
|
|
6507
|
+
// return this.repo.save(entity, options);
|
|
6508
|
+
// }
|
|
6509
|
+
//#endregion
|
|
6510
|
+
//#endregion
|
|
6511
|
+
//#region crud operations / typeorm / merge
|
|
6512
|
+
/**
|
|
6513
|
+
* Merges multiple entities (or entity-like objects) into a given entity.
|
|
6514
|
+
*/
|
|
6515
|
+
merge(mergeIntoEntity, ...entityLikes) {
|
|
6516
|
+
return this.repo.merge(mergeIntoEntity, ...entityLikes);
|
|
6517
|
+
}
|
|
6518
|
+
//#endregion
|
|
6519
|
+
//#region crud operations / typeorm / preload
|
|
6520
|
+
/**
|
|
6521
|
+
* Creates a new entity from the given plain javascript object. If entity already exist in the database, then
|
|
6522
|
+
* it loads it (and everything related to it), replaces all values with the new ones from the given object
|
|
6523
|
+
* and returns this new entity. This new entity is actually a loaded from the db entity with all properties
|
|
6524
|
+
* replaced from the new object.
|
|
6525
|
+
*
|
|
6526
|
+
* Note that given entity-like object must have an entity id / primary key to find entity by.
|
|
6527
|
+
* Returns undefined if entity with given id was not found.
|
|
6528
|
+
*/
|
|
6529
|
+
preload(entityLike) {
|
|
6530
|
+
return this.repo.preload(entityLike);
|
|
6531
|
+
}
|
|
6532
|
+
//#endregion
|
|
6533
|
+
//#region crud operations / typeorm / remove (delete) & bulk remove (delete)
|
|
6534
|
+
/**
|
|
6535
|
+
* Removes a given entities from the database.
|
|
6536
|
+
*/
|
|
6537
|
+
async remove(idOrEntity) {
|
|
6538
|
+
/* */
|
|
6539
|
+
/* */
|
|
6540
|
+
/* */
|
|
6729
6541
|
/* */
|
|
6730
6542
|
/* */
|
|
6731
6543
|
/* */
|
|
6732
6544
|
/* */
|
|
6733
6545
|
/* */
|
|
6734
6546
|
/* */
|
|
6735
|
-
return (void 0);
|
|
6736
|
-
}
|
|
6737
|
-
//#endregion
|
|
6738
|
-
//#region bulk update
|
|
6739
|
-
bulkUpdate(items) {
|
|
6740
6547
|
/* */
|
|
6741
6548
|
/* */
|
|
6742
6549
|
/* */
|
|
@@ -6745,11 +6552,6 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6745
6552
|
/* */
|
|
6746
6553
|
/* */
|
|
6747
6554
|
/* */
|
|
6748
|
-
return (void 0);
|
|
6749
|
-
}
|
|
6750
|
-
//#endregion
|
|
6751
|
-
//#region delete by id
|
|
6752
|
-
deleteById(id) {
|
|
6753
6555
|
/* */
|
|
6754
6556
|
/* */
|
|
6755
6557
|
/* */
|
|
@@ -6757,9 +6559,26 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6757
6559
|
/* */
|
|
6758
6560
|
return (void 0);
|
|
6759
6561
|
}
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6562
|
+
/**
|
|
6563
|
+
* alias to remove
|
|
6564
|
+
*/
|
|
6565
|
+
async delete(idOrEntity) {
|
|
6566
|
+
return this.remove(idOrEntity);
|
|
6567
|
+
}
|
|
6568
|
+
/**
|
|
6569
|
+
* alias to removeById
|
|
6570
|
+
*/
|
|
6571
|
+
async deleteById(id) {
|
|
6572
|
+
return this.remove(id);
|
|
6573
|
+
}
|
|
6574
|
+
async bulkRemove(idsOrEntities) {
|
|
6575
|
+
/* */
|
|
6576
|
+
/* */
|
|
6577
|
+
/* */
|
|
6578
|
+
/* */
|
|
6579
|
+
/* */
|
|
6580
|
+
/* */
|
|
6581
|
+
/* */
|
|
6763
6582
|
/* */
|
|
6764
6583
|
/* */
|
|
6765
6584
|
/* */
|
|
@@ -6767,18 +6586,81 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6767
6586
|
/* */
|
|
6768
6587
|
return (void 0);
|
|
6769
6588
|
}
|
|
6589
|
+
async bulkDelete(ids) {
|
|
6590
|
+
return this.bulkRemove(ids);
|
|
6591
|
+
}
|
|
6592
|
+
/**
|
|
6593
|
+
* Records the delete date of a given entity.
|
|
6594
|
+
*/
|
|
6595
|
+
softRemove(entity, options) {
|
|
6596
|
+
return this.repo.softRemove(entity, options);
|
|
6597
|
+
}
|
|
6598
|
+
/**
|
|
6599
|
+
* Recovers a given entity in the database.
|
|
6600
|
+
*/
|
|
6601
|
+
recover(entity, options) {
|
|
6602
|
+
return this.repo.recover(entity, options);
|
|
6603
|
+
}
|
|
6770
6604
|
//#endregion
|
|
6771
|
-
//#region
|
|
6772
|
-
|
|
6773
|
-
|
|
6605
|
+
//#region crud operations / typeorm / insert
|
|
6606
|
+
/**
|
|
6607
|
+
* Inserts a given entity into the database.
|
|
6608
|
+
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
6609
|
+
* Executes fast and efficient INSERT query.
|
|
6610
|
+
* Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
|
|
6611
|
+
*/
|
|
6612
|
+
insert(entity) {
|
|
6613
|
+
// debugger;
|
|
6614
|
+
return this.repo.insert(entity);
|
|
6615
|
+
}
|
|
6616
|
+
//#endregion
|
|
6617
|
+
//#region crud operations / typeorm / update & build update
|
|
6618
|
+
async update(item) {
|
|
6774
6619
|
/* */
|
|
6775
6620
|
/* */
|
|
6776
6621
|
/* */
|
|
6777
6622
|
return (void 0);
|
|
6778
6623
|
}
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6624
|
+
async updateById(id, item) {
|
|
6625
|
+
/* */
|
|
6626
|
+
/* */
|
|
6627
|
+
/* */
|
|
6628
|
+
/* */
|
|
6629
|
+
/* */
|
|
6630
|
+
/* */
|
|
6631
|
+
/* */
|
|
6632
|
+
/* */
|
|
6633
|
+
/* */
|
|
6634
|
+
/* */
|
|
6635
|
+
/* */
|
|
6636
|
+
/* */
|
|
6637
|
+
/* */
|
|
6638
|
+
/* */
|
|
6639
|
+
/* */
|
|
6640
|
+
/* */
|
|
6641
|
+
/* */
|
|
6642
|
+
/* */
|
|
6643
|
+
/* */
|
|
6644
|
+
/* */
|
|
6645
|
+
/* */
|
|
6646
|
+
/* */
|
|
6647
|
+
/* */
|
|
6648
|
+
/* */
|
|
6649
|
+
/* */
|
|
6650
|
+
/* */
|
|
6651
|
+
/* */
|
|
6652
|
+
/* */
|
|
6653
|
+
/* */
|
|
6654
|
+
/* */
|
|
6655
|
+
/* */
|
|
6656
|
+
/* */
|
|
6657
|
+
/* */
|
|
6658
|
+
/* */
|
|
6659
|
+
/* */
|
|
6660
|
+
/* */
|
|
6661
|
+
/* */
|
|
6662
|
+
/* */
|
|
6663
|
+
/* */
|
|
6782
6664
|
/* */
|
|
6783
6665
|
/* */
|
|
6784
6666
|
/* */
|
|
@@ -6786,9 +6668,11 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6786
6668
|
/* */
|
|
6787
6669
|
return (void 0);
|
|
6788
6670
|
}
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6671
|
+
async bulkUpdate(items) {
|
|
6672
|
+
/* */
|
|
6673
|
+
/* */
|
|
6674
|
+
/* */
|
|
6675
|
+
/* */
|
|
6792
6676
|
/* */
|
|
6793
6677
|
/* */
|
|
6794
6678
|
/* */
|
|
@@ -6796,359 +6680,244 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6796
6680
|
/* */
|
|
6797
6681
|
return (void 0);
|
|
6798
6682
|
}
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
PUT(),
|
|
6833
|
-
__param(0, Query(`id`)),
|
|
6834
|
-
__param(1, Body()),
|
|
6835
|
-
__metadata("design:type", Function),
|
|
6836
|
-
__metadata("design:paramtypes", [Object, Object]),
|
|
6837
|
-
__metadata("design:returntype", Object)
|
|
6838
|
-
], TaonBaseCrudController.prototype, "updateById", null);
|
|
6839
|
-
__decorate([
|
|
6840
|
-
PATCH(),
|
|
6841
|
-
__param(0, Query(`id`)),
|
|
6842
|
-
__param(1, Body()),
|
|
6843
|
-
__metadata("design:type", Function),
|
|
6844
|
-
__metadata("design:paramtypes", [Object, Object]),
|
|
6845
|
-
__metadata("design:returntype", Object)
|
|
6846
|
-
], TaonBaseCrudController.prototype, "patchById", null);
|
|
6847
|
-
__decorate([
|
|
6848
|
-
PUT(),
|
|
6849
|
-
__param(0, Body()),
|
|
6850
|
-
__metadata("design:type", Function),
|
|
6851
|
-
__metadata("design:paramtypes", [Array]),
|
|
6852
|
-
__metadata("design:returntype", Object)
|
|
6853
|
-
], TaonBaseCrudController.prototype, "bulkUpdate", null);
|
|
6854
|
-
__decorate([
|
|
6855
|
-
DELETE(),
|
|
6856
|
-
__param(0, Query(`id`)),
|
|
6857
|
-
__metadata("design:type", Function),
|
|
6858
|
-
__metadata("design:paramtypes", [Object]),
|
|
6859
|
-
__metadata("design:returntype", Object)
|
|
6860
|
-
], TaonBaseCrudController.prototype, "deleteById", null);
|
|
6861
|
-
__decorate([
|
|
6862
|
-
DELETE(),
|
|
6863
|
-
__param(0, Query(`ids`)),
|
|
6864
|
-
__metadata("design:type", Function),
|
|
6865
|
-
__metadata("design:paramtypes", [Array]),
|
|
6866
|
-
__metadata("design:returntype", Object)
|
|
6867
|
-
], TaonBaseCrudController.prototype, "bulkDelete", null);
|
|
6868
|
-
__decorate([
|
|
6869
|
-
DELETE(),
|
|
6870
|
-
__metadata("design:type", Function),
|
|
6871
|
-
__metadata("design:paramtypes", []),
|
|
6872
|
-
__metadata("design:returntype", Object)
|
|
6873
|
-
], TaonBaseCrudController.prototype, "clearTable", null);
|
|
6874
|
-
__decorate([
|
|
6875
|
-
POST(),
|
|
6876
|
-
__param(0, Body()),
|
|
6877
|
-
__metadata("design:type", Function),
|
|
6878
|
-
__metadata("design:paramtypes", [Object]),
|
|
6879
|
-
__metadata("design:returntype", Object)
|
|
6880
|
-
], TaonBaseCrudController.prototype, "save", null);
|
|
6881
|
-
__decorate([
|
|
6882
|
-
POST(),
|
|
6883
|
-
__param(0, Body()),
|
|
6884
|
-
__metadata("design:type", Function),
|
|
6885
|
-
__metadata("design:paramtypes", [Object]),
|
|
6886
|
-
__metadata("design:returntype", Object)
|
|
6887
|
-
], TaonBaseCrudController.prototype, "bulkCreate", null);
|
|
6888
|
-
TaonBaseCrudController = __decorate([
|
|
6889
|
-
TaonController({ className: 'TaonBaseCrudController' })
|
|
6890
|
-
], TaonBaseCrudController);
|
|
6891
|
-
|
|
6892
|
-
/**
|
|
6893
|
-
* Repository decorator
|
|
6894
|
-
*/
|
|
6895
|
-
function TaonRepository(options) {
|
|
6896
|
-
return function (constructor) {
|
|
6897
|
-
Reflect.defineMetadata(Symbols.metadata.options.repository, options, constructor);
|
|
6898
|
-
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
6899
|
-
ClassHelpers.setName(constructor, options?.className);
|
|
6900
|
-
};
|
|
6901
|
-
}
|
|
6902
|
-
class TaonRepositoryOptions extends DecoratorAbstractOpt {
|
|
6903
|
-
}
|
|
6904
|
-
|
|
6905
|
-
//#endregion
|
|
6906
|
-
let TaonBaseCustomRepository = class TaonBaseCustomRepository extends TaonBaseInjector {
|
|
6907
|
-
};
|
|
6908
|
-
TaonBaseCustomRepository = __decorate([
|
|
6909
|
-
TaonRepository({ className: 'TaonBaseCustomRepository' })
|
|
6910
|
-
], TaonBaseCustomRepository);
|
|
6911
|
-
|
|
6912
|
-
//#endregion
|
|
6913
|
-
const INDEX_KEYS_NO_FOR_UPDATE = ['id'];
|
|
6914
|
-
let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomRepository {
|
|
6915
|
-
constructor(
|
|
6916
|
-
// Injected through TaonBaseCrudController
|
|
6917
|
-
__entityClassResolveFn) {
|
|
6918
|
-
super();
|
|
6919
|
-
this.REPOS_CACHE_KEY = Symbol('repository cache inside instance');
|
|
6920
|
-
this.allowedTypesToUpdate = ['simple-json', 'simple-array', 'json'];
|
|
6921
|
-
// @ts-ignore
|
|
6922
|
-
this.entityClassResolveFn = __entityClassResolveFn;
|
|
6683
|
+
//#region tpeorm update version
|
|
6684
|
+
// this version suck and will not return update entity
|
|
6685
|
+
// /**
|
|
6686
|
+
// * Updates entity partially. Entity can be found by a given conditions.
|
|
6687
|
+
// * Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
6688
|
+
// * Executes fast and efficient UPDATE query.
|
|
6689
|
+
// * Does not check if entity exist in the database.
|
|
6690
|
+
// */
|
|
6691
|
+
// update(
|
|
6692
|
+
// criteria:
|
|
6693
|
+
// | string
|
|
6694
|
+
// | string[]
|
|
6695
|
+
// | number
|
|
6696
|
+
// | number[]
|
|
6697
|
+
// | Date
|
|
6698
|
+
// | Date[]
|
|
6699
|
+
// | ObjectID
|
|
6700
|
+
// | ObjectID[]
|
|
6701
|
+
// | FindOptionsWhere<Entity>,
|
|
6702
|
+
// partialEntity: QueryDeepPartialEntity<Entity>,
|
|
6703
|
+
// ): Promise<UpdateResult> {
|
|
6704
|
+
// return this.repo.update(criteria, partialEntity);
|
|
6705
|
+
// }
|
|
6706
|
+
//#endregion
|
|
6707
|
+
//#endregion
|
|
6708
|
+
//#region crud operations / typeorm / upsert
|
|
6709
|
+
/**
|
|
6710
|
+
* Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
|
|
6711
|
+
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
6712
|
+
* Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
|
|
6713
|
+
*/
|
|
6714
|
+
upsert(entityOrEntities, conflictPathsOrOptions) {
|
|
6715
|
+
return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
|
|
6923
6716
|
}
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
/* */
|
|
6935
|
-
/* */
|
|
6936
|
-
/* */
|
|
6937
|
-
/* */
|
|
6938
|
-
/* */
|
|
6939
|
-
/* */
|
|
6940
|
-
/* */
|
|
6941
|
-
/* */
|
|
6942
|
-
/* */
|
|
6943
|
-
/* */
|
|
6944
|
-
return (void 0);
|
|
6717
|
+
//#endregion
|
|
6718
|
+
//#region crud operations / typeorm / soft delete
|
|
6719
|
+
/**
|
|
6720
|
+
* Records the delete date of entities by a given criteria.
|
|
6721
|
+
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
6722
|
+
* Executes fast and efficient SOFT-DELETE query.
|
|
6723
|
+
* Does not check if entity exist in the database.
|
|
6724
|
+
*/
|
|
6725
|
+
softDelete(criteria) {
|
|
6726
|
+
return this.repo.softDelete(criteria);
|
|
6945
6727
|
}
|
|
6946
6728
|
//#endregion
|
|
6947
|
-
//#region
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6729
|
+
//#region crud operations / typeorm / restore
|
|
6730
|
+
/**
|
|
6731
|
+
* Restores entities by a given criteria.
|
|
6732
|
+
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
6733
|
+
* Executes fast and efficient SOFT-DELETE query.
|
|
6734
|
+
* Does not check if entity exist in the database.
|
|
6735
|
+
*/
|
|
6736
|
+
restore(criteria) {
|
|
6737
|
+
return this.repo.restore(criteria);
|
|
6952
6738
|
}
|
|
6953
6739
|
//#endregion
|
|
6954
|
-
//#region
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
/* */
|
|
6962
|
-
/* */
|
|
6963
|
-
/* */
|
|
6964
|
-
/* */
|
|
6965
|
-
/* */
|
|
6966
|
-
/* */
|
|
6967
|
-
/* */
|
|
6968
|
-
/* */
|
|
6969
|
-
/* */
|
|
6970
|
-
/* */
|
|
6971
|
-
/* */
|
|
6972
|
-
/* */
|
|
6973
|
-
/* */
|
|
6974
|
-
/* */
|
|
6975
|
-
/* */
|
|
6976
|
-
/* */
|
|
6977
|
-
/* */
|
|
6978
|
-
/* */
|
|
6979
|
-
/* */
|
|
6980
|
-
/* */
|
|
6981
|
-
/* */
|
|
6982
|
-
/* */
|
|
6983
|
-
/* */
|
|
6984
|
-
/* */
|
|
6985
|
-
return (void 0);
|
|
6740
|
+
//#region crud operations / typeorm / count
|
|
6741
|
+
/**
|
|
6742
|
+
* Counts entities that match given options.
|
|
6743
|
+
* Useful for pagination.
|
|
6744
|
+
*/
|
|
6745
|
+
count(options) {
|
|
6746
|
+
return this.repo.count(options);
|
|
6986
6747
|
}
|
|
6748
|
+
//#endregion
|
|
6749
|
+
//#region crud operations / typeorm / count by
|
|
6987
6750
|
/**
|
|
6988
|
-
*
|
|
6751
|
+
* Counts entities that match given conditions.
|
|
6752
|
+
* Useful for pagination.
|
|
6989
6753
|
*/
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6754
|
+
countBy(where) {
|
|
6755
|
+
return this.repo.countBy(where);
|
|
6756
|
+
}
|
|
6757
|
+
//#endregion
|
|
6758
|
+
//#region crud operations / typeorm / find
|
|
6759
|
+
/**
|
|
6760
|
+
* Finds entities that match given find options.
|
|
6761
|
+
*/
|
|
6762
|
+
find(options) {
|
|
6763
|
+
return this.repo.find(options);
|
|
6994
6764
|
}
|
|
6765
|
+
//#endregion
|
|
6766
|
+
//#region crud operations / typeorm / find by
|
|
6995
6767
|
/**
|
|
6996
|
-
*
|
|
6768
|
+
* Finds entities that match given find options.
|
|
6997
6769
|
*/
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
/* */
|
|
7001
|
-
return (void 0);
|
|
6770
|
+
findBy(where) {
|
|
6771
|
+
return this.repo.findBy(where);
|
|
7002
6772
|
}
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
6773
|
+
//#endregion
|
|
6774
|
+
//#region crud operations / typeorm / find and count
|
|
6775
|
+
// async findAndCount(options: { take: number; skip: number }) {
|
|
6776
|
+
// const { take, skip } = options;
|
|
6777
|
+
// const [result, total] = await this.repo.findAndCount({
|
|
6778
|
+
// // where: { name: Like('%' + keyword + '%') },
|
|
6779
|
+
// // order: { name: "DESC" },
|
|
6780
|
+
// take: take,
|
|
6781
|
+
// skip: skip,
|
|
6782
|
+
// });
|
|
6783
|
+
// return { result, total };
|
|
6784
|
+
// }
|
|
6785
|
+
//
|
|
6786
|
+
/**
|
|
6787
|
+
* Finds entities that match given find options.
|
|
6788
|
+
* Also counts all entities that match given conditions,
|
|
6789
|
+
* but ignores pagination settings (from and take options).
|
|
6790
|
+
*/
|
|
6791
|
+
findAndCount(options) {
|
|
6792
|
+
return this.repo.findAndCount(options);
|
|
7007
6793
|
}
|
|
7008
6794
|
//#endregion
|
|
7009
|
-
//#region crud operations / typeorm /
|
|
6795
|
+
//#region crud operations / typeorm / find and count by
|
|
7010
6796
|
/**
|
|
7011
|
-
*
|
|
7012
|
-
*
|
|
6797
|
+
* Finds entities that match given WHERE conditions.
|
|
6798
|
+
* Also counts all entities that match given conditions,
|
|
6799
|
+
* but ignores pagination settings (from and take options).
|
|
7013
6800
|
*/
|
|
7014
|
-
|
|
7015
|
-
return this.repo.
|
|
6801
|
+
findAndCountBy(where) {
|
|
6802
|
+
return this.repo.findAndCountBy(where);
|
|
7016
6803
|
}
|
|
7017
6804
|
//#endregion
|
|
7018
|
-
//#region crud operations / typeorm /
|
|
6805
|
+
//#region crud operations / typeorm / find by ids
|
|
7019
6806
|
/**
|
|
7020
|
-
*
|
|
6807
|
+
* Finds entities with ids.
|
|
6808
|
+
* Optionally find options or conditions can be applied.
|
|
6809
|
+
*
|
|
6810
|
+
* @deprecated use `findBy` method instead in conjunction with `In` operator, for example:
|
|
6811
|
+
*
|
|
6812
|
+
* .findBy({
|
|
6813
|
+
* id: In([1, 2, 3])
|
|
6814
|
+
* })
|
|
7021
6815
|
*/
|
|
7022
|
-
|
|
7023
|
-
return this.repo.
|
|
6816
|
+
findByIds(ids) {
|
|
6817
|
+
return this.repo.findByIds(ids);
|
|
7024
6818
|
}
|
|
7025
6819
|
//#endregion
|
|
7026
|
-
//#region crud operations / typeorm /
|
|
6820
|
+
//#region crud operations / typeorm / find one
|
|
7027
6821
|
/**
|
|
7028
|
-
|
|
7029
|
-
* If entity
|
|
6822
|
+
* Finds first entity by a given find options.
|
|
6823
|
+
* If entity was not found in the database - returns null.
|
|
7030
6824
|
*/
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
/* */
|
|
7034
|
-
/* */
|
|
7035
|
-
/* */
|
|
7036
|
-
/* */
|
|
7037
|
-
/* */
|
|
7038
|
-
/* */
|
|
7039
|
-
/* */
|
|
7040
|
-
/* */
|
|
7041
|
-
/* */
|
|
7042
|
-
/* */
|
|
7043
|
-
/* */
|
|
7044
|
-
/* */
|
|
7045
|
-
/* */
|
|
7046
|
-
return (void 0);
|
|
6825
|
+
findOne(options) {
|
|
6826
|
+
return this.repo.findOne(options);
|
|
7047
6827
|
}
|
|
6828
|
+
//#endregion
|
|
6829
|
+
//#region crud operations / typeorm / find one by
|
|
7048
6830
|
/**
|
|
7049
|
-
*
|
|
7050
|
-
*
|
|
6831
|
+
* Finds first entity that matches given where condition.
|
|
6832
|
+
* If entity was not found in the database - returns null.
|
|
7051
6833
|
*/
|
|
7052
|
-
|
|
7053
|
-
return this.repo.
|
|
6834
|
+
findOneBy(where) {
|
|
6835
|
+
return this.repo.findOneBy(where);
|
|
7054
6836
|
}
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
6837
|
+
//#endregion
|
|
6838
|
+
//#region crud operations / typeorm / find one or fail
|
|
6839
|
+
/**
|
|
6840
|
+
* Finds first entity that matches given id.
|
|
6841
|
+
* If entity was not found in the database - returns null.
|
|
6842
|
+
*
|
|
6843
|
+
* @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:
|
|
6844
|
+
*
|
|
6845
|
+
* .findOneBy({
|
|
6846
|
+
* id: 1 // where "id" is your primary column name
|
|
6847
|
+
* })
|
|
6848
|
+
*/
|
|
6849
|
+
findOneById(id) {
|
|
6850
|
+
return this.repo.findOneById(id);
|
|
7066
6851
|
}
|
|
6852
|
+
//#endregion
|
|
6853
|
+
//#region crud operations / typeorm / find one or fail
|
|
7067
6854
|
/**
|
|
7068
|
-
*
|
|
6855
|
+
* Finds first entity by a given find options.
|
|
6856
|
+
* If entity was not found in the database - rejects with error.
|
|
7069
6857
|
*/
|
|
7070
|
-
|
|
7071
|
-
return this.
|
|
6858
|
+
findOneOrFail(options) {
|
|
6859
|
+
return this.repo.findOneOrFail(options);
|
|
7072
6860
|
}
|
|
7073
|
-
//#
|
|
6861
|
+
//#endregion
|
|
6862
|
+
//#region crud operations / typeorm / find one by or fail
|
|
7074
6863
|
/**
|
|
7075
|
-
*
|
|
7076
|
-
* If
|
|
6864
|
+
* Finds first entity that matches given where condition.
|
|
6865
|
+
* If entity was not found in the database - rejects with error.
|
|
7077
6866
|
*/
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
// reload: false;
|
|
7100
|
-
// },
|
|
7101
|
-
// ): Promise<T>;
|
|
7102
|
-
// /**
|
|
7103
|
-
// * Saves a given entity in the database.
|
|
7104
|
-
// * If entity does not exist in the database then inserts, otherwise updates.
|
|
7105
|
-
// */
|
|
7106
|
-
// save<T extends DeepPartial<Entity>>(
|
|
7107
|
-
// entity: T,
|
|
7108
|
-
// options?: SaveOptions,
|
|
7109
|
-
// ): Promise<T & Entity> {
|
|
7110
|
-
// return this.repo.save(entity, options);
|
|
7111
|
-
// }
|
|
6867
|
+
findOneByOrFail(where) {
|
|
6868
|
+
return this.repo.findOneByOrFail(where);
|
|
6869
|
+
}
|
|
6870
|
+
//#endregion
|
|
6871
|
+
//#region crud operations / typeorm / query
|
|
6872
|
+
/**
|
|
6873
|
+
* Executes a raw SQL query and returns a raw database results.
|
|
6874
|
+
* Raw query execution is supported only by relational databases (MongoDB is not supported).
|
|
6875
|
+
*/
|
|
6876
|
+
query(query, parameters) {
|
|
6877
|
+
return this.repo.query(query, parameters);
|
|
6878
|
+
}
|
|
6879
|
+
//#endregion
|
|
6880
|
+
//#region crud operations / typeorm / query
|
|
6881
|
+
/**
|
|
6882
|
+
* Executes a raw SQL query and returns a raw database results.
|
|
6883
|
+
* Raw query execution is supported only by relational databases (MongoDB is not supported).
|
|
6884
|
+
*/
|
|
6885
|
+
createQueryBuilder(alias, queryRunner) {
|
|
6886
|
+
return this.repo.createQueryBuilder(alias, queryRunner);
|
|
6887
|
+
}
|
|
7112
6888
|
//#endregion
|
|
6889
|
+
//#region crud operations / typeorm / clear
|
|
6890
|
+
/**
|
|
6891
|
+
* Clears all the data from the given table/collection (truncates/drops it).
|
|
6892
|
+
*
|
|
6893
|
+
* Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.
|
|
6894
|
+
* @see https://stackoverflow.com/a/5972738/925151
|
|
6895
|
+
*/
|
|
6896
|
+
clear() {
|
|
6897
|
+
return this.repo.clear();
|
|
6898
|
+
}
|
|
7113
6899
|
//#endregion
|
|
7114
|
-
//#region crud operations / typeorm /
|
|
6900
|
+
//#region crud operations / typeorm / increment
|
|
7115
6901
|
/**
|
|
7116
|
-
*
|
|
6902
|
+
* Increments some column by provided value of the entities matched given conditions.
|
|
7117
6903
|
*/
|
|
7118
|
-
|
|
7119
|
-
return this.repo.
|
|
6904
|
+
increment(conditions, propertyPath, value) {
|
|
6905
|
+
return this.repo.increment(conditions, propertyPath, value);
|
|
7120
6906
|
}
|
|
7121
6907
|
//#endregion
|
|
7122
|
-
//#region crud operations / typeorm /
|
|
6908
|
+
//#region crud operations / typeorm / decrement
|
|
7123
6909
|
/**
|
|
7124
|
-
*
|
|
7125
|
-
* it loads it (and everything related to it), replaces all values with the new ones from the given object
|
|
7126
|
-
* and returns this new entity. This new entity is actually a loaded from the db entity with all properties
|
|
7127
|
-
* replaced from the new object.
|
|
7128
|
-
*
|
|
7129
|
-
* Note that given entity-like object must have an entity id / primary key to find entity by.
|
|
7130
|
-
* Returns undefined if entity with given id was not found.
|
|
6910
|
+
* Decrements some column by provided value of the entities matched given conditions.
|
|
7131
6911
|
*/
|
|
7132
|
-
|
|
7133
|
-
return this.repo.
|
|
6912
|
+
decrement(conditions, propertyPath, value) {
|
|
6913
|
+
return this.repo.decrement(conditions, propertyPath, value);
|
|
7134
6914
|
}
|
|
7135
6915
|
//#endregion
|
|
7136
|
-
//#region crud operations /
|
|
6916
|
+
//#region crud operations / get all
|
|
7137
6917
|
/**
|
|
7138
|
-
*
|
|
6918
|
+
* @deprecated use findAndCount instead
|
|
7139
6919
|
*/
|
|
7140
|
-
async
|
|
7141
|
-
/* */
|
|
7142
|
-
/* */
|
|
7143
|
-
/* */
|
|
7144
|
-
/* */
|
|
7145
|
-
/* */
|
|
7146
|
-
/* */
|
|
7147
|
-
/* */
|
|
7148
|
-
/* */
|
|
7149
|
-
/* */
|
|
7150
|
-
/* */
|
|
7151
|
-
/* */
|
|
6920
|
+
async getAll() {
|
|
7152
6921
|
/* */
|
|
7153
6922
|
/* */
|
|
7154
6923
|
/* */
|
|
@@ -7162,25 +6931,9 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
7162
6931
|
/* */
|
|
7163
6932
|
return (void 0);
|
|
7164
6933
|
}
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
async delete(idOrEntity) {
|
|
7169
|
-
return this.remove(idOrEntity);
|
|
7170
|
-
}
|
|
7171
|
-
/**
|
|
7172
|
-
* alias to removeById
|
|
7173
|
-
*/
|
|
7174
|
-
async deleteById(id) {
|
|
7175
|
-
return this.remove(id);
|
|
7176
|
-
}
|
|
7177
|
-
async bulkRemove(idsOrEntities) {
|
|
7178
|
-
/* */
|
|
7179
|
-
/* */
|
|
7180
|
-
/* */
|
|
7181
|
-
/* */
|
|
7182
|
-
/* */
|
|
7183
|
-
/* */
|
|
6934
|
+
//#endregion
|
|
6935
|
+
//#region crud operations / get by id
|
|
6936
|
+
async getBy(id) {
|
|
7184
6937
|
/* */
|
|
7185
6938
|
/* */
|
|
7186
6939
|
/* */
|
|
@@ -7189,55 +6942,199 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
7189
6942
|
/* */
|
|
7190
6943
|
return (void 0);
|
|
7191
6944
|
}
|
|
7192
|
-
|
|
7193
|
-
|
|
6945
|
+
};
|
|
6946
|
+
TaonBaseRepository = __decorate([
|
|
6947
|
+
TaonRepository({ className: 'TaonBaseRepository' }),
|
|
6948
|
+
__metadata("design:paramtypes", [Function])
|
|
6949
|
+
], TaonBaseRepository);
|
|
6950
|
+
|
|
6951
|
+
const TaonBaseContext = createContext(() => ({
|
|
6952
|
+
contextName: 'TaonBaseContext',
|
|
6953
|
+
abstract: true,
|
|
6954
|
+
contexts: {
|
|
6955
|
+
// TaonGlobalStateContext,
|
|
6956
|
+
},
|
|
6957
|
+
middlewares: {
|
|
6958
|
+
TaonBaseFileUploadMiddleware,
|
|
6959
|
+
},
|
|
6960
|
+
repositories: {
|
|
6961
|
+
// @ts-ignore
|
|
6962
|
+
TaonBaseRepository,
|
|
6963
|
+
},
|
|
6964
|
+
}));
|
|
6965
|
+
|
|
6966
|
+
var baseContext = /*#__PURE__*/Object.freeze({
|
|
6967
|
+
__proto__: null,
|
|
6968
|
+
TaonBaseContext: TaonBaseContext
|
|
6969
|
+
});
|
|
6970
|
+
|
|
6971
|
+
/**
|
|
6972
|
+
* Controller decorator
|
|
6973
|
+
*/
|
|
6974
|
+
function TaonController(options) {
|
|
6975
|
+
return function (constructor) {
|
|
6976
|
+
ClassHelpers.setName(constructor, options?.className);
|
|
6977
|
+
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
6978
|
+
const cfg = ClassHelpers.ensureClassConfig(constructor);
|
|
6979
|
+
options = options || {};
|
|
6980
|
+
cfg.className = options.className || constructor.name;
|
|
6981
|
+
cfg.path = options.path || '';
|
|
6982
|
+
cfg.realtime = options.realtime;
|
|
6983
|
+
cfg.middlewares = options.middlewares;
|
|
6984
|
+
};
|
|
6985
|
+
}
|
|
6986
|
+
|
|
6987
|
+
const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
|
|
6988
|
+
const methodConfig = ClassHelpers.ensureMethodConfig(target, propertyKey);
|
|
6989
|
+
let options;
|
|
6990
|
+
if (typeof pathOrOptions === 'object') {
|
|
6991
|
+
options = pathOrOptions;
|
|
6992
|
+
pathOrOptions = options.path;
|
|
6993
|
+
pathIsGlobal = !!options.pathIsGlobal;
|
|
6994
|
+
path = options.path;
|
|
7194
6995
|
}
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
*/
|
|
7198
|
-
softRemove(entity, options) {
|
|
7199
|
-
return this.repo.softRemove(entity, options);
|
|
6996
|
+
else {
|
|
6997
|
+
options = { pathOrOptions, pathIsGlobal };
|
|
7200
6998
|
}
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
6999
|
+
const { overrideContentType, overrideResponseType, overrideExpressSendAsHtml, middlewares, } = options;
|
|
7000
|
+
methodConfig.methodName = propertyKey;
|
|
7001
|
+
methodConfig.middlewares = middlewares;
|
|
7002
|
+
methodConfig.type = method;
|
|
7003
|
+
if (!path) {
|
|
7004
|
+
let paramsPathConcatedPath = '';
|
|
7005
|
+
for (const key in methodConfig.parameters) {
|
|
7006
|
+
if (methodConfig.parameters.hasOwnProperty(key)) {
|
|
7007
|
+
const element = methodConfig.parameters[key];
|
|
7008
|
+
if (element.paramType === 'Path' &&
|
|
7009
|
+
_.isString(element.paramName) &&
|
|
7010
|
+
element.paramName.trim().length > 0) {
|
|
7011
|
+
paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
|
|
7012
|
+
}
|
|
7013
|
+
}
|
|
7014
|
+
}
|
|
7015
|
+
methodConfig.path = `/${propertyKey}${paramsPathConcatedPath}`;
|
|
7206
7016
|
}
|
|
7207
|
-
|
|
7208
|
-
|
|
7017
|
+
else {
|
|
7018
|
+
methodConfig.path = path;
|
|
7019
|
+
}
|
|
7020
|
+
methodConfig.descriptor = descriptor;
|
|
7021
|
+
methodConfig.global = pathIsGlobal;
|
|
7022
|
+
methodConfig.contentType = overrideContentType;
|
|
7023
|
+
methodConfig.responseType = overrideResponseType;
|
|
7024
|
+
methodConfig.overrideExpressSendAsHtml = overrideExpressSendAsHtml;
|
|
7025
|
+
};
|
|
7026
|
+
function GET(pathOrOptions, pathIsGlobal = false) {
|
|
7027
|
+
return function (target, propertyKey, descriptor) {
|
|
7028
|
+
metaReq('get', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
7029
|
+
};
|
|
7030
|
+
}
|
|
7031
|
+
/**
|
|
7032
|
+
* Method for sending html website from text
|
|
7033
|
+
* Example
|
|
7034
|
+
*
|
|
7035
|
+
* ```ts
|
|
7036
|
+
* ...
|
|
7037
|
+
* // in your taon controller
|
|
7038
|
+
* ..Taon.Http.HTML()
|
|
7039
|
+
* sendHtmlDummyWebsite(): Taon.ResponseHtml {
|
|
7040
|
+
* return `
|
|
7041
|
+
<html>
|
|
7042
|
+
<head>
|
|
7043
|
+
<title>Dummy website</title>
|
|
7044
|
+
</head>
|
|
7045
|
+
<body>
|
|
7046
|
+
<h1>This is dummy website</h1>
|
|
7047
|
+
<p>Served as HTML string from Taon controller method</p>
|
|
7048
|
+
</body>
|
|
7049
|
+
</html>
|
|
7050
|
+
* `; *
|
|
7051
|
+
* }
|
|
7052
|
+
* ...
|
|
7053
|
+
* ```
|
|
7054
|
+
*/
|
|
7055
|
+
function HTML(pathOrOptions) {
|
|
7056
|
+
return function (target, propertyKey, descriptor) {
|
|
7057
|
+
const opt = pathOrOptions;
|
|
7058
|
+
opt.overrideExpressSendAsHtml = true;
|
|
7059
|
+
metaReq('get', opt, target, propertyKey, descriptor, pathOrOptions, opt.pathIsGlobal);
|
|
7060
|
+
};
|
|
7061
|
+
}
|
|
7062
|
+
function HEAD(pathOrOptions, pathIsGlobal = false) {
|
|
7063
|
+
return function (target, propertyKey, descriptor) {
|
|
7064
|
+
metaReq('head', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
7065
|
+
};
|
|
7066
|
+
}
|
|
7067
|
+
function POST(pathOrOptions, pathIsGlobal = false) {
|
|
7068
|
+
return function (target, propertyKey, descriptor) {
|
|
7069
|
+
metaReq('post', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
7070
|
+
};
|
|
7071
|
+
}
|
|
7072
|
+
function PUT(pathOrOptions, pathIsGlobal = false) {
|
|
7073
|
+
return function (target, propertyKey, descriptor) {
|
|
7074
|
+
metaReq('put', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
7075
|
+
};
|
|
7076
|
+
}
|
|
7077
|
+
function PATCH(pathOrOptions, pathIsGlobal = false) {
|
|
7078
|
+
return function (target, propertyKey, descriptor) {
|
|
7079
|
+
metaReq('patch', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
7080
|
+
};
|
|
7081
|
+
}
|
|
7082
|
+
function DELETE(pathOrOptions, pathIsGlobal = false) {
|
|
7083
|
+
return function (target, propertyKey, descriptor) {
|
|
7084
|
+
metaReq('delete', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
7085
|
+
};
|
|
7086
|
+
}
|
|
7087
|
+
|
|
7088
|
+
function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
|
|
7089
|
+
const methodCfg = ClassHelpers.ensureMethodConfig(target, propertyKey);
|
|
7090
|
+
const nameKey = name ? name : param;
|
|
7091
|
+
// const key = name || `${param}_${parameterIndex}`;
|
|
7092
|
+
methodCfg.parameters[nameKey] = {
|
|
7093
|
+
index: parameterIndex,
|
|
7094
|
+
paramName: name,
|
|
7095
|
+
paramType: param,
|
|
7096
|
+
defaultType: defaultValue,
|
|
7097
|
+
expireInSeconds: expire,
|
|
7098
|
+
};
|
|
7099
|
+
// console.log('params updated', methodConfig);
|
|
7100
|
+
}
|
|
7101
|
+
/**
|
|
7102
|
+
* @deprecated use Taon.Http.Param.Path (is more safe and cleaner)
|
|
7103
|
+
*/
|
|
7104
|
+
function Path(name) {
|
|
7105
|
+
return function (target, propertyKey, parameterIndex) {
|
|
7106
|
+
metaParam('Path', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
7107
|
+
};
|
|
7108
|
+
}
|
|
7109
|
+
function Query(name) {
|
|
7110
|
+
return function (target, propertyKey, parameterIndex) {
|
|
7111
|
+
metaParam('Query', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
7112
|
+
};
|
|
7113
|
+
}
|
|
7114
|
+
function Cookie(name, expireInSecond = 3600) {
|
|
7115
|
+
return function (target, propertyKey, parameterIndex) {
|
|
7116
|
+
metaParam('Cookie', name, expireInSecond, {}, target, propertyKey, parameterIndex);
|
|
7117
|
+
};
|
|
7118
|
+
}
|
|
7119
|
+
function Header(name) {
|
|
7120
|
+
return function (target, propertyKey, parameterIndex) {
|
|
7121
|
+
metaParam('Header', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
7122
|
+
};
|
|
7123
|
+
}
|
|
7124
|
+
function Body(name) {
|
|
7125
|
+
return function (target, propertyKey, parameterIndex) {
|
|
7126
|
+
metaParam('Body', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
7127
|
+
};
|
|
7128
|
+
}
|
|
7129
|
+
|
|
7130
|
+
let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
|
|
7209
7131
|
/**
|
|
7210
|
-
*
|
|
7211
|
-
*
|
|
7212
|
-
* Executes fast and efficient INSERT query.
|
|
7213
|
-
* Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
|
|
7132
|
+
* Hook that is called when taon app is inited
|
|
7133
|
+
* (all contexts are created and inited)
|
|
7214
7134
|
*/
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
}
|
|
7219
|
-
//#endregion
|
|
7220
|
-
//#region crud operations / typeorm / update & build update
|
|
7221
|
-
async update(item) {
|
|
7222
|
-
/* */
|
|
7223
|
-
/* */
|
|
7224
|
-
/* */
|
|
7225
|
-
return (void 0);
|
|
7226
|
-
}
|
|
7227
|
-
async updateById(id, item) {
|
|
7228
|
-
/* */
|
|
7229
|
-
/* */
|
|
7230
|
-
/* */
|
|
7231
|
-
/* */
|
|
7232
|
-
/* */
|
|
7233
|
-
/* */
|
|
7234
|
-
/* */
|
|
7235
|
-
/* */
|
|
7236
|
-
/* */
|
|
7237
|
-
/* */
|
|
7238
|
-
/* */
|
|
7239
|
-
/* */
|
|
7240
|
-
/* */
|
|
7135
|
+
async afterAllCtxInited(options) { }
|
|
7136
|
+
//#region upload form data to server
|
|
7137
|
+
uploadFormDataToServer(formData, queryParams) {
|
|
7241
7138
|
/* */
|
|
7242
7139
|
/* */
|
|
7243
7140
|
/* */
|
|
@@ -7264,14 +7161,24 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
7264
7161
|
/* */
|
|
7265
7162
|
/* */
|
|
7266
7163
|
/* */
|
|
7164
|
+
return (void 0);
|
|
7165
|
+
}
|
|
7166
|
+
//#endregion
|
|
7167
|
+
//#region after file upload hook
|
|
7168
|
+
/**
|
|
7169
|
+
* Hook after file is uploaded
|
|
7170
|
+
* through `uploadFormDataToServer` or `uploadLocalFileToServer`
|
|
7171
|
+
*/
|
|
7172
|
+
afterFileUploadAction(file, queryParams) {
|
|
7173
|
+
// empty
|
|
7174
|
+
}
|
|
7175
|
+
//#region upload local file to server
|
|
7176
|
+
async uploadLocalFileToServer(absFilePath, options, queryParams) {
|
|
7267
7177
|
/* */
|
|
7268
7178
|
/* */
|
|
7269
7179
|
/* */
|
|
7270
7180
|
/* */
|
|
7271
7181
|
/* */
|
|
7272
|
-
return (void 0);
|
|
7273
|
-
}
|
|
7274
|
-
async bulkUpdate(items) {
|
|
7275
7182
|
/* */
|
|
7276
7183
|
/* */
|
|
7277
7184
|
/* */
|
|
@@ -7283,249 +7190,232 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
7283
7190
|
/* */
|
|
7284
7191
|
return (void 0);
|
|
7285
7192
|
}
|
|
7286
|
-
//#region tpeorm update version
|
|
7287
|
-
// this version suck and will not return update entity
|
|
7288
|
-
// /**
|
|
7289
|
-
// * Updates entity partially. Entity can be found by a given conditions.
|
|
7290
|
-
// * Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
7291
|
-
// * Executes fast and efficient UPDATE query.
|
|
7292
|
-
// * Does not check if entity exist in the database.
|
|
7293
|
-
// */
|
|
7294
|
-
// update(
|
|
7295
|
-
// criteria:
|
|
7296
|
-
// | string
|
|
7297
|
-
// | string[]
|
|
7298
|
-
// | number
|
|
7299
|
-
// | number[]
|
|
7300
|
-
// | Date
|
|
7301
|
-
// | Date[]
|
|
7302
|
-
// | ObjectID
|
|
7303
|
-
// | ObjectID[]
|
|
7304
|
-
// | FindOptionsWhere<Entity>,
|
|
7305
|
-
// partialEntity: QueryDeepPartialEntity<Entity>,
|
|
7306
|
-
// ): Promise<UpdateResult> {
|
|
7307
|
-
// return this.repo.update(criteria, partialEntity);
|
|
7308
|
-
// }
|
|
7309
|
-
//#endregion
|
|
7310
|
-
//#endregion
|
|
7311
|
-
//#region crud operations / typeorm / upsert
|
|
7312
|
-
/**
|
|
7313
|
-
* Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
|
|
7314
|
-
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
7315
|
-
* Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
|
|
7316
|
-
*/
|
|
7317
|
-
upsert(entityOrEntities, conflictPathsOrOptions) {
|
|
7318
|
-
return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
|
|
7319
|
-
}
|
|
7320
|
-
//#endregion
|
|
7321
|
-
//#region crud operations / typeorm / soft delete
|
|
7322
|
-
/**
|
|
7323
|
-
* Records the delete date of entities by a given criteria.
|
|
7324
|
-
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
7325
|
-
* Executes fast and efficient SOFT-DELETE query.
|
|
7326
|
-
* Does not check if entity exist in the database.
|
|
7327
|
-
*/
|
|
7328
|
-
softDelete(criteria) {
|
|
7329
|
-
return this.repo.softDelete(criteria);
|
|
7330
|
-
}
|
|
7331
|
-
//#endregion
|
|
7332
|
-
//#region crud operations / typeorm / restore
|
|
7333
|
-
/**
|
|
7334
|
-
* Restores entities by a given criteria.
|
|
7335
|
-
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
7336
|
-
* Executes fast and efficient SOFT-DELETE query.
|
|
7337
|
-
* Does not check if entity exist in the database.
|
|
7338
|
-
*/
|
|
7339
|
-
restore(criteria) {
|
|
7340
|
-
return this.repo.restore(criteria);
|
|
7341
|
-
}
|
|
7342
|
-
//#endregion
|
|
7343
|
-
//#region crud operations / typeorm / count
|
|
7344
|
-
/**
|
|
7345
|
-
* Counts entities that match given options.
|
|
7346
|
-
* Useful for pagination.
|
|
7347
|
-
*/
|
|
7348
|
-
count(options) {
|
|
7349
|
-
return this.repo.count(options);
|
|
7350
|
-
}
|
|
7351
|
-
//#endregion
|
|
7352
|
-
//#region crud operations / typeorm / count by
|
|
7353
|
-
/**
|
|
7354
|
-
* Counts entities that match given conditions.
|
|
7355
|
-
* Useful for pagination.
|
|
7356
|
-
*/
|
|
7357
|
-
countBy(where) {
|
|
7358
|
-
return this.repo.countBy(where);
|
|
7359
|
-
}
|
|
7360
|
-
//#endregion
|
|
7361
|
-
//#region crud operations / typeorm / find
|
|
7362
|
-
/**
|
|
7363
|
-
* Finds entities that match given find options.
|
|
7364
|
-
*/
|
|
7365
|
-
find(options) {
|
|
7366
|
-
return this.repo.find(options);
|
|
7367
|
-
}
|
|
7368
|
-
//#endregion
|
|
7369
|
-
//#region crud operations / typeorm / find by
|
|
7370
|
-
/**
|
|
7371
|
-
* Finds entities that match given find options.
|
|
7372
|
-
*/
|
|
7373
|
-
findBy(where) {
|
|
7374
|
-
return this.repo.findBy(where);
|
|
7375
|
-
}
|
|
7376
7193
|
//#endregion
|
|
7377
|
-
|
|
7378
|
-
//
|
|
7379
|
-
//
|
|
7380
|
-
//
|
|
7381
|
-
//
|
|
7382
|
-
// // order: { name: "DESC" },
|
|
7383
|
-
// take: take,
|
|
7384
|
-
// skip: skip,
|
|
7385
|
-
// });
|
|
7386
|
-
// return { result, total };
|
|
7194
|
+
// async check() {
|
|
7195
|
+
// await this._waitForProperStatusChange({
|
|
7196
|
+
// request: () => this.uploadFormDataToServer(void 0, void 0).request(),
|
|
7197
|
+
// statusCheck: resp => resp.body.json[0].ok,
|
|
7198
|
+
// });
|
|
7387
7199
|
// }
|
|
7388
|
-
//
|
|
7389
|
-
/**
|
|
7390
|
-
* Finds entities that match given find options.
|
|
7391
|
-
* Also counts all entities that match given conditions,
|
|
7392
|
-
* but ignores pagination settings (from and take options).
|
|
7393
|
-
*/
|
|
7394
|
-
findAndCount(options) {
|
|
7395
|
-
return this.repo.findAndCount(options);
|
|
7396
|
-
}
|
|
7397
|
-
//#endregion
|
|
7398
|
-
//#region crud operations / typeorm / find and count by
|
|
7399
|
-
/**
|
|
7400
|
-
* Finds entities that match given WHERE conditions.
|
|
7401
|
-
* Also counts all entities that match given conditions,
|
|
7402
|
-
* but ignores pagination settings (from and take options).
|
|
7403
|
-
*/
|
|
7404
|
-
findAndCountBy(where) {
|
|
7405
|
-
return this.repo.findAndCountBy(where);
|
|
7406
|
-
}
|
|
7407
|
-
//#endregion
|
|
7408
|
-
//#region crud operations / typeorm / find by ids
|
|
7409
|
-
/**
|
|
7410
|
-
* Finds entities with ids.
|
|
7411
|
-
* Optionally find options or conditions can be applied.
|
|
7412
|
-
*
|
|
7413
|
-
* @deprecated use `findBy` method instead in conjunction with `In` operator, for example:
|
|
7414
|
-
*
|
|
7415
|
-
* .findBy({
|
|
7416
|
-
* id: In([1, 2, 3])
|
|
7417
|
-
* })
|
|
7418
|
-
*/
|
|
7419
|
-
findByIds(ids) {
|
|
7420
|
-
return this.repo.findByIds(ids);
|
|
7421
|
-
}
|
|
7422
|
-
//#endregion
|
|
7423
|
-
//#region crud operations / typeorm / find one
|
|
7424
|
-
/**
|
|
7425
|
-
* Finds first entity by a given find options.
|
|
7426
|
-
* If entity was not found in the database - returns null.
|
|
7427
|
-
*/
|
|
7428
|
-
findOne(options) {
|
|
7429
|
-
return this.repo.findOne(options);
|
|
7430
|
-
}
|
|
7431
|
-
//#endregion
|
|
7432
|
-
//#region crud operations / typeorm / find one by
|
|
7433
|
-
/**
|
|
7434
|
-
* Finds first entity that matches given where condition.
|
|
7435
|
-
* If entity was not found in the database - returns null.
|
|
7436
|
-
*/
|
|
7437
|
-
findOneBy(where) {
|
|
7438
|
-
return this.repo.findOneBy(where);
|
|
7439
|
-
}
|
|
7440
|
-
//#endregion
|
|
7441
|
-
//#region crud operations / typeorm / find one or fail
|
|
7442
7200
|
/**
|
|
7443
|
-
*
|
|
7444
|
-
* If entity was not found in the database - returns null.
|
|
7445
|
-
*
|
|
7446
|
-
* @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:
|
|
7201
|
+
* Easy way to wait for status change with http (1s default) pooling.
|
|
7447
7202
|
*
|
|
7448
|
-
*
|
|
7449
|
-
*
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
/**
|
|
7458
|
-
* Finds first entity by a given find options.
|
|
7459
|
-
* If entity was not found in the database - rejects with error.
|
|
7460
|
-
*/
|
|
7461
|
-
findOneOrFail(options) {
|
|
7462
|
-
return this.repo.findOneOrFail(options);
|
|
7463
|
-
}
|
|
7464
|
-
//#endregion
|
|
7465
|
-
//#region crud operations / typeorm / find one by or fail
|
|
7466
|
-
/**
|
|
7467
|
-
* Finds first entity that matches given where condition.
|
|
7468
|
-
* If entity was not found in the database - rejects with error.
|
|
7203
|
+
* example (in sub class):
|
|
7204
|
+
* ```ts
|
|
7205
|
+
async check() {
|
|
7206
|
+
await this.waitForProperStatusChange({
|
|
7207
|
+
request: () => this.uploadFormDataToServer(void 0, void 0).request(),
|
|
7208
|
+
statusCheck: resp => resp.body.json[0].ok,
|
|
7209
|
+
});
|
|
7210
|
+
}
|
|
7211
|
+
* ```
|
|
7469
7212
|
*/
|
|
7470
|
-
|
|
7471
|
-
|
|
7213
|
+
async _waitForProperStatusChange(options) {
|
|
7214
|
+
const poolingInterval = options.poolingInterval || 1000;
|
|
7215
|
+
const taonRequest = options.request;
|
|
7216
|
+
let maxTries = options.maxTries || Number.POSITIVE_INFINITY;
|
|
7217
|
+
let i = 0;
|
|
7218
|
+
let httpErrorsCount = 0;
|
|
7219
|
+
while (true) {
|
|
7220
|
+
await UtilsTerminal.waitMilliseconds(poolingInterval);
|
|
7221
|
+
try {
|
|
7222
|
+
const resp = await taonRequest({
|
|
7223
|
+
reqIndexNum: i,
|
|
7224
|
+
httpErrorsCount,
|
|
7225
|
+
});
|
|
7226
|
+
if (options.statusCheck && options.statusCheck(resp)) {
|
|
7227
|
+
return;
|
|
7228
|
+
}
|
|
7229
|
+
}
|
|
7230
|
+
catch (error) {
|
|
7231
|
+
httpErrorsCount++;
|
|
7232
|
+
if (options.loopRequestsOnBackendError) {
|
|
7233
|
+
const isProperTaonError = error instanceof HttpResponseError &&
|
|
7234
|
+
error.body.json[CoreModels.TaonHttpErrorCustomProp];
|
|
7235
|
+
const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
|
|
7236
|
+
const isUnknownError = !(error instanceof HttpResponseError);
|
|
7237
|
+
const resBool = await options.loopRequestsOnBackendError({
|
|
7238
|
+
taonError: isProperTaonError ? error : void 0,
|
|
7239
|
+
unknownHttpError: isHttpError ? error : void 0,
|
|
7240
|
+
unknownError: isUnknownError ? error : void 0,
|
|
7241
|
+
reqIndexNum: i,
|
|
7242
|
+
httpErrorsCount,
|
|
7243
|
+
});
|
|
7244
|
+
if (resBool) {
|
|
7245
|
+
i++;
|
|
7246
|
+
continue;
|
|
7247
|
+
}
|
|
7248
|
+
else {
|
|
7249
|
+
return;
|
|
7250
|
+
}
|
|
7251
|
+
}
|
|
7252
|
+
if (httpErrorsCount >
|
|
7253
|
+
(options.allowedHttpErrors || Number.POSITIVE_INFINITY)) {
|
|
7254
|
+
throw new Error(`Too many http errors (${httpErrorsCount}) for "${options.actionName}".`);
|
|
7255
|
+
}
|
|
7256
|
+
}
|
|
7257
|
+
if (i++ > maxTries) {
|
|
7258
|
+
throw new Error(`Timeout waiting for "${options.actionName}" to be finished. Waited for ${maxTries} seconds`);
|
|
7259
|
+
}
|
|
7260
|
+
}
|
|
7472
7261
|
}
|
|
7262
|
+
};
|
|
7263
|
+
__decorate([
|
|
7264
|
+
POST({
|
|
7265
|
+
overrideContentType: 'multipart/form-data',
|
|
7266
|
+
middlewares: ({ parentMiddlewares }) => ({
|
|
7267
|
+
...parentMiddlewares,
|
|
7268
|
+
TaonBaseFileUploadMiddleware,
|
|
7269
|
+
}),
|
|
7270
|
+
}),
|
|
7271
|
+
__param(0, Body()),
|
|
7272
|
+
__param(1, Query()),
|
|
7273
|
+
__metadata("design:type", Function),
|
|
7274
|
+
__metadata("design:paramtypes", [FormData, Object]),
|
|
7275
|
+
__metadata("design:returntype", Object)
|
|
7276
|
+
], TaonBaseController.prototype, "uploadFormDataToServer", null);
|
|
7277
|
+
TaonBaseController = __decorate([
|
|
7278
|
+
TaonController({
|
|
7279
|
+
className: 'TaonBaseController',
|
|
7280
|
+
})
|
|
7281
|
+
], TaonBaseController);
|
|
7282
|
+
|
|
7283
|
+
//#endregion
|
|
7284
|
+
/**
|
|
7285
|
+
* Please override property entityClassFn with entity class.
|
|
7286
|
+
*/
|
|
7287
|
+
let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseController {
|
|
7473
7288
|
//#endregion
|
|
7474
|
-
//#region
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7289
|
+
//#region init
|
|
7290
|
+
async _() {
|
|
7291
|
+
if (!_.isFunction(this.entityClassResolveFn)) {
|
|
7292
|
+
Helpers.warn(`Skipping initing CRUD controller ${ClassHelpers.getName(this)} because entityClassResolveFn is not provided.`);
|
|
7293
|
+
return;
|
|
7294
|
+
}
|
|
7295
|
+
let entityClassFn = this.entityClassResolveFn();
|
|
7296
|
+
this.db = this.injectRepo(entityClassFn);
|
|
7297
|
+
if (entityClassFn) {
|
|
7298
|
+
const configEntity = Reflect.getMetadata(Symbols.metadata.options.entity, ClassHelpers.getClassFnFromObject(this));
|
|
7299
|
+
if (configEntity?.createTable === false) {
|
|
7300
|
+
Helpers.warn(`Table for entity ${ClassHelpers.getName(entityClassFn)} will not be created. Crud will not work properly.`);
|
|
7301
|
+
}
|
|
7302
|
+
}
|
|
7303
|
+
else {
|
|
7304
|
+
Helpers.error(`Entity class not provided for controller ${ClassHelpers.getName(this)}.
|
|
7305
|
+
|
|
7306
|
+
Please provide entity as class property entityClassFn:
|
|
7307
|
+
|
|
7308
|
+
class ${ClassHelpers.getName(this)} extends TaonBaseCrudController<Entity> {
|
|
7309
|
+
// ...
|
|
7310
|
+
entityClassResolveFn = ()=> MyEntityClass;
|
|
7311
|
+
// ...
|
|
7312
|
+
}
|
|
7313
|
+
|
|
7314
|
+
`);
|
|
7315
|
+
}
|
|
7316
|
+
await super._();
|
|
7481
7317
|
}
|
|
7482
7318
|
//#endregion
|
|
7483
|
-
//#region
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7319
|
+
//#region bufferd changes
|
|
7320
|
+
bufforedChanges(id, property, alreadyLength) {
|
|
7321
|
+
/* */
|
|
7322
|
+
/* */
|
|
7323
|
+
/* */
|
|
7324
|
+
/* */
|
|
7325
|
+
/* */
|
|
7326
|
+
/* */
|
|
7327
|
+
/* */
|
|
7328
|
+
/* */
|
|
7329
|
+
/* */
|
|
7330
|
+
/* */
|
|
7331
|
+
/* */
|
|
7332
|
+
/* */
|
|
7333
|
+
/* */
|
|
7334
|
+
/* */
|
|
7335
|
+
/* */
|
|
7336
|
+
return (void 0);
|
|
7490
7337
|
}
|
|
7491
7338
|
//#endregion
|
|
7492
|
-
//#region
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7339
|
+
//#region pagintation
|
|
7340
|
+
pagination(pageNumber = 1, pageSize = 10, search = '') {
|
|
7341
|
+
/* */
|
|
7342
|
+
/* */
|
|
7343
|
+
/* */
|
|
7344
|
+
/* */
|
|
7345
|
+
/* */
|
|
7346
|
+
/* */
|
|
7347
|
+
/* */
|
|
7348
|
+
/* */
|
|
7349
|
+
/* */
|
|
7350
|
+
/* */
|
|
7351
|
+
/* */
|
|
7352
|
+
/* */
|
|
7353
|
+
/* */
|
|
7354
|
+
/* */
|
|
7355
|
+
/* */
|
|
7356
|
+
/* */
|
|
7357
|
+
/* */
|
|
7358
|
+
/* */
|
|
7359
|
+
/* */
|
|
7360
|
+
/* */
|
|
7361
|
+
/* */
|
|
7362
|
+
/* */
|
|
7363
|
+
/* */
|
|
7364
|
+
/* */
|
|
7365
|
+
/* */
|
|
7366
|
+
/* */
|
|
7367
|
+
/* */
|
|
7368
|
+
/* */
|
|
7369
|
+
/* */
|
|
7370
|
+
/* */
|
|
7371
|
+
/* */
|
|
7372
|
+
/* */
|
|
7373
|
+
/* */
|
|
7374
|
+
/* */
|
|
7375
|
+
/* */
|
|
7376
|
+
/* */
|
|
7377
|
+
/* */
|
|
7378
|
+
/* */
|
|
7379
|
+
return (void 0);
|
|
7501
7380
|
}
|
|
7502
7381
|
//#endregion
|
|
7503
|
-
//#region
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7382
|
+
//#region get all
|
|
7383
|
+
getAll() {
|
|
7384
|
+
/* */
|
|
7385
|
+
/* */
|
|
7386
|
+
/* */
|
|
7387
|
+
/* */
|
|
7388
|
+
/* */
|
|
7389
|
+
/* */
|
|
7390
|
+
/* */
|
|
7391
|
+
/* */
|
|
7392
|
+
/* */
|
|
7393
|
+
return (void 0);
|
|
7509
7394
|
}
|
|
7510
7395
|
//#endregion
|
|
7511
|
-
//#region
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7396
|
+
//#region get by id
|
|
7397
|
+
getBy(id) {
|
|
7398
|
+
/* */
|
|
7399
|
+
/* */
|
|
7400
|
+
/* */
|
|
7401
|
+
/* */
|
|
7402
|
+
/* */
|
|
7403
|
+
return (void 0);
|
|
7517
7404
|
}
|
|
7518
7405
|
//#endregion
|
|
7519
|
-
//#region
|
|
7520
|
-
|
|
7521
|
-
* @deprecated use findAndCount instead
|
|
7522
|
-
*/
|
|
7523
|
-
async getAll() {
|
|
7406
|
+
//#region update by id
|
|
7407
|
+
updateById(id, item) {
|
|
7524
7408
|
/* */
|
|
7525
7409
|
/* */
|
|
7526
7410
|
/* */
|
|
7527
7411
|
/* */
|
|
7528
7412
|
/* */
|
|
7413
|
+
/* */
|
|
7414
|
+
return (void 0);
|
|
7415
|
+
}
|
|
7416
|
+
//#endregion
|
|
7417
|
+
//#region patch by id
|
|
7418
|
+
patchById(id, item) {
|
|
7529
7419
|
/* */
|
|
7530
7420
|
/* */
|
|
7531
7421
|
/* */
|
|
@@ -7535,8 +7425,10 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
7535
7425
|
return (void 0);
|
|
7536
7426
|
}
|
|
7537
7427
|
//#endregion
|
|
7538
|
-
//#region
|
|
7539
|
-
|
|
7428
|
+
//#region bulk update
|
|
7429
|
+
bulkUpdate(items) {
|
|
7430
|
+
/* */
|
|
7431
|
+
/* */
|
|
7540
7432
|
/* */
|
|
7541
7433
|
/* */
|
|
7542
7434
|
/* */
|
|
@@ -7545,20 +7437,19 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
7545
7437
|
/* */
|
|
7546
7438
|
return (void 0);
|
|
7547
7439
|
}
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
constructor() {
|
|
7558
|
-
super(...arguments);
|
|
7559
|
-
this.entityClassResolveFn = () => TAON_GLOBAL_STATE;
|
|
7440
|
+
//#endregion
|
|
7441
|
+
//#region delete by id
|
|
7442
|
+
deleteById(id) {
|
|
7443
|
+
/* */
|
|
7444
|
+
/* */
|
|
7445
|
+
/* */
|
|
7446
|
+
/* */
|
|
7447
|
+
/* */
|
|
7448
|
+
return (void 0);
|
|
7560
7449
|
}
|
|
7561
|
-
|
|
7450
|
+
//#endregion
|
|
7451
|
+
//#region bulk delete
|
|
7452
|
+
bulkDelete(ids) {
|
|
7562
7453
|
/* */
|
|
7563
7454
|
/* */
|
|
7564
7455
|
/* */
|
|
@@ -7566,9 +7457,18 @@ let TaonGlobalStateRepository = class TaonGlobalStateRepository extends TaonBase
|
|
|
7566
7457
|
/* */
|
|
7567
7458
|
return (void 0);
|
|
7568
7459
|
}
|
|
7569
|
-
|
|
7460
|
+
//#endregion
|
|
7461
|
+
//#region bulk delete
|
|
7462
|
+
clearTable() {
|
|
7570
7463
|
/* */
|
|
7571
7464
|
/* */
|
|
7465
|
+
/* */
|
|
7466
|
+
/* */
|
|
7467
|
+
return (void 0);
|
|
7468
|
+
}
|
|
7469
|
+
//#endregion
|
|
7470
|
+
//#region create
|
|
7471
|
+
save(item) {
|
|
7572
7472
|
/* */
|
|
7573
7473
|
/* */
|
|
7574
7474
|
/* */
|
|
@@ -7576,8 +7476,9 @@ let TaonGlobalStateRepository = class TaonGlobalStateRepository extends TaonBase
|
|
|
7576
7476
|
/* */
|
|
7577
7477
|
return (void 0);
|
|
7578
7478
|
}
|
|
7579
|
-
|
|
7580
|
-
|
|
7479
|
+
//#endregion
|
|
7480
|
+
//#region bulk create
|
|
7481
|
+
bulkCreate(items) {
|
|
7581
7482
|
/* */
|
|
7582
7483
|
/* */
|
|
7583
7484
|
/* */
|
|
@@ -7586,52 +7487,115 @@ let TaonGlobalStateRepository = class TaonGlobalStateRepository extends TaonBase
|
|
|
7586
7487
|
return (void 0);
|
|
7587
7488
|
}
|
|
7588
7489
|
};
|
|
7589
|
-
TaonGlobalStateRepository = __decorate([
|
|
7590
|
-
TaonRepository({
|
|
7591
|
-
className: 'TaonGlobalStateRepository',
|
|
7592
|
-
})
|
|
7593
|
-
], TaonGlobalStateRepository);
|
|
7594
|
-
|
|
7595
|
-
//#region imports
|
|
7596
|
-
//#endregion
|
|
7597
|
-
let TaonGlobalStateController = class TaonGlobalStateController extends TaonBaseCrudController {
|
|
7598
|
-
constructor() {
|
|
7599
|
-
super(...arguments);
|
|
7600
|
-
this.entityClassResolveFn = () => TAON_GLOBAL_STATE;
|
|
7601
|
-
this.taonGlobalStateRepository = this.injectCustomRepo(TaonGlobalStateRepository);
|
|
7602
|
-
}
|
|
7603
|
-
getStatus() {
|
|
7604
|
-
return async () => {
|
|
7605
|
-
/* */
|
|
7606
|
-
/* */
|
|
7607
|
-
/* */
|
|
7608
|
-
return (void 0);
|
|
7609
|
-
};
|
|
7610
|
-
}
|
|
7611
|
-
setDraining(secondsBeforeReadonly = 0) {
|
|
7612
|
-
return async () => {
|
|
7613
|
-
await this.taonGlobalStateRepository.setDraining(secondsBeforeReadonly);
|
|
7614
|
-
};
|
|
7615
|
-
}
|
|
7616
|
-
};
|
|
7617
7490
|
__decorate([
|
|
7618
7491
|
GET(),
|
|
7492
|
+
__param(0, Query(`id`)),
|
|
7493
|
+
__param(1, Query(`property`)),
|
|
7494
|
+
__param(2, Query('alreadyLength')),
|
|
7495
|
+
__metadata("design:type", Function),
|
|
7496
|
+
__metadata("design:paramtypes", [Object, String, Number]),
|
|
7497
|
+
__metadata("design:returntype", Object)
|
|
7498
|
+
], TaonBaseCrudController.prototype, "bufforedChanges", null);
|
|
7499
|
+
__decorate([
|
|
7500
|
+
GET(),
|
|
7501
|
+
__param(0, Query('pageNumber')),
|
|
7502
|
+
__param(1, Query('pageSize')),
|
|
7503
|
+
__param(2, Query('search')),
|
|
7504
|
+
__metadata("design:type", Function),
|
|
7505
|
+
__metadata("design:paramtypes", [Number, Number, String]),
|
|
7506
|
+
__metadata("design:returntype", Object)
|
|
7507
|
+
], TaonBaseCrudController.prototype, "pagination", null);
|
|
7508
|
+
__decorate([
|
|
7509
|
+
GET(),
|
|
7510
|
+
__metadata("design:type", Function),
|
|
7511
|
+
__metadata("design:paramtypes", []),
|
|
7512
|
+
__metadata("design:returntype", Object)
|
|
7513
|
+
], TaonBaseCrudController.prototype, "getAll", null);
|
|
7514
|
+
__decorate([
|
|
7515
|
+
GET(),
|
|
7516
|
+
__param(0, Query(`id`)),
|
|
7517
|
+
__metadata("design:type", Function),
|
|
7518
|
+
__metadata("design:paramtypes", [Object]),
|
|
7519
|
+
__metadata("design:returntype", Object)
|
|
7520
|
+
], TaonBaseCrudController.prototype, "getBy", null);
|
|
7521
|
+
__decorate([
|
|
7522
|
+
PUT(),
|
|
7523
|
+
__param(0, Query(`id`)),
|
|
7524
|
+
__param(1, Body()),
|
|
7525
|
+
__metadata("design:type", Function),
|
|
7526
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
7527
|
+
__metadata("design:returntype", Object)
|
|
7528
|
+
], TaonBaseCrudController.prototype, "updateById", null);
|
|
7529
|
+
__decorate([
|
|
7530
|
+
PATCH(),
|
|
7531
|
+
__param(0, Query(`id`)),
|
|
7532
|
+
__param(1, Body()),
|
|
7533
|
+
__metadata("design:type", Function),
|
|
7534
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
7535
|
+
__metadata("design:returntype", Object)
|
|
7536
|
+
], TaonBaseCrudController.prototype, "patchById", null);
|
|
7537
|
+
__decorate([
|
|
7538
|
+
PUT(),
|
|
7539
|
+
__param(0, Body()),
|
|
7540
|
+
__metadata("design:type", Function),
|
|
7541
|
+
__metadata("design:paramtypes", [Array]),
|
|
7542
|
+
__metadata("design:returntype", Object)
|
|
7543
|
+
], TaonBaseCrudController.prototype, "bulkUpdate", null);
|
|
7544
|
+
__decorate([
|
|
7545
|
+
DELETE(),
|
|
7546
|
+
__param(0, Query(`id`)),
|
|
7547
|
+
__metadata("design:type", Function),
|
|
7548
|
+
__metadata("design:paramtypes", [Object]),
|
|
7549
|
+
__metadata("design:returntype", Object)
|
|
7550
|
+
], TaonBaseCrudController.prototype, "deleteById", null);
|
|
7551
|
+
__decorate([
|
|
7552
|
+
DELETE(),
|
|
7553
|
+
__param(0, Query(`ids`)),
|
|
7554
|
+
__metadata("design:type", Function),
|
|
7555
|
+
__metadata("design:paramtypes", [Array]),
|
|
7556
|
+
__metadata("design:returntype", Object)
|
|
7557
|
+
], TaonBaseCrudController.prototype, "bulkDelete", null);
|
|
7558
|
+
__decorate([
|
|
7559
|
+
DELETE(),
|
|
7619
7560
|
__metadata("design:type", Function),
|
|
7620
7561
|
__metadata("design:paramtypes", []),
|
|
7621
7562
|
__metadata("design:returntype", Object)
|
|
7622
|
-
],
|
|
7563
|
+
], TaonBaseCrudController.prototype, "clearTable", null);
|
|
7623
7564
|
__decorate([
|
|
7624
7565
|
POST(),
|
|
7625
|
-
__param(0,
|
|
7566
|
+
__param(0, Body()),
|
|
7626
7567
|
__metadata("design:type", Function),
|
|
7627
7568
|
__metadata("design:paramtypes", [Object]),
|
|
7628
7569
|
__metadata("design:returntype", Object)
|
|
7629
|
-
],
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7570
|
+
], TaonBaseCrudController.prototype, "save", null);
|
|
7571
|
+
__decorate([
|
|
7572
|
+
POST(),
|
|
7573
|
+
__param(0, Body()),
|
|
7574
|
+
__metadata("design:type", Function),
|
|
7575
|
+
__metadata("design:paramtypes", [Object]),
|
|
7576
|
+
__metadata("design:returntype", Object)
|
|
7577
|
+
], TaonBaseCrudController.prototype, "bulkCreate", null);
|
|
7578
|
+
TaonBaseCrudController = __decorate([
|
|
7579
|
+
TaonController({ className: 'TaonBaseCrudController' })
|
|
7580
|
+
], TaonBaseCrudController);
|
|
7581
|
+
|
|
7582
|
+
class TaonBaseMigration extends TaonBaseInjector {
|
|
7583
|
+
/**
|
|
7584
|
+
* by default is READY to run
|
|
7585
|
+
*/
|
|
7586
|
+
isReadyToRun() {
|
|
7587
|
+
return true;
|
|
7588
|
+
}
|
|
7589
|
+
getDescription() {
|
|
7590
|
+
return _.startCase(ClassHelpers.getName(this));
|
|
7591
|
+
}
|
|
7592
|
+
async up(queryRunner) {
|
|
7593
|
+
console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers.getName(this)}"`);
|
|
7594
|
+
}
|
|
7595
|
+
async down(queryRunner) {
|
|
7596
|
+
console.log(`[TaonBaseMigration] Running migration DOWN "${ClassHelpers.getName(this)}"`);
|
|
7597
|
+
}
|
|
7598
|
+
}
|
|
7635
7599
|
|
|
7636
7600
|
/**
|
|
7637
7601
|
* TODO
|
|
@@ -7641,39 +7605,6 @@ TaonGlobalStateController = __decorate([
|
|
|
7641
7605
|
class TaonBaseProvider extends TaonBaseInjector {
|
|
7642
7606
|
}
|
|
7643
7607
|
|
|
7644
|
-
/**
|
|
7645
|
-
* Provider decorator
|
|
7646
|
-
*/
|
|
7647
|
-
function TaonProvider(options) {
|
|
7648
|
-
return function (constructor) {
|
|
7649
|
-
Reflect.defineMetadata(Symbols.metadata.options.provider, options, constructor);
|
|
7650
|
-
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
7651
|
-
ClassHelpers.setName(constructor, options?.className || constructor.name);
|
|
7652
|
-
};
|
|
7653
|
-
}
|
|
7654
|
-
class TaonProviderOptions extends DecoratorAbstractOpt {
|
|
7655
|
-
}
|
|
7656
|
-
|
|
7657
|
-
//#region imports
|
|
7658
|
-
//#endregion
|
|
7659
|
-
let TaonGlobalStateProvider = class TaonGlobalStateProvider extends TaonBaseProvider {
|
|
7660
|
-
};
|
|
7661
|
-
TaonGlobalStateProvider = __decorate([
|
|
7662
|
-
TaonProvider({
|
|
7663
|
-
className: 'TaonGlobalStateProvider',
|
|
7664
|
-
})
|
|
7665
|
-
], TaonGlobalStateProvider);
|
|
7666
|
-
|
|
7667
|
-
//#region imports
|
|
7668
|
-
//#endregion
|
|
7669
|
-
let TaonGlobalStateMiddleware = class TaonGlobalStateMiddleware extends TaonBaseMiddleware {
|
|
7670
|
-
};
|
|
7671
|
-
TaonGlobalStateMiddleware = __decorate([
|
|
7672
|
-
TaonMiddleware({
|
|
7673
|
-
className: 'TaonGlobalStateMiddleware',
|
|
7674
|
-
})
|
|
7675
|
-
], TaonGlobalStateMiddleware);
|
|
7676
|
-
|
|
7677
7608
|
/**
|
|
7678
7609
|
* Subscriber decorator
|
|
7679
7610
|
*/
|
|
@@ -7830,75 +7761,6 @@ TaonBaseSubscriberForEntity = __decorate([
|
|
|
7830
7761
|
})
|
|
7831
7762
|
], TaonBaseSubscriberForEntity);
|
|
7832
7763
|
|
|
7833
|
-
//#region imports
|
|
7834
|
-
//#endregion
|
|
7835
|
-
let TaonGlobalStateSubscriber = class TaonGlobalStateSubscriber extends TaonBaseSubscriberForEntity {
|
|
7836
|
-
constructor() {
|
|
7837
|
-
super(...arguments);
|
|
7838
|
-
this.taonGlobalStateProvider = this.injectProvider(TaonGlobalStateProvider);
|
|
7839
|
-
}
|
|
7840
|
-
listenTo() {
|
|
7841
|
-
return TAON_GLOBAL_STATE;
|
|
7842
|
-
}
|
|
7843
|
-
};
|
|
7844
|
-
TaonGlobalStateSubscriber = __decorate([
|
|
7845
|
-
TaonSubscriber({
|
|
7846
|
-
className: 'TaonGlobalStateSubscriber',
|
|
7847
|
-
// allowedEvents: ['afterUpdate'],
|
|
7848
|
-
})
|
|
7849
|
-
], TaonGlobalStateSubscriber);
|
|
7850
|
-
|
|
7851
|
-
//#region imports
|
|
7852
|
-
//#endregion
|
|
7853
|
-
const TaonGlobalStateContext = createContext(() => ({
|
|
7854
|
-
contextName: 'TaonGlobalStateContext',
|
|
7855
|
-
abstract: true,
|
|
7856
|
-
entities: { TAON_GLOBAL_STATE },
|
|
7857
|
-
controllers: { TaonGlobalStateController },
|
|
7858
|
-
repositories: { TaonGlobalStateRepository },
|
|
7859
|
-
providers: { TaonGlobalStateProvider },
|
|
7860
|
-
middlewares: { TaonGlobalStateMiddleware },
|
|
7861
|
-
subscribers: { TaonGlobalStateSubscriber },
|
|
7862
|
-
}));
|
|
7863
|
-
|
|
7864
|
-
const TaonBaseContext = createContext(() => ({
|
|
7865
|
-
contextName: 'TaonBaseContext',
|
|
7866
|
-
abstract: true,
|
|
7867
|
-
contexts: {
|
|
7868
|
-
TaonGlobalStateContext,
|
|
7869
|
-
},
|
|
7870
|
-
middlewares: {
|
|
7871
|
-
TaonBaseFileUploadMiddleware,
|
|
7872
|
-
},
|
|
7873
|
-
repositories: {
|
|
7874
|
-
// @ts-ignore
|
|
7875
|
-
TaonBaseRepository,
|
|
7876
|
-
},
|
|
7877
|
-
}));
|
|
7878
|
-
|
|
7879
|
-
var baseContext = /*#__PURE__*/Object.freeze({
|
|
7880
|
-
__proto__: null,
|
|
7881
|
-
TaonBaseContext: TaonBaseContext
|
|
7882
|
-
});
|
|
7883
|
-
|
|
7884
|
-
class TaonBaseMigration extends TaonBaseInjector {
|
|
7885
|
-
/**
|
|
7886
|
-
* by default is READY to run
|
|
7887
|
-
*/
|
|
7888
|
-
isReadyToRun() {
|
|
7889
|
-
return true;
|
|
7890
|
-
}
|
|
7891
|
-
getDescription() {
|
|
7892
|
-
return _.startCase(ClassHelpers.getName(this));
|
|
7893
|
-
}
|
|
7894
|
-
async up(queryRunner) {
|
|
7895
|
-
console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers.getName(this)}"`);
|
|
7896
|
-
}
|
|
7897
|
-
async down(queryRunner) {
|
|
7898
|
-
console.log(`[TaonBaseMigration] Running migration DOWN "${ClassHelpers.getName(this)}"`);
|
|
7899
|
-
}
|
|
7900
|
-
}
|
|
7901
|
-
|
|
7902
7764
|
//#region models / method config
|
|
7903
7765
|
/**
|
|
7904
7766
|
* @link './decorators/http/http-methods-decorators.ts' TaonHttpDecoratorOptions
|
|
@@ -8355,6 +8217,38 @@ const SimpleJsonColumn = () => Column({ type: 'simple-json', nullable: true });
|
|
|
8355
8217
|
const BooleanColumn = (defaultValue) => Column({ type: 'boolean', nullable: true, default: defaultValue });
|
|
8356
8218
|
const DateTimeColumn = (defaultValue = null) => Column({ type: 'datetime', nullable: true, default: defaultValue });
|
|
8357
8219
|
|
|
8220
|
+
/**
|
|
8221
|
+
* Entity decorator
|
|
8222
|
+
*/
|
|
8223
|
+
function TaonEntity(options) {
|
|
8224
|
+
return function (constructor) {
|
|
8225
|
+
options = options || {};
|
|
8226
|
+
options.uniqueKeyProp = options.uniqueKeyProp || 'id';
|
|
8227
|
+
if (!options.className) {
|
|
8228
|
+
const nameForClass = constructor?.name || 'AnyClass';
|
|
8229
|
+
throw `Please define 'classname' property inside decorator of class '${nameForClass}':
|
|
8230
|
+
|
|
8231
|
+
@TaonEntity({
|
|
8232
|
+
className: '${nameForClass}'
|
|
8233
|
+
})
|
|
8234
|
+
class ${constructor?.name} {
|
|
8235
|
+
//...
|
|
8236
|
+
|
|
8237
|
+
`;
|
|
8238
|
+
}
|
|
8239
|
+
ClassHelpers.setName(constructor, options?.className);
|
|
8240
|
+
DefaultMapping(options?.defaultModelMapping)(constructor);
|
|
8241
|
+
DefaultModel(options.defaultModelMapping)(constructor);
|
|
8242
|
+
Reflect.defineMetadata(Symbols.metadata.options.entity, options, constructor);
|
|
8243
|
+
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
8244
|
+
/* */
|
|
8245
|
+
/* */
|
|
8246
|
+
CLASS.setName(constructor, options?.className); // TODO QUICK_FIX for ng2-rest
|
|
8247
|
+
};
|
|
8248
|
+
}
|
|
8249
|
+
class TaonEntityOptions extends DecoratorAbstractOpt {
|
|
8250
|
+
}
|
|
8251
|
+
|
|
8358
8252
|
/**
|
|
8359
8253
|
* Migration decorator
|
|
8360
8254
|
*/
|
|
@@ -8368,6 +8262,19 @@ function TaonMigration(options) {
|
|
|
8368
8262
|
class TaonMigrationOptions extends DecoratorAbstractOpt {
|
|
8369
8263
|
}
|
|
8370
8264
|
|
|
8265
|
+
/**
|
|
8266
|
+
* Provider decorator
|
|
8267
|
+
*/
|
|
8268
|
+
function TaonProvider(options) {
|
|
8269
|
+
return function (constructor) {
|
|
8270
|
+
Reflect.defineMetadata(Symbols.metadata.options.provider, options, constructor);
|
|
8271
|
+
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
8272
|
+
ClassHelpers.setName(constructor, options?.className || constructor.name);
|
|
8273
|
+
};
|
|
8274
|
+
}
|
|
8275
|
+
class TaonProviderOptions extends DecoratorAbstractOpt {
|
|
8276
|
+
}
|
|
8277
|
+
|
|
8371
8278
|
// TODO export all things
|
|
8372
8279
|
var Taon;
|
|
8373
8280
|
(function (Taon) {
|