taon 21.0.52 → 21.0.53
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/bin/taon +5 -5
- package/bin/taon-debug +5 -5
- package/bin/taon-debug-brk +4 -4
- 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 +33 -0
- package/lib-prod/base-classes/base-angular-service.js +56 -0
- package/lib-prod/base-classes/base-class.js +37 -0
- package/lib-prod/base-classes/base-context.js +21 -0
- package/lib-prod/base-classes/base-controller.js +162 -0
- package/lib-prod/base-classes/base-crud-controller.js +235 -0
- package/lib-prod/base-classes/base-custom-repository.js +20 -0
- package/lib-prod/base-classes/base-electron-service.js +0 -0
- package/lib-prod/base-classes/base-entity.js +32 -0
- package/lib-prod/base-classes/base-file-upload.middleware.js +78 -0
- package/lib-prod/base-classes/base-injector.js +202 -0
- package/lib-prod/base-classes/base-middleware.js +6 -0
- package/lib-prod/base-classes/base-migration.js +23 -0
- package/lib-prod/base-classes/base-provider.js +6 -0
- package/lib-prod/base-classes/base-repository.js +589 -0
- package/lib-prod/base-classes/base-subscriber-for-entity.js +154 -0
- package/lib-prod/base-classes/base.js +0 -0
- package/lib-prod/build-info._auto-generated_.js +14 -0
- package/lib-prod/config/controller-config.js +28 -0
- package/lib-prod/config/controller-options.js +6 -0
- package/lib-prod/config/method-config.js +9 -0
- package/lib-prod/config/param-config.js +9 -0
- package/lib-prod/constants.js +29 -0
- package/lib-prod/context-db-migrations.js +339 -0
- package/lib-prod/create-context.js +152 -0
- package/lib-prod/decorators/classes/controller-decorator.js +21 -0
- package/lib-prod/decorators/classes/entity-decorator.js +49 -0
- package/lib-prod/decorators/classes/middleware-decorator.js +26 -0
- package/lib-prod/decorators/classes/migration-decorator.js +24 -0
- package/lib-prod/decorators/classes/provider-decorator.js +25 -0
- package/lib-prod/decorators/classes/repository-decorator.js +24 -0
- package/lib-prod/decorators/classes/subscriber-decorator.js +25 -0
- package/lib-prod/decorators/decorator-abstract-opt.js +5 -0
- package/lib-prod/decorators/http/http-decorators.js +5 -0
- package/lib-prod/decorators/http/http-methods-decorators.js +144 -0
- package/lib-prod/decorators/http/http-params-decorators.js +68 -0
- package/lib-prod/dependency-injection/di-container.js +31 -0
- package/lib-prod/endpoint-context-storage.js +36 -0
- package/lib-prod/endpoint-context.js +2033 -0
- package/lib-prod/entity-process.js +214 -0
- package/lib-prod/env/env.angular-node-app.js +130 -0
- package/lib-prod/env/env.docs-webapp.js +130 -0
- package/lib-prod/env/env.electron-app.js +130 -0
- package/lib-prod/env/env.mobile-app.js +130 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +130 -0
- package/lib-prod/env/env.vscode-plugin.js +130 -0
- package/lib-prod/env/index.js +6 -0
- package/lib-prod/express-types.js +0 -0
- package/lib-prod/formly/formly.models.js +0 -0
- package/lib-prod/formly/fromly.js +184 -0
- package/lib-prod/formly/type-from-entity.js +58 -0
- package/lib-prod/get-response-value.js +19 -0
- package/lib-prod/global-state/taon-global-state/index.js +5 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js +20 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +10 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +48 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +48 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +22 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +34 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +22 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +47 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +29 -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.js +10 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js +22 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +8 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +41 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +56 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +22 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +10 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +22 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +36 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +29 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +6 -0
- package/lib-prod/helpers/class-helpers.js +195 -0
- package/lib-prod/helpers/clone-obj.js +21 -0
- package/lib-prod/helpers/taon-helpers.js +129 -0
- package/lib-prod/index._auto-generated_.js +0 -0
- package/lib-prod/index.js +231 -0
- package/lib-prod/inject.js +34 -0
- package/lib-prod/migrations/index.js +1 -0
- package/lib-prod/migrations/migrations_index._auto-generated_.js +0 -0
- package/lib-prod/models.js +109 -0
- package/lib-prod/orm/columns.js +124 -0
- package/lib-prod/orm/index.js +1 -0
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.js +196 -0
- package/lib-prod/realtime/realtime-core.js +82 -0
- package/lib-prod/realtime/realtime-server.js +252 -0
- package/lib-prod/realtime/realtime-strategy/index.js +4 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +226 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +262 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +21 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +14 -0
- package/lib-prod/realtime/realtime-subs-manager.js +96 -0
- package/lib-prod/realtime/realtime.models.js +0 -0
- package/lib-prod/symbols.js +109 -0
- package/lib-prod/ui/index.js +5 -0
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +5 -0
- package/lib-prod/validators.js +74 -0
- 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-context.ts +0 -21
- 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-electron-service.ts +0 -60
- 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-provider.ts +0 -8
- 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/base-classes/base.ts +0 -31
- package/lib-prod/build-info._auto-generated_.ts +0 -27
- 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/env/env.angular-node-app.ts +0 -66
- package/lib-prod/env/env.docs-webapp.ts +0 -66
- package/lib-prod/env/env.electron-app.ts +0 -66
- package/lib-prod/env/env.mobile-app.ts +0 -66
- package/lib-prod/env/env.npm-lib-and-cli-tool.ts +0 -66
- package/lib-prod/env/env.vscode-plugin.ts +0 -66
- package/lib-prod/env/index.ts +0 -6
- 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/index.ts +0 -6
- package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.ts +0 -21
- 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/index.ts +0 -11
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.ts +0 -23
- 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._auto-generated_.ts +0 -5
- package/lib-prod/index.ts +0 -323
- package/lib-prod/inject.ts +0 -111
- 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/migrations/migrations_index._auto-generated_.ts +0 -5
- 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/index.ts +0 -4
- 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
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
import { TaonBaseInjector } from "./base-injector";
|
|
12
|
+
import { TaonSubscriber } from "../decorators/classes/subscriber-decorator";
|
|
13
|
+
let TaonBaseSubscriberForEntity = class extends TaonBaseInjector {
|
|
14
|
+
/**
|
|
15
|
+
* Called after entity is loaded.
|
|
16
|
+
*/
|
|
17
|
+
afterLoad(entity) {
|
|
18
|
+
this.ctx.logDb && console.log(`AFTER ENTITY LOADED: `, entity);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Called before query execution.
|
|
22
|
+
*/
|
|
23
|
+
beforeQuery(event) {
|
|
24
|
+
this.ctx.logDb && console.log(`BEFORE QUERY: `, event.query);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Called after query execution.
|
|
28
|
+
*/
|
|
29
|
+
afterQuery(event) {
|
|
30
|
+
this.ctx.logDb && console.log(`AFTER QUERY: `, event.query);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Called before entity insertion.
|
|
34
|
+
*/
|
|
35
|
+
beforeInsert(event) {
|
|
36
|
+
this.ctx.logDb && console.log(`BEFORE ENTITY INSERTED: `, event.entity);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Called after entity insertion.
|
|
40
|
+
*/
|
|
41
|
+
afterInsert(event) {
|
|
42
|
+
this.ctx.logDb && console.log(`AFTER ENTITY INSERTED: `, event.entity);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Called before entity update.
|
|
46
|
+
*/
|
|
47
|
+
beforeUpdate(event) {
|
|
48
|
+
this.ctx.logDb && console.log(`BEFORE ENTITY UPDATED: `, event.entity);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Called after entity update.
|
|
52
|
+
*/
|
|
53
|
+
afterUpdate(event) {
|
|
54
|
+
this.ctx.logDb && console.log(`AFTER ENTITY UPDATED: `, event.entity);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Called before entity removal.
|
|
58
|
+
*/
|
|
59
|
+
beforeRemove(event) {
|
|
60
|
+
this.ctx.logDb && console.log(
|
|
61
|
+
`BEFORE ENTITY WITH ID ${event.entityId} REMOVED: `,
|
|
62
|
+
event.entity
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Called after entity removal.
|
|
67
|
+
*/
|
|
68
|
+
afterRemove(event) {
|
|
69
|
+
this.ctx.logDb && console.log(
|
|
70
|
+
`AFTER ENTITY WITH ID ${event.entityId} REMOVED: `,
|
|
71
|
+
event.entity
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Called before entity removal.
|
|
76
|
+
*/
|
|
77
|
+
beforeSoftRemove(event) {
|
|
78
|
+
this.ctx.logDb && console.log(
|
|
79
|
+
`BEFORE ENTITY WITH ID ${event.entityId} SOFT REMOVED: `,
|
|
80
|
+
event.entity
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Called after entity removal.
|
|
85
|
+
*/
|
|
86
|
+
afterSoftRemove(event) {
|
|
87
|
+
this.ctx.logDb && console.log(
|
|
88
|
+
`AFTER ENTITY WITH ID ${event.entityId} SOFT REMOVED: `,
|
|
89
|
+
event.entity
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Called before entity recovery.
|
|
94
|
+
*/
|
|
95
|
+
beforeRecover(event) {
|
|
96
|
+
this.ctx.logDb && console.log(
|
|
97
|
+
`BEFORE ENTITY WITH ID ${event.entityId} RECOVERED: `,
|
|
98
|
+
event.entity
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Called after entity recovery.
|
|
103
|
+
*/
|
|
104
|
+
afterRecover(event) {
|
|
105
|
+
this.ctx.logDb && console.log(
|
|
106
|
+
`AFTER ENTITY WITH ID ${event.entityId} RECOVERED: `,
|
|
107
|
+
event.entity
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Called before transaction start.
|
|
112
|
+
*/
|
|
113
|
+
beforeTransactionStart(event) {
|
|
114
|
+
this.ctx.logDb && console.log(`BEFORE TRANSACTION STARTED: `, event);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Called after transaction start.
|
|
118
|
+
*/
|
|
119
|
+
afterTransactionStart(event) {
|
|
120
|
+
this.ctx.logDb && console.log(`AFTER TRANSACTION STARTED: `, event);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Called before transaction commit.
|
|
124
|
+
*/
|
|
125
|
+
beforeTransactionCommit(event) {
|
|
126
|
+
this.ctx.logDb && console.log(`BEFORE TRANSACTION COMMITTED: `, event);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Called after transaction commit.
|
|
130
|
+
*/
|
|
131
|
+
afterTransactionCommit(event) {
|
|
132
|
+
this.ctx.logDb && console.log(`AFTER TRANSACTION COMMITTED: `, event);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Called before transaction rollback.
|
|
136
|
+
*/
|
|
137
|
+
beforeTransactionRollback(event) {
|
|
138
|
+
this.ctx.logDb && console.log(`BEFORE TRANSACTION ROLLBACK: `, event);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Called after transaction rollback.
|
|
142
|
+
*/
|
|
143
|
+
afterTransactionRollback(event) {
|
|
144
|
+
this.ctx.logDb && console.log(`AFTER TRANSACTION ROLLBACK: `, event);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
TaonBaseSubscriberForEntity = __decorateClass([
|
|
148
|
+
TaonSubscriber({
|
|
149
|
+
className: "TaonBaseSubscriberForEntity"
|
|
150
|
+
})
|
|
151
|
+
], TaonBaseSubscriberForEntity);
|
|
152
|
+
export {
|
|
153
|
+
TaonBaseSubscriberForEntity
|
|
154
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const BUILD_FRAMEWORK_CLI_NAME = "tnp";
|
|
2
|
+
const APP_ID = "dev.taon.app";
|
|
3
|
+
const BUILD_BASE_HREF = "";
|
|
4
|
+
const PROJECT_NPM_NAME = "taon";
|
|
5
|
+
const CURRENT_PACKAGE_TAON_VERSION = "v21";
|
|
6
|
+
const CURRENT_PACKAGE_VERSION = "21.0.53";
|
|
7
|
+
export {
|
|
8
|
+
APP_ID,
|
|
9
|
+
BUILD_BASE_HREF,
|
|
10
|
+
BUILD_FRAMEWORK_CLI_NAME,
|
|
11
|
+
CURRENT_PACKAGE_TAON_VERSION,
|
|
12
|
+
CURRENT_PACKAGE_VERSION,
|
|
13
|
+
PROJECT_NPM_NAME
|
|
14
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TaonControllerOptions } from "./controller-options";
|
|
2
|
+
class ControllerConfig extends TaonControllerOptions {
|
|
3
|
+
// ! CLONING WILL CONE DESCRIPTOR OF METHOD AND I NEED IT!
|
|
4
|
+
// public clone(override?: Partial<ControllerConfig>): ControllerConfig {
|
|
5
|
+
// return cloneObj<ControllerConfig>(override, ControllerConfig);
|
|
6
|
+
// }
|
|
7
|
+
}
|
|
8
|
+
const controllerConfigFrom = (partial) => {
|
|
9
|
+
const newObj = partial || {};
|
|
10
|
+
newObj.methods = newObj.methods || {};
|
|
11
|
+
for (const methodName in newObj.methods) {
|
|
12
|
+
if (newObj.methods.hasOwnProperty(methodName)) {
|
|
13
|
+
newObj.methods[methodName] = newObj.methods[methodName] || {};
|
|
14
|
+
const params = newObj.methods[methodName].parameters || {};
|
|
15
|
+
newObj.methods[methodName].parameters = params ? params : {};
|
|
16
|
+
for (const paramName in params) {
|
|
17
|
+
if (params.hasOwnProperty(paramName)) {
|
|
18
|
+
params[paramName] = params[paramName] || {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return newObj;
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
ControllerConfig,
|
|
27
|
+
controllerConfigFrom
|
|
28
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const TaonEntityKeysToOmitArr = [
|
|
2
|
+
"ctrl",
|
|
3
|
+
"clone",
|
|
4
|
+
"__endpoint_context__",
|
|
5
|
+
"ctx",
|
|
6
|
+
"inject",
|
|
7
|
+
"_",
|
|
8
|
+
"relation",
|
|
9
|
+
"relations",
|
|
10
|
+
"inject",
|
|
11
|
+
"injectRepo",
|
|
12
|
+
"injectCustomRepository",
|
|
13
|
+
"injectCustomRepo",
|
|
14
|
+
"injectController",
|
|
15
|
+
"injectCtrl",
|
|
16
|
+
"injectProvider",
|
|
17
|
+
"injectMiddleware"
|
|
18
|
+
];
|
|
19
|
+
let TAON_CONTEXT;
|
|
20
|
+
let CURRENT_HOST_BACKEND_PORT;
|
|
21
|
+
let CURRENT_HOST_URL;
|
|
22
|
+
const apiPrefix = "api";
|
|
23
|
+
export {
|
|
24
|
+
CURRENT_HOST_BACKEND_PORT,
|
|
25
|
+
CURRENT_HOST_URL,
|
|
26
|
+
TAON_CONTEXT,
|
|
27
|
+
TaonEntityKeysToOmitArr,
|
|
28
|
+
apiPrefix
|
|
29
|
+
};
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { Helpers__NS__throwError, UtilsMigrations__NS__getTimestampFromClassName, UtilsMigrations__NS__isValidTimestamp } from "tnp-core/lib-prod";
|
|
2
|
+
import { Models__NS__ClassType } from "./models";
|
|
3
|
+
import { ClassHelpers__NS__getName } from "./helpers/class-helpers";
|
|
4
|
+
import {
|
|
5
|
+
Table,
|
|
6
|
+
TableIndex
|
|
7
|
+
} from "taon-typeorm/lib-prod";
|
|
8
|
+
class ContextDbMigrations {
|
|
9
|
+
//#endregion
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region constructor
|
|
12
|
+
constructor(ctx) {
|
|
13
|
+
this.ctx = ctx;
|
|
14
|
+
}
|
|
15
|
+
//#region fields
|
|
16
|
+
//#region fields / migration table name
|
|
17
|
+
DEFAULT_MIGRATION_TABLE_NAME = "TAON_MIGRATION_META";
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region fields / migration statuses
|
|
20
|
+
MIGRATION_STATUS_COMPLETED = "completed";
|
|
21
|
+
MIGRATION_STATUS_PENDING = "pending";
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region fields / migration table schema
|
|
24
|
+
table = new Table({
|
|
25
|
+
name: this.DEFAULT_MIGRATION_TABLE_NAME,
|
|
26
|
+
columns: [
|
|
27
|
+
{
|
|
28
|
+
name: "id",
|
|
29
|
+
type: "integer",
|
|
30
|
+
isPrimary: true,
|
|
31
|
+
// Mark it as the primary key
|
|
32
|
+
isGenerated: true,
|
|
33
|
+
// Enable auto-generation
|
|
34
|
+
generationStrategy: "increment"
|
|
35
|
+
// Use auto-increment strategy
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "name",
|
|
39
|
+
type: "varchar",
|
|
40
|
+
length: "255",
|
|
41
|
+
isUnique: true,
|
|
42
|
+
// Ensure the name is unique
|
|
43
|
+
isNullable: false
|
|
44
|
+
// Ensure this field is required
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
// context is a part of name
|
|
48
|
+
name: "context",
|
|
49
|
+
type: "varchar",
|
|
50
|
+
length: "255",
|
|
51
|
+
isNullable: false
|
|
52
|
+
// Optional context for migrations (e.g., tenant or module name)
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "applied_at",
|
|
56
|
+
type: "timestamp",
|
|
57
|
+
default: "CURRENT_TIMESTAMP",
|
|
58
|
+
// Automatically set the timestamp
|
|
59
|
+
isNullable: true
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "status",
|
|
63
|
+
type: "varchar",
|
|
64
|
+
length: "50",
|
|
65
|
+
default: `'${this.MIGRATION_STATUS_COMPLETED}'`,
|
|
66
|
+
isNullable: false
|
|
67
|
+
}
|
|
68
|
+
// { // TODO not needed for now
|
|
69
|
+
// name: 'checksum',
|
|
70
|
+
// type: 'varchar',
|
|
71
|
+
// length: '64',
|
|
72
|
+
// isNullable: true, // Optional field to store a hash/checksum of migration file
|
|
73
|
+
// },
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region methods & getters / make sure migration table exists
|
|
78
|
+
async ensureMigrationTableExists() {
|
|
79
|
+
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const queryRunner = this.ctx.connection.createQueryRunner();
|
|
83
|
+
await queryRunner.connect();
|
|
84
|
+
await queryRunner.startTransaction();
|
|
85
|
+
const hasTable = await queryRunner.hasTable(
|
|
86
|
+
this.DEFAULT_MIGRATION_TABLE_NAME
|
|
87
|
+
);
|
|
88
|
+
if (hasTable) {
|
|
89
|
+
this.ctx.logMigrations && console.log(
|
|
90
|
+
`Table ${this.DEFAULT_MIGRATION_TABLE_NAME} already exists.`
|
|
91
|
+
);
|
|
92
|
+
await queryRunner.commitTransaction();
|
|
93
|
+
await queryRunner.release();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
await queryRunner.createTable(this.table);
|
|
98
|
+
await queryRunner.createIndex(
|
|
99
|
+
this.DEFAULT_MIGRATION_TABLE_NAME,
|
|
100
|
+
new TableIndex({
|
|
101
|
+
name: "IDX_NAME",
|
|
102
|
+
columnNames: ["name"]
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
await queryRunner.commitTransaction();
|
|
106
|
+
} catch (error) {
|
|
107
|
+
this.ctx.logMigrations && console.error(
|
|
108
|
+
`Transaction failed [ensureMigrationTableExists], rolling back:`,
|
|
109
|
+
error
|
|
110
|
+
);
|
|
111
|
+
await queryRunner.rollbackTransaction();
|
|
112
|
+
} finally {
|
|
113
|
+
await queryRunner.release();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region methods & getters / revert migration to timestamp
|
|
118
|
+
async logSelectALl(name, queryRunner) {
|
|
119
|
+
console.log(
|
|
120
|
+
name,
|
|
121
|
+
(await queryRunner.query(
|
|
122
|
+
`SELECT * FROM ${this.DEFAULT_MIGRATION_TABLE_NAME} WHERE context = $1`,
|
|
123
|
+
[this.ctx.contextName]
|
|
124
|
+
)).map((m) => m.name)
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
async revertMigrationToTimestamp(timestamp) {
|
|
128
|
+
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (!UtilsMigrations__NS__isValidTimestamp(timestamp)) {
|
|
132
|
+
Helpers__NS__throwError(
|
|
133
|
+
`Invalid timestamp provided for migration revert: ${timestamp}`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
const migrationsClassFns = this.ctx.getClassFunByArr(Models__NS__ClassType.MIGRATION).reverse();
|
|
137
|
+
const migrationClassesInstancesToRevert = migrationsClassFns.map((classFn) => {
|
|
138
|
+
const timestampFromClassName = Number(
|
|
139
|
+
UtilsMigrations__NS__getTimestampFromClassName(
|
|
140
|
+
ClassHelpers__NS__getName(classFn)
|
|
141
|
+
)
|
|
142
|
+
);
|
|
143
|
+
if (timestampFromClassName <= timestamp) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return this.ctx.getInstanceBy(classFn);
|
|
147
|
+
}).filter((f) => !!f).map((f) => f).filter((migrationInstance) => migrationInstance.isReadyToRun());
|
|
148
|
+
const queryRunner = this.ctx.connection.createQueryRunner();
|
|
149
|
+
await queryRunner.connect();
|
|
150
|
+
try {
|
|
151
|
+
await queryRunner.startTransaction();
|
|
152
|
+
const appliedMigrationsForContext = await queryRunner.query(
|
|
153
|
+
`SELECT name FROM ${this.DEFAULT_MIGRATION_TABLE_NAME}
|
|
154
|
+
WHERE status = $1 AND context = $2`,
|
|
155
|
+
[this.MIGRATION_STATUS_COMPLETED, this.ctx.contextName]
|
|
156
|
+
);
|
|
157
|
+
const appliedMigrationsForContextNames = appliedMigrationsForContext.map(
|
|
158
|
+
(m) => m.name
|
|
159
|
+
);
|
|
160
|
+
for (const migrationClassInstance of migrationClassesInstancesToRevert) {
|
|
161
|
+
const migrationName = ClassHelpers__NS__getName(migrationClassInstance);
|
|
162
|
+
if (!appliedMigrationsForContextNames.includes(migrationName)) {
|
|
163
|
+
this.ctx.logMigrations && console.warn(
|
|
164
|
+
`Skipping migration not marked as applied: ${migrationName}`
|
|
165
|
+
);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
this.ctx.logMigrations && console.log(
|
|
169
|
+
`Reverting migration: ${migrationName} , context: ${this.ctx.contextName}`
|
|
170
|
+
);
|
|
171
|
+
await migrationClassInstance.down(queryRunner);
|
|
172
|
+
await queryRunner.query(
|
|
173
|
+
`DELETE FROM ${this.DEFAULT_MIGRATION_TABLE_NAME} WHERE name = $1`,
|
|
174
|
+
[migrationName]
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
await queryRunner.commitTransaction();
|
|
178
|
+
this.ctx.logMigrations && console.log(
|
|
179
|
+
`Migrations successfully reverted to the specified timestamp ${timestamp} .`
|
|
180
|
+
);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
this.ctx.logMigrations && console.error("Transaction failed, rolling back:", error);
|
|
183
|
+
await queryRunner.rollbackTransaction();
|
|
184
|
+
} finally {
|
|
185
|
+
await queryRunner.release();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region methods & getters / clear migration table
|
|
190
|
+
async clearMigrationTable() {
|
|
191
|
+
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const queryRunner = this.ctx.connection.createQueryRunner();
|
|
195
|
+
await queryRunner.connect();
|
|
196
|
+
await queryRunner.startTransaction();
|
|
197
|
+
try {
|
|
198
|
+
await queryRunner.clearTable(this.DEFAULT_MIGRATION_TABLE_NAME);
|
|
199
|
+
await queryRunner.commitTransaction();
|
|
200
|
+
} catch (error) {
|
|
201
|
+
this.ctx.logMigrations && console.error("Transaction failed, rolling back:", error);
|
|
202
|
+
await queryRunner.rollbackTransaction();
|
|
203
|
+
} finally {
|
|
204
|
+
await queryRunner.release();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region methods & getters / mark all migrations as applied
|
|
209
|
+
async markAllMigrationsAsApplied() {
|
|
210
|
+
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const migrationsClassFns = this.ctx.getClassFunByArr(
|
|
214
|
+
Models__NS__ClassType.MIGRATION
|
|
215
|
+
);
|
|
216
|
+
const migrationClassesInstances = migrationsClassFns.map((classFn) => this.ctx.getInstanceBy(classFn)).map((f) => f).filter((migrationInstance) => migrationInstance.isReadyToRun());
|
|
217
|
+
const queryRunner = this.ctx.connection.createQueryRunner();
|
|
218
|
+
await queryRunner.connect();
|
|
219
|
+
try {
|
|
220
|
+
await queryRunner.startTransaction();
|
|
221
|
+
const allMigrationsInDb = await queryRunner.query(
|
|
222
|
+
`SELECT name FROM ${this.DEFAULT_MIGRATION_TABLE_NAME}`
|
|
223
|
+
);
|
|
224
|
+
const allMigrationInDBNames = allMigrationsInDb.map((m) => m.name);
|
|
225
|
+
for (const instance of migrationClassesInstances) {
|
|
226
|
+
const migrationName = ClassHelpers__NS__getName(instance);
|
|
227
|
+
if (allMigrationInDBNames.includes(migrationName)) {
|
|
228
|
+
this.ctx.logMigrations && console.log(`Skipping already applied migration: ${migrationName}`);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
this.ctx.logMigrations && console.log(`Marking migration as applied: ${migrationName}`);
|
|
232
|
+
await queryRunner.query(
|
|
233
|
+
`INSERT INTO ${this.DEFAULT_MIGRATION_TABLE_NAME} (name, status, context, applied_at) VALUES ($1, $2, $3, CURRENT_TIMESTAMP)`,
|
|
234
|
+
[
|
|
235
|
+
migrationName,
|
|
236
|
+
this.MIGRATION_STATUS_COMPLETED,
|
|
237
|
+
instance.ctx.contextName
|
|
238
|
+
]
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
await queryRunner.query(
|
|
242
|
+
`UPDATE ${this.DEFAULT_MIGRATION_TABLE_NAME}
|
|
243
|
+
SET status = $1, applied_at = CURRENT_TIMESTAMP
|
|
244
|
+
WHERE status = $2`,
|
|
245
|
+
[this.MIGRATION_STATUS_COMPLETED, this.MIGRATION_STATUS_PENDING]
|
|
246
|
+
);
|
|
247
|
+
await queryRunner.commitTransaction();
|
|
248
|
+
this.ctx.logMigrations && console.log("All migrations marked as applied.");
|
|
249
|
+
} catch (error) {
|
|
250
|
+
this.ctx.logMigrations && console.error(
|
|
251
|
+
"Failed to mark all migrations as applied, rolling back:",
|
|
252
|
+
error
|
|
253
|
+
);
|
|
254
|
+
await queryRunner.rollbackTransaction();
|
|
255
|
+
} finally {
|
|
256
|
+
await queryRunner.release();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region methods & getters / run all migrations
|
|
261
|
+
async runAllNotCompletedMigrations() {
|
|
262
|
+
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const migrationsClassFns = this.ctx.getClassFunByArr(
|
|
266
|
+
Models__NS__ClassType.MIGRATION
|
|
267
|
+
);
|
|
268
|
+
const migrationClassesInstances = migrationsClassFns.map((classFn) => this.ctx.getInstanceBy(classFn)).map((f) => f).filter((migrationInstance) => migrationInstance.isReadyToRun());
|
|
269
|
+
const queryRunner = this.ctx.connection.createQueryRunner();
|
|
270
|
+
await queryRunner.connect();
|
|
271
|
+
try {
|
|
272
|
+
await queryRunner.startTransaction();
|
|
273
|
+
const appliedMigrationsForContext = await queryRunner.query(
|
|
274
|
+
`SELECT name, status FROM ${this.DEFAULT_MIGRATION_TABLE_NAME} WHERE context = $1`,
|
|
275
|
+
[this.ctx.contextName]
|
|
276
|
+
);
|
|
277
|
+
const pendingMigrationsForContext = appliedMigrationsForContext.filter(
|
|
278
|
+
(m) => m.status === this.MIGRATION_STATUS_PENDING
|
|
279
|
+
);
|
|
280
|
+
for (const pendingContextMigration of pendingMigrationsForContext) {
|
|
281
|
+
const migrationInstance = migrationClassesInstances.find(
|
|
282
|
+
(instance) => ClassHelpers__NS__getName(instance) === pendingContextMigration.name
|
|
283
|
+
);
|
|
284
|
+
if (!migrationInstance) {
|
|
285
|
+
this.ctx.logMigrations && console.warn(
|
|
286
|
+
`Pending migration ${pendingContextMigration.name} not found in loaded migrations.`
|
|
287
|
+
);
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
this.ctx.logMigrations && console.log(
|
|
291
|
+
`Completing pending migration: ${pendingContextMigration.name}`
|
|
292
|
+
);
|
|
293
|
+
await migrationInstance.up(queryRunner);
|
|
294
|
+
await queryRunner.query(
|
|
295
|
+
`UPDATE ${this.DEFAULT_MIGRATION_TABLE_NAME}
|
|
296
|
+
SET status = $1, applied_at = CURRENT_TIMESTAMP
|
|
297
|
+
WHERE name = $2`,
|
|
298
|
+
[this.MIGRATION_STATUS_COMPLETED, pendingContextMigration.name]
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
for (const instance of migrationClassesInstances) {
|
|
302
|
+
const migrationName = ClassHelpers__NS__getName(instance);
|
|
303
|
+
if (appliedMigrationsForContext.some((m) => m.name === migrationName)) {
|
|
304
|
+
this.ctx.logMigrations && console.log(`Skipping already applied migration: ${migrationName}`);
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
this.ctx.logMigrations && console.log(`Applying new migration: ${migrationName}`);
|
|
308
|
+
await queryRunner.query(
|
|
309
|
+
`INSERT INTO ${this.DEFAULT_MIGRATION_TABLE_NAME} (name, status, context, applied_at) VALUES ($1, $2, $3, NULL)`,
|
|
310
|
+
[migrationName, this.MIGRATION_STATUS_PENDING, this.ctx.contextName]
|
|
311
|
+
);
|
|
312
|
+
try {
|
|
313
|
+
await instance.up(queryRunner);
|
|
314
|
+
await queryRunner.query(
|
|
315
|
+
`UPDATE ${this.DEFAULT_MIGRATION_TABLE_NAME} SET status = '${this.MIGRATION_STATUS_COMPLETED}', applied_at = CURRENT_TIMESTAMP WHERE name = $1`,
|
|
316
|
+
[migrationName]
|
|
317
|
+
);
|
|
318
|
+
} catch (error) {
|
|
319
|
+
this.ctx.logMigrations && console.error(`Failed to apply migration: ${migrationName}`, error);
|
|
320
|
+
await queryRunner.query(
|
|
321
|
+
`DELETE FROM ${this.DEFAULT_MIGRATION_TABLE_NAME} WHERE name = $1`,
|
|
322
|
+
[migrationName]
|
|
323
|
+
);
|
|
324
|
+
throw error;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
await queryRunner.commitTransaction();
|
|
328
|
+
} catch (error) {
|
|
329
|
+
this.ctx.logMigrations && console.error("Transaction failed, rolling back:", error);
|
|
330
|
+
await queryRunner.rollbackTransaction();
|
|
331
|
+
} finally {
|
|
332
|
+
await queryRunner.release();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
//#endregion
|
|
336
|
+
}
|
|
337
|
+
export {
|
|
338
|
+
ContextDbMigrations
|
|
339
|
+
};
|