taon 21.0.52 → 21.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/package.json +1 -1
- package/browser-prod/package.json +1 -1
- package/icon-menu-taon.svg +15 -15
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +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-abstract-entity.js +19 -0
- package/lib-prod/base-classes/base-angular-service.js +84 -0
- package/lib-prod/base-classes/base-class.js +35 -0
- package/lib-prod/base-classes/{base-context.ts → base-context.js} +13 -15
- package/lib-prod/base-classes/base-controller.js +154 -0
- package/lib-prod/base-classes/base-crud-controller.js +264 -0
- package/lib-prod/base-classes/base-custom-repository.js +9 -0
- package/lib-prod/base-classes/{base-electron-service.ts → base-electron-service.js} +1 -12
- package/lib-prod/base-classes/base-entity.js +22 -0
- package/lib-prod/base-classes/base-file-upload.middleware.js +75 -0
- package/lib-prod/base-classes/base-injector.js +184 -0
- package/lib-prod/base-classes/base-middleware.js +9 -0
- package/lib-prod/base-classes/base-migration.js +20 -0
- package/lib-prod/base-classes/{base-provider.ts → base-provider.js} +2 -2
- package/lib-prod/base-classes/base-repository.js +617 -0
- package/lib-prod/base-classes/base-subscriber-for-entity.js +145 -0
- package/lib-prod/base-classes/{base.ts → base.js} +2 -15
- package/lib-prod/{build-info._auto-generated_.ts → build-info._auto-generated_.js} +1 -2
- package/lib-prod/config/controller-config.js +28 -0
- package/lib-prod/config/controller-options.js +3 -0
- package/lib-prod/config/method-config.js +7 -0
- package/lib-prod/config/param-config.js +3 -0
- package/lib-prod/constants.js +33 -0
- package/lib-prod/context-db-migrations.js +342 -0
- package/lib-prod/create-context.js +217 -0
- package/lib-prod/decorators/classes/controller-decorator.js +17 -0
- package/lib-prod/decorators/classes/entity-decorator.js +28 -0
- package/lib-prod/decorators/classes/middleware-decorator.js +16 -0
- package/lib-prod/decorators/classes/migration-decorator.js +15 -0
- package/lib-prod/decorators/classes/provider-decorator.js +15 -0
- package/lib-prod/decorators/classes/repository-decorator.js +15 -0
- package/lib-prod/decorators/classes/subscriber-decorator.js +15 -0
- package/lib-prod/decorators/decorator-abstract-opt.js +2 -0
- package/lib-prod/decorators/http/http-decorators.js +20 -0
- package/lib-prod/decorators/http/http-methods-decorators.js +102 -0
- package/lib-prod/decorators/http/http-params-decorators.js +42 -0
- package/lib-prod/dependency-injection/di-container.js +30 -0
- package/lib-prod/endpoint-context-storage.js +31 -0
- package/lib-prod/endpoint-context.js +2397 -0
- package/lib-prod/entity-process.js +225 -0
- package/lib-prod/env/{env.angular-node-app.ts → env.angular-node-app.js} +1 -1
- package/lib-prod/env/{env.docs-webapp.ts → env.docs-webapp.js} +1 -1
- package/lib-prod/env/{env.electron-app.ts → env.electron-app.js} +1 -1
- package/lib-prod/env/{env.mobile-app.ts → env.mobile-app.js} +1 -1
- package/lib-prod/env/{env.npm-lib-and-cli-tool.ts → env.npm-lib-and-cli-tool.js} +1 -1
- package/lib-prod/env/{env.vscode-plugin.ts → env.vscode-plugin.js} +1 -1
- package/lib-prod/express-types.js +1 -0
- package/lib-prod/formly/formly.models.js +1 -0
- package/lib-prod/formly/fromly.js +205 -0
- package/lib-prod/formly/type-from-entity.js +51 -0
- package/lib-prod/get-response-value.js +22 -0
- package/lib-prod/global-state/taon-global-state/{index.ts → index.js} +2 -2
- package/lib-prod/global-state/taon-global-state/{taon-global-state.abstract.context.ts → taon-global-state.abstract.context.js} +9 -11
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +7 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +42 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +35 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +12 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +44 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +12 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +46 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +22 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +11 -0
- package/lib-prod/global-state/taon-transaction-registry/{index.ts → index.js} +2 -2
- package/lib-prod/global-state/taon-transaction-registry/{taon-transaction-registry.abstract.context.ts → taon-transaction-registry.abstract.context.js} +10 -12
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +5 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +36 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +36 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +12 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +7 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +12 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +31 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +22 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +5 -0
- package/lib-prod/helpers/class-helpers.js +228 -0
- package/lib-prod/helpers/clone-obj.js +17 -0
- package/lib-prod/helpers/taon-helpers.js +147 -0
- package/lib-prod/{index._auto-generated_.ts → index._auto-generated_.js} +1 -1
- package/lib-prod/index.js +252 -0
- package/lib-prod/{inject.ts → inject.js} +35 -57
- package/lib-prod/migrations/index.js +2 -0
- package/lib-prod/migrations/{migrations_index._auto-generated_.ts → migrations_index._auto-generated_.js} +0 -2
- package/lib-prod/models.js +78 -0
- package/lib-prod/orm/columns.js +64 -0
- package/lib-prod/orm/index.js +56 -0
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.js +198 -0
- package/lib-prod/realtime/realtime-core.js +81 -0
- package/lib-prod/realtime/realtime-server.js +237 -0
- package/lib-prod/realtime/realtime-strategy/{index.ts → index.js} +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +280 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +289 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +27 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +11 -0
- package/lib-prod/realtime/realtime-subs-manager.js +88 -0
- package/lib-prod/realtime/realtime.models.js +2 -0
- package/lib-prod/symbols.js +108 -0
- package/lib-prod/ui/index.js +1 -0
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -0
- package/lib-prod/validators.js +80 -0
- package/lib-prod.split-namespaces.json +31 -91
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
- package/lib-prod/base-classes/base-abstract-entity.ts +0 -34
- package/lib-prod/base-classes/base-angular-service.ts +0 -107
- package/lib-prod/base-classes/base-class.ts +0 -46
- package/lib-prod/base-classes/base-controller.ts +0 -240
- package/lib-prod/base-classes/base-crud-controller.ts +0 -298
- package/lib-prod/base-classes/base-custom-repository.ts +0 -10
- package/lib-prod/base-classes/base-entity.ts +0 -28
- package/lib-prod/base-classes/base-file-upload.middleware.ts +0 -92
- package/lib-prod/base-classes/base-injector.ts +0 -278
- package/lib-prod/base-classes/base-middleware.ts +0 -71
- package/lib-prod/base-classes/base-migration.ts +0 -26
- package/lib-prod/base-classes/base-repository.ts +0 -942
- package/lib-prod/base-classes/base-subscriber-for-entity.ts +0 -196
- package/lib-prod/config/controller-config.ts +0 -58
- package/lib-prod/config/controller-options.ts +0 -19
- package/lib-prod/config/method-config.ts +0 -55
- package/lib-prod/config/param-config.ts +0 -16
- package/lib-prod/constants.ts +0 -63
- package/lib-prod/context-db-migrations.ts +0 -488
- package/lib-prod/create-context.ts +0 -345
- package/lib-prod/decorators/classes/controller-decorator.ts +0 -25
- package/lib-prod/decorators/classes/entity-decorator.ts +0 -57
- package/lib-prod/decorators/classes/middleware-decorator.ts +0 -29
- package/lib-prod/decorators/classes/migration-decorator.ts +0 -27
- package/lib-prod/decorators/classes/provider-decorator.ts +0 -28
- package/lib-prod/decorators/classes/repository-decorator.ts +0 -26
- package/lib-prod/decorators/classes/subscriber-decorator.ts +0 -28
- package/lib-prod/decorators/decorator-abstract-opt.ts +0 -4
- package/lib-prod/decorators/http/http-decorators.ts +0 -26
- package/lib-prod/decorators/http/http-methods-decorators.ts +0 -275
- package/lib-prod/decorators/http/http-params-decorators.ts +0 -105
- package/lib-prod/dependency-injection/di-container.ts +0 -39
- package/lib-prod/endpoint-context-storage.ts +0 -47
- package/lib-prod/endpoint-context.ts +0 -3110
- package/lib-prod/entity-process.ts +0 -286
- package/lib-prod/express-types.ts +0 -4
- package/lib-prod/formly/formly.models.ts +0 -7
- package/lib-prod/formly/fromly.ts +0 -261
- package/lib-prod/formly/type-from-entity.ts +0 -80
- package/lib-prod/get-response-value.ts +0 -30
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.ts +0 -9
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.ts +0 -44
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.ts +0 -40
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.ts +0 -12
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.ts +0 -48
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.ts +0 -16
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.ts +0 -47
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.ts +0 -18
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.ts +0 -21
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.ts +0 -7
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.ts +0 -38
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.ts +0 -54
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.ts +0 -12
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.ts +0 -6
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.ts +0 -16
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.ts +0 -29
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.ts +0 -20
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.ts +0 -9
- package/lib-prod/helpers/class-helpers.ts +0 -315
- package/lib-prod/helpers/clone-obj.ts +0 -24
- package/lib-prod/helpers/taon-helpers.ts +0 -181
- package/lib-prod/index.ts +0 -323
- package/lib-prod/lib-info.md +0 -8
- package/lib-prod/migrations/index.ts +0 -2
- package/lib-prod/migrations/migrations-info.md +0 -6
- package/lib-prod/models.ts +0 -427
- package/lib-prod/orm/columns.ts +0 -121
- package/lib-prod/orm/index.ts +0 -62
- package/lib-prod/realtime/realtime-client.ts +0 -288
- package/lib-prod/realtime/realtime-core.ts +0 -134
- package/lib-prod/realtime/realtime-server.ts +0 -398
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.ts +0 -344
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.ts +0 -349
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.ts +0 -30
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.ts +0 -21
- package/lib-prod/realtime/realtime-subs-manager.ts +0 -127
- package/lib-prod/realtime/realtime.models.ts +0 -33
- package/lib-prod/symbols.ts +0 -136
- package/lib-prod/ui/index.ts +0 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.ts +0 -1
- package/lib-prod/validators.ts +0 -103
- /package/lib-prod/env/{index.ts → index.js} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { CreateDateColumn, CustomColumn } from '../../orm/columns';
|
|
3
|
+
import { TaonGlobalStateDefaultsValues } from './taon-global-state.constants';
|
|
4
|
+
import { TaonBaseAbstractEntity } from '../../base-classes/base-abstract-entity';
|
|
5
|
+
import { TaonEntity } from '../../decorators/classes/entity-decorator';
|
|
6
|
+
//#endregion
|
|
7
|
+
let TAON_GLOBAL_STATE = class TAON_GLOBAL_STATE extends TaonBaseAbstractEntity {
|
|
8
|
+
};
|
|
9
|
+
__decorate([
|
|
10
|
+
CustomColumn({
|
|
11
|
+
type: 'varchar',
|
|
12
|
+
length: 20,
|
|
13
|
+
nullable: false,
|
|
14
|
+
default: TaonGlobalStateDefaultsValues.status,
|
|
15
|
+
})
|
|
16
|
+
//#endregion
|
|
17
|
+
], TAON_GLOBAL_STATE.prototype, "status", void 0);
|
|
18
|
+
__decorate([
|
|
19
|
+
CreateDateColumn()
|
|
20
|
+
//#endregion
|
|
21
|
+
], TAON_GLOBAL_STATE.prototype, "createdAt", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
CustomColumn({
|
|
24
|
+
type: 'int',
|
|
25
|
+
nullable: true,
|
|
26
|
+
})
|
|
27
|
+
//#endregion
|
|
28
|
+
], TAON_GLOBAL_STATE.prototype, "secondsBeforeReadonly", void 0);
|
|
29
|
+
TAON_GLOBAL_STATE = __decorate([
|
|
30
|
+
TaonEntity({
|
|
31
|
+
className: 'TAON_GLOBAL_STATE',
|
|
32
|
+
createTable: true,
|
|
33
|
+
})
|
|
34
|
+
], TAON_GLOBAL_STATE);
|
|
35
|
+
export { TAON_GLOBAL_STATE };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { TaonBaseMiddleware } from '../../base-classes/base-middleware';
|
|
3
|
+
import { TaonMiddleware } from '../../decorators/classes/middleware-decorator';
|
|
4
|
+
//#endregion
|
|
5
|
+
let TaonGlobalStateMiddleware = class TaonGlobalStateMiddleware extends TaonBaseMiddleware {
|
|
6
|
+
};
|
|
7
|
+
TaonGlobalStateMiddleware = __decorate([
|
|
8
|
+
TaonMiddleware({
|
|
9
|
+
className: 'TaonGlobalStateMiddleware',
|
|
10
|
+
})
|
|
11
|
+
], TaonGlobalStateMiddleware);
|
|
12
|
+
export { TaonGlobalStateMiddleware };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export var TaonGlobalStateStatus;
|
|
2
|
+
(function (TaonGlobalStateStatus) {
|
|
3
|
+
TaonGlobalStateStatus["NORMAL"] = "normal";
|
|
4
|
+
/**
|
|
5
|
+
* no new transactions allowed
|
|
6
|
+
* existing ones may finish
|
|
7
|
+
*/
|
|
8
|
+
TaonGlobalStateStatus["DRAINING"] = "draining";
|
|
9
|
+
/**
|
|
10
|
+
* DB is readonly
|
|
11
|
+
* app is readonly (no writes, no side effects)
|
|
12
|
+
*/
|
|
13
|
+
TaonGlobalStateStatus["READONLY"] = "readonly";
|
|
14
|
+
/**
|
|
15
|
+
* Db and app still readonly - migration in progress
|
|
16
|
+
*/
|
|
17
|
+
TaonGlobalStateStatus["MIGRATING"] = "migrating";
|
|
18
|
+
/**
|
|
19
|
+
* emergency stop / maintenance mode
|
|
20
|
+
*/
|
|
21
|
+
TaonGlobalStateStatus["FROZEN"] = "frozen";
|
|
22
|
+
})(TaonGlobalStateStatus || (TaonGlobalStateStatus = {}));
|
|
23
|
+
export const allowedTaonGlobalStatusOrders = {
|
|
24
|
+
[TaonGlobalStateStatus.NORMAL]: [
|
|
25
|
+
TaonGlobalStateStatus.DRAINING,
|
|
26
|
+
TaonGlobalStateStatus.FROZEN,
|
|
27
|
+
],
|
|
28
|
+
[TaonGlobalStateStatus.DRAINING]: [
|
|
29
|
+
TaonGlobalStateStatus.READONLY,
|
|
30
|
+
TaonGlobalStateStatus.FROZEN,
|
|
31
|
+
],
|
|
32
|
+
[TaonGlobalStateStatus.READONLY]: [
|
|
33
|
+
TaonGlobalStateStatus.MIGRATING,
|
|
34
|
+
TaonGlobalStateStatus.NORMAL,
|
|
35
|
+
TaonGlobalStateStatus.FROZEN,
|
|
36
|
+
],
|
|
37
|
+
[TaonGlobalStateStatus.MIGRATING]: [
|
|
38
|
+
TaonGlobalStateStatus.READONLY
|
|
39
|
+
],
|
|
40
|
+
[TaonGlobalStateStatus.FROZEN]: [
|
|
41
|
+
TaonGlobalStateStatus.READONLY,
|
|
42
|
+
TaonGlobalStateStatus.NORMAL,
|
|
43
|
+
],
|
|
44
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { TaonBaseProvider } from '../../base-classes/base-provider';
|
|
3
|
+
import { TaonProvider } from '../../decorators/classes/provider-decorator';
|
|
4
|
+
//#endregion
|
|
5
|
+
let TaonGlobalStateProvider = class TaonGlobalStateProvider extends TaonBaseProvider {
|
|
6
|
+
};
|
|
7
|
+
TaonGlobalStateProvider = __decorate([
|
|
8
|
+
TaonProvider({
|
|
9
|
+
className: 'TaonGlobalStateProvider',
|
|
10
|
+
})
|
|
11
|
+
], TaonGlobalStateProvider);
|
|
12
|
+
export { TaonGlobalStateProvider };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { TaonBaseRepository } from '../../base-classes/base-repository';
|
|
3
|
+
import { TaonRepository } from '../../decorators/classes/repository-decorator';
|
|
4
|
+
import { TAON_GLOBAL_STATE } from './taon-global-state.entity';
|
|
5
|
+
import { TaonGlobalStateStatus } from './taon-global-state.models';
|
|
6
|
+
import { TaonGlobalStateUtils__NS__assertAllowedTransition } from './taon-global-state.utils';
|
|
7
|
+
//#endregion
|
|
8
|
+
let TaonGlobalStateRepository = class TaonGlobalStateRepository extends TaonBaseRepository {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.entityClassResolveFn = () => TAON_GLOBAL_STATE;
|
|
12
|
+
}
|
|
13
|
+
async getLastStatus() {
|
|
14
|
+
//#region @websqlFunc
|
|
15
|
+
const lastStatus = await this.findOne({
|
|
16
|
+
order: { createdAt: 'DESC' },
|
|
17
|
+
});
|
|
18
|
+
return lastStatus;
|
|
19
|
+
//#endregion
|
|
20
|
+
}
|
|
21
|
+
async setDraining(secondsBeforeReadonly = 0) {
|
|
22
|
+
//#region @websqlFunc
|
|
23
|
+
await this.transitionTo(TaonGlobalStateStatus.DRAINING);
|
|
24
|
+
if (secondsBeforeReadonly > 0) {
|
|
25
|
+
setTimeout(async () => {
|
|
26
|
+
await this.transitionTo(TaonGlobalStateStatus.READONLY);
|
|
27
|
+
}, secondsBeforeReadonly);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
}
|
|
31
|
+
async transitionTo(next) {
|
|
32
|
+
//#region @websqlFunc
|
|
33
|
+
const current = await this.getLastStatus();
|
|
34
|
+
TaonGlobalStateUtils__NS__assertAllowedTransition(current.status, next);
|
|
35
|
+
const newState = this.create({ status: next });
|
|
36
|
+
await this.save(newState);
|
|
37
|
+
return newState;
|
|
38
|
+
//#endregion
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
TaonGlobalStateRepository = __decorate([
|
|
42
|
+
TaonRepository({
|
|
43
|
+
className: 'TaonGlobalStateRepository',
|
|
44
|
+
})
|
|
45
|
+
], TaonGlobalStateRepository);
|
|
46
|
+
export { TaonGlobalStateRepository };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { TaonBaseSubscriberForEntity } from '../../base-classes/base-subscriber-for-entity';
|
|
3
|
+
import { TaonSubscriber } from '../../decorators/classes/subscriber-decorator';
|
|
4
|
+
import { TAON_GLOBAL_STATE } from './taon-global-state.entity';
|
|
5
|
+
import { TaonGlobalStateProvider } from './taon-global-state.provider';
|
|
6
|
+
//#endregion
|
|
7
|
+
let TaonGlobalStateSubscriber = class TaonGlobalStateSubscriber extends TaonBaseSubscriberForEntity {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.taonGlobalStateProvider = this.injectProvider(TaonGlobalStateProvider);
|
|
11
|
+
}
|
|
12
|
+
listenTo() {
|
|
13
|
+
return TAON_GLOBAL_STATE;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
TaonGlobalStateSubscriber = __decorate([
|
|
17
|
+
TaonSubscriber({
|
|
18
|
+
className: 'TaonGlobalStateSubscriber',
|
|
19
|
+
// allowedEvents: ['afterUpdate'],
|
|
20
|
+
})
|
|
21
|
+
], TaonGlobalStateSubscriber);
|
|
22
|
+
export { TaonGlobalStateSubscriber };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { allowedTaonGlobalStatusOrders, } from './taon-global-state.models';
|
|
2
|
+
//namespace TaonGlobalStateUtils
|
|
3
|
+
// export function isActive(state: string): state is TaonGlobalStateStatus {
|
|
4
|
+
// return state === 'active';
|
|
5
|
+
// }
|
|
6
|
+
export const TaonGlobalStateUtils__NS__assertAllowedTransition = (from, to) => {
|
|
7
|
+
if (!allowedTaonGlobalStatusOrders[from]?.includes(to)) {
|
|
8
|
+
throw new Error(`Invalid state transition: ${from} → ${to}`);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
//end of namespace TaonGlobalStateUtils
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* */
|
|
1
|
+
/* */
|
|
2
2
|
export * from './taon-transaction-registry.abstract.context';
|
|
3
3
|
export * from './taon-transaction-registry.constants';
|
|
4
4
|
export * from './taon-transaction-registry.controller';
|
|
@@ -8,4 +8,4 @@ export * from './taon-transaction-registry.models';
|
|
|
8
8
|
export * from './taon-transaction-registry.provider';
|
|
9
9
|
export * from './taon-transaction-registry.repository';
|
|
10
10
|
export * from './taon-transaction-registry.subscriber';
|
|
11
|
-
export * from './taon-transaction-registry.utils';
|
|
11
|
+
export * from './taon-transaction-registry.utils';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
//#region imports
|
|
2
2
|
import { TaonBaseContext } from '../../base-classes/base-context';
|
|
3
3
|
import { createContext } from '../../create-context';
|
|
4
|
-
|
|
5
4
|
import { TaonTransactionRegistryController } from './taon-transaction-registry.controller';
|
|
6
5
|
import { TAON_TANSACTION_REGISTRY } from './taon-transaction-registry.entity';
|
|
7
6
|
import { TaonTransactionRegistryMiddleware } from './taon-transaction-registry.middleware';
|
|
@@ -9,15 +8,14 @@ import { TaonTransactionRegistryProvider } from './taon-transaction-registry.pro
|
|
|
9
8
|
import { TaonTransactionRegistryRepository } from './taon-transaction-registry.repository';
|
|
10
9
|
import { TaonTransactionRegistrySubscriber } from './taon-transaction-registry.subscriber';
|
|
11
10
|
//#endregion
|
|
12
|
-
|
|
13
11
|
export const TaonTransactionRegistryContext = createContext(() => ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}));
|
|
12
|
+
contextName: 'TaonTransactionRegistryContext',
|
|
13
|
+
abstract: true,
|
|
14
|
+
contexts: { TaonBaseContext },
|
|
15
|
+
entities: { TAON_TANSACTION_REGISTRY },
|
|
16
|
+
controllers: { TaonTransactionRegistryController },
|
|
17
|
+
repositories: { TaonTransactionRegistryRepository },
|
|
18
|
+
providers: { TaonTransactionRegistryProvider },
|
|
19
|
+
middlewares: { TaonTransactionRegistryMiddleware },
|
|
20
|
+
subscribers: { TaonTransactionRegistrySubscriber },
|
|
21
|
+
}));
|
package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { TaonController } from '../../decorators/classes/controller-decorator';
|
|
3
|
+
import { TaonBaseCrudController } from '../../base-classes/base-crud-controller';
|
|
4
|
+
import { Query } from '../../decorators/http/http-params-decorators';
|
|
5
|
+
import { POST } from '../../decorators/http/http-methods-decorators';
|
|
6
|
+
import { TAON_TANSACTION_REGISTRY } from './taon-transaction-registry.entity';
|
|
7
|
+
import { TaonTransactionRegistryRepository } from './taon-transaction-registry.repository';
|
|
8
|
+
//#endregion
|
|
9
|
+
let TaonTransactionRegistryController = class TaonTransactionRegistryController extends TaonBaseCrudController {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.entityClassResolveFn = () => TAON_TANSACTION_REGISTRY;
|
|
13
|
+
this.taonTransactionRegistryRepository = this.injectCustomRepo(TaonTransactionRegistryRepository);
|
|
14
|
+
//#endregion
|
|
15
|
+
}
|
|
16
|
+
//#region methods & getters / hello world
|
|
17
|
+
startTransaction(yourName) {
|
|
18
|
+
//#region @websqlFunc
|
|
19
|
+
return async (req, res) => {
|
|
20
|
+
// TODO @LAST
|
|
21
|
+
// return this.taonTransactionRegistryRepository.startTransaction(yourName);
|
|
22
|
+
return void 0;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
__decorate([
|
|
28
|
+
POST(),
|
|
29
|
+
__param(0, Query('serviceName'))
|
|
30
|
+
], TaonTransactionRegistryController.prototype, "startTransaction", null);
|
|
31
|
+
TaonTransactionRegistryController = __decorate([
|
|
32
|
+
TaonController({
|
|
33
|
+
className: 'TaonTransactionRegistryController',
|
|
34
|
+
})
|
|
35
|
+
], TaonTransactionRegistryController);
|
|
36
|
+
export { TaonTransactionRegistryController };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { CreateDateColumn, NumberColumn, String100Column, String20Column, } from '../../orm/columns';
|
|
3
|
+
import { DateTimeColumn } from '../../orm/columns';
|
|
4
|
+
import { TaonBaseAbstractEntity } from '../../base-classes/base-abstract-entity';
|
|
5
|
+
import { TaonEntity } from '../../decorators/classes/entity-decorator';
|
|
6
|
+
import { TaonTransactionRegistryState } from './taon-transaction-registry.models';
|
|
7
|
+
//#endregion
|
|
8
|
+
let TAON_TANSACTION_REGISTRY = class TAON_TANSACTION_REGISTRY extends TaonBaseAbstractEntity {
|
|
9
|
+
};
|
|
10
|
+
__decorate([
|
|
11
|
+
NumberColumn()
|
|
12
|
+
//#endregion
|
|
13
|
+
], TAON_TANSACTION_REGISTRY.prototype, "workerIndex", void 0);
|
|
14
|
+
__decorate([
|
|
15
|
+
String100Column()
|
|
16
|
+
//#endregion
|
|
17
|
+
], TAON_TANSACTION_REGISTRY.prototype, "contextName", void 0);
|
|
18
|
+
__decorate([
|
|
19
|
+
CreateDateColumn()
|
|
20
|
+
//#endregion
|
|
21
|
+
], TAON_TANSACTION_REGISTRY.prototype, "startedAt", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
DateTimeColumn()
|
|
24
|
+
//#endregion
|
|
25
|
+
], TAON_TANSACTION_REGISTRY.prototype, "finishedAt", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
String20Column(TaonTransactionRegistryState.RUNNING)
|
|
28
|
+
//#endregion
|
|
29
|
+
], TAON_TANSACTION_REGISTRY.prototype, "state", void 0);
|
|
30
|
+
TAON_TANSACTION_REGISTRY = __decorate([
|
|
31
|
+
TaonEntity({
|
|
32
|
+
className: 'TAON_TANSACTION_REGISTRY',
|
|
33
|
+
createTable: true,
|
|
34
|
+
})
|
|
35
|
+
], TAON_TANSACTION_REGISTRY);
|
|
36
|
+
export { TAON_TANSACTION_REGISTRY };
|
package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { TaonBaseMiddleware } from '../../base-classes/base-middleware';
|
|
3
|
+
import { TaonMiddleware } from '../../decorators/classes/middleware-decorator';
|
|
4
|
+
//#endregion
|
|
5
|
+
let TaonTransactionRegistryMiddleware = class TaonTransactionRegistryMiddleware extends TaonBaseMiddleware {
|
|
6
|
+
};
|
|
7
|
+
TaonTransactionRegistryMiddleware = __decorate([
|
|
8
|
+
TaonMiddleware({
|
|
9
|
+
className: 'TaonTransactionRegistryMiddleware',
|
|
10
|
+
})
|
|
11
|
+
], TaonTransactionRegistryMiddleware);
|
|
12
|
+
export { TaonTransactionRegistryMiddleware };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var TaonTransactionRegistryState;
|
|
2
|
+
(function (TaonTransactionRegistryState) {
|
|
3
|
+
TaonTransactionRegistryState["RUNNING"] = "running";
|
|
4
|
+
TaonTransactionRegistryState["COMMITTED"] = "committed";
|
|
5
|
+
TaonTransactionRegistryState["ROLLED_BACK"] = "rolled_back";
|
|
6
|
+
TaonTransactionRegistryState["ABANDONED"] = "abandoned";
|
|
7
|
+
})(TaonTransactionRegistryState || (TaonTransactionRegistryState = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { TaonBaseProvider } from '../../base-classes/base-provider';
|
|
3
|
+
import { TaonProvider } from '../../decorators/classes/provider-decorator';
|
|
4
|
+
//#endregion
|
|
5
|
+
let TaonTransactionRegistryProvider = class TaonTransactionRegistryProvider extends TaonBaseProvider {
|
|
6
|
+
};
|
|
7
|
+
TaonTransactionRegistryProvider = __decorate([
|
|
8
|
+
TaonProvider({
|
|
9
|
+
className: 'TaonTransactionRegistryProvider',
|
|
10
|
+
})
|
|
11
|
+
], TaonTransactionRegistryProvider);
|
|
12
|
+
export { TaonTransactionRegistryProvider };
|
package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { TaonBaseRepository } from '../../base-classes/base-repository';
|
|
3
|
+
import { TaonRepository } from '../../decorators/classes/repository-decorator';
|
|
4
|
+
import { Raw } from 'taon-typeorm/lib-prod';
|
|
5
|
+
import { TAON_TANSACTION_REGISTRY } from './taon-transaction-registry.entity';
|
|
6
|
+
//#endregion
|
|
7
|
+
let TaonTransactionRegistryRepository = class TaonTransactionRegistryRepository extends TaonBaseRepository {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.entityClassResolveFn = () => TAON_TANSACTION_REGISTRY;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* TODO remove this demo example method
|
|
14
|
+
*/
|
|
15
|
+
async countEntitesWithEvenId() {
|
|
16
|
+
//#region @websqlFunc
|
|
17
|
+
const result = await this.count({
|
|
18
|
+
where: {
|
|
19
|
+
id: Raw(alias => `${alias} % 2 = 0`),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
return result;
|
|
23
|
+
//#endregion
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
TaonTransactionRegistryRepository = __decorate([
|
|
27
|
+
TaonRepository({
|
|
28
|
+
className: 'TaonTransactionRegistryRepository',
|
|
29
|
+
})
|
|
30
|
+
], TaonTransactionRegistryRepository);
|
|
31
|
+
export { TaonTransactionRegistryRepository };
|
package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { TaonBaseSubscriberForEntity } from '../../base-classes/base-subscriber-for-entity';
|
|
3
|
+
import { TaonSubscriber } from '../../decorators/classes/subscriber-decorator';
|
|
4
|
+
import { TAON_TANSACTION_REGISTRY } from './taon-transaction-registry.entity';
|
|
5
|
+
import { TaonTransactionRegistryProvider } from './taon-transaction-registry.provider';
|
|
6
|
+
//#endregion
|
|
7
|
+
let TaonTransactionRegistrySubscriber = class TaonTransactionRegistrySubscriber extends TaonBaseSubscriberForEntity {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.taonTransactionRegistryProvider = this.injectProvider(TaonTransactionRegistryProvider);
|
|
11
|
+
}
|
|
12
|
+
listenTo() {
|
|
13
|
+
return TAON_TANSACTION_REGISTRY;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
TaonTransactionRegistrySubscriber = __decorate([
|
|
17
|
+
TaonSubscriber({
|
|
18
|
+
className: 'TaonTransactionRegistrySubscriber',
|
|
19
|
+
// allowedEvents: ['afterUpdate'],
|
|
20
|
+
})
|
|
21
|
+
], TaonTransactionRegistrySubscriber);
|
|
22
|
+
export { TaonTransactionRegistrySubscriber };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import * as FormData from 'form-data'; // @backend
|
|
3
|
+
import { ___NS__isArray, ___NS__isArrayBuffer, ___NS__isBuffer, ___NS__isDate, ___NS__isFunction, ___NS__isNull, ___NS__isObject, ___NS__isRegExp, ___NS__isString, ___NS__isUndefined, ___NS__uniq, Utils__NS__uniqArray } from 'tnp-core/lib-prod';
|
|
4
|
+
import { CLASS } from 'typescript-class-helpers/lib-prod';
|
|
5
|
+
import { controllerConfigFrom, } from '../config/controller-config';
|
|
6
|
+
import { Symbols__NS__classNameStaticProperty, Symbols__NS__fullClassNameStaticProperty, Symbols__NS__metadata, Symbols__NS__orignalClass } from '../symbols';
|
|
7
|
+
import { Validators__NS__classNameVlidation } from '../validators';
|
|
8
|
+
//#endregion
|
|
9
|
+
//namespace ClassHelpers
|
|
10
|
+
//#region get class from name
|
|
11
|
+
/**
|
|
12
|
+
* TODO - repalce in every place when getting class fn from object
|
|
13
|
+
*/
|
|
14
|
+
export const ClassHelpers__NS__getClassFnFromObject = (json) => {
|
|
15
|
+
if (___NS__isUndefined(json) || ___NS__isNull(json)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (json.constructor) {
|
|
19
|
+
return json.constructor;
|
|
20
|
+
}
|
|
21
|
+
const p = Object.getPrototypeOf(json);
|
|
22
|
+
return p && p.constructor && p.constructor.name !== 'Object'
|
|
23
|
+
? p.constructor
|
|
24
|
+
: void 0;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region get name
|
|
28
|
+
export const ClassHelpers__NS__getName = (classFnOrObject) => {
|
|
29
|
+
// exception for FormData
|
|
30
|
+
if (classFnOrObject instanceof FormData) {
|
|
31
|
+
return 'FormData';
|
|
32
|
+
}
|
|
33
|
+
if (!classFnOrObject) {
|
|
34
|
+
console.error('OBJECT OR CLASS', classFnOrObject);
|
|
35
|
+
throw new Error(`Cannot get name from this object or class.`);
|
|
36
|
+
}
|
|
37
|
+
return ((classFnOrObject[Symbols__NS__classNameStaticProperty]
|
|
38
|
+
? classFnOrObject[Symbols__NS__classNameStaticProperty]
|
|
39
|
+
: classFnOrObject?.constructor[Symbols__NS__classNameStaticProperty]) ||
|
|
40
|
+
(___NS__isFunction(classFnOrObject) ? CLASS.getName(classFnOrObject) : void 0));
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export const ClassHelpers__NS__getOrginalClass = (classFnOrObject) => {
|
|
44
|
+
const org = classFnOrObject[Symbols__NS__orignalClass];
|
|
45
|
+
if (!org) {
|
|
46
|
+
return classFnOrObject;
|
|
47
|
+
}
|
|
48
|
+
return ClassHelpers__NS__getOrginalClass(org);
|
|
49
|
+
};
|
|
50
|
+
//#region get full internal name
|
|
51
|
+
export const ClassHelpers__NS__getFullInternalName = (classFnOrObject) => {
|
|
52
|
+
// exception for FormData
|
|
53
|
+
if (!classFnOrObject) {
|
|
54
|
+
throw new Error(`Cannot get name from: ${classFnOrObject}`);
|
|
55
|
+
}
|
|
56
|
+
return ((classFnOrObject[Symbols__NS__fullClassNameStaticProperty]
|
|
57
|
+
? classFnOrObject[Symbols__NS__fullClassNameStaticProperty]
|
|
58
|
+
: classFnOrObject?.constructor[Symbols__NS__fullClassNameStaticProperty]) ||
|
|
59
|
+
void 0);
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region get unique key
|
|
63
|
+
export const ClassHelpers__NS__getUniqueKey = (classFnOrObject) => {
|
|
64
|
+
const classFn = ___NS__isFunction(classFnOrObject)
|
|
65
|
+
? classFnOrObject
|
|
66
|
+
: classFnOrObject.constructor;
|
|
67
|
+
const config = Reflect.getMetadata(Symbols__NS__metadata.options.entity, classFn);
|
|
68
|
+
return config.uniqueKeyProp;
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region is class object
|
|
72
|
+
export const ClassHelpers__NS__isContextClassObject = (obj) => {
|
|
73
|
+
if (!___NS__isObject(obj) ||
|
|
74
|
+
___NS__isArray(obj) ||
|
|
75
|
+
___NS__isRegExp(obj) ||
|
|
76
|
+
___NS__isBuffer(obj) ||
|
|
77
|
+
___NS__isArrayBuffer(obj)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (___NS__isDate(obj)) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
const className = ClassHelpers__NS__getName(obj);
|
|
84
|
+
return ___NS__isString(className) && className !== 'Object';
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region get name
|
|
88
|
+
export const ClassHelpers__NS__setName = (target, className) => {
|
|
89
|
+
// console.log('setName', className, target.name)
|
|
90
|
+
Validators__NS__classNameVlidation(className, target);
|
|
91
|
+
target[Symbols__NS__classNameStaticProperty] = className;
|
|
92
|
+
};
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region has parent with class name
|
|
95
|
+
export const ClassHelpers__NS__hasParentClassWithName = (target, className, targets = []) => {
|
|
96
|
+
if (!target) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
targets.push(target);
|
|
100
|
+
let targetProto = Object.getPrototypeOf(target);
|
|
101
|
+
if (___NS__isFunction(targetProto) &&
|
|
102
|
+
ClassHelpers__NS__getName(targetProto) === className) {
|
|
103
|
+
// console.log(`true "${___NS__first(targets).name}" for ${targets.map(d => d.name).join(',')}`)
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
return ClassHelpers__NS__hasParentClassWithName(targetProto, className, targets);
|
|
107
|
+
};
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region get methods name
|
|
110
|
+
//#region not allowed as method name
|
|
111
|
+
const notAllowedAsMethodName = [
|
|
112
|
+
'length',
|
|
113
|
+
'name',
|
|
114
|
+
'arguments',
|
|
115
|
+
'caller',
|
|
116
|
+
'constructor',
|
|
117
|
+
'apply',
|
|
118
|
+
'bind',
|
|
119
|
+
'call',
|
|
120
|
+
'toString',
|
|
121
|
+
'__defineGetter__',
|
|
122
|
+
'__defineSetter__',
|
|
123
|
+
'hasOwnProperty',
|
|
124
|
+
'__lookupGetter__',
|
|
125
|
+
'__lookupSetter__',
|
|
126
|
+
'isPrototypeOf',
|
|
127
|
+
'propertyIsEnumerable',
|
|
128
|
+
'valueOf',
|
|
129
|
+
'__proto__',
|
|
130
|
+
'toLocaleString',
|
|
131
|
+
];
|
|
132
|
+
//#endregion
|
|
133
|
+
/**
|
|
134
|
+
* Express async handler for middleware functions.
|
|
135
|
+
*/
|
|
136
|
+
export const ClassHelpers__NS__asyncHandler = fn => (req, res, next) => {
|
|
137
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
138
|
+
};
|
|
139
|
+
export const ClassHelpers__NS__getMethodsNames = (classOrClassInstance, allMethodsNames = []) => {
|
|
140
|
+
if (!classOrClassInstance) {
|
|
141
|
+
return Utils__NS__uniqArray(allMethodsNames);
|
|
142
|
+
}
|
|
143
|
+
const isClassFunction = ___NS__isFunction(classOrClassInstance);
|
|
144
|
+
const classFun = isClassFunction
|
|
145
|
+
? classOrClassInstance
|
|
146
|
+
: Object.getPrototypeOf(classOrClassInstance);
|
|
147
|
+
const objectToCheck = isClassFunction
|
|
148
|
+
? classOrClassInstance?.prototype
|
|
149
|
+
: classOrClassInstance;
|
|
150
|
+
const prototypeObj = Object.getPrototypeOf(objectToCheck || {});
|
|
151
|
+
const properties = ___NS__uniq([
|
|
152
|
+
...Object.getOwnPropertyNames(objectToCheck || {}),
|
|
153
|
+
...Object.getOwnPropertyNames(prototypeObj || {}),
|
|
154
|
+
...Object.keys(objectToCheck || {}),
|
|
155
|
+
...Object.keys(prototypeObj || {}),
|
|
156
|
+
]).filter(f => !!f && !notAllowedAsMethodName.includes(f));
|
|
157
|
+
properties
|
|
158
|
+
.filter(methodName => typeof objectToCheck[methodName] === 'function')
|
|
159
|
+
.forEach(p => allMethodsNames.push(p));
|
|
160
|
+
if (!classFun ||
|
|
161
|
+
!classFun.constructor ||
|
|
162
|
+
classFun?.constructor?.name === 'Object') {
|
|
163
|
+
return Utils__NS__uniqArray(allMethodsNames);
|
|
164
|
+
}
|
|
165
|
+
return ClassHelpers__NS__getMethodsNames(Object.getPrototypeOf(classFun), allMethodsNames);
|
|
166
|
+
};
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region get controller configs
|
|
169
|
+
export const ClassHelpers__NS__getControllerConfigs = (target, configs = [], callerTarget) => {
|
|
170
|
+
if (!___NS__isFunction(target)) {
|
|
171
|
+
throw `[typescript-class-helper][getControllerConfigs] Cannot get class config from: ${target}`;
|
|
172
|
+
}
|
|
173
|
+
let config;
|
|
174
|
+
const parentClass = Object.getPrototypeOf(target);
|
|
175
|
+
const parentName = parentClass ? ClassHelpers__NS__getName(parentClass) : void 0;
|
|
176
|
+
const isValidParent = ___NS__isFunction(parentClass) && parentName !== '';
|
|
177
|
+
config = controllerConfigFrom(ClassHelpers__NS__getClassConfig(target));
|
|
178
|
+
configs.push(config);
|
|
179
|
+
return isValidParent
|
|
180
|
+
? ClassHelpers__NS__getControllerConfigs(parentClass, configs, target)
|
|
181
|
+
: configs;
|
|
182
|
+
};
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region ensure configs
|
|
185
|
+
// Ensure ClassConfig on constructor, clone parent if needed
|
|
186
|
+
export const ClassHelpers__NS__ensureClassConfig = (target) => {
|
|
187
|
+
let cfg = Reflect.getOwnMetadata(Symbols__NS__metadata.options.controller, // META_KEYS.class,
|
|
188
|
+
target);
|
|
189
|
+
if (!cfg) {
|
|
190
|
+
cfg = { methods: {} };
|
|
191
|
+
const parent = Object.getPrototypeOf(target);
|
|
192
|
+
if (parent && parent !== Function.prototype) {
|
|
193
|
+
const parentCfg = Reflect.getMetadata(Symbols__NS__metadata.options.controller, // META_KEYS.class,
|
|
194
|
+
parent);
|
|
195
|
+
if (parentCfg) {
|
|
196
|
+
// Deep copy each method config so child gets its own objects
|
|
197
|
+
const clonedMethods = {};
|
|
198
|
+
for (const [k, v] of Object.entries(parentCfg.methods)) {
|
|
199
|
+
clonedMethods[k] = {
|
|
200
|
+
...v,
|
|
201
|
+
parameters: { ...v.parameters }, // shallow clone parameters too
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
cfg = {
|
|
205
|
+
...parentCfg,
|
|
206
|
+
methods: clonedMethods,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.controller, cfg, target);
|
|
211
|
+
}
|
|
212
|
+
return cfg;
|
|
213
|
+
};
|
|
214
|
+
// Ensure MethodConfig inside ClassConfig
|
|
215
|
+
export const ClassHelpers__NS__ensureMethodConfig = (target, propertyKey) => {
|
|
216
|
+
const classCfg = ClassHelpers__NS__ensureClassConfig(target.constructor);
|
|
217
|
+
let methodCfg = classCfg.methods[propertyKey?.toString()];
|
|
218
|
+
if (!methodCfg) {
|
|
219
|
+
methodCfg = { methodName: propertyKey?.toString(), parameters: {} };
|
|
220
|
+
classCfg.methods[propertyKey?.toString()] = methodCfg;
|
|
221
|
+
}
|
|
222
|
+
return methodCfg;
|
|
223
|
+
};
|
|
224
|
+
export const ClassHelpers__NS__getClassConfig = (constructor) => {
|
|
225
|
+
return Reflect.getMetadata(Symbols__NS__metadata.options.controller, constructor);
|
|
226
|
+
};
|
|
227
|
+
//#endregion
|
|
228
|
+
//end of namespace ClassHelpers
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { walk } from 'lodash-walk-object/lib-prod';
|
|
2
|
+
import { ___NS__cloneDeep, ___NS__isFunction, ___NS__isNil, ___NS__isObject, ___NS__merge, ___NS__set } from 'tnp-core/lib-prod';
|
|
3
|
+
export const cloneObj = (override, classFn) => {
|
|
4
|
+
const result = ___NS__merge(new classFn(), ___NS__cloneDeep(this));
|
|
5
|
+
walk.Object(override || {}, (value, lodashPath) => {
|
|
6
|
+
if (___NS__isNil(value) || ___NS__isFunction(value) || ___NS__isObject(value)) {
|
|
7
|
+
// skipping
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
___NS__set(result, lodashPath, value);
|
|
11
|
+
}
|
|
12
|
+
}, {
|
|
13
|
+
walkGetters: false,
|
|
14
|
+
});
|
|
15
|
+
// console.log({result})
|
|
16
|
+
return result;
|
|
17
|
+
};
|