taon 19.0.50 → 19.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/fesm2022/taon.mjs +167 -77
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-context.d.ts +1 -0
- package/browser/lib/base-classes/base-controller.d.ts +0 -6
- package/browser/lib/base-classes/base-injector.d.ts +4 -5
- package/browser/lib/base-classes/base-middleware.d.ts +17 -0
- package/browser/lib/base-classes/base.d.ts +3 -0
- package/browser/lib/constants.d.ts +1 -1
- package/browser/lib/create-context.d.ts +4 -2
- package/browser/lib/decorators/classes/middleware-decorator.d.ts +8 -0
- package/browser/lib/endpoint-context.d.ts +6 -5
- package/browser/lib/index.d.ts +8 -2
- package/browser/lib/models.d.ts +65 -5
- package/browser/package.json +1 -1
- package/lib/base-classes/base-context.d.ts +1 -0
- package/lib/base-classes/base-controller.d.ts +0 -6
- package/lib/base-classes/base-controller.js +0 -8
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/base-classes/base-injector.d.ts +4 -5
- package/lib/base-classes/base-injector.js +6 -7
- package/lib/base-classes/base-injector.js.map +1 -1
- package/lib/base-classes/base-middleware.d.ts +20 -0
- package/lib/base-classes/base-middleware.js +13 -0
- package/lib/base-classes/base-middleware.js.map +1 -0
- package/lib/base-classes/base.d.ts +3 -0
- package/lib/base-classes/base.js +2 -0
- package/lib/base-classes/base.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/constants.d.ts +1 -1
- package/lib/constants.js +2 -3
- package/lib/constants.js.map +1 -1
- package/lib/create-context.d.ts +4 -2
- package/lib/create-context.js +40 -36
- package/lib/create-context.js.map +1 -1
- package/lib/decorators/classes/middleware-decorator.d.ts +7 -0
- package/lib/decorators/classes/middleware-decorator.js +21 -0
- package/lib/decorators/classes/middleware-decorator.js.map +1 -0
- package/lib/decorators/classes/provider-decorator.js +1 -1
- package/lib/decorators/classes/provider-decorator.js.map +1 -1
- package/lib/endpoint-context.d.ts +6 -5
- package/lib/endpoint-context.js +79 -29
- package/lib/endpoint-context.js.map +1 -1
- package/lib/env/env.angular-node-app.d.ts +1 -0
- package/lib/env/env.angular-node-app.js +3 -2
- package/lib/env/env.angular-node-app.js.map +1 -1
- package/lib/env/env.docs-webapp.d.ts +1 -0
- package/lib/env/env.docs-webapp.js +3 -2
- package/lib/env/env.docs-webapp.js.map +1 -1
- package/lib/env/env.electron-app.d.ts +1 -0
- package/lib/env/env.electron-app.js +3 -2
- package/lib/env/env.electron-app.js.map +1 -1
- package/lib/env/env.mobile-app.d.ts +1 -0
- package/lib/env/env.mobile-app.js +3 -2
- package/lib/env/env.mobile-app.js.map +1 -1
- package/lib/env/env.npm-lib-and-cli-tool.d.ts +1 -0
- package/lib/env/env.npm-lib-and-cli-tool.js +3 -2
- package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
- package/lib/env/env.vscode-plugin.d.ts +1 -0
- package/lib/env/env.vscode-plugin.js +3 -2
- package/lib/env/env.vscode-plugin.js.map +1 -1
- package/lib/env.js +1 -5
- package/lib/env.js.map +1 -1
- package/lib/index.d.ts +8 -2
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +65 -5
- package/lib/models.js +7 -5
- package/lib/models.js.map +1 -1
- package/lib/storage.d.ts +1 -1
- package/lib/storage.js +1 -5
- package/lib/storage.js.map +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/package.json +1 -1
- package/websql/fesm2022/taon.mjs +168 -78
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-context.d.ts +1 -0
- package/websql/lib/base-classes/base-controller.d.ts +0 -6
- package/websql/lib/base-classes/base-injector.d.ts +4 -5
- package/websql/lib/base-classes/base-middleware.d.ts +21 -0
- package/websql/lib/base-classes/base.d.ts +3 -0
- package/websql/lib/constants.d.ts +1 -1
- package/websql/lib/create-context.d.ts +4 -2
- package/websql/lib/decorators/classes/middleware-decorator.d.ts +8 -0
- package/websql/lib/endpoint-context.d.ts +6 -5
- package/websql/lib/index.d.ts +8 -2
- package/websql/lib/models.d.ts +65 -5
- package/websql/package.json +1 -1
- package/lib/base-classes/base-subscriber.d.ts +0 -4
- package/lib/base-classes/base-subscriber.js +0 -25
- package/lib/base-classes/base-subscriber.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.d.ts +0 -10
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.js +0 -214
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.d.ts +0 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js +0 -5
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +0 -22
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js +0 -139
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +0 -16
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js +0 -68
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +0 -10
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js +0 -56
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +0 -10
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js +0 -50
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +0 -13
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js +0 -3
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +0 -2
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js +0 -6
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +0 -16
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js +0 -54
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +0 -17
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js +0 -52
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +0 -11
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js +0 -39
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +0 -13
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js +0 -46
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +0 -11
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js +0 -3
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js.map +0 -1
- package/lib/ui/directives/firedev-inject-html.directive.d.ts +0 -6
- package/lib/ui/directives/firedev-long-press.directive.d.ts +0 -22
- package/lib/ui/directives/index.d.ts +0 -3
- package/lib/ui/directives/index.js +0 -5
- package/lib/ui/directives/index.js.map +0 -1
- package/lib/ui/directives/safe.pipe.d.ts +0 -7
- package/lib/ui/directives/taon-inject-html.directive.d.ts +0 -6
- package/lib/ui/directives/taon-long-press.directive.d.ts +0 -22
- package/lib/ui/directives/view-mode.d.ts +0 -5
- package/lib/ui/directives/view-mode.js +0 -10
- package/lib/ui/directives/view-mode.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.component.d.ts +0 -29
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.module.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.d.ts +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/taon-db-admin.component.d.ts +0 -8
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.component.d.ts +0 -13
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.module.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +0 -5
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js +0 -3
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +0 -14
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +0 -43
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.module.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.d.ts +0 -5
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js +0 -3
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +0 -1
- package/lib/ui/taon-full-material.module.d.ts +0 -5
- package/lib/ui/taon-github-fork-me-corner/index.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-corner/index.js +0 -5
- package/lib/ui/taon-github-fork-me-corner/index.js.map +0 -1
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.d.ts +0 -3
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-ribbon/index.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-ribbon/index.js +0 -5
- package/lib/ui/taon-github-fork-me-ribbon/index.js.map +0 -1
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.component.d.ts +0 -3
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.module.d.ts +0 -2
- package/lib/ui/taon-notifications/index.d.ts +0 -4
- package/lib/ui/taon-notifications/index.js +0 -24
- package/lib/ui/taon-notifications/index.js.map +0 -1
- package/lib/ui/taon-notifications/taon-notifications.component.d.ts +0 -9
- package/lib/ui/taon-notifications/taon-notifications.models.d.ts +0 -6
- package/lib/ui/taon-notifications/taon-notifications.models.js +0 -5
- package/lib/ui/taon-notifications/taon-notifications.models.js.map +0 -1
- package/lib/ui/taon-notifications/taon-notifications.module.d.ts +0 -2
- package/lib/ui/taon-notifications/taon-notifications.service.d.ts +0 -11
- package/lib/ui/taon-progress-bar/index.d.ts +0 -2
- package/lib/ui/taon-progress-bar/index.js +0 -5
- package/lib/ui/taon-progress-bar/index.js.map +0 -1
- package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +0 -13
- package/lib/ui/taon-progress-bar/taon-progress-bar.module.d.ts +0 -2
- package/lib/ui/taon-session-passcode/index.d.ts +0 -1
- package/lib/ui/taon-session-passcode/index.js +0 -5
- package/lib/ui/taon-session-passcode/index.js.map +0 -1
- package/lib/ui/taon-session-passcode/taon-session-passcode.component.d.ts +0 -35
- package/lib/ui/taon-table/index.d.ts +0 -2
- package/lib/ui/taon-table/index.js +0 -5
- package/lib/ui/taon-table/index.js.map +0 -1
- package/lib/ui/taon-table/taon-table.component.d.ts +0 -34
- package/lib/ui/taon-table/taon-table.module.d.ts +0 -2
- package/lib/ui/taon.models.d.ts +0 -11
- package/lib/ui/taon.models.js +0 -3
- package/lib/ui/taon.models.js.map +0 -1
- package/lib/ui/toan-full-material.module.d.ts +0 -2
- package/tmp-environment.json +0 -43
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { BaseInjector } from './base-injector';
|
|
3
3
|
export declare class BaseController extends BaseInjector {
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated use migration instead
|
|
6
|
-
* THIS ONLY WORKS IF NO MIGRATIONS PROVIDED IN CONFIG
|
|
7
|
-
* Purpose: init example data for db.
|
|
8
|
-
*/
|
|
9
|
-
initExampleDbData(): Promise<any>;
|
|
10
4
|
}
|
|
@@ -53,14 +53,13 @@ export declare class BaseInjector {
|
|
|
53
53
|
*/
|
|
54
54
|
injectCtrl<T>(ctor: new (...args: any[]) => T): T;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* inject middleware for context
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
injectMiddleware<T>(ctor: new (...args: any[]) => T): T;
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
61
|
-
* TODO
|
|
60
|
+
* inject provider for context
|
|
62
61
|
*/
|
|
63
|
-
|
|
62
|
+
injectProvider<T>(ctor: new (...args: any[]) => T): T;
|
|
64
63
|
/**
|
|
65
64
|
* Inject: Controllers, Providers, Repositories, Services, etc.
|
|
66
65
|
* TODO addd nest js injecting
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
3
|
+
import type express from 'express';
|
|
4
|
+
import { BaseInjector } from './base-injector';
|
|
5
|
+
export interface TaonMiddlewareInterceptOptions {
|
|
6
|
+
client?: {
|
|
7
|
+
req: AxiosRequestConfig<unknown>;
|
|
8
|
+
} | undefined;
|
|
9
|
+
server?: {
|
|
10
|
+
req: express.Request;
|
|
11
|
+
res: express.Response;
|
|
12
|
+
} | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* TODO
|
|
16
|
+
* - global provider available in all contexts
|
|
17
|
+
* - provider available in own context
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class BaseMiddleware extends BaseInjector {
|
|
20
|
+
abstract intercept({ server, client, }: TaonMiddlewareInterceptOptions): Promise<void>;
|
|
21
|
+
}
|
|
@@ -6,6 +6,7 @@ import * as controller from './base-controller';
|
|
|
6
6
|
import * as crudController from './base-crud-controller';
|
|
7
7
|
import * as customRepository from './base-custom-repository';
|
|
8
8
|
import * as entity from './base-entity';
|
|
9
|
+
import * as baseMiddleware from './base-middleware';
|
|
9
10
|
import * as baseMigration from './base-migration';
|
|
10
11
|
import * as provider from './base-provider';
|
|
11
12
|
import * as repository from './base-repository';
|
|
@@ -22,6 +23,7 @@ export declare namespace Base {
|
|
|
22
23
|
export import CustomRepository = customRepository.BaseCustomRepository;
|
|
23
24
|
export import SubscriberForEntity = baseSubscriberEntity.BaseSubscriberForEntity;
|
|
24
25
|
export import Migration = baseMigration.BaseMigration;
|
|
26
|
+
export import Middleware = baseMiddleware.BaseMiddleware;
|
|
25
27
|
export import AngularService = baseService.BaseAngularsService;
|
|
26
28
|
const Context: {
|
|
27
29
|
types: {
|
|
@@ -30,6 +32,7 @@ export declare namespace Base {
|
|
|
30
32
|
readonly providers: any;
|
|
31
33
|
readonly subscribers: any;
|
|
32
34
|
readonly migrations: any;
|
|
35
|
+
readonly middlewares: any;
|
|
33
36
|
};
|
|
34
37
|
readonly contexts: any;
|
|
35
38
|
readonly contextName: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
export type TaonEntityKeysToOmit = 'ctrl' | 'clone' | '__endpoint_context__' | 'ctx' | 'inject' | '_' | 'relation' | 'relations' | 'inject' | 'injectRepo' | 'injectCustomRepository' | 'injectCustomRepo' | 'injectController' | 'injectCtrl' | '
|
|
2
|
+
export type TaonEntityKeysToOmit = 'ctrl' | 'clone' | '__endpoint_context__' | 'ctx' | 'inject' | '_' | 'relation' | 'relations' | 'inject' | 'injectRepo' | 'injectCustomRepository' | 'injectCustomRepo' | 'injectController' | 'injectCtrl' | 'injectProvider' | 'injectMiddleware';
|
|
3
3
|
export declare const TaonEntityKeysToOmitArr: TaonEntityKeysToOmit[];
|
|
4
4
|
import { InjectionToken } from '@angular/core';
|
|
5
5
|
import type { TaonContext } from './create-context';
|
|
@@ -6,13 +6,14 @@ import { Models } from './models';
|
|
|
6
6
|
* Context function can be used to dynamically
|
|
7
7
|
* create context with specific configuration.
|
|
8
8
|
*/
|
|
9
|
-
export declare const createContextTemplate: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION>) => () => {
|
|
9
|
+
export declare const createContextTemplate: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>, MIDDLEWARE extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION, MIDDLEWARE>) => () => {
|
|
10
10
|
types: {
|
|
11
11
|
readonly controllers: any;
|
|
12
12
|
readonly repositories: any;
|
|
13
13
|
readonly providers: any;
|
|
14
14
|
readonly subscribers: any;
|
|
15
15
|
readonly migrations: any;
|
|
16
|
+
readonly middlewares: any;
|
|
16
17
|
};
|
|
17
18
|
readonly contexts: any;
|
|
18
19
|
readonly contextName: string;
|
|
@@ -52,13 +53,14 @@ export declare const createContextTemplate: <CTX extends Record<string, object>,
|
|
|
52
53
|
* REQURIED PROPERTY:
|
|
53
54
|
* - contextName
|
|
54
55
|
*/
|
|
55
|
-
export declare const createContext: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION>) => {
|
|
56
|
+
export declare const createContext: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>, MIDDLEWARES extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION, MIDDLEWARES>) => {
|
|
56
57
|
types: {
|
|
57
58
|
readonly controllers: any;
|
|
58
59
|
readonly repositories: any;
|
|
59
60
|
readonly providers: any;
|
|
60
61
|
readonly subscribers: any;
|
|
61
62
|
readonly migrations: any;
|
|
63
|
+
readonly middlewares: any;
|
|
62
64
|
};
|
|
63
65
|
readonly contexts: any;
|
|
64
66
|
readonly contextName: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { Models } from '../../models';
|
|
3
|
+
/**
|
|
4
|
+
* Provider decorator
|
|
5
|
+
*/
|
|
6
|
+
export declare function TaonMiddleware<T = any>(options?: TaonMiddlewareOptions<T>): (constructor: Function) => void;
|
|
7
|
+
export declare class TaonMiddlewareOptions<T = any> extends Models.DecoratorAbstractOpt {
|
|
8
|
+
}
|
|
@@ -5,6 +5,7 @@ import type { Application } from 'express';
|
|
|
5
5
|
import type { Repository } from 'taon-typeorm/websql';
|
|
6
6
|
import { DataSource } from 'taon-typeorm/websql';
|
|
7
7
|
import type { BaseInjector } from './base-classes/base-injector';
|
|
8
|
+
export type { TaonMiddlewareInterceptOptions } from './base-classes/base-middleware';
|
|
8
9
|
import { ContextDbMigrations } from './context-db-migrations';
|
|
9
10
|
import { Models } from './models';
|
|
10
11
|
export declare class EndpointContext {
|
|
@@ -55,7 +56,7 @@ export declare class EndpointContext {
|
|
|
55
56
|
/**
|
|
56
57
|
* available after init()
|
|
57
58
|
*/
|
|
58
|
-
config: Models.ContextOptions<any, any, any, any, any, any, any>;
|
|
59
|
+
config: Models.ContextOptions<any, any, any, any, any, any, any, any>;
|
|
59
60
|
get logHttp(): boolean;
|
|
60
61
|
get logRealtime(): boolean;
|
|
61
62
|
get logFramework(): boolean;
|
|
@@ -65,7 +66,7 @@ export declare class EndpointContext {
|
|
|
65
66
|
* Inside docker there is not need for https secure server
|
|
66
67
|
*/
|
|
67
68
|
private isRunningInsideDocker;
|
|
68
|
-
constructor(originalConfig: Models.ContextOptions<any, any, any, any, any, any, any>, configFn: (env: any) => Models.ContextOptions<any, any, any, any, any, any, any>);
|
|
69
|
+
constructor(originalConfig: Models.ContextOptions<any, any, any, any, any, any, any, any>, configFn: (env: any) => Models.ContextOptions<any, any, any, any, any, any, any, any>);
|
|
69
70
|
init(options?: {
|
|
70
71
|
initFromRecrusiveContextResovle?: boolean;
|
|
71
72
|
overrideHost?: string | null;
|
|
@@ -99,13 +100,12 @@ export declare class EndpointContext {
|
|
|
99
100
|
isCLassType(classType: Models.ClassType, classFn: Function): boolean;
|
|
100
101
|
/**
|
|
101
102
|
* Only for injectable types
|
|
102
|
-
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER
|
|
103
|
+
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER, MIDDLEWARES
|
|
103
104
|
*/
|
|
104
105
|
getClassFunByClassName(className: string): Function;
|
|
105
106
|
getClassFunByClass(classFunction: Function): Function;
|
|
106
107
|
getClassFunByArr(classType: Models.ClassType): Function[];
|
|
107
108
|
private createInstances;
|
|
108
|
-
reinitControllers(): Promise<void>;
|
|
109
109
|
initClasses(): Promise<void>;
|
|
110
110
|
isActiveOn(classInstance: object): boolean;
|
|
111
111
|
get frontendHostUri(): URL;
|
|
@@ -158,7 +158,8 @@ export declare class EndpointContext {
|
|
|
158
158
|
initControllers(): Promise<void>;
|
|
159
159
|
writeActiveRoutes(): void;
|
|
160
160
|
get middlewares(): Models.MiddlewareType[];
|
|
161
|
-
private
|
|
161
|
+
private initFrontnedMiddlewares;
|
|
162
|
+
private initBackendMiddlewares;
|
|
162
163
|
private initServer;
|
|
163
164
|
/**
|
|
164
165
|
* client can be browser or nodejs (when remote host)
|
package/websql/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { NgZone } from '@angular/core';
|
|
|
4
4
|
import * as base from './base-classes/base';
|
|
5
5
|
import * as controllerDecorator from './decorators/classes/controller-decorator';
|
|
6
6
|
import * as entityDecorator from './decorators/classes/entity-decorator';
|
|
7
|
+
import * as middlewareDecorator from './decorators/classes/middleware-decorator';
|
|
7
8
|
import * as migrationDecorator from './decorators/classes/migration-decorator';
|
|
8
9
|
import * as providerDecorator from './decorators/classes/provider-decorator';
|
|
9
10
|
import * as repositoryDecorator from './decorators/classes/repository-decorator';
|
|
@@ -27,6 +28,7 @@ export { inject } from './inject';
|
|
|
27
28
|
export { Models } from './models';
|
|
28
29
|
export * from './constants';
|
|
29
30
|
export { ClassHelpers } from './helpers/class-helpers';
|
|
31
|
+
export type { TaonMiddlewareInterceptOptions } from './base-classes/base-middleware';
|
|
30
32
|
export declare namespace Taon {
|
|
31
33
|
export import Response = models.Models.Http.Response;
|
|
32
34
|
export import Http = http.Http;
|
|
@@ -43,17 +45,19 @@ export declare namespace Taon {
|
|
|
43
45
|
export import Repository = repositoryDecorator.TaonRepository;
|
|
44
46
|
export import Subscriber = subscriberDecorator.TaonSubscriber;
|
|
45
47
|
export import Migration = migrationDecorator.TaonMigration;
|
|
48
|
+
export import Middleware = middlewareDecorator.TaonMiddleware;
|
|
46
49
|
const isBrowser: boolean;
|
|
47
50
|
const isNode: boolean;
|
|
48
51
|
const isWebSQL: boolean;
|
|
49
52
|
const isElectron: boolean;
|
|
50
|
-
const createContext: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => models.Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION>) => {
|
|
53
|
+
const createContext: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>, MIDDLEWARES extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => models.Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION, MIDDLEWARES>) => {
|
|
51
54
|
types: {
|
|
52
55
|
readonly controllers: any;
|
|
53
56
|
readonly repositories: any;
|
|
54
57
|
readonly providers: any;
|
|
55
58
|
readonly subscribers: any;
|
|
56
59
|
readonly migrations: any;
|
|
60
|
+
readonly middlewares: any;
|
|
57
61
|
};
|
|
58
62
|
readonly contexts: any;
|
|
59
63
|
readonly contextName: string;
|
|
@@ -73,13 +77,14 @@ export declare namespace Taon {
|
|
|
73
77
|
readonly server: import("./realtime/realtime-server").RealtimeServer;
|
|
74
78
|
};
|
|
75
79
|
};
|
|
76
|
-
const createContextTemplate: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => models.Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION>) => () => {
|
|
80
|
+
const createContextTemplate: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>, MIDDLEWARE extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => models.Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION, MIDDLEWARE>) => () => {
|
|
77
81
|
types: {
|
|
78
82
|
readonly controllers: any;
|
|
79
83
|
readonly repositories: any;
|
|
80
84
|
readonly providers: any;
|
|
81
85
|
readonly subscribers: any;
|
|
82
86
|
readonly migrations: any;
|
|
87
|
+
readonly middlewares: any;
|
|
83
88
|
};
|
|
84
89
|
readonly contexts: any;
|
|
85
90
|
readonly contextName: string;
|
|
@@ -117,6 +122,7 @@ export declare namespace Taon {
|
|
|
117
122
|
readonly providers: any;
|
|
118
123
|
readonly subscribers: any;
|
|
119
124
|
readonly migrations: any;
|
|
125
|
+
readonly middlewares: any;
|
|
120
126
|
};
|
|
121
127
|
readonly contexts: any;
|
|
122
128
|
readonly contextName: string;
|
package/websql/lib/models.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import { CoreModels } from 'tnp-core/websql';
|
|
3
2
|
import { RequestHandler } from 'express';
|
|
4
3
|
import { Response as ExpressResponse, Request as ExpressRequest } from 'express';
|
|
5
4
|
import { Models as ModelsNg2Rest } from 'ng2-rest/websql';
|
|
5
|
+
import { CoreModels } from 'tnp-core/websql';
|
|
6
6
|
export declare namespace Models {
|
|
7
7
|
type FrameworkMode = 'backend-frontend(tcp+udp)' | 'remote-backend(tcp+udp)' | 'backend-frontend(ipc-electron)' | 'backend-frontend(websql-electron)' | 'backend-frontend(websql)';
|
|
8
8
|
enum ClassType {
|
|
@@ -11,9 +11,10 @@ export declare namespace Models {
|
|
|
11
11
|
REPOSITORY = "REPOSITORY",
|
|
12
12
|
PROVIDER = "PROVIDER",
|
|
13
13
|
SUBSCRIBER = "SUBSCRIBER",
|
|
14
|
-
MIGRATION = "MIGRATION"
|
|
14
|
+
MIGRATION = "MIGRATION",
|
|
15
|
+
MIDDLEWARE = "MIDDLEWARE"
|
|
15
16
|
}
|
|
16
|
-
const ClassTypeKey: { [key in ClassType]: keyof ContextOptions<any, any, any, any, any, any, any>; };
|
|
17
|
+
const ClassTypeKey: { [key in ClassType]: keyof ContextOptions<any, any, any, any, any, any, any, any>; };
|
|
17
18
|
type MiddlewareType = [Function, any[]];
|
|
18
19
|
/**
|
|
19
20
|
* DROP_DB+MIGRATIONS (default for development)
|
|
@@ -82,7 +83,7 @@ export declare namespace Models {
|
|
|
82
83
|
db?: boolean;
|
|
83
84
|
migrations?: boolean;
|
|
84
85
|
};
|
|
85
|
-
interface ContextOptions<CONTEXTS, CONTROLLERS, ENTITIES, REPOSITORIES, PROVIDERS, SUBSCRIBERS, MIGRATIONS> {
|
|
86
|
+
interface ContextOptions<CONTEXTS, CONTROLLERS, ENTITIES, REPOSITORIES, PROVIDERS, SUBSCRIBERS, MIGRATIONS, MIDDLEWARES> {
|
|
86
87
|
appId?: string;
|
|
87
88
|
contextName: string;
|
|
88
89
|
/**
|
|
@@ -123,29 +124,88 @@ export declare namespace Models {
|
|
|
123
124
|
* Default: true
|
|
124
125
|
*/
|
|
125
126
|
useIpcWhenElectron?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* taon contexts here
|
|
129
|
+
* (module like structure)
|
|
130
|
+
*/
|
|
126
131
|
contexts?: CONTEXTS;
|
|
132
|
+
/**
|
|
133
|
+
* taon controller here
|
|
134
|
+
* (glue between frontend and backend)
|
|
135
|
+
*/
|
|
127
136
|
controllers?: CONTROLLERS;
|
|
137
|
+
/**
|
|
138
|
+
* taon entities
|
|
139
|
+
* (entities are used to create tables in db)
|
|
140
|
+
*/
|
|
128
141
|
entities?: ENTITIES;
|
|
142
|
+
/**
|
|
143
|
+
* taon repositories
|
|
144
|
+
* (repositories are used to access data from db)
|
|
145
|
+
*/
|
|
129
146
|
repositories?: REPOSITORIES;
|
|
147
|
+
/**
|
|
148
|
+
* taon providers
|
|
149
|
+
* (context singletons)
|
|
150
|
+
*/
|
|
130
151
|
providers?: PROVIDERS;
|
|
152
|
+
/**
|
|
153
|
+
* taon subscribers
|
|
154
|
+
* (subscribers are used to listen to db events)
|
|
155
|
+
*/
|
|
131
156
|
subscribers?: SUBSCRIBERS;
|
|
157
|
+
/**
|
|
158
|
+
* taon migrations
|
|
159
|
+
* (migrations are used to update db schema and achieve proper CI/CD)
|
|
160
|
+
*/
|
|
132
161
|
migrations?: MIGRATIONS;
|
|
162
|
+
/**
|
|
163
|
+
* taon middlewares
|
|
164
|
+
* middlewares are used to intercept requests
|
|
165
|
+
* and responses in the context
|
|
166
|
+
*/
|
|
167
|
+
middlewares?: MIDDLEWARES;
|
|
168
|
+
/**
|
|
169
|
+
* Config for express session
|
|
170
|
+
*/
|
|
133
171
|
session?: ISession;
|
|
172
|
+
/**
|
|
173
|
+
* taon is not going to write .rest files to cwd()
|
|
174
|
+
*/
|
|
134
175
|
skipWritingServerRoutes?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* TODO - this is still in progress
|
|
178
|
+
* @deprecated
|
|
179
|
+
*/
|
|
135
180
|
productionMode?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* If you want your context to never be started as separated server
|
|
183
|
+
* use abstract: true
|
|
184
|
+
* @default: false
|
|
185
|
+
*/
|
|
136
186
|
abstract?: boolean;
|
|
137
187
|
logs?: boolean | ConnectionOptionsLogs;
|
|
138
188
|
database?: boolean | Partial<DatabaseConfig>;
|
|
189
|
+
/**
|
|
190
|
+
* disable default realtime communication through TCP upgrade sockets
|
|
191
|
+
*/
|
|
139
192
|
disabledRealtime?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Will be removed soon - cloud will handle certs and https
|
|
195
|
+
* @deprecated
|
|
196
|
+
*/
|
|
140
197
|
https?: {
|
|
141
198
|
key: string;
|
|
142
199
|
cert: string;
|
|
143
200
|
};
|
|
201
|
+
/**
|
|
202
|
+
* TODO - will be removed soon
|
|
203
|
+
* @deprecated
|
|
204
|
+
*/
|
|
144
205
|
publicAssets?: {
|
|
145
206
|
serverPath: string;
|
|
146
207
|
locationOnDisk: string;
|
|
147
208
|
}[];
|
|
148
|
-
middlewares?: MiddlewareType[];
|
|
149
209
|
}
|
|
150
210
|
class DecoratorAbstractOpt {
|
|
151
211
|
className: string;
|
package/websql/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseSubscriber = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var base_injector_1 = require("./base-injector");
|
|
6
|
-
var subscriber_decorator_1 = require("../decorators/classes/subscriber-decorator");
|
|
7
|
-
var BaseSubscriber = /** @class */ (function (_super) {
|
|
8
|
-
tslib_1.__extends(BaseSubscriber, _super);
|
|
9
|
-
function BaseSubscriber() {
|
|
10
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
11
|
-
}
|
|
12
|
-
BaseSubscriber.prototype.__trigger_event__ = function (eventName) {
|
|
13
|
-
var ctx = this.__endpoint_context__;
|
|
14
|
-
console.log('Trigger event', eventName, ctx);
|
|
15
|
-
// ctx.realtimeServer.triggerCustomEvent/
|
|
16
|
-
};
|
|
17
|
-
BaseSubscriber = tslib_1.__decorate([
|
|
18
|
-
(0, subscriber_decorator_1.TaonSubscriber)({
|
|
19
|
-
className: 'BaseSubscriber',
|
|
20
|
-
})
|
|
21
|
-
], BaseSubscriber);
|
|
22
|
-
return BaseSubscriber;
|
|
23
|
-
}(base_injector_1.BaseInjector));
|
|
24
|
-
exports.BaseSubscriber = BaseSubscriber;
|
|
25
|
-
//# sourceMappingURL=base-subscriber.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-subscriber.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;;AAWA,iDAA+C;AAC/C,mFAA4E;AAK5E;IAA2D,0CAAY;IAAvE;;IAMA,CAAC;IALW,0CAAiB,GAA3B,UAA4B,SAAuB;QACjD,IAAM,GAAG,GAAG,IAAI,CAAC,oBAAoB,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QAC7C,yCAAyC;IAC3C,CAAC;IALmB,cAAc;QAHnC,IAAA,qCAAc,EAAC;YACd,SAAS,EAAE,gBAAgB;SAC5B,CAAC;OACoB,cAAc,CAMnC;IAAD,qBAAC;CAAA,AAND,CAA2D,4BAAY,GAMtE;AANqB,wCAAc"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RealtimeStrategy } from './realtime-strategy';
|
|
2
|
-
/**
|
|
3
|
-
* Purpose:
|
|
4
|
-
* - browser-browser communication mock (in websql mode)
|
|
5
|
-
*/
|
|
6
|
-
export declare class RealtimeAbstractMock extends RealtimeStrategy {
|
|
7
|
-
toString(): string;
|
|
8
|
-
get Server(): any;
|
|
9
|
-
get io(): any;
|
|
10
|
-
}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// BIG TODO: Implement the following classes and interfaces
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.RealtimeAbstractMock = void 0;
|
|
5
|
-
var tslib_1 = require("tslib");
|
|
6
|
-
var realtime_strategy_1 = require("./realtime-strategy");
|
|
7
|
-
var rxjs_1 = require("rxjs");
|
|
8
|
-
var messagesFromClientToServer = new rxjs_1.Subject();
|
|
9
|
-
var messagesServerToClient = new rxjs_1.Subject();
|
|
10
|
-
//#endregion
|
|
11
|
-
var AbstractServer = /** @class */ (function () {
|
|
12
|
-
function AbstractServer(url) {
|
|
13
|
-
this.url = url;
|
|
14
|
-
this.namespaceByName = new Map();
|
|
15
|
-
AbstractServer.serverByUrl.set(url, this);
|
|
16
|
-
}
|
|
17
|
-
Object.defineProperty(AbstractServer.prototype, "AbstractNamespace", {
|
|
18
|
-
get: function () {
|
|
19
|
-
return AbstractNamespace;
|
|
20
|
-
},
|
|
21
|
-
enumerable: false,
|
|
22
|
-
configurable: true
|
|
23
|
-
});
|
|
24
|
-
AbstractServer.prototype.of = function (namespaceName) {
|
|
25
|
-
if (!this.namespaceByName.has(namespaceName)) {
|
|
26
|
-
this.namespaceByName.set(namespaceName, new this.AbstractNamespace(namespaceName, this.url));
|
|
27
|
-
}
|
|
28
|
-
return this.namespaceByName.get(namespaceName);
|
|
29
|
-
};
|
|
30
|
-
AbstractServer.serverByUrl = new Map();
|
|
31
|
-
return AbstractServer;
|
|
32
|
-
}());
|
|
33
|
-
/**
|
|
34
|
-
* A namespace is a collection of sockets that share a common name.
|
|
35
|
-
* Namespace are on the "server" side, and sockets are on the "client" side.
|
|
36
|
-
*/
|
|
37
|
-
var AbstractNamespace = /** @class */ (function () {
|
|
38
|
-
function AbstractNamespace(
|
|
39
|
-
/**
|
|
40
|
-
* unique namespace name
|
|
41
|
-
*/
|
|
42
|
-
name, url) {
|
|
43
|
-
this.name = name;
|
|
44
|
-
this.url = url;
|
|
45
|
-
this.allNamespaceSockets = [];
|
|
46
|
-
this.socketByRoomName = new Map();
|
|
47
|
-
this.namespaceEventHandlers = new Map();
|
|
48
|
-
this.startListeningServer();
|
|
49
|
-
}
|
|
50
|
-
AbstractNamespace.prototype.handleRawClientMessage = function (msg) {
|
|
51
|
-
var _a;
|
|
52
|
-
var data = msg.data, eventName = msg.eventName, namespace = msg.namespace, url = msg.url, roomName = msg.roomName, client = msg.client;
|
|
53
|
-
if (this.url !== url) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (this.name !== namespace) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (this.shouldAutomaticHandleEvent(eventName)) {
|
|
60
|
-
this.emit.apply(this, tslib_1.__spreadArray([eventName], tslib_1.__read(data), false));
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
var roomNameFromEvent = this.getRoomNameFromMessage(eventName);
|
|
64
|
-
if (this.isRoomJoinMessage(eventName)) {
|
|
65
|
-
this.socketByRoomName.set(roomNameFromEvent, client);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (this.isRoomLeaveMessage(eventName)) {
|
|
69
|
-
this.socketByRoomName.delete(roomNameFromEvent);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
var namespaceInstance = this;
|
|
73
|
-
if (namespaceInstance) {
|
|
74
|
-
if (roomName) {
|
|
75
|
-
(_a = namespaceInstance.socketByRoomName
|
|
76
|
-
.get(roomName)) === null || _a === void 0 ? void 0 : _a.emit.apply(_a, tslib_1.__spreadArray([eventName], tslib_1.__read(data), false));
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
namespaceInstance.emit.apply(namespaceInstance, tslib_1.__spreadArray([eventName], tslib_1.__read(data), false));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
AbstractNamespace.prototype.startListeningServer = function () {
|
|
84
|
-
var _this = this;
|
|
85
|
-
messagesFromClientToServer.subscribe(function (data) { return _this.handleRawClientMessage(data); });
|
|
86
|
-
};
|
|
87
|
-
//#region on
|
|
88
|
-
AbstractNamespace.prototype.on = function (eventName, handler) {
|
|
89
|
-
this.namespaceEventHandlers.set(eventName, handler);
|
|
90
|
-
};
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region emit
|
|
93
|
-
AbstractNamespace.prototype.emit = function (eventName) {
|
|
94
|
-
var e_1, _a;
|
|
95
|
-
var _b;
|
|
96
|
-
var args = [];
|
|
97
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
98
|
-
args[_i - 1] = arguments[_i];
|
|
99
|
-
}
|
|
100
|
-
(_b = this.namespaceEventHandlers.get(eventName)) === null || _b === void 0 ? void 0 : _b.apply(void 0, tslib_1.__spreadArray([], tslib_1.__read(args), false));
|
|
101
|
-
try {
|
|
102
|
-
for (var _c = tslib_1.__values(this.allNamespaceSockets), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
103
|
-
var socket = _d.value;
|
|
104
|
-
socket.emit.apply(socket, tslib_1.__spreadArray([eventName], tslib_1.__read(args), false));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
108
|
-
finally {
|
|
109
|
-
try {
|
|
110
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
111
|
-
}
|
|
112
|
-
finally { if (e_1) throw e_1.error; }
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
//#endregion
|
|
116
|
-
AbstractNamespace.prototype.connect = function (socket) {
|
|
117
|
-
this.allNamespaceSockets.push(socket);
|
|
118
|
-
socket.namespaceInstance = this;
|
|
119
|
-
};
|
|
120
|
-
AbstractNamespace.prototype.isRoomJoinMessage = function (eventName) {
|
|
121
|
-
throw new Error('Method not implemented.');
|
|
122
|
-
};
|
|
123
|
-
AbstractNamespace.prototype.isRoomLeaveMessage = function (eventName) {
|
|
124
|
-
throw new Error('Method not implemented.');
|
|
125
|
-
};
|
|
126
|
-
AbstractNamespace.prototype.getRoomNameFromMessage = function (eventName) {
|
|
127
|
-
throw new Error('Method not implemented.');
|
|
128
|
-
};
|
|
129
|
-
AbstractNamespace.prototype.shouldAutomaticHandleEvent = function (event) {
|
|
130
|
-
throw new Error('Method not implemented.');
|
|
131
|
-
};
|
|
132
|
-
return AbstractNamespace;
|
|
133
|
-
}());
|
|
134
|
-
/**
|
|
135
|
-
* Client starts a connection to the server with socket
|
|
136
|
-
*/
|
|
137
|
-
var AbstractSocket = /** @class */ (function () {
|
|
138
|
-
function AbstractSocket(url, opts) {
|
|
139
|
-
this.eventHandlers = new Map();
|
|
140
|
-
// @ts-ignore
|
|
141
|
-
var _a = tslib_1.__read([url, opts.path || '/'], 2), __ = _a[0], namespace = _a[1];
|
|
142
|
-
// console.log({ url, baseUrl, namespace });
|
|
143
|
-
var namespaceName = namespace || '/';
|
|
144
|
-
// Look up the server instance from the registry
|
|
145
|
-
var server = AbstractServer.serverByUrl.get(url);
|
|
146
|
-
if (!server) {
|
|
147
|
-
AbstractServer.serverByUrl.set(url, new AbstractServer(url));
|
|
148
|
-
server = AbstractServer.serverByUrl.get(url);
|
|
149
|
-
}
|
|
150
|
-
var namespaceFromServer = server.of(namespaceName);
|
|
151
|
-
namespaceFromServer.connect(this);
|
|
152
|
-
// TODO: @LAST listen to server messages
|
|
153
|
-
}
|
|
154
|
-
AbstractSocket.prototype.emit = function (eventName) {
|
|
155
|
-
var _a;
|
|
156
|
-
var args = [];
|
|
157
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
158
|
-
args[_i - 1] = arguments[_i];
|
|
159
|
-
}
|
|
160
|
-
(_a = this.eventHandlers.get(eventName)) === null || _a === void 0 ? void 0 : _a.apply(void 0, tslib_1.__spreadArray([], tslib_1.__read(args), false));
|
|
161
|
-
var msg = {
|
|
162
|
-
eventName: Array.isArray(eventName) ? eventName[0] : eventName,
|
|
163
|
-
url: this.namespaceInstance.url,
|
|
164
|
-
namespace: this.namespaceInstance.name,
|
|
165
|
-
roomName: Array.isArray(eventName) ? eventName[1] : void 0,
|
|
166
|
-
data: args,
|
|
167
|
-
client: this,
|
|
168
|
-
};
|
|
169
|
-
messagesFromClientToServer.next(msg);
|
|
170
|
-
};
|
|
171
|
-
AbstractSocket.prototype.on = function (eventName, handler) {
|
|
172
|
-
this.eventHandlers[eventName] = handler;
|
|
173
|
-
};
|
|
174
|
-
AbstractSocket.prototype.off = function (event) {
|
|
175
|
-
this.eventHandlers.delete(event);
|
|
176
|
-
};
|
|
177
|
-
return AbstractSocket;
|
|
178
|
-
}());
|
|
179
|
-
/**
|
|
180
|
-
* Purpose:
|
|
181
|
-
* - browser-browser communication mock (in websql mode)
|
|
182
|
-
*/
|
|
183
|
-
var RealtimeAbstractMock = /** @class */ (function (_super) {
|
|
184
|
-
tslib_1.__extends(RealtimeAbstractMock, _super);
|
|
185
|
-
function RealtimeAbstractMock() {
|
|
186
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
187
|
-
}
|
|
188
|
-
//#region toString
|
|
189
|
-
RealtimeAbstractMock.prototype.toString = function () {
|
|
190
|
-
return 'mock';
|
|
191
|
-
};
|
|
192
|
-
Object.defineProperty(RealtimeAbstractMock.prototype, "Server", {
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region server & io
|
|
195
|
-
get: function () {
|
|
196
|
-
return AbstractServer;
|
|
197
|
-
},
|
|
198
|
-
enumerable: false,
|
|
199
|
-
configurable: true
|
|
200
|
-
});
|
|
201
|
-
Object.defineProperty(RealtimeAbstractMock.prototype, "io", {
|
|
202
|
-
get: function () {
|
|
203
|
-
var clientIo = function (uri, opts) {
|
|
204
|
-
return new AbstractSocket(uri, opts);
|
|
205
|
-
};
|
|
206
|
-
return clientIo;
|
|
207
|
-
},
|
|
208
|
-
enumerable: false,
|
|
209
|
-
configurable: true
|
|
210
|
-
});
|
|
211
|
-
return RealtimeAbstractMock;
|
|
212
|
-
}(realtime_strategy_1.RealtimeStrategy));
|
|
213
|
-
exports.RealtimeAbstractMock = RealtimeAbstractMock;
|
|
214
|
-
//# sourceMappingURL=realtime-abstract-mock.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"realtime-abstract-mock.js","sourceRoot":"","sources":[""],"names":[],"mappings":";AAAA,2DAA2D;;;;AAG3D,yDAAuD;AACvD,6BAA+B;AAE/B,IAAM,0BAA0B,GAAG,IAAI,cAAO,EAAoB,CAAC;AACnE,IAAM,sBAAsB,GAAG,IAAI,cAAO,EAAoB,CAAC;AAc/D,YAAY;AAEZ;IAOE,wBAA4B,GAAW;QAAX,QAAG,GAAH,GA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