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,217 @@
|
|
|
1
|
+
//#region imports
|
|
2
|
+
import { ___NS__isString, Helpers__NS__log, UtilsOs__NS__isRunningInDocker } from 'tnp-core/lib-prod';
|
|
3
|
+
import { EndpointContext } from './endpoint-context';
|
|
4
|
+
/* */
|
|
5
|
+
import { ContextsEndpointStorage } from './endpoint-context-storage';
|
|
6
|
+
//#endregion
|
|
7
|
+
/**
|
|
8
|
+
* @returns function that returns context function.
|
|
9
|
+
* Context function can be used to dynamically
|
|
10
|
+
* create context with specific configuration.
|
|
11
|
+
*/
|
|
12
|
+
export const createContextTemplate = (configFn) => {
|
|
13
|
+
return () => {
|
|
14
|
+
return createContext(configFn);
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* REQURIED PROPERTY:
|
|
19
|
+
* - contextName
|
|
20
|
+
*/
|
|
21
|
+
const createContextFn = (configFn, cloneOptions) => {
|
|
22
|
+
cloneOptions = cloneOptions || {};
|
|
23
|
+
let config = configFn({});
|
|
24
|
+
// console.log(
|
|
25
|
+
// `
|
|
26
|
+
// [Taon] Creating context ${config.contextName}...`,
|
|
27
|
+
// {config},
|
|
28
|
+
// );
|
|
29
|
+
const endpointContextRef = new EndpointContext(config, configFn, cloneOptions);
|
|
30
|
+
const res = {
|
|
31
|
+
//#region contexts
|
|
32
|
+
get contextName() {
|
|
33
|
+
return config.contextName;
|
|
34
|
+
},
|
|
35
|
+
//#endregion
|
|
36
|
+
get appId() {
|
|
37
|
+
return config.appId;
|
|
38
|
+
},
|
|
39
|
+
cloneAsRemote: (cloneOpt) => {
|
|
40
|
+
cloneOpt = cloneOpt || {};
|
|
41
|
+
const opt = {
|
|
42
|
+
...cloneOpt,
|
|
43
|
+
sourceContext: endpointContextRef,
|
|
44
|
+
useAsRemoteContext: true,
|
|
45
|
+
};
|
|
46
|
+
return createContextFn(configFn, opt);
|
|
47
|
+
},
|
|
48
|
+
cloneAsNormal: (cloneOpt) => {
|
|
49
|
+
cloneOpt = cloneOpt || {};
|
|
50
|
+
const opt = {
|
|
51
|
+
...cloneOpt,
|
|
52
|
+
sourceContext: endpointContextRef,
|
|
53
|
+
useAsRemoteContext: false,
|
|
54
|
+
};
|
|
55
|
+
return createContextFn(configFn, opt);
|
|
56
|
+
},
|
|
57
|
+
//#region context
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated
|
|
60
|
+
* - get reference to internal context
|
|
61
|
+
*/
|
|
62
|
+
async __ref() {
|
|
63
|
+
if (!endpointContextRef.inited) {
|
|
64
|
+
await endpointContextRef.init({
|
|
65
|
+
initFromRecrusiveContextResovle: true,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return endpointContextRef;
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* only for internal use
|
|
72
|
+
* @deprecated
|
|
73
|
+
*/
|
|
74
|
+
get __refSync() {
|
|
75
|
+
return endpointContextRef;
|
|
76
|
+
},
|
|
77
|
+
getClassInstance(ctor) {
|
|
78
|
+
return endpointContextRef.getInstanceBy(ctor);
|
|
79
|
+
},
|
|
80
|
+
getClass(ctor) {
|
|
81
|
+
const classFun = endpointContextRef.getClassFunByClass(ctor);
|
|
82
|
+
return classFun;
|
|
83
|
+
//#region old
|
|
84
|
+
// TODO hmmmm for now context for controller inside api service
|
|
85
|
+
// const allContexts = Object.values(classFun[Symbols__NS__orignalClassClonesObj] || {}).map(classFn => {
|
|
86
|
+
// return {
|
|
87
|
+
// ctx: classFn[Symbols__NS__ctxInClassOrClassObj] as EndpointContext,
|
|
88
|
+
// classFn,
|
|
89
|
+
// }
|
|
90
|
+
// })
|
|
91
|
+
// const activeContext = allContexts.find(c => c.ctx.inited);
|
|
92
|
+
// debugger
|
|
93
|
+
// console.log('activeContext', activeContext.ctx.contextName);
|
|
94
|
+
// return activeContext.ctx.getClassFunByClass(ctor) as any;
|
|
95
|
+
//#endregion
|
|
96
|
+
},
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region initialize
|
|
99
|
+
/**
|
|
100
|
+
* - create controller instances for context
|
|
101
|
+
* - init database (if enable) + migation scripts
|
|
102
|
+
*/
|
|
103
|
+
initialize: async (overrideOptions) => {
|
|
104
|
+
return await new Promise(async (resolve, reject) => {
|
|
105
|
+
//#region init in set timeout
|
|
106
|
+
setTimeout(async () => {
|
|
107
|
+
if (UtilsOs__NS__isRunningInDocker()) {
|
|
108
|
+
const activeContext = config?.activeContext || null;
|
|
109
|
+
if (___NS__isString(activeContext) &&
|
|
110
|
+
activeContext !== '' &&
|
|
111
|
+
activeContext !== config?.contextName) {
|
|
112
|
+
console.warn(`[taon] Context ${endpointContextRef.contextName} is not active context, skipping initialization.`);
|
|
113
|
+
resolve(endpointContextRef);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
await endpointContextRef.init({
|
|
118
|
+
...overrideOptions,
|
|
119
|
+
});
|
|
120
|
+
if (config.abstract) {
|
|
121
|
+
throw new Error(`Abstract context can not be initialized`);
|
|
122
|
+
}
|
|
123
|
+
await endpointContextRef.initEntities();
|
|
124
|
+
await endpointContextRef.initSubscribers();
|
|
125
|
+
await endpointContextRef.initDatabaseConnection();
|
|
126
|
+
await endpointContextRef.dbMigrations.ensureMigrationTableExists();
|
|
127
|
+
// console.log(
|
|
128
|
+
// 'connection subscribers',
|
|
129
|
+
// endpointContextRef?.connection?.subscribers,
|
|
130
|
+
// );
|
|
131
|
+
// debugger;
|
|
132
|
+
await endpointContextRef.initControllers();
|
|
133
|
+
await endpointContextRef.startServer();
|
|
134
|
+
//#region @websql
|
|
135
|
+
endpointContextRef.writeActiveRoutes();
|
|
136
|
+
//#endregion
|
|
137
|
+
await endpointContextRef.initClasses();
|
|
138
|
+
if (endpointContextRef.databaseConfig) {
|
|
139
|
+
//#region handle websql reload data
|
|
140
|
+
/* */
|
|
141
|
+
/* */
|
|
142
|
+
/* */
|
|
143
|
+
/* */
|
|
144
|
+
/* */
|
|
145
|
+
/* */
|
|
146
|
+
/* */
|
|
147
|
+
/* */
|
|
148
|
+
/* */
|
|
149
|
+
/* */
|
|
150
|
+
/* */
|
|
151
|
+
/* */
|
|
152
|
+
/* */
|
|
153
|
+
/* */
|
|
154
|
+
/* */
|
|
155
|
+
/* */
|
|
156
|
+
/* */
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region TODO this may be usefull but for now
|
|
159
|
+
// 2 separate contexts are fine
|
|
160
|
+
// const shouldStartRemoteHost = endpointContextRef.mode !== 'remote-backend(tcp+udp)';
|
|
161
|
+
// if(shouldStartRemoteHost) {
|
|
162
|
+
// const endpointContextRemoteHostRef = new EndpointContext(config, configFn);
|
|
163
|
+
// await endpointContextRemoteHostRef.init({
|
|
164
|
+
// overrideRemoteHost: endpointContextRef.host,
|
|
165
|
+
// overrideHost: null,
|
|
166
|
+
// });
|
|
167
|
+
// endpointContextRemoteHostRef.initMetadata();
|
|
168
|
+
// endpointContextRef.__contextForControllerInstanceAccess = endpointContextRemoteHostRef;
|
|
169
|
+
// }
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region run migrations tasks
|
|
172
|
+
if (endpointContextRef.onlyMigrationRun) {
|
|
173
|
+
endpointContextRef.logMigrations &&
|
|
174
|
+
Helpers__NS__log(`[taon] Running only migrations (context=${endpointContextRef.contextName}).`);
|
|
175
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
176
|
+
}
|
|
177
|
+
else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
|
|
178
|
+
endpointContextRef.logMigrations &&
|
|
179
|
+
Helpers__NS__log(`[taon] Reverting migrations to timestamp ${endpointContextRef.onlyMigrationRevertToTimestamp} (context=${endpointContextRef.contextName}).`);
|
|
180
|
+
await endpointContextRef.dbMigrations.revertMigrationToTimestamp(endpointContextRef.onlyMigrationRevertToTimestamp);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
endpointContextRef.logMigrations &&
|
|
184
|
+
Helpers__NS__log(`[taon] Running all not applied migrations (context=${endpointContextRef.contextName}).`);
|
|
185
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
}
|
|
189
|
+
ContextsEndpointStorage.Instance.set(endpointContextRef);
|
|
190
|
+
resolve(endpointContextRef);
|
|
191
|
+
});
|
|
192
|
+
//#endregion
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
/**
|
|
196
|
+
* realtime communication with server
|
|
197
|
+
* TCP(upgrade) socket.io (or ipc) based.
|
|
198
|
+
*/
|
|
199
|
+
get realtime() {
|
|
200
|
+
return {
|
|
201
|
+
get client() {
|
|
202
|
+
return endpointContextRef.realtimeClient;
|
|
203
|
+
},
|
|
204
|
+
get server() {
|
|
205
|
+
return endpointContextRef.realtimeServer;
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
return res;
|
|
211
|
+
};
|
|
212
|
+
//#endregion
|
|
213
|
+
export const createContext = (configFn) => {
|
|
214
|
+
return createContextFn(configFn, { useAsRemoteContext: false });
|
|
215
|
+
};
|
|
216
|
+
// const AA = createContext(() => ({ contextName: 'aa' }));
|
|
217
|
+
// const BB = AA.cloneAsRemoteContext();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ClassHelpers__NS__ensureClassConfig, ClassHelpers__NS__setName } from '../../helpers/class-helpers';
|
|
2
|
+
import { Symbols__NS__metadata } from '../../symbols';
|
|
3
|
+
/**
|
|
4
|
+
* Controller decorator
|
|
5
|
+
*/
|
|
6
|
+
export function TaonController(options) {
|
|
7
|
+
return function (constructor) {
|
|
8
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
9
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
10
|
+
const cfg = ClassHelpers__NS__ensureClassConfig(constructor);
|
|
11
|
+
options = options || {};
|
|
12
|
+
cfg.className = options.className || constructor.name;
|
|
13
|
+
cfg.path = options.path || '';
|
|
14
|
+
cfg.realtime = options.realtime;
|
|
15
|
+
cfg.middlewares = options.middlewares;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Mapping__NS__DefaultModelWithMapping } from 'ng2-rest/lib-prod';
|
|
2
|
+
import { Entity } from 'taon-typeorm/lib-prod';
|
|
3
|
+
import { ___NS__merge } from 'tnp-core/lib-prod';
|
|
4
|
+
import { CLASS } from 'typescript-class-helpers/lib-prod';
|
|
5
|
+
import { ClassHelpers__NS__setName } from '../../helpers/class-helpers';
|
|
6
|
+
import { Symbols__NS__metadata } from '../../symbols';
|
|
7
|
+
import { DecoratorAbstractOpt } from '../decorator-abstract-opt';
|
|
8
|
+
/**
|
|
9
|
+
* Entity decorator
|
|
10
|
+
*/
|
|
11
|
+
export function TaonEntity(options) {
|
|
12
|
+
return function (constructor) {
|
|
13
|
+
options = options || {};
|
|
14
|
+
options.uniqueKeyProp = options.uniqueKeyProp || 'id';
|
|
15
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
16
|
+
Mapping__NS__DefaultModelWithMapping(options?.defaultModelValues || {}, ___NS__merge(options?.defaultModelMapping || {}, (options?.defaultModelMappingDeep || {})))(constructor);
|
|
17
|
+
// TODO when entit metadata generator read use this
|
|
18
|
+
Mapping__NS__DefaultModelWithMapping(void 0, {})(constructor);
|
|
19
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.entity, options, constructor);
|
|
20
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
21
|
+
//#region @websql
|
|
22
|
+
Entity(options?.className)(constructor);
|
|
23
|
+
//#endregion
|
|
24
|
+
CLASS.setName(constructor, options?.className); // TODO QUICK_FIX for ng2-rest
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export class TaonEntityOptions extends DecoratorAbstractOpt {
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { ClassHelpers__NS__setName } from '../../helpers/class-helpers';
|
|
3
|
+
import { Symbols__NS__metadata } from '../../symbols';
|
|
4
|
+
import { DecoratorAbstractOpt } from '../decorator-abstract-opt';
|
|
5
|
+
/**
|
|
6
|
+
* Provider decorator
|
|
7
|
+
*/
|
|
8
|
+
export function TaonMiddleware(options) {
|
|
9
|
+
return function (constructor) {
|
|
10
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.provider, options, constructor);
|
|
11
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
12
|
+
ClassHelpers__NS__setName(constructor, options?.className || constructor.name);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export class TaonMiddlewareOptions extends DecoratorAbstractOpt {
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ClassHelpers__NS__setName } from '../../helpers/class-helpers';
|
|
2
|
+
import { Symbols__NS__metadata } from '../../symbols';
|
|
3
|
+
import { DecoratorAbstractOpt } from '../decorator-abstract-opt';
|
|
4
|
+
/**
|
|
5
|
+
* Migration decorator
|
|
6
|
+
*/
|
|
7
|
+
export function TaonMigration(options) {
|
|
8
|
+
return function (constructor) {
|
|
9
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.migration, options, constructor);
|
|
10
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
11
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export class TaonMigrationOptions extends DecoratorAbstractOpt {
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ClassHelpers__NS__setName } from '../../helpers/class-helpers';
|
|
2
|
+
import { Symbols__NS__metadata } from '../../symbols';
|
|
3
|
+
import { DecoratorAbstractOpt } from '../decorator-abstract-opt';
|
|
4
|
+
/**
|
|
5
|
+
* Provider decorator
|
|
6
|
+
*/
|
|
7
|
+
export function TaonProvider(options) {
|
|
8
|
+
return function (constructor) {
|
|
9
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.provider, options, constructor);
|
|
10
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
11
|
+
ClassHelpers__NS__setName(constructor, options?.className || constructor.name);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export class TaonProviderOptions extends DecoratorAbstractOpt {
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ClassHelpers__NS__setName } from '../../helpers/class-helpers';
|
|
2
|
+
import { Symbols__NS__metadata } from '../../symbols';
|
|
3
|
+
import { DecoratorAbstractOpt } from '../decorator-abstract-opt';
|
|
4
|
+
/**
|
|
5
|
+
* Repository decorator
|
|
6
|
+
*/
|
|
7
|
+
export function TaonRepository(options) {
|
|
8
|
+
return function (constructor) {
|
|
9
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.repository, options, constructor);
|
|
10
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
11
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export class TaonRepositoryOptions extends DecoratorAbstractOpt {
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ClassHelpers__NS__setName } from '../../helpers/class-helpers';
|
|
2
|
+
import { Symbols__NS__metadata } from '../../symbols';
|
|
3
|
+
import { DecoratorAbstractOpt } from '../decorator-abstract-opt';
|
|
4
|
+
/**
|
|
5
|
+
* Subscriber decorator
|
|
6
|
+
*/
|
|
7
|
+
export function TaonSubscriber(options) {
|
|
8
|
+
return function (constructor) {
|
|
9
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.subscriber, options, constructor);
|
|
10
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
11
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export class TaonSubscriberOptions extends DecoratorAbstractOpt {
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Models } from 'ng2-rest/lib-prod';
|
|
2
|
+
export const HttpResponse = Models.HttpResponse;
|
|
3
|
+
// TODO new 5.8 typescript is not allowing this
|
|
4
|
+
// export namespace Http {
|
|
5
|
+
// export import GET = methods.GET;
|
|
6
|
+
// export import POST = methods.POST;
|
|
7
|
+
// export import PUT = methods.PUT;
|
|
8
|
+
// export import DELETE = methods.DELETE;
|
|
9
|
+
// export import PATCH = methods.PATCH;
|
|
10
|
+
// export import HEAD = methods.HEAD;
|
|
11
|
+
// export import HTML = methods.HTML;
|
|
12
|
+
// export import Response = Models.HttpResponse;
|
|
13
|
+
// export namespace Param {
|
|
14
|
+
// export import Query = params.Query;
|
|
15
|
+
// export import Path = params.Path;
|
|
16
|
+
// export import Body = params.Body;
|
|
17
|
+
// export import Cookie = params.Cookie;
|
|
18
|
+
// export import Header = params.Header;
|
|
19
|
+
// }
|
|
20
|
+
// }
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ___NS__isString } from 'tnp-core/lib-prod';
|
|
2
|
+
import { ClassHelpers__NS__ensureMethodConfig } from '../../helpers/class-helpers';
|
|
3
|
+
const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
|
|
4
|
+
const methodConfig = ClassHelpers__NS__ensureMethodConfig(target, propertyKey);
|
|
5
|
+
let options;
|
|
6
|
+
if (typeof pathOrOptions === 'object') {
|
|
7
|
+
options = pathOrOptions;
|
|
8
|
+
pathOrOptions = options.path;
|
|
9
|
+
pathIsGlobal = !!options.pathIsGlobal;
|
|
10
|
+
path = options.path;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
options = { pathOrOptions, pathIsGlobal };
|
|
14
|
+
}
|
|
15
|
+
const { overrideContentType, overrideResponseType, overrideExpressSendAsHtml, middlewares, } = options;
|
|
16
|
+
methodConfig.methodName = propertyKey;
|
|
17
|
+
methodConfig.middlewares = middlewares;
|
|
18
|
+
methodConfig.type = method;
|
|
19
|
+
if (!path) {
|
|
20
|
+
let paramsPathConcatedPath = '';
|
|
21
|
+
for (const key in methodConfig.parameters) {
|
|
22
|
+
if (methodConfig.parameters.hasOwnProperty(key)) {
|
|
23
|
+
const element = methodConfig.parameters[key];
|
|
24
|
+
if (element.paramType === 'Path' &&
|
|
25
|
+
___NS__isString(element.paramName) &&
|
|
26
|
+
element.paramName.trim().length > 0) {
|
|
27
|
+
paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
methodConfig.path = `/${propertyKey}${paramsPathConcatedPath}`;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
methodConfig.path = path;
|
|
35
|
+
}
|
|
36
|
+
methodConfig.descriptor = descriptor;
|
|
37
|
+
methodConfig.global = pathIsGlobal;
|
|
38
|
+
methodConfig.contentType = overrideContentType;
|
|
39
|
+
methodConfig.responseType = overrideResponseType;
|
|
40
|
+
methodConfig.overrideExpressSendAsHtml = overrideExpressSendAsHtml;
|
|
41
|
+
};
|
|
42
|
+
export function GET(pathOrOptions, pathIsGlobal = false) {
|
|
43
|
+
return function (target, propertyKey, descriptor) {
|
|
44
|
+
metaReq('get', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Method for sending html website from text
|
|
49
|
+
* Example
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* ...
|
|
53
|
+
* // in your taon controller
|
|
54
|
+
* ..Taon.Http.HTML()
|
|
55
|
+
* sendHtmlDummyWebsite(): Taon.ResponseHtml {
|
|
56
|
+
* return `
|
|
57
|
+
<html>
|
|
58
|
+
<head>
|
|
59
|
+
<title>Dummy website</title>
|
|
60
|
+
</head>
|
|
61
|
+
<body>
|
|
62
|
+
<h1>This is dummy website</h1>
|
|
63
|
+
<p>Served as HTML string from Taon controller method</p>
|
|
64
|
+
</body>
|
|
65
|
+
</html>
|
|
66
|
+
* `; *
|
|
67
|
+
* }
|
|
68
|
+
* ...
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function HTML(pathOrOptions) {
|
|
72
|
+
return function (target, propertyKey, descriptor) {
|
|
73
|
+
const opt = pathOrOptions;
|
|
74
|
+
opt.overrideExpressSendAsHtml = true;
|
|
75
|
+
metaReq('get', opt, target, propertyKey, descriptor, pathOrOptions, opt.pathIsGlobal);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function HEAD(pathOrOptions, pathIsGlobal = false) {
|
|
79
|
+
return function (target, propertyKey, descriptor) {
|
|
80
|
+
metaReq('head', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export function POST(pathOrOptions, pathIsGlobal = false) {
|
|
84
|
+
return function (target, propertyKey, descriptor) {
|
|
85
|
+
metaReq('post', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export function PUT(pathOrOptions, pathIsGlobal = false) {
|
|
89
|
+
return function (target, propertyKey, descriptor) {
|
|
90
|
+
metaReq('put', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export function PATCH(pathOrOptions, pathIsGlobal = false) {
|
|
94
|
+
return function (target, propertyKey, descriptor) {
|
|
95
|
+
metaReq('patch', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export function DELETE(pathOrOptions, pathIsGlobal = false) {
|
|
99
|
+
return function (target, propertyKey, descriptor) {
|
|
100
|
+
metaReq('delete', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ClassHelpers__NS__ensureMethodConfig } from '../../helpers/class-helpers';
|
|
2
|
+
function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
|
|
3
|
+
const methodCfg = ClassHelpers__NS__ensureMethodConfig(target, propertyKey);
|
|
4
|
+
const nameKey = name ? name : param;
|
|
5
|
+
// const key = name || `${param}_${parameterIndex}`;
|
|
6
|
+
methodCfg.parameters[nameKey] = {
|
|
7
|
+
index: parameterIndex,
|
|
8
|
+
paramName: name,
|
|
9
|
+
paramType: param,
|
|
10
|
+
defaultType: defaultValue,
|
|
11
|
+
expireInSeconds: expire,
|
|
12
|
+
};
|
|
13
|
+
// console.log('params updated', methodConfig);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated use Taon.Http.Param.Path (is more safe and cleaner)
|
|
17
|
+
*/
|
|
18
|
+
export function Path(name) {
|
|
19
|
+
return function (target, propertyKey, parameterIndex) {
|
|
20
|
+
metaParam('Path', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function Query(name) {
|
|
24
|
+
return function (target, propertyKey, parameterIndex) {
|
|
25
|
+
metaParam('Query', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function Cookie(name, expireInSecond = 3600) {
|
|
29
|
+
return function (target, propertyKey, parameterIndex) {
|
|
30
|
+
metaParam('Cookie', name, expireInSecond, {}, target, propertyKey, parameterIndex);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function Header(name) {
|
|
34
|
+
return function (target, propertyKey, parameterIndex) {
|
|
35
|
+
metaParam('Header', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function Body(name) {
|
|
39
|
+
return function (target, propertyKey, parameterIndex) {
|
|
40
|
+
metaParam('Body', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class DITaonContainer {
|
|
2
|
+
static { this.instances = new Map(); }
|
|
3
|
+
static resolve(target) {
|
|
4
|
+
if (DITaonContainer.instances.has(target)) {
|
|
5
|
+
return DITaonContainer.instances.get(target);
|
|
6
|
+
}
|
|
7
|
+
// const tokens = Reflect.getMetadata('design:paramtypes', target) || [];
|
|
8
|
+
const injections = []; // tokens.map(token => Container.inject<any>(token));
|
|
9
|
+
const instance = new target(...injections);
|
|
10
|
+
DITaonContainer.instances.set(target, instance);
|
|
11
|
+
return instance;
|
|
12
|
+
}
|
|
13
|
+
static inject(target) {
|
|
14
|
+
return new Proxy({}, {
|
|
15
|
+
get: (_, propName) => {
|
|
16
|
+
let instance = DITaonContainer.instances.get(target) ||
|
|
17
|
+
DITaonContainer.resolve(target);
|
|
18
|
+
return typeof instance[propName] === 'function'
|
|
19
|
+
? instance[propName].bind(instance)
|
|
20
|
+
: instance[propName];
|
|
21
|
+
},
|
|
22
|
+
set: (_, propName, value) => {
|
|
23
|
+
let instance = DITaonContainer.instances.get(target) ||
|
|
24
|
+
DITaonContainer.resolve(target);
|
|
25
|
+
instance[propName] = value;
|
|
26
|
+
return true;
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CoreModels__NS__SPECIAL_APP_READY_MESSAGE } from 'tnp-core/lib-prod';
|
|
2
|
+
export class ContextsEndpointStorage {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.SPECIAL_APP_READY_MESSAGE = CoreModels__NS__SPECIAL_APP_READY_MESSAGE;
|
|
5
|
+
this.taonEndpointContexts = new Map();
|
|
6
|
+
// Private constructor to prevent direct instantiation
|
|
7
|
+
}
|
|
8
|
+
static get Instance() {
|
|
9
|
+
if (!ContextsEndpointStorage.instance) {
|
|
10
|
+
ContextsEndpointStorage.instance = new ContextsEndpointStorage();
|
|
11
|
+
}
|
|
12
|
+
return ContextsEndpointStorage.instance;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
set(context) {
|
|
16
|
+
if (!this.taonEndpointContexts.has(context.contextName)) {
|
|
17
|
+
this.taonEndpointContexts.set(context.contextName, context);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
get arr() {
|
|
21
|
+
return Array.from(this.taonEndpointContexts.values()).filter(f => f.contextType === 'normal');
|
|
22
|
+
}
|
|
23
|
+
getBy(context) {
|
|
24
|
+
if (typeof context === 'string') {
|
|
25
|
+
return this.taonEndpointContexts.get(context);
|
|
26
|
+
}
|
|
27
|
+
return this.taonEndpointContexts.get(context.contextName);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// TODO QUICK_FIX @LAST encapsulate this => move to separate package
|
|
31
|
+
globalThis['$$$ContextsEndpointStorage$$$'] = ContextsEndpointStorage.Instance;
|