taon 19.0.65 → 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 +288 -81
- 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/decorators/http/http-params-decorators.d.ts +3 -0
- 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 +29 -17
- 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/decorators/http/http-params-decorators.d.ts +3 -0
- package/lib/decorators/http/http-params-decorators.js +3 -0
- package/lib/decorators/http/http-params-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/scss/global.scss +9 -12
- package/websql/README.md +24 -24
- package/websql/fesm2022/taon.mjs +289 -83
- 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/decorators/http/http-params-decorators.d.ts +3 -0
- 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
package/websql/fesm2022/taon.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import * as coreHelpers from 'tnp-core/websql';
|
|
3
|
-
import { _, Utils, UtilsMigrations, Helpers, UtilsOs, crossPlatformPath, CoreModels } from 'tnp-core/websql';
|
|
3
|
+
import { _, Utils, UtilsMigrations, Helpers, UtilsOs, crossPlatformPath, CoreModels, UtilsTerminal } from 'tnp-core/websql';
|
|
4
4
|
import { __decorate, __metadata, __param } from 'tslib';
|
|
5
5
|
import * as tsorm from 'taon-typeorm/websql';
|
|
6
6
|
import { OrignalClassKey, Entity, Table, TableIndex, EventSubscriber, DataSource } from 'taon-typeorm/websql';
|
|
@@ -10,7 +10,7 @@ import * as i0 from '@angular/core';
|
|
|
10
10
|
import { InjectionToken, inject as inject$1, Injectable } from '@angular/core';
|
|
11
11
|
import axios from 'axios';
|
|
12
12
|
import { JSON10 } from 'json10/websql';
|
|
13
|
-
import { Models as Models$1, Resource, RestHeaders, Mapping } from 'ng2-rest/websql';
|
|
13
|
+
import { RestResponseWrapper, Models as Models$1, Resource, RestHeaders, Mapping, HttpResponseError } from 'ng2-rest/websql';
|
|
14
14
|
import { Observable, Subject, from } from 'rxjs';
|
|
15
15
|
import { config } from 'tnp-config/websql';
|
|
16
16
|
import * as JSON5 from 'json5';
|
|
@@ -596,9 +596,26 @@ class BaseClass {
|
|
|
596
596
|
async _() { }
|
|
597
597
|
//#endregion
|
|
598
598
|
//#region clone
|
|
599
|
-
|
|
599
|
+
/**
|
|
600
|
+
*
|
|
601
|
+
* @param overrideObjOrFn if object is provided it will override values in cloned object,
|
|
602
|
+
* if function is provided it will be called with old cloned values and should return
|
|
603
|
+
* object with values to override
|
|
604
|
+
* @returns cloned instance of the class
|
|
605
|
+
*/
|
|
606
|
+
clone(overrideObjOrFn) {
|
|
607
|
+
if (_.isString(overrideObjOrFn)) {
|
|
608
|
+
console.log(overrideObjOrFn);
|
|
609
|
+
throw new Error('String is not supported as .clone() method argument');
|
|
610
|
+
}
|
|
600
611
|
const classFn = ClassHelpers.getClassFnFromObject(this);
|
|
601
|
-
|
|
612
|
+
if (_.isFunction(overrideObjOrFn)) {
|
|
613
|
+
// console.log('clone with fn');
|
|
614
|
+
const oldValues = (_.cloneDeep(this) || {});
|
|
615
|
+
return cloneObj(overrideObjOrFn(oldValues), classFn);
|
|
616
|
+
}
|
|
617
|
+
// console.log('clone normal');
|
|
618
|
+
return cloneObj(overrideObjOrFn, classFn);
|
|
602
619
|
}
|
|
603
620
|
}
|
|
604
621
|
|
|
@@ -830,6 +847,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
830
847
|
type: Injectable
|
|
831
848
|
}], ctorParameters: () => [] });
|
|
832
849
|
|
|
850
|
+
// ! TODO make it as a nice way to wrap normal request
|
|
851
|
+
class TaonRestResponseWrapper extends RestResponseWrapper {
|
|
852
|
+
}
|
|
833
853
|
var Models;
|
|
834
854
|
(function (Models) {
|
|
835
855
|
//#region models / class types
|
|
@@ -887,25 +907,6 @@ var Models;
|
|
|
887
907
|
let Http;
|
|
888
908
|
(function (Http) {
|
|
889
909
|
Http.Rest = Models$1;
|
|
890
|
-
class Errors {
|
|
891
|
-
constructor(message, code = 400) {
|
|
892
|
-
this.message = message;
|
|
893
|
-
this.code = code;
|
|
894
|
-
this.toString = () => {
|
|
895
|
-
return this.message;
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
static create(message, code = 400) {
|
|
899
|
-
return new Errors(message, code);
|
|
900
|
-
}
|
|
901
|
-
static entityNotFound(entity) {
|
|
902
|
-
return Errors.create(`Entity ${ClassHelpers.getName(entity)} not found`);
|
|
903
|
-
}
|
|
904
|
-
static custom(message, code = 400) {
|
|
905
|
-
return Errors.create(message, code);
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
Http.Errors = Errors;
|
|
909
910
|
//#endregion
|
|
910
911
|
})(Http = Models.Http || (Models.Http = {}));
|
|
911
912
|
//#endregion
|
|
@@ -1294,9 +1295,6 @@ const getResponseValue = (response, options) => {
|
|
|
1294
1295
|
resolve(result);
|
|
1295
1296
|
}
|
|
1296
1297
|
catch (e) {
|
|
1297
|
-
console.error(e);
|
|
1298
|
-
console.error('[taon] Error during function call inside controller');
|
|
1299
|
-
Helpers.renderError(e);
|
|
1300
1298
|
reject(e);
|
|
1301
1299
|
}
|
|
1302
1300
|
}
|
|
@@ -1325,6 +1323,12 @@ var TaonHelpers;
|
|
|
1325
1323
|
return p && typeof p === 'string' && p.trim() !== '';
|
|
1326
1324
|
};
|
|
1327
1325
|
//#endregion
|
|
1326
|
+
TaonHelpers.firstStringOrElemFromArray = (stringOrArrayOfString) => {
|
|
1327
|
+
if (Array.isArray(stringOrArrayOfString)) {
|
|
1328
|
+
return _.first(stringOrArrayOfString);
|
|
1329
|
+
}
|
|
1330
|
+
return stringOrArrayOfString;
|
|
1331
|
+
};
|
|
1328
1332
|
//#region try transform params
|
|
1329
1333
|
TaonHelpers.tryTransformParam = param => {
|
|
1330
1334
|
if (typeof param === 'string') {
|
|
@@ -1548,6 +1552,14 @@ class RealtimeSubsManager {
|
|
|
1548
1552
|
|
|
1549
1553
|
//#region imports
|
|
1550
1554
|
//#endregion
|
|
1555
|
+
/**
|
|
1556
|
+
* Client for realtime communication
|
|
1557
|
+
* you can listen to:
|
|
1558
|
+
* - entity changes (any property in table changed)
|
|
1559
|
+
* - entity custom property changes (specific property changed)
|
|
1560
|
+
* - entity table changes (new instance added, instance removed)
|
|
1561
|
+
* - custom events
|
|
1562
|
+
*/
|
|
1551
1563
|
class RealtimeClient {
|
|
1552
1564
|
constructor(core) {
|
|
1553
1565
|
this.core = core;
|
|
@@ -1621,20 +1633,32 @@ class RealtimeClient {
|
|
|
1621
1633
|
//#endregion
|
|
1622
1634
|
//#region methods & getters / listen changes entity
|
|
1623
1635
|
/**
|
|
1636
|
+
* Usage:
|
|
1637
|
+
* myContext.realtimeClient.listenChangesEntity(myEntityInstance);
|
|
1638
|
+
*
|
|
1639
|
+
*
|
|
1624
1640
|
* Changes trigger on backend needs to be done manually.. example code:
|
|
1625
1641
|
*
|
|
1626
|
-
*
|
|
1627
|
-
* Context.Realtime.Server.TrigggerEntityChanges(myEntityInstance);
|
|
1642
|
+
* myContext.realtimeServer.triggerEntityChanges(myEntityInstance);
|
|
1628
1643
|
* ...
|
|
1629
1644
|
*/
|
|
1630
|
-
listenChangesEntity(
|
|
1645
|
+
listenChangesEntity(entityClassFnOrObj, options) {
|
|
1631
1646
|
options = options || {};
|
|
1647
|
+
if (_.isObject(entityClassFnOrObj)) {
|
|
1648
|
+
const orgObj = entityClassFnOrObj;
|
|
1649
|
+
entityClassFnOrObj =
|
|
1650
|
+
ClassHelpers.getClassFnFromObject(entityClassFnOrObj);
|
|
1651
|
+
const uniqueKey = ClassHelpers.getUniqueKey(entityClassFnOrObj);
|
|
1652
|
+
if (uniqueKey) {
|
|
1653
|
+
options.idOrUniqValue = orgObj[uniqueKey];
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1632
1656
|
//#region parameters validation
|
|
1633
1657
|
const { property, customEvent } = options;
|
|
1634
|
-
const className = !customEvent && ClassHelpers.getName(
|
|
1658
|
+
const className = !customEvent && ClassHelpers.getName(entityClassFnOrObj);
|
|
1635
1659
|
if (_.isString(property)) {
|
|
1636
1660
|
if (property.trim() === '') {
|
|
1637
|
-
throw new Error(`[Taon][listenChangesEntity..
|
|
1661
|
+
throw new Error(`[Taon][listenChangesEntity.. incorrect property '' for ${className}`);
|
|
1638
1662
|
}
|
|
1639
1663
|
}
|
|
1640
1664
|
//#endregion
|
|
@@ -1659,8 +1683,8 @@ to use socket realtime connection;
|
|
|
1659
1683
|
}
|
|
1660
1684
|
else {
|
|
1661
1685
|
roomName = _.isString(property)
|
|
1662
|
-
? Symbols.REALTIME.ROOM_NAME_UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, className, property, idOrUniqValue)
|
|
1663
|
-
: Symbols.REALTIME.ROOM_NAME_UPDATE_ENTITY(this.core.ctx.contextName, className, idOrUniqValue);
|
|
1686
|
+
? Symbols.REALTIME.ROOM_NAME_UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, className, property, options.idOrUniqValue)
|
|
1687
|
+
: Symbols.REALTIME.ROOM_NAME_UPDATE_ENTITY(this.core.ctx.contextName, className, options.idOrUniqValue);
|
|
1664
1688
|
}
|
|
1665
1689
|
const roomSubOptions = {
|
|
1666
1690
|
core: this.core,
|
|
@@ -1683,32 +1707,20 @@ to use socket realtime connection;
|
|
|
1683
1707
|
}
|
|
1684
1708
|
//#endregion
|
|
1685
1709
|
//#region listen changes entity table
|
|
1710
|
+
/**
|
|
1711
|
+
* Listen changes entity table
|
|
1712
|
+
* Example: for pagination, lists update ...
|
|
1713
|
+
*/
|
|
1686
1714
|
listenChangesEntityTable(entityClassFn) {
|
|
1687
1715
|
const className = ClassHelpers.getName(entityClassFn);
|
|
1688
|
-
return this.listenChangesEntity(entityClassFn,
|
|
1716
|
+
return this.listenChangesEntity(entityClassFn, {
|
|
1689
1717
|
customEvent: Symbols.REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className),
|
|
1690
1718
|
});
|
|
1691
1719
|
}
|
|
1692
1720
|
//#endregion
|
|
1693
|
-
//#region listen change entity object
|
|
1694
|
-
/**
|
|
1695
|
-
* Changes trigger on backend needs to be done manually.. example code:
|
|
1696
|
-
*
|
|
1697
|
-
* ...
|
|
1698
|
-
* Context.Realtime.Server.TrigggerEntityChanges(myEntityInstance);
|
|
1699
|
-
* // or
|
|
1700
|
-
* Context.Realtime.Server.TrigggerEntityPropertyChanges(myEntityInstance,{ property: 'geolocationX' });
|
|
1701
|
-
* ...
|
|
1702
|
-
*/
|
|
1703
|
-
listenChangesEntityObj(entity, options) {
|
|
1704
|
-
const classFn = ClassHelpers.getClassFnFromObject(entity);
|
|
1705
|
-
const uniqueKey = ClassHelpers.getUniqueKey(classFn);
|
|
1706
|
-
return this.listenChangesEntity(classFn, entity[uniqueKey], options);
|
|
1707
|
-
}
|
|
1708
|
-
//#endregion
|
|
1709
1721
|
//#region listen changes custom event
|
|
1710
1722
|
listenChangesCustomEvent(customEvent) {
|
|
1711
|
-
return this.listenChangesEntity(void 0,
|
|
1723
|
+
return this.listenChangesEntity(void 0, {
|
|
1712
1724
|
customEvent,
|
|
1713
1725
|
});
|
|
1714
1726
|
}
|
|
@@ -1734,6 +1746,17 @@ to use socket realtime connection;
|
|
|
1734
1746
|
//#region imports
|
|
1735
1747
|
/* */
|
|
1736
1748
|
//#endregion
|
|
1749
|
+
/**
|
|
1750
|
+
* Server for realtime communication
|
|
1751
|
+
* you can trigger:
|
|
1752
|
+
* - entity changes (any property in table changed)
|
|
1753
|
+
* - entity custom property changes (specific property changed)
|
|
1754
|
+
* - entity table changes (new instance added, instance removed)
|
|
1755
|
+
* - custom events
|
|
1756
|
+
*
|
|
1757
|
+
* and also listen to:
|
|
1758
|
+
* - custom events from yourself
|
|
1759
|
+
*/
|
|
1737
1760
|
class RealtimeServer {
|
|
1738
1761
|
// private jobs = {};
|
|
1739
1762
|
constructor(core) {
|
|
@@ -1881,7 +1904,12 @@ class RealtimeServer {
|
|
|
1881
1904
|
//#endregion
|
|
1882
1905
|
//#region entity changes
|
|
1883
1906
|
//#region methods & getters / trigger entity changes
|
|
1884
|
-
triggerEntityChanges(entityObjOrClass,
|
|
1907
|
+
triggerEntityChanges(entityObjOrClass,
|
|
1908
|
+
/**
|
|
1909
|
+
* value of unique key property of entity instance
|
|
1910
|
+
* (this value is not needed if entityObjOrClass is instance of entity)
|
|
1911
|
+
*/
|
|
1912
|
+
idToTrigger) {
|
|
1885
1913
|
if (this.core.ctx.disabledRealtime) {
|
|
1886
1914
|
const className = ClassHelpers.getName(entityObjOrClass);
|
|
1887
1915
|
console.warn(`[Taon][TriggerEntityChanges] Entity "${className}' is not realtime`);
|
|
@@ -1891,7 +1919,17 @@ class RealtimeServer {
|
|
|
1891
1919
|
}
|
|
1892
1920
|
//#endregion
|
|
1893
1921
|
//#region methods & getters / trigger entity property changes
|
|
1894
|
-
triggerEntityPropertyChanges(entityObjOrClass,
|
|
1922
|
+
triggerEntityPropertyChanges(entityObjOrClass,
|
|
1923
|
+
/**
|
|
1924
|
+
* property name or array of property names that changed
|
|
1925
|
+
* for entity instance
|
|
1926
|
+
*/
|
|
1927
|
+
property,
|
|
1928
|
+
/**
|
|
1929
|
+
* value of unique key property of entity instance
|
|
1930
|
+
* (this value is not needed if entityObjOrClass is instance of entity)
|
|
1931
|
+
*/
|
|
1932
|
+
idToTrigger) {
|
|
1895
1933
|
if (this.core.ctx.disabledRealtime) {
|
|
1896
1934
|
const className = ClassHelpers.getName(entityObjOrClass);
|
|
1897
1935
|
console.warn(`[Taon][TriggerEntityPropertyChanges][property=${property}] Entity "${className}' is not realtime`);
|
|
@@ -2710,6 +2748,12 @@ class EndpointContext {
|
|
|
2710
2748
|
}
|
|
2711
2749
|
return this.config?.logs === true;
|
|
2712
2750
|
}
|
|
2751
|
+
get logRoutes() {
|
|
2752
|
+
if (_.isObject(this.config?.logs)) {
|
|
2753
|
+
return !!this.config.logs.routes;
|
|
2754
|
+
}
|
|
2755
|
+
return this.config?.logs === true;
|
|
2756
|
+
}
|
|
2713
2757
|
get logDb() {
|
|
2714
2758
|
if (_.isObject(this.config?.logs)) {
|
|
2715
2759
|
return !!this.config.logs.db;
|
|
@@ -4157,9 +4201,7 @@ class EndpointContext {
|
|
|
4157
4201
|
//#endregion
|
|
4158
4202
|
//#region methods & getters / write active routes
|
|
4159
4203
|
writeActiveRoutes() {
|
|
4160
|
-
if (this.isRemoteHost ||
|
|
4161
|
-
this.isRunOrRevertOnlyMigrationAppStart ||
|
|
4162
|
-
this.skipWritingServerRoutes) {
|
|
4204
|
+
if (this.isRemoteHost || this.isRunOrRevertOnlyMigrationAppStart) {
|
|
4163
4205
|
return;
|
|
4164
4206
|
}
|
|
4165
4207
|
// const contexts: EndpointContext[] = [this];
|
|
@@ -4185,7 +4227,7 @@ class EndpointContext {
|
|
|
4185
4227
|
`routes-${this.config.contextName}.rest`,
|
|
4186
4228
|
]);
|
|
4187
4229
|
this.logFramework && console.log(`[taon] routes file: ${fileName} `);
|
|
4188
|
-
|
|
4230
|
+
this.logRoutes && console.log(routes);
|
|
4189
4231
|
/* */
|
|
4190
4232
|
/* */
|
|
4191
4233
|
/* */
|
|
@@ -4670,6 +4712,39 @@ class EndpointContext {
|
|
|
4670
4712
|
};
|
|
4671
4713
|
}
|
|
4672
4714
|
//#endregion
|
|
4715
|
+
sendError(res, error, req, expressPath) {
|
|
4716
|
+
/* */
|
|
4717
|
+
/* */
|
|
4718
|
+
/* */
|
|
4719
|
+
/* */
|
|
4720
|
+
/* */
|
|
4721
|
+
/* */
|
|
4722
|
+
/* */
|
|
4723
|
+
/* */
|
|
4724
|
+
/* */
|
|
4725
|
+
/* */
|
|
4726
|
+
/* */
|
|
4727
|
+
/* */
|
|
4728
|
+
/* */
|
|
4729
|
+
/* */
|
|
4730
|
+
/* */
|
|
4731
|
+
/* */
|
|
4732
|
+
/* */
|
|
4733
|
+
/* */
|
|
4734
|
+
/* */
|
|
4735
|
+
/* */
|
|
4736
|
+
/* */
|
|
4737
|
+
/* */
|
|
4738
|
+
/* */
|
|
4739
|
+
/* */
|
|
4740
|
+
/* */
|
|
4741
|
+
/* */
|
|
4742
|
+
/* */
|
|
4743
|
+
/* */
|
|
4744
|
+
/* */
|
|
4745
|
+
/* */
|
|
4746
|
+
return (void 0);
|
|
4747
|
+
}
|
|
4673
4748
|
//#region methods & getters / init client
|
|
4674
4749
|
/**
|
|
4675
4750
|
* client can be browser or nodejs (when remote host)
|
|
@@ -4704,8 +4779,8 @@ class EndpointContext {
|
|
|
4704
4779
|
});
|
|
4705
4780
|
//#endregion
|
|
4706
4781
|
// : { received: any; /* Rest<any, any> */ }
|
|
4707
|
-
this.logHttp &&
|
|
4708
|
-
|
|
4782
|
+
// this.logHttp &&
|
|
4783
|
+
// console.log(`${httpRequestType?.toUpperCase()} ${expressPath} `);
|
|
4709
4784
|
// console.log('INITING', methodConfig); // TODO inject in static
|
|
4710
4785
|
//#region resolve storage
|
|
4711
4786
|
// TODO not a good idea
|
|
@@ -5701,6 +5776,9 @@ let BaseRepository = class BaseRepository extends BaseCustomRepository {
|
|
|
5701
5776
|
return models;
|
|
5702
5777
|
//#endregion
|
|
5703
5778
|
}
|
|
5779
|
+
/**
|
|
5780
|
+
* @deprecated use bulkSave instead
|
|
5781
|
+
*/
|
|
5704
5782
|
async bulkCreate(items, options) {
|
|
5705
5783
|
return this.bulkSave(items, options);
|
|
5706
5784
|
}
|
|
@@ -6211,7 +6289,7 @@ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, p
|
|
|
6211
6289
|
else {
|
|
6212
6290
|
options = { pathOrOptions, pathIsGlobal };
|
|
6213
6291
|
}
|
|
6214
|
-
const { overrideContentType, overrideResponseType, middlewares } = options;
|
|
6292
|
+
const { overrideContentType, overrideResponseType, overrideExpressSendAsHtml, middlewares, } = options;
|
|
6215
6293
|
methodConfig.methodName = propertyKey;
|
|
6216
6294
|
methodConfig.middlewares = middlewares;
|
|
6217
6295
|
methodConfig.type = method;
|
|
@@ -6236,12 +6314,44 @@ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, p
|
|
|
6236
6314
|
methodConfig.global = pathIsGlobal;
|
|
6237
6315
|
methodConfig.contentType = overrideContentType;
|
|
6238
6316
|
methodConfig.responseType = overrideResponseType;
|
|
6317
|
+
methodConfig.overrideExpressSendAsHtml = overrideExpressSendAsHtml;
|
|
6239
6318
|
};
|
|
6240
6319
|
function GET(pathOrOptions, pathIsGlobal = false) {
|
|
6241
6320
|
return function (target, propertyKey, descriptor) {
|
|
6242
6321
|
metaReq('get', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
6243
6322
|
};
|
|
6244
6323
|
}
|
|
6324
|
+
/**
|
|
6325
|
+
* Method for sending html website from text
|
|
6326
|
+
* Example
|
|
6327
|
+
*
|
|
6328
|
+
* ```ts
|
|
6329
|
+
* ...
|
|
6330
|
+
* // in your taon controller
|
|
6331
|
+
* ..Taon.Http.HTML()
|
|
6332
|
+
* sendHtmlDummyWebsite(): Taon.ResponseHtml {
|
|
6333
|
+
* return `
|
|
6334
|
+
<html>
|
|
6335
|
+
<head>
|
|
6336
|
+
<title>Dummy website</title>
|
|
6337
|
+
</head>
|
|
6338
|
+
<body>
|
|
6339
|
+
<h1>This is dummy website</h1>
|
|
6340
|
+
<p>Served as HTML string from Taon controller method</p>
|
|
6341
|
+
</body>
|
|
6342
|
+
</html>
|
|
6343
|
+
* `; *
|
|
6344
|
+
* }
|
|
6345
|
+
* ...
|
|
6346
|
+
* ```
|
|
6347
|
+
*/
|
|
6348
|
+
function HTML(pathOrOptions) {
|
|
6349
|
+
return function (target, propertyKey, descriptor) {
|
|
6350
|
+
const opt = pathOrOptions;
|
|
6351
|
+
opt.overrideExpressSendAsHtml = true;
|
|
6352
|
+
metaReq('get', opt, target, propertyKey, descriptor, pathOrOptions, opt.pathIsGlobal);
|
|
6353
|
+
};
|
|
6354
|
+
}
|
|
6245
6355
|
function HEAD(pathOrOptions, pathIsGlobal = false) {
|
|
6246
6356
|
return function (target, propertyKey, descriptor) {
|
|
6247
6357
|
metaReq('head', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
@@ -6281,6 +6391,9 @@ function metaParam(param, name, expire, defaultValue = undefined, target, proper
|
|
|
6281
6391
|
};
|
|
6282
6392
|
// console.log('params updated', methodConfig);
|
|
6283
6393
|
}
|
|
6394
|
+
/**
|
|
6395
|
+
* @deprecated use Taon.Http.Param.Path (is more safe and cleaner)
|
|
6396
|
+
*/
|
|
6284
6397
|
function Path(name) {
|
|
6285
6398
|
return function (target, propertyKey, parameterIndex) {
|
|
6286
6399
|
metaParam('Path', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
@@ -6314,7 +6427,7 @@ let BaseController = class BaseController extends BaseInjector {
|
|
|
6314
6427
|
*/
|
|
6315
6428
|
async afterAllCtxInited(options) { }
|
|
6316
6429
|
//#region upload form data to server
|
|
6317
|
-
uploadFormDataToServer(formData) {
|
|
6430
|
+
uploadFormDataToServer(formData, queryParams) {
|
|
6318
6431
|
/* */
|
|
6319
6432
|
/* */
|
|
6320
6433
|
/* */
|
|
@@ -6349,11 +6462,13 @@ let BaseController = class BaseController extends BaseInjector {
|
|
|
6349
6462
|
* Hook after file is uploaded
|
|
6350
6463
|
* through `uploadFormDataToServer` or `uploadLocalFileToServer`
|
|
6351
6464
|
*/
|
|
6352
|
-
afterFileUploadAction(file) {
|
|
6465
|
+
afterFileUploadAction(file, queryParams) {
|
|
6353
6466
|
// empty
|
|
6354
6467
|
}
|
|
6355
6468
|
//#region upload local file to server
|
|
6356
|
-
async uploadLocalFileToServer(absFilePath, options) {
|
|
6469
|
+
async uploadLocalFileToServer(absFilePath, options, queryParams) {
|
|
6470
|
+
/* */
|
|
6471
|
+
/* */
|
|
6357
6472
|
/* */
|
|
6358
6473
|
/* */
|
|
6359
6474
|
/* */
|
|
@@ -6368,6 +6483,75 @@ let BaseController = class BaseController extends BaseInjector {
|
|
|
6368
6483
|
/* */
|
|
6369
6484
|
return (void 0);
|
|
6370
6485
|
}
|
|
6486
|
+
//#endregion
|
|
6487
|
+
// async check() {
|
|
6488
|
+
// await this._waitForProperStatusChange({
|
|
6489
|
+
// request: () => this.uploadFormDataToServer(void 0, void 0).request(),
|
|
6490
|
+
// statusCheck: resp => resp.body.json[0].ok,
|
|
6491
|
+
// });
|
|
6492
|
+
// }
|
|
6493
|
+
/**
|
|
6494
|
+
* Easy way to wait for status change with http (1s default) pooling.
|
|
6495
|
+
*
|
|
6496
|
+
* example (in sub class):
|
|
6497
|
+
* ```ts
|
|
6498
|
+
async check() {
|
|
6499
|
+
await this.waitForProperStatusChange({
|
|
6500
|
+
request: () => this.uploadFormDataToServer(void 0, void 0).request(),
|
|
6501
|
+
statusCheck: resp => resp.body.json[0].ok,
|
|
6502
|
+
});
|
|
6503
|
+
}
|
|
6504
|
+
* ```
|
|
6505
|
+
*/
|
|
6506
|
+
async _waitForProperStatusChange(options) {
|
|
6507
|
+
const poolingInterval = options.poolingInterval || 1000;
|
|
6508
|
+
const taonRequest = options.request;
|
|
6509
|
+
let maxTries = options.maxTries || Number.POSITIVE_INFINITY;
|
|
6510
|
+
let i = 0;
|
|
6511
|
+
let httpErrorsCount = 0;
|
|
6512
|
+
while (true) {
|
|
6513
|
+
await UtilsTerminal.waitMilliseconds(poolingInterval);
|
|
6514
|
+
try {
|
|
6515
|
+
const resp = await taonRequest({
|
|
6516
|
+
reqIndexNum: i,
|
|
6517
|
+
httpErrorsCount,
|
|
6518
|
+
});
|
|
6519
|
+
if (options.statusCheck && options.statusCheck(resp)) {
|
|
6520
|
+
return;
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6523
|
+
catch (error) {
|
|
6524
|
+
httpErrorsCount++;
|
|
6525
|
+
if (options.loopRequestsOnBackendError) {
|
|
6526
|
+
const isProperTaonError = error instanceof HttpResponseError &&
|
|
6527
|
+
error.body.json[CoreModels.TaonHttpErrorCustomProp];
|
|
6528
|
+
const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
|
|
6529
|
+
const isUnknownError = !(error instanceof HttpResponseError);
|
|
6530
|
+
const resBool = await options.loopRequestsOnBackendError({
|
|
6531
|
+
taonError: isProperTaonError ? error : void 0,
|
|
6532
|
+
unknownHttpError: isHttpError ? error : void 0,
|
|
6533
|
+
unknownError: isUnknownError ? error : void 0,
|
|
6534
|
+
reqIndexNum: i,
|
|
6535
|
+
httpErrorsCount,
|
|
6536
|
+
});
|
|
6537
|
+
if (resBool) {
|
|
6538
|
+
i++;
|
|
6539
|
+
continue;
|
|
6540
|
+
}
|
|
6541
|
+
else {
|
|
6542
|
+
return;
|
|
6543
|
+
}
|
|
6544
|
+
}
|
|
6545
|
+
if (httpErrorsCount >
|
|
6546
|
+
(options.allowedHttpErrors || Number.POSITIVE_INFINITY)) {
|
|
6547
|
+
throw new Error(`Too many http errors (${httpErrorsCount}) for "${options.actionName}".`);
|
|
6548
|
+
}
|
|
6549
|
+
}
|
|
6550
|
+
if (i++ > maxTries) {
|
|
6551
|
+
throw new Error(`Timeout waiting for "${options.actionName}" to be finished. Waited for ${maxTries} seconds`);
|
|
6552
|
+
}
|
|
6553
|
+
}
|
|
6554
|
+
}
|
|
6371
6555
|
};
|
|
6372
6556
|
__decorate([
|
|
6373
6557
|
POST({
|
|
@@ -6378,8 +6562,9 @@ __decorate([
|
|
|
6378
6562
|
}),
|
|
6379
6563
|
}),
|
|
6380
6564
|
__param(0, Body()),
|
|
6565
|
+
__param(1, Query()),
|
|
6381
6566
|
__metadata("design:type", Function),
|
|
6382
|
-
__metadata("design:paramtypes", [FormData]),
|
|
6567
|
+
__metadata("design:paramtypes", [FormData, Object]),
|
|
6383
6568
|
__metadata("design:returntype", Object)
|
|
6384
6569
|
], BaseController.prototype, "uploadFormDataToServer", null);
|
|
6385
6570
|
BaseController = __decorate([
|
|
@@ -6411,7 +6596,7 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
6411
6596
|
else {
|
|
6412
6597
|
Helpers.error(`Entity class not provided for controller ${ClassHelpers.getName(this)}.
|
|
6413
6598
|
|
|
6414
|
-
Please provide entity as class
|
|
6599
|
+
Please provide entity as class property entityClassFn:
|
|
6415
6600
|
|
|
6416
6601
|
class ${ClassHelpers.getName(this)} extends BaseCrudController<Entity> {
|
|
6417
6602
|
// ...
|
|
@@ -6558,11 +6743,20 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
6558
6743
|
//#endregion
|
|
6559
6744
|
}
|
|
6560
6745
|
//#endregion
|
|
6746
|
+
//#region bulk delete
|
|
6747
|
+
clearTable() {
|
|
6748
|
+
//#region @websqlFunc
|
|
6749
|
+
return async () => {
|
|
6750
|
+
await this.db.clear();
|
|
6751
|
+
};
|
|
6752
|
+
//#endregion
|
|
6753
|
+
}
|
|
6754
|
+
//#endregion
|
|
6561
6755
|
//#region create
|
|
6562
|
-
|
|
6756
|
+
save(item) {
|
|
6563
6757
|
//#region @websqlFunc
|
|
6564
6758
|
return async () => {
|
|
6565
|
-
const model = await this.db.
|
|
6759
|
+
const model = await this.db.save(item);
|
|
6566
6760
|
return model;
|
|
6567
6761
|
};
|
|
6568
6762
|
//#endregion
|
|
@@ -6579,9 +6773,9 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
6579
6773
|
}
|
|
6580
6774
|
};
|
|
6581
6775
|
__decorate([
|
|
6582
|
-
GET(
|
|
6583
|
-
__param(0,
|
|
6584
|
-
__param(1,
|
|
6776
|
+
GET(),
|
|
6777
|
+
__param(0, Query(`id`)),
|
|
6778
|
+
__param(1, Query(`property`)),
|
|
6585
6779
|
__param(2, Query('alreadyLength')),
|
|
6586
6780
|
__metadata("design:type", Function),
|
|
6587
6781
|
__metadata("design:paramtypes", [Object, String, Number]),
|
|
@@ -6603,23 +6797,23 @@ __decorate([
|
|
|
6603
6797
|
__metadata("design:returntype", Object)
|
|
6604
6798
|
], BaseCrudController.prototype, "getAll", null);
|
|
6605
6799
|
__decorate([
|
|
6606
|
-
GET(
|
|
6607
|
-
__param(0,
|
|
6800
|
+
GET(),
|
|
6801
|
+
__param(0, Query(`id`)),
|
|
6608
6802
|
__metadata("design:type", Function),
|
|
6609
6803
|
__metadata("design:paramtypes", [Object]),
|
|
6610
6804
|
__metadata("design:returntype", Object)
|
|
6611
6805
|
], BaseCrudController.prototype, "getBy", null);
|
|
6612
6806
|
__decorate([
|
|
6613
|
-
PUT(
|
|
6614
|
-
__param(0,
|
|
6807
|
+
PUT(),
|
|
6808
|
+
__param(0, Query(`id`)),
|
|
6615
6809
|
__param(1, Body()),
|
|
6616
6810
|
__metadata("design:type", Function),
|
|
6617
6811
|
__metadata("design:paramtypes", [Object, Object]),
|
|
6618
6812
|
__metadata("design:returntype", Object)
|
|
6619
6813
|
], BaseCrudController.prototype, "updateById", null);
|
|
6620
6814
|
__decorate([
|
|
6621
|
-
PATCH(
|
|
6622
|
-
__param(0,
|
|
6815
|
+
PATCH(),
|
|
6816
|
+
__param(0, Query(`id`)),
|
|
6623
6817
|
__param(1, Body()),
|
|
6624
6818
|
__metadata("design:type", Function),
|
|
6625
6819
|
__metadata("design:paramtypes", [Object, Object]),
|
|
@@ -6633,26 +6827,32 @@ __decorate([
|
|
|
6633
6827
|
__metadata("design:returntype", Object)
|
|
6634
6828
|
], BaseCrudController.prototype, "bulkUpdate", null);
|
|
6635
6829
|
__decorate([
|
|
6636
|
-
DELETE(
|
|
6637
|
-
__param(0,
|
|
6830
|
+
DELETE(),
|
|
6831
|
+
__param(0, Query(`id`)),
|
|
6638
6832
|
__metadata("design:type", Function),
|
|
6639
|
-
__metadata("design:paramtypes", [
|
|
6833
|
+
__metadata("design:paramtypes", [Object]),
|
|
6640
6834
|
__metadata("design:returntype", Object)
|
|
6641
6835
|
], BaseCrudController.prototype, "deleteById", null);
|
|
6642
6836
|
__decorate([
|
|
6643
|
-
DELETE(
|
|
6644
|
-
__param(0,
|
|
6837
|
+
DELETE(),
|
|
6838
|
+
__param(0, Query(`ids`)),
|
|
6645
6839
|
__metadata("design:type", Function),
|
|
6646
6840
|
__metadata("design:paramtypes", [Array]),
|
|
6647
6841
|
__metadata("design:returntype", Object)
|
|
6648
6842
|
], BaseCrudController.prototype, "bulkDelete", null);
|
|
6843
|
+
__decorate([
|
|
6844
|
+
DELETE(),
|
|
6845
|
+
__metadata("design:type", Function),
|
|
6846
|
+
__metadata("design:paramtypes", []),
|
|
6847
|
+
__metadata("design:returntype", Object)
|
|
6848
|
+
], BaseCrudController.prototype, "clearTable", null);
|
|
6649
6849
|
__decorate([
|
|
6650
6850
|
POST(),
|
|
6651
6851
|
__param(0, Body()),
|
|
6652
6852
|
__metadata("design:type", Function),
|
|
6653
6853
|
__metadata("design:paramtypes", [Object]),
|
|
6654
6854
|
__metadata("design:returntype", Object)
|
|
6655
|
-
], BaseCrudController.prototype, "
|
|
6855
|
+
], BaseCrudController.prototype, "save", null);
|
|
6656
6856
|
__decorate([
|
|
6657
6857
|
POST(),
|
|
6658
6858
|
__param(0, Body()),
|
|
@@ -6919,6 +7119,7 @@ var Http;
|
|
|
6919
7119
|
Http.DELETE = DELETE;
|
|
6920
7120
|
Http.PATCH = PATCH;
|
|
6921
7121
|
Http.HEAD = HEAD;
|
|
7122
|
+
Http.HTML = HTML;
|
|
6922
7123
|
Http.Response = Models$1.HttpResponse;
|
|
6923
7124
|
let Param;
|
|
6924
7125
|
(function (Param) {
|
|
@@ -6933,6 +7134,11 @@ var Http;
|
|
|
6933
7134
|
// TODO export all things
|
|
6934
7135
|
var Taon;
|
|
6935
7136
|
(function (Taon) {
|
|
7137
|
+
Taon.error = (opt) => {
|
|
7138
|
+
throw () => {
|
|
7139
|
+
return opt;
|
|
7140
|
+
};
|
|
7141
|
+
};
|
|
6936
7142
|
Taon.Http = Http;
|
|
6937
7143
|
Taon.Base = Base;
|
|
6938
7144
|
Taon.Orm = Orm;
|
|
@@ -6986,5 +7192,5 @@ var Taon;
|
|
|
6986
7192
|
* Generated bundle index. Do not edit.
|
|
6987
7193
|
*/
|
|
6988
7194
|
|
|
6989
|
-
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 };
|
|
7195
|
+
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 };
|
|
6990
7196
|
//# sourceMappingURL=taon.mjs.map
|