taon 19.0.4 → 19.0.6
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/README.md +175 -175
- package/assets/shared/shared_folder_info.txt +1 -1
- package/bin/start.js +279 -279
- package/bin/taon +6 -6
- package/bin/taon-debug +5 -5
- package/bin/taon-debug-brk +5 -5
- package/browser/README.md +24 -24
- package/browser/fesm2022/taon.mjs +1313 -259
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-class.d.ts +1 -1
- package/browser/lib/base-classes/base-context.d.ts +6 -6
- package/browser/lib/base-classes/base-repository.d.ts +3 -2
- package/browser/lib/base-classes/base.d.ts +6 -6
- package/browser/lib/create-context.d.ts +12 -12
- package/browser/lib/index.d.ts +18 -18
- package/browser/lib/inject.d.ts +4 -1
- package/browser/lib/ui/taon-table/taon-table.component.d.ts +8 -7
- package/browser/package.json +1 -1
- package/cli.js.map +1 -1
- package/client/README.md +24 -24
- package/client/fesm2022/taon.mjs +1313 -259
- package/client/fesm2022/taon.mjs.map +1 -1
- package/client/lib/base-classes/base-class.d.ts +1 -1
- package/client/lib/base-classes/base-context.d.ts +6 -6
- package/client/lib/base-classes/base-repository.d.ts +3 -2
- package/client/lib/base-classes/base.d.ts +6 -6
- package/client/lib/create-context.d.ts +12 -12
- package/client/lib/index.d.ts +18 -18
- package/client/lib/inject.d.ts +4 -1
- package/client/lib/ui/taon-table/taon-table.component.d.ts +8 -7
- package/client/package.json +1 -1
- package/index.js.map +1 -1
- package/lib/base-classes/base-abstract-entity.js +2 -2
- package/lib/base-classes/base-abstract-entity.js.map +1 -1
- package/lib/base-classes/base-class.d.ts +1 -1
- package/lib/base-classes/base-class.js +13 -4
- package/lib/base-classes/base-class.js.map +1 -1
- package/lib/base-classes/base-context.d.ts +6 -6
- package/lib/base-classes/base-context.js.map +1 -1
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/base-classes/base-crud-controller.js +6 -6
- package/lib/base-classes/base-crud-controller.js.map +1 -1
- package/lib/base-classes/base-entity.js +2 -2
- package/lib/base-classes/base-entity.js.map +1 -1
- package/lib/base-classes/base-injector.js +2 -2
- package/lib/base-classes/base-injector.js.map +1 -1
- package/lib/base-classes/base-migration.d.ts +1 -1
- package/lib/base-classes/base-migration.js +2 -2
- package/lib/base-classes/base-migration.js.map +1 -1
- package/lib/base-classes/base-provider.js.map +1 -1
- package/lib/base-classes/base-repository.d.ts +3 -2
- package/lib/base-classes/base-repository.js +14 -11
- package/lib/base-classes/base-repository.js.map +1 -1
- package/lib/base-classes/base-subscriber-for-entity.d.ts +1 -1
- package/lib/base-classes/base-subscriber-for-entity.js.map +1 -1
- package/lib/base-classes/base.d.ts +6 -6
- package/lib/base-classes/base.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +2 -1
- package/lib/build-info._auto-generated_.js +3 -2
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/constants.js.map +1 -1
- package/lib/context-db-migrations.d.ts +1 -1
- package/lib/context-db-migrations.js +7 -7
- package/lib/context-db-migrations.js.map +1 -1
- package/lib/create-context.d.ts +12 -12
- package/lib/create-context.js +13 -13
- package/lib/create-context.js.map +1 -1
- package/lib/decorators/classes/controller-decorator.js.map +1 -1
- package/lib/decorators/classes/entity-decorator.d.ts +1 -1
- package/lib/decorators/classes/entity-decorator.js +8 -8
- package/lib/decorators/classes/entity-decorator.js.map +1 -1
- package/lib/decorators/classes/migration-decorator.js.map +1 -1
- package/lib/decorators/classes/provider-decorator.js.map +1 -1
- package/lib/decorators/classes/repository-decorator.js.map +1 -1
- package/lib/decorators/classes/subscriber-decorator.js.map +1 -1
- package/lib/decorators/http/http-decorators.d.ts +1 -1
- package/lib/decorators/http/http-decorators.js +2 -2
- package/lib/decorators/http/http-decorators.js.map +1 -1
- package/lib/decorators/http/http-methods-decorators.d.ts +1 -1
- package/lib/decorators/http/http-methods-decorators.js +2 -2
- package/lib/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib/decorators/http/http-params-decorators.js.map +1 -1
- package/lib/dependency-injection/di-container.js.map +1 -1
- package/lib/endpoint-context.js +112 -112
- package/lib/endpoint-context.js.map +1 -1
- package/lib/entity-process.js +35 -35
- package/lib/entity-process.js.map +1 -1
- package/lib/env.js +2 -2
- package/lib/env.js.map +1 -1
- package/lib/formly/formly-group-wrapper-component.js.map +1 -1
- package/lib/formly/formly-repeat-component.js.map +1 -1
- package/lib/formly/formly.models.js.map +1 -1
- package/lib/formly/fromly.d.ts +1 -1
- package/lib/formly/fromly.js +26 -26
- package/lib/formly/fromly.js.map +1 -1
- package/lib/formly/type-from-entity.js +6 -6
- package/lib/formly/type-from-entity.js.map +1 -1
- package/lib/get-response-value.js +2 -2
- package/lib/get-response-value.js.map +1 -1
- package/lib/helpers/class-helpers.js +21 -21
- package/lib/helpers/class-helpers.js.map +1 -1
- package/lib/helpers/taon-helpers.js +4 -4
- package/lib/helpers/taon-helpers.js.map +1 -1
- package/lib/index._auto-generated_.js.map +1 -1
- package/lib/index.d.ts +18 -18
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/inject.js +0 -5
- package/lib/inject.js.map +1 -1
- package/lib/models.d.ts +1 -1
- package/lib/models.js +5 -5
- package/lib/models.js.map +1 -1
- package/lib/orm.d.ts +1 -1
- package/lib/orm.js +4 -4
- package/lib/orm.js.map +1 -1
- package/lib/realtime/realtime-client.js +3 -3
- package/lib/realtime/realtime-client.js.map +1 -1
- package/lib/realtime/realtime-core.js +3 -3
- package/lib/realtime/realtime-core.js.map +1 -1
- package/lib/realtime/realtime-server.js +7 -7
- package/lib/realtime/realtime-server.js.map +1 -1
- package/lib/realtime/realtime-strategy/index.js.map +1 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-socket-io.js.map +1 -1
- package/lib/realtime/realtime-strategy/realtime-strategy.js.map +1 -1
- package/lib/realtime/realtime-subs-manager.js +3 -3
- package/lib/realtime/realtime-subs-manager.js.map +1 -1
- package/lib/realtime/realtime.models.js.map +1 -1
- package/lib/storage.js +2 -2
- package/lib/storage.js.map +1 -1
- package/lib/symbols.js +7 -7
- package/lib/symbols.js.map +1 -1
- package/lib/ui/directives/index.js +2 -2
- package/lib/ui/directives/index.js.map +1 -1
- package/lib/ui/directives/view-mode.js.map +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/index.js.map +1 -1
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js.map +1 -1
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +1 -1
- package/lib/ui/taon-github-fork-me-corner/index.js +2 -2
- package/lib/ui/taon-github-fork-me-corner/index.js.map +1 -1
- package/lib/ui/taon-github-fork-me-ribbon/index.js +2 -2
- package/lib/ui/taon-github-fork-me-ribbon/index.js.map +1 -1
- package/lib/ui/taon-notifications/index.js.map +1 -1
- package/lib/ui/taon-notifications/taon-notifications.models.js +2 -2
- package/lib/ui/taon-notifications/taon-notifications.models.js.map +1 -1
- package/lib/ui/taon-progress-bar/index.js +2 -2
- package/lib/ui/taon-progress-bar/index.js.map +1 -1
- package/lib/ui/taon-session-passcode/index.js +2 -2
- package/lib/ui/taon-session-passcode/index.js.map +1 -1
- package/lib/ui/taon-table/index.js +2 -2
- package/lib/ui/taon-table/index.js.map +1 -1
- package/lib/ui/taon-table/taon-table.component.d.ts +7 -6
- package/lib/ui/taon.models.d.ts +1 -1
- package/lib/ui/taon.models.js.map +1 -1
- package/lib/validators.js +8 -8
- package/lib/validators.js.map +1 -1
- package/migrations/index.js.map +1 -1
- package/migrations/migrations_index._auto-generated_.js.map +1 -1
- package/old-app .js +1 -1
- package/old-app .js.map +1 -1
- package/package.json +1 -1
- package/playground.js.map +1 -1
- package/tmp-environment.json +5 -4
- package/websql/README.md +24 -24
- package/websql/fesm2022/taon.mjs +1609 -282
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-class.d.ts +1 -1
- package/websql/lib/base-classes/base-context.d.ts +6 -6
- package/websql/lib/base-classes/base-repository.d.ts +3 -2
- package/websql/lib/base-classes/base.d.ts +6 -6
- package/websql/lib/create-context.d.ts +12 -12
- package/websql/lib/index.d.ts +18 -18
- package/websql/lib/inject.d.ts +4 -1
- package/websql/lib/ui/taon-table/taon-table.component.d.ts +8 -7
- package/websql/package.json +1 -1
- package/browser/lib/storage.d.ts +0 -2
- package/client/lib/storage.d.ts +0 -2
- package/websql/lib/storage.d.ts +0 -2
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import * as coreHelpers from 'tnp-core/browser';
|
|
3
|
-
import { _
|
|
3
|
+
import { _, Utils, Helpers, UtilsOs, json5 } from 'tnp-core/browser';
|
|
4
4
|
import { Models as Models$1, RestHeaders, Resource, Mapping } from 'ng2-rest/browser';
|
|
5
5
|
import { OrignalClassKey, Table } from 'taon-typeorm/browser';
|
|
6
6
|
import { SYMBOL, CLASS } from 'typescript-class-helpers/browser';
|
|
7
7
|
import * as JSON5 from 'json5';
|
|
8
8
|
import { __decorate, __param, __metadata } from 'tslib';
|
|
9
|
+
import { walk } from 'lodash-walk-object/browser';
|
|
9
10
|
import { JSON10 } from 'json10/browser';
|
|
10
|
-
import { Observable, from, Subject, interval, tap, defer, fromEvent, map, debounceTime, distinctUntilChanged, share,
|
|
11
|
+
import { Observable, from, Subject, interval, tap, Subscription, defer, fromEvent, map, debounceTime, distinctUntilChanged, share, takeUntil } from 'rxjs';
|
|
11
12
|
import axios from 'axios';
|
|
12
13
|
import { io } from 'socket.io-client';
|
|
13
14
|
import { Stor } from 'taon-storage/browser';
|
|
14
15
|
import * as i0 from '@angular/core';
|
|
15
|
-
import {
|
|
16
|
+
import { EventEmitter, HostListener, HostBinding, Output, Input, Directive, Pipe, NgModule, Component, Injectable, inject as inject$1, DestroyRef, Self, ViewChild, ChangeDetectorRef } from '@angular/core';
|
|
16
17
|
import { Log, Level } from 'ng2-logger/browser';
|
|
17
18
|
import * as i1 from '@angular/platform-browser';
|
|
18
19
|
import { A11yModule } from '@angular/cdk/a11y';
|
|
@@ -70,7 +71,6 @@ import * as i2 from '@angular/forms';
|
|
|
70
71
|
import { FormGroup, FormControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
71
72
|
import { PasswordModule } from 'primeng/password';
|
|
72
73
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
73
|
-
import * as _ from 'lodash';
|
|
74
74
|
import * as i3 from '@ng-matero/extensions/grid';
|
|
75
75
|
import { MtxGridModule } from '@ng-matero/extensions/grid';
|
|
76
76
|
import * as i1$2 from 'static-columns/browser';
|
|
@@ -97,6 +97,7 @@ var Symbols;
|
|
|
97
97
|
constructor() {
|
|
98
98
|
this.KEYroomSubscribe = `roomSubscribe`;
|
|
99
99
|
this.KEYroomUnsubscribe = `roomUnsubscribe`;
|
|
100
|
+
//#endregion
|
|
100
101
|
}
|
|
101
102
|
NAMESPACE(contextName) {
|
|
102
103
|
return `${contextName}-taonRealtimeNsp`;
|
|
@@ -104,6 +105,18 @@ var Symbols;
|
|
|
104
105
|
TABLE_CHANGE(contextName, tableName) {
|
|
105
106
|
return `${contextName}:listentablename${tableName}`;
|
|
106
107
|
}
|
|
108
|
+
// /**
|
|
109
|
+
// * TODO use it or not?
|
|
110
|
+
// * @deprecated
|
|
111
|
+
// */
|
|
112
|
+
// ROOM_NAME_SUBSCRIBER_EVENT(
|
|
113
|
+
// contextName: string,
|
|
114
|
+
// className: string,
|
|
115
|
+
// propertyName: string,
|
|
116
|
+
// ) {
|
|
117
|
+
// return `${contextName}:room${_.camelCase(className)}${propertyName}`.toLowerCase();
|
|
118
|
+
// }
|
|
119
|
+
//#region custom events in rooms
|
|
107
120
|
ROOM_NAME_CUSTOM(contextName, customEvent) {
|
|
108
121
|
return `${contextName}:CustomRoomEvent${customEvent}`;
|
|
109
122
|
}
|
|
@@ -113,8 +126,10 @@ var Symbols;
|
|
|
113
126
|
ROOM_UNSUBSCRIBE_CUSTOM(contextName) {
|
|
114
127
|
return `${contextName}:${this.KEYroomUnsubscribe}CustomRoomEvent`;
|
|
115
128
|
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region entity events
|
|
116
131
|
ROOM_NAME_UPDATE_ENTITY(contextName, className, entityId) {
|
|
117
|
-
return `${contextName}:room${_
|
|
132
|
+
return `${contextName}:room${_.camelCase(className)}${entityId}`.toLowerCase();
|
|
118
133
|
}
|
|
119
134
|
ROOM_SUBSCRIBE_ENTITY_UPDATE_EVENTS(contextName) {
|
|
120
135
|
return `${contextName}:${this.KEYroomSubscribe}EntityEvents`;
|
|
@@ -122,8 +137,10 @@ var Symbols;
|
|
|
122
137
|
ROOM_UNSUBSCRIBE_ENTITY_UPDATE_EVENTS(contextName) {
|
|
123
138
|
return `${contextName}:${this.KEYroomUnsubscribe}EntityEvents`;
|
|
124
139
|
}
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region entity property events
|
|
125
142
|
ROOM_NAME_UPDATE_ENTITY_PROPERTY(contextName, className, property, entityId) {
|
|
126
|
-
return `${contextName}:room${_
|
|
143
|
+
return `${contextName}:room${_.camelCase(className)}${_.camelCase(property)}${entityId}`.toLowerCase();
|
|
127
144
|
}
|
|
128
145
|
ROOM_SUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(contextName) {
|
|
129
146
|
return `${contextName}:${this.KEYroomSubscribe}EntityPropertyEvents`;
|
|
@@ -170,14 +187,14 @@ var Symbols;
|
|
|
170
187
|
},
|
|
171
188
|
};
|
|
172
189
|
})(Symbols || (Symbols = {}));
|
|
173
|
-
;
|
|
174
|
-
({}); // @--end-of-file-for-module=taon lib/symbols.ts
|
|
175
190
|
|
|
176
191
|
var Validators;
|
|
177
192
|
(function (Validators) {
|
|
193
|
+
//#region vlidate class name
|
|
178
194
|
Validators.classNameVlidation = (className, target) => {
|
|
179
195
|
setTimeout(() => {
|
|
180
|
-
|
|
196
|
+
// console.log(`check after timeout ${className} , production mode: ${FrameworkContext.isProductionMode}`)
|
|
197
|
+
if (_.isUndefined(className)) {
|
|
181
198
|
throw `[Taon]
|
|
182
199
|
Please provide "className" property for each Controller and Entity:
|
|
183
200
|
|
|
@@ -197,8 +214,10 @@ var Validators;
|
|
|
197
214
|
`;
|
|
198
215
|
}
|
|
199
216
|
});
|
|
200
|
-
return _
|
|
217
|
+
return _.isUndefined(className) ? target.name : className;
|
|
201
218
|
};
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region validate method config
|
|
202
221
|
Validators.checkIfMethodsWithReponseTYpeAlowed = (methods, current) => {
|
|
203
222
|
const defaultResponseType = 'text or JSON';
|
|
204
223
|
if (!current.responseType) {
|
|
@@ -219,9 +238,12 @@ var Validators;
|
|
|
219
238
|
}
|
|
220
239
|
}
|
|
221
240
|
};
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region validate class functions
|
|
243
|
+
// TODO
|
|
222
244
|
Validators.validateClassFunctions = (controllers, entities, proviers, repositories) => {
|
|
223
|
-
if (_
|
|
224
|
-
controllers.filter(f => !_
|
|
245
|
+
if (_.isArray(controllers) &&
|
|
246
|
+
controllers.filter(f => !_.isFunction(f)).length > 0) {
|
|
225
247
|
console.error('controllers', controllers);
|
|
226
248
|
throw `
|
|
227
249
|
|
|
@@ -229,8 +251,8 @@ var Validators;
|
|
|
229
251
|
|
|
230
252
|
`;
|
|
231
253
|
}
|
|
232
|
-
if (_
|
|
233
|
-
entities.filter(f => !_
|
|
254
|
+
if (_.isArray(entities) &&
|
|
255
|
+
entities.filter(f => !_.isFunction(f)).length > 0) {
|
|
234
256
|
console.error('entites', entities);
|
|
235
257
|
throw `
|
|
236
258
|
|
|
@@ -239,28 +261,32 @@ var Validators;
|
|
|
239
261
|
`;
|
|
240
262
|
}
|
|
241
263
|
};
|
|
264
|
+
//#endregion
|
|
242
265
|
Validators.preventUndefinedModel = (model, id) => {
|
|
243
|
-
if (_
|
|
266
|
+
if (_.isUndefined(model)) {
|
|
244
267
|
throw `Bad update by id, config, id: ${id}`;
|
|
245
268
|
}
|
|
246
269
|
};
|
|
247
270
|
})(Validators || (Validators = {}));
|
|
248
|
-
;
|
|
249
|
-
({}); // @--end-of-file-for-module=taon lib/validators.ts
|
|
250
271
|
|
|
251
272
|
var TaonHelpers;
|
|
252
273
|
(function (TaonHelpers) {
|
|
274
|
+
//#region fillUpTo string
|
|
253
275
|
TaonHelpers.fillUpTo = (s, nCharacters) => {
|
|
254
|
-
return _
|
|
276
|
+
return _.times(nCharacters, n => {
|
|
255
277
|
if (s.charAt(n)) {
|
|
256
278
|
return s.charAt(n);
|
|
257
279
|
}
|
|
258
280
|
return ' ';
|
|
259
281
|
}).join('');
|
|
260
282
|
};
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region is good path
|
|
261
285
|
TaonHelpers.isGoodPath = (p) => {
|
|
262
286
|
return p && typeof p === 'string' && p.trim() !== '';
|
|
263
287
|
};
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region try transform params
|
|
264
290
|
TaonHelpers.tryTransformParam = param => {
|
|
265
291
|
if (typeof param === 'string') {
|
|
266
292
|
let n = Number(param);
|
|
@@ -283,11 +309,15 @@ var TaonHelpers;
|
|
|
283
309
|
}
|
|
284
310
|
return param;
|
|
285
311
|
};
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region get expores path
|
|
286
314
|
TaonHelpers.getExpressPath = (c, pathOrClassConfig) => {
|
|
287
315
|
if (typeof pathOrClassConfig === 'string')
|
|
288
316
|
return `${c.calculatedPath}${pathOrClassConfig}`.replace(/\/$/, '');
|
|
289
317
|
return `${c.calculatedPath}${pathOrClassConfig.path}`.replace(/\/$/, '');
|
|
290
318
|
};
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region get default value tyep
|
|
291
321
|
TaonHelpers.defaultType = value => {
|
|
292
322
|
if (typeof value === 'string')
|
|
293
323
|
return '';
|
|
@@ -298,8 +328,11 @@ var TaonHelpers;
|
|
|
298
328
|
if (typeof value === 'object')
|
|
299
329
|
return {};
|
|
300
330
|
};
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region parse json with string jsons
|
|
301
333
|
TaonHelpers.parseJSONwithStringJSONs = (object, waring = false) => {
|
|
302
|
-
|
|
334
|
+
// console.log('checking object', object)
|
|
335
|
+
if (!_.isObject(object)) {
|
|
303
336
|
if (waring) {
|
|
304
337
|
console.error(`
|
|
305
338
|
parseJSONwithStringJSONs(...)
|
|
@@ -308,7 +341,7 @@ var TaonHelpers;
|
|
|
308
341
|
}
|
|
309
342
|
return object;
|
|
310
343
|
}
|
|
311
|
-
let res = _
|
|
344
|
+
let res = _.cloneDeep(object);
|
|
312
345
|
Object.keys(res).forEach(key => {
|
|
313
346
|
let isJson = false;
|
|
314
347
|
try {
|
|
@@ -319,15 +352,20 @@ var TaonHelpers;
|
|
|
319
352
|
catch (e) {
|
|
320
353
|
isJson = false;
|
|
321
354
|
}
|
|
355
|
+
// console.log(`key ${key} is json `, isJson)
|
|
322
356
|
if (isJson) {
|
|
323
357
|
res[key] = TaonHelpers.parseJSONwithStringJSONs(res[key], false);
|
|
324
358
|
}
|
|
325
359
|
});
|
|
326
360
|
return res;
|
|
327
361
|
};
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region is plain file or folder
|
|
328
364
|
TaonHelpers.isPlainFileOrFolder = filePath => {
|
|
329
365
|
return /^([a-zA-Z]|\-|\_|\@|\#|\$|\!|\^|\&|\*|\(|\))+$/.test(filePath);
|
|
330
366
|
};
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region ips key name repsonse
|
|
331
369
|
TaonHelpers.ipcKeyNameResponse = (target, methodConfig, expressPath) => {
|
|
332
370
|
return [
|
|
333
371
|
'response',
|
|
@@ -337,6 +375,8 @@ var TaonHelpers;
|
|
|
337
375
|
expressPath,
|
|
338
376
|
].join('--');
|
|
339
377
|
};
|
|
378
|
+
//#endregion
|
|
379
|
+
//#region ipc key name request
|
|
340
380
|
TaonHelpers.ipcKeyNameRequest = (target, methodConfig, expressPath) => {
|
|
341
381
|
return [
|
|
342
382
|
'request',
|
|
@@ -346,34 +386,39 @@ var TaonHelpers;
|
|
|
346
386
|
expressPath,
|
|
347
387
|
].join('--');
|
|
348
388
|
};
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region websql mocks
|
|
349
391
|
TaonHelpers.websqlMocks = headers => {
|
|
350
392
|
const response = {
|
|
351
393
|
status(status) {
|
|
394
|
+
// console.log({status})
|
|
352
395
|
return {
|
|
353
396
|
send(send) {
|
|
397
|
+
// console.log({status})
|
|
354
398
|
},
|
|
355
399
|
};
|
|
356
400
|
},
|
|
357
401
|
setHeader(key, value) {
|
|
402
|
+
// console.log('Dummy set header', arguments)
|
|
358
403
|
headers[key] = value;
|
|
359
404
|
},
|
|
360
405
|
};
|
|
361
406
|
const request = {};
|
|
362
407
|
return { request, response };
|
|
363
408
|
};
|
|
409
|
+
//#endregion
|
|
364
410
|
})(TaonHelpers || (TaonHelpers = {}));
|
|
365
|
-
;
|
|
366
|
-
({}); // @--end-of-file-for-module=taon lib/helpers/taon-helpers.ts
|
|
367
411
|
|
|
368
412
|
/* */
|
|
369
413
|
/* */
|
|
370
414
|
var ClassHelpers;
|
|
371
415
|
(function (ClassHelpers) {
|
|
416
|
+
//#region get class from name
|
|
372
417
|
/**
|
|
373
418
|
* TODO - repalce in every place when getting class fn from object
|
|
374
419
|
*/
|
|
375
420
|
ClassHelpers.getClassFnFromObject = (json) => {
|
|
376
|
-
if (_
|
|
421
|
+
if (_.isUndefined(json) || _.isNull(json)) {
|
|
377
422
|
return;
|
|
378
423
|
}
|
|
379
424
|
if (json.constructor) {
|
|
@@ -384,7 +429,10 @@ var ClassHelpers;
|
|
|
384
429
|
? p.constructor
|
|
385
430
|
: void 0;
|
|
386
431
|
};
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region get name
|
|
387
434
|
ClassHelpers.getName = (classFnOrObject) => {
|
|
435
|
+
// exception for FormData
|
|
388
436
|
if (classFnOrObject instanceof FormData) {
|
|
389
437
|
return 'FormData';
|
|
390
438
|
}
|
|
@@ -395,8 +443,9 @@ var ClassHelpers;
|
|
|
395
443
|
return ((classFnOrObject[Symbols.classNameStaticProperty]
|
|
396
444
|
? classFnOrObject[Symbols.classNameStaticProperty]
|
|
397
445
|
: classFnOrObject?.constructor[Symbols.classNameStaticProperty]) ||
|
|
398
|
-
CLASS.getName(classFnOrObject));
|
|
446
|
+
(_.isFunction(classFnOrObject) ? CLASS.getName(classFnOrObject) : void 0));
|
|
399
447
|
};
|
|
448
|
+
//#endregion
|
|
400
449
|
ClassHelpers.getOrginalClass = (classFnOrObject) => {
|
|
401
450
|
const org = classFnOrObject[Symbols.orignalClass];
|
|
402
451
|
if (!org) {
|
|
@@ -404,7 +453,9 @@ var ClassHelpers;
|
|
|
404
453
|
}
|
|
405
454
|
return ClassHelpers.getOrginalClass(org);
|
|
406
455
|
};
|
|
456
|
+
//#region get full internal name
|
|
407
457
|
ClassHelpers.getFullInternalName = (classFnOrObject) => {
|
|
458
|
+
// exception for FormData
|
|
408
459
|
if (!classFnOrObject) {
|
|
409
460
|
throw new Error(`Cannot get name from: ${classFnOrObject}`);
|
|
410
461
|
}
|
|
@@ -413,55 +464,73 @@ var ClassHelpers;
|
|
|
413
464
|
: classFnOrObject?.constructor[Symbols.fullClassNameStaticProperty]) ||
|
|
414
465
|
void 0);
|
|
415
466
|
};
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region get unique key
|
|
416
469
|
ClassHelpers.getUniqueKey = (classFnOrObject) => {
|
|
417
|
-
const classFn = _
|
|
470
|
+
const classFn = _.isFunction(classFnOrObject)
|
|
418
471
|
? classFnOrObject
|
|
419
472
|
: classFnOrObject.constructor;
|
|
420
473
|
const config = Reflect.getMetadata(Symbols.metadata.options.controller, classFn);
|
|
421
474
|
return config.uniqueKeyProp;
|
|
422
475
|
};
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region is class object
|
|
423
478
|
ClassHelpers.isContextClassObject = (obj) => {
|
|
424
|
-
if (!_
|
|
425
|
-
_
|
|
426
|
-
_
|
|
427
|
-
_
|
|
428
|
-
_
|
|
479
|
+
if (!_.isObject(obj) ||
|
|
480
|
+
_.isArray(obj) ||
|
|
481
|
+
_.isRegExp(obj) ||
|
|
482
|
+
_.isBuffer(obj) ||
|
|
483
|
+
_.isArrayBuffer(obj)) {
|
|
429
484
|
return false;
|
|
430
485
|
}
|
|
431
|
-
if (_
|
|
486
|
+
if (_.isDate(obj)) {
|
|
432
487
|
return true;
|
|
433
488
|
}
|
|
434
489
|
const className = ClassHelpers.getName(obj);
|
|
435
|
-
return _
|
|
490
|
+
return _.isString(className) && className !== 'Object';
|
|
436
491
|
};
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region get name
|
|
437
494
|
ClassHelpers.setName = (target, className) => {
|
|
495
|
+
// console.log('setName', className, target.name)
|
|
438
496
|
Validators.classNameVlidation(className, target);
|
|
439
497
|
target[Symbols.classNameStaticProperty] = className;
|
|
440
498
|
};
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region has parent with class name
|
|
441
501
|
ClassHelpers.hasParentClassWithName = (target, className, targets = []) => {
|
|
442
502
|
if (!target) {
|
|
443
503
|
return false;
|
|
444
504
|
}
|
|
445
505
|
targets.push(target);
|
|
446
506
|
let targetProto = Object.getPrototypeOf(target);
|
|
447
|
-
if (_
|
|
507
|
+
if (_.isFunction(targetProto) &&
|
|
448
508
|
ClassHelpers.getName(targetProto) === className) {
|
|
509
|
+
// console.log(`true "${_.first(targets).name}" for ${targets.map(d => d.name).join(',')}`)
|
|
449
510
|
return true;
|
|
450
511
|
}
|
|
451
512
|
return ClassHelpers.hasParentClassWithName(targetProto, className, targets);
|
|
452
513
|
};
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region get all metadata for controller
|
|
453
516
|
ClassHelpers.getControllerConfig = (target) => {
|
|
454
517
|
const classMetadataOptions = Reflect.getMetadata(Symbols.metadata.options.controller, target);
|
|
455
|
-
const classMetadata = _
|
|
518
|
+
const classMetadata = _.merge(new Models.ControllerConfig(), classMetadataOptions);
|
|
519
|
+
// Iterate over all methods of the class
|
|
456
520
|
const methodNames = ClassHelpers.getMethodsNames(target); // Object.getOwnPropertyNames(target.prototype);
|
|
521
|
+
// console.log(`methodNames for ${ClassHelpers.getName(target)} `, methodNames)
|
|
457
522
|
for (const methodName of methodNames) {
|
|
458
523
|
const methodMetadata = Reflect.getMetadata(Symbols.metadata.options.controllerMethod, target, methodName);
|
|
524
|
+
// console.log('methodMetadata for ' + methodName, methodMetadata)
|
|
459
525
|
if (methodMetadata) {
|
|
460
526
|
classMetadata.methods[methodName] = methodMetadata;
|
|
461
527
|
}
|
|
462
528
|
}
|
|
463
529
|
return classMetadata;
|
|
464
530
|
};
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region get methods name
|
|
533
|
+
//#region not allowed as method name
|
|
465
534
|
const notAllowedAsMethodName = [
|
|
466
535
|
'length',
|
|
467
536
|
'name',
|
|
@@ -483,11 +552,12 @@ var ClassHelpers;
|
|
|
483
552
|
'__proto__',
|
|
484
553
|
'toLocaleString',
|
|
485
554
|
];
|
|
555
|
+
//#endregion
|
|
486
556
|
ClassHelpers.getMethodsNames = (classOrClassInstance, allMethodsNames = []) => {
|
|
487
557
|
if (!classOrClassInstance) {
|
|
488
558
|
return Utils.uniqArray(allMethodsNames);
|
|
489
559
|
}
|
|
490
|
-
const isClassFunction = _
|
|
560
|
+
const isClassFunction = _.isFunction(classOrClassInstance);
|
|
491
561
|
const classFun = isClassFunction
|
|
492
562
|
? classOrClassInstance
|
|
493
563
|
: Object.getPrototypeOf(classOrClassInstance);
|
|
@@ -495,7 +565,7 @@ var ClassHelpers;
|
|
|
495
565
|
? classOrClassInstance?.prototype
|
|
496
566
|
: classOrClassInstance;
|
|
497
567
|
const prototypeObj = Object.getPrototypeOf(objectToCheck || {});
|
|
498
|
-
const properties = _
|
|
568
|
+
const properties = _.uniq([
|
|
499
569
|
...Object.getOwnPropertyNames(objectToCheck || {}),
|
|
500
570
|
...Object.getOwnPropertyNames(prototypeObj || {}),
|
|
501
571
|
...Object.keys(objectToCheck || {}),
|
|
@@ -511,23 +581,27 @@ var ClassHelpers;
|
|
|
511
581
|
}
|
|
512
582
|
return ClassHelpers.getMethodsNames(Object.getPrototypeOf(classFun), allMethodsNames);
|
|
513
583
|
};
|
|
584
|
+
//#endregion
|
|
585
|
+
//#region get controller configs
|
|
514
586
|
ClassHelpers.getControllerConfigs = (target, configs = [], callerTarget) => {
|
|
515
|
-
if (!_
|
|
587
|
+
if (!_.isFunction(target)) {
|
|
516
588
|
throw `[typescript-class-helper][getClassConfig] Cannot get class config from: ${target}`;
|
|
517
589
|
}
|
|
518
590
|
let config;
|
|
519
591
|
const parentClass = Object.getPrototypeOf(target);
|
|
520
592
|
const parentName = parentClass ? ClassHelpers.getName(parentClass) : void 0;
|
|
521
|
-
const isValidParent = _
|
|
593
|
+
const isValidParent = _.isFunction(parentClass) && parentName !== '';
|
|
522
594
|
config = ClassHelpers.getControllerConfig(target);
|
|
523
595
|
configs.push(config);
|
|
524
596
|
return isValidParent
|
|
525
597
|
? ClassHelpers.getControllerConfigs(parentClass, configs, target)
|
|
526
598
|
: configs;
|
|
527
599
|
};
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region get path for
|
|
528
602
|
ClassHelpers.getCalculatedPathFor = (target) => {
|
|
529
603
|
const configs = ClassHelpers.getControllerConfigs(target);
|
|
530
|
-
const parentscalculatedPath = _
|
|
604
|
+
const parentscalculatedPath = _.slice(configs, 1)
|
|
531
605
|
.reverse()
|
|
532
606
|
.map(bc => {
|
|
533
607
|
if (TaonHelpers.isGoodPath(bc.path)) {
|
|
@@ -538,14 +612,12 @@ var ClassHelpers;
|
|
|
538
612
|
.join('/');
|
|
539
613
|
return `/${parentscalculatedPath}/${ClassHelpers.getName(target)}`;
|
|
540
614
|
};
|
|
615
|
+
//#endregion
|
|
541
616
|
})(ClassHelpers || (ClassHelpers = {}));
|
|
542
|
-
;
|
|
543
|
-
({}); // @--end-of-file-for-module=taon lib/helpers/class-helpers.ts
|
|
544
617
|
|
|
545
|
-
/* */
|
|
546
|
-
/* */
|
|
547
618
|
var Models;
|
|
548
619
|
(function (Models) {
|
|
620
|
+
//#region models / class types
|
|
549
621
|
let ClassType;
|
|
550
622
|
(function (ClassType) {
|
|
551
623
|
ClassType["ENTITY"] = "ENTITY";
|
|
@@ -563,12 +635,16 @@ var Models;
|
|
|
563
635
|
[ClassType.SUBSCRIBER]: 'subscribers',
|
|
564
636
|
[ClassType.MIGRATION]: 'migrations',
|
|
565
637
|
};
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region models / database connection options
|
|
566
640
|
class DatabaseConfigTypeOrm {
|
|
567
641
|
}
|
|
568
642
|
Models.DatabaseConfigTypeOrm = DatabaseConfigTypeOrm;
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region models / database config
|
|
569
645
|
class DatabaseConfig extends DatabaseConfigTypeOrm {
|
|
570
646
|
static from(databasePartialConfig) {
|
|
571
|
-
return _
|
|
647
|
+
return _.merge(new DatabaseConfig(), databasePartialConfig);
|
|
572
648
|
}
|
|
573
649
|
get databaseConfigTypeORM() {
|
|
574
650
|
/* */
|
|
@@ -589,12 +665,18 @@ var Models;
|
|
|
589
665
|
}
|
|
590
666
|
}
|
|
591
667
|
Models.DatabaseConfig = DatabaseConfig;
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region models / decorator abstract options
|
|
592
670
|
class DecoratorAbstractOpt {
|
|
593
671
|
}
|
|
594
672
|
Models.DecoratorAbstractOpt = DecoratorAbstractOpt;
|
|
673
|
+
//#endregion
|
|
674
|
+
//#region models / param config
|
|
595
675
|
class ParamConfig {
|
|
596
676
|
}
|
|
597
677
|
Models.ParamConfig = ParamConfig;
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region models / method config
|
|
598
680
|
class MethodConfig {
|
|
599
681
|
constructor() {
|
|
600
682
|
/* */
|
|
@@ -603,6 +685,8 @@ var Models;
|
|
|
603
685
|
}
|
|
604
686
|
}
|
|
605
687
|
Models.MethodConfig = MethodConfig;
|
|
688
|
+
//#endregion
|
|
689
|
+
//#region models / controller config
|
|
606
690
|
class ControllerConfig extends DecoratorAbstractOpt {
|
|
607
691
|
constructor() {
|
|
608
692
|
super(...arguments);
|
|
@@ -610,9 +694,13 @@ var Models;
|
|
|
610
694
|
}
|
|
611
695
|
}
|
|
612
696
|
Models.ControllerConfig = ControllerConfig;
|
|
697
|
+
//#endregion
|
|
698
|
+
//#region models / runtime controller config
|
|
613
699
|
class RuntimeControllerConfig extends ControllerConfig {
|
|
614
700
|
}
|
|
615
701
|
Models.RuntimeControllerConfig = RuntimeControllerConfig;
|
|
702
|
+
//#endregion
|
|
703
|
+
//#region models / http
|
|
616
704
|
let Http;
|
|
617
705
|
(function (Http) {
|
|
618
706
|
Http.Rest = Models$1;
|
|
@@ -641,9 +729,8 @@ var Models;
|
|
|
641
729
|
/* */
|
|
642
730
|
/* */
|
|
643
731
|
})(Http = Models.Http || (Models.Http = {}));
|
|
732
|
+
//#endregion
|
|
644
733
|
})(Models || (Models = {}));
|
|
645
|
-
;
|
|
646
|
-
({}); // @--end-of-file-for-module=taon lib/models.ts
|
|
647
734
|
|
|
648
735
|
const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
|
|
649
736
|
let options;
|
|
@@ -670,7 +757,7 @@ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, p
|
|
|
670
757
|
if (methodConfig.parameters.hasOwnProperty(key)) {
|
|
671
758
|
const element = methodConfig.parameters[key];
|
|
672
759
|
if (element.paramType === 'Path' &&
|
|
673
|
-
_
|
|
760
|
+
_.isString(element.paramName) &&
|
|
674
761
|
element.paramName.trim().length > 0) {
|
|
675
762
|
paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
|
|
676
763
|
}
|
|
@@ -686,6 +773,7 @@ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, p
|
|
|
686
773
|
methodConfig.contentType = overrideContentType;
|
|
687
774
|
methodConfig.responseType = overridResponseType;
|
|
688
775
|
Reflect.defineMetadata(Symbols.metadata.options.controllerMethod, methodConfig, target.constructor, propertyKey);
|
|
776
|
+
// console.log('methods updated', methodConfig);
|
|
689
777
|
};
|
|
690
778
|
function GET(pathOrOptions, pathIsGlobal = false) {
|
|
691
779
|
return function (target, propertyKey, descriptor) {
|
|
@@ -717,8 +805,6 @@ function DELETE(pathOrOptions, pathIsGlobal = false) {
|
|
|
717
805
|
metaReq('delete', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
|
|
718
806
|
};
|
|
719
807
|
}
|
|
720
|
-
;
|
|
721
|
-
({}); // @--end-of-file-for-module=taon lib/decorators/http/http-methods-decorators.ts
|
|
722
808
|
|
|
723
809
|
function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
|
|
724
810
|
let methodConfig = Reflect.getMetadata(Symbols.metadata.options.controllerMethod, target.constructor, propertyKey);
|
|
@@ -736,6 +822,7 @@ function metaParam(param, name, expire, defaultValue = undefined, target, proper
|
|
|
736
822
|
p.defaultType = defaultValue;
|
|
737
823
|
p.expireInSeconds = expire;
|
|
738
824
|
Reflect.defineMetadata(Symbols.metadata.options.controllerMethod, methodConfig, target.constructor, propertyKey);
|
|
825
|
+
// console.log('params updated', methodConfig);
|
|
739
826
|
}
|
|
740
827
|
function Path(name) {
|
|
741
828
|
return function (target, propertyKey, parameterIndex) {
|
|
@@ -762,8 +849,6 @@ function Body(name) {
|
|
|
762
849
|
metaParam('Body', name, undefined, {}, target, propertyKey, parameterIndex);
|
|
763
850
|
};
|
|
764
851
|
}
|
|
765
|
-
;
|
|
766
|
-
({}); // @--end-of-file-for-module=taon lib/decorators/http/http-params-decorators.ts
|
|
767
852
|
|
|
768
853
|
var Http;
|
|
769
854
|
(function (Http) {
|
|
@@ -783,8 +868,6 @@ var Http;
|
|
|
783
868
|
Param.Header = Header;
|
|
784
869
|
})(Param = Http.Param || (Http.Param = {}));
|
|
785
870
|
})(Http || (Http = {}));
|
|
786
|
-
;
|
|
787
|
-
({}); // @--end-of-file-for-module=taon lib/decorators/http/http-decorators.ts
|
|
788
871
|
|
|
789
872
|
/**
|
|
790
873
|
* Controller decorator
|
|
@@ -798,16 +881,19 @@ function TaonController(options) {
|
|
|
798
881
|
}
|
|
799
882
|
class TaonControllerOptions extends Models.DecoratorAbstractOpt {
|
|
800
883
|
}
|
|
801
|
-
;
|
|
802
|
-
({}); // @--end-of-file-for-module=taon lib/decorators/classes/controller-decorator.ts
|
|
803
884
|
|
|
885
|
+
//#region imports
|
|
886
|
+
//#endregion
|
|
804
887
|
class BaseInjector {
|
|
805
888
|
constructor() {
|
|
889
|
+
//#endregion
|
|
806
890
|
/**
|
|
807
891
|
* Repositories to init (by controller)
|
|
808
892
|
*/
|
|
809
893
|
this.__repositories_to_init__ = [];
|
|
894
|
+
//#endregion
|
|
810
895
|
}
|
|
896
|
+
//#region class initialization hook
|
|
811
897
|
/**
|
|
812
898
|
* class initialization hook
|
|
813
899
|
* taon after class instace creation
|
|
@@ -818,6 +904,8 @@ class BaseInjector {
|
|
|
818
904
|
await repo.__init(this);
|
|
819
905
|
}
|
|
820
906
|
}
|
|
907
|
+
//#endregion
|
|
908
|
+
//#region context
|
|
821
909
|
/**
|
|
822
910
|
* @deprecated use ctx instead
|
|
823
911
|
* Current endpoint context
|
|
@@ -831,6 +919,9 @@ class BaseInjector {
|
|
|
831
919
|
get ctx() {
|
|
832
920
|
return this.__endpoint_context__;
|
|
833
921
|
}
|
|
922
|
+
//#endregion
|
|
923
|
+
//#region inject
|
|
924
|
+
//#region inject / repo for entity
|
|
834
925
|
/**
|
|
835
926
|
* inject crud repo for entity
|
|
836
927
|
*/
|
|
@@ -843,6 +934,8 @@ class BaseInjector {
|
|
|
843
934
|
this.__repositories_to_init__.push(repoProxy);
|
|
844
935
|
return repoProxy;
|
|
845
936
|
}
|
|
937
|
+
//#endregion
|
|
938
|
+
//#region inject / custom repository
|
|
846
939
|
injectCustomRepository(cutomRepositoryClass) {
|
|
847
940
|
const repoProxy = this.__inject(cutomRepositoryClass, {
|
|
848
941
|
localInstance: true,
|
|
@@ -853,6 +946,8 @@ class BaseInjector {
|
|
|
853
946
|
this.__repositories_to_init__.push(repoProxy);
|
|
854
947
|
return repoProxy;
|
|
855
948
|
}
|
|
949
|
+
//#endregion
|
|
950
|
+
//#region inject / custom repo
|
|
856
951
|
/**
|
|
857
952
|
* aliast to .injectRepository()
|
|
858
953
|
*/
|
|
@@ -861,27 +956,37 @@ class BaseInjector {
|
|
|
861
956
|
this.__repositories_to_init__.push(repoProxy);
|
|
862
957
|
return repoProxy;
|
|
863
958
|
}
|
|
959
|
+
//#endregion
|
|
960
|
+
//#region inject / controller
|
|
864
961
|
injectController(ctor) {
|
|
865
962
|
return this.__inject(ctor, { localInstance: false });
|
|
866
963
|
}
|
|
964
|
+
//#endregion
|
|
965
|
+
//#region inject / ctrl
|
|
867
966
|
/**
|
|
868
967
|
* aliast to .injectController()
|
|
869
968
|
*/
|
|
870
969
|
injectSubscriber(ctor) {
|
|
871
970
|
return this.__inject(ctor, { localInstance: false });
|
|
872
971
|
}
|
|
972
|
+
//#endregion
|
|
973
|
+
//#region inject / ctrl
|
|
873
974
|
/**
|
|
874
975
|
* aliast to .injectController()
|
|
875
976
|
*/
|
|
876
977
|
injectCtrl(ctor) {
|
|
877
978
|
return this.injectController(ctor);
|
|
878
979
|
}
|
|
980
|
+
//#endregion
|
|
981
|
+
//#region inject / global provider
|
|
879
982
|
/**
|
|
880
983
|
* global provider available in every context
|
|
881
984
|
*/
|
|
882
985
|
injectGlobalProvider(ctor) {
|
|
883
986
|
return this.__inject(ctor, { localInstance: false });
|
|
884
987
|
}
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region inject / context provider
|
|
885
990
|
/**
|
|
886
991
|
* context scoped provider
|
|
887
992
|
* TODO
|
|
@@ -889,6 +994,7 @@ class BaseInjector {
|
|
|
889
994
|
injectContextProvider(ctor) {
|
|
890
995
|
return this.__inject(ctor, { localInstance: false });
|
|
891
996
|
}
|
|
997
|
+
//#region inject / __ inject
|
|
892
998
|
/**
|
|
893
999
|
* Inject: Controllers, Providers, Repositories, Services, etc.
|
|
894
1000
|
* TODO addd nest js injecting
|
|
@@ -924,8 +1030,12 @@ class BaseInjector {
|
|
|
924
1030
|
const result = typeof instance[propName] === 'function'
|
|
925
1031
|
? instance[propName].bind(instance)
|
|
926
1032
|
: instance[propName];
|
|
1033
|
+
// console.log(`Accessing injected "${propName?.toString()}" from "${ClassHelpers.getName(ctor) || ctor.name}"`,result)
|
|
927
1034
|
return result;
|
|
928
1035
|
}
|
|
1036
|
+
//#region @browser
|
|
1037
|
+
// return inject(ctor)[propName];
|
|
1038
|
+
//#endregion
|
|
929
1039
|
},
|
|
930
1040
|
set: (__, propName, value) => {
|
|
931
1041
|
const contextFromClass = ctor && ctor[Symbols.ctxInClassOrClassObj];
|
|
@@ -956,14 +1066,16 @@ class BaseInjector {
|
|
|
956
1066
|
},
|
|
957
1067
|
});
|
|
958
1068
|
}
|
|
1069
|
+
//#endregion
|
|
1070
|
+
//#endregion
|
|
1071
|
+
//#region clone
|
|
959
1072
|
clone(override) {
|
|
960
1073
|
const classFn = ClassHelpers.getClassFnFromObject(this);
|
|
961
|
-
const result = _
|
|
1074
|
+
const result = _.merge(new classFn(), _.merge(_.cloneDeep(this), override));
|
|
1075
|
+
// console.log({result})
|
|
962
1076
|
return result;
|
|
963
1077
|
}
|
|
964
1078
|
}
|
|
965
|
-
;
|
|
966
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base-injector.ts
|
|
967
1079
|
|
|
968
1080
|
let BaseController = class BaseController extends BaseInjector {
|
|
969
1081
|
/**
|
|
@@ -977,15 +1089,16 @@ let BaseController = class BaseController extends BaseInjector {
|
|
|
977
1089
|
BaseController = __decorate([
|
|
978
1090
|
TaonController({ className: 'BaseController' })
|
|
979
1091
|
], BaseController);
|
|
980
|
-
;
|
|
981
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base-controller.ts
|
|
982
1092
|
|
|
1093
|
+
//#endregion
|
|
983
1094
|
/**
|
|
984
1095
|
* Please override property entityClassFn with entity class.
|
|
985
1096
|
*/
|
|
986
1097
|
let BaseCrudController = class BaseCrudController extends BaseController {
|
|
1098
|
+
//#endregion
|
|
1099
|
+
//#region init
|
|
987
1100
|
async _() {
|
|
988
|
-
if (!_
|
|
1101
|
+
if (!_.isFunction(this.entityClassResolveFn)) {
|
|
989
1102
|
Helpers.warn(`Skipping initing CRUD controller ${ClassHelpers.getName(this)} because entityClassResolveFn is not provided.`);
|
|
990
1103
|
return;
|
|
991
1104
|
}
|
|
@@ -1003,15 +1116,17 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
1003
1116
|
Please provide entity as class propery entityClassFn:
|
|
1004
1117
|
|
|
1005
1118
|
class ${ClassHelpers.getName(this)} extends BaseCrudController<Entity> {
|
|
1006
|
-
|
|
1119
|
+
// ...
|
|
1007
1120
|
entityClassResolveFn = ()=> MyEntityClass;
|
|
1008
|
-
|
|
1121
|
+
// ...
|
|
1009
1122
|
}
|
|
1010
1123
|
|
|
1011
1124
|
`);
|
|
1012
1125
|
}
|
|
1013
1126
|
await super._();
|
|
1014
1127
|
}
|
|
1128
|
+
//#endregion
|
|
1129
|
+
//#region bufferd changes
|
|
1015
1130
|
bufforedChanges(id, property, alreadyLength) {
|
|
1016
1131
|
/* */
|
|
1017
1132
|
/* */
|
|
@@ -1030,6 +1145,8 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
1030
1145
|
/* */
|
|
1031
1146
|
return (void 0);
|
|
1032
1147
|
}
|
|
1148
|
+
//#endregion
|
|
1149
|
+
//#region pagintation
|
|
1033
1150
|
pagination(pageNumber = 1, pageSize = 10, search = '') {
|
|
1034
1151
|
/* */
|
|
1035
1152
|
/* */
|
|
@@ -1071,6 +1188,8 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
1071
1188
|
/* */
|
|
1072
1189
|
return (void 0);
|
|
1073
1190
|
}
|
|
1191
|
+
//#endregion
|
|
1192
|
+
//#region get all
|
|
1074
1193
|
getAll() {
|
|
1075
1194
|
/* */
|
|
1076
1195
|
/* */
|
|
@@ -1083,6 +1202,8 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
1083
1202
|
/* */
|
|
1084
1203
|
return (void 0);
|
|
1085
1204
|
}
|
|
1205
|
+
//#endregion
|
|
1206
|
+
//#region get by id
|
|
1086
1207
|
getBy(id) {
|
|
1087
1208
|
/* */
|
|
1088
1209
|
/* */
|
|
@@ -1091,6 +1212,8 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
1091
1212
|
/* */
|
|
1092
1213
|
return (void 0);
|
|
1093
1214
|
}
|
|
1215
|
+
//#endregion
|
|
1216
|
+
//#region update by id
|
|
1094
1217
|
updateById(id, item) {
|
|
1095
1218
|
/* */
|
|
1096
1219
|
/* */
|
|
@@ -1100,6 +1223,8 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
1100
1223
|
/* */
|
|
1101
1224
|
return (void 0);
|
|
1102
1225
|
}
|
|
1226
|
+
//#endregion
|
|
1227
|
+
//#region patch by id
|
|
1103
1228
|
patchById(id, item) {
|
|
1104
1229
|
/* */
|
|
1105
1230
|
/* */
|
|
@@ -1109,6 +1234,8 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
1109
1234
|
/* */
|
|
1110
1235
|
return (void 0);
|
|
1111
1236
|
}
|
|
1237
|
+
//#endregion
|
|
1238
|
+
//#region bulk update
|
|
1112
1239
|
bulkUpdate(items) {
|
|
1113
1240
|
/* */
|
|
1114
1241
|
/* */
|
|
@@ -1120,6 +1247,8 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
1120
1247
|
/* */
|
|
1121
1248
|
return (void 0);
|
|
1122
1249
|
}
|
|
1250
|
+
//#endregion
|
|
1251
|
+
//#region delete by id
|
|
1123
1252
|
deleteById(id) {
|
|
1124
1253
|
/* */
|
|
1125
1254
|
/* */
|
|
@@ -1128,6 +1257,8 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
1128
1257
|
/* */
|
|
1129
1258
|
return (void 0);
|
|
1130
1259
|
}
|
|
1260
|
+
//#endregion
|
|
1261
|
+
//#region bulk delete
|
|
1131
1262
|
bulkDelete(ids) {
|
|
1132
1263
|
/* */
|
|
1133
1264
|
/* */
|
|
@@ -1136,6 +1267,8 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
1136
1267
|
/* */
|
|
1137
1268
|
return (void 0);
|
|
1138
1269
|
}
|
|
1270
|
+
//#endregion
|
|
1271
|
+
//#region create
|
|
1139
1272
|
create(item) {
|
|
1140
1273
|
/* */
|
|
1141
1274
|
/* */
|
|
@@ -1144,6 +1277,8 @@ let BaseCrudController = class BaseCrudController extends BaseController {
|
|
|
1144
1277
|
/* */
|
|
1145
1278
|
return (void 0);
|
|
1146
1279
|
}
|
|
1280
|
+
//#endregion
|
|
1281
|
+
//#region bulk create
|
|
1147
1282
|
bulkCreate(items) {
|
|
1148
1283
|
/* */
|
|
1149
1284
|
/* */
|
|
@@ -1238,23 +1373,35 @@ __decorate([
|
|
|
1238
1373
|
BaseCrudController = __decorate([
|
|
1239
1374
|
TaonController({ className: 'BaseCrudController' })
|
|
1240
1375
|
], BaseCrudController);
|
|
1241
|
-
;
|
|
1242
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base-crud-controller.ts
|
|
1243
1376
|
|
|
1377
|
+
//#region imports
|
|
1378
|
+
//#endregion
|
|
1244
1379
|
class BaseClass {
|
|
1380
|
+
//#region class initialization hook
|
|
1245
1381
|
/**
|
|
1246
1382
|
* class initialization hook
|
|
1247
1383
|
* taon after class instance creation
|
|
1248
1384
|
*/
|
|
1249
1385
|
async _() { }
|
|
1386
|
+
//#endregion
|
|
1387
|
+
//#region clone
|
|
1250
1388
|
clone(override) {
|
|
1251
1389
|
const classFn = ClassHelpers.getClassFnFromObject(this);
|
|
1252
|
-
const result = _
|
|
1390
|
+
const result = _.merge(new classFn(), _.cloneDeep(this));
|
|
1391
|
+
walk.Object(override || {}, (value, lodashPath) => {
|
|
1392
|
+
if (_.isNil(value) || _.isFunction(value) || _.isObject(value)) {
|
|
1393
|
+
// skipping
|
|
1394
|
+
}
|
|
1395
|
+
else {
|
|
1396
|
+
_.set(result, lodashPath, value);
|
|
1397
|
+
}
|
|
1398
|
+
}, {
|
|
1399
|
+
walkGetters: false,
|
|
1400
|
+
});
|
|
1401
|
+
// console.log({result})
|
|
1253
1402
|
return result;
|
|
1254
1403
|
}
|
|
1255
1404
|
}
|
|
1256
|
-
;
|
|
1257
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base-class.ts
|
|
1258
1405
|
|
|
1259
1406
|
/* */
|
|
1260
1407
|
/* */
|
|
@@ -1268,11 +1415,10 @@ let BaseEntity = class BaseEntity extends BaseClass {
|
|
|
1268
1415
|
BaseEntity = __decorate([
|
|
1269
1416
|
EntityDecorator$1()
|
|
1270
1417
|
], BaseEntity);
|
|
1271
|
-
;
|
|
1272
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base-entity.ts
|
|
1273
1418
|
|
|
1274
1419
|
/* */
|
|
1275
1420
|
/* */
|
|
1421
|
+
// empty decorator
|
|
1276
1422
|
let EntityDecorator = () => {
|
|
1277
1423
|
return (target) => { };
|
|
1278
1424
|
};
|
|
@@ -1283,8 +1429,6 @@ let BaseAbstractEntity = class BaseAbstractEntity extends BaseEntity {
|
|
|
1283
1429
|
BaseAbstractEntity = __decorate([
|
|
1284
1430
|
EntityDecorator()
|
|
1285
1431
|
], BaseAbstractEntity);
|
|
1286
|
-
;
|
|
1287
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base-abstract-entity.ts
|
|
1288
1432
|
|
|
1289
1433
|
/**
|
|
1290
1434
|
* Repository decorator
|
|
@@ -1298,14 +1442,16 @@ function TaonRepository(options) {
|
|
|
1298
1442
|
}
|
|
1299
1443
|
class TaonRepositoryOptions extends Models.DecoratorAbstractOpt {
|
|
1300
1444
|
}
|
|
1301
|
-
;
|
|
1302
|
-
({}); // @--end-of-file-for-module=taon lib/decorators/classes/repository-decorator.ts
|
|
1303
1445
|
|
|
1446
|
+
//#endregion
|
|
1304
1447
|
const INDEX_KEYS_NO_FOR_UPDATE = ['id'];
|
|
1305
1448
|
let BaseRepository = class BaseRepository extends BaseInjector {
|
|
1306
|
-
constructor(
|
|
1449
|
+
constructor(
|
|
1450
|
+
// Injected through BaseCrudController
|
|
1451
|
+
__entityClassResolveFn) {
|
|
1307
1452
|
super();
|
|
1308
1453
|
this.__entityClassResolveFn = __entityClassResolveFn;
|
|
1454
|
+
this.allowedTypesToUpdate = ['simple-json', 'simple-array', 'json'];
|
|
1309
1455
|
// @ts-ignore
|
|
1310
1456
|
this.entityClassResolveFn = __entityClassResolveFn;
|
|
1311
1457
|
}
|
|
@@ -1331,11 +1477,15 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1331
1477
|
/* */
|
|
1332
1478
|
return (void 0);
|
|
1333
1479
|
}
|
|
1480
|
+
//#endregion
|
|
1481
|
+
//#region connection
|
|
1334
1482
|
get connection() {
|
|
1335
1483
|
/* */
|
|
1336
1484
|
/* */
|
|
1337
1485
|
return (void 0);
|
|
1338
1486
|
}
|
|
1487
|
+
//#endregion
|
|
1488
|
+
//#region repository
|
|
1339
1489
|
/* */
|
|
1340
1490
|
/* */
|
|
1341
1491
|
get repository() {
|
|
@@ -1364,6 +1514,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1364
1514
|
/* */
|
|
1365
1515
|
return (void 0);
|
|
1366
1516
|
}
|
|
1517
|
+
//#endregion
|
|
1518
|
+
//#region init
|
|
1367
1519
|
async __init(context) {
|
|
1368
1520
|
/* */
|
|
1369
1521
|
/* */
|
|
@@ -1417,6 +1569,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1417
1569
|
/* */
|
|
1418
1570
|
/* */
|
|
1419
1571
|
}
|
|
1572
|
+
//#endregion
|
|
1573
|
+
//#region crud operations / typeorm / has id
|
|
1420
1574
|
/**
|
|
1421
1575
|
* Checks if entity has an id.
|
|
1422
1576
|
* If entity composite compose ids, it will check them all.
|
|
@@ -1424,12 +1578,16 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1424
1578
|
hasId(entity) {
|
|
1425
1579
|
return this.repo.hasId(entity);
|
|
1426
1580
|
}
|
|
1581
|
+
//#endregion
|
|
1582
|
+
//#region crud operations / typeorm / get id
|
|
1427
1583
|
/**
|
|
1428
1584
|
* Gets entity mixed id.
|
|
1429
1585
|
*/
|
|
1430
1586
|
getId(entity) {
|
|
1431
1587
|
return this.repo.getId(entity);
|
|
1432
1588
|
}
|
|
1589
|
+
//#endregion
|
|
1590
|
+
//#region crud operations / typeorm / create & bulk create
|
|
1433
1591
|
/**
|
|
1434
1592
|
Saves a given entity in the database.
|
|
1435
1593
|
* If entity does not exist in the database then inserts, otherwise updates.
|
|
@@ -1471,16 +1629,70 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1471
1629
|
async bulkCreate(items, options) {
|
|
1472
1630
|
return this.bulkSave(items, options);
|
|
1473
1631
|
}
|
|
1632
|
+
//#region old typeorm version
|
|
1633
|
+
// /**
|
|
1634
|
+
// * Creates a new entity instance.
|
|
1635
|
+
// */
|
|
1636
|
+
// create(): Entity;
|
|
1637
|
+
// /**
|
|
1638
|
+
// * Creates new entities and copies all entity properties from given objects into their new entities.
|
|
1639
|
+
// * Note that it copies only properties that are present in entity schema.
|
|
1640
|
+
// */
|
|
1641
|
+
// create(entityLikeArray: Entity[]): Entity[];
|
|
1642
|
+
// /**
|
|
1643
|
+
// * Creates a new entity instance and copies all entity properties from this object into a new entity.
|
|
1644
|
+
// * Note that it copies only properties that are present in entity schema.
|
|
1645
|
+
// */
|
|
1646
|
+
// create(entityLike: Entity): Entity;
|
|
1474
1647
|
/**
|
|
1475
1648
|
* Saves all given entities in the database.
|
|
1476
1649
|
* If entities do not exist in the database then inserts, otherwise updates.
|
|
1477
1650
|
*/
|
|
1651
|
+
// save<T extends DeepPartial<Entity>>(
|
|
1652
|
+
// entities: T[],
|
|
1653
|
+
// options: SaveOptions & {
|
|
1654
|
+
// reload: false;
|
|
1655
|
+
// },
|
|
1656
|
+
// ): Promise<T[]>;
|
|
1657
|
+
// /**
|
|
1658
|
+
// * Saves all given entities in the database.
|
|
1659
|
+
// * If entities do not exist in the database then inserts, otherwise updates.
|
|
1660
|
+
// */
|
|
1661
|
+
// save<T extends DeepPartial<Entity>>(
|
|
1662
|
+
// entities: T[],
|
|
1663
|
+
// options?: SaveOptions,
|
|
1664
|
+
// ): Promise<(T & Entity)[]>;
|
|
1665
|
+
// /**
|
|
1666
|
+
// * Saves a given entity in the database.
|
|
1667
|
+
// * If entity does not exist in the database then inserts, otherwise updates.
|
|
1668
|
+
// */
|
|
1669
|
+
// save<T extends DeepPartial<Entity>>(
|
|
1670
|
+
// entity: T,
|
|
1671
|
+
// options: SaveOptions & {
|
|
1672
|
+
// reload: false;
|
|
1673
|
+
// },
|
|
1674
|
+
// ): Promise<T>;
|
|
1675
|
+
// /**
|
|
1676
|
+
// * Saves a given entity in the database.
|
|
1677
|
+
// * If entity does not exist in the database then inserts, otherwise updates.
|
|
1678
|
+
// */
|
|
1679
|
+
// save<T extends DeepPartial<Entity>>(
|
|
1680
|
+
// entity: T,
|
|
1681
|
+
// options?: SaveOptions,
|
|
1682
|
+
// ): Promise<T & Entity> {
|
|
1683
|
+
// return this.repo.save(entity, options);
|
|
1684
|
+
// }
|
|
1685
|
+
//#endregion
|
|
1686
|
+
//#endregion
|
|
1687
|
+
//#region crud operations / typeorm / merge
|
|
1478
1688
|
/**
|
|
1479
1689
|
* Merges multiple entities (or entity-like objects) into a given entity.
|
|
1480
1690
|
*/
|
|
1481
1691
|
merge(mergeIntoEntity, ...entityLikes) {
|
|
1482
1692
|
return this.repo.merge(mergeIntoEntity, ...entityLikes);
|
|
1483
1693
|
}
|
|
1694
|
+
//#endregion
|
|
1695
|
+
//#region crud operations / typeorm / preload
|
|
1484
1696
|
/**
|
|
1485
1697
|
* Creates a new entity from the given plain javascript object. If entity already exist in the database, then
|
|
1486
1698
|
* it loads it (and everything related to it), replaces all values with the new ones from the given object
|
|
@@ -1493,6 +1705,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1493
1705
|
preload(entityLike) {
|
|
1494
1706
|
return this.repo.preload(entityLike);
|
|
1495
1707
|
}
|
|
1708
|
+
//#endregion
|
|
1709
|
+
//#region crud operations / typeorm / remove (delete) & bulk remove (delete)
|
|
1496
1710
|
/**
|
|
1497
1711
|
* Removes a given entities from the database.
|
|
1498
1712
|
*/
|
|
@@ -1554,6 +1768,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1554
1768
|
recover(entity, options) {
|
|
1555
1769
|
return this.repo.recover(entity, options);
|
|
1556
1770
|
}
|
|
1771
|
+
//#endregion
|
|
1772
|
+
//#region crud operations / typeorm / insert
|
|
1557
1773
|
/**
|
|
1558
1774
|
* Inserts a given entity into the database.
|
|
1559
1775
|
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
@@ -1563,6 +1779,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1563
1779
|
insert(entity) {
|
|
1564
1780
|
return this.repo.insert(entity);
|
|
1565
1781
|
}
|
|
1782
|
+
//#endregion
|
|
1783
|
+
//#region crud operations / typeorm / update & build update
|
|
1566
1784
|
async update(item) {
|
|
1567
1785
|
/* */
|
|
1568
1786
|
/* */
|
|
@@ -1612,6 +1830,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1612
1830
|
/* */
|
|
1613
1831
|
/* */
|
|
1614
1832
|
/* */
|
|
1833
|
+
/* */
|
|
1834
|
+
/* */
|
|
1615
1835
|
return (void 0);
|
|
1616
1836
|
}
|
|
1617
1837
|
async bulkUpdate(items) {
|
|
@@ -1626,6 +1846,32 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1626
1846
|
/* */
|
|
1627
1847
|
return (void 0);
|
|
1628
1848
|
}
|
|
1849
|
+
//#region tpeorm update version
|
|
1850
|
+
// this version suck and will not return update entity
|
|
1851
|
+
// /**
|
|
1852
|
+
// * Updates entity partially. Entity can be found by a given conditions.
|
|
1853
|
+
// * Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
1854
|
+
// * Executes fast and efficient UPDATE query.
|
|
1855
|
+
// * Does not check if entity exist in the database.
|
|
1856
|
+
// */
|
|
1857
|
+
// update(
|
|
1858
|
+
// criteria:
|
|
1859
|
+
// | string
|
|
1860
|
+
// | string[]
|
|
1861
|
+
// | number
|
|
1862
|
+
// | number[]
|
|
1863
|
+
// | Date
|
|
1864
|
+
// | Date[]
|
|
1865
|
+
// | ObjectID
|
|
1866
|
+
// | ObjectID[]
|
|
1867
|
+
// | FindOptionsWhere<Entity>,
|
|
1868
|
+
// partialEntity: QueryDeepPartialEntity<Entity>,
|
|
1869
|
+
// ): Promise<UpdateResult> {
|
|
1870
|
+
// return this.repo.update(criteria, partialEntity);
|
|
1871
|
+
// }
|
|
1872
|
+
//#endregion
|
|
1873
|
+
//#endregion
|
|
1874
|
+
//#region crud operations / typeorm / upsert
|
|
1629
1875
|
/**
|
|
1630
1876
|
* Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
|
|
1631
1877
|
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
@@ -1634,6 +1880,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1634
1880
|
upsert(entityOrEntities, conflictPathsOrOptions) {
|
|
1635
1881
|
return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
|
|
1636
1882
|
}
|
|
1883
|
+
//#endregion
|
|
1884
|
+
//#region crud operations / typeorm / soft delete
|
|
1637
1885
|
/**
|
|
1638
1886
|
* Records the delete date of entities by a given criteria.
|
|
1639
1887
|
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
@@ -1643,6 +1891,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1643
1891
|
softDelete(criteria) {
|
|
1644
1892
|
return this.repo.softDelete(criteria);
|
|
1645
1893
|
}
|
|
1894
|
+
//#endregion
|
|
1895
|
+
//#region crud operations / typeorm / restore
|
|
1646
1896
|
/**
|
|
1647
1897
|
* Restores entities by a given criteria.
|
|
1648
1898
|
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
@@ -1652,6 +1902,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1652
1902
|
restore(criteria) {
|
|
1653
1903
|
return this.repo.restore(criteria);
|
|
1654
1904
|
}
|
|
1905
|
+
//#endregion
|
|
1906
|
+
//#region crud operations / typeorm / count
|
|
1655
1907
|
/**
|
|
1656
1908
|
* Counts entities that match given options.
|
|
1657
1909
|
* Useful for pagination.
|
|
@@ -1659,6 +1911,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1659
1911
|
count(options) {
|
|
1660
1912
|
return this.repo.count(options);
|
|
1661
1913
|
}
|
|
1914
|
+
//#endregion
|
|
1915
|
+
//#region crud operations / typeorm / count by
|
|
1662
1916
|
/**
|
|
1663
1917
|
* Counts entities that match given conditions.
|
|
1664
1918
|
* Useful for pagination.
|
|
@@ -1666,18 +1920,34 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1666
1920
|
countBy(where) {
|
|
1667
1921
|
return this.repo.countBy(where);
|
|
1668
1922
|
}
|
|
1923
|
+
//#endregion
|
|
1924
|
+
//#region crud operations / typeorm / find
|
|
1669
1925
|
/**
|
|
1670
1926
|
* Finds entities that match given find options.
|
|
1671
1927
|
*/
|
|
1672
1928
|
find(options) {
|
|
1673
1929
|
return this.repo.find(options);
|
|
1674
1930
|
}
|
|
1931
|
+
//#endregion
|
|
1932
|
+
//#region crud operations / typeorm / find by
|
|
1675
1933
|
/**
|
|
1676
1934
|
* Finds entities that match given find options.
|
|
1677
1935
|
*/
|
|
1678
1936
|
findBy(where) {
|
|
1679
1937
|
return this.repo.findBy(where);
|
|
1680
1938
|
}
|
|
1939
|
+
//#endregion
|
|
1940
|
+
//#region crud operations / typeorm / find and count
|
|
1941
|
+
// async findAndCount(options: { take: number; skip: number }) {
|
|
1942
|
+
// const { take, skip } = options;
|
|
1943
|
+
// const [result, total] = await this.repo.findAndCount({
|
|
1944
|
+
// // where: { name: Like('%' + keyword + '%') },
|
|
1945
|
+
// // order: { name: "DESC" },
|
|
1946
|
+
// take: take,
|
|
1947
|
+
// skip: skip,
|
|
1948
|
+
// });
|
|
1949
|
+
// return { result, total };
|
|
1950
|
+
// }
|
|
1681
1951
|
//
|
|
1682
1952
|
/**
|
|
1683
1953
|
* Finds entities that match given find options.
|
|
@@ -1687,6 +1957,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1687
1957
|
findAndCount(options) {
|
|
1688
1958
|
return this.repo.findAndCount(options);
|
|
1689
1959
|
}
|
|
1960
|
+
//#endregion
|
|
1961
|
+
//#region crud operations / typeorm / find and count by
|
|
1690
1962
|
/**
|
|
1691
1963
|
* Finds entities that match given WHERE conditions.
|
|
1692
1964
|
* Also counts all entities that match given conditions,
|
|
@@ -1695,6 +1967,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1695
1967
|
findAndCountBy(where) {
|
|
1696
1968
|
return this.repo.findAndCountBy(where);
|
|
1697
1969
|
}
|
|
1970
|
+
//#endregion
|
|
1971
|
+
//#region crud operations / typeorm / find by ids
|
|
1698
1972
|
/**
|
|
1699
1973
|
* Finds entities with ids.
|
|
1700
1974
|
* Optionally find options or conditions can be applied.
|
|
@@ -1708,6 +1982,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1708
1982
|
findByIds(ids) {
|
|
1709
1983
|
return this.repo.findByIds(ids);
|
|
1710
1984
|
}
|
|
1985
|
+
//#endregion
|
|
1986
|
+
//#region crud operations / typeorm / find one
|
|
1711
1987
|
/**
|
|
1712
1988
|
* Finds first entity by a given find options.
|
|
1713
1989
|
* If entity was not found in the database - returns null.
|
|
@@ -1715,6 +1991,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1715
1991
|
findOne(options) {
|
|
1716
1992
|
return this.repo.findOne(options);
|
|
1717
1993
|
}
|
|
1994
|
+
//#endregion
|
|
1995
|
+
//#region crud operations / typeorm / find one by
|
|
1718
1996
|
/**
|
|
1719
1997
|
* Finds first entity that matches given where condition.
|
|
1720
1998
|
* If entity was not found in the database - returns null.
|
|
@@ -1722,6 +2000,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1722
2000
|
findOneBy(where) {
|
|
1723
2001
|
return this.repo.findOneBy(where);
|
|
1724
2002
|
}
|
|
2003
|
+
//#endregion
|
|
2004
|
+
//#region crud operations / typeorm / find one or fail
|
|
1725
2005
|
/**
|
|
1726
2006
|
* Finds first entity that matches given id.
|
|
1727
2007
|
* If entity was not found in the database - returns null.
|
|
@@ -1735,6 +2015,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1735
2015
|
findOneById(id) {
|
|
1736
2016
|
return this.repo.findOneById(id);
|
|
1737
2017
|
}
|
|
2018
|
+
//#endregion
|
|
2019
|
+
//#region crud operations / typeorm / find one or fail
|
|
1738
2020
|
/**
|
|
1739
2021
|
* Finds first entity by a given find options.
|
|
1740
2022
|
* If entity was not found in the database - rejects with error.
|
|
@@ -1742,6 +2024,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1742
2024
|
findOneOrFail(options) {
|
|
1743
2025
|
return this.repo.findOneOrFail(options);
|
|
1744
2026
|
}
|
|
2027
|
+
//#endregion
|
|
2028
|
+
//#region crud operations / typeorm / find one by or fail
|
|
1745
2029
|
/**
|
|
1746
2030
|
* Finds first entity that matches given where condition.
|
|
1747
2031
|
* If entity was not found in the database - rejects with error.
|
|
@@ -1749,6 +2033,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1749
2033
|
findOneByOrFail(where) {
|
|
1750
2034
|
return this.repo.findOneByOrFail(where);
|
|
1751
2035
|
}
|
|
2036
|
+
//#endregion
|
|
2037
|
+
//#region crud operations / typeorm / query
|
|
1752
2038
|
/**
|
|
1753
2039
|
* Executes a raw SQL query and returns a raw database results.
|
|
1754
2040
|
* Raw query execution is supported only by relational databases (MongoDB is not supported).
|
|
@@ -1756,6 +2042,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1756
2042
|
query(query, parameters) {
|
|
1757
2043
|
return this.repo.query(query, parameters);
|
|
1758
2044
|
}
|
|
2045
|
+
//#endregion
|
|
2046
|
+
//#region crud operations / typeorm / clear
|
|
1759
2047
|
/**
|
|
1760
2048
|
* Clears all the data from the given table/collection (truncates/drops it).
|
|
1761
2049
|
*
|
|
@@ -1765,18 +2053,24 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1765
2053
|
clear() {
|
|
1766
2054
|
return this.repo.clear();
|
|
1767
2055
|
}
|
|
2056
|
+
//#endregion
|
|
2057
|
+
//#region crud operations / typeorm / increment
|
|
1768
2058
|
/**
|
|
1769
2059
|
* Increments some column by provided value of the entities matched given conditions.
|
|
1770
2060
|
*/
|
|
1771
2061
|
increment(conditions, propertyPath, value) {
|
|
1772
2062
|
return this.repo.increment(conditions, propertyPath, value);
|
|
1773
2063
|
}
|
|
2064
|
+
//#endregion
|
|
2065
|
+
//#region crud operations / typeorm / decrement
|
|
1774
2066
|
/**
|
|
1775
2067
|
* Decrements some column by provided value of the entities matched given conditions.
|
|
1776
2068
|
*/
|
|
1777
2069
|
decrement(conditions, propertyPath, value) {
|
|
1778
2070
|
return this.repo.decrement(conditions, propertyPath, value);
|
|
1779
2071
|
}
|
|
2072
|
+
//#endregion
|
|
2073
|
+
//#region crud operations / get all
|
|
1780
2074
|
/**
|
|
1781
2075
|
* @deprecated use findAndCount instead
|
|
1782
2076
|
*/
|
|
@@ -1794,6 +2088,8 @@ let BaseRepository = class BaseRepository extends BaseInjector {
|
|
|
1794
2088
|
/* */
|
|
1795
2089
|
return (void 0);
|
|
1796
2090
|
}
|
|
2091
|
+
//#endregion
|
|
2092
|
+
//#region crud operations / get by id
|
|
1797
2093
|
async getBy(id) {
|
|
1798
2094
|
/* */
|
|
1799
2095
|
/* */
|
|
@@ -1808,13 +2104,9 @@ BaseRepository = __decorate([
|
|
|
1808
2104
|
TaonRepository({ className: 'BaseRepository' }),
|
|
1809
2105
|
__metadata("design:paramtypes", [Function])
|
|
1810
2106
|
], BaseRepository);
|
|
1811
|
-
;
|
|
1812
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base-repository.ts
|
|
1813
2107
|
|
|
1814
2108
|
class BaseProvider extends BaseInjector {
|
|
1815
2109
|
}
|
|
1816
|
-
;
|
|
1817
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base-provider.ts
|
|
1818
2110
|
|
|
1819
2111
|
class DITaonContainer {
|
|
1820
2112
|
static { this.instances = new Map(); }
|
|
@@ -1822,6 +2114,7 @@ class DITaonContainer {
|
|
|
1822
2114
|
if (DITaonContainer.instances.has(target)) {
|
|
1823
2115
|
return DITaonContainer.instances.get(target);
|
|
1824
2116
|
}
|
|
2117
|
+
// const tokens = Reflect.getMetadata('design:paramtypes', target) || [];
|
|
1825
2118
|
const injections = []; // tokens.map(token => Container.inject<any>(token));
|
|
1826
2119
|
const instance = new target(...injections);
|
|
1827
2120
|
DITaonContainer.instances.set(target, instance);
|
|
@@ -1845,8 +2138,6 @@ class DITaonContainer {
|
|
|
1845
2138
|
});
|
|
1846
2139
|
}
|
|
1847
2140
|
}
|
|
1848
|
-
;
|
|
1849
|
-
({}); // @--end-of-file-for-module=taon lib/dependency-injection/di-container.ts
|
|
1850
2141
|
|
|
1851
2142
|
const getResponseValue = (response, options) => {
|
|
1852
2143
|
/* */
|
|
@@ -1872,21 +2163,20 @@ const getResponseValue = (response, options) => {
|
|
|
1872
2163
|
/* */
|
|
1873
2164
|
return (void 0);
|
|
1874
2165
|
};
|
|
1875
|
-
;
|
|
1876
|
-
({}); // @--end-of-file-for-module=taon lib/get-response-value.ts
|
|
1877
2166
|
|
|
1878
2167
|
const ENV$2 = Helpers.isBrowser ? window['ENV'] : global['ENV'];
|
|
1879
|
-
;
|
|
1880
|
-
({}); // @--end-of-file-for-module=taon lib/env.ts
|
|
1881
2168
|
|
|
2169
|
+
//#region imports
|
|
1882
2170
|
/* */
|
|
1883
2171
|
/* */
|
|
2172
|
+
//#endregion
|
|
1884
2173
|
class RealtimeSubsManager {
|
|
1885
2174
|
constructor(options) {
|
|
1886
2175
|
this.options = options;
|
|
1887
2176
|
this.isListening = false;
|
|
1888
2177
|
this.observers = [];
|
|
1889
2178
|
}
|
|
2179
|
+
//#region methods & getters / start listen if not started
|
|
1890
2180
|
startListenIfNotStarted(realtime) {
|
|
1891
2181
|
if (this.options.core.ctx.disabledRealtime) {
|
|
1892
2182
|
console.warn(`[Taon][startListenIfNotStarted] sockets are disabled`);
|
|
@@ -1897,32 +2187,44 @@ class RealtimeSubsManager {
|
|
|
1897
2187
|
return;
|
|
1898
2188
|
}
|
|
1899
2189
|
if (!this.isListening) {
|
|
2190
|
+
// console.info(`[BROWSER]][IPC] subscribe to "${this.options?.roomName}" by sending event: "${subscribeEvent}"`, this.options);
|
|
1900
2191
|
this.isListening = true;
|
|
1901
2192
|
if (this.options.customEvent) {
|
|
1902
2193
|
const subscribeEvent = Symbols.REALTIME.ROOM_SUBSCRIBE_CUSTOM(this.options.core.ctx.contextName);
|
|
2194
|
+
// this means: send to current client custom event notification
|
|
1903
2195
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1904
2196
|
}
|
|
1905
2197
|
else {
|
|
1906
|
-
if (_
|
|
2198
|
+
if (_.isString(this.options.property)) {
|
|
1907
2199
|
const subscribeEvent = Symbols.REALTIME.ROOM_SUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName);
|
|
2200
|
+
// this means: send to current client entity property events updates
|
|
1908
2201
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1909
2202
|
}
|
|
1910
2203
|
else {
|
|
1911
2204
|
const subscribeEvent = Symbols.REALTIME.ROOM_SUBSCRIBE_ENTITY_UPDATE_EVENTS(this.options.core.ctx.contextName);
|
|
2205
|
+
// this means: send to current client entity update events
|
|
1912
2206
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1913
2207
|
}
|
|
1914
2208
|
}
|
|
2209
|
+
// subPath -> SYMBOL - (customevnet|entityupdatebyid){..}{..}
|
|
1915
2210
|
realtime.on(this.options.roomName, data => {
|
|
1916
2211
|
this.update(data);
|
|
1917
2212
|
});
|
|
1918
2213
|
}
|
|
1919
2214
|
}
|
|
2215
|
+
//#endregion
|
|
2216
|
+
//#region methods & getters / add observer
|
|
1920
2217
|
add(observer) {
|
|
2218
|
+
// log.info('Add observer')
|
|
1921
2219
|
this.observers.push(observer);
|
|
1922
2220
|
}
|
|
2221
|
+
//#endregion
|
|
2222
|
+
//#region methods & getters / remove observer
|
|
1923
2223
|
remove(observer) {
|
|
2224
|
+
// log.info('Remove observer')
|
|
1924
2225
|
this.observers = this.observers.filter(obs => obs !== observer);
|
|
1925
2226
|
if (this.observers.length === 0) {
|
|
2227
|
+
// log.info('Emit unsubscribe to server SERVER')
|
|
1926
2228
|
this.isListening = false;
|
|
1927
2229
|
const { core, customEvent, roomName, property } = this.options;
|
|
1928
2230
|
const realtime = core.socketFE;
|
|
@@ -1930,7 +2232,7 @@ class RealtimeSubsManager {
|
|
|
1930
2232
|
realtime.emit(Symbols.REALTIME.ROOM_UNSUBSCRIBE_CUSTOM(this.options.core.ctx.contextName), roomName);
|
|
1931
2233
|
}
|
|
1932
2234
|
else {
|
|
1933
|
-
if (_
|
|
2235
|
+
if (_.isString(property)) {
|
|
1934
2236
|
realtime.emit(Symbols.REALTIME.ROOM_UNSUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName), roomName);
|
|
1935
2237
|
}
|
|
1936
2238
|
else {
|
|
@@ -1939,9 +2241,15 @@ class RealtimeSubsManager {
|
|
|
1939
2241
|
}
|
|
1940
2242
|
}
|
|
1941
2243
|
}
|
|
2244
|
+
//#endregion
|
|
2245
|
+
//#region methods & getters / update
|
|
1942
2246
|
update(data) {
|
|
2247
|
+
// log.data(`realtime update!!!!! observers=${this.observers?.length} `)
|
|
1943
2248
|
const ngZone = this.options.core.ctx.ngZone;
|
|
2249
|
+
// console.log('updating', data);
|
|
2250
|
+
// console.log('ngzone', ngZone);
|
|
1944
2251
|
this.observers.forEach(observer => {
|
|
2252
|
+
// console.log(`observer closed: ${observer.closed}`,observer);
|
|
1945
2253
|
if (!observer.closed) {
|
|
1946
2254
|
if (ngZone) {
|
|
1947
2255
|
ngZone.run(() => {
|
|
@@ -1955,48 +2263,66 @@ class RealtimeSubsManager {
|
|
|
1955
2263
|
});
|
|
1956
2264
|
}
|
|
1957
2265
|
}
|
|
1958
|
-
;
|
|
1959
|
-
({}); // @--end-of-file-for-module=taon lib/realtime/realtime-subs-manager.ts
|
|
1960
2266
|
|
|
2267
|
+
//#region imports
|
|
2268
|
+
//#endregion
|
|
1961
2269
|
class RealtimeClient {
|
|
1962
2270
|
constructor(core) {
|
|
1963
2271
|
this.core = core;
|
|
1964
2272
|
this.subsManagers = {};
|
|
1965
2273
|
this.core = core;
|
|
1966
2274
|
if (!core.ctx.disabledRealtime) {
|
|
2275
|
+
//#region @browser
|
|
1967
2276
|
this.init();
|
|
2277
|
+
//#endregion
|
|
1968
2278
|
}
|
|
1969
2279
|
}
|
|
2280
|
+
//#region methods & getters / init
|
|
1970
2281
|
init() {
|
|
2282
|
+
//#region prepare naspaces pathes
|
|
1971
2283
|
const nspPath = {
|
|
1972
2284
|
global: this.core.pathFor(),
|
|
1973
2285
|
realtime: this.core.pathFor(Symbols.REALTIME.NAMESPACE(this.core.ctx.contextName)),
|
|
1974
2286
|
};
|
|
2287
|
+
// console.log('[browser] nspPath', nspPath);
|
|
1975
2288
|
this.core.ctx.logRealtime &&
|
|
1976
2289
|
console.info('[CLIENT] NAMESPACE GLOBAL ', nspPath.global.href + ` host: ${this.core.ctx.host}`);
|
|
1977
2290
|
this.core.ctx.logRealtime &&
|
|
1978
2291
|
console.info('[CLIENT] NAMESPACE REALTIME', nspPath.realtime.href + ` host: ${this.core.ctx.host}`);
|
|
2292
|
+
//#endregion
|
|
2293
|
+
//#region prepare globa FE socket
|
|
1979
2294
|
this.core.conectSocketFE = this.core.strategy.ioClient(nspPath.global.origin, {
|
|
1980
2295
|
path: nspPath.global.pathname,
|
|
1981
2296
|
});
|
|
1982
2297
|
if (this.core.conectSocketFE.on) {
|
|
1983
2298
|
this.core.conectSocketFE.on('connect', () => {
|
|
2299
|
+
// console.info(
|
|
2300
|
+
// `[CLIENT] connected to GLOBAL namespace ${global.nsp} of host: ${context.host}`,
|
|
2301
|
+
// );
|
|
1984
2302
|
this.core.ctx.logRealtime &&
|
|
1985
2303
|
console.info(`[CLIENT] connected to GLOBAL namespace ${nspPath.global.pathname}` +
|
|
1986
2304
|
` of host: ${this.core.ctx.host}`);
|
|
1987
2305
|
});
|
|
1988
2306
|
}
|
|
2307
|
+
//#endregion
|
|
2308
|
+
//#region prepare realtime FE socket
|
|
1989
2309
|
this.core.socketFE = this.core.strategy.ioClient(nspPath.realtime.origin, {
|
|
1990
2310
|
path: nspPath.realtime.pathname,
|
|
1991
2311
|
});
|
|
1992
2312
|
if (this.core.socketFE.on) {
|
|
1993
2313
|
this.core.socketFE.on('connect', () => {
|
|
2314
|
+
// console.info(
|
|
2315
|
+
// `[CLIENT] connected to REALTIME namespace ${realtime.nsp} host: ${context.host}`,
|
|
2316
|
+
// );
|
|
1994
2317
|
this.core.ctx.logRealtime &&
|
|
1995
2318
|
console.info(`[CLIENT] connected to REALTIME namespace ${nspPath.realtime.pathname}` +
|
|
1996
2319
|
` host: ${this.core.ctx.host}`);
|
|
1997
2320
|
});
|
|
1998
2321
|
}
|
|
2322
|
+
//#endregion
|
|
1999
2323
|
}
|
|
2324
|
+
//#endregion
|
|
2325
|
+
//#region methods & getters / listen changes entity
|
|
2000
2326
|
/**
|
|
2001
2327
|
* Changes trigger on backend needs to be done manually.. example code:
|
|
2002
2328
|
*
|
|
@@ -2006,14 +2332,17 @@ class RealtimeClient {
|
|
|
2006
2332
|
*/
|
|
2007
2333
|
listenChangesEntity(entityClassFn, idOrUniqValue, options) {
|
|
2008
2334
|
options = options || {};
|
|
2335
|
+
//#region parameters validation
|
|
2009
2336
|
const { property, customEvent } = options;
|
|
2010
2337
|
const className = !customEvent && ClassHelpers.getName(entityClassFn);
|
|
2011
|
-
if (_
|
|
2338
|
+
if (_.isString(property)) {
|
|
2012
2339
|
if (property.trim() === '') {
|
|
2013
2340
|
throw new Error(`[Taon][listenChangesEntity.. incorect property '' for ${className}`);
|
|
2014
2341
|
}
|
|
2015
2342
|
}
|
|
2343
|
+
//#endregion
|
|
2016
2344
|
return new Observable(observer => {
|
|
2345
|
+
//#region prepare parameters for manager
|
|
2017
2346
|
if (this.core.ctx.disabledRealtime) {
|
|
2018
2347
|
console.error(`[Taon][realtime rxjs] remove taon config flag:
|
|
2019
2348
|
|
|
@@ -2024,6 +2353,7 @@ class RealtimeClient {
|
|
|
2024
2353
|
to use socket realtime connection;
|
|
2025
2354
|
`);
|
|
2026
2355
|
return () => {
|
|
2356
|
+
// empty nothing to do
|
|
2027
2357
|
};
|
|
2028
2358
|
}
|
|
2029
2359
|
let roomName;
|
|
@@ -2031,7 +2361,7 @@ to use socket realtime connection;
|
|
|
2031
2361
|
roomName = Symbols.REALTIME.ROOM_NAME_CUSTOM(this.core.ctx.contextName, customEvent);
|
|
2032
2362
|
}
|
|
2033
2363
|
else {
|
|
2034
|
-
roomName = _
|
|
2364
|
+
roomName = _.isString(property)
|
|
2035
2365
|
? Symbols.REALTIME.ROOM_NAME_UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, className, property, idOrUniqValue)
|
|
2036
2366
|
: Symbols.REALTIME.ROOM_NAME_UPDATE_ENTITY(this.core.ctx.contextName, className, idOrUniqValue);
|
|
2037
2367
|
}
|
|
@@ -2041,6 +2371,7 @@ to use socket realtime connection;
|
|
|
2041
2371
|
roomName,
|
|
2042
2372
|
customEvent,
|
|
2043
2373
|
};
|
|
2374
|
+
//#endregion
|
|
2044
2375
|
const subManagerId = this.getUniqueIdentifierForConnection(roomSubOptions);
|
|
2045
2376
|
if (!this.subsManagers[subManagerId]) {
|
|
2046
2377
|
this.subsManagers[subManagerId] = new RealtimeSubsManager(roomSubOptions);
|
|
@@ -2053,12 +2384,16 @@ to use socket realtime connection;
|
|
|
2053
2384
|
};
|
|
2054
2385
|
});
|
|
2055
2386
|
}
|
|
2387
|
+
//#endregion
|
|
2388
|
+
//#region listen changes entity table
|
|
2056
2389
|
listenChangesEntityTable(entityClassFn) {
|
|
2057
2390
|
const className = ClassHelpers.getName(entityClassFn);
|
|
2058
2391
|
return this.listenChangesEntity(entityClassFn, void 0, {
|
|
2059
2392
|
customEvent: Symbols.REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className),
|
|
2060
2393
|
});
|
|
2061
2394
|
}
|
|
2395
|
+
//#endregion
|
|
2396
|
+
//#region listen change entity object
|
|
2062
2397
|
/**
|
|
2063
2398
|
* Changes trigger on backend needs to be done manually.. example code:
|
|
2064
2399
|
*
|
|
@@ -2073,11 +2408,15 @@ to use socket realtime connection;
|
|
|
2073
2408
|
const uniqueKey = ClassHelpers.getUniqueKey(classFn);
|
|
2074
2409
|
return this.listenChangesEntity(classFn, entity[uniqueKey], options);
|
|
2075
2410
|
}
|
|
2411
|
+
//#endregion
|
|
2412
|
+
//#region listen changes custom event
|
|
2076
2413
|
listenChangesCustomEvent(customEvent) {
|
|
2077
2414
|
return this.listenChangesEntity(void 0, void 0, {
|
|
2078
2415
|
customEvent,
|
|
2079
2416
|
});
|
|
2080
2417
|
}
|
|
2418
|
+
//#endregion
|
|
2419
|
+
//#region methods & getters / trigger custom event\
|
|
2081
2420
|
/**
|
|
2082
2421
|
* Trigger custom event on backend
|
|
2083
2422
|
* @param customEvent global event name
|
|
@@ -2086,15 +2425,18 @@ to use socket realtime connection;
|
|
|
2086
2425
|
triggerCustomEvent(customEvent, dataToPush) {
|
|
2087
2426
|
this.core.socketFE.emit(customEvent, dataToPush);
|
|
2088
2427
|
}
|
|
2428
|
+
//#endregion
|
|
2429
|
+
//#region methods & getters / get room id from
|
|
2089
2430
|
getUniqueIdentifierForConnection(options) {
|
|
2090
2431
|
const url = new URL(options.core.ctx.host);
|
|
2091
2432
|
return `${this.core.ctx.contextName}:${url.origin}|${options.roomName}|${options.property}|${options.customEvent}`;
|
|
2092
2433
|
}
|
|
2093
2434
|
}
|
|
2094
|
-
;
|
|
2095
|
-
({}); // @--end-of-file-for-module=taon lib/realtime/realtime-client.ts
|
|
2096
2435
|
|
|
2436
|
+
//#region imports
|
|
2437
|
+
//#endregion
|
|
2097
2438
|
class RealtimeServer {
|
|
2439
|
+
// private jobs = {};
|
|
2098
2440
|
constructor(core) {
|
|
2099
2441
|
this.core = core;
|
|
2100
2442
|
this.core = core;
|
|
@@ -2103,6 +2445,7 @@ class RealtimeServer {
|
|
|
2103
2445
|
/* */
|
|
2104
2446
|
}
|
|
2105
2447
|
}
|
|
2448
|
+
//#region methods & getters / init
|
|
2106
2449
|
init() {
|
|
2107
2450
|
/* */
|
|
2108
2451
|
/* */
|
|
@@ -2269,7 +2612,12 @@ class RealtimeServer {
|
|
|
2269
2612
|
/* */
|
|
2270
2613
|
/* */
|
|
2271
2614
|
}
|
|
2615
|
+
//#endregion
|
|
2616
|
+
//#region methods & getters / trigger changes
|
|
2617
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
2272
2618
|
triggerChanges(entityObjOrClass, property, valueOfUniqueProperty, customEvent, customEventData) {
|
|
2619
|
+
// console.log('customEventData', customEventData);
|
|
2620
|
+
// console.info('__triger entity changes');
|
|
2273
2621
|
/* */
|
|
2274
2622
|
/* */
|
|
2275
2623
|
/* */
|
|
@@ -2328,6 +2676,9 @@ class RealtimeServer {
|
|
|
2328
2676
|
/* */
|
|
2329
2677
|
/* */
|
|
2330
2678
|
}
|
|
2679
|
+
//#endregion
|
|
2680
|
+
//#region entity changes
|
|
2681
|
+
//#region methods & getters / trigger entity changes
|
|
2331
2682
|
triggerEntityChanges(entityObjOrClass, idToTrigger) {
|
|
2332
2683
|
if (this.core.ctx.disabledRealtime) {
|
|
2333
2684
|
const className = ClassHelpers.getName(entityObjOrClass);
|
|
@@ -2336,13 +2687,15 @@ class RealtimeServer {
|
|
|
2336
2687
|
}
|
|
2337
2688
|
this.triggerChanges(entityObjOrClass, void 0, idToTrigger);
|
|
2338
2689
|
}
|
|
2690
|
+
//#endregion
|
|
2691
|
+
//#region methods & getters / trigger entity property changes
|
|
2339
2692
|
triggerEntityPropertyChanges(entityObjOrClass, property, idToTrigger) {
|
|
2340
2693
|
if (this.core.ctx.disabledRealtime) {
|
|
2341
2694
|
const className = ClassHelpers.getName(entityObjOrClass);
|
|
2342
2695
|
console.warn(`[Taon][TriggerEntityPropertyChanges][property=${property}] Entity "${className}' is not realtime`);
|
|
2343
2696
|
return;
|
|
2344
2697
|
}
|
|
2345
|
-
if (_
|
|
2698
|
+
if (_.isArray(property)) {
|
|
2346
2699
|
property.forEach(propertyFromArr => {
|
|
2347
2700
|
this.triggerChanges(entityObjOrClass, propertyFromArr, idToTrigger);
|
|
2348
2701
|
});
|
|
@@ -2351,6 +2704,8 @@ class RealtimeServer {
|
|
|
2351
2704
|
this.triggerChanges(entityObjOrClass, property, idToTrigger);
|
|
2352
2705
|
}
|
|
2353
2706
|
}
|
|
2707
|
+
//#endregion
|
|
2708
|
+
//#region methods & getters / trigger entity table changes
|
|
2354
2709
|
triggerEntityTableChanges(entityClassOrInstance) {
|
|
2355
2710
|
const className = ClassHelpers.getName(entityClassOrInstance);
|
|
2356
2711
|
if (this.core.ctx.disabledRealtime) {
|
|
@@ -2359,9 +2714,15 @@ class RealtimeServer {
|
|
|
2359
2714
|
}
|
|
2360
2715
|
this.triggerChanges(entityClassOrInstance, void 0, void 0, Symbols.REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className));
|
|
2361
2716
|
}
|
|
2717
|
+
//#endregion
|
|
2718
|
+
//#endregion
|
|
2719
|
+
//#region custom changes
|
|
2720
|
+
//#region methods & getters / trigger custom event
|
|
2362
2721
|
triggerCustomEvent(customEvent, dataToPush) {
|
|
2363
2722
|
this.triggerChanges(void 0, void 0, void 0, customEvent, dataToPush);
|
|
2364
2723
|
}
|
|
2724
|
+
//#endregion
|
|
2725
|
+
//#region methods & getters / listen custom events from users
|
|
2365
2726
|
/**
|
|
2366
2727
|
* Listen to custom events from users
|
|
2367
2728
|
* @param customEvent global event name
|
|
@@ -2380,8 +2741,6 @@ class RealtimeServer {
|
|
|
2380
2741
|
return (void 0);
|
|
2381
2742
|
}
|
|
2382
2743
|
}
|
|
2383
|
-
;
|
|
2384
|
-
({}); // @--end-of-file-for-module=taon lib/realtime/realtime-server.ts
|
|
2385
2744
|
|
|
2386
2745
|
class RealtimeStrategy {
|
|
2387
2746
|
constructor(ctx) {
|
|
@@ -2394,9 +2753,9 @@ class RealtimeStrategy {
|
|
|
2394
2753
|
throw new Error('Not implemented');
|
|
2395
2754
|
}
|
|
2396
2755
|
}
|
|
2397
|
-
;
|
|
2398
|
-
({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy.ts
|
|
2399
2756
|
|
|
2757
|
+
//#endregion
|
|
2758
|
+
//#region mock server ipc
|
|
2400
2759
|
class MockServerIpc {
|
|
2401
2760
|
static { this.serverByContextName = new Map(); }
|
|
2402
2761
|
static from(contextName) {
|
|
@@ -2405,11 +2764,14 @@ class MockServerIpc {
|
|
|
2405
2764
|
}
|
|
2406
2765
|
return MockServerIpc.serverByContextName.get(contextName);
|
|
2407
2766
|
}
|
|
2767
|
+
//#region constructor
|
|
2408
2768
|
constructor(contextName) {
|
|
2409
2769
|
this.contextName = contextName;
|
|
2410
2770
|
this.namespacesByName = new Map();
|
|
2411
2771
|
MockServerIpc.serverByContextName.set(contextName, this);
|
|
2412
2772
|
}
|
|
2773
|
+
//#endregion
|
|
2774
|
+
//#region of
|
|
2413
2775
|
of(namespace) {
|
|
2414
2776
|
if (!this.namespacesByName.has(namespace)) {
|
|
2415
2777
|
this.namespacesByName.set(namespace, new MockNamespaceIpc(namespace, this));
|
|
@@ -2417,7 +2779,11 @@ class MockServerIpc {
|
|
|
2417
2779
|
return this.namespacesByName.get(namespace);
|
|
2418
2780
|
}
|
|
2419
2781
|
}
|
|
2782
|
+
//#endregion
|
|
2783
|
+
//#region mock namespace ipc
|
|
2420
2784
|
class MockNamespaceIpc {
|
|
2785
|
+
//#endregion
|
|
2786
|
+
//#region constructor
|
|
2421
2787
|
constructor(
|
|
2422
2788
|
/**
|
|
2423
2789
|
* Namespace name
|
|
@@ -2425,10 +2791,13 @@ class MockNamespaceIpc {
|
|
|
2425
2791
|
name, server) {
|
|
2426
2792
|
this.name = name;
|
|
2427
2793
|
this.server = server;
|
|
2794
|
+
//#region fields & getters
|
|
2428
2795
|
this.electronClients = new Set();
|
|
2429
2796
|
this.roomsByRoomName = {};
|
|
2430
2797
|
this.namespaceEventHandlers = {};
|
|
2431
2798
|
}
|
|
2799
|
+
//#endregion
|
|
2800
|
+
//#region on
|
|
2432
2801
|
on(eventName, callback) {
|
|
2433
2802
|
/* */
|
|
2434
2803
|
/* */
|
|
@@ -2461,6 +2830,8 @@ class MockNamespaceIpc {
|
|
|
2461
2830
|
/* */
|
|
2462
2831
|
return (void 0);
|
|
2463
2832
|
}
|
|
2833
|
+
//#endregion
|
|
2834
|
+
//#region off
|
|
2464
2835
|
off(event, callback) {
|
|
2465
2836
|
/* */
|
|
2466
2837
|
/* */
|
|
@@ -2476,6 +2847,8 @@ class MockNamespaceIpc {
|
|
|
2476
2847
|
/* */
|
|
2477
2848
|
return (void 0);
|
|
2478
2849
|
}
|
|
2850
|
+
//#endregion
|
|
2851
|
+
//#region emit
|
|
2479
2852
|
emit(eventName, ...args) {
|
|
2480
2853
|
/* */
|
|
2481
2854
|
/* */
|
|
@@ -2488,20 +2861,28 @@ class MockNamespaceIpc {
|
|
|
2488
2861
|
/* */
|
|
2489
2862
|
return (void 0);
|
|
2490
2863
|
}
|
|
2864
|
+
//#endregion
|
|
2865
|
+
//#region to
|
|
2491
2866
|
to(roomName) {
|
|
2492
2867
|
const electronClientsInroom = this.roomsByRoomName[roomName];
|
|
2493
2868
|
return new RoomEmitterIpc(electronClientsInroom, this.name, true);
|
|
2494
2869
|
}
|
|
2870
|
+
//#endregion
|
|
2871
|
+
//#region in
|
|
2495
2872
|
in(roomName) {
|
|
2496
2873
|
const electronClientsInroom = this.roomsByRoomName[roomName];
|
|
2497
2874
|
return new RoomEmitterIpc(electronClientsInroom, this.name, false);
|
|
2498
2875
|
}
|
|
2876
|
+
//#endregion
|
|
2877
|
+
//#region join
|
|
2499
2878
|
join(webContents, roomName) {
|
|
2500
2879
|
if (!this.roomsByRoomName[roomName]) {
|
|
2501
2880
|
this.roomsByRoomName[roomName] = new Set();
|
|
2502
2881
|
}
|
|
2503
2882
|
this.roomsByRoomName[roomName].add(webContents);
|
|
2504
2883
|
}
|
|
2884
|
+
//#endregion
|
|
2885
|
+
//#region leave
|
|
2505
2886
|
leave(webContents, roomName) {
|
|
2506
2887
|
if (this.roomsByRoomName[roomName]) {
|
|
2507
2888
|
this.roomsByRoomName[roomName].delete(webContents);
|
|
@@ -2510,9 +2891,13 @@ class MockNamespaceIpc {
|
|
|
2510
2891
|
}
|
|
2511
2892
|
}
|
|
2512
2893
|
}
|
|
2894
|
+
//#endregion
|
|
2895
|
+
//#region path
|
|
2513
2896
|
path() {
|
|
2514
2897
|
return this.name;
|
|
2515
2898
|
}
|
|
2899
|
+
//#endregion
|
|
2900
|
+
//#region get nsp
|
|
2516
2901
|
get nsp() {
|
|
2517
2902
|
const self = this;
|
|
2518
2903
|
return {
|
|
@@ -2522,7 +2907,10 @@ class MockNamespaceIpc {
|
|
|
2522
2907
|
};
|
|
2523
2908
|
}
|
|
2524
2909
|
}
|
|
2910
|
+
//#endregion
|
|
2911
|
+
//#region room emitter ipc
|
|
2525
2912
|
class RoomEmitterIpc {
|
|
2913
|
+
//#region constructor
|
|
2526
2914
|
constructor(electronClients,
|
|
2527
2915
|
/**
|
|
2528
2916
|
* namespace name
|
|
@@ -2533,6 +2921,8 @@ class RoomEmitterIpc {
|
|
|
2533
2921
|
this.includeSender = includeSender;
|
|
2534
2922
|
this.sender = sender;
|
|
2535
2923
|
}
|
|
2924
|
+
//#endregion
|
|
2925
|
+
//#region emit in room
|
|
2536
2926
|
emit(eventName, ...args) {
|
|
2537
2927
|
const emitEvent = `(${this.name}) "${eventName}"`;
|
|
2538
2928
|
this.electronClients?.forEach(webContents => {
|
|
@@ -2540,18 +2930,29 @@ class RoomEmitterIpc {
|
|
|
2540
2930
|
});
|
|
2541
2931
|
}
|
|
2542
2932
|
}
|
|
2933
|
+
//#endregion
|
|
2934
|
+
//#region mock socket ipc
|
|
2543
2935
|
class MockSocketIpc {
|
|
2936
|
+
//#endregion
|
|
2937
|
+
//#region fields & getters / name
|
|
2544
2938
|
get name() {
|
|
2545
2939
|
return this.namespaceName;
|
|
2546
2940
|
}
|
|
2941
|
+
//#endregion
|
|
2942
|
+
//#endregion
|
|
2943
|
+
//#region constructor
|
|
2547
2944
|
/**
|
|
2548
2945
|
* @param namespaceName instead url for ipc
|
|
2549
2946
|
*/
|
|
2550
2947
|
constructor(namespaceName) {
|
|
2551
2948
|
this.namespaceName = namespaceName;
|
|
2949
|
+
//#endregion
|
|
2950
|
+
//#region fields & getters / event handlers by name
|
|
2552
2951
|
this.socketEventHandlers = {};
|
|
2553
2952
|
this.ipcRenderer = window.require('electron').ipcRenderer;
|
|
2554
2953
|
}
|
|
2954
|
+
//#endregion
|
|
2955
|
+
//#region on
|
|
2555
2956
|
on(eventName, callback) {
|
|
2556
2957
|
if (!this.socketEventHandlers[eventName]) {
|
|
2557
2958
|
this.socketEventHandlers[eventName] = new Set();
|
|
@@ -2566,6 +2967,8 @@ class MockSocketIpc {
|
|
|
2566
2967
|
this.ipcRenderer.send(connectionEventKey, this.name);
|
|
2567
2968
|
}
|
|
2568
2969
|
}
|
|
2970
|
+
//#endregion
|
|
2971
|
+
//#region off
|
|
2569
2972
|
off(event, callback) {
|
|
2570
2973
|
if (!this.socketEventHandlers[event]) {
|
|
2571
2974
|
return;
|
|
@@ -2581,23 +2984,31 @@ class MockSocketIpc {
|
|
|
2581
2984
|
callback(data);
|
|
2582
2985
|
});
|
|
2583
2986
|
}
|
|
2987
|
+
//#endregion
|
|
2988
|
+
//#region emit
|
|
2584
2989
|
emit(event, ...args) {
|
|
2585
2990
|
const emitEvent = `(${this.name}) "${event}"`;
|
|
2586
2991
|
this.ipcRenderer.send(emitEvent, ...args);
|
|
2587
2992
|
}
|
|
2588
2993
|
}
|
|
2994
|
+
//#endregion
|
|
2589
2995
|
/**
|
|
2590
2996
|
* Purpose:
|
|
2591
2997
|
* - backend-browser communication between 2 processes in electron mode
|
|
2592
2998
|
*/
|
|
2593
2999
|
class RealtimeStrategyIpc extends RealtimeStrategy {
|
|
3000
|
+
//#region to string
|
|
2594
3001
|
toString() {
|
|
2595
3002
|
return 'ipc';
|
|
2596
3003
|
}
|
|
3004
|
+
//#endregion
|
|
3005
|
+
//#region constructor
|
|
2597
3006
|
constructor(ctx) {
|
|
2598
3007
|
super(ctx);
|
|
2599
3008
|
this.ctx = ctx;
|
|
2600
3009
|
}
|
|
3010
|
+
//#endregion
|
|
3011
|
+
//#region server & io
|
|
2601
3012
|
ioServer(__, opt) {
|
|
2602
3013
|
const namespace = opt?.path || '/';
|
|
2603
3014
|
const server = MockServerIpc.from(this.ctx.contextName);
|
|
@@ -2611,9 +3022,9 @@ class RealtimeStrategyIpc extends RealtimeStrategy {
|
|
|
2611
3022
|
return clientIo;
|
|
2612
3023
|
}
|
|
2613
3024
|
}
|
|
2614
|
-
;
|
|
2615
|
-
({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-ipc.ts
|
|
2616
3025
|
|
|
3026
|
+
//#endregion
|
|
3027
|
+
//#region mock server
|
|
2617
3028
|
class MockServer {
|
|
2618
3029
|
static { this.serverByUrl = new Map(); }
|
|
2619
3030
|
static from(url) {
|
|
@@ -2625,22 +3036,30 @@ class MockServer {
|
|
|
2625
3036
|
get allServers() {
|
|
2626
3037
|
return Array.from(MockServer.serverByUrl.values());
|
|
2627
3038
|
}
|
|
3039
|
+
//#region constructor
|
|
2628
3040
|
constructor(url) {
|
|
2629
3041
|
this.url = url;
|
|
2630
3042
|
this.namespacesByName = new Map();
|
|
2631
3043
|
MockServer.serverByUrl.set(url, this);
|
|
2632
3044
|
}
|
|
3045
|
+
//#endregion
|
|
3046
|
+
//#region of
|
|
2633
3047
|
of(namespace) {
|
|
2634
3048
|
if (!this.namespacesByName.has(namespace)) {
|
|
2635
3049
|
this.namespacesByName.set(namespace, new MockNamespace(namespace, this));
|
|
2636
3050
|
}
|
|
2637
3051
|
return this.namespacesByName.get(namespace);
|
|
2638
3052
|
}
|
|
3053
|
+
//#endregion
|
|
3054
|
+
//#region path
|
|
2639
3055
|
path() {
|
|
2640
3056
|
return this.url;
|
|
2641
3057
|
}
|
|
2642
3058
|
}
|
|
3059
|
+
//#endregion
|
|
3060
|
+
//#region mock namespace
|
|
2643
3061
|
class MockNamespace {
|
|
3062
|
+
//#region constructor
|
|
2644
3063
|
constructor(
|
|
2645
3064
|
/**
|
|
2646
3065
|
* unique namespace name
|
|
@@ -2661,7 +3080,10 @@ class MockNamespace {
|
|
|
2661
3080
|
*/
|
|
2662
3081
|
this.namespaceEventHandlers = {};
|
|
2663
3082
|
}
|
|
3083
|
+
//#endregion
|
|
3084
|
+
//#region on
|
|
2664
3085
|
on(eventName, handler) {
|
|
3086
|
+
// console.log(`ON EVNET event "${eventName}"`);
|
|
2665
3087
|
if (!this.namespaceEventHandlers[eventName]) {
|
|
2666
3088
|
this.namespaceEventHandlers[eventName] =
|
|
2667
3089
|
new Set();
|
|
@@ -2669,41 +3091,57 @@ class MockNamespace {
|
|
|
2669
3091
|
if (!this.namespaceEventHandlers[eventName].has(handler)) {
|
|
2670
3092
|
this.namespaceEventHandlers[eventName].add(handler);
|
|
2671
3093
|
}
|
|
3094
|
+
// QUICK_FIX Emit connection event for backend
|
|
3095
|
+
// TODO make it in emit
|
|
2672
3096
|
if (eventName === 'connection') {
|
|
2673
3097
|
setTimeout(() => {
|
|
2674
3098
|
this.emit('connection', this);
|
|
2675
3099
|
});
|
|
2676
3100
|
}
|
|
2677
3101
|
}
|
|
3102
|
+
//#endregion
|
|
3103
|
+
//#region emit
|
|
2678
3104
|
emit(event, ...args) {
|
|
2679
3105
|
this.allSocketsForNamespace?.forEach(socket => {
|
|
2680
3106
|
socket.emit(event, ...args);
|
|
2681
3107
|
});
|
|
2682
3108
|
}
|
|
3109
|
+
//#endregion
|
|
3110
|
+
//#region connect
|
|
2683
3111
|
connect(socket) {
|
|
2684
3112
|
this.allSocketsForNamespace.add(socket);
|
|
2685
3113
|
socket.namespaceInstance = this;
|
|
2686
3114
|
}
|
|
3115
|
+
//#endregion
|
|
3116
|
+
//#region to
|
|
2687
3117
|
to(roomName) {
|
|
2688
3118
|
const socketsInRoom = this.socketByRoomName[roomName];
|
|
2689
3119
|
return new RoomEmitter(socketsInRoom, true);
|
|
2690
3120
|
}
|
|
3121
|
+
//#endregion
|
|
3122
|
+
//#region to room
|
|
2691
3123
|
in(roomName) {
|
|
2692
3124
|
const socketsInRoom = this.socketByRoomName[roomName];
|
|
2693
3125
|
return new RoomEmitter(socketsInRoom, false);
|
|
2694
3126
|
}
|
|
3127
|
+
//#endregion
|
|
3128
|
+
//#region join room
|
|
2695
3129
|
joinRoom(roomName, socket) {
|
|
2696
3130
|
if (!this.socketByRoomName[roomName]) {
|
|
2697
3131
|
this.socketByRoomName[roomName] = new Set();
|
|
2698
3132
|
}
|
|
2699
3133
|
this.socketByRoomName[roomName].add(socket);
|
|
2700
3134
|
}
|
|
3135
|
+
//#endregion
|
|
3136
|
+
//#region leave room
|
|
2701
3137
|
leaveRoom(roomName, socket) {
|
|
2702
3138
|
const roomSockets = this.socketByRoomName[roomName];
|
|
2703
3139
|
if (roomSockets) {
|
|
2704
3140
|
this.socketByRoomName[roomName].delete(socket);
|
|
2705
3141
|
}
|
|
2706
3142
|
}
|
|
3143
|
+
//#endregion
|
|
3144
|
+
//#region nsp + name
|
|
2707
3145
|
get nsp() {
|
|
2708
3146
|
const self = this;
|
|
2709
3147
|
return {
|
|
@@ -2712,38 +3150,55 @@ class MockNamespace {
|
|
|
2712
3150
|
},
|
|
2713
3151
|
};
|
|
2714
3152
|
}
|
|
3153
|
+
//#endregion
|
|
2715
3154
|
path() {
|
|
2716
3155
|
return this.name;
|
|
2717
3156
|
}
|
|
2718
3157
|
}
|
|
3158
|
+
//#endregion
|
|
3159
|
+
//#region room emitter
|
|
2719
3160
|
class RoomEmitter {
|
|
3161
|
+
//#region constructor
|
|
2720
3162
|
constructor(sockets, includeSender = false, sender = null) {
|
|
2721
3163
|
this.sockets = sockets;
|
|
2722
3164
|
this.includeSender = includeSender;
|
|
2723
3165
|
this.sender = sender;
|
|
2724
3166
|
}
|
|
3167
|
+
//#endregion
|
|
3168
|
+
//#region emit in room
|
|
2725
3169
|
emit(event, ...args) {
|
|
3170
|
+
// console.log(
|
|
3171
|
+
// `emit room emiter ${event} , this.sockets ${this.sockets.length}`,
|
|
3172
|
+
// );
|
|
2726
3173
|
this.sockets?.forEach(socket => {
|
|
3174
|
+
// console.log(`emit event ${event} to socket ${socket.id}`);
|
|
2727
3175
|
if (this.includeSender || socket !== this.sender) {
|
|
2728
3176
|
socket.emit(event, ...args);
|
|
2729
3177
|
}
|
|
2730
3178
|
});
|
|
2731
3179
|
}
|
|
2732
3180
|
}
|
|
3181
|
+
//#endregion
|
|
3182
|
+
//#region mock socket
|
|
2733
3183
|
class MockSocket {
|
|
2734
3184
|
get id() {
|
|
2735
3185
|
return this.nsp.name;
|
|
2736
3186
|
}
|
|
3187
|
+
//#region constructor
|
|
2737
3188
|
constructor(url, opts) {
|
|
2738
3189
|
this.url = url;
|
|
2739
3190
|
this.socketEventHandlers = {};
|
|
2740
3191
|
// @ts-ignore
|
|
2741
3192
|
const [baseUrl, namespace] = [url, opts.path || '/'];
|
|
3193
|
+
// console.log({ url, baseUrl, namespace });
|
|
2742
3194
|
const namespaceName = namespace || '/';
|
|
3195
|
+
// Look up the server instance from the registry
|
|
2743
3196
|
const server = MockServer.from(url);
|
|
2744
3197
|
const ns = server.of(namespaceName);
|
|
2745
3198
|
ns.connect(this);
|
|
2746
3199
|
}
|
|
3200
|
+
//#endregion
|
|
3201
|
+
//#region nsp + name
|
|
2747
3202
|
get nsp() {
|
|
2748
3203
|
const self = this;
|
|
2749
3204
|
return {
|
|
@@ -2752,21 +3207,29 @@ class MockSocket {
|
|
|
2752
3207
|
},
|
|
2753
3208
|
};
|
|
2754
3209
|
}
|
|
3210
|
+
//#endregion
|
|
3211
|
+
//#region path
|
|
2755
3212
|
path() {
|
|
2756
3213
|
return this.namespaceInstance?.name;
|
|
2757
3214
|
}
|
|
3215
|
+
//#endregion
|
|
3216
|
+
//#region on
|
|
2758
3217
|
on(eventName, handler) {
|
|
2759
3218
|
if (!this.socketEventHandlers[eventName]) {
|
|
2760
3219
|
this.socketEventHandlers[eventName] =
|
|
2761
3220
|
new Set();
|
|
2762
3221
|
}
|
|
2763
3222
|
this.socketEventHandlers[eventName].add(handler);
|
|
3223
|
+
// QUICK_FIX client initing itself
|
|
2764
3224
|
if (eventName === 'connect') {
|
|
2765
3225
|
setTimeout(() => {
|
|
2766
3226
|
this.emit('connect');
|
|
3227
|
+
// this.namespaceInstance.emit('connection', this); @UNCOMMNENT
|
|
2767
3228
|
});
|
|
2768
3229
|
}
|
|
2769
3230
|
}
|
|
3231
|
+
//#endregion
|
|
3232
|
+
//#region emit
|
|
2770
3233
|
emit(eventName, ...args) {
|
|
2771
3234
|
eventName = eventName || '';
|
|
2772
3235
|
if (eventName.includes(`:${Symbols.REALTIME.KEYroomSubscribe}`)) {
|
|
@@ -2778,14 +3241,17 @@ class MockSocket {
|
|
|
2778
3241
|
this.leave(room);
|
|
2779
3242
|
}
|
|
2780
3243
|
else {
|
|
3244
|
+
// console.log('try to emit event (to server)', event);
|
|
2781
3245
|
if (this.namespaceInstance) {
|
|
2782
3246
|
const namespaceEventHandlers = this.namespaceInstance.namespaceEventHandlers[eventName] || [];
|
|
3247
|
+
// emit to namespace events
|
|
2783
3248
|
for (const namespaceEventHandler of namespaceEventHandlers) {
|
|
2784
3249
|
if (namespaceEventHandler) {
|
|
2785
3250
|
namespaceEventHandler(...args);
|
|
2786
3251
|
}
|
|
2787
3252
|
}
|
|
2788
3253
|
const allSocketsForNamespaceExceptCurrent = Array.from(this.namespaceInstance.allSocketsForNamespace.values()).filter(socket => socket !== this);
|
|
3254
|
+
// emit to all sockets in namespace
|
|
2789
3255
|
for (const socket of allSocketsForNamespaceExceptCurrent) {
|
|
2790
3256
|
const socketEventHandlers = socket.socketEventHandlers[eventName];
|
|
2791
3257
|
for (const socketEventHandler of socketEventHandlers) {
|
|
@@ -2794,6 +3260,7 @@ class MockSocket {
|
|
|
2794
3260
|
}
|
|
2795
3261
|
}
|
|
2796
3262
|
}
|
|
3263
|
+
// Emit to current socket
|
|
2797
3264
|
const socketEventHandlers = this.socketEventHandlers[eventName] || [];
|
|
2798
3265
|
for (const clientHandler of socketEventHandlers) {
|
|
2799
3266
|
if (clientHandler) {
|
|
@@ -2803,25 +3270,35 @@ class MockSocket {
|
|
|
2803
3270
|
}
|
|
2804
3271
|
}
|
|
2805
3272
|
}
|
|
3273
|
+
//#endregion
|
|
3274
|
+
//#region join room
|
|
2806
3275
|
join(roomName) {
|
|
2807
3276
|
this.namespaceInstance.joinRoom(roomName, this);
|
|
2808
3277
|
}
|
|
3278
|
+
//#endregion
|
|
3279
|
+
//#region leave room
|
|
2809
3280
|
leave(roomName) {
|
|
2810
3281
|
this.namespaceInstance.leaveRoom(roomName, this);
|
|
2811
3282
|
}
|
|
2812
3283
|
}
|
|
3284
|
+
//#endregion
|
|
2813
3285
|
/**
|
|
2814
3286
|
* Purpose:
|
|
2815
3287
|
* - browser-browser communication mock (in websql mode)
|
|
2816
3288
|
*/
|
|
2817
3289
|
class RealtimeStrategyMock extends RealtimeStrategy {
|
|
3290
|
+
//#region toString
|
|
2818
3291
|
toString() {
|
|
2819
3292
|
return 'mock';
|
|
2820
3293
|
}
|
|
3294
|
+
//#endregion
|
|
3295
|
+
//#region constructor
|
|
2821
3296
|
constructor(ctx) {
|
|
2822
3297
|
super(ctx);
|
|
2823
3298
|
this.ctx = ctx;
|
|
2824
3299
|
}
|
|
3300
|
+
//#endregion
|
|
3301
|
+
//#region server & io
|
|
2825
3302
|
ioServer(url, opt) {
|
|
2826
3303
|
const server = MockServer.from(url || this.ctx.uri.origin);
|
|
2827
3304
|
return server.of(opt?.path || '/');
|
|
@@ -2833,8 +3310,6 @@ class RealtimeStrategyMock extends RealtimeStrategy {
|
|
|
2833
3310
|
return clientIo;
|
|
2834
3311
|
}
|
|
2835
3312
|
}
|
|
2836
|
-
;
|
|
2837
|
-
({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-mock.ts
|
|
2838
3313
|
|
|
2839
3314
|
/**
|
|
2840
3315
|
* Purpose:
|
|
@@ -2858,12 +3333,8 @@ class RealtimeStrategySocketIO extends RealtimeStrategy {
|
|
|
2858
3333
|
return io;
|
|
2859
3334
|
}
|
|
2860
3335
|
}
|
|
2861
|
-
;
|
|
2862
|
-
({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-socket-io.ts
|
|
2863
|
-
|
|
2864
|
-
;
|
|
2865
|
-
({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/index.ts
|
|
2866
3336
|
|
|
3337
|
+
//#endregion
|
|
2867
3338
|
/**
|
|
2868
3339
|
* Realtime class
|
|
2869
3340
|
* - mock (when browser-browser)
|
|
@@ -2872,8 +3343,11 @@ class RealtimeStrategySocketIO extends RealtimeStrategy {
|
|
|
2872
3343
|
* - webworker (when webworker is used in browser or nodejs)
|
|
2873
3344
|
*/
|
|
2874
3345
|
class RealtimeCore {
|
|
3346
|
+
//#endregion
|
|
3347
|
+
//#region constructor
|
|
2875
3348
|
constructor(ctx) {
|
|
2876
3349
|
this.ctx = ctx;
|
|
3350
|
+
//#region fields
|
|
2877
3351
|
this.allHttpMethods = [
|
|
2878
3352
|
'GET',
|
|
2879
3353
|
'POST',
|
|
@@ -2889,23 +3363,36 @@ class RealtimeCore {
|
|
|
2889
3363
|
console.log(`[taon] realtime strategy: ${this.strategy}`);
|
|
2890
3364
|
if (Helpers.isWebSQL) {
|
|
2891
3365
|
this.server = new RealtimeServer(this);
|
|
3366
|
+
// console.log('DONE INITING SERVER');
|
|
2892
3367
|
this.client = new RealtimeClient(this);
|
|
3368
|
+
// console.log('DONE INITING CLIENT');
|
|
2893
3369
|
}
|
|
2894
3370
|
else {
|
|
2895
3371
|
this.client = new RealtimeClient(this);
|
|
2896
3372
|
this.server = new RealtimeServer(this);
|
|
2897
3373
|
}
|
|
2898
3374
|
}
|
|
3375
|
+
//#endregion
|
|
3376
|
+
//#region methods & getters / resovle staraegy
|
|
2899
3377
|
resolveStrategy() {
|
|
2900
3378
|
if (this.ctx.mode === 'backend-frontend(websql)' ||
|
|
2901
3379
|
this.ctx.mode === 'backend-frontend(websql-electron)') {
|
|
3380
|
+
// debugger
|
|
2902
3381
|
return new RealtimeStrategyMock(this.ctx);
|
|
2903
3382
|
}
|
|
2904
3383
|
if (this.ctx.mode === 'backend-frontend(ipc-electron)') {
|
|
2905
3384
|
return new RealtimeStrategyIpc(this.ctx);
|
|
2906
3385
|
}
|
|
3386
|
+
// if (this.ctx.mode === 'backend-frontend(tcp+udp)') {
|
|
3387
|
+
// return new RealtimeStrategySocketIO(this.ctx);
|
|
3388
|
+
// }
|
|
3389
|
+
// if (this.ctx.mode === 'remote-backend(tcp+udp)') {
|
|
3390
|
+
// return new RealtimeStrategySocketIO(this.ctx);
|
|
3391
|
+
// }
|
|
2907
3392
|
return new RealtimeStrategySocketIO(this.ctx);
|
|
2908
3393
|
}
|
|
3394
|
+
//#endregion
|
|
3395
|
+
//#region path for
|
|
2909
3396
|
pathFor(namespace) {
|
|
2910
3397
|
const uri = this.ctx.uri;
|
|
2911
3398
|
let nsp = namespace ? namespace : '';
|
|
@@ -2916,18 +3403,26 @@ class RealtimeCore {
|
|
|
2916
3403
|
prefix = ``;
|
|
2917
3404
|
}
|
|
2918
3405
|
const href = `${uri.origin}${pathname}/${prefix}${prefix && nsp ? '-' + nsp : nsp}`;
|
|
3406
|
+
// console.log(`HREF: ${href}, nsp: ${nsp}`)
|
|
2919
3407
|
return new URL(href);
|
|
2920
3408
|
}
|
|
2921
3409
|
}
|
|
2922
|
-
;
|
|
2923
|
-
({}); // @--end-of-file-for-module=taon lib/realtime/realtime-core.ts
|
|
2924
3410
|
|
|
2925
3411
|
class ContextDbMigrations {
|
|
3412
|
+
//#endregion
|
|
3413
|
+
//#endregion
|
|
3414
|
+
//#region constructor
|
|
2926
3415
|
constructor(ctx) {
|
|
2927
3416
|
this.ctx = ctx;
|
|
3417
|
+
//#region fields
|
|
3418
|
+
//#region fields / migration table name
|
|
2928
3419
|
this.DEFAULT_MIGRATION_TABLE_NAME = 'TAON_MIGRATION_META';
|
|
3420
|
+
//#endregion
|
|
3421
|
+
//#region fields / migration statuses
|
|
2929
3422
|
this.MIGRATION_STATUS_COMPLETED = 'completed';
|
|
2930
3423
|
this.MIGRATION_STATUS_PENDING = 'pending';
|
|
3424
|
+
//#endregion
|
|
3425
|
+
//#region fields / migration table schema
|
|
2931
3426
|
this.table = new Table({
|
|
2932
3427
|
name: this.DEFAULT_MIGRATION_TABLE_NAME,
|
|
2933
3428
|
columns: [
|
|
@@ -2946,6 +3441,7 @@ class ContextDbMigrations {
|
|
|
2946
3441
|
isNullable: false, // Ensure this field is required
|
|
2947
3442
|
},
|
|
2948
3443
|
{
|
|
3444
|
+
// context is a part of name
|
|
2949
3445
|
name: 'context',
|
|
2950
3446
|
type: 'varchar',
|
|
2951
3447
|
length: '255',
|
|
@@ -2964,9 +3460,17 @@ class ContextDbMigrations {
|
|
|
2964
3460
|
default: `'${this.MIGRATION_STATUS_COMPLETED}'`,
|
|
2965
3461
|
isNullable: false,
|
|
2966
3462
|
},
|
|
3463
|
+
// { // TODO not needed for now
|
|
3464
|
+
// name: 'checksum',
|
|
3465
|
+
// type: 'varchar',
|
|
3466
|
+
// length: '64',
|
|
3467
|
+
// isNullable: true, // Optional field to store a hash/checksum of migration file
|
|
3468
|
+
// },
|
|
2967
3469
|
],
|
|
2968
3470
|
});
|
|
2969
3471
|
}
|
|
3472
|
+
//#endregion
|
|
3473
|
+
//#region methods & getters / make sure migration table exists
|
|
2970
3474
|
async ensureMigrationTableExists() {
|
|
2971
3475
|
/* */
|
|
2972
3476
|
/* */
|
|
@@ -3014,6 +3518,8 @@ class ContextDbMigrations {
|
|
|
3014
3518
|
/* */
|
|
3015
3519
|
return (void 0);
|
|
3016
3520
|
}
|
|
3521
|
+
//#endregion
|
|
3522
|
+
//#region methods & getters / revert migration to timestamp
|
|
3017
3523
|
async logSelectALl(name, queryRunner) {
|
|
3018
3524
|
console.log(name, (await queryRunner.query(`SELECT * FROM ${this.DEFAULT_MIGRATION_TABLE_NAME} WHERE context = $1`, [this.ctx.contextName])).map(m => m.name));
|
|
3019
3525
|
}
|
|
@@ -3115,6 +3621,8 @@ class ContextDbMigrations {
|
|
|
3115
3621
|
/* */
|
|
3116
3622
|
return (void 0);
|
|
3117
3623
|
}
|
|
3624
|
+
//#endregion
|
|
3625
|
+
//#region methods & getters / clear migration table
|
|
3118
3626
|
async clearMigrationTable() {
|
|
3119
3627
|
/* */
|
|
3120
3628
|
/* */
|
|
@@ -3136,6 +3644,8 @@ class ContextDbMigrations {
|
|
|
3136
3644
|
/* */
|
|
3137
3645
|
return (void 0);
|
|
3138
3646
|
}
|
|
3647
|
+
//#endregion
|
|
3648
|
+
//#region methods & getters / mark all migrations as applied
|
|
3139
3649
|
async markAllMigrationsAsApplied() {
|
|
3140
3650
|
/* */
|
|
3141
3651
|
/* */
|
|
@@ -3210,6 +3720,8 @@ class ContextDbMigrations {
|
|
|
3210
3720
|
/* */
|
|
3211
3721
|
return (void 0);
|
|
3212
3722
|
}
|
|
3723
|
+
//#endregion
|
|
3724
|
+
//#region methods & getters / run all migrations
|
|
3213
3725
|
async runAllNotCompletedMigrations() {
|
|
3214
3726
|
/* */
|
|
3215
3727
|
/* */
|
|
@@ -3343,13 +3855,29 @@ class ContextDbMigrations {
|
|
|
3343
3855
|
return (void 0);
|
|
3344
3856
|
}
|
|
3345
3857
|
}
|
|
3346
|
-
;
|
|
3347
|
-
({}); // @--end-of-file-for-module=taon lib/context-db-migrations.ts
|
|
3348
3858
|
|
|
3349
3859
|
/* eslint-disable @typescript-eslint/typedef */
|
|
3860
|
+
//#region imports
|
|
3861
|
+
/* */
|
|
3862
|
+
/* */
|
|
3863
|
+
/* */
|
|
3864
|
+
/* */
|
|
3865
|
+
/* */
|
|
3866
|
+
/* */
|
|
3867
|
+
/* */
|
|
3868
|
+
/* */
|
|
3869
|
+
/* */
|
|
3870
|
+
/* */
|
|
3871
|
+
/* */
|
|
3872
|
+
/* */
|
|
3873
|
+
/* */
|
|
3874
|
+
//#endregion
|
|
3350
3875
|
class EndpointContext {
|
|
3876
|
+
//#endregion
|
|
3351
3877
|
static initNgZone(ngZone) {
|
|
3878
|
+
//#region @browser
|
|
3352
3879
|
this.ngZone = ngZone;
|
|
3880
|
+
//#endregion
|
|
3353
3881
|
}
|
|
3354
3882
|
get isRunOrRevertOnlyMigrationAppStart() {
|
|
3355
3883
|
return !!(this.onlyMigrationRun || this.onlyMigrationRevertToTimestamp);
|
|
@@ -3360,56 +3888,81 @@ class EndpointContext {
|
|
|
3360
3888
|
get realtimeServer() {
|
|
3361
3889
|
return this.realtime.server;
|
|
3362
3890
|
}
|
|
3891
|
+
//#endregion
|
|
3892
|
+
//#region fields / logs
|
|
3363
3893
|
get logHttp() {
|
|
3364
|
-
if (_
|
|
3894
|
+
if (_.isObject(this.config?.logs)) {
|
|
3365
3895
|
return !!this.config.logs.http;
|
|
3366
3896
|
}
|
|
3367
3897
|
return this.config?.logs === true;
|
|
3368
3898
|
}
|
|
3369
3899
|
get logRealtime() {
|
|
3370
|
-
if (_
|
|
3900
|
+
if (_.isObject(this.config?.logs)) {
|
|
3371
3901
|
return !!this.config.logs.realtime;
|
|
3372
3902
|
}
|
|
3373
3903
|
return this.config?.logs === true;
|
|
3374
3904
|
}
|
|
3375
3905
|
get logFramework() {
|
|
3376
|
-
if (_
|
|
3906
|
+
if (_.isObject(this.config?.logs)) {
|
|
3377
3907
|
return !!this.config.logs.framework;
|
|
3378
3908
|
}
|
|
3379
3909
|
return this.config?.logs === true;
|
|
3380
3910
|
}
|
|
3381
3911
|
get logDb() {
|
|
3382
|
-
if (_
|
|
3912
|
+
if (_.isObject(this.config?.logs)) {
|
|
3383
3913
|
return !!this.config.logs.db;
|
|
3384
3914
|
}
|
|
3385
3915
|
return this.config?.logs === true;
|
|
3386
3916
|
}
|
|
3387
3917
|
get logMigrations() {
|
|
3388
|
-
if (_
|
|
3918
|
+
if (_.isObject(this.config?.logs)) {
|
|
3389
3919
|
return !!this.config.logs.migrations;
|
|
3390
3920
|
}
|
|
3391
3921
|
return this.config?.logs === true;
|
|
3392
3922
|
}
|
|
3923
|
+
//#endregion
|
|
3924
|
+
//#endregion
|
|
3925
|
+
//#region constructor
|
|
3393
3926
|
constructor(originalConfig, configFn) {
|
|
3394
3927
|
this.originalConfig = originalConfig;
|
|
3395
3928
|
this.configFn = configFn;
|
|
3929
|
+
// public static findForTraget(classFnOrObject: any): EndpointContext {
|
|
3930
|
+
// const obj = ClassHelpers.getClassFnFromObject(classFnOrObject) || {};
|
|
3931
|
+
// return (
|
|
3932
|
+
// classFnOrObject[Symbols.ctxInClassOrClassObj] ||
|
|
3933
|
+
// obj[Symbols.ctxInClassOrClassObj]
|
|
3934
|
+
// );
|
|
3935
|
+
// }
|
|
3936
|
+
//#endregion
|
|
3937
|
+
//#region fields
|
|
3938
|
+
//#region fields / flags
|
|
3396
3939
|
this.disabledRealtime = false;
|
|
3397
3940
|
/**
|
|
3398
3941
|
* check whether context is inited
|
|
3399
3942
|
* (with init() function )
|
|
3400
3943
|
*/
|
|
3401
3944
|
this.inited = false;
|
|
3945
|
+
//#endregion
|
|
3402
3946
|
this.dbMigrations = new ContextDbMigrations(this);
|
|
3403
3947
|
this.localInstaceObjSymbol = Symbol('localInstaceObjSymbol');
|
|
3948
|
+
//#region fields / all instances of classes from context
|
|
3404
3949
|
/**
|
|
3405
3950
|
* all instances of classes from context
|
|
3406
3951
|
* key is class name
|
|
3407
3952
|
*/
|
|
3408
3953
|
this.allClassesInstances = {};
|
|
3954
|
+
//#endregion
|
|
3955
|
+
//#region fields / class instances by name
|
|
3409
3956
|
this.classInstancesByNameObj = {};
|
|
3957
|
+
//#endregion
|
|
3958
|
+
//#region fields / obj with classes instances arr
|
|
3410
3959
|
this.objWithClassesInstancesArr = {};
|
|
3960
|
+
//#endregion
|
|
3961
|
+
//#region fields / active routes
|
|
3411
3962
|
this.activeRoutes = [];
|
|
3963
|
+
//#endregion
|
|
3412
3964
|
this.skipWritingServerRoutes = false;
|
|
3965
|
+
//#region fields / types from contexts
|
|
3413
3966
|
this.injectableTypesfromContexts = [
|
|
3414
3967
|
Models.ClassType.CONTROLLER,
|
|
3415
3968
|
Models.ClassType.PROVIDER,
|
|
@@ -3417,15 +3970,26 @@ class EndpointContext {
|
|
|
3417
3970
|
Models.ClassType.SUBSCRIBER,
|
|
3418
3971
|
Models.ClassType.MIGRATION,
|
|
3419
3972
|
];
|
|
3973
|
+
//#endregion
|
|
3420
3974
|
this.allTypesfromContexts = [
|
|
3421
3975
|
...this.injectableTypesfromContexts,
|
|
3422
3976
|
Models.ClassType.ENTITY,
|
|
3423
3977
|
];
|
|
3978
|
+
// public __contextForControllerInstanceAccess?: EndpointContext;
|
|
3979
|
+
//#region fields / express app
|
|
3424
3980
|
this.expressApp = {};
|
|
3981
|
+
//#endregion
|
|
3982
|
+
//#region fields / only migration start
|
|
3425
3983
|
this.onlyMigrationRun = false;
|
|
3426
3984
|
this.onlyMigrationRevertToTimestamp = undefined;
|
|
3985
|
+
//#endregion
|
|
3986
|
+
//#region fields / entities triggers
|
|
3427
3987
|
this.entitiesTriggers = {};
|
|
3988
|
+
//#endregion
|
|
3989
|
+
//#region methods & getters / clone class
|
|
3990
|
+
// eslint-disable-next-line @typescript-eslint/typedef
|
|
3428
3991
|
this.cloneClassWithNewMetadata = ({ BaseClass, className, config, ctx, classType, }) => {
|
|
3992
|
+
// Return a new class that extends the base class
|
|
3429
3993
|
const cloneClass = () => {
|
|
3430
3994
|
var _a, _b, _c, _d, _e;
|
|
3431
3995
|
if (BaseClass[Symbols.fullClassNameStaticProperty] ===
|
|
@@ -3436,15 +4000,23 @@ class EndpointContext {
|
|
|
3436
4000
|
constructor() {
|
|
3437
4001
|
super(...arguments);
|
|
3438
4002
|
this[_e] = ctx;
|
|
4003
|
+
// You can override prototype properties or methods here if needed
|
|
4004
|
+
// static properties override allowed
|
|
3439
4005
|
}
|
|
3440
4006
|
static { _a = Symbols.orignalClass, _b = Symbols.fullClassNameStaticProperty, _c = Symbols.classNameStaticProperty, _d = Symbols.ctxInClassOrClassObj, _e = Symbols.ctxInClassOrClassObj; }
|
|
4007
|
+
// static ['_'] = BaseClass['_'];
|
|
4008
|
+
// eslint-disable-next-line @typescript-eslint/typedef
|
|
3441
4009
|
// @ts-ignore
|
|
3442
4010
|
static { this[_a] = BaseClass; }
|
|
4011
|
+
// eslint-disable-next-line @typescript-eslint/typedef
|
|
3443
4012
|
// @ts-ignore
|
|
3444
4013
|
static { this[_b] = `${ctx.contextName}.${className}`; }
|
|
4014
|
+
// eslint-disable-next-line @typescript-eslint/typedef
|
|
3445
4015
|
// @ts-ignore
|
|
3446
4016
|
static { this[_c] = className; }
|
|
4017
|
+
// eslint-disable-next-line @typescript-eslint/typedef
|
|
3447
4018
|
static { this[_d] = ctx; }
|
|
4019
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/typedef
|
|
3448
4020
|
static __getFullPathForClass__(arr = []) {
|
|
3449
4021
|
const name = this[Symbols.fullClassNameStaticProperty];
|
|
3450
4022
|
arr.push(name);
|
|
@@ -3462,10 +4034,31 @@ class EndpointContext {
|
|
|
3462
4034
|
};
|
|
3463
4035
|
};
|
|
3464
4036
|
const cloneClassFunction = cloneClass();
|
|
4037
|
+
//#region gather all instances for all contexts
|
|
4038
|
+
// TODO this is not needed anymore - for typeorm I use normal entities
|
|
4039
|
+
// this thinng belowe is nice for debugging purpose
|
|
4040
|
+
// if (_.isUndefined(cloneClassFunction[Symbols.orignalClassClonesObj])) {
|
|
4041
|
+
// cloneClassFunction[Symbols.orignalClassClonesObj] = {};
|
|
4042
|
+
// }
|
|
4043
|
+
// if (_.isUndefined(BaseClass[Symbols.orignalClassClonesObj])) {
|
|
4044
|
+
// BaseClass[Symbols.orignalClassClonesObj] = {};
|
|
4045
|
+
// }
|
|
4046
|
+
// const all = {
|
|
4047
|
+
// ...BaseClass[Symbols.orignalClassClonesObj],
|
|
4048
|
+
// ...cloneClassFunction[Symbols.orignalClassClonesObj],
|
|
4049
|
+
// };
|
|
4050
|
+
// all[ctx.contextName] = cloneClassFunction;
|
|
4051
|
+
// cloneClassFunction[Symbols.orignalClassClonesObj] = all;
|
|
4052
|
+
// BaseClass[Symbols.orignalClassClonesObj] = all;
|
|
4053
|
+
//#endregion
|
|
3465
4054
|
return cloneClassFunction;
|
|
3466
4055
|
};
|
|
4056
|
+
//#endregion
|
|
4057
|
+
//#region methods & getters / clone classes obj with new metadata
|
|
4058
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
3467
4059
|
this.cloneClassesObjWithNewMetadata = ({ classesInput, config, ctx, classType, }) => {
|
|
3468
4060
|
const classes = {};
|
|
4061
|
+
// console.log(Object.keys(classesInput))
|
|
3469
4062
|
for (const key of Object.keys(classesInput || {})) {
|
|
3470
4063
|
const BaseClass = classesInput[key];
|
|
3471
4064
|
if (!BaseClass) {
|
|
@@ -3476,6 +4069,10 @@ class EndpointContext {
|
|
|
3476
4069
|
`);
|
|
3477
4070
|
}
|
|
3478
4071
|
var className = Reflect.getMetadata(Symbols.metadata.className, BaseClass);
|
|
4072
|
+
// console.log('Metadata className', className, BaseClass);
|
|
4073
|
+
// if (!className) {
|
|
4074
|
+
// console.warn(`Please provide className for ${BaseClass.name} class`);
|
|
4075
|
+
// }
|
|
3479
4076
|
className = className || key;
|
|
3480
4077
|
BaseClass[Symbols.classNameStaticProperty] = className;
|
|
3481
4078
|
const clonedClass = this.cloneClassWithNewMetadata({
|
|
@@ -3490,6 +4087,8 @@ class EndpointContext {
|
|
|
3490
4087
|
return classes;
|
|
3491
4088
|
};
|
|
3492
4089
|
}
|
|
4090
|
+
//#endregion
|
|
4091
|
+
//#region methods & getters / init
|
|
3493
4092
|
async init(options) {
|
|
3494
4093
|
const { initFromRecrusiveContextResovle, overrideHost, overrideRemoteHost, onlyMigrationRun, onlyMigrationRevertToTimestamp, } = options || {}; // TODO use it ?
|
|
3495
4094
|
this.inited = true;
|
|
@@ -3498,16 +4097,16 @@ class EndpointContext {
|
|
|
3498
4097
|
// @ts-ignore
|
|
3499
4098
|
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
3500
4099
|
this.config = this.configFn(ENV$2);
|
|
3501
|
-
if (_
|
|
4100
|
+
if (_.isObject(this.config.database)) {
|
|
3502
4101
|
this.config.database = Models.DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
3503
4102
|
}
|
|
3504
4103
|
if (overrideHost && overrideRemoteHost) {
|
|
3505
4104
|
Helpers.throw(`[taon-config] You can't have overrideHost and overrideRemoteHost at the same time`);
|
|
3506
4105
|
}
|
|
3507
|
-
this.config.host = !_
|
|
4106
|
+
this.config.host = !_.isUndefined(overrideHost)
|
|
3508
4107
|
? overrideHost
|
|
3509
4108
|
: this.config.host;
|
|
3510
|
-
this.config.remoteHost = !_
|
|
4109
|
+
this.config.remoteHost = !_.isUndefined(overrideRemoteHost)
|
|
3511
4110
|
? overrideRemoteHost
|
|
3512
4111
|
: this.config.remoteHost;
|
|
3513
4112
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
@@ -3518,7 +4117,7 @@ class EndpointContext {
|
|
|
3518
4117
|
!this.config.host.startsWith('https://')) {
|
|
3519
4118
|
Helpers.throw(`[taon-config] Your 'host' must start with http:// or https://`);
|
|
3520
4119
|
}
|
|
3521
|
-
if (_
|
|
4120
|
+
if (_.isUndefined(this.config.useIpcWhenElectron)) {
|
|
3522
4121
|
this.config.useIpcWhenElectron = true;
|
|
3523
4122
|
}
|
|
3524
4123
|
if (this.config.remoteHost &&
|
|
@@ -3526,10 +4125,13 @@ class EndpointContext {
|
|
|
3526
4125
|
!this.config.remoteHost.startsWith('https://')) {
|
|
3527
4126
|
Helpers.throw(`[taon-config] Your 'remoteHost' must start with http:// or https://`);
|
|
3528
4127
|
}
|
|
4128
|
+
//#region resolve if skipping writing server routes
|
|
3529
4129
|
//@ts-expect-error overriding readonly
|
|
3530
|
-
this.skipWritingServerRoutes = _
|
|
4130
|
+
this.skipWritingServerRoutes = _.isBoolean(this.config.skipWritingServerRoutes)
|
|
3531
4131
|
? this.config.skipWritingServerRoutes
|
|
3532
4132
|
: false;
|
|
4133
|
+
//#endregion
|
|
4134
|
+
//#region resolve mode
|
|
3533
4135
|
if (this.config.host) {
|
|
3534
4136
|
this.mode = 'backend-frontend(tcp+udp)';
|
|
3535
4137
|
/* */
|
|
@@ -3554,20 +4156,27 @@ class EndpointContext {
|
|
|
3554
4156
|
/* */
|
|
3555
4157
|
/* */
|
|
3556
4158
|
}
|
|
4159
|
+
//#endregion
|
|
4160
|
+
//#region resolve database config
|
|
3557
4161
|
if (this.config.database === true) {
|
|
3558
4162
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
3559
4163
|
}
|
|
3560
|
-
else if (_
|
|
3561
|
-
this.databaseConfig = _
|
|
4164
|
+
else if (_.isObject(this.config.database)) {
|
|
4165
|
+
this.databaseConfig = _.merge(this.getAutoGeneratedConfig(), _.cloneDeep(this.config.database));
|
|
3562
4166
|
}
|
|
4167
|
+
//#endregion
|
|
4168
|
+
//#region resolve session
|
|
3563
4169
|
if (this.config.session) {
|
|
3564
|
-
this.session = _
|
|
4170
|
+
this.session = _.cloneDeep(this.config.session);
|
|
3565
4171
|
const oneHour = 1000 * 60 * 60 * 1; // 24;
|
|
3566
4172
|
if (!this.session.cookieMaxAge) {
|
|
3567
4173
|
this.session.cookieMaxAge = oneHour;
|
|
3568
4174
|
}
|
|
4175
|
+
// serever and browser cookie authentication
|
|
3569
4176
|
axios.defaults.withCredentials = true;
|
|
3570
4177
|
}
|
|
4178
|
+
//#endregion
|
|
4179
|
+
//#region prepare & gather all classes recrusively
|
|
3571
4180
|
this.config.contexts = this.config.contexts || {};
|
|
3572
4181
|
this.config.entities = this.config.entities || {};
|
|
3573
4182
|
this.config.controllers = this.config.controllers || {};
|
|
@@ -3599,6 +4208,10 @@ class EndpointContext {
|
|
|
3599
4208
|
...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.MIGRATION)),
|
|
3600
4209
|
...this.config.migrations,
|
|
3601
4210
|
};
|
|
4211
|
+
// console.log(this.config);
|
|
4212
|
+
// debugger;
|
|
4213
|
+
//#endregion
|
|
4214
|
+
//#region prepare classes instances/functions clones
|
|
3602
4215
|
this.config.controllers = this.cloneClassesObjWithNewMetadata({
|
|
3603
4216
|
classesInput: this.config.controllers,
|
|
3604
4217
|
config: this.config,
|
|
@@ -3629,6 +4242,8 @@ class EndpointContext {
|
|
|
3629
4242
|
ctx: this,
|
|
3630
4243
|
classType: Models.ClassType.MIGRATION,
|
|
3631
4244
|
});
|
|
4245
|
+
//#endregion
|
|
4246
|
+
//#region prepare instances
|
|
3632
4247
|
for (const classTypeName of this.injectableTypesfromContexts) {
|
|
3633
4248
|
this.classInstancesByNameObj[classTypeName] = {};
|
|
3634
4249
|
this.objWithClassesInstancesArr[classTypeName] = [];
|
|
@@ -3636,7 +4251,9 @@ class EndpointContext {
|
|
|
3636
4251
|
for (const classTypeName of this.injectableTypesfromContexts) {
|
|
3637
4252
|
await this.createInstances(this.config[Models.ClassTypeKey[classTypeName]], classTypeName);
|
|
3638
4253
|
}
|
|
4254
|
+
//#endregion
|
|
3639
4255
|
if (!this.isRunOrRevertOnlyMigrationAppStart) {
|
|
4256
|
+
//#region prepares server
|
|
3640
4257
|
if (this.mode === 'backend-frontend(tcp+udp)' && !this.config.abstract) {
|
|
3641
4258
|
/* */
|
|
3642
4259
|
/* */
|
|
@@ -3658,6 +4275,8 @@ class EndpointContext {
|
|
|
3658
4275
|
/* */
|
|
3659
4276
|
/* */
|
|
3660
4277
|
}
|
|
4278
|
+
//#endregion
|
|
4279
|
+
//#region prepare realtime
|
|
3661
4280
|
if (!this.config.abstract) {
|
|
3662
4281
|
this.disabledRealtime = !!this.config.disabledRealtime;
|
|
3663
4282
|
/* */
|
|
@@ -3667,7 +4286,10 @@ class EndpointContext {
|
|
|
3667
4286
|
/* */
|
|
3668
4287
|
this.realtime = new RealtimeCore(this);
|
|
3669
4288
|
}
|
|
4289
|
+
//#endregion
|
|
3670
4290
|
}
|
|
4291
|
+
//#region show context info
|
|
4292
|
+
// console.log({ ref })
|
|
3671
4293
|
if (this.config.abstract) {
|
|
3672
4294
|
this.logFramework &&
|
|
3673
4295
|
Helpers.info(`[taon] Create abstract context: ${this.config.contextName}`);
|
|
@@ -3682,10 +4304,14 @@ class EndpointContext {
|
|
|
3682
4304
|
Helpers.info(`[taon] Create context for host: ${this.config.host}`);
|
|
3683
4305
|
}
|
|
3684
4306
|
}
|
|
4307
|
+
//#endregion
|
|
4308
|
+
// update first exposed config
|
|
3685
4309
|
Object.keys(this.config).forEach(key => {
|
|
3686
4310
|
this.originalConfig[key] = this.config[key];
|
|
3687
4311
|
});
|
|
3688
4312
|
}
|
|
4313
|
+
//#endregion
|
|
4314
|
+
//#region methods & getters / get auto generated config
|
|
3689
4315
|
getAutoGeneratedConfig() {
|
|
3690
4316
|
/* */
|
|
3691
4317
|
/* */
|
|
@@ -3756,10 +4382,16 @@ class EndpointContext {
|
|
|
3756
4382
|
/* */
|
|
3757
4383
|
return (void 0);
|
|
3758
4384
|
}
|
|
4385
|
+
//#endregion
|
|
4386
|
+
//#region methods & getters / ng zone
|
|
3759
4387
|
get ngZone() {
|
|
4388
|
+
//#region @browser
|
|
3760
4389
|
return EndpointContext.ngZone;
|
|
4390
|
+
//#endregion
|
|
3761
4391
|
return;
|
|
3762
4392
|
}
|
|
4393
|
+
//#endregion
|
|
4394
|
+
//#region methods & getters / start server
|
|
3763
4395
|
startServer() {
|
|
3764
4396
|
/* */
|
|
3765
4397
|
/* */
|
|
@@ -3779,6 +4411,8 @@ class EndpointContext {
|
|
|
3779
4411
|
/* */
|
|
3780
4412
|
return (void 0);
|
|
3781
4413
|
}
|
|
4414
|
+
//#endregion
|
|
4415
|
+
//#region methods & getters / display express routes
|
|
3782
4416
|
displayRoutes(app) {
|
|
3783
4417
|
/* */
|
|
3784
4418
|
/* */
|
|
@@ -3809,11 +4443,15 @@ class EndpointContext {
|
|
|
3809
4443
|
/* */
|
|
3810
4444
|
/* */
|
|
3811
4445
|
}
|
|
4446
|
+
//#endregion
|
|
4447
|
+
//#region methods & getters / mode allows database creation
|
|
3812
4448
|
get modeAllowsDatabaseCreation() {
|
|
3813
4449
|
return (this.mode === 'backend-frontend(tcp+udp)' ||
|
|
3814
4450
|
this.mode === 'backend-frontend(websql)' ||
|
|
3815
4451
|
this.mode === 'backend-frontend(ipc-electron)');
|
|
3816
4452
|
}
|
|
4453
|
+
//#endregion
|
|
4454
|
+
//#region methods & getters / get recursive classes from contexts
|
|
3817
4455
|
async getRecrusiveClassesfromContextsObj(classType) {
|
|
3818
4456
|
const arr = await this.getRecrusiveClassesfromContexts(classType);
|
|
3819
4457
|
return arr.reduce((acc, c) => {
|
|
@@ -3823,26 +4461,39 @@ class EndpointContext {
|
|
|
3823
4461
|
}
|
|
3824
4462
|
async getRecrusiveClassesfromContexts(classType, arr = []) {
|
|
3825
4463
|
const contexts = Object.values(this.config.contexts || {});
|
|
4464
|
+
// console.log({
|
|
4465
|
+
// contexts,
|
|
4466
|
+
// });
|
|
3826
4467
|
for (const ctx of contexts) {
|
|
4468
|
+
// console.log(`STARTING ${ctx.contextName}`);
|
|
3827
4469
|
const ref = await ctx.__ref();
|
|
4470
|
+
// console.log(`CTX FROM ${ctx.contextName}`, ref.contextName);
|
|
3828
4471
|
const classesInput = ref.getClassFunBy(classType);
|
|
4472
|
+
// console.log(`${ref.contextName} - ${classType}`, { classesInput });
|
|
3829
4473
|
const clonedClasses = Object.values(this.cloneClassesObjWithNewMetadata({
|
|
3830
4474
|
classesInput,
|
|
3831
4475
|
config: this.config,
|
|
3832
4476
|
ctx: this,
|
|
3833
4477
|
classType,
|
|
3834
4478
|
}));
|
|
4479
|
+
// console.log(`${classType} clonedClasses`, clonedClasses);
|
|
3835
4480
|
clonedClasses.forEach(c => arr.push(c));
|
|
3836
4481
|
await ref.getRecrusiveClassesfromContexts(classType, arr);
|
|
3837
4482
|
}
|
|
3838
4483
|
return arr;
|
|
3839
4484
|
}
|
|
4485
|
+
//#endregion
|
|
4486
|
+
//#region methods & getters / get class instances by class type
|
|
3840
4487
|
getClassInstanceObjBy(classType) {
|
|
3841
4488
|
return this.classInstancesByNameObj[classType];
|
|
3842
4489
|
}
|
|
4490
|
+
//#endregion
|
|
4491
|
+
//#region methods & getters / get class instances arr
|
|
3843
4492
|
getClassesInstancesArrBy(classType) {
|
|
3844
4493
|
return this.objWithClassesInstancesArr[classType];
|
|
3845
4494
|
}
|
|
4495
|
+
//#endregion
|
|
4496
|
+
//#region methods & getters / inject
|
|
3846
4497
|
inject(ctor, options) {
|
|
3847
4498
|
if (!options) {
|
|
3848
4499
|
options = {};
|
|
@@ -3866,6 +4517,7 @@ class EndpointContext {
|
|
|
3866
4517
|
const instanceKey = className + (entityName ? `.${entityName}` : '');
|
|
3867
4518
|
const existed = options.contextClassInstance[this.localInstaceObjSymbol][instanceKey];
|
|
3868
4519
|
if (existed) {
|
|
4520
|
+
// console.log(`exited `, existed)
|
|
3869
4521
|
return existed;
|
|
3870
4522
|
}
|
|
3871
4523
|
if (!ctxClassFn) {
|
|
@@ -3878,29 +4530,50 @@ class EndpointContext {
|
|
|
3878
4530
|
const injectedInstance = new ctxClassFn(...locaInstanceConstructorArgs);
|
|
3879
4531
|
options.contextClassInstance[this.localInstaceObjSymbol][instanceKey] =
|
|
3880
4532
|
injectedInstance;
|
|
4533
|
+
// console.log(`injectedInstance `, existed)
|
|
3881
4534
|
return injectedInstance;
|
|
3882
4535
|
}
|
|
3883
4536
|
const contextScopeInstance = this.allClassesInstances[className];
|
|
4537
|
+
// if (className === 'TopicController') {
|
|
4538
|
+
// debugger;
|
|
4539
|
+
// }
|
|
3884
4540
|
return contextScopeInstance;
|
|
3885
4541
|
}
|
|
3886
4542
|
/**
|
|
3887
4543
|
* alias for inject
|
|
3888
4544
|
*/
|
|
3889
4545
|
getInstanceBy(ctor) {
|
|
4546
|
+
// if (!!this.__contextForControllerInstanceAccess) {
|
|
4547
|
+
// const className = ClassHelpers.getName(ctor);
|
|
4548
|
+
// const allControllers = this.getClassFunByArr(Models.ClassType.CONTROLLER);
|
|
4549
|
+
// // TODO QUICK_FIX cache controllers
|
|
4550
|
+
// for (const ctrl of allControllers) {
|
|
4551
|
+
// if (ClassHelpers.getName(ctrl) === className) {
|
|
4552
|
+
// // console.log('injecting from contextForControllerInstanceAcesss', className);
|
|
4553
|
+
// return this.__contextForControllerInstanceAccess.inject(ctor, {
|
|
4554
|
+
// localInstance: false,
|
|
4555
|
+
// });
|
|
4556
|
+
// }
|
|
4557
|
+
// }
|
|
4558
|
+
// }
|
|
3890
4559
|
return this.inject(ctor, { localInstance: false });
|
|
3891
4560
|
}
|
|
4561
|
+
//#endregion
|
|
4562
|
+
//#region methods & getters / check if context initialized
|
|
3892
4563
|
checkIfContextInitialized() {
|
|
3893
|
-
if (_
|
|
4564
|
+
if (_.isUndefined(this.config)) {
|
|
3894
4565
|
throw new Error(`Please check if your context has been initialized.
|
|
3895
4566
|
|
|
3896
|
-
|
|
4567
|
+
// ...
|
|
3897
4568
|
await Context.initialize();
|
|
3898
|
-
|
|
4569
|
+
// ...
|
|
3899
4570
|
|
|
3900
4571
|
|
|
3901
4572
|
`);
|
|
3902
4573
|
}
|
|
3903
4574
|
}
|
|
4575
|
+
//#endregion
|
|
4576
|
+
//#region methods & getters / get class function by class type name
|
|
3904
4577
|
getClassFunBy(classType) {
|
|
3905
4578
|
this.checkIfContextInitialized();
|
|
3906
4579
|
switch (classType) {
|
|
@@ -3940,32 +4613,50 @@ class EndpointContext {
|
|
|
3940
4613
|
getClassFunByArr(classType) {
|
|
3941
4614
|
return Object.values(this.getClassFunBy(classType) || {});
|
|
3942
4615
|
}
|
|
4616
|
+
//#endregion
|
|
4617
|
+
//#region methods & getters / create class instances
|
|
3943
4618
|
async createInstances(classes, classType) {
|
|
4619
|
+
// const recrusiveValuesFromContext =
|
|
4620
|
+
// await this.getRecrusiveClassesfromContexts(classType);
|
|
4621
|
+
// console.log(this.config.contexts);
|
|
4622
|
+
// console.log('recrusiveValuesFromContext', recrusiveValuesFromContext);
|
|
3944
4623
|
for (const classFn of [
|
|
4624
|
+
// ...recrusiveValuesFromContext,
|
|
3945
4625
|
...Object.values(classes),
|
|
3946
4626
|
]) {
|
|
3947
4627
|
const instance = DITaonContainer.resolve(classFn);
|
|
3948
4628
|
const classInstancesByNameObj = this.classInstancesByNameObj[classType];
|
|
3949
4629
|
const className = ClassHelpers.getName(classFn);
|
|
4630
|
+
// console.log({ classFn, classType, instance, place, className, 'classInstancesByNameObj': this.classInstancesByNameObj });
|
|
3950
4631
|
classInstancesByNameObj[className] = instance;
|
|
4632
|
+
// update config
|
|
3951
4633
|
this.config[Models.ClassTypeKey[classType]][className] = classFn;
|
|
3952
4634
|
this.objWithClassesInstancesArr[classType].push(instance);
|
|
3953
4635
|
this.allClassesInstances[className] = instance;
|
|
3954
4636
|
}
|
|
3955
4637
|
}
|
|
4638
|
+
//#endregion
|
|
4639
|
+
//#region methods & getters / reinit controllers db example data
|
|
3956
4640
|
async reinitControllers() {
|
|
3957
4641
|
if (this.remoteHost || Object.keys(this.config.migrations).length > 0) {
|
|
3958
4642
|
return;
|
|
3959
4643
|
}
|
|
4644
|
+
// Helpers.taskStarted(
|
|
4645
|
+
// `[taon] REINITING CONTROLLERS ${this.contextName} STARTED`,
|
|
4646
|
+
// );
|
|
3960
4647
|
const controllers = this.getClassesInstancesArrBy(Models.ClassType.CONTROLLER);
|
|
4648
|
+
// console.log('CONTROLLERS TO REINIT', controllers);
|
|
3961
4649
|
for (const ctrl of controllers) {
|
|
3962
|
-
if (_
|
|
4650
|
+
if (_.isFunction(ctrl.initExampleDbData)) {
|
|
3963
4651
|
await Helpers.runSyncOrAsync({
|
|
3964
4652
|
functionFn: ctrl.initExampleDbData,
|
|
3965
4653
|
context: ctrl,
|
|
3966
4654
|
});
|
|
3967
4655
|
}
|
|
3968
4656
|
}
|
|
4657
|
+
// Helpers.taskDone(
|
|
4658
|
+
// `[taon] REINITING CONTROLLERS ${this.contextName} DONE`,
|
|
4659
|
+
// );
|
|
3969
4660
|
}
|
|
3970
4661
|
async initClasses() {
|
|
3971
4662
|
if (this.remoteHost) {
|
|
@@ -3978,14 +4669,28 @@ class EndpointContext {
|
|
|
3978
4669
|
Models.ClassType.ENTITY,
|
|
3979
4670
|
Models.ClassType.MIGRATION,
|
|
3980
4671
|
]) {
|
|
4672
|
+
//#region init class static _ property
|
|
4673
|
+
// Helpers.taskStarted(
|
|
4674
|
+
// `[taon] REINITING _ CLASS FN ${classTypeName} ${this.contextName} STARTED`,
|
|
4675
|
+
// );
|
|
3981
4676
|
for (const classFun of this.getClassFunByArr(classTypeName)) {
|
|
3982
|
-
if (_
|
|
4677
|
+
if (_.isFunction(classFun._)) {
|
|
3983
4678
|
await Helpers.runSyncOrAsync({
|
|
3984
4679
|
functionFn: classFun._,
|
|
3985
4680
|
context: classFun,
|
|
3986
4681
|
});
|
|
4682
|
+
// const orgClass = ClassHelpers.getOrginalClass(classFun);
|
|
4683
|
+
// // orgClass['ctrl'] = classFun['ctrl'];
|
|
4684
|
+
// await Helpers.runSyncOrAsync({
|
|
4685
|
+
// functionFn: orgClass._,
|
|
4686
|
+
// context: orgClass,
|
|
4687
|
+
// });
|
|
3987
4688
|
}
|
|
3988
4689
|
}
|
|
4690
|
+
// Helpers.taskStarted(
|
|
4691
|
+
// `[taon] REINITING _ CLASS FN ${classTypeName} ${this.contextName} DONE`,
|
|
4692
|
+
// );
|
|
4693
|
+
//#endregion
|
|
3989
4694
|
}
|
|
3990
4695
|
for (const classTypeName of [
|
|
3991
4696
|
Models.ClassType.PROVIDER,
|
|
@@ -3993,20 +4698,32 @@ class EndpointContext {
|
|
|
3993
4698
|
Models.ClassType.CONTROLLER,
|
|
3994
4699
|
Models.ClassType.MIGRATION,
|
|
3995
4700
|
]) {
|
|
4701
|
+
//#region init providers, repositories _ property
|
|
4702
|
+
// Helpers.taskStarted(
|
|
4703
|
+
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} STARTED`,
|
|
4704
|
+
// );
|
|
3996
4705
|
for (const ctrl of this.getClassesInstancesArrBy(classTypeName)) {
|
|
3997
|
-
if (_
|
|
4706
|
+
if (_.isFunction(ctrl._)) {
|
|
3998
4707
|
await Helpers.runSyncOrAsync({
|
|
3999
4708
|
functionFn: ctrl._,
|
|
4000
4709
|
context: ctrl,
|
|
4001
4710
|
});
|
|
4002
4711
|
}
|
|
4003
4712
|
}
|
|
4713
|
+
// Helpers.taskStarted(
|
|
4714
|
+
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} DONE`,
|
|
4715
|
+
// );
|
|
4716
|
+
//#endregion
|
|
4004
4717
|
}
|
|
4005
4718
|
}
|
|
4719
|
+
//#endregion
|
|
4720
|
+
//#region methods & getters / is active on
|
|
4006
4721
|
isActiveOn(classInstance) {
|
|
4007
4722
|
let contextRef = classInstance[Symbols.ctxInClassOrClassObj];
|
|
4008
4723
|
return this === contextRef;
|
|
4009
4724
|
}
|
|
4725
|
+
//#endregion
|
|
4726
|
+
//#region methods & getters / uri
|
|
4010
4727
|
get uri() {
|
|
4011
4728
|
const url = this.host
|
|
4012
4729
|
? new URL(this.host)
|
|
@@ -4015,6 +4732,7 @@ class EndpointContext {
|
|
|
4015
4732
|
: void 0;
|
|
4016
4733
|
return url;
|
|
4017
4734
|
}
|
|
4735
|
+
//#endregion
|
|
4018
4736
|
/**
|
|
4019
4737
|
* Port from uri as number
|
|
4020
4738
|
* @returns {Number | undefined}
|
|
@@ -4022,30 +4740,45 @@ class EndpointContext {
|
|
|
4022
4740
|
get port() {
|
|
4023
4741
|
return this.uri?.port ? Number(this.uri.port) : undefined;
|
|
4024
4742
|
}
|
|
4743
|
+
//#region methods & getters / is https server
|
|
4025
4744
|
get isHttpServer() {
|
|
4026
4745
|
return this.uri.protocol === 'https:';
|
|
4027
4746
|
}
|
|
4747
|
+
//#endregion
|
|
4748
|
+
//#region methods & getters / public assets
|
|
4028
4749
|
/**
|
|
4029
4750
|
* ipc/udp needs this
|
|
4030
4751
|
*/
|
|
4031
4752
|
get contextName() {
|
|
4032
4753
|
return this.config.contextName;
|
|
4033
4754
|
}
|
|
4755
|
+
//#endregion
|
|
4756
|
+
//#region methods & getters / public assets
|
|
4034
4757
|
get publicAssets() {
|
|
4035
4758
|
return this.config?.publicAssets || [];
|
|
4036
4759
|
}
|
|
4760
|
+
//#endregion
|
|
4761
|
+
//#region methods & getters / is production mode
|
|
4037
4762
|
get isProductionMode() {
|
|
4038
4763
|
return this.config.productionMode;
|
|
4039
4764
|
}
|
|
4765
|
+
//#endregion
|
|
4766
|
+
//#region methods & getters / remote host
|
|
4040
4767
|
get remoteHost() {
|
|
4041
4768
|
return this.config.remoteHost;
|
|
4042
4769
|
}
|
|
4770
|
+
//#endregion
|
|
4771
|
+
//#region methods & getters / host
|
|
4043
4772
|
get host() {
|
|
4044
4773
|
return this.config.host;
|
|
4045
4774
|
}
|
|
4775
|
+
//#endregion
|
|
4776
|
+
//#region methods & getters / host
|
|
4046
4777
|
get orgin() {
|
|
4047
4778
|
return this.uri?.origin;
|
|
4048
4779
|
}
|
|
4780
|
+
//#endregion
|
|
4781
|
+
//#region methods & getters / init subscribers
|
|
4049
4782
|
async initSubscribers() {
|
|
4050
4783
|
/* */
|
|
4051
4784
|
/* */
|
|
@@ -4065,6 +4798,8 @@ class EndpointContext {
|
|
|
4065
4798
|
/* */
|
|
4066
4799
|
return (void 0);
|
|
4067
4800
|
}
|
|
4801
|
+
//#endregion
|
|
4802
|
+
//#region methods & getters / init entities
|
|
4068
4803
|
async initEntities() {
|
|
4069
4804
|
/* */
|
|
4070
4805
|
/* */
|
|
@@ -4096,6 +4831,8 @@ class EndpointContext {
|
|
|
4096
4831
|
/* */
|
|
4097
4832
|
/* */
|
|
4098
4833
|
}
|
|
4834
|
+
//#endregion
|
|
4835
|
+
//#region methods & getters / destroy
|
|
4099
4836
|
async destroy() {
|
|
4100
4837
|
/* */
|
|
4101
4838
|
/* */
|
|
@@ -4114,6 +4851,8 @@ class EndpointContext {
|
|
|
4114
4851
|
/* */
|
|
4115
4852
|
return (void 0);
|
|
4116
4853
|
}
|
|
4854
|
+
//#endregion
|
|
4855
|
+
//#region methods & getters / init connection
|
|
4117
4856
|
async initDatabaseConnection() {
|
|
4118
4857
|
/* */
|
|
4119
4858
|
/* */
|
|
@@ -4212,17 +4951,21 @@ class EndpointContext {
|
|
|
4212
4951
|
/* */
|
|
4213
4952
|
return (void 0);
|
|
4214
4953
|
}
|
|
4954
|
+
//#endregion
|
|
4955
|
+
//#region methods & getters / initialize metadata
|
|
4215
4956
|
initControllers() {
|
|
4216
4957
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
4217
4958
|
return;
|
|
4218
4959
|
}
|
|
4219
4960
|
const allControllers = this.getClassFunByArr(Models.ClassType.CONTROLLER);
|
|
4961
|
+
// console.log('allControllers', allControllers)11
|
|
4220
4962
|
for (const controllerClassFn of allControllers) {
|
|
4221
4963
|
controllerClassFn[Symbols.classMethodsNames] =
|
|
4222
4964
|
ClassHelpers.getMethodsNames(controllerClassFn);
|
|
4223
4965
|
const configs = ClassHelpers.getControllerConfigs(controllerClassFn);
|
|
4966
|
+
// console.log(`Class config for ${ClassHelpers.getName(controllerClassFn)}`, configs)
|
|
4224
4967
|
const classConfig = configs[0];
|
|
4225
|
-
const parentscalculatedPath = _
|
|
4968
|
+
const parentscalculatedPath = _.slice(configs, 1)
|
|
4226
4969
|
.reverse()
|
|
4227
4970
|
.map(bc => {
|
|
4228
4971
|
if (TaonHelpers.isGoodPath(bc.path)) {
|
|
@@ -4240,13 +4983,13 @@ class EndpointContext {
|
|
|
4240
4983
|
.replace(/\/\//g, '/')
|
|
4241
4984
|
.split('/')
|
|
4242
4985
|
.reduce((acc, bc) => {
|
|
4243
|
-
return _
|
|
4986
|
+
return _.last(acc) === bc ? acc : [...acc, bc];
|
|
4244
4987
|
}, [])
|
|
4245
4988
|
.join('/');
|
|
4246
4989
|
}
|
|
4247
|
-
_
|
|
4990
|
+
_.slice(configs, 1).forEach(bc => {
|
|
4248
4991
|
const alreadyIs = classConfig.methods;
|
|
4249
|
-
const toMerge = _
|
|
4992
|
+
const toMerge = _.cloneDeep(bc.methods);
|
|
4250
4993
|
for (const key in toMerge) {
|
|
4251
4994
|
if (toMerge.hasOwnProperty(key) && !alreadyIs[key]) {
|
|
4252
4995
|
const element = toMerge[key];
|
|
@@ -4260,12 +5003,15 @@ class EndpointContext {
|
|
|
4260
5003
|
console.groupCollapsed(`[taon][express-server] routes [${classConfig.className}]`);
|
|
4261
5004
|
/* */
|
|
4262
5005
|
/* */
|
|
5006
|
+
// console.log('methods', classConfig.methods);
|
|
4263
5007
|
Object.keys(classConfig.methods).forEach(methodName => {
|
|
4264
5008
|
const methodConfig = classConfig.methods[methodName];
|
|
5009
|
+
// debugger
|
|
4265
5010
|
const type = methodConfig.type;
|
|
4266
5011
|
const expressPath = methodConfig.global
|
|
4267
5012
|
? `/${methodConfig.path?.replace(/\//, '')}`
|
|
4268
5013
|
: TaonHelpers.getExpressPath(classConfig, methodConfig);
|
|
5014
|
+
// console.log({ expressPath })
|
|
4269
5015
|
if (Helpers.isNode || Helpers.isWebSQL) {
|
|
4270
5016
|
/* */
|
|
4271
5017
|
/* */
|
|
@@ -4283,7 +5029,15 @@ class EndpointContext {
|
|
|
4283
5029
|
/* */
|
|
4284
5030
|
}
|
|
4285
5031
|
const shouldInitClient = Helpers.isBrowser || this.remoteHost || Helpers.isWebSQL;
|
|
5032
|
+
// console.log('shouldInitClient', shouldInitClient);
|
|
4286
5033
|
if (shouldInitClient) {
|
|
5034
|
+
// console.log(
|
|
5035
|
+
// 'initClient',
|
|
5036
|
+
// ClassHelpers.getFullInternalName(controllerClassFn),
|
|
5037
|
+
// type,
|
|
5038
|
+
// methodConfig,
|
|
5039
|
+
// expressPath,
|
|
5040
|
+
// );
|
|
4287
5041
|
this.initClient(controllerClassFn, type, methodConfig, expressPath);
|
|
4288
5042
|
}
|
|
4289
5043
|
});
|
|
@@ -4294,6 +5048,8 @@ class EndpointContext {
|
|
|
4294
5048
|
/* */
|
|
4295
5049
|
}
|
|
4296
5050
|
}
|
|
5051
|
+
//#endregion
|
|
5052
|
+
//#region methods & getters / write active routes
|
|
4297
5053
|
writeActiveRoutes() {
|
|
4298
5054
|
if (this.remoteHost ||
|
|
4299
5055
|
this.isRunOrRevertOnlyMigrationAppStart ||
|
|
@@ -4336,11 +5092,15 @@ class EndpointContext {
|
|
|
4336
5092
|
/* */
|
|
4337
5093
|
/* */
|
|
4338
5094
|
}
|
|
5095
|
+
//#endregion
|
|
5096
|
+
//#region methods & getters / middlewares
|
|
4339
5097
|
get middlewares() {
|
|
4340
5098
|
/* */
|
|
4341
5099
|
/* */
|
|
4342
5100
|
return (void 0);
|
|
4343
5101
|
}
|
|
5102
|
+
//#endregion
|
|
5103
|
+
//#region methods & getters / init middlewares
|
|
4344
5104
|
initMiddlewares() {
|
|
4345
5105
|
/* */
|
|
4346
5106
|
/* */
|
|
@@ -4445,7 +5205,12 @@ class EndpointContext {
|
|
|
4445
5205
|
/* */
|
|
4446
5206
|
/* */
|
|
4447
5207
|
}
|
|
4448
|
-
|
|
5208
|
+
//#endregion
|
|
5209
|
+
//#region methods & getters / init methods node
|
|
5210
|
+
initServer(
|
|
5211
|
+
//#region parameters
|
|
5212
|
+
type, methodConfig, classConfig, expressPath, target) {
|
|
5213
|
+
//#region resolve variables
|
|
4449
5214
|
/* */
|
|
4450
5215
|
/* */
|
|
4451
5216
|
/* */
|
|
@@ -4455,6 +5220,7 @@ class EndpointContext {
|
|
|
4455
5220
|
/* */
|
|
4456
5221
|
/* */
|
|
4457
5222
|
const url = this.uri;
|
|
5223
|
+
//#region get result
|
|
4458
5224
|
const getResult = async (resolvedParams, req, res) => {
|
|
4459
5225
|
const response = methodConfig.descriptor.value.apply(
|
|
4460
5226
|
/**
|
|
@@ -4468,11 +5234,14 @@ class EndpointContext {
|
|
|
4468
5234
|
let result = await getResponseValue(response, { req, res });
|
|
4469
5235
|
return result;
|
|
4470
5236
|
};
|
|
5237
|
+
//#endregion
|
|
4471
5238
|
url.pathname = url.pathname.replace(/\/$/, '');
|
|
4472
5239
|
expressPath = url.pathname.startsWith('/')
|
|
4473
5240
|
? `${url.pathname}${expressPath}`
|
|
4474
5241
|
: expressPath;
|
|
4475
5242
|
expressPath = expressPath.replace(/\/\//g, '/');
|
|
5243
|
+
// console.log(`BACKEND: expressPath: ${ expressPath } `)
|
|
5244
|
+
//#endregion
|
|
4476
5245
|
if (Helpers.isElectron) {
|
|
4477
5246
|
/* */
|
|
4478
5247
|
/* */
|
|
@@ -4497,12 +5266,14 @@ class EndpointContext {
|
|
|
4497
5266
|
/* */
|
|
4498
5267
|
}
|
|
4499
5268
|
if (!this.remoteHost) {
|
|
5269
|
+
//#region apply dummy websql express routers
|
|
4500
5270
|
/* */
|
|
4501
5271
|
/* */
|
|
4502
5272
|
/* */
|
|
4503
5273
|
/* */
|
|
4504
5274
|
/* */
|
|
4505
5275
|
/* */
|
|
5276
|
+
//#endregion
|
|
4506
5277
|
/* */
|
|
4507
5278
|
/* */
|
|
4508
5279
|
/* */
|
|
@@ -4723,12 +5494,19 @@ class EndpointContext {
|
|
|
4723
5494
|
method: methodConfig.type,
|
|
4724
5495
|
};
|
|
4725
5496
|
}
|
|
5497
|
+
//#endregion
|
|
5498
|
+
//#region methods & getters / init client
|
|
4726
5499
|
/**
|
|
4727
5500
|
* client can be browser or nodejs (when remote host)
|
|
4728
5501
|
*/
|
|
4729
|
-
initClient(
|
|
5502
|
+
initClient(
|
|
5503
|
+
//#region parameters
|
|
5504
|
+
target, type, methodConfig, expressPath) {
|
|
4730
5505
|
const ctx = this;
|
|
5506
|
+
// : { received: any; /* Rest<any, any> */ }
|
|
4731
5507
|
this.logHttp && console.log(`${type?.toUpperCase()} ${expressPath} `);
|
|
5508
|
+
// console.log('INITING', methodConfig); // TODO inject in static
|
|
5509
|
+
//#region resolve storage
|
|
4732
5510
|
let storage;
|
|
4733
5511
|
if (Helpers.isBrowser) {
|
|
4734
5512
|
storage = window;
|
|
@@ -4737,7 +5515,9 @@ class EndpointContext {
|
|
|
4737
5515
|
/* */
|
|
4738
5516
|
/* */
|
|
4739
5517
|
/* */
|
|
5518
|
+
//#endregion
|
|
4740
5519
|
const orgMethods = target.prototype[methodConfig.methodName];
|
|
5520
|
+
//#region handle electron ipc request
|
|
4741
5521
|
if (Helpers.isElectron) {
|
|
4742
5522
|
target.prototype[methodConfig.methodName] = function (...args) {
|
|
4743
5523
|
const received = new Promise(async (resolve, reject) => {
|
|
@@ -4754,7 +5534,7 @@ class EndpointContext {
|
|
|
4754
5534
|
method: methodConfig.type,
|
|
4755
5535
|
url: `${ctx.uri.origin}${'' // TODO express path
|
|
4756
5536
|
}${methodConfig.path} `,
|
|
4757
|
-
}, Helpers.isBlob(body) || _
|
|
5537
|
+
}, Helpers.isBlob(body) || _.isString(body)
|
|
4758
5538
|
? body
|
|
4759
5539
|
: JSON.stringify(body), RestHeaders.from(headers), void 0, () => body);
|
|
4760
5540
|
resolve(res);
|
|
@@ -4773,6 +5553,8 @@ class EndpointContext {
|
|
|
4773
5553
|
};
|
|
4774
5554
|
return;
|
|
4775
5555
|
}
|
|
5556
|
+
//#endregion
|
|
5557
|
+
//#region handling web sql request
|
|
4776
5558
|
/* */
|
|
4777
5559
|
/* */
|
|
4778
5560
|
/* */
|
|
@@ -4915,7 +5697,12 @@ class EndpointContext {
|
|
|
4915
5697
|
/* */
|
|
4916
5698
|
/* */
|
|
4917
5699
|
/* */
|
|
5700
|
+
//#endregion
|
|
5701
|
+
//#region handle normal request
|
|
4918
5702
|
target.prototype[methodConfig.methodName] = function (...args) {
|
|
5703
|
+
// console.log('[init method browser] FRONTEND expressPath', expressPath)
|
|
5704
|
+
// const productionMode = FrameworkContext.isProductionMode;
|
|
5705
|
+
//#region resolve frontend parameters
|
|
4919
5706
|
if (!storage[Symbols.old.ENDPOINT_META_CONFIG])
|
|
4920
5707
|
storage[Symbols.old.ENDPOINT_META_CONFIG] = {};
|
|
4921
5708
|
if (!storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.uri.href])
|
|
@@ -4980,12 +5767,13 @@ class EndpointContext {
|
|
|
4980
5767
|
if (mapping) {
|
|
4981
5768
|
rest.headers.set(Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
4982
5769
|
}
|
|
4983
|
-
queryParams = _
|
|
5770
|
+
queryParams = _.cloneDeep(param);
|
|
4984
5771
|
}
|
|
4985
5772
|
}
|
|
4986
5773
|
if (currentParam.paramType === 'Header') {
|
|
4987
5774
|
if (currentParam.paramName) {
|
|
4988
5775
|
if (currentParam.paramName === Symbols.old.MDC_KEY) {
|
|
5776
|
+
// parese MDC
|
|
4989
5777
|
rest.headers.set(currentParam.paramName, encodeURIComponent(JSON.stringify(param)));
|
|
4990
5778
|
}
|
|
4991
5779
|
else {
|
|
@@ -5006,14 +5794,14 @@ class EndpointContext {
|
|
|
5006
5794
|
if (ClassHelpers.getName(bodyObject) === 'FormData') {
|
|
5007
5795
|
throw new Error(`[taon - framework] Don use param names when posting / putting FormData.
|
|
5008
5796
|
Use this:
|
|
5009
|
-
|
|
5797
|
+
// ...
|
|
5010
5798
|
(@Taon.Http.Param.Body() formData: FormData) ...
|
|
5011
|
-
|
|
5799
|
+
// ...
|
|
5012
5800
|
|
|
5013
5801
|
instead
|
|
5014
|
-
|
|
5802
|
+
// ...
|
|
5015
5803
|
(@Taon.Http.Param.Body('${currentParam.paramName}') formData: FormData) ...
|
|
5016
|
-
|
|
5804
|
+
// ...
|
|
5017
5805
|
`);
|
|
5018
5806
|
}
|
|
5019
5807
|
const mapping = Mapping.decode(param, !ctx.isProductionMode);
|
|
@@ -5046,6 +5834,7 @@ instead
|
|
|
5046
5834
|
}));
|
|
5047
5835
|
rest.headers.set(Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, JSON10.stringify(circuralFromQueryParams));
|
|
5048
5836
|
}
|
|
5837
|
+
//#endregion
|
|
5049
5838
|
const httpResultObj = {
|
|
5050
5839
|
received: isWithBody
|
|
5051
5840
|
? rest.model(pathPrams)[method](bodyObject, [queryParams])
|
|
@@ -5053,12 +5842,13 @@ instead
|
|
|
5053
5842
|
};
|
|
5054
5843
|
return httpResultObj;
|
|
5055
5844
|
};
|
|
5845
|
+
//#endregion
|
|
5056
5846
|
}
|
|
5057
5847
|
}
|
|
5058
|
-
;
|
|
5059
|
-
({}); // @--end-of-file-for-module=taon lib/endpoint-context.ts
|
|
5060
5848
|
|
|
5849
|
+
//#endregion
|
|
5061
5850
|
const ENV$1 = Helpers.isBrowser ? window['ENV'] : global['ENV'];
|
|
5851
|
+
// @Injectable({ providedIn: 'root' }) TODO make it angular service
|
|
5062
5852
|
class TaonAdminService {
|
|
5063
5853
|
static get Instance() {
|
|
5064
5854
|
if (!this._instance) {
|
|
@@ -5066,7 +5856,12 @@ class TaonAdminService {
|
|
|
5066
5856
|
}
|
|
5067
5857
|
return this._instance;
|
|
5068
5858
|
}
|
|
5859
|
+
//#endregion
|
|
5860
|
+
//#endregion
|
|
5861
|
+
//#region constructor
|
|
5069
5862
|
constructor() {
|
|
5863
|
+
//#endregion
|
|
5864
|
+
//#region fields & getters
|
|
5070
5865
|
this.scrollableEnabled = false; // TOOD false by default
|
|
5071
5866
|
this.onEditMode = new Subject();
|
|
5072
5867
|
this.onEditMode$ = this.onEditMode.asObservable();
|
|
@@ -5074,10 +5869,15 @@ class TaonAdminService {
|
|
|
5074
5869
|
TaonAdminService._instance = this;
|
|
5075
5870
|
this.scrollableEnabled = !!ENV$1?.useGlobalNgxScrollbar;
|
|
5076
5871
|
}
|
|
5872
|
+
//#endregion
|
|
5873
|
+
//#region methods
|
|
5077
5874
|
setEditMode(value) {
|
|
5078
5875
|
this.onEditMode.next(value);
|
|
5079
5876
|
}
|
|
5080
5877
|
setKeepWebsqlDbDataAfterReload(value) {
|
|
5878
|
+
// if (value && !this.keepWebsqlDbDataAfterReload) {
|
|
5879
|
+
// this.firstTimeKeepWebsqlDbDataTrue = true;
|
|
5880
|
+
// }
|
|
5081
5881
|
this.keepWebsqlDbDataAfterReload = value;
|
|
5082
5882
|
}
|
|
5083
5883
|
hide() {
|
|
@@ -5106,9 +5906,12 @@ __decorate([
|
|
|
5106
5906
|
(Stor.property.in.localstorage.for(TaonAdminService).withDefaultValue(false)),
|
|
5107
5907
|
__metadata("design:type", Boolean)
|
|
5108
5908
|
], TaonAdminService.prototype, "keepWebsqlDbDataAfterReload", void 0);
|
|
5109
|
-
;
|
|
5110
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-admin-mode-configuration/taon-admin.service.ts
|
|
5111
5909
|
|
|
5910
|
+
//#region imports
|
|
5911
|
+
//#endregion
|
|
5912
|
+
// import { Symbols } from './symbols';
|
|
5913
|
+
// import { Taon } from 'taon/src';
|
|
5914
|
+
//#endregion
|
|
5112
5915
|
const createContextTemplate = (configFn) => {
|
|
5113
5916
|
return () => {
|
|
5114
5917
|
return createContext(configFn);
|
|
@@ -5118,29 +5921,52 @@ const createContext = (configFn) => {
|
|
|
5118
5921
|
let config = configFn(ENV$2);
|
|
5119
5922
|
const endpointContextRef = new EndpointContext(config, configFn);
|
|
5120
5923
|
const res = {
|
|
5924
|
+
//#region types
|
|
5121
5925
|
types: {
|
|
5926
|
+
//#region entites for
|
|
5927
|
+
// get entities() {
|
|
5928
|
+
// return config.entities;
|
|
5929
|
+
// },
|
|
5930
|
+
// entitiesFor(classInstace: BaseInjector) {
|
|
5931
|
+
// const ctx = classInstace.__endpoint_context__;
|
|
5932
|
+
// if (!entitiesCache[ctx.contextName]) {
|
|
5933
|
+
// entitiesCache[ctx.contextName] = {};
|
|
5934
|
+
// for (const entityClassName of Object.keys(config.entities)) {
|
|
5935
|
+
// entitiesCache[ctx.contextName][entityClassName] =
|
|
5936
|
+
// config.entities[entityClassName][
|
|
5937
|
+
// Taon.symbols.orignalClassClonesObj
|
|
5938
|
+
// ][ctx.contextName];
|
|
5939
|
+
// }
|
|
5940
|
+
// }
|
|
5941
|
+
// return entitiesCache[ctx.contextName] as typeof config.entities;
|
|
5942
|
+
// },
|
|
5943
|
+
//#endregion
|
|
5122
5944
|
get controllers() {
|
|
5123
|
-
return config.controllers;
|
|
5945
|
+
return config.controllers; // TODO QUICK_FIX new typescript generated wrong types
|
|
5124
5946
|
},
|
|
5125
5947
|
get repositories() {
|
|
5126
|
-
return config.repositories;
|
|
5948
|
+
return config.repositories; // TODO QUICK_FIX new typescript generated wrong types
|
|
5127
5949
|
},
|
|
5128
5950
|
get providers() {
|
|
5129
|
-
return config.providers;
|
|
5951
|
+
return config.providers; // TODO QUICK_FIX new typescript generated wrong types
|
|
5130
5952
|
},
|
|
5131
5953
|
get subscribers() {
|
|
5132
|
-
return config.subscribers;
|
|
5954
|
+
return config.subscribers; // TODO QUICK_FIX new typescript generated wrong types
|
|
5133
5955
|
},
|
|
5134
5956
|
get migrations() {
|
|
5135
|
-
return config.migrations;
|
|
5957
|
+
return config.migrations; // TODO QUICK_FIX new typescript generated wrong types
|
|
5136
5958
|
},
|
|
5137
5959
|
},
|
|
5960
|
+
//#endregion
|
|
5961
|
+
//#region contexts
|
|
5138
5962
|
get contexts() {
|
|
5139
|
-
return config.contexts;
|
|
5963
|
+
return config.contexts; // TODO QUICK_FIX new typescript generated wrong types
|
|
5140
5964
|
},
|
|
5141
5965
|
get contextName() {
|
|
5142
5966
|
return config.contextName;
|
|
5143
5967
|
},
|
|
5968
|
+
//#endregion
|
|
5969
|
+
//#region context
|
|
5144
5970
|
/**
|
|
5145
5971
|
* @deprecated
|
|
5146
5972
|
* - get reference to internal context
|
|
@@ -5166,13 +5992,29 @@ const createContext = (configFn) => {
|
|
|
5166
5992
|
getClass(ctor) {
|
|
5167
5993
|
const classFun = endpointContextRef.getClassFunByClass(ctor);
|
|
5168
5994
|
return classFun;
|
|
5995
|
+
//#region old
|
|
5996
|
+
// TODO hmmmm for now context for controller inside api service
|
|
5997
|
+
// const allContexts = Object.values(classFun[Symbols.orignalClassClonesObj] || {}).map(classFn => {
|
|
5998
|
+
// return {
|
|
5999
|
+
// ctx: classFn[Symbols.ctxInClassOrClassObj] as EndpointContext,
|
|
6000
|
+
// classFn,
|
|
6001
|
+
// }
|
|
6002
|
+
// })
|
|
6003
|
+
// const activeContext = allContexts.find(c => c.ctx.inited);
|
|
6004
|
+
// debugger
|
|
6005
|
+
// console.log('activeContext', activeContext.ctx.contextName);
|
|
6006
|
+
// return activeContext.ctx.getClassFunByClass(ctor) as any;
|
|
6007
|
+
//#endregion
|
|
5169
6008
|
},
|
|
6009
|
+
//#endregion
|
|
6010
|
+
//#region initialize
|
|
5170
6011
|
/**
|
|
5171
6012
|
* - create controller instances for context
|
|
5172
6013
|
* - init database (if enable) + migation scripts
|
|
5173
6014
|
*/
|
|
5174
6015
|
initialize: async (overrideOptions) => {
|
|
5175
6016
|
return await new Promise(async (resolve, reject) => {
|
|
6017
|
+
//#region init in set timeout
|
|
5176
6018
|
setTimeout(async () => {
|
|
5177
6019
|
await endpointContextRef.init({
|
|
5178
6020
|
...overrideOptions,
|
|
@@ -5184,14 +6026,21 @@ const createContext = (configFn) => {
|
|
|
5184
6026
|
await endpointContextRef.initSubscribers();
|
|
5185
6027
|
await endpointContextRef.initDatabaseConnection();
|
|
5186
6028
|
await endpointContextRef.dbMigrations.ensureMigrationTableExists();
|
|
6029
|
+
// console.log(
|
|
6030
|
+
// 'connection subscribers',
|
|
6031
|
+
// endpointContextRef?.connection?.subscribers,
|
|
6032
|
+
// );
|
|
6033
|
+
// debugger;
|
|
5187
6034
|
endpointContextRef.initControllers();
|
|
5188
6035
|
endpointContextRef.startServer();
|
|
5189
6036
|
/* */
|
|
5190
6037
|
/* */
|
|
5191
6038
|
await endpointContextRef.initClasses();
|
|
5192
6039
|
let keepWebsqlDbDataAfterReload = false;
|
|
6040
|
+
//#region @browser
|
|
5193
6041
|
keepWebsqlDbDataAfterReload =
|
|
5194
6042
|
TaonAdminService.Instance?.keepWebsqlDbDataAfterReload;
|
|
6043
|
+
//#endregion
|
|
5195
6044
|
if (!Helpers.isNode && keepWebsqlDbDataAfterReload) {
|
|
5196
6045
|
!UtilsOs.isRunningInCliMode() &&
|
|
5197
6046
|
Helpers.info(`[taon] Keeping websql data after reload ` +
|
|
@@ -5203,6 +6052,19 @@ const createContext = (configFn) => {
|
|
|
5203
6052
|
`(context=${endpointContextRef.contextName}).`);
|
|
5204
6053
|
await endpointContextRef.reinitControllers();
|
|
5205
6054
|
}
|
|
6055
|
+
//#region TODO this may be usefull but for now
|
|
6056
|
+
// 2 separate contexts are fine
|
|
6057
|
+
// const shouldStartRemoteHost = endpointContextRef.mode !== 'remote-backend(tcp+udp)';
|
|
6058
|
+
// if(shouldStartRemoteHost) {
|
|
6059
|
+
// const endpointContextRemoteHostRef = new EndpointContext(config, configFn);
|
|
6060
|
+
// await endpointContextRemoteHostRef.init({
|
|
6061
|
+
// overrideRemoteHost: endpointContextRef.host,
|
|
6062
|
+
// overrideHost: null,
|
|
6063
|
+
// });
|
|
6064
|
+
// endpointContextRemoteHostRef.initMetadata();
|
|
6065
|
+
// endpointContextRef.__contextForControllerInstanceAccess = endpointContextRemoteHostRef;
|
|
6066
|
+
// }
|
|
6067
|
+
//#endregion
|
|
5206
6068
|
if (endpointContextRef.onlyMigrationRun) {
|
|
5207
6069
|
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
5208
6070
|
}
|
|
@@ -5214,6 +6076,7 @@ const createContext = (configFn) => {
|
|
|
5214
6076
|
}
|
|
5215
6077
|
resolve(endpointContextRef);
|
|
5216
6078
|
});
|
|
6079
|
+
//#endregion
|
|
5217
6080
|
});
|
|
5218
6081
|
},
|
|
5219
6082
|
/**
|
|
@@ -5233,8 +6096,7 @@ const createContext = (configFn) => {
|
|
|
5233
6096
|
};
|
|
5234
6097
|
return res;
|
|
5235
6098
|
};
|
|
5236
|
-
|
|
5237
|
-
({}); // @--end-of-file-for-module=taon lib/create-context.ts
|
|
6099
|
+
//#endregion
|
|
5238
6100
|
|
|
5239
6101
|
const BaseContext = createContext(() => ({
|
|
5240
6102
|
contextName: 'BaseContext',
|
|
@@ -5244,8 +6106,6 @@ const BaseContext = createContext(() => ({
|
|
|
5244
6106
|
BaseRepository,
|
|
5245
6107
|
},
|
|
5246
6108
|
}));
|
|
5247
|
-
;
|
|
5248
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base-context.ts
|
|
5249
6109
|
|
|
5250
6110
|
var baseContext = /*#__PURE__*/Object.freeze({
|
|
5251
6111
|
__proto__: null,
|
|
@@ -5264,8 +6124,6 @@ function TaonSubscriber(options) {
|
|
|
5264
6124
|
}
|
|
5265
6125
|
class TaonSubscriberOptions extends Models.DecoratorAbstractOpt {
|
|
5266
6126
|
}
|
|
5267
|
-
;
|
|
5268
|
-
({}); // @--end-of-file-for-module=taon lib/decorators/classes/subscriber-decorator.ts
|
|
5269
6127
|
|
|
5270
6128
|
let BaseSubscriberForEntity = class BaseSubscriberForEntity extends BaseInjector {
|
|
5271
6129
|
/**
|
|
@@ -5279,6 +6137,7 @@ let BaseSubscriberForEntity = class BaseSubscriberForEntity extends BaseInjector
|
|
|
5279
6137
|
* Called before query execution.
|
|
5280
6138
|
*/
|
|
5281
6139
|
beforeQuery(event) {
|
|
6140
|
+
// BeforeQueryEvent<any>
|
|
5282
6141
|
this.ctx.logDb &&
|
|
5283
6142
|
console.log(`BEFORE QUERY: `, event.query);
|
|
5284
6143
|
}
|
|
@@ -5286,6 +6145,7 @@ let BaseSubscriberForEntity = class BaseSubscriberForEntity extends BaseInjector
|
|
|
5286
6145
|
* Called after query execution.
|
|
5287
6146
|
*/
|
|
5288
6147
|
afterQuery(event) {
|
|
6148
|
+
// AfterQueryEvent<any>
|
|
5289
6149
|
this.ctx.logDb &&
|
|
5290
6150
|
console.log(`AFTER QUERY: `, event.query);
|
|
5291
6151
|
}
|
|
@@ -5407,8 +6267,6 @@ BaseSubscriberForEntity = __decorate([
|
|
|
5407
6267
|
className: 'BaseSubscriberForEntity',
|
|
5408
6268
|
})
|
|
5409
6269
|
], BaseSubscriberForEntity);
|
|
5410
|
-
;
|
|
5411
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base-subscriber-for-entity.ts
|
|
5412
6270
|
|
|
5413
6271
|
class BaseMigration extends BaseInjector {
|
|
5414
6272
|
/**
|
|
@@ -5418,7 +6276,7 @@ class BaseMigration extends BaseInjector {
|
|
|
5418
6276
|
return true;
|
|
5419
6277
|
}
|
|
5420
6278
|
getDescription() {
|
|
5421
|
-
return _
|
|
6279
|
+
return _.startCase(ClassHelpers.getName(this));
|
|
5422
6280
|
}
|
|
5423
6281
|
async up(queryRunner) {
|
|
5424
6282
|
console.log(`[BaseMigration] Running migration UP "${ClassHelpers.getName(this)}"`);
|
|
@@ -5427,8 +6285,6 @@ class BaseMigration extends BaseInjector {
|
|
|
5427
6285
|
console.log(`[BaseMigration] Running migration DOWN "${ClassHelpers.getName(this)}"`);
|
|
5428
6286
|
}
|
|
5429
6287
|
}
|
|
5430
|
-
;
|
|
5431
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base-migration.ts
|
|
5432
6288
|
|
|
5433
6289
|
var Base;
|
|
5434
6290
|
(function (Base) {
|
|
@@ -5443,8 +6299,6 @@ var Base;
|
|
|
5443
6299
|
Base.Migration = BaseMigration;
|
|
5444
6300
|
Base.Context = BaseContext;
|
|
5445
6301
|
})(Base || (Base = {}));
|
|
5446
|
-
;
|
|
5447
|
-
({}); // @--end-of-file-for-module=taon lib/base-classes/base.ts
|
|
5448
6302
|
|
|
5449
6303
|
/* */
|
|
5450
6304
|
/* */
|
|
@@ -5456,7 +6310,8 @@ function TaonEntity(options) {
|
|
|
5456
6310
|
options = options || {};
|
|
5457
6311
|
options.uniqueKeyProp = options.uniqueKeyProp || 'id';
|
|
5458
6312
|
ClassHelpers.setName(constructor, options?.className);
|
|
5459
|
-
Mapping.DefaultModelWithMapping(options?.defaultModelValues || {}, _
|
|
6313
|
+
Mapping.DefaultModelWithMapping(options?.defaultModelValues || {}, _.merge(options?.defaultModelMapping || {}, (options?.defaultModelMappingDeep || {})))(constructor);
|
|
6314
|
+
// TODO when entit metadata generator read use this
|
|
5460
6315
|
Mapping.DefaultModelWithMapping(void 0, {})(constructor);
|
|
5461
6316
|
Reflect.defineMetadata(Symbols.metadata.options.entity, options, constructor);
|
|
5462
6317
|
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
@@ -5467,8 +6322,6 @@ function TaonEntity(options) {
|
|
|
5467
6322
|
}
|
|
5468
6323
|
class TaonEntityOptions extends Models.DecoratorAbstractOpt {
|
|
5469
6324
|
}
|
|
5470
|
-
;
|
|
5471
|
-
({}); // @--end-of-file-for-module=taon lib/decorators/classes/entity-decorator.ts
|
|
5472
6325
|
|
|
5473
6326
|
/**
|
|
5474
6327
|
* Provider decorator
|
|
@@ -5482,8 +6335,6 @@ function TaonProvider(options) {
|
|
|
5482
6335
|
}
|
|
5483
6336
|
class TaonProviderOptions extends Models.DecoratorAbstractOpt {
|
|
5484
6337
|
}
|
|
5485
|
-
;
|
|
5486
|
-
({}); // @--end-of-file-for-module=taon lib/decorators/classes/provider-decorator.ts
|
|
5487
6338
|
|
|
5488
6339
|
/**
|
|
5489
6340
|
* Migration decorator
|
|
@@ -5497,8 +6348,6 @@ function TaonMigration(options) {
|
|
|
5497
6348
|
}
|
|
5498
6349
|
class TaonMigrationOptions extends Models.DecoratorAbstractOpt {
|
|
5499
6350
|
}
|
|
5500
|
-
;
|
|
5501
|
-
({}); // @--end-of-file-for-module=taon lib/decorators/classes/migration-decorator.ts
|
|
5502
6351
|
|
|
5503
6352
|
const inject = (entity) => {
|
|
5504
6353
|
return new Proxy({}, {
|
|
@@ -5511,6 +6360,7 @@ const inject = (entity) => {
|
|
|
5511
6360
|
const resultContext = contextFromClass;
|
|
5512
6361
|
if (resultContext) {
|
|
5513
6362
|
let instance = resultContext.inject(ctor);
|
|
6363
|
+
// console.log('instance', instance);
|
|
5514
6364
|
if (propName === 'getOriginalPrototype') {
|
|
5515
6365
|
return () => Object.getPrototypeOf(instance);
|
|
5516
6366
|
}
|
|
@@ -5522,17 +6372,69 @@ const inject = (entity) => {
|
|
|
5522
6372
|
const methodOrProperty = isMethods
|
|
5523
6373
|
? instance[propName].bind(instance)
|
|
5524
6374
|
: instance[propName];
|
|
6375
|
+
// console.log(
|
|
6376
|
+
// `methodOrProperty from proxy ${propName?.toString()} = isMethods:${isMethods}`,
|
|
6377
|
+
// methods,
|
|
6378
|
+
// );
|
|
5525
6379
|
return methodOrProperty;
|
|
5526
6380
|
}
|
|
5527
|
-
return inject$1(ctor)[propName];
|
|
5528
6381
|
},
|
|
5529
6382
|
});
|
|
5530
6383
|
};
|
|
6384
|
+
// export const injectController = inject;
|
|
6385
|
+
// export type SubscriptionEvent<T> = {
|
|
6386
|
+
// name: keyof T;
|
|
6387
|
+
// data: any;
|
|
6388
|
+
// };
|
|
5531
6389
|
/**
|
|
5532
6390
|
* TODO
|
|
5533
6391
|
*/
|
|
5534
|
-
|
|
5535
|
-
(
|
|
6392
|
+
// export const injectEntityEvents = <T>(
|
|
6393
|
+
// subscriberClassResolveFn: () => new (...args: any[]) => T,
|
|
6394
|
+
// eventName?: keyof Omit<EntitySubscriberInterface,'listenTo'> ,
|
|
6395
|
+
// ): Observable<SubscriptionEvent<T>> => {
|
|
6396
|
+
// const eventsSrc = new Subject<SubscriptionEvent<T>>();
|
|
6397
|
+
// const obs = eventsSrc.asObservable();
|
|
6398
|
+
// let isFirstSubscription = true;
|
|
6399
|
+
// const proxyObservable = new Proxy(obs, {
|
|
6400
|
+
// get(target, prop, receiver) {
|
|
6401
|
+
// if (prop === 'subscribe') {
|
|
6402
|
+
// return (...args: any[]) => {
|
|
6403
|
+
// if (isFirstSubscription) {
|
|
6404
|
+
// isFirstSubscription = false;
|
|
6405
|
+
// const subscriberClassFN: typeof BaseClass =
|
|
6406
|
+
// subscriberClassResolveFn() as any;
|
|
6407
|
+
// const ctx = subscriberClassFN[
|
|
6408
|
+
// Symbols.ctxInClassOrClassObj
|
|
6409
|
+
// ] as EndpointContext;
|
|
6410
|
+
// if (!ctx) {
|
|
6411
|
+
// throw new Error(
|
|
6412
|
+
// `You are trying to inject class without context. Use context like this:
|
|
6413
|
+
// class MyClassSubscriber extends BaseSubscriber {
|
|
6414
|
+
// ${eventName as any}() {
|
|
6415
|
+
// \/\/ your code here
|
|
6416
|
+
// }
|
|
6417
|
+
// }
|
|
6418
|
+
// Taon.injectSubscriberEvents( MyContext.getInstance(()=> MyClassSubscriber), '${eventName as any}' )
|
|
6419
|
+
// `,
|
|
6420
|
+
// );
|
|
6421
|
+
// }
|
|
6422
|
+
// const subscriberInstance = ctx.getInstanceBy(subscriberClassFN);
|
|
6423
|
+
// // subscriberInstance TODO @LAST subscriber event from instance
|
|
6424
|
+
// // const entity = subscriberClassFN.prototype.listenTo();
|
|
6425
|
+
// console.log('First subscription, you can access arguments here:', {
|
|
6426
|
+
// subscriberClassFN,
|
|
6427
|
+
// eventName,
|
|
6428
|
+
// });
|
|
6429
|
+
// }
|
|
6430
|
+
// return target.subscribe(...args);
|
|
6431
|
+
// };
|
|
6432
|
+
// }
|
|
6433
|
+
// return Reflect.get(target, prop, receiver);
|
|
6434
|
+
// },
|
|
6435
|
+
// });
|
|
6436
|
+
// return proxyObservable as Observable<SubscriptionEvent<T>>;
|
|
6437
|
+
// };
|
|
5536
6438
|
|
|
5537
6439
|
const log$1 = Log.create(`[taon-helpers] long-press`, Level.__NOTHING);
|
|
5538
6440
|
class TaonLongPress {
|
|
@@ -5544,7 +6446,7 @@ class TaonLongPress {
|
|
|
5544
6446
|
this.mouseX = 0;
|
|
5545
6447
|
this.mouseY = 0;
|
|
5546
6448
|
this.allowTrigger = false;
|
|
5547
|
-
this.triggerEnd = _
|
|
6449
|
+
this.triggerEnd = _.debounce(() => {
|
|
5548
6450
|
this.endPress();
|
|
5549
6451
|
}, 500);
|
|
5550
6452
|
}
|
|
@@ -5555,6 +6457,7 @@ class TaonLongPress {
|
|
|
5555
6457
|
return this.longPressing;
|
|
5556
6458
|
}
|
|
5557
6459
|
onMouseDown(event) {
|
|
6460
|
+
// don't do right/middle clicks
|
|
5558
6461
|
log$1.d(`MOUSE DOWN `);
|
|
5559
6462
|
if (event.which !== 1)
|
|
5560
6463
|
return;
|
|
@@ -5641,8 +6544,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
5641
6544
|
type: HostListener,
|
|
5642
6545
|
args: ['mouseup']
|
|
5643
6546
|
}] } });
|
|
5644
|
-
;
|
|
5645
|
-
({}); // @--end-of-file-for-module=taon lib/ui/directives/taon-long-press.directive.ts
|
|
5646
6547
|
|
|
5647
6548
|
class TaonInjectHTMLDirective {
|
|
5648
6549
|
set taonInjectHTML(content) {
|
|
@@ -5663,15 +6564,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
5663
6564
|
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { taonInjectHTML: [{
|
|
5664
6565
|
type: Input
|
|
5665
6566
|
}] } });
|
|
5666
|
-
;
|
|
5667
|
-
({}); // @--end-of-file-for-module=taon lib/ui/directives/taon-inject-html.directive.ts
|
|
5668
6567
|
|
|
5669
|
-
/* */
|
|
5670
|
-
/* */
|
|
5671
|
-
/* */
|
|
5672
|
-
/* */
|
|
5673
|
-
/* */
|
|
5674
|
-
/* */
|
|
5675
6568
|
class SafePipe {
|
|
5676
6569
|
constructor(sanitizer) {
|
|
5677
6570
|
this.sanitizer = sanitizer;
|
|
@@ -5702,12 +6595,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
5702
6595
|
standalone: true,
|
|
5703
6596
|
}]
|
|
5704
6597
|
}], ctorParameters: () => [{ type: i1.DomSanitizer }] });
|
|
5705
|
-
;
|
|
5706
|
-
({}); // @--end-of-file-for-module=taon lib/ui/directives/safe.pipe.ts
|
|
5707
6598
|
|
|
5708
|
-
|
|
5709
|
-
|
|
6599
|
+
//#region @browser
|
|
6600
|
+
//#endregion
|
|
5710
6601
|
|
|
6602
|
+
//#region @browser
|
|
5711
6603
|
class TaonFullMaterialModule {
|
|
5712
6604
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: TaonFullMaterialModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
5713
6605
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: TaonFullMaterialModule, exports: [A11yModule,
|
|
@@ -5841,9 +6733,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
5841
6733
|
],
|
|
5842
6734
|
}]
|
|
5843
6735
|
}] });
|
|
5844
|
-
;
|
|
5845
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-full-material.module.ts
|
|
5846
6736
|
|
|
6737
|
+
//#region @browser
|
|
5847
6738
|
class TaonGithubForkMeCornerComponent {
|
|
5848
6739
|
constructor() {
|
|
5849
6740
|
this.url = 'https://github.com';
|
|
@@ -5857,9 +6748,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
5857
6748
|
}], propDecorators: { url: [{
|
|
5858
6749
|
type: Input
|
|
5859
6750
|
}] } });
|
|
5860
|
-
;
|
|
5861
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.ts
|
|
5862
6751
|
|
|
6752
|
+
//#region @browser
|
|
5863
6753
|
class TaonGithubForkMeCornerModule {
|
|
5864
6754
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: TaonGithubForkMeCornerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
5865
6755
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: TaonGithubForkMeCornerModule, declarations: [TaonGithubForkMeCornerComponent], imports: [CommonModule], exports: [TaonGithubForkMeCornerComponent] }); }
|
|
@@ -5874,20 +6764,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
5874
6764
|
providers: [],
|
|
5875
6765
|
}]
|
|
5876
6766
|
}] });
|
|
5877
|
-
;
|
|
5878
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.ts
|
|
5879
6767
|
|
|
5880
|
-
|
|
5881
|
-
|
|
6768
|
+
//#region @browser
|
|
6769
|
+
//#endregion
|
|
5882
6770
|
|
|
5883
|
-
|
|
5884
|
-
/* */
|
|
6771
|
+
//#region @browser
|
|
5885
6772
|
class TaonNotificationsService {
|
|
5886
6773
|
constructor(toast) {
|
|
5887
6774
|
this.toast = toast;
|
|
5888
6775
|
}
|
|
5889
6776
|
options(type, options) {
|
|
5890
|
-
if (_
|
|
6777
|
+
if (_.isString(options)) {
|
|
5891
6778
|
options = {
|
|
5892
6779
|
// @ts-ignore
|
|
5893
6780
|
title: options,
|
|
@@ -5920,9 +6807,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
5920
6807
|
providedIn: 'root',
|
|
5921
6808
|
}]
|
|
5922
6809
|
}], ctorParameters: () => [{ type: i1$1.HotToastService }] });
|
|
5923
|
-
;
|
|
5924
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-notifications/taon-notifications.service.ts
|
|
5925
6810
|
|
|
6811
|
+
//#region @browser
|
|
5926
6812
|
class TaonNotificationsComponent {
|
|
5927
6813
|
constructor(notification) {
|
|
5928
6814
|
this.notification = notification;
|
|
@@ -5931,6 +6817,10 @@ class TaonNotificationsComponent {
|
|
|
5931
6817
|
init(subscribtionsArray, template, callback) {
|
|
5932
6818
|
subscribtionsArray.push(Resource.listenErrors.subscribe(err => {
|
|
5933
6819
|
this.notification.error(err.msg);
|
|
6820
|
+
// subscribtionsArray.push(notify.onTap.subscribe(() => {
|
|
6821
|
+
// callback(err);
|
|
6822
|
+
// this.modal.open(template);
|
|
6823
|
+
// }) as any);
|
|
5934
6824
|
}));
|
|
5935
6825
|
}
|
|
5936
6826
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: TaonNotificationsComponent, deps: [{ token: TaonNotificationsService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
@@ -5940,14 +6830,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
5940
6830
|
type: Component,
|
|
5941
6831
|
args: [{ selector: 'taon-notifications', standalone: false, template: "<!-- <p>\n notyfications works!\n</p> -->\n", styles: [":host{position:absolute;width:0px;height:0px}\n"] }]
|
|
5942
6832
|
}], ctorParameters: () => [{ type: TaonNotificationsService }] });
|
|
5943
|
-
;
|
|
5944
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-notifications/taon-notifications.component.ts
|
|
5945
6833
|
|
|
5946
6834
|
class TaonNotificationOptions {
|
|
5947
6835
|
}
|
|
5948
|
-
|
|
5949
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-notifications/taon-notifications.models.ts
|
|
6836
|
+
//#endregion
|
|
5950
6837
|
|
|
6838
|
+
//#region @browser
|
|
5951
6839
|
class TaonNotificationsModule {
|
|
5952
6840
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: TaonNotificationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
5953
6841
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: TaonNotificationsModule, declarations: [TaonNotificationsComponent], exports: [TaonNotificationsComponent] }); }
|
|
@@ -5956,17 +6844,21 @@ class TaonNotificationsModule {
|
|
|
5956
6844
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: TaonNotificationsModule, decorators: [{
|
|
5957
6845
|
type: NgModule,
|
|
5958
6846
|
args: [{
|
|
5959
|
-
imports: [
|
|
6847
|
+
imports: [
|
|
6848
|
+
// CommonModule,
|
|
6849
|
+
// BrowserAnimationsModule, // required animations module
|
|
6850
|
+
// HotToastModule.forRoot({
|
|
6851
|
+
// position: 'top-right',
|
|
6852
|
+
// }),
|
|
6853
|
+
],
|
|
5960
6854
|
exports: [TaonNotificationsComponent],
|
|
5961
6855
|
declarations: [TaonNotificationsComponent],
|
|
5962
6856
|
providers: [TaonNotificationsService],
|
|
5963
6857
|
}]
|
|
5964
6858
|
}] });
|
|
5965
|
-
;
|
|
5966
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-notifications/taon-notifications.module.ts
|
|
5967
6859
|
|
|
5968
|
-
|
|
5969
|
-
|
|
6860
|
+
//#region @browser
|
|
6861
|
+
//#endregion
|
|
5970
6862
|
|
|
5971
6863
|
class TaonSessionPasscodeComponent {
|
|
5972
6864
|
constructor(element, domSanitizer, cdr) {
|
|
@@ -5989,6 +6881,13 @@ class TaonSessionPasscodeComponent {
|
|
|
5989
6881
|
|
|
5990
6882
|
`;
|
|
5991
6883
|
}
|
|
6884
|
+
// console.log({
|
|
6885
|
+
// 'lastPasscode': this.lastPasscode,
|
|
6886
|
+
// 'current passcode': this.passcode,
|
|
6887
|
+
// 'current message': this.message,
|
|
6888
|
+
// })
|
|
6889
|
+
// this.width = window.innerWidth;
|
|
6890
|
+
// this.height = window.innerHeight;
|
|
5992
6891
|
this.safeMessage = this.domSanitizer.bypassSecurityTrustHtml(this.message);
|
|
5993
6892
|
if (this.lastPasscode?.toString() === this.passcode?.toString()) {
|
|
5994
6893
|
this.hide();
|
|
@@ -6060,14 +6959,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
6060
6959
|
type: HostBinding,
|
|
6061
6960
|
args: ['style.display']
|
|
6062
6961
|
}] } });
|
|
6063
|
-
;
|
|
6064
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-session-passcode/taon-session-passcode.component.ts
|
|
6065
6962
|
|
|
6066
|
-
|
|
6067
|
-
|
|
6963
|
+
//#region @browser
|
|
6964
|
+
//#endregion
|
|
6068
6965
|
|
|
6966
|
+
//#region @browser
|
|
6967
|
+
// import { Models } from 'tnp-models';
|
|
6968
|
+
// import type { TaonAdmin } from '../taon-admin-mode-configuration';
|
|
6069
6969
|
const calculatePercentage = (loaded, total) => Math.floor(loaded * 1.0) / total;
|
|
6070
6970
|
class TaonProgressBarComponent {
|
|
6971
|
+
// options: NgProgressConfig = _.merge(
|
|
6972
|
+
// {
|
|
6973
|
+
// min: 8,
|
|
6974
|
+
// max: 100,
|
|
6975
|
+
// speed: 200,
|
|
6976
|
+
// trickleSpeed: 300,
|
|
6977
|
+
// debounceTime: 0,
|
|
6978
|
+
// ease: 'linear',
|
|
6979
|
+
// spinnerPosition: 'right',
|
|
6980
|
+
// direction: 'ltr+',
|
|
6981
|
+
// color: 'gray',
|
|
6982
|
+
// fixed: true,
|
|
6983
|
+
// meteor: true,
|
|
6984
|
+
// spinner: true,
|
|
6985
|
+
// thick: false,
|
|
6986
|
+
// },
|
|
6987
|
+
// _.get(ENV, `plugins['ngx-progressbar']`),
|
|
6988
|
+
// );
|
|
6071
6989
|
constructor() {
|
|
6072
6990
|
this.handlers = [];
|
|
6073
6991
|
}
|
|
@@ -6076,9 +6994,48 @@ class TaonProgressBarComponent {
|
|
|
6076
6994
|
this.handlers.forEach(h => h.unsubscribe());
|
|
6077
6995
|
}
|
|
6078
6996
|
ngAfterViewInit() {
|
|
6997
|
+
// this.labProgress.set(20)
|
|
6079
6998
|
this.loadProgressBar(void 0, axios);
|
|
6080
6999
|
}
|
|
6081
7000
|
loadProgressBar(config, instance = axios) {
|
|
7001
|
+
// let requestsCounter = 0;
|
|
7002
|
+
// const setupStartProgress = () => {
|
|
7003
|
+
// instance.interceptors.request.use(config => {
|
|
7004
|
+
// requestsCounter++;
|
|
7005
|
+
// this.labProgress.start();
|
|
7006
|
+
// return config;
|
|
7007
|
+
// });
|
|
7008
|
+
// };
|
|
7009
|
+
// const setupUpdateProgress = () => {
|
|
7010
|
+
// const update = e => {
|
|
7011
|
+
// // NProgress.inc(calculatePercentage(e.loaded, e.total))
|
|
7012
|
+
// const percentage = calculatePercentage(e.loaded, e.total) * 100;
|
|
7013
|
+
// // console.log(`loaded: ${e.loaded}, total: ${e.total} , pecent: ${percentage}`)
|
|
7014
|
+
// this.labProgress.inc(percentage);
|
|
7015
|
+
// };
|
|
7016
|
+
// instance.defaults.onDownloadProgress = update;
|
|
7017
|
+
// instance.defaults.onUploadProgress = update;
|
|
7018
|
+
// };
|
|
7019
|
+
// const setupStopProgress = () => {
|
|
7020
|
+
// const responseFunc = response => {
|
|
7021
|
+
// if (--requestsCounter === 0) {
|
|
7022
|
+
// this.labProgress.complete();
|
|
7023
|
+
// // NProgress.done()
|
|
7024
|
+
// }
|
|
7025
|
+
// return response;
|
|
7026
|
+
// };
|
|
7027
|
+
// const errorFunc = error => {
|
|
7028
|
+
// if (--requestsCounter === 0) {
|
|
7029
|
+
// this.labProgress.complete();
|
|
7030
|
+
// // NProgress.done()
|
|
7031
|
+
// }
|
|
7032
|
+
// return Promise.reject(error);
|
|
7033
|
+
// };
|
|
7034
|
+
// instance.interceptors.response.use(responseFunc, errorFunc);
|
|
7035
|
+
// };
|
|
7036
|
+
// setupStartProgress();
|
|
7037
|
+
// setupUpdateProgress();
|
|
7038
|
+
// setupStopProgress();
|
|
6082
7039
|
/* */
|
|
6083
7040
|
/* */
|
|
6084
7041
|
/* */
|
|
@@ -6140,9 +7097,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
6140
7097
|
}], isDesktop: [{
|
|
6141
7098
|
type: Input
|
|
6142
7099
|
}] } });
|
|
6143
|
-
;
|
|
6144
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-progress-bar/taon-progress-bar.component.ts
|
|
6145
7100
|
|
|
7101
|
+
//#region @browser
|
|
7102
|
+
// import { NgProgressConfig, NgProgressModule } from 'ngx-progressbar';
|
|
6146
7103
|
class TaonProgressBarModule {
|
|
6147
7104
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: TaonProgressBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
6148
7105
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: TaonProgressBarModule, declarations: [TaonProgressBarComponent], imports: [CommonModule], exports: [TaonProgressBarComponent] }); }
|
|
@@ -6152,17 +7109,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
6152
7109
|
type: NgModule,
|
|
6153
7110
|
args: [{
|
|
6154
7111
|
imports: [CommonModule,
|
|
7112
|
+
// NgProgressModule.withConfig({})
|
|
6155
7113
|
],
|
|
6156
7114
|
declarations: [TaonProgressBarComponent],
|
|
6157
7115
|
exports: [TaonProgressBarComponent],
|
|
6158
7116
|
}]
|
|
6159
7117
|
}] });
|
|
6160
|
-
;
|
|
6161
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-progress-bar/taon-progress-bar.module.ts
|
|
6162
7118
|
|
|
6163
|
-
|
|
6164
|
-
|
|
7119
|
+
//#region @browser
|
|
7120
|
+
//#endregion
|
|
6165
7121
|
|
|
7122
|
+
//#region imports
|
|
7123
|
+
//#endregion
|
|
7124
|
+
//#region constants
|
|
6166
7125
|
const log = Log.create('Table wrapper', Level.__NOTHING);
|
|
6167
7126
|
const defaultColumns = [
|
|
6168
7127
|
{
|
|
@@ -6174,8 +7133,10 @@ const defaultColumns = [
|
|
|
6174
7133
|
field: 'name',
|
|
6175
7134
|
},
|
|
6176
7135
|
];
|
|
7136
|
+
//#endregion
|
|
6177
7137
|
class TaonTableComponent {
|
|
6178
7138
|
constructor() {
|
|
7139
|
+
//#region fields
|
|
6179
7140
|
this.pageNumber = 1;
|
|
6180
7141
|
this.pageSize = 5;
|
|
6181
7142
|
this.allowedColumns = [];
|
|
@@ -6189,27 +7150,36 @@ class TaonTableComponent {
|
|
|
6189
7150
|
this.pageSizeOptions = [5, 10, 20];
|
|
6190
7151
|
this.expansionChange = new EventEmitter();
|
|
6191
7152
|
this.addingItem = new EventEmitter();
|
|
6192
|
-
this.searchInputChange$ = defer(() => fromEvent(this.search?.nativeElement, 'keyup')).pipe(map(c => c.target['value']), debounceTime(500), distinctUntilChanged(), share(), tap(data => {
|
|
6193
|
-
console.log({ data });
|
|
6194
|
-
}));
|
|
6195
7153
|
this.expandable = false;
|
|
6196
7154
|
this.showPaginator = true;
|
|
6197
7155
|
this.isLoading = false;
|
|
6198
7156
|
this.totalElements = 100;
|
|
6199
7157
|
this.sub = new Subscription();
|
|
6200
7158
|
}
|
|
7159
|
+
//#endregion
|
|
7160
|
+
get entity() {
|
|
7161
|
+
return this.entityCrudController?.entityClassResolveFn();
|
|
7162
|
+
}
|
|
7163
|
+
//#region hooks
|
|
7164
|
+
//#region hooks / on init
|
|
6201
7165
|
async ngOnInit() {
|
|
6202
|
-
if (
|
|
6203
|
-
this.
|
|
7166
|
+
if (!this.hideSearch) {
|
|
7167
|
+
this.searchInputChange$ = defer(() => fromEvent(this.search?.nativeElement, 'keyup')).pipe(map(c => c.target['value']), debounceTime(500), distinctUntilChanged(), share(), tap(data => {
|
|
7168
|
+
console.log({ data });
|
|
7169
|
+
}));
|
|
7170
|
+
this.sub.add(this.searchInputChange$.subscribe());
|
|
6204
7171
|
}
|
|
6205
|
-
this.
|
|
6206
|
-
if (!!
|
|
7172
|
+
const entityClass = this.entity;
|
|
7173
|
+
if (!!entityClass) {
|
|
6207
7174
|
this.rows = [];
|
|
6208
7175
|
}
|
|
6209
7176
|
this.expandable = !!this.expansionTemplate;
|
|
7177
|
+
// this.arrayDataConfig.set.pagination.rowDisplayed(5);
|
|
6210
7178
|
log.i('this.columns,', this.columns);
|
|
6211
7179
|
const columnsConfigSameAsDefault = _.isEqual(this.columns, defaultColumns);
|
|
6212
|
-
|
|
7180
|
+
// console.log({
|
|
7181
|
+
// columnsConfigSameAsDefault
|
|
7182
|
+
// })
|
|
6213
7183
|
if (entityClass && columnsConfigSameAsDefault) {
|
|
6214
7184
|
log.i('this.crud.entity', CLASS.describeProperites(entityClass));
|
|
6215
7185
|
try {
|
|
@@ -6234,6 +7204,9 @@ class TaonTableComponent {
|
|
|
6234
7204
|
};
|
|
6235
7205
|
}),
|
|
6236
7206
|
];
|
|
7207
|
+
// console.log({
|
|
7208
|
+
// extra
|
|
7209
|
+
// });
|
|
6237
7210
|
if (!this.expandable) {
|
|
6238
7211
|
for (let index = 0; index < columns.length; index++) {
|
|
6239
7212
|
const col = columns[index];
|
|
@@ -6251,46 +7224,99 @@ class TaonTableComponent {
|
|
|
6251
7224
|
if (!this.entity) {
|
|
6252
7225
|
this.showPaginator = false;
|
|
6253
7226
|
}
|
|
6254
|
-
await this.
|
|
7227
|
+
await this.getData();
|
|
6255
7228
|
}
|
|
7229
|
+
//#endregion
|
|
7230
|
+
//#region hooks / on destroy
|
|
6256
7231
|
ngOnDestroy() {
|
|
6257
7232
|
this.sub.unsubscribe();
|
|
6258
7233
|
}
|
|
7234
|
+
//#endregion
|
|
7235
|
+
//#endregion
|
|
7236
|
+
//#region methods
|
|
7237
|
+
//#region methods / get next page
|
|
6259
7238
|
async getNextPage(e) {
|
|
7239
|
+
// console.log({
|
|
7240
|
+
// e
|
|
7241
|
+
// });
|
|
6260
7242
|
this.pageNumber = e.pageIndex + 1;
|
|
6261
7243
|
this.pageSize = e.pageSize;
|
|
6262
|
-
await this.
|
|
7244
|
+
await this.getData();
|
|
6263
7245
|
}
|
|
6264
|
-
|
|
7246
|
+
//#endregion
|
|
7247
|
+
//#region methods / retrive data
|
|
7248
|
+
async getData() {
|
|
7249
|
+
if (!this.entity) {
|
|
7250
|
+
return;
|
|
7251
|
+
}
|
|
7252
|
+
this.isLoading = true;
|
|
7253
|
+
// console.log('PAGINTION FETCH DATA START!')
|
|
7254
|
+
const controller = this.entityCrudController;
|
|
7255
|
+
if (controller) {
|
|
7256
|
+
const data = await controller.pagination(this.pageNumber, this.pageSize)
|
|
7257
|
+
.received;
|
|
7258
|
+
// console.log('PAGINTION DATA', {
|
|
7259
|
+
// data,
|
|
7260
|
+
// });
|
|
7261
|
+
const totalElements = Number(data.headers.get(Taon.symbols.old.X_TOTAL_COUNT));
|
|
7262
|
+
const rows = data.body.json;
|
|
7263
|
+
// console.log('PAGINTION DATA', {
|
|
7264
|
+
// rows,
|
|
7265
|
+
// totalElements,
|
|
7266
|
+
// });
|
|
7267
|
+
this.totalElements = totalElements;
|
|
7268
|
+
this.rows = rows.map(d => {
|
|
7269
|
+
for (const key in d) {
|
|
7270
|
+
if (Object.prototype.hasOwnProperty.call(d, key)) {
|
|
7271
|
+
const elem = d[key];
|
|
7272
|
+
if (_.isObject(elem)) {
|
|
7273
|
+
d[key] = json5.stringify(d[key]);
|
|
7274
|
+
}
|
|
7275
|
+
}
|
|
7276
|
+
}
|
|
7277
|
+
// console.log({ d })
|
|
7278
|
+
return d;
|
|
7279
|
+
});
|
|
7280
|
+
}
|
|
7281
|
+
this.isLoading = false;
|
|
6265
7282
|
}
|
|
7283
|
+
//#endregion
|
|
7284
|
+
//#region methods / expansion row
|
|
6266
7285
|
expansionRow(e) {
|
|
6267
7286
|
this.expansionChange.next(e);
|
|
6268
7287
|
}
|
|
7288
|
+
//#endregion
|
|
7289
|
+
//#region methods / on table context menu
|
|
6269
7290
|
onTableContextMenu(e) {
|
|
7291
|
+
// if (this.rowHref) {
|
|
7292
|
+
// this.router.navigateByUrl(this.rowHref)
|
|
7293
|
+
// }
|
|
6270
7294
|
log.i('context menu event', e);
|
|
6271
7295
|
}
|
|
6272
7296
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: TaonTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
6273
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.8", type: TaonTableComponent, isStandalone: false, selector: "taon-table", inputs: { pageNumber: "pageNumber", pageSize: "pageSize", allowedColumns: "allowedColumns",
|
|
7297
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.8", type: TaonTableComponent, isStandalone: false, selector: "taon-table", inputs: { pageNumber: "pageNumber", pageSize: "pageSize", allowedColumns: "allowedColumns", expansionTemplate: "expansionTemplate", rows: "rows", entityCrudController: "entityCrudController", columns: "columns", pageSizeOptions: "pageSizeOptions", hideSearch: "hideSearch" }, outputs: { expansionChange: "expansionChange", addingItem: "addingItem" }, viewQueries: [{ propertyName: "search", first: true, predicate: ["search"], descendants: true, static: true }], ngImport: i0, template: "<br />\n<columns-container *ngIf=\"!hideSearch\">\n <column grow>\n <mat-form-field class=\"search-input\">\n <input\n matInput\n placeholder=\"Type to search table...\"\n #search />\n </mat-form-field>\n </column>\n <column [width]=\"80\">\n <button\n mat-fab\n [ngClass]=\"{ 'half-opacity': !search.value }\"\n class=\"undo-button\"\n color=\"secondary\"\n (click)=\"search.value = ''\">\n <mat-icon>close </mat-icon>\n </button>\n </column>\n\n <column [width]=\"80\">\n <button\n mat-fab\n (click)=\"addingItem.next()\"\n class=\"undo-button\"\n color=\"primary\">\n <mat-icon>add</mat-icon>\n </button>\n </column>\n</columns-container>\n\n<mtx-grid\n *ngIf=\"rows && columns\"\n [data]=\"rows\"\n [columns]=\"columns\"\n [expandable]=\"expandable\"\n [expansionTemplate]=\"expansionTemplate\"\n (expansionChange)=\"expansionRow($event)\"\n [length]=\"totalElements\"\n [loading]=\"isLoading\"\n [pageOnFront]=\"false\"\n [pageIndex]=\"pageNumber - 1\"\n [pageSize]=\"pageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n [showPaginator]=\"showPaginator\"\n (page)=\"getNextPage($event)\">\n</mtx-grid>\n", styles: [":host{min-height:250px}.search-input{width:100%}.undo-button{margin-left:10px}.half-opacity{opacity:.2}\n"], dependencies: [{ kind: "directive", type: i2$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2$2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "component", type: i3.MtxGrid, selector: "mtx-grid", inputs: ["displayedColumns", "columns", "data", "length", "loading", "trackBy", "columnResizable", "emptyValuePlaceholder", "pageOnFront", "showPaginator", "pageDisabled", "showFirstLastButtons", "pageIndex", "pageSize", "pageSizeOptions", "hidePageSize", "paginationTemplate", "sortOnFront", "sortActive", "sortDirection", "sortDisableClear", "sortDisabled", "sortStart", "rowHover", "rowStriped", "expandable", "expansionTemplate", "multiSelectable", "multiSelectionWithClick", "rowSelectable", "hideRowSelectionCheckbox", "disableRowClickSelection", "rowSelectionFormatter", "rowClassFormatter", "rowSelected", "cellSelectable", "showToolbar", "toolbarTitle", "toolbarTemplate", "columnHideable", "columnHideableChecked", "columnSortable", "columnPinnable", "columnPinOptions", "showColumnMenuButton", "columnMenuButtonText", "columnMenuButtonType", "columnMenuButtonColor", "columnMenuButtonClass", "columnMenuButtonIcon", "columnMenuButtonFontIcon", "columnMenuButtonSvgIcon", "showColumnMenuHeader", "columnMenuHeaderText", "columnMenuHeaderTemplate", "showColumnMenuFooter", "columnMenuFooterText", "columnMenuFooterTemplate", "noResultText", "noResultTemplate", "headerTemplate", "headerExtraTemplate", "cellTemplate", "useContentRowTemplate", "useContentHeaderRowTemplate", "useContentFooterRowTemplate", "showSummary", "summaryTemplate", "showSidebar", "sidebarTemplate", "showStatusbar", "statusbarTemplate"], outputs: ["page", "sortChange", "rowClick", "rowContextMenu", "expansionChange", "rowSelectedChange", "cellSelectedChange", "columnChange"], exportAs: ["mtxGrid"] }, { kind: "directive", type: i2$2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: i1$2.ColumnsComponent, selector: "columns-container" }, { kind: "component", type: i1$2.ColumnComponent, selector: "column", inputs: ["width"] }, { kind: "directive", type: i1$2.DirectiveGrow, selector: "[grow]" }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i6.MatFabButton, selector: "button[mat-fab]", inputs: ["extended"], exportAs: ["matButton"] }] }); }
|
|
6274
7298
|
}
|
|
6275
7299
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: TaonTableComponent, decorators: [{
|
|
6276
7300
|
type: Component,
|
|
6277
|
-
args: [{ selector: 'taon-table', standalone: false, template: "<br />\n<columns-container>\n <column grow>\n <mat-form-field class=\"search-input\">\n <input
|
|
6278
|
-
}],
|
|
7301
|
+
args: [{ selector: 'taon-table', standalone: false, template: "<br />\n<columns-container *ngIf=\"!hideSearch\">\n <column grow>\n <mat-form-field class=\"search-input\">\n <input\n matInput\n placeholder=\"Type to search table...\"\n #search />\n </mat-form-field>\n </column>\n <column [width]=\"80\">\n <button\n mat-fab\n [ngClass]=\"{ 'half-opacity': !search.value }\"\n class=\"undo-button\"\n color=\"secondary\"\n (click)=\"search.value = ''\">\n <mat-icon>close </mat-icon>\n </button>\n </column>\n\n <column [width]=\"80\">\n <button\n mat-fab\n (click)=\"addingItem.next()\"\n class=\"undo-button\"\n color=\"primary\">\n <mat-icon>add</mat-icon>\n </button>\n </column>\n</columns-container>\n\n<mtx-grid\n *ngIf=\"rows && columns\"\n [data]=\"rows\"\n [columns]=\"columns\"\n [expandable]=\"expandable\"\n [expansionTemplate]=\"expansionTemplate\"\n (expansionChange)=\"expansionRow($event)\"\n [length]=\"totalElements\"\n [loading]=\"isLoading\"\n [pageOnFront]=\"false\"\n [pageIndex]=\"pageNumber - 1\"\n [pageSize]=\"pageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n [showPaginator]=\"showPaginator\"\n (page)=\"getNextPage($event)\">\n</mtx-grid>\n", styles: [":host{min-height:250px}.search-input{width:100%}.undo-button{margin-left:10px}.half-opacity{opacity:.2}\n"] }]
|
|
7302
|
+
}], propDecorators: { pageNumber: [{
|
|
6279
7303
|
type: Input
|
|
6280
7304
|
}], pageSize: [{
|
|
6281
7305
|
type: Input
|
|
6282
7306
|
}], allowedColumns: [{
|
|
6283
7307
|
type: Input
|
|
6284
|
-
}], entity: [{
|
|
6285
|
-
type: Input
|
|
6286
7308
|
}], expansionTemplate: [{
|
|
6287
7309
|
type: Input
|
|
6288
7310
|
}], rows: [{
|
|
6289
7311
|
type: Input
|
|
7312
|
+
}], entityCrudController: [{
|
|
7313
|
+
type: Input
|
|
6290
7314
|
}], columns: [{
|
|
6291
7315
|
type: Input
|
|
6292
7316
|
}], pageSizeOptions: [{
|
|
6293
7317
|
type: Input
|
|
7318
|
+
}], hideSearch: [{
|
|
7319
|
+
type: Input
|
|
6294
7320
|
}], expansionChange: [{
|
|
6295
7321
|
type: Output
|
|
6296
7322
|
}], addingItem: [{
|
|
@@ -6299,8 +7325,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
6299
7325
|
type: ViewChild,
|
|
6300
7326
|
args: ['search', { static: true }]
|
|
6301
7327
|
}] } });
|
|
6302
|
-
;
|
|
6303
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-table/taon-table.component.ts
|
|
6304
7328
|
|
|
6305
7329
|
class TaonTableModule {
|
|
6306
7330
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: TaonTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
@@ -6344,11 +7368,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
6344
7368
|
declarations: [TaonTableComponent],
|
|
6345
7369
|
}]
|
|
6346
7370
|
}] });
|
|
6347
|
-
;
|
|
6348
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-table/taon-table.module.ts
|
|
6349
7371
|
|
|
6350
|
-
|
|
6351
|
-
|
|
7372
|
+
//#region @browser
|
|
7373
|
+
//#endregion
|
|
6352
7374
|
|
|
6353
7375
|
class TaonAdminModeConfigurationComponent {
|
|
6354
7376
|
get opened() {
|
|
@@ -6364,8 +7386,11 @@ class TaonAdminModeConfigurationComponent {
|
|
|
6364
7386
|
}
|
|
6365
7387
|
this.taonAdminService.adminPanelIsOpen = v;
|
|
6366
7388
|
}
|
|
7389
|
+
//#endregion
|
|
7390
|
+
//#region constructor
|
|
6367
7391
|
constructor(breakpointsService) {
|
|
6368
7392
|
this.breakpointsService = breakpointsService;
|
|
7393
|
+
//#region fields & getters
|
|
6369
7394
|
this.$destroy = new Subject();
|
|
6370
7395
|
this.cdr = inject$1(ChangeDetectorRef);
|
|
6371
7396
|
this.taonAdminService = TaonAdminService.Instance;
|
|
@@ -6375,13 +7400,13 @@ class TaonAdminModeConfigurationComponent {
|
|
|
6375
7400
|
this.height = 100;
|
|
6376
7401
|
this.openedOnce = false;
|
|
6377
7402
|
this.reloading = false;
|
|
6378
|
-
this.showPasscode = _
|
|
6379
|
-
this.passcode = _
|
|
7403
|
+
this.showPasscode = _.isString(ENV.passcode) || _.isObject(ENV.passcode);
|
|
7404
|
+
this.passcode = _.isString(ENV.passcode)
|
|
6380
7405
|
? ENV.passcode
|
|
6381
|
-
: _
|
|
7406
|
+
: _.isObject(ENV.passcode)
|
|
6382
7407
|
? ENV.passcode.code
|
|
6383
7408
|
: '';
|
|
6384
|
-
this.message = _
|
|
7409
|
+
this.message = _.isObject(ENV.passcode)
|
|
6385
7410
|
? ENV.passcode.message
|
|
6386
7411
|
: void 0;
|
|
6387
7412
|
this.dragPositionZero = { x: 0, y: 0 };
|
|
@@ -6395,19 +7420,33 @@ class TaonAdminModeConfigurationComponent {
|
|
|
6395
7420
|
this.isDesktop = breakpoint === 'desktop';
|
|
6396
7421
|
});
|
|
6397
7422
|
}
|
|
7423
|
+
//#endregion
|
|
7424
|
+
//#region hooks
|
|
6398
7425
|
async ngOnInit() {
|
|
6399
7426
|
await Stor.awaitPendingOperatios();
|
|
7427
|
+
// console.log('PENDING OPERATION AWAITED ', this.selectedIndex)
|
|
7428
|
+
// console.log('draggablePopupModeFullScreen ', this.taonAdminService.draggablePopupModeFullScreen)
|
|
6400
7429
|
this.dragPosition = { x: this.dragPositionX, y: this.dragPositionY };
|
|
6401
7430
|
this.openedOnce = this.opened;
|
|
7431
|
+
// console.log('ONINIT',{
|
|
7432
|
+
// 'this.openedOnce': this.openedOnce,
|
|
7433
|
+
// 'this.dragPosition': this.dragPosition,
|
|
7434
|
+
// this: this
|
|
7435
|
+
// })
|
|
6402
7436
|
}
|
|
6403
7437
|
ngAfterViewInit() {
|
|
6404
7438
|
//Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
|
|
6405
7439
|
//Add 'implements AfterViewInit' to the class.
|
|
6406
7440
|
setTimeout(() => {
|
|
6407
7441
|
this.height = window.innerHeight;
|
|
7442
|
+
// TODO QUICK_FIX for draggble popup proper first index load on tabs
|
|
6408
7443
|
if (this.taonAdminService.draggablePopupMode) {
|
|
6409
7444
|
this.reloadTabs();
|
|
6410
7445
|
}
|
|
7446
|
+
// const tablist = (this.tabGroup?._tabHeader?._elementRef?.nativeElement as HTMLElement).querySelector('.mat-tab-list') as HTMLElement;
|
|
7447
|
+
// if (tablist) {
|
|
7448
|
+
// tablist.style.transform = 'translateX(0px)'; // TODO QUICK_FIX
|
|
7449
|
+
// }
|
|
6411
7450
|
});
|
|
6412
7451
|
}
|
|
6413
7452
|
ngOnDestroy() {
|
|
@@ -6417,6 +7456,8 @@ class TaonAdminModeConfigurationComponent {
|
|
|
6417
7456
|
onResize(event) {
|
|
6418
7457
|
this.height = window.innerHeight;
|
|
6419
7458
|
}
|
|
7459
|
+
//#endregion
|
|
7460
|
+
//#region methods
|
|
6420
7461
|
async reloadTabs() {
|
|
6421
7462
|
return new Promise(resolve => {
|
|
6422
7463
|
this.reloading = true;
|
|
@@ -6428,6 +7469,7 @@ class TaonAdminModeConfigurationComponent {
|
|
|
6428
7469
|
});
|
|
6429
7470
|
}
|
|
6430
7471
|
async toogle() {
|
|
7472
|
+
// await stor.setItem(IS_OPEN_ADMIN, !this.opened);
|
|
6431
7473
|
this.opened = !this.opened;
|
|
6432
7474
|
}
|
|
6433
7475
|
async toogleFullScreen() {
|
|
@@ -6447,9 +7489,20 @@ class TaonAdminModeConfigurationComponent {
|
|
|
6447
7489
|
}
|
|
6448
7490
|
scrollTabs(event) {
|
|
6449
7491
|
return;
|
|
7492
|
+
// event?.stopPropagation();
|
|
7493
|
+
// event?.stopImmediatePropagation(); // TODO not working
|
|
7494
|
+
// const children = this.tabGroup._tabHeader._elementRef.nativeElement.children;
|
|
7495
|
+
// const back = children[0];
|
|
7496
|
+
// const forward = children[2];
|
|
7497
|
+
// if (event.deltaY > 0) {
|
|
7498
|
+
// forward.click();
|
|
7499
|
+
// } else {
|
|
7500
|
+
// back.click();
|
|
7501
|
+
// }
|
|
6450
7502
|
}
|
|
6451
7503
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: TaonAdminModeConfigurationComponent, deps: [{ token: i1$2.BreakpointsService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
6452
7504
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.8", type: TaonAdminModeConfigurationComponent, isStandalone: true, selector: "taon-admin-mode-configuration", inputs: { taonAdminModeConfigurationData: "taonAdminModeConfigurationData" }, outputs: { taonAdminModeConfigurationDataChanged: "taonAdminModeConfigurationDataChanged" }, host: { listeners: { "window:resize": "onResize($event)" } }, viewQueries: [{ propertyName: "tabGroup", first: true, predicate: ["tabGroup"], descendants: true }], ngImport: i0, template: "<!-- #region basic global components -->\n<taon-session-passcode\n *ngIf=\"showPasscode\"\n [passcode]=\"passcode\"\n [message]=\"message\" />\n<!-- <taon-progress-bar [isDesktop]=\"isDesktop\"></taon-progress-bar> -->\n<!-- <taon-notifications></taon-notifications> -->\n<button\n mat-fab\n class=\"fab-button\"\n color=\"accent\"\n aria-label=\"Taon Admin Mode\"\n *ngIf=\"\n !taonAdminService.draggablePopupMode &&\n isDesktop &&\n !isIframe &&\n !hideTaonToolsInProduction\n \"\n (click)=\"toogle()\">\n <mat-icon>build</mat-icon>\n</button>\n<!-- #endregion -->\n\n<!-- #region small hidden button -->\n<!-- <button class=\"admin-show-button\"\n *ngIf=\"!taonAdminService.draggablePopupMode && isDesktop\"\n (click)=\"toogle()\"> Admin </button> -->\n<!-- #endregion -->\n\n<ng-template #contentNoScroll>\n <ng-content> </ng-content>\n</ng-template>\n\n<ng-template #content>\n <ng-scrollbar>\n <ng-container [ngTemplateOutlet]=\"contentNoScroll\"></ng-container>\n </ng-scrollbar>\n</ng-template>\n\n<!-- #region admin tabs -->\n<ng-template #adminTabs>\n <!-- #region admin tabs / header -->\n <div class=\"taon-header-admin-wrapper\">\n <columns-container\n class=\"taon-header-admin\"\n [ngClass]=\"{ 'draggable-column': taonAdminService.draggablePopupMode }\">\n <column\n width=\"200\"\n class=\"logo-header\">\n <img\n *ngIf=\"openedOnce\"\n src=\"assets/assets-for/taon/shared/logo-header-admin-mode.png\" />\n </column>\n\n <column grow>\n <!-- <span>Super Admin Mode</span> -->\n </column>\n\n <column\n width=\"40\"\n *ngIf=\"\n !taonAdminService.draggablePopupModeFullScreen &&\n !taonAdminService.draggablePopupMode\n \">\n <button\n mat-icon-button\n *ngIf=\"taonAdminService.draggablePopupMode\"\n (click)=\"\n taonAdminService.draggablePopupMode = false;\n opened = false;\n wasOpenDraggablePopup = true\n \"\n class=\"admin-close-button\">\n <mat-icon>close </mat-icon>\n </button>\n\n <button\n mat-icon-button\n *ngIf=\"!taonAdminService.draggablePopupMode\"\n (click)=\"toogle()\"\n class=\"admin-close-button\">\n <mat-icon>close</mat-icon>\n </button>\n </column>\n\n <column width=\"40\">\n <button\n mat-icon-button\n *ngIf=\"!taonAdminService.draggablePopupModeFullScreen\"\n class=\"admin-close-button\"\n (click)=\"toogleFullScreen()\">\n <mat-icon>fullscreen</mat-icon>\n </button>\n <button\n mat-icon-button\n *ngIf=\"taonAdminService.draggablePopupModeFullScreen\"\n class=\"admin-close-button\"\n (click)=\"toogleFullScreen()\">\n <mat-icon>close_fullscreen</mat-icon>\n </button>\n </column>\n\n <column\n width=\"40\"\n *ngIf=\"!taonAdminService.draggablePopupModeFullScreen\">\n <button\n mat-icon-button\n *ngIf=\"!taonAdminService.draggablePopupMode\"\n (click)=\"taonAdminService.draggablePopupMode = true\"\n class=\"admin-close-button\">\n <mat-icon>launch</mat-icon>\n </button>\n\n <button\n mat-icon-button\n *ngIf=\"taonAdminService.draggablePopupMode\"\n (click)=\"taonAdminService.draggablePopupMode = false; resetDrag()\"\n class=\"admin-close-button\">\n <mat-icon style=\"transform: rotate(180deg)\">login</mat-icon>\n </button>\n </column>\n </columns-container>\n </div>\n <!-- #endregion -->\n\n <columns-container\n [ngClass]=\"{ 'draggable-column': taonAdminService.draggablePopupMode }\">\n <column grow>\n <mat-tab-group\n dynamicHeight\n (wheel)=\"scrollTabs($event)\"\n #tabGroup\n [selectedIndex]=\"selectedIndex\"\n (selectedIndexChange)=\"selectedIndex = $event\">\n <mat-tab label=\"DB/Cache\">\n <section>\n <mat-card>\n <mat-card-header>\n <mat-card-subtitle>WEBSQL MODE</mat-card-subtitle>\n </mat-card-header>\n <mat-card-content>\n <mat-checkbox\n [disabled]=\"!isWebSQLMode\"\n [ngModel]=\"taonAdminService.keepWebsqlDbDataAfterReload\"\n (change)=\"\n taonAdminService.setKeepWebsqlDbDataAfterReload(\n $event.checked\n )\n \">\n Don't remove data when reloading\n </mat-checkbox>\n </mat-card-content>\n </mat-card>\n </section>\n <br />\n <taon-db-admin />\n </mat-tab>\n </mat-tab-group>\n </column>\n </columns-container>\n</ng-template>\n<!-- #endregion -->\n\n<!-- #region small/mobile draggable popup windows -->\n<div\n class=\"draggable-popup-mode-window\"\n *ngIf=\"\n taonAdminService.draggablePopupMode &&\n !taonAdminService.draggablePopupModeFullScreen &&\n !isIframe\n \"\n cdkDrag\n [cdkDragFreeDragPosition]=\"dragPosition\"\n (cdkDragEnded)=\"moved($event)\">\n <ng-scrollbar>\n <ng-container [ngTemplateOutlet]=\"adminTabs\"></ng-container>\n </ng-scrollbar>\n</div>\n<!-- #endregion -->\n\n<!-- #region fullscreen draggable popup window -->\n<div\n class=\"draggable-popup-mode-window-full\"\n *ngIf=\"\n taonAdminService.draggablePopupMode &&\n taonAdminService.draggablePopupModeFullScreen &&\n !isIframe &&\n !reloading\n \"\n cdkDrag\n [cdkDragFreeDragPosition]=\"dragPositionZero\">\n <ng-container [ngTemplateOutlet]=\"adminTabs\"></ng-container>\n</div>\n<!-- #endregion -->\n\n<!-- #region content when not in draggable (or fullscreen draggable) popup -->\n<div\n [style.height.px]=\"height\"\n *ngIf=\"\n (isIframe ||\n !isDesktop ||\n taonAdminService.draggablePopupMode ||\n taonAdminService.draggablePopupModeFullScreen) &&\n !reloading\n \"\n style=\"width: 100%; display: block\"\n class=\"content\">\n <ng-container\n [ngTemplateOutlet]=\"\n taonAdminService.scrollableEnabled ? content : contentNoScroll\n \"></ng-container>\n</div>\n<!-- #endregion -->\n\n<!-- #region draggable popup window -->\n<mat-drawer-container\n *ngIf=\"!taonAdminService.draggablePopupMode && isDesktop && !isIframe\"\n class=\"example-container\"\n [style.height.px]=\"height\"\n style=\"background-color: transparent\"\n (backdropClick)=\"opened = false\"\n [hasBackdrop]=\"false\">\n <mat-drawer\n #drawer\n style=\"width: 580px\"\n [opened]=\"opened\"\n [mode]=\"'side'\">\n <ng-container [ngTemplateOutlet]=\"adminTabs\"></ng-container>\n </mat-drawer>\n <mat-drawer-content style=\"overflow: hidden\">\n <ng-container\n *ngIf=\"!taonAdminService.draggablePopupMode && !reloading\"\n [ngTemplateOutlet]=\"\n taonAdminService.scrollableEnabled ? content : contentNoScroll\n \"></ng-container>\n </mat-drawer-content>\n</mat-drawer-container>\n<!-- #endregion -->\n", styles: ["section{display:block;padding:10px}section>*{margin-top:0!important;margin-bottom:10px!important}section>*:last-child{margin-bottom:0!important}:host{display:block}.draggable-column{display:block!important;width:100%!important}.admin-show-button{position:fixed;bottom:100px;left:-15px;z-index:2147483647;transform:rotate(90deg);border:0px;color:#fff;background:gray;opacity:.1;cursor:pointer}.admin-show-button:hover{opacity:1}.taon-ui-super-admin-mode{font-family:JosefinSans-Bold;text-align:right;margin-right:10px}mat-drawer{margin:0;background-color:#dcdcdc!important}.taon-header-admin-wrapper{overflow:hidden;width:100%;display:block}.taon-header-admin{background:#fff;box-shadow:0 -9px 6px 6px #000;height:47px}.taon-header-admin .logo-header img{height:18px;padding:8px;position:relative;float:left;top:7px;box-sizing:content-box;transform:scale(1.5);left:49px}.draggable-popup-mode-window{width:600px;height:500px;border:solid 1px #ccc;color:#000000de;cursor:move;justify-content:center;align-items:center;background:#fff;border-radius:4px;position:fixed;z-index:105;background-color:#dcdcdc!important;transition:box-shadow .2s cubic-bezier(0,0,.2,1);box-shadow:0 3px 1px -2px #0003,0 2px 2px #00000024,0 1px 5px #0000001f}.draggable-popup-mode-window:active{box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.draggable-popup-mode-window-full{width:100%;height:100%;overflow:scroll;color:#000000de;justify-content:center;align-items:center;background:#fff;border-radius:4px;position:fixed;z-index:105;background-color:#dcdcdc!important}.admin-close-button{float:right}.fab-button{position:fixed;right:110px;bottom:100px;z-index:10;background-color:#dcdcdc;color:#8f8f8f}.full-tabs{padding:10px}.mat-drawer-container-full-screen{background-color:red}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: StaticColumnsModule }, { kind: "component", type: i1$2.ColumnsComponent, selector: "columns-container" }, { kind: "component", type: i1$2.ColumnComponent, selector: "column", inputs: ["width"] }, { kind: "directive", type: i1$2.DirectiveGrow, selector: "[grow]" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: NgScrollbarModule }, { kind: "component", type: i4.NgScrollbar, selector: "ng-scrollbar:not([externalViewport])", exportAs: ["ngScrollbar"] }, { kind: "ngmodule", type: TaonProgressBarModule }, { kind: "ngmodule", type: TaonNotificationsModule }, { kind: "ngmodule", type: TaonFullMaterialModule }, { kind: "directive", type: i5$1.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "component", type: i6.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i6.MatFabButton, selector: "button[mat-fab]", inputs: ["extended"], exportAs: ["matButton"] }, { kind: "component", type: i7.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i7.MatCardContent, selector: "mat-card-content" }, { kind: "component", type: i7.MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: i7.MatCardSubtitle, selector: "mat-card-subtitle, [mat-card-subtitle], [matCardSubtitle]" }, { kind: "component", type: i8.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i10.MatDrawer, selector: "mat-drawer", inputs: ["position", "mode", "disableClose", "autoFocus", "opened"], outputs: ["openedChange", "opened", "openedStart", "closed", "closedStart", "positionChanged"], exportAs: ["matDrawer"] }, { kind: "component", type: i10.MatDrawerContainer, selector: "mat-drawer-container", inputs: ["autosize", "hasBackdrop"], outputs: ["backdropClick"], exportAs: ["matDrawerContainer"] }, { kind: "component", type: i10.MatDrawerContent, selector: "mat-drawer-content" }, { kind: "component", type: i11.MatTab, selector: "mat-tab", inputs: ["disabled", "label", "aria-label", "aria-labelledby", "labelClass", "bodyClass", "id"], exportAs: ["matTab"] }, { kind: "component", type: i11.MatTabGroup, selector: "mat-tab-group", inputs: ["color", "fitInkBarToContent", "mat-stretch-tabs", "mat-align-tabs", "dynamicHeight", "selectedIndex", "headerPosition", "animationDuration", "contentTabIndex", "disablePagination", "disableRipple", "preserveContent", "backgroundColor", "aria-label", "aria-labelledby"], outputs: ["selectedIndexChange", "focusChange", "animationDone", "selectedTabChange"], exportAs: ["matTabGroup"] }, { kind: "component", type: // TODO import only partial things
|
|
7505
|
+
// TaonDbAdminComponent,
|
|
6453
7506
|
TaonSessionPasscodeComponent, selector: "taon-session-passcode", inputs: ["passcode", "message"] }] }); }
|
|
6454
7507
|
}
|
|
6455
7508
|
__decorate([
|
|
@@ -6486,6 +7539,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
6486
7539
|
TaonProgressBarModule,
|
|
6487
7540
|
TaonNotificationsModule,
|
|
6488
7541
|
TaonFullMaterialModule, // TODO import only partial things
|
|
7542
|
+
// TaonDbAdminComponent,
|
|
6489
7543
|
TaonSessionPasscodeComponent,
|
|
6490
7544
|
], template: "<!-- #region basic global components -->\n<taon-session-passcode\n *ngIf=\"showPasscode\"\n [passcode]=\"passcode\"\n [message]=\"message\" />\n<!-- <taon-progress-bar [isDesktop]=\"isDesktop\"></taon-progress-bar> -->\n<!-- <taon-notifications></taon-notifications> -->\n<button\n mat-fab\n class=\"fab-button\"\n color=\"accent\"\n aria-label=\"Taon Admin Mode\"\n *ngIf=\"\n !taonAdminService.draggablePopupMode &&\n isDesktop &&\n !isIframe &&\n !hideTaonToolsInProduction\n \"\n (click)=\"toogle()\">\n <mat-icon>build</mat-icon>\n</button>\n<!-- #endregion -->\n\n<!-- #region small hidden button -->\n<!-- <button class=\"admin-show-button\"\n *ngIf=\"!taonAdminService.draggablePopupMode && isDesktop\"\n (click)=\"toogle()\"> Admin </button> -->\n<!-- #endregion -->\n\n<ng-template #contentNoScroll>\n <ng-content> </ng-content>\n</ng-template>\n\n<ng-template #content>\n <ng-scrollbar>\n <ng-container [ngTemplateOutlet]=\"contentNoScroll\"></ng-container>\n </ng-scrollbar>\n</ng-template>\n\n<!-- #region admin tabs -->\n<ng-template #adminTabs>\n <!-- #region admin tabs / header -->\n <div class=\"taon-header-admin-wrapper\">\n <columns-container\n class=\"taon-header-admin\"\n [ngClass]=\"{ 'draggable-column': taonAdminService.draggablePopupMode }\">\n <column\n width=\"200\"\n class=\"logo-header\">\n <img\n *ngIf=\"openedOnce\"\n src=\"assets/assets-for/taon/shared/logo-header-admin-mode.png\" />\n </column>\n\n <column grow>\n <!-- <span>Super Admin Mode</span> -->\n </column>\n\n <column\n width=\"40\"\n *ngIf=\"\n !taonAdminService.draggablePopupModeFullScreen &&\n !taonAdminService.draggablePopupMode\n \">\n <button\n mat-icon-button\n *ngIf=\"taonAdminService.draggablePopupMode\"\n (click)=\"\n taonAdminService.draggablePopupMode = false;\n opened = false;\n wasOpenDraggablePopup = true\n \"\n class=\"admin-close-button\">\n <mat-icon>close </mat-icon>\n </button>\n\n <button\n mat-icon-button\n *ngIf=\"!taonAdminService.draggablePopupMode\"\n (click)=\"toogle()\"\n class=\"admin-close-button\">\n <mat-icon>close</mat-icon>\n </button>\n </column>\n\n <column width=\"40\">\n <button\n mat-icon-button\n *ngIf=\"!taonAdminService.draggablePopupModeFullScreen\"\n class=\"admin-close-button\"\n (click)=\"toogleFullScreen()\">\n <mat-icon>fullscreen</mat-icon>\n </button>\n <button\n mat-icon-button\n *ngIf=\"taonAdminService.draggablePopupModeFullScreen\"\n class=\"admin-close-button\"\n (click)=\"toogleFullScreen()\">\n <mat-icon>close_fullscreen</mat-icon>\n </button>\n </column>\n\n <column\n width=\"40\"\n *ngIf=\"!taonAdminService.draggablePopupModeFullScreen\">\n <button\n mat-icon-button\n *ngIf=\"!taonAdminService.draggablePopupMode\"\n (click)=\"taonAdminService.draggablePopupMode = true\"\n class=\"admin-close-button\">\n <mat-icon>launch</mat-icon>\n </button>\n\n <button\n mat-icon-button\n *ngIf=\"taonAdminService.draggablePopupMode\"\n (click)=\"taonAdminService.draggablePopupMode = false; resetDrag()\"\n class=\"admin-close-button\">\n <mat-icon style=\"transform: rotate(180deg)\">login</mat-icon>\n </button>\n </column>\n </columns-container>\n </div>\n <!-- #endregion -->\n\n <columns-container\n [ngClass]=\"{ 'draggable-column': taonAdminService.draggablePopupMode }\">\n <column grow>\n <mat-tab-group\n dynamicHeight\n (wheel)=\"scrollTabs($event)\"\n #tabGroup\n [selectedIndex]=\"selectedIndex\"\n (selectedIndexChange)=\"selectedIndex = $event\">\n <mat-tab label=\"DB/Cache\">\n <section>\n <mat-card>\n <mat-card-header>\n <mat-card-subtitle>WEBSQL MODE</mat-card-subtitle>\n </mat-card-header>\n <mat-card-content>\n <mat-checkbox\n [disabled]=\"!isWebSQLMode\"\n [ngModel]=\"taonAdminService.keepWebsqlDbDataAfterReload\"\n (change)=\"\n taonAdminService.setKeepWebsqlDbDataAfterReload(\n $event.checked\n )\n \">\n Don't remove data when reloading\n </mat-checkbox>\n </mat-card-content>\n </mat-card>\n </section>\n <br />\n <taon-db-admin />\n </mat-tab>\n </mat-tab-group>\n </column>\n </columns-container>\n</ng-template>\n<!-- #endregion -->\n\n<!-- #region small/mobile draggable popup windows -->\n<div\n class=\"draggable-popup-mode-window\"\n *ngIf=\"\n taonAdminService.draggablePopupMode &&\n !taonAdminService.draggablePopupModeFullScreen &&\n !isIframe\n \"\n cdkDrag\n [cdkDragFreeDragPosition]=\"dragPosition\"\n (cdkDragEnded)=\"moved($event)\">\n <ng-scrollbar>\n <ng-container [ngTemplateOutlet]=\"adminTabs\"></ng-container>\n </ng-scrollbar>\n</div>\n<!-- #endregion -->\n\n<!-- #region fullscreen draggable popup window -->\n<div\n class=\"draggable-popup-mode-window-full\"\n *ngIf=\"\n taonAdminService.draggablePopupMode &&\n taonAdminService.draggablePopupModeFullScreen &&\n !isIframe &&\n !reloading\n \"\n cdkDrag\n [cdkDragFreeDragPosition]=\"dragPositionZero\">\n <ng-container [ngTemplateOutlet]=\"adminTabs\"></ng-container>\n</div>\n<!-- #endregion -->\n\n<!-- #region content when not in draggable (or fullscreen draggable) popup -->\n<div\n [style.height.px]=\"height\"\n *ngIf=\"\n (isIframe ||\n !isDesktop ||\n taonAdminService.draggablePopupMode ||\n taonAdminService.draggablePopupModeFullScreen) &&\n !reloading\n \"\n style=\"width: 100%; display: block\"\n class=\"content\">\n <ng-container\n [ngTemplateOutlet]=\"\n taonAdminService.scrollableEnabled ? content : contentNoScroll\n \"></ng-container>\n</div>\n<!-- #endregion -->\n\n<!-- #region draggable popup window -->\n<mat-drawer-container\n *ngIf=\"!taonAdminService.draggablePopupMode && isDesktop && !isIframe\"\n class=\"example-container\"\n [style.height.px]=\"height\"\n style=\"background-color: transparent\"\n (backdropClick)=\"opened = false\"\n [hasBackdrop]=\"false\">\n <mat-drawer\n #drawer\n style=\"width: 580px\"\n [opened]=\"opened\"\n [mode]=\"'side'\">\n <ng-container [ngTemplateOutlet]=\"adminTabs\"></ng-container>\n </mat-drawer>\n <mat-drawer-content style=\"overflow: hidden\">\n <ng-container\n *ngIf=\"!taonAdminService.draggablePopupMode && !reloading\"\n [ngTemplateOutlet]=\"\n taonAdminService.scrollableEnabled ? content : contentNoScroll\n \"></ng-container>\n </mat-drawer-content>\n</mat-drawer-container>\n<!-- #endregion -->\n", styles: ["section{display:block;padding:10px}section>*{margin-top:0!important;margin-bottom:10px!important}section>*:last-child{margin-bottom:0!important}:host{display:block}.draggable-column{display:block!important;width:100%!important}.admin-show-button{position:fixed;bottom:100px;left:-15px;z-index:2147483647;transform:rotate(90deg);border:0px;color:#fff;background:gray;opacity:.1;cursor:pointer}.admin-show-button:hover{opacity:1}.taon-ui-super-admin-mode{font-family:JosefinSans-Bold;text-align:right;margin-right:10px}mat-drawer{margin:0;background-color:#dcdcdc!important}.taon-header-admin-wrapper{overflow:hidden;width:100%;display:block}.taon-header-admin{background:#fff;box-shadow:0 -9px 6px 6px #000;height:47px}.taon-header-admin .logo-header img{height:18px;padding:8px;position:relative;float:left;top:7px;box-sizing:content-box;transform:scale(1.5);left:49px}.draggable-popup-mode-window{width:600px;height:500px;border:solid 1px #ccc;color:#000000de;cursor:move;justify-content:center;align-items:center;background:#fff;border-radius:4px;position:fixed;z-index:105;background-color:#dcdcdc!important;transition:box-shadow .2s cubic-bezier(0,0,.2,1);box-shadow:0 3px 1px -2px #0003,0 2px 2px #00000024,0 1px 5px #0000001f}.draggable-popup-mode-window:active{box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.draggable-popup-mode-window-full{width:100%;height:100%;overflow:scroll;color:#000000de;justify-content:center;align-items:center;background:#fff;border-radius:4px;position:fixed;z-index:105;background-color:#dcdcdc!important}.admin-close-button{float:right}.fab-button{position:fixed;right:110px;bottom:100px;z-index:10;background-color:#dcdcdc;color:#8f8f8f}.full-tabs{padding:10px}.mat-drawer-container-full-screen{background-color:red}\n"] }]
|
|
6491
7545
|
}], ctorParameters: () => [{ type: i1$2.BreakpointsService }], propDecorators: { tabGroup: [{
|
|
@@ -6499,39 +7553,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
6499
7553
|
type: HostListener,
|
|
6500
7554
|
args: ['window:resize', ['$event']]
|
|
6501
7555
|
}] } });
|
|
6502
|
-
;
|
|
6503
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.ts
|
|
6504
|
-
|
|
6505
|
-
;
|
|
6506
|
-
({}); // @--end-of-file-for-module=taon lib/ui/taon-admin-mode-configuration/index.ts
|
|
6507
7556
|
|
|
6508
|
-
|
|
6509
|
-
|
|
7557
|
+
//#region @browser
|
|
7558
|
+
//#endregion
|
|
6510
7559
|
|
|
6511
|
-
|
|
6512
|
-
|
|
7560
|
+
//#region @browser
|
|
7561
|
+
//#endregion
|
|
6513
7562
|
|
|
7563
|
+
// TODO export all things
|
|
6514
7564
|
var Taon;
|
|
6515
7565
|
(function (Taon) {
|
|
6516
7566
|
Taon.Http = Http;
|
|
6517
7567
|
Taon.Base = Base;
|
|
6518
7568
|
Taon.getResponseValue = getResponseValue;
|
|
7569
|
+
//#region class decorators
|
|
6519
7570
|
Taon.Controller = TaonController;
|
|
6520
7571
|
Taon.Entity = TaonEntity;
|
|
6521
7572
|
Taon.Provider = TaonProvider;
|
|
6522
7573
|
Taon.Repository = TaonRepository;
|
|
6523
7574
|
Taon.Subscriber = TaonSubscriber;
|
|
6524
7575
|
Taon.Migration = TaonMigration;
|
|
7576
|
+
//#endregion
|
|
7577
|
+
//#region aliases to helpers
|
|
6525
7578
|
Taon.isBrowser = coreHelpers.Helpers.isBrowser;
|
|
6526
7579
|
Taon.isNode = coreHelpers.Helpers.isNode;
|
|
6527
7580
|
Taon.isWebSQL = coreHelpers.Helpers.isWebSQL;
|
|
6528
7581
|
Taon.isElectron = coreHelpers.Helpers.isElectron;
|
|
7582
|
+
//#endregion
|
|
6529
7583
|
Taon.createContext = createContext;
|
|
6530
7584
|
Taon.createContextTemplate = createContextTemplate;
|
|
6531
7585
|
Taon.inject = inject;
|
|
7586
|
+
//#region @browser
|
|
6532
7587
|
Taon.initNgZone = (ngZone) => {
|
|
6533
7588
|
EndpointContext.initNgZone(ngZone);
|
|
6534
7589
|
};
|
|
7590
|
+
//#endregion
|
|
6535
7591
|
Taon.symbols = Symbols;
|
|
6536
7592
|
/**
|
|
6537
7593
|
* @deprecated
|
|
@@ -6552,8 +7608,6 @@ var Taon;
|
|
|
6552
7608
|
return context;
|
|
6553
7609
|
};
|
|
6554
7610
|
})(Taon || (Taon = {}));
|
|
6555
|
-
;
|
|
6556
|
-
({}); // @--end-of-file-for-module=taon lib/index.ts
|
|
6557
7611
|
|
|
6558
7612
|
/**
|
|
6559
7613
|
* Generated bundle index. Do not edit.
|