taon 19.0.66 → 19.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +160 -160
- package/bin/start.js +281 -281
- package/bin/taon +6 -6
- package/bin/taon-debug +5 -5
- package/bin/taon-debug-brk +5 -5
- package/browser/README.md +24 -24
- package/browser/fesm2022/taon.mjs +272 -68
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-class.d.ts +8 -1
- package/browser/lib/base-classes/base-controller.d.ts +56 -4
- package/browser/lib/base-classes/base-crud-controller.d.ts +5 -4
- package/browser/lib/base-classes/base-repository.d.ts +3 -0
- package/browser/lib/config/method-config.d.ts +1 -0
- package/browser/lib/decorators/http/http-decorators.d.ts +2 -1
- package/browser/lib/decorators/http/http-methods-decorators.d.ts +35 -4
- package/browser/lib/endpoint-context.d.ts +3 -0
- package/browser/lib/get-response-value.d.ts +1 -1
- package/browser/lib/helpers/taon-helpers.d.ts +1 -0
- package/browser/lib/index.d.ts +4 -0
- package/browser/lib/models.d.ts +4 -10
- package/browser/lib/realtime/realtime-client.d.ts +18 -14
- package/browser/lib/realtime/realtime-server.d.ts +28 -3
- package/browser/lib/realtime/realtime.models.d.ts +15 -2
- package/browser/package.json +1 -1
- package/icon-menu-taon.svg +15 -15
- package/lib/base-classes/base-class.d.ts +8 -1
- package/lib/base-classes/base-class.js +20 -2
- package/lib/base-classes/base-class.js.map +1 -1
- package/lib/base-classes/base-controller.d.ts +57 -5
- package/lib/base-classes/base-controller.js +83 -12
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/base-classes/base-crud-controller.d.ts +5 -4
- package/lib/base-classes/base-crud-controller.js +16 -4
- package/lib/base-classes/base-crud-controller.js.map +1 -1
- package/lib/base-classes/base-repository.d.ts +3 -0
- package/lib/base-classes/base-repository.js +3 -0
- package/lib/base-classes/base-repository.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/config/method-config.d.ts +1 -0
- package/lib/config/method-config.js.map +1 -1
- package/lib/decorators/http/http-decorators.d.ts +2 -1
- package/lib/decorators/http/http-decorators.js +2 -1
- package/lib/decorators/http/http-decorators.js.map +1 -1
- package/lib/decorators/http/http-methods-decorators.d.ts +35 -4
- package/lib/decorators/http/http-methods-decorators.js +34 -1
- package/lib/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib/endpoint-context.d.ts +3 -0
- package/lib/endpoint-context.js +152 -122
- package/lib/endpoint-context.js.map +1 -1
- package/lib/get-response-value.d.ts +1 -1
- package/lib/get-response-value.js +0 -4
- package/lib/get-response-value.js.map +1 -1
- package/lib/helpers/taon-helpers.d.ts +1 -0
- package/lib/helpers/taon-helpers.js +6 -0
- package/lib/helpers/taon-helpers.js.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.js +8 -2
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +4 -10
- package/lib/models.js +5 -23
- package/lib/models.js.map +1 -1
- package/lib/realtime/realtime-client.d.ts +18 -14
- package/lib/realtime/realtime-client.js +33 -25
- package/lib/realtime/realtime-client.js.map +1 -1
- package/lib/realtime/realtime-server.d.ts +28 -3
- package/lib/realtime/realtime-server.js +28 -2
- package/lib/realtime/realtime-server.js.map +1 -1
- package/lib/realtime/realtime.models.d.ts +15 -2
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/package.json +1 -1
- package/websql/README.md +24 -24
- package/websql/fesm2022/taon.mjs +273 -70
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-class.d.ts +8 -1
- package/websql/lib/base-classes/base-controller.d.ts +56 -4
- package/websql/lib/base-classes/base-crud-controller.d.ts +5 -4
- package/websql/lib/base-classes/base-repository.d.ts +3 -0
- package/websql/lib/config/method-config.d.ts +1 -0
- package/websql/lib/decorators/http/http-decorators.d.ts +2 -1
- package/websql/lib/decorators/http/http-methods-decorators.d.ts +35 -4
- package/websql/lib/endpoint-context.d.ts +3 -0
- package/websql/lib/get-response-value.d.ts +1 -1
- package/websql/lib/helpers/taon-helpers.d.ts +1 -0
- package/websql/lib/index.d.ts +4 -0
- package/websql/lib/models.d.ts +4 -10
- package/websql/lib/realtime/realtime-client.d.ts +18 -14
- package/websql/lib/realtime/realtime-server.d.ts +28 -3
- package/websql/lib/realtime/realtime.models.d.ts +15 -2
- package/websql/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import * as coreHelpers from 'tnp-core/browser';
|
|
3
|
-
import { _, Utils, Helpers, UtilsOs, CoreModels, crossPlatformPath } from 'tnp-core/browser';
|
|
3
|
+
import { _, Utils, Helpers, UtilsOs, CoreModels, crossPlatformPath, UtilsTerminal } from 'tnp-core/browser';
|
|
4
4
|
import { __decorate, __metadata, __param } from 'tslib';
|
|
5
5
|
import { SYMBOL, CLASS } from 'typescript-class-helpers/browser';
|
|
6
6
|
import { OrignalClassKey, Table } from 'taon-typeorm/browser';
|
|
@@ -9,7 +9,7 @@ import * as i0 from '@angular/core';
|
|
|
9
9
|
import { InjectionToken, inject as inject$1, Injectable } from '@angular/core';
|
|
10
10
|
import axios from 'axios';
|
|
11
11
|
import { JSON10 } from 'json10/browser';
|
|
12
|
-
import { Models as Models$1, Resource, RestHeaders, Mapping } from 'ng2-rest/browser';
|
|
12
|
+
import { RestResponseWrapper, Models as Models$1, Resource, RestHeaders, Mapping, HttpResponseError } from 'ng2-rest/browser';
|
|
13
13
|
import { Observable, from, Subject } from 'rxjs';
|
|
14
14
|
import { config } from 'tnp-config/browser';
|
|
15
15
|
import * as JSON5 from 'json5';
|
|
@@ -488,9 +488,26 @@ class BaseClass {
|
|
|
488
488
|
async _() { }
|
|
489
489
|
//#endregion
|
|
490
490
|
//#region clone
|
|
491
|
-
|
|
491
|
+
/**
|
|
492
|
+
*
|
|
493
|
+
* @param overrideObjOrFn if object is provided it will override values in cloned object,
|
|
494
|
+
* if function is provided it will be called with old cloned values and should return
|
|
495
|
+
* object with values to override
|
|
496
|
+
* @returns cloned instance of the class
|
|
497
|
+
*/
|
|
498
|
+
clone(overrideObjOrFn) {
|
|
499
|
+
if (_.isString(overrideObjOrFn)) {
|
|
500
|
+
console.log(overrideObjOrFn);
|
|
501
|
+
throw new Error('String is not supported as .clone() method argument');
|
|
502
|
+
}
|
|
492
503
|
const classFn = ClassHelpers.getClassFnFromObject(this);
|
|
493
|
-
|
|
504
|
+
if (_.isFunction(overrideObjOrFn)) {
|
|
505
|
+
// console.log('clone with fn');
|
|
506
|
+
const oldValues = (_.cloneDeep(this) || {});
|
|
507
|
+
return cloneObj(overrideObjOrFn(oldValues), classFn);
|
|
508
|
+
}
|
|
509
|
+
// console.log('clone normal');
|
|
510
|
+
return cloneObj(overrideObjOrFn, classFn);
|
|
494
511
|
}
|
|
495
512
|
}
|
|
496
513
|
|
|
@@ -1208,9 +1225,6 @@ const getResponseValue = (response, options) => {
|
|
|
1208
1225
|
/* */
|
|
1209
1226
|
/* */
|
|
1210
1227
|
/* */
|
|
1211
|
-
/* */
|
|
1212
|
-
/* */
|
|
1213
|
-
/* */
|
|
1214
1228
|
return (void 0);
|
|
1215
1229
|
};
|
|
1216
1230
|
|
|
@@ -1231,6 +1245,12 @@ var TaonHelpers;
|
|
|
1231
1245
|
return p && typeof p === 'string' && p.trim() !== '';
|
|
1232
1246
|
};
|
|
1233
1247
|
//#endregion
|
|
1248
|
+
TaonHelpers.firstStringOrElemFromArray = (stringOrArrayOfString) => {
|
|
1249
|
+
if (Array.isArray(stringOrArrayOfString)) {
|
|
1250
|
+
return _.first(stringOrArrayOfString);
|
|
1251
|
+
}
|
|
1252
|
+
return stringOrArrayOfString;
|
|
1253
|
+
};
|
|
1234
1254
|
//#region try transform params
|
|
1235
1255
|
TaonHelpers.tryTransformParam = param => {
|
|
1236
1256
|
if (typeof param === 'string') {
|
|
@@ -1354,6 +1374,9 @@ var TaonHelpers;
|
|
|
1354
1374
|
//#endregion
|
|
1355
1375
|
})(TaonHelpers || (TaonHelpers = {}));
|
|
1356
1376
|
|
|
1377
|
+
// ! TODO make it as a nice way to wrap normal request
|
|
1378
|
+
class TaonRestResponseWrapper extends RestResponseWrapper {
|
|
1379
|
+
}
|
|
1357
1380
|
var Models;
|
|
1358
1381
|
(function (Models) {
|
|
1359
1382
|
//#region models / class types
|
|
@@ -1411,25 +1434,6 @@ var Models;
|
|
|
1411
1434
|
let Http;
|
|
1412
1435
|
(function (Http) {
|
|
1413
1436
|
Http.Rest = Models$1;
|
|
1414
|
-
class Errors {
|
|
1415
|
-
constructor(message, code = 400) {
|
|
1416
|
-
this.message = message;
|
|
1417
|
-
this.code = code;
|
|
1418
|
-
this.toString = () => {
|
|
1419
|
-
return this.message;
|
|
1420
|
-
};
|
|
1421
|
-
}
|
|
1422
|
-
static create(message, code = 400) {
|
|
1423
|
-
return new Errors(message, code);
|
|
1424
|
-
}
|
|
1425
|
-
static entityNotFound(entity) {
|
|
1426
|
-
return Errors.create(`Entity ${ClassHelpers.getName(entity)} not found`);
|
|
1427
|
-
}
|
|
1428
|
-
static custom(message, code = 400) {
|
|
1429
|
-
return Errors.create(message, code);
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
Http.Errors = Errors;
|
|
1433
1437
|
/* */
|
|
1434
1438
|
/* */
|
|
1435
1439
|
/* */
|
|
@@ -1539,6 +1543,14 @@ class RealtimeSubsManager {
|
|
|
1539
1543
|
|
|
1540
1544
|
//#region imports
|
|
1541
1545
|
//#endregion
|
|
1546
|
+
/**
|
|
1547
|
+
* Client for realtime communication
|
|
1548
|
+
* you can listen to:
|
|
1549
|
+
* - entity changes (any property in table changed)
|
|
1550
|
+
* - entity custom property changes (specific property changed)
|
|
1551
|
+
* - entity table changes (new instance added, instance removed)
|
|
1552
|
+
* - custom events
|
|
1553
|
+
*/
|
|
1542
1554
|
class RealtimeClient {
|
|
1543
1555
|
constructor(core) {
|
|
1544
1556
|
this.core = core;
|
|
@@ -1612,20 +1624,32 @@ class RealtimeClient {
|
|
|
1612
1624
|
//#endregion
|
|
1613
1625
|
//#region methods & getters / listen changes entity
|
|
1614
1626
|
/**
|
|
1627
|
+
* Usage:
|
|
1628
|
+
* myContext.realtimeClient.listenChangesEntity(myEntityInstance);
|
|
1629
|
+
*
|
|
1630
|
+
*
|
|
1615
1631
|
* Changes trigger on backend needs to be done manually.. example code:
|
|
1616
1632
|
*
|
|
1617
|
-
*
|
|
1618
|
-
* Context.Realtime.Server.TrigggerEntityChanges(myEntityInstance);
|
|
1633
|
+
* myContext.realtimeServer.triggerEntityChanges(myEntityInstance);
|
|
1619
1634
|
* ...
|
|
1620
1635
|
*/
|
|
1621
|
-
listenChangesEntity(
|
|
1636
|
+
listenChangesEntity(entityClassFnOrObj, options) {
|
|
1622
1637
|
options = options || {};
|
|
1638
|
+
if (_.isObject(entityClassFnOrObj)) {
|
|
1639
|
+
const orgObj = entityClassFnOrObj;
|
|
1640
|
+
entityClassFnOrObj =
|
|
1641
|
+
ClassHelpers.getClassFnFromObject(entityClassFnOrObj);
|
|
1642
|
+
const uniqueKey = ClassHelpers.getUniqueKey(entityClassFnOrObj);
|
|
1643
|
+
if (uniqueKey) {
|
|
1644
|
+
options.idOrUniqValue = orgObj[uniqueKey];
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1623
1647
|
//#region parameters validation
|
|
1624
1648
|
const { property, customEvent } = options;
|
|
1625
|
-
const className = !customEvent && ClassHelpers.getName(
|
|
1649
|
+
const className = !customEvent && ClassHelpers.getName(entityClassFnOrObj);
|
|
1626
1650
|
if (_.isString(property)) {
|
|
1627
1651
|
if (property.trim() === '') {
|
|
1628
|
-
throw new Error(`[Taon][listenChangesEntity..
|
|
1652
|
+
throw new Error(`[Taon][listenChangesEntity.. incorrect property '' for ${className}`);
|
|
1629
1653
|
}
|
|
1630
1654
|
}
|
|
1631
1655
|
//#endregion
|
|
@@ -1650,8 +1674,8 @@ to use socket realtime connection;
|
|
|
1650
1674
|
}
|
|
1651
1675
|
else {
|
|
1652
1676
|
roomName = _.isString(property)
|
|
1653
|
-
? Symbols.REALTIME.ROOM_NAME_UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, className, property, idOrUniqValue)
|
|
1654
|
-
: Symbols.REALTIME.ROOM_NAME_UPDATE_ENTITY(this.core.ctx.contextName, className, idOrUniqValue);
|
|
1677
|
+
? Symbols.REALTIME.ROOM_NAME_UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, className, property, options.idOrUniqValue)
|
|
1678
|
+
: Symbols.REALTIME.ROOM_NAME_UPDATE_ENTITY(this.core.ctx.contextName, className, options.idOrUniqValue);
|
|
1655
1679
|
}
|
|
1656
1680
|
const roomSubOptions = {
|
|
1657
1681
|
core: this.core,
|
|
@@ -1674,32 +1698,20 @@ to use socket realtime connection;
|
|
|
1674
1698
|
}
|
|
1675
1699
|
//#endregion
|
|
1676
1700
|
//#region listen changes entity table
|
|
1701
|
+
/**
|
|
1702
|
+
* Listen changes entity table
|
|
1703
|
+
* Example: for pagination, lists update ...
|
|
1704
|
+
*/
|
|
1677
1705
|
listenChangesEntityTable(entityClassFn) {
|
|
1678
1706
|
const className = ClassHelpers.getName(entityClassFn);
|
|
1679
|
-
return this.listenChangesEntity(entityClassFn,
|
|
1707
|
+
return this.listenChangesEntity(entityClassFn, {
|
|
1680
1708
|
customEvent: Symbols.REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className),
|
|
1681
1709
|
});
|
|
1682
1710
|
}
|
|
1683
1711
|
//#endregion
|
|
1684
|
-
//#region listen change entity object
|
|
1685
|
-
/**
|
|
1686
|
-
* Changes trigger on backend needs to be done manually.. example code:
|
|
1687
|
-
*
|
|
1688
|
-
* ...
|
|
1689
|
-
* Context.Realtime.Server.TrigggerEntityChanges(myEntityInstance);
|
|
1690
|
-
* // or
|
|
1691
|
-
* Context.Realtime.Server.TrigggerEntityPropertyChanges(myEntityInstance,{ property: 'geolocationX' });
|
|
1692
|
-
* ...
|
|
1693
|
-
*/
|
|
1694
|
-
listenChangesEntityObj(entity, options) {
|
|
1695
|
-
const classFn = ClassHelpers.getClassFnFromObject(entity);
|
|
1696
|
-
const uniqueKey = ClassHelpers.getUniqueKey(classFn);
|
|
1697
|
-
return this.listenChangesEntity(classFn, entity[uniqueKey], options);
|
|
1698
|
-
}
|
|
1699
|
-
//#endregion
|
|
1700
1712
|
//#region listen changes custom event
|
|
1701
1713
|
listenChangesCustomEvent(customEvent) {
|
|
1702
|
-
return this.listenChangesEntity(void 0,
|
|
1714
|
+
return this.listenChangesEntity(void 0, {
|
|
1703
1715
|
customEvent,
|
|
1704
1716
|
});
|
|
1705
1717
|
}
|
|
@@ -1725,6 +1737,17 @@ to use socket realtime connection;
|
|
|
1725
1737
|
//#region imports
|
|
1726
1738
|
/* */
|
|
1727
1739
|
//#endregion
|
|
1740
|
+
/**
|
|
1741
|
+
* Server for realtime communication
|
|
1742
|
+
* you can trigger:
|
|
1743
|
+
* - entity changes (any property in table changed)
|
|
1744
|
+
* - entity custom property changes (specific property changed)
|
|
1745
|
+
* - entity table changes (new instance added, instance removed)
|
|
1746
|
+
* - custom events
|
|
1747
|
+
*
|
|
1748
|
+
* and also listen to:
|
|
1749
|
+
* - custom events from yourself
|
|
1750
|
+
*/
|
|
1728
1751
|
class RealtimeServer {
|
|
1729
1752
|
// private jobs = {};
|
|
1730
1753
|
constructor(core) {
|
|
@@ -1972,7 +1995,12 @@ class RealtimeServer {
|
|
|
1972
1995
|
//#endregion
|
|
1973
1996
|
//#region entity changes
|
|
1974
1997
|
//#region methods & getters / trigger entity changes
|
|
1975
|
-
triggerEntityChanges(entityObjOrClass,
|
|
1998
|
+
triggerEntityChanges(entityObjOrClass,
|
|
1999
|
+
/**
|
|
2000
|
+
* value of unique key property of entity instance
|
|
2001
|
+
* (this value is not needed if entityObjOrClass is instance of entity)
|
|
2002
|
+
*/
|
|
2003
|
+
idToTrigger) {
|
|
1976
2004
|
if (this.core.ctx.disabledRealtime) {
|
|
1977
2005
|
const className = ClassHelpers.getName(entityObjOrClass);
|
|
1978
2006
|
console.warn(`[Taon][TriggerEntityChanges] Entity "${className}' is not realtime`);
|
|
@@ -1982,7 +2010,17 @@ class RealtimeServer {
|
|
|
1982
2010
|
}
|
|
1983
2011
|
//#endregion
|
|
1984
2012
|
//#region methods & getters / trigger entity property changes
|
|
1985
|
-
triggerEntityPropertyChanges(entityObjOrClass,
|
|
2013
|
+
triggerEntityPropertyChanges(entityObjOrClass,
|
|
2014
|
+
/**
|
|
2015
|
+
* property name or array of property names that changed
|
|
2016
|
+
* for entity instance
|
|
2017
|
+
*/
|
|
2018
|
+
property,
|
|
2019
|
+
/**
|
|
2020
|
+
* value of unique key property of entity instance
|
|
2021
|
+
* (this value is not needed if entityObjOrClass is instance of entity)
|
|
2022
|
+
*/
|
|
2023
|
+
idToTrigger) {
|
|
1986
2024
|
if (this.core.ctx.disabledRealtime) {
|
|
1987
2025
|
const className = ClassHelpers.getName(entityObjOrClass);
|
|
1988
2026
|
console.warn(`[Taon][TriggerEntityPropertyChanges][property=${property}] Entity "${className}' is not realtime`);
|
|
@@ -2760,6 +2798,12 @@ class EndpointContext {
|
|
|
2760
2798
|
}
|
|
2761
2799
|
return this.config?.logs === true;
|
|
2762
2800
|
}
|
|
2801
|
+
get logRoutes() {
|
|
2802
|
+
if (_.isObject(this.config?.logs)) {
|
|
2803
|
+
return !!this.config.logs.routes;
|
|
2804
|
+
}
|
|
2805
|
+
return this.config?.logs === true;
|
|
2806
|
+
}
|
|
2763
2807
|
get logDb() {
|
|
2764
2808
|
if (_.isObject(this.config?.logs)) {
|
|
2765
2809
|
return !!this.config.logs.db;
|
|
@@ -4255,9 +4299,7 @@ class EndpointContext {
|
|
|
4255
4299
|
//#endregion
|
|
4256
4300
|
//#region methods & getters / write active routes
|
|
4257
4301
|
writeActiveRoutes() {
|
|
4258
|
-
if (this.isRemoteHost ||
|
|
4259
|
-
this.isRunOrRevertOnlyMigrationAppStart ||
|
|
4260
|
-
this.skipWritingServerRoutes) {
|
|
4302
|
+
if (this.isRemoteHost || this.isRunOrRevertOnlyMigrationAppStart) {
|
|
4261
4303
|
return;
|
|
4262
4304
|
}
|
|
4263
4305
|
// const contexts: EndpointContext[] = [this];
|
|
@@ -4297,6 +4339,7 @@ class EndpointContext {
|
|
|
4297
4339
|
/* */
|
|
4298
4340
|
/* */
|
|
4299
4341
|
/* */
|
|
4342
|
+
/* */
|
|
4300
4343
|
}
|
|
4301
4344
|
//#endregion
|
|
4302
4345
|
//#region methods & getters / middlewares
|
|
@@ -4775,6 +4818,39 @@ class EndpointContext {
|
|
|
4775
4818
|
};
|
|
4776
4819
|
}
|
|
4777
4820
|
//#endregion
|
|
4821
|
+
sendError(res, error, req, expressPath) {
|
|
4822
|
+
/* */
|
|
4823
|
+
/* */
|
|
4824
|
+
/* */
|
|
4825
|
+
/* */
|
|
4826
|
+
/* */
|
|
4827
|
+
/* */
|
|
4828
|
+
/* */
|
|
4829
|
+
/* */
|
|
4830
|
+
/* */
|
|
4831
|
+
/* */
|
|
4832
|
+
/* */
|
|
4833
|
+
/* */
|
|
4834
|
+
/* */
|
|
4835
|
+
/* */
|
|
4836
|
+
/* */
|
|
4837
|
+
/* */
|
|
4838
|
+
/* */
|
|
4839
|
+
/* */
|
|
4840
|
+
/* */
|
|
4841
|
+
/* */
|
|
4842
|
+
/* */
|
|
4843
|
+
/* */
|
|
4844
|
+
/* */
|
|
4845
|
+
/* */
|
|
4846
|
+
/* */
|
|
4847
|
+
/* */
|
|
4848
|
+
/* */
|
|
4849
|
+
/* */
|
|
4850
|
+
/* */
|
|
4851
|
+
/* */
|
|
4852
|
+
return (void 0);
|
|
4853
|
+
}
|
|
4778
4854
|
//#region methods & getters / init client
|
|
4779
4855
|
/**
|
|
4780
4856
|
* client can be browser or nodejs (when remote host)
|
|
@@ -4809,8 +4885,8 @@ class EndpointContext {
|
|
|
4809
4885
|
});
|
|
4810
4886
|
//#endregion
|
|
4811
4887
|
// : { received: any; /* Rest<any, any> */ }
|
|
4812
|
-
this.logHttp &&
|
|
4813
|
-
|
|
4888
|
+
// this.logHttp &&
|
|
4889
|
+
// console.log(`${httpRequestType?.toUpperCase()} ${expressPath} `);
|
|
4814
4890
|
// console.log('INITING', methodConfig); // TODO inject in static
|
|
4815
4891
|
//#region resolve storage
|
|
4816
4892
|
// TODO not a good idea
|
|
@@ -5887,6 +5963,9 @@ let BaseRepository = class BaseRepository extends BaseCustomRepository {
|
|
|
5887
5963
|
/* */
|
|
5888
5964
|
return (void 0);
|
|
5889
5965
|
}
|
|
5966
|
+
/**
|
|
5967
|
+
* @deprecated use bulkSave instead
|
|
5968
|
+
*/
|
|
5890
5969
|
async bulkCreate(items, options) {
|
|
5891
5970
|
return this.bulkSave(items, options);
|
|
5892
5971
|
}
|
|
@@ -6414,7 +6493,7 @@ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, p
|
|
|
6414
6493
|
else {
|
|
6415
6494
|
options = { pathOrOptions, pathIsGlobal };
|
|
6416
6495
|
}
|
|
6417
|
-
const { overrideContentType, overrideResponseType, middlewares } = options;
|
|
6496
|
+
const { overrideContentType, overrideResponseType, overrideExpressSendAsHtml, middlewares, } = options;
|
|
6418
6497
|
methodConfig.methodName = propertyKey;
|
|
6419
6498
|
methodConfig.middlewares = middlewares;
|
|
6420
6499
|
methodConfig.type = method;
|
|
@@ -6439,12 +6518,44 @@ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, p
|
|
|
6439
6518
|
methodConfig.global = pathIsGlobal;
|
|
6440
6519
|
methodConfig.contentType = overrideContentType;
|
|
6441
6520
|
methodConfig.responseType = overrideResponseType;
|
|
6521
|
+
methodConfig.overrideExpressSendAsHtml = overrideExpressSendAsHtml;
|
|
6442
6522
|
};
|
|
6443
6523
|
function GET(pathOrOptions, pathIsGlobal = false) {
|
|
6444
6524
|
return function (target, propertyKey, descriptor) {
|
|
6445
6525
|
metaReq('get', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
6446
6526
|
};
|
|
6447
6527
|
}
|
|
6528
|
+
/**
|
|
6529
|
+
* Method for sending html website from text
|
|
6530
|
+
* Example
|
|
6531
|
+
*
|
|
6532
|
+
* ```ts
|
|
6533
|
+
* ...
|
|
6534
|
+
* // in your taon controller
|
|
6535
|
+
* ..Taon.Http.HTML()
|
|
6536
|
+
* sendHtmlDummyWebsite(): Taon.ResponseHtml {
|
|
6537
|
+
* return `
|
|
6538
|
+
<html>
|
|
6539
|
+
<head>
|
|
6540
|
+
<title>Dummy website</title>
|
|
6541
|
+
</head>
|
|
6542
|
+
<body>
|
|
6543
|
+
<h1>This is dummy website</h1>
|
|
6544
|
+
<p>Served as HTML string from Taon controller method</p>
|
|
6545
|
+
</body>
|
|
6546
|
+
</html>
|
|
6547
|
+
* `; *
|
|
6548
|
+
* }
|
|
6549
|
+
* ...
|
|
6550
|
+
* ```
|
|
6551
|
+
*/
|
|
6552
|
+
function HTML(pathOrOptions) {
|
|
6553
|
+
return function (target, propertyKey, descriptor) {
|
|
6554
|
+
const opt = pathOrOptions;
|
|
6555
|
+
opt.overrideExpressSendAsHtml = true;
|
|
6556
|
+
metaReq('get', opt, target, propertyKey, descriptor, pathOrOptions, opt.pathIsGlobal);
|
|
6557
|
+
};
|
|
6558
|
+
}
|
|
6448
6559
|
function HEAD(pathOrOptions, pathIsGlobal = false) {
|
|
6449
6560
|
return function (target, propertyKey, descriptor) {
|
|
6450
6561
|
metaReq('head', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
@@ -6520,7 +6631,7 @@ let BaseController = class BaseController extends BaseInjector {
|
|
|
6520
6631
|
*/
|
|
6521
6632
|
async afterAllCtxInited(options) { }
|
|
6522
6633
|
//#region upload form data to server
|
|
6523
|
-
uploadFormDataToServer(formData) {
|
|
6634
|
+
uploadFormDataToServer(formData, queryParams) {
|
|
6524
6635
|
/* */
|
|
6525
6636
|
/* */
|
|
6526
6637
|
/* */
|
|
@@ -6555,11 +6666,13 @@ let BaseController = class BaseController extends BaseInjector {
|
|
|
6555
6666
|
* Hook after file is uploaded
|
|
6556
6667
|
* through `uploadFormDataToServer` or `uploadLocalFileToServer`
|
|
6557
6668
|
*/
|
|
6558
|
-
afterFileUploadAction(file) {
|
|
6669
|
+
afterFileUploadAction(file, queryParams) {
|
|
6559
6670
|
// empty
|
|
6560
6671
|
}
|
|
6561
6672
|
//#region upload local file to server
|
|
6562
|
-
async uploadLocalFileToServer(absFilePath, options) {
|
|
6673
|
+
async uploadLocalFileToServer(absFilePath, options, queryParams) {
|
|
6674
|
+
/* */
|
|
6675
|
+
/* */
|
|
6563
6676
|
/* */
|
|
6564
6677
|
/* */
|
|
6565
6678
|
/* */
|
|
@@ -6574,6 +6687,75 @@ let BaseController = class BaseController extends BaseInjector {
|
|
|
6574
6687
|
/* */
|
|
6575
6688
|
return (void 0);
|
|
6576
6689
|
}
|
|
6690
|
+
//#endregion
|
|
6691
|
+
// async check() {
|
|
6692
|
+
// await this._waitForProperStatusChange({
|
|
6693
|
+
// request: () => this.uploadFormDataToServer(void 0, void 0).request(),
|
|
6694
|
+
// statusCheck: resp => resp.body.json[0].ok,
|
|
6695
|
+
// });
|
|
6696
|
+
// }
|
|
6697
|
+
/**
|
|
6698
|
+
* Easy way to wait for status change with http (1s default) pooling.
|
|
6699
|
+
*
|
|
6700
|
+
* example (in sub class):
|
|
6701
|
+
* ```ts
|
|
6702
|
+
async check() {
|
|
6703
|
+
await this.waitForProperStatusChange({
|
|
6704
|
+
request: () => this.uploadFormDataToServer(void 0, void 0).request(),
|
|
6705
|
+
statusCheck: resp => resp.body.json[0].ok,
|
|
6706
|
+
});
|
|
6707
|
+
}
|
|
6708
|
+
* ```
|
|
6709
|
+
*/
|
|
6710
|
+
async _waitForProperStatusChange(options) {
|
|
6711
|
+
const poolingInterval = options.poolingInterval || 1000;
|
|
6712
|
+
const taonRequest = options.request;
|
|
6713
|
+
let maxTries = options.maxTries || Number.POSITIVE_INFINITY;
|
|
6714
|
+
let i = 0;
|
|
6715
|
+
let httpErrorsCount = 0;
|
|
6716
|
+
while (true) {
|
|
6717
|
+
await UtilsTerminal.waitMilliseconds(poolingInterval);
|
|
6718
|
+
try {
|
|
6719
|
+
const resp = await taonRequest({
|
|
6720
|
+
reqIndexNum: i,
|
|
6721
|
+
httpErrorsCount,
|
|
6722
|
+
});
|
|
6723
|
+
if (options.statusCheck && options.statusCheck(resp)) {
|
|
6724
|
+
return;
|
|
6725
|
+
}
|
|
6726
|
+
}
|
|
6727
|
+
catch (error) {
|
|
6728
|
+
httpErrorsCount++;
|
|
6729
|
+
if (options.loopRequestsOnBackendError) {
|
|
6730
|
+
const isProperTaonError = error instanceof HttpResponseError &&
|
|
6731
|
+
error.body.json[CoreModels.TaonHttpErrorCustomProp];
|
|
6732
|
+
const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
|
|
6733
|
+
const isUnknownError = !(error instanceof HttpResponseError);
|
|
6734
|
+
const resBool = await options.loopRequestsOnBackendError({
|
|
6735
|
+
taonError: isProperTaonError ? error : void 0,
|
|
6736
|
+
unknownHttpError: isHttpError ? error : void 0,
|
|
6737
|
+
unknownError: isUnknownError ? error : void 0,
|
|
6738
|
+
reqIndexNum: i,
|
|
6739
|
+
httpErrorsCount,
|
|
6740
|
+
});
|
|
6741
|
+
if (resBool) {
|
|
6742
|
+
i++;
|
|
6743
|
+
continue;
|
|
6744
|
+
}
|
|
6745
|
+
else {
|
|
6746
|
+
return;
|
|
6747
|
+
}
|
|
6748
|
+
}
|
|
6749
|
+
if (httpErrorsCount >
|
|
6750
|
+
(options.allowedHttpErrors || Number.POSITIVE_INFINITY)) {
|
|
6751
|
+
throw new Error(`Too many http errors (${httpErrorsCount}) for "${options.actionName}".`);
|
|
6752
|
+
}
|
|
6753
|
+
}
|
|
6754
|
+
if (i++ > maxTries) {
|
|
6755
|
+
throw new Error(`Timeout waiting for "${options.actionName}" to be finished. Waited for ${maxTries} seconds`);
|
|
6756
|
+
}
|
|
6757
|
+
}
|
|
6758
|
+
}
|
|
6577
6759
|
};
|
|
6578
6760
|
__decorate([
|
|
6579
6761
|
POST({
|
|
@@ -6584,8 +6766,9 @@ __decorate([
|
|
|
6584
6766
|
}),
|
|
6585
6767
|
}),
|
|
6586
6768
|
__param(0, Body()),
|
|
6769
|
+
__param(1, Query()),
|
|
6587
6770
|
__metadata("design:type", Function),
|
|
6588
|
-
__metadata("design:paramtypes", [FormData]),
|
|
6771
|
+
__metadata("design:paramtypes", [FormData, Object]),
|
|
6589
6772
|
__metadata("design:returntype", Object)
|
|
6590
6773
|
], BaseController.prototype, "uploadFormDataToServer", null);
|
|
6591
6774
|
BaseController = __decorate([
|
|
@@ -6617,7 +6800,7 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
6617
6800
|
else {
|
|
6618
6801
|
Helpers.error(`Entity class not provided for controller ${ClassHelpers.getName(this)}.
|
|
6619
6802
|
|
|
6620
|
-
Please provide entity as class
|
|
6803
|
+
Please provide entity as class property entityClassFn:
|
|
6621
6804
|
|
|
6622
6805
|
class ${ClassHelpers.getName(this)} extends BaseCrudController<Entity> {
|
|
6623
6806
|
// ...
|
|
@@ -6772,8 +6955,17 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
6772
6955
|
return (void 0);
|
|
6773
6956
|
}
|
|
6774
6957
|
//#endregion
|
|
6958
|
+
//#region bulk delete
|
|
6959
|
+
clearTable() {
|
|
6960
|
+
/* */
|
|
6961
|
+
/* */
|
|
6962
|
+
/* */
|
|
6963
|
+
/* */
|
|
6964
|
+
return (void 0);
|
|
6965
|
+
}
|
|
6966
|
+
//#endregion
|
|
6775
6967
|
//#region create
|
|
6776
|
-
|
|
6968
|
+
save(item) {
|
|
6777
6969
|
/* */
|
|
6778
6970
|
/* */
|
|
6779
6971
|
/* */
|
|
@@ -6850,7 +7042,7 @@ __decorate([
|
|
|
6850
7042
|
DELETE(),
|
|
6851
7043
|
__param(0, Query(`id`)),
|
|
6852
7044
|
__metadata("design:type", Function),
|
|
6853
|
-
__metadata("design:paramtypes", [
|
|
7045
|
+
__metadata("design:paramtypes", [Object]),
|
|
6854
7046
|
__metadata("design:returntype", Object)
|
|
6855
7047
|
], BaseCrudController.prototype, "deleteById", null);
|
|
6856
7048
|
__decorate([
|
|
@@ -6860,13 +7052,19 @@ __decorate([
|
|
|
6860
7052
|
__metadata("design:paramtypes", [Array]),
|
|
6861
7053
|
__metadata("design:returntype", Object)
|
|
6862
7054
|
], BaseCrudController.prototype, "bulkDelete", null);
|
|
7055
|
+
__decorate([
|
|
7056
|
+
DELETE(),
|
|
7057
|
+
__metadata("design:type", Function),
|
|
7058
|
+
__metadata("design:paramtypes", []),
|
|
7059
|
+
__metadata("design:returntype", Object)
|
|
7060
|
+
], BaseCrudController.prototype, "clearTable", null);
|
|
6863
7061
|
__decorate([
|
|
6864
7062
|
POST(),
|
|
6865
7063
|
__param(0, Body()),
|
|
6866
7064
|
__metadata("design:type", Function),
|
|
6867
7065
|
__metadata("design:paramtypes", [Object]),
|
|
6868
7066
|
__metadata("design:returntype", Object)
|
|
6869
|
-
], BaseCrudController.prototype, "
|
|
7067
|
+
], BaseCrudController.prototype, "save", null);
|
|
6870
7068
|
__decorate([
|
|
6871
7069
|
POST(),
|
|
6872
7070
|
__param(0, Body()),
|
|
@@ -7132,6 +7330,7 @@ var Http;
|
|
|
7132
7330
|
Http.DELETE = DELETE;
|
|
7133
7331
|
Http.PATCH = PATCH;
|
|
7134
7332
|
Http.HEAD = HEAD;
|
|
7333
|
+
Http.HTML = HTML;
|
|
7135
7334
|
Http.Response = Models$1.HttpResponse;
|
|
7136
7335
|
let Param;
|
|
7137
7336
|
(function (Param) {
|
|
@@ -7146,6 +7345,11 @@ var Http;
|
|
|
7146
7345
|
// TODO export all things
|
|
7147
7346
|
var Taon;
|
|
7148
7347
|
(function (Taon) {
|
|
7348
|
+
Taon.error = (opt) => {
|
|
7349
|
+
throw () => {
|
|
7350
|
+
return opt;
|
|
7351
|
+
};
|
|
7352
|
+
};
|
|
7149
7353
|
Taon.Http = Http;
|
|
7150
7354
|
Taon.Base = Base;
|
|
7151
7355
|
Taon.getResponseValue = getResponseValue;
|
|
@@ -7198,5 +7402,5 @@ var Taon;
|
|
|
7198
7402
|
* Generated bundle index. Do not edit.
|
|
7199
7403
|
*/
|
|
7200
7404
|
|
|
7201
|
-
export { BaseContext, BaseController, BaseCustomRepository, BaseEntity, BaseFileUploadMiddleware, BaseMigration, BaseProvider, BaseRepository, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL, ClassHelpers, ContextsEndpointStorage, EndpointContext, Models, TAON_CONTEXT, Taon, TaonAdminService, TaonEntityKeysToOmitArr, apiPrefix, createContext, inject };
|
|
7405
|
+
export { BaseClass, BaseContext, BaseController, BaseCustomRepository, BaseEntity, BaseFileUploadMiddleware, BaseMigration, BaseProvider, BaseRepository, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL, ClassHelpers, ContextsEndpointStorage, EndpointContext, Models, TAON_CONTEXT, Taon, TaonAdminService, TaonEntityKeysToOmitArr, apiPrefix, createContext, inject };
|
|
7202
7406
|
//# sourceMappingURL=taon.mjs.map
|