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,262 @@
|
|
|
1
|
+
import { RealtimeStrategy } from "./realtime-strategy";
|
|
2
|
+
import { Symbols__NS__REALTIME } from "../../symbols";
|
|
3
|
+
class MockServer {
|
|
4
|
+
//#region constructor
|
|
5
|
+
constructor(url) {
|
|
6
|
+
this.url = url;
|
|
7
|
+
MockServer.serverByUrl.set(url, this);
|
|
8
|
+
}
|
|
9
|
+
static serverByUrl = /* @__PURE__ */ new Map();
|
|
10
|
+
static from(url) {
|
|
11
|
+
if (!MockServer.serverByUrl.has(url)) {
|
|
12
|
+
MockServer.serverByUrl.set(url, new MockServer(url));
|
|
13
|
+
}
|
|
14
|
+
return MockServer.serverByUrl.get(url);
|
|
15
|
+
}
|
|
16
|
+
get allServers() {
|
|
17
|
+
return Array.from(MockServer.serverByUrl.values());
|
|
18
|
+
}
|
|
19
|
+
namespacesByName = /* @__PURE__ */ new Map();
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region of
|
|
22
|
+
of(namespace) {
|
|
23
|
+
if (!this.namespacesByName.has(namespace)) {
|
|
24
|
+
this.namespacesByName.set(namespace, new MockNamespace(namespace, this));
|
|
25
|
+
}
|
|
26
|
+
return this.namespacesByName.get(namespace);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region path
|
|
30
|
+
path() {
|
|
31
|
+
return this.url;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
}
|
|
35
|
+
class MockNamespace {
|
|
36
|
+
//#region constructor
|
|
37
|
+
constructor(name, server) {
|
|
38
|
+
this.name = name;
|
|
39
|
+
this.server = server;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* All sockets connected to this namespace
|
|
43
|
+
*/
|
|
44
|
+
allSocketsForNamespace = /* @__PURE__ */ new Set();
|
|
45
|
+
/**
|
|
46
|
+
* Rooms and their sockets
|
|
47
|
+
*/
|
|
48
|
+
socketByRoomName = {};
|
|
49
|
+
/**
|
|
50
|
+
* Event handlers for this namespace
|
|
51
|
+
*/
|
|
52
|
+
namespaceEventHandlers = {};
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region on
|
|
55
|
+
on(eventName, handler) {
|
|
56
|
+
if (!this.namespaceEventHandlers[eventName]) {
|
|
57
|
+
this.namespaceEventHandlers[eventName] = /* @__PURE__ */ new Set();
|
|
58
|
+
}
|
|
59
|
+
if (!this.namespaceEventHandlers[eventName].has(handler)) {
|
|
60
|
+
this.namespaceEventHandlers[eventName].add(handler);
|
|
61
|
+
}
|
|
62
|
+
if (eventName === "connection") {
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
this.emit("connection", this);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region emit
|
|
70
|
+
emit(event, ...args) {
|
|
71
|
+
this.allSocketsForNamespace?.forEach((socket) => {
|
|
72
|
+
socket.emit(event, ...args);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region connect
|
|
77
|
+
connect(socket) {
|
|
78
|
+
this.allSocketsForNamespace.add(socket);
|
|
79
|
+
socket.namespaceInstance = this;
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region to
|
|
83
|
+
to(roomName) {
|
|
84
|
+
const socketsInRoom = this.socketByRoomName[roomName];
|
|
85
|
+
return new RoomEmitter(socketsInRoom, true);
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region to room
|
|
89
|
+
in(roomName) {
|
|
90
|
+
const socketsInRoom = this.socketByRoomName[roomName];
|
|
91
|
+
return new RoomEmitter(socketsInRoom, false);
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region join room
|
|
95
|
+
joinRoom(roomName, socket) {
|
|
96
|
+
if (!this.socketByRoomName[roomName]) {
|
|
97
|
+
this.socketByRoomName[roomName] = /* @__PURE__ */ new Set();
|
|
98
|
+
}
|
|
99
|
+
this.socketByRoomName[roomName].add(socket);
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region leave room
|
|
103
|
+
leaveRoom(roomName, socket) {
|
|
104
|
+
const roomSockets = this.socketByRoomName[roomName];
|
|
105
|
+
if (roomSockets) {
|
|
106
|
+
this.socketByRoomName[roomName].delete(socket);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region nsp + name
|
|
111
|
+
get nsp() {
|
|
112
|
+
const self = this;
|
|
113
|
+
return {
|
|
114
|
+
get name() {
|
|
115
|
+
return self.name;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
path() {
|
|
121
|
+
return this.name;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
class RoomEmitter {
|
|
125
|
+
//#region constructor
|
|
126
|
+
constructor(sockets, includeSender = false, sender = null) {
|
|
127
|
+
this.sockets = sockets;
|
|
128
|
+
this.includeSender = includeSender;
|
|
129
|
+
this.sender = sender;
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region emit in room
|
|
133
|
+
emit(event, ...args) {
|
|
134
|
+
this.sockets?.forEach((socket) => {
|
|
135
|
+
if (this.includeSender || socket !== this.sender) {
|
|
136
|
+
socket.emit(event, ...args);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
}
|
|
142
|
+
class MockSocket {
|
|
143
|
+
//#region constructor
|
|
144
|
+
constructor(url, opts) {
|
|
145
|
+
this.url = url;
|
|
146
|
+
const [baseUrl, namespace] = [url, opts.path || "/"];
|
|
147
|
+
const namespaceName = namespace || "/";
|
|
148
|
+
const server = MockServer.from(url);
|
|
149
|
+
const ns = server.of(namespaceName);
|
|
150
|
+
ns.connect(this);
|
|
151
|
+
}
|
|
152
|
+
namespaceInstance;
|
|
153
|
+
socketEventHandlers = {};
|
|
154
|
+
get id() {
|
|
155
|
+
return this.nsp.name;
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region nsp + name
|
|
159
|
+
get nsp() {
|
|
160
|
+
const self = this;
|
|
161
|
+
return {
|
|
162
|
+
get name() {
|
|
163
|
+
return self.namespaceInstance?.name;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region path
|
|
169
|
+
path() {
|
|
170
|
+
return this.namespaceInstance?.name;
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region on
|
|
174
|
+
on(eventName, handler) {
|
|
175
|
+
if (!this.socketEventHandlers[eventName]) {
|
|
176
|
+
this.socketEventHandlers[eventName] = /* @__PURE__ */ new Set();
|
|
177
|
+
}
|
|
178
|
+
this.socketEventHandlers[eventName].add(handler);
|
|
179
|
+
if (eventName === "connect") {
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
this.emit("connect");
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region emit
|
|
187
|
+
emit(eventName, ...args) {
|
|
188
|
+
eventName = eventName || "";
|
|
189
|
+
if (eventName.includes(`:${Symbols__NS__REALTIME.KEYroomSubscribe}`)) {
|
|
190
|
+
const room = args[0];
|
|
191
|
+
this.join(room);
|
|
192
|
+
} else if (eventName.includes(`:${Symbols__NS__REALTIME.KEYroomUnsubscribe}`)) {
|
|
193
|
+
const room = args[0];
|
|
194
|
+
this.leave(room);
|
|
195
|
+
} else {
|
|
196
|
+
if (this.namespaceInstance) {
|
|
197
|
+
const namespaceEventHandlers = this.namespaceInstance.namespaceEventHandlers[eventName] || [];
|
|
198
|
+
for (const namespaceEventHandler of namespaceEventHandlers) {
|
|
199
|
+
if (namespaceEventHandler) {
|
|
200
|
+
namespaceEventHandler(...args);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const allSocketsForNamespaceExceptCurrent = Array.from(
|
|
204
|
+
this.namespaceInstance.allSocketsForNamespace.values()
|
|
205
|
+
).filter((socket) => socket !== this);
|
|
206
|
+
for (const socket of allSocketsForNamespaceExceptCurrent) {
|
|
207
|
+
const socketEventHandlers2 = socket.socketEventHandlers[eventName];
|
|
208
|
+
for (const socketEventHandler of socketEventHandlers2) {
|
|
209
|
+
if (socketEventHandler) {
|
|
210
|
+
socketEventHandler(...args);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const socketEventHandlers = this.socketEventHandlers[eventName] || [];
|
|
215
|
+
for (const clientHandler of socketEventHandlers) {
|
|
216
|
+
if (clientHandler) {
|
|
217
|
+
clientHandler(...args);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region join room
|
|
225
|
+
join(roomName) {
|
|
226
|
+
this.namespaceInstance.joinRoom(roomName, this);
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region leave room
|
|
230
|
+
leave(roomName) {
|
|
231
|
+
this.namespaceInstance.leaveRoom(roomName, this);
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
234
|
+
}
|
|
235
|
+
class RealtimeStrategyMock extends RealtimeStrategy {
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region constructor
|
|
238
|
+
constructor(ctx) {
|
|
239
|
+
super(ctx);
|
|
240
|
+
this.ctx = ctx;
|
|
241
|
+
}
|
|
242
|
+
//#region toString
|
|
243
|
+
toString() {
|
|
244
|
+
return "mock";
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region server & io
|
|
248
|
+
ioServer(url, opt) {
|
|
249
|
+
const server = MockServer.from(url || this.ctx.uriOrigin);
|
|
250
|
+
return server.of(opt?.path || "/");
|
|
251
|
+
}
|
|
252
|
+
get ioClient() {
|
|
253
|
+
const clientIo = (uri, opts) => {
|
|
254
|
+
return new MockSocket(uri || this.ctx.uriOrigin, opts);
|
|
255
|
+
};
|
|
256
|
+
return clientIo;
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
259
|
+
}
|
|
260
|
+
export {
|
|
261
|
+
RealtimeStrategyMock
|
|
262
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RealtimeStrategy } from "./realtime-strategy";
|
|
2
|
+
import { Server } from "socket.io";
|
|
3
|
+
import { io } from "socket.io-client";
|
|
4
|
+
class RealtimeStrategySocketIO extends RealtimeStrategy {
|
|
5
|
+
constructor(ctx) {
|
|
6
|
+
super(ctx);
|
|
7
|
+
this.ctx = ctx;
|
|
8
|
+
}
|
|
9
|
+
toString() {
|
|
10
|
+
return "socket-io";
|
|
11
|
+
}
|
|
12
|
+
ioServer(...args) {
|
|
13
|
+
return new Server(...args);
|
|
14
|
+
}
|
|
15
|
+
get ioClient() {
|
|
16
|
+
return io;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
RealtimeStrategySocketIO
|
|
21
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ___NS__isString } from "tnp-core/lib-prod";
|
|
2
|
+
import { Symbols__NS__REALTIME } from "../symbols";
|
|
3
|
+
class RealtimeSubsManager {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.options = options;
|
|
6
|
+
}
|
|
7
|
+
isListening = false;
|
|
8
|
+
observers = [];
|
|
9
|
+
//#region methods & getters / start listen if not started
|
|
10
|
+
startListenIfNotStarted(realtime) {
|
|
11
|
+
if (this.options.core.ctx.disabledRealtime) {
|
|
12
|
+
console.warn(`[Taon][startListenIfNotStarted] sockets are disabled`);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (!realtime) {
|
|
16
|
+
console.warn(`[Taon][startListenIfNotStarted] invalid socket connection`);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (!this.isListening) {
|
|
20
|
+
this.isListening = true;
|
|
21
|
+
if (this.options.customEvent) {
|
|
22
|
+
const subscribeEvent = Symbols__NS__REALTIME.ROOM_SUBSCRIBE_CUSTOM(
|
|
23
|
+
this.options.core.ctx.contextName
|
|
24
|
+
);
|
|
25
|
+
realtime.emit(subscribeEvent, this.options.roomName);
|
|
26
|
+
} else {
|
|
27
|
+
if (___NS__isString(this.options.property)) {
|
|
28
|
+
const subscribeEvent = Symbols__NS__REALTIME.ROOM_SUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(
|
|
29
|
+
this.options.core.ctx.contextName
|
|
30
|
+
);
|
|
31
|
+
realtime.emit(subscribeEvent, this.options.roomName);
|
|
32
|
+
} else {
|
|
33
|
+
const subscribeEvent = Symbols__NS__REALTIME.ROOM_SUBSCRIBE_ENTITY_UPDATE_EVENTS(
|
|
34
|
+
this.options.core.ctx.contextName
|
|
35
|
+
);
|
|
36
|
+
realtime.emit(subscribeEvent, this.options.roomName);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
realtime.on(this.options.roomName, (data) => {
|
|
40
|
+
this.update(data);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region methods & getters / add observer
|
|
46
|
+
add(observer) {
|
|
47
|
+
this.observers.push(observer);
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region methods & getters / remove observer
|
|
51
|
+
remove(observer) {
|
|
52
|
+
this.observers = this.observers.filter((obs) => obs !== observer);
|
|
53
|
+
if (this.observers.length === 0) {
|
|
54
|
+
this.isListening = false;
|
|
55
|
+
const { core, customEvent, roomName, property } = this.options;
|
|
56
|
+
const realtime = core.socketFE;
|
|
57
|
+
if (customEvent) {
|
|
58
|
+
realtime.emit(
|
|
59
|
+
Symbols__NS__REALTIME.ROOM_UNSUBSCRIBE_CUSTOM(
|
|
60
|
+
this.options.core.ctx.contextName
|
|
61
|
+
),
|
|
62
|
+
roomName
|
|
63
|
+
);
|
|
64
|
+
} else {
|
|
65
|
+
if (___NS__isString(property)) {
|
|
66
|
+
realtime.emit(
|
|
67
|
+
Symbols__NS__REALTIME.ROOM_UNSUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(
|
|
68
|
+
this.options.core.ctx.contextName
|
|
69
|
+
),
|
|
70
|
+
roomName
|
|
71
|
+
);
|
|
72
|
+
} else {
|
|
73
|
+
realtime.emit(
|
|
74
|
+
Symbols__NS__REALTIME.ROOM_UNSUBSCRIBE_ENTITY_UPDATE_EVENTS(
|
|
75
|
+
this.options.core.ctx.contextName
|
|
76
|
+
),
|
|
77
|
+
roomName
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region methods & getters / update
|
|
85
|
+
update(data) {
|
|
86
|
+
this.observers.forEach((observer) => {
|
|
87
|
+
if (!observer.closed) {
|
|
88
|
+
observer.next(data);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
RealtimeSubsManager
|
|
96
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { OrignalClassKey } from "taon-typeorm/lib-prod";
|
|
2
|
+
import { ___NS__camelCase } from "tnp-core/lib-prod";
|
|
3
|
+
import { SYMBOL } from "typescript-class-helpers/lib-prod";
|
|
4
|
+
class Realtime {
|
|
5
|
+
NAMESPACE(contextName) {
|
|
6
|
+
return `${contextName}-taonRealtimeNsp`;
|
|
7
|
+
}
|
|
8
|
+
TABLE_CHANGE(contextName, tableName) {
|
|
9
|
+
return `${contextName}:listentablename${tableName}`;
|
|
10
|
+
}
|
|
11
|
+
KEYroomSubscribe = `roomSubscribe`;
|
|
12
|
+
KEYroomUnsubscribe = `roomUnsubscribe`;
|
|
13
|
+
// /**
|
|
14
|
+
// * TODO use it or not?
|
|
15
|
+
// * @deprecated
|
|
16
|
+
// */
|
|
17
|
+
// ROOM_NAME_SUBSCRIBER_EVENT(
|
|
18
|
+
// contextName: string,
|
|
19
|
+
// className: string,
|
|
20
|
+
// propertyName: string,
|
|
21
|
+
// ) {
|
|
22
|
+
// return `${contextName}:room${___NS__camelCase(className)}${propertyName}`.toLowerCase();
|
|
23
|
+
// }
|
|
24
|
+
//#region custom events in rooms
|
|
25
|
+
ROOM_NAME_CUSTOM(contextName, customEvent) {
|
|
26
|
+
return `${contextName}:CustomRoomEvent${customEvent}`;
|
|
27
|
+
}
|
|
28
|
+
ROOM_SUBSCRIBE_CUSTOM(contextName) {
|
|
29
|
+
return `${contextName}:${this.KEYroomSubscribe}CustomRoomEvent`;
|
|
30
|
+
}
|
|
31
|
+
ROOM_UNSUBSCRIBE_CUSTOM(contextName) {
|
|
32
|
+
return `${contextName}:${this.KEYroomUnsubscribe}CustomRoomEvent`;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region entity events
|
|
36
|
+
ROOM_NAME_UPDATE_ENTITY(contextName, className, entityId) {
|
|
37
|
+
return `${contextName}:room${___NS__camelCase(className)}${entityId}`.toLowerCase();
|
|
38
|
+
}
|
|
39
|
+
ROOM_SUBSCRIBE_ENTITY_UPDATE_EVENTS(contextName) {
|
|
40
|
+
return `${contextName}:${this.KEYroomSubscribe}EntityEvents`;
|
|
41
|
+
}
|
|
42
|
+
ROOM_UNSUBSCRIBE_ENTITY_UPDATE_EVENTS(contextName) {
|
|
43
|
+
return `${contextName}:${this.KEYroomUnsubscribe}EntityEvents`;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region entity property events
|
|
47
|
+
ROOM_NAME_UPDATE_ENTITY_PROPERTY(contextName, className, property, entityId) {
|
|
48
|
+
return `${contextName}:room${___NS__camelCase(className)}${___NS__camelCase(property)}${entityId}`.toLowerCase();
|
|
49
|
+
}
|
|
50
|
+
ROOM_SUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(contextName) {
|
|
51
|
+
return `${contextName}:${this.KEYroomSubscribe}EntityPropertyEvents`;
|
|
52
|
+
}
|
|
53
|
+
ROOM_UNSUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(contextName) {
|
|
54
|
+
return `${contextName}:${this.KEYroomUnsubscribe}EntityPropertyEvents`;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
}
|
|
58
|
+
const Symbols__NS__ctxInClassOrClassObj = Symbol();
|
|
59
|
+
const Symbols__NS__classNameStaticProperty = SYMBOL.ClassNameStaticProperty;
|
|
60
|
+
const Symbols__NS__fullClassNameStaticProperty = `$$fullclassName$$`;
|
|
61
|
+
const Symbols__NS__orignalClass = OrignalClassKey;
|
|
62
|
+
const Symbols__NS__orignalClassClonesObj = `$$originalClassClonesObj$$`;
|
|
63
|
+
const Symbols__NS__classMethodsNames = `$$classMethodsNames$$`;
|
|
64
|
+
const Symbols__NS__REALTIME = new Realtime();
|
|
65
|
+
const Symbols__NS__metadata = {
|
|
66
|
+
className: `class:realname`,
|
|
67
|
+
options: {
|
|
68
|
+
controller: `controller:options`,
|
|
69
|
+
entity: `entity:options`,
|
|
70
|
+
repository: `repository:options`,
|
|
71
|
+
provider: `provider:options`,
|
|
72
|
+
subscriber: `subscriber:options`,
|
|
73
|
+
migration: `migration:options`
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const Symbols__NS__old = {
|
|
77
|
+
HAS_TABLE_IN_DB: Symbol(),
|
|
78
|
+
MDC_KEY: `modeldataconfig`,
|
|
79
|
+
WEBSQL_REST_PROGRESS_FUN: Symbol(),
|
|
80
|
+
WEBSQL_REST_PROGRESS_FUN_START: Symbol(),
|
|
81
|
+
WEBSQL_REST_PROGRESS_FUN_DONE: Symbol(),
|
|
82
|
+
WEBSQL_REST_PROGRESS_TIMEOUT: Symbol(),
|
|
83
|
+
X_TOTAL_COUNT: `x-total-count`,
|
|
84
|
+
CIRCURAL_OBJECTS_MAP_BODY: `circuralmapbody`,
|
|
85
|
+
CIRCURAL_OBJECTS_MAP_QUERY_PARAM: `circuralmapbody`,
|
|
86
|
+
MAPPING_CONFIG_HEADER: `mappingheader`,
|
|
87
|
+
MAPPING_CONFIG_HEADER_BODY_PARAMS: `mhbodyparams`,
|
|
88
|
+
MAPPING_CONFIG_HEADER_QUERY_PARAMS: `mhqueryparams`,
|
|
89
|
+
ENDPOINT_META_CONFIG: `ng2_rest_endpoint_config`,
|
|
90
|
+
CLASS_DECORATOR_CONTEXT: `$$ng2_rest_class_context`,
|
|
91
|
+
SOCKET_MSG: `socketmessageng2rest`,
|
|
92
|
+
ANGULAR: {
|
|
93
|
+
INPUT_NAMES: Symbol()
|
|
94
|
+
},
|
|
95
|
+
ERROR_MESSAGES: {
|
|
96
|
+
CLASS_NAME_MATCH: `Please check if your "class name" matches @Controller( className ) or @Entity( className )`
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
export {
|
|
100
|
+
Symbols__NS__REALTIME,
|
|
101
|
+
Symbols__NS__classMethodsNames,
|
|
102
|
+
Symbols__NS__classNameStaticProperty,
|
|
103
|
+
Symbols__NS__ctxInClassOrClassObj,
|
|
104
|
+
Symbols__NS__fullClassNameStaticProperty,
|
|
105
|
+
Symbols__NS__metadata,
|
|
106
|
+
Symbols__NS__old,
|
|
107
|
+
Symbols__NS__orignalClass,
|
|
108
|
+
Symbols__NS__orignalClassClonesObj
|
|
109
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ___NS__isArray, ___NS__isFunction, ___NS__isUndefined } from "tnp-core/lib-prod";
|
|
2
|
+
const Validators__NS__classNameVlidation = (className, target) => {
|
|
3
|
+
setTimeout(() => {
|
|
4
|
+
if (___NS__isUndefined(className)) {
|
|
5
|
+
throw `[Taon]
|
|
6
|
+
Please provide "className" property for each Controller and Entity:
|
|
7
|
+
|
|
8
|
+
@Taon.Controller({ className: 'MyExampleCtrl' })
|
|
9
|
+
class MyExampleCtrl {
|
|
10
|
+
...
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Taon.Entity({ className: 'MyExampleEntity' })
|
|
14
|
+
class MyExampleEntity {
|
|
15
|
+
...
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Notice that minified javascript code does not preserve
|
|
19
|
+
Functions/Classes names -this is only solution to preserve classes names.
|
|
20
|
+
|
|
21
|
+
`;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return ___NS__isUndefined(className) ? target.name : className;
|
|
25
|
+
};
|
|
26
|
+
const Validators__NS__checkIfMethodsWithReponseTYpeAlowed = (methods, current) => {
|
|
27
|
+
const defaultResponseType = "text or JSON";
|
|
28
|
+
if (!current.responseType) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
for (let index = 0; index < methods.length; index++) {
|
|
32
|
+
const m = methods[index];
|
|
33
|
+
if (m.path === current.path && m.responseType !== current.responseType) {
|
|
34
|
+
throw new Error(`
|
|
35
|
+
[taon] you can have 2 methods with same path but differetn reponseType-s
|
|
36
|
+
|
|
37
|
+
${m.methodName}( ... path: ${m.path} ) -> responseType: ${m.responseType || defaultResponseType}
|
|
38
|
+
${current.methodName}( ... path: ${current.path} ) -> responseType: ${current.responseType}
|
|
39
|
+
|
|
40
|
+
Please change path name on of the methods.
|
|
41
|
+
|
|
42
|
+
`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const Validators__NS__validateClassFunctions = (controllers, entities, proviers, repositories) => {
|
|
47
|
+
if (___NS__isArray(controllers) && controllers.filter((f) => !___NS__isFunction(f)).length > 0) {
|
|
48
|
+
console.error("controllers", controllers);
|
|
49
|
+
throw `
|
|
50
|
+
|
|
51
|
+
Incorect value for property "controllers" inside Taon.Init(...)
|
|
52
|
+
|
|
53
|
+
`;
|
|
54
|
+
}
|
|
55
|
+
if (___NS__isArray(entities) && entities.filter((f) => !___NS__isFunction(f)).length > 0) {
|
|
56
|
+
console.error("entites", entities);
|
|
57
|
+
throw `
|
|
58
|
+
|
|
59
|
+
Incorect value for property "entities" inside Taon.Init(...)
|
|
60
|
+
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const Validators__NS__preventUndefinedModel = (model, id) => {
|
|
65
|
+
if (___NS__isUndefined(model)) {
|
|
66
|
+
throw `Bad update by id, config, id: ${id}`;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
Validators__NS__checkIfMethodsWithReponseTYpeAlowed,
|
|
71
|
+
Validators__NS__classNameVlidation,
|
|
72
|
+
Validators__NS__preventUndefinedModel,
|
|
73
|
+
Validators__NS__validateClassFunctions
|
|
74
|
+
};
|
package/package.json
CHANGED
|
@@ -2362,7 +2362,17 @@ class TaonAdminService {
|
|
|
2362
2362
|
/* */
|
|
2363
2363
|
/* */
|
|
2364
2364
|
//#endregion
|
|
2365
|
-
let
|
|
2365
|
+
let bodyParser;
|
|
2366
|
+
let cookieParser;
|
|
2367
|
+
let cors;
|
|
2368
|
+
let express;
|
|
2369
|
+
let methodOverride;
|
|
2370
|
+
let expressSession;
|
|
2371
|
+
/* */
|
|
2372
|
+
/* */
|
|
2373
|
+
/* */
|
|
2374
|
+
/* */
|
|
2375
|
+
/* */
|
|
2366
2376
|
/* */
|
|
2367
2377
|
/* */
|
|
2368
2378
|
class EndpointContext {
|