taon 21.0.51 → 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/fesm2022/taon-browser.mjs +11 -1
- package/browser/fesm2022/taon-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser-prod/fesm2022/taon-browser.mjs +11 -1
- package/browser-prod/fesm2022/taon-browser.mjs.map +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/endpoint-context.d.ts +1 -1
- package/lib/endpoint-context.js +11 -6
- package/lib/endpoint-context.js.map +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/fesm2022/taon-websql.mjs +11 -1
- package/websql/fesm2022/taon-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/fesm2022/taon-websql.mjs +11 -1
- package/websql-prod/fesm2022/taon-websql.mjs.map +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 -3105
- 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,152 @@
|
|
|
1
|
+
import { ___NS__isString, Helpers__NS__log, UtilsOs__NS__isRunningInDocker } from "tnp-core/lib-prod";
|
|
2
|
+
import { EndpointContext } from "./endpoint-context";
|
|
3
|
+
import { ContextsEndpointStorage } from "./endpoint-context-storage";
|
|
4
|
+
const createContextTemplate = (configFn) => {
|
|
5
|
+
return () => {
|
|
6
|
+
return createContext(configFn);
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
const createContextFn = (configFn, cloneOptions) => {
|
|
10
|
+
cloneOptions = cloneOptions || {};
|
|
11
|
+
let config = configFn({});
|
|
12
|
+
const endpointContextRef = new EndpointContext(
|
|
13
|
+
config,
|
|
14
|
+
configFn,
|
|
15
|
+
cloneOptions
|
|
16
|
+
);
|
|
17
|
+
const res = {
|
|
18
|
+
//#region contexts
|
|
19
|
+
get contextName() {
|
|
20
|
+
return config.contextName;
|
|
21
|
+
},
|
|
22
|
+
//#endregion
|
|
23
|
+
get appId() {
|
|
24
|
+
return config.appId;
|
|
25
|
+
},
|
|
26
|
+
cloneAsRemote: (cloneOpt) => {
|
|
27
|
+
cloneOpt = cloneOpt || {};
|
|
28
|
+
const opt = {
|
|
29
|
+
...cloneOpt,
|
|
30
|
+
sourceContext: endpointContextRef,
|
|
31
|
+
useAsRemoteContext: true
|
|
32
|
+
};
|
|
33
|
+
return createContextFn(configFn, opt);
|
|
34
|
+
},
|
|
35
|
+
cloneAsNormal: (cloneOpt) => {
|
|
36
|
+
cloneOpt = cloneOpt || {};
|
|
37
|
+
const opt = {
|
|
38
|
+
...cloneOpt,
|
|
39
|
+
sourceContext: endpointContextRef,
|
|
40
|
+
useAsRemoteContext: false
|
|
41
|
+
};
|
|
42
|
+
return createContextFn(configFn, opt);
|
|
43
|
+
},
|
|
44
|
+
//#region context
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated
|
|
47
|
+
* - get reference to internal context
|
|
48
|
+
*/
|
|
49
|
+
async __ref() {
|
|
50
|
+
if (!endpointContextRef.inited) {
|
|
51
|
+
await endpointContextRef.init({
|
|
52
|
+
initFromRecrusiveContextResovle: true
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return endpointContextRef;
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* only for internal use
|
|
59
|
+
* @deprecated
|
|
60
|
+
*/
|
|
61
|
+
get __refSync() {
|
|
62
|
+
return endpointContextRef;
|
|
63
|
+
},
|
|
64
|
+
getClassInstance(ctor) {
|
|
65
|
+
return endpointContextRef.getInstanceBy(ctor);
|
|
66
|
+
},
|
|
67
|
+
getClass(ctor) {
|
|
68
|
+
const classFun = endpointContextRef.getClassFunByClass(ctor);
|
|
69
|
+
return classFun;
|
|
70
|
+
},
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region initialize
|
|
73
|
+
/**
|
|
74
|
+
* - create controller instances for context
|
|
75
|
+
* - init database (if enable) + migation scripts
|
|
76
|
+
*/
|
|
77
|
+
initialize: async (overrideOptions) => {
|
|
78
|
+
return await new Promise(async (resolve, reject) => {
|
|
79
|
+
setTimeout(async () => {
|
|
80
|
+
if (UtilsOs__NS__isRunningInDocker()) {
|
|
81
|
+
const activeContext = config?.activeContext || null;
|
|
82
|
+
if (___NS__isString(activeContext) && activeContext !== "" && activeContext !== config?.contextName) {
|
|
83
|
+
console.warn(
|
|
84
|
+
`[taon] Context ${endpointContextRef.contextName} is not active context, skipping initialization.`
|
|
85
|
+
);
|
|
86
|
+
resolve(endpointContextRef);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
await endpointContextRef.init({
|
|
91
|
+
...overrideOptions
|
|
92
|
+
});
|
|
93
|
+
if (config.abstract) {
|
|
94
|
+
throw new Error(`Abstract context can not be initialized`);
|
|
95
|
+
}
|
|
96
|
+
await endpointContextRef.initEntities();
|
|
97
|
+
await endpointContextRef.initSubscribers();
|
|
98
|
+
await endpointContextRef.initDatabaseConnection();
|
|
99
|
+
await endpointContextRef.dbMigrations.ensureMigrationTableExists();
|
|
100
|
+
await endpointContextRef.initControllers();
|
|
101
|
+
await endpointContextRef.startServer();
|
|
102
|
+
endpointContextRef.writeActiveRoutes();
|
|
103
|
+
await endpointContextRef.initClasses();
|
|
104
|
+
if (endpointContextRef.databaseConfig) {
|
|
105
|
+
if (endpointContextRef.onlyMigrationRun) {
|
|
106
|
+
endpointContextRef.logMigrations && Helpers__NS__log(
|
|
107
|
+
`[taon] Running only migrations (context=${endpointContextRef.contextName}).`
|
|
108
|
+
);
|
|
109
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
110
|
+
} else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
|
|
111
|
+
endpointContextRef.logMigrations && Helpers__NS__log(
|
|
112
|
+
`[taon] Reverting migrations to timestamp ${endpointContextRef.onlyMigrationRevertToTimestamp} (context=${endpointContextRef.contextName}).`
|
|
113
|
+
);
|
|
114
|
+
await endpointContextRef.dbMigrations.revertMigrationToTimestamp(
|
|
115
|
+
endpointContextRef.onlyMigrationRevertToTimestamp
|
|
116
|
+
);
|
|
117
|
+
} else {
|
|
118
|
+
endpointContextRef.logMigrations && Helpers__NS__log(
|
|
119
|
+
`[taon] Running all not applied migrations (context=${endpointContextRef.contextName}).`
|
|
120
|
+
);
|
|
121
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
ContextsEndpointStorage.Instance.set(endpointContextRef);
|
|
125
|
+
resolve(endpointContextRef);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* realtime communication with server
|
|
131
|
+
* TCP(upgrade) socket.io (or ipc) based.
|
|
132
|
+
*/
|
|
133
|
+
get realtime() {
|
|
134
|
+
return {
|
|
135
|
+
get client() {
|
|
136
|
+
return endpointContextRef.realtimeClient;
|
|
137
|
+
},
|
|
138
|
+
get server() {
|
|
139
|
+
return endpointContextRef.realtimeServer;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
return res;
|
|
145
|
+
};
|
|
146
|
+
const createContext = (configFn) => {
|
|
147
|
+
return createContextFn(configFn, { useAsRemoteContext: false });
|
|
148
|
+
};
|
|
149
|
+
export {
|
|
150
|
+
createContext,
|
|
151
|
+
createContextTemplate
|
|
152
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ClassHelpers__NS__ensureClassConfig, ClassHelpers__NS__setName } from "../../helpers/class-helpers";
|
|
2
|
+
import { Symbols__NS__metadata } from "../../symbols";
|
|
3
|
+
function TaonController(options) {
|
|
4
|
+
return function(constructor) {
|
|
5
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
6
|
+
Reflect.defineMetadata(
|
|
7
|
+
Symbols__NS__metadata.className,
|
|
8
|
+
options?.className || constructor.name,
|
|
9
|
+
constructor
|
|
10
|
+
);
|
|
11
|
+
const cfg = ClassHelpers__NS__ensureClassConfig(constructor);
|
|
12
|
+
options = options || {};
|
|
13
|
+
cfg.className = options.className || constructor.name;
|
|
14
|
+
cfg.path = options.path || "";
|
|
15
|
+
cfg.realtime = options.realtime;
|
|
16
|
+
cfg.middlewares = options.middlewares;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
TaonController
|
|
21
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
function TaonEntity(options) {
|
|
9
|
+
return function(constructor) {
|
|
10
|
+
options = options || {};
|
|
11
|
+
options.uniqueKeyProp = options.uniqueKeyProp || "id";
|
|
12
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
13
|
+
Mapping__NS__DefaultModelWithMapping(
|
|
14
|
+
options?.defaultModelValues || {},
|
|
15
|
+
___NS__merge(
|
|
16
|
+
options?.defaultModelMapping || {},
|
|
17
|
+
options?.defaultModelMappingDeep || {}
|
|
18
|
+
)
|
|
19
|
+
)(constructor);
|
|
20
|
+
Mapping__NS__DefaultModelWithMapping(void 0, {})(constructor);
|
|
21
|
+
Reflect.defineMetadata(
|
|
22
|
+
Symbols__NS__metadata.options.entity,
|
|
23
|
+
options,
|
|
24
|
+
constructor
|
|
25
|
+
);
|
|
26
|
+
Reflect.defineMetadata(
|
|
27
|
+
Symbols__NS__metadata.className,
|
|
28
|
+
options?.className || constructor.name,
|
|
29
|
+
constructor
|
|
30
|
+
);
|
|
31
|
+
Entity(options?.className)(constructor);
|
|
32
|
+
CLASS.setName(constructor, options?.className);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
class TaonEntityOptions extends DecoratorAbstractOpt {
|
|
36
|
+
/**
|
|
37
|
+
* default unique property is "id"
|
|
38
|
+
* for your entity it may be something else
|
|
39
|
+
*/
|
|
40
|
+
uniqueKeyProp;
|
|
41
|
+
createTable;
|
|
42
|
+
defaultModelValues;
|
|
43
|
+
defaultModelMapping;
|
|
44
|
+
defaultModelMappingDeep;
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
TaonEntity,
|
|
48
|
+
TaonEntityOptions
|
|
49
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
function TaonMiddleware(options) {
|
|
6
|
+
return function(constructor) {
|
|
7
|
+
Reflect.defineMetadata(
|
|
8
|
+
Symbols__NS__metadata.options.provider,
|
|
9
|
+
options,
|
|
10
|
+
constructor
|
|
11
|
+
);
|
|
12
|
+
Reflect.defineMetadata(
|
|
13
|
+
Symbols__NS__metadata.className,
|
|
14
|
+
options?.className || constructor.name,
|
|
15
|
+
constructor
|
|
16
|
+
);
|
|
17
|
+
ClassHelpers__NS__setName(constructor, options?.className || constructor.name);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
class TaonMiddlewareOptions extends DecoratorAbstractOpt {
|
|
21
|
+
// middleware is a singleton for each context
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
TaonMiddleware,
|
|
25
|
+
TaonMiddlewareOptions
|
|
26
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ClassHelpers__NS__setName } from "../../helpers/class-helpers";
|
|
2
|
+
import { Symbols__NS__metadata } from "../../symbols";
|
|
3
|
+
import { DecoratorAbstractOpt } from "../decorator-abstract-opt";
|
|
4
|
+
function TaonMigration(options) {
|
|
5
|
+
return function(constructor) {
|
|
6
|
+
Reflect.defineMetadata(
|
|
7
|
+
Symbols__NS__metadata.options.migration,
|
|
8
|
+
options,
|
|
9
|
+
constructor
|
|
10
|
+
);
|
|
11
|
+
Reflect.defineMetadata(
|
|
12
|
+
Symbols__NS__metadata.className,
|
|
13
|
+
options?.className || constructor.name,
|
|
14
|
+
constructor
|
|
15
|
+
);
|
|
16
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
class TaonMigrationOptions extends DecoratorAbstractOpt {
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
TaonMigration,
|
|
23
|
+
TaonMigrationOptions
|
|
24
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ClassHelpers__NS__setName } from "../../helpers/class-helpers";
|
|
2
|
+
import { Symbols__NS__metadata } from "../../symbols";
|
|
3
|
+
import { DecoratorAbstractOpt } from "../decorator-abstract-opt";
|
|
4
|
+
function TaonProvider(options) {
|
|
5
|
+
return function(constructor) {
|
|
6
|
+
Reflect.defineMetadata(
|
|
7
|
+
Symbols__NS__metadata.options.provider,
|
|
8
|
+
options,
|
|
9
|
+
constructor
|
|
10
|
+
);
|
|
11
|
+
Reflect.defineMetadata(
|
|
12
|
+
Symbols__NS__metadata.className,
|
|
13
|
+
options?.className || constructor.name,
|
|
14
|
+
constructor
|
|
15
|
+
);
|
|
16
|
+
ClassHelpers__NS__setName(constructor, options?.className || constructor.name);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
class TaonProviderOptions extends DecoratorAbstractOpt {
|
|
20
|
+
// providers is a singleton for each context
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
TaonProvider,
|
|
24
|
+
TaonProviderOptions
|
|
25
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ClassHelpers__NS__setName } from "../../helpers/class-helpers";
|
|
2
|
+
import { Symbols__NS__metadata } from "../../symbols";
|
|
3
|
+
import { DecoratorAbstractOpt } from "../decorator-abstract-opt";
|
|
4
|
+
function TaonRepository(options) {
|
|
5
|
+
return function(constructor) {
|
|
6
|
+
Reflect.defineMetadata(
|
|
7
|
+
Symbols__NS__metadata.options.repository,
|
|
8
|
+
options,
|
|
9
|
+
constructor
|
|
10
|
+
);
|
|
11
|
+
Reflect.defineMetadata(
|
|
12
|
+
Symbols__NS__metadata.className,
|
|
13
|
+
options?.className || constructor.name,
|
|
14
|
+
constructor
|
|
15
|
+
);
|
|
16
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
class TaonRepositoryOptions extends DecoratorAbstractOpt {
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
TaonRepository,
|
|
23
|
+
TaonRepositoryOptions
|
|
24
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ClassHelpers__NS__setName } from "../../helpers/class-helpers";
|
|
2
|
+
import { Symbols__NS__metadata } from "../../symbols";
|
|
3
|
+
import { DecoratorAbstractOpt } from "../decorator-abstract-opt";
|
|
4
|
+
function TaonSubscriber(options) {
|
|
5
|
+
return function(constructor) {
|
|
6
|
+
Reflect.defineMetadata(
|
|
7
|
+
Symbols__NS__metadata.options.subscriber,
|
|
8
|
+
options,
|
|
9
|
+
constructor
|
|
10
|
+
);
|
|
11
|
+
Reflect.defineMetadata(
|
|
12
|
+
Symbols__NS__metadata.className,
|
|
13
|
+
options?.className || constructor.name,
|
|
14
|
+
constructor
|
|
15
|
+
);
|
|
16
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
class TaonSubscriberOptions extends DecoratorAbstractOpt {
|
|
20
|
+
allowedEvents;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
TaonSubscriber,
|
|
24
|
+
TaonSubscriberOptions
|
|
25
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
} else {
|
|
12
|
+
options = { pathOrOptions, pathIsGlobal };
|
|
13
|
+
}
|
|
14
|
+
const {
|
|
15
|
+
overrideContentType,
|
|
16
|
+
overrideResponseType,
|
|
17
|
+
overrideExpressSendAsHtml,
|
|
18
|
+
middlewares
|
|
19
|
+
} = options;
|
|
20
|
+
methodConfig.methodName = propertyKey;
|
|
21
|
+
methodConfig.middlewares = middlewares;
|
|
22
|
+
methodConfig.type = method;
|
|
23
|
+
if (!path) {
|
|
24
|
+
let paramsPathConcatedPath = "";
|
|
25
|
+
for (const key in methodConfig.parameters) {
|
|
26
|
+
if (methodConfig.parameters.hasOwnProperty(key)) {
|
|
27
|
+
const element = methodConfig.parameters[key];
|
|
28
|
+
if (element.paramType === "Path" && ___NS__isString(element.paramName) && element.paramName.trim().length > 0) {
|
|
29
|
+
paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
methodConfig.path = `/${propertyKey}${paramsPathConcatedPath}`;
|
|
34
|
+
} else {
|
|
35
|
+
methodConfig.path = path;
|
|
36
|
+
}
|
|
37
|
+
methodConfig.descriptor = descriptor;
|
|
38
|
+
methodConfig.global = pathIsGlobal;
|
|
39
|
+
methodConfig.contentType = overrideContentType;
|
|
40
|
+
methodConfig.responseType = overrideResponseType;
|
|
41
|
+
methodConfig.overrideExpressSendAsHtml = overrideExpressSendAsHtml;
|
|
42
|
+
};
|
|
43
|
+
function GET(pathOrOptions, pathIsGlobal = false) {
|
|
44
|
+
return function(target, propertyKey, descriptor) {
|
|
45
|
+
metaReq(
|
|
46
|
+
"get",
|
|
47
|
+
pathOrOptions,
|
|
48
|
+
target,
|
|
49
|
+
propertyKey,
|
|
50
|
+
descriptor,
|
|
51
|
+
pathOrOptions,
|
|
52
|
+
pathIsGlobal
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function HTML(pathOrOptions) {
|
|
57
|
+
return function(target, propertyKey, descriptor) {
|
|
58
|
+
const opt = pathOrOptions;
|
|
59
|
+
opt.overrideExpressSendAsHtml = true;
|
|
60
|
+
metaReq(
|
|
61
|
+
"get",
|
|
62
|
+
opt,
|
|
63
|
+
target,
|
|
64
|
+
propertyKey,
|
|
65
|
+
descriptor,
|
|
66
|
+
pathOrOptions,
|
|
67
|
+
opt.pathIsGlobal
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function HEAD(pathOrOptions, pathIsGlobal = false) {
|
|
72
|
+
return function(target, propertyKey, descriptor) {
|
|
73
|
+
metaReq(
|
|
74
|
+
"head",
|
|
75
|
+
pathOrOptions,
|
|
76
|
+
target,
|
|
77
|
+
propertyKey,
|
|
78
|
+
descriptor,
|
|
79
|
+
pathOrOptions,
|
|
80
|
+
pathIsGlobal
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function POST(pathOrOptions, pathIsGlobal = false) {
|
|
85
|
+
return function(target, propertyKey, descriptor) {
|
|
86
|
+
metaReq(
|
|
87
|
+
"post",
|
|
88
|
+
pathOrOptions,
|
|
89
|
+
target,
|
|
90
|
+
propertyKey,
|
|
91
|
+
descriptor,
|
|
92
|
+
pathOrOptions,
|
|
93
|
+
pathIsGlobal
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function PUT(pathOrOptions, pathIsGlobal = false) {
|
|
98
|
+
return function(target, propertyKey, descriptor) {
|
|
99
|
+
metaReq(
|
|
100
|
+
"put",
|
|
101
|
+
pathOrOptions,
|
|
102
|
+
target,
|
|
103
|
+
propertyKey,
|
|
104
|
+
descriptor,
|
|
105
|
+
pathOrOptions,
|
|
106
|
+
pathIsGlobal
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function PATCH(pathOrOptions, pathIsGlobal = false) {
|
|
111
|
+
return function(target, propertyKey, descriptor) {
|
|
112
|
+
metaReq(
|
|
113
|
+
"patch",
|
|
114
|
+
pathOrOptions,
|
|
115
|
+
target,
|
|
116
|
+
propertyKey,
|
|
117
|
+
descriptor,
|
|
118
|
+
pathOrOptions,
|
|
119
|
+
pathIsGlobal
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function DELETE(pathOrOptions, pathIsGlobal = false) {
|
|
124
|
+
return function(target, propertyKey, descriptor) {
|
|
125
|
+
metaReq(
|
|
126
|
+
"delete",
|
|
127
|
+
pathOrOptions,
|
|
128
|
+
target,
|
|
129
|
+
propertyKey,
|
|
130
|
+
descriptor,
|
|
131
|
+
pathOrOptions,
|
|
132
|
+
pathIsGlobal
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
DELETE,
|
|
138
|
+
GET,
|
|
139
|
+
HEAD,
|
|
140
|
+
HTML,
|
|
141
|
+
PATCH,
|
|
142
|
+
POST,
|
|
143
|
+
PUT
|
|
144
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ClassHelpers__NS__ensureMethodConfig } from "../../helpers/class-helpers";
|
|
2
|
+
function metaParam(param, name, expire, defaultValue = void 0, target, propertyKey, parameterIndex) {
|
|
3
|
+
const methodCfg = ClassHelpers__NS__ensureMethodConfig(target, propertyKey);
|
|
4
|
+
const nameKey = name ? name : param;
|
|
5
|
+
methodCfg.parameters[nameKey] = {
|
|
6
|
+
index: parameterIndex,
|
|
7
|
+
paramName: name,
|
|
8
|
+
paramType: param,
|
|
9
|
+
defaultType: defaultValue,
|
|
10
|
+
expireInSeconds: expire
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function Path(name) {
|
|
14
|
+
return function(target, propertyKey, parameterIndex) {
|
|
15
|
+
metaParam("Path", name, void 0, {}, target, propertyKey, parameterIndex);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function Query(name) {
|
|
19
|
+
return function(target, propertyKey, parameterIndex) {
|
|
20
|
+
metaParam(
|
|
21
|
+
"Query",
|
|
22
|
+
name,
|
|
23
|
+
void 0,
|
|
24
|
+
{},
|
|
25
|
+
target,
|
|
26
|
+
propertyKey,
|
|
27
|
+
parameterIndex
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function Cookie(name, expireInSecond = 3600) {
|
|
32
|
+
return function(target, propertyKey, parameterIndex) {
|
|
33
|
+
metaParam(
|
|
34
|
+
"Cookie",
|
|
35
|
+
name,
|
|
36
|
+
expireInSecond,
|
|
37
|
+
{},
|
|
38
|
+
target,
|
|
39
|
+
propertyKey,
|
|
40
|
+
parameterIndex
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function Header(name) {
|
|
45
|
+
return function(target, propertyKey, parameterIndex) {
|
|
46
|
+
metaParam(
|
|
47
|
+
"Header",
|
|
48
|
+
name,
|
|
49
|
+
void 0,
|
|
50
|
+
{},
|
|
51
|
+
target,
|
|
52
|
+
propertyKey,
|
|
53
|
+
parameterIndex
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function Body(name) {
|
|
58
|
+
return function(target, propertyKey, parameterIndex) {
|
|
59
|
+
metaParam("Body", name, void 0, {}, target, propertyKey, parameterIndex);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
Body,
|
|
64
|
+
Cookie,
|
|
65
|
+
Header,
|
|
66
|
+
Path,
|
|
67
|
+
Query
|
|
68
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class DITaonContainer {
|
|
2
|
+
static instances = /* @__PURE__ */ new Map();
|
|
3
|
+
static resolve(target) {
|
|
4
|
+
if (DITaonContainer.instances.has(target)) {
|
|
5
|
+
return DITaonContainer.instances.get(target);
|
|
6
|
+
}
|
|
7
|
+
const injections = [];
|
|
8
|
+
const instance = new target(...injections);
|
|
9
|
+
DITaonContainer.instances.set(target, instance);
|
|
10
|
+
return instance;
|
|
11
|
+
}
|
|
12
|
+
static inject(target) {
|
|
13
|
+
return new Proxy(
|
|
14
|
+
{},
|
|
15
|
+
{
|
|
16
|
+
get: (_, propName) => {
|
|
17
|
+
let instance = DITaonContainer.instances.get(target) || DITaonContainer.resolve(target);
|
|
18
|
+
return typeof instance[propName] === "function" ? instance[propName].bind(instance) : instance[propName];
|
|
19
|
+
},
|
|
20
|
+
set: (_, propName, value) => {
|
|
21
|
+
let instance = DITaonContainer.instances.get(target) || DITaonContainer.resolve(target);
|
|
22
|
+
instance[propName] = value;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
DITaonContainer
|
|
31
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CoreModels__NS__SPECIAL_APP_READY_MESSAGE } from "tnp-core/lib-prod";
|
|
2
|
+
class ContextsEndpointStorage {
|
|
3
|
+
SPECIAL_APP_READY_MESSAGE = CoreModels__NS__SPECIAL_APP_READY_MESSAGE;
|
|
4
|
+
taonEndpointContexts = /* @__PURE__ */ new Map();
|
|
5
|
+
//#region singleton
|
|
6
|
+
static instance;
|
|
7
|
+
constructor() {
|
|
8
|
+
}
|
|
9
|
+
static get Instance() {
|
|
10
|
+
if (!ContextsEndpointStorage.instance) {
|
|
11
|
+
ContextsEndpointStorage.instance = new ContextsEndpointStorage();
|
|
12
|
+
}
|
|
13
|
+
return ContextsEndpointStorage.instance;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
set(context) {
|
|
17
|
+
if (!this.taonEndpointContexts.has(context.contextName)) {
|
|
18
|
+
this.taonEndpointContexts.set(context.contextName, context);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
get arr() {
|
|
22
|
+
return Array.from(this.taonEndpointContexts.values()).filter(
|
|
23
|
+
(f) => f.contextType === "normal"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
getBy(context) {
|
|
27
|
+
if (typeof context === "string") {
|
|
28
|
+
return this.taonEndpointContexts.get(context);
|
|
29
|
+
}
|
|
30
|
+
return this.taonEndpointContexts.get(context.contextName);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
globalThis["$$$ContextsEndpointStorage$$$"] = ContextsEndpointStorage.Instance;
|
|
34
|
+
export {
|
|
35
|
+
ContextsEndpointStorage
|
|
36
|
+
};
|