taon 19.0.66 → 19.0.67
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 +160 -160
- package/bin/start.js +281 -281
- 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 +272 -68
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-class.d.ts +8 -1
- package/browser/lib/base-classes/base-controller.d.ts +56 -4
- package/browser/lib/base-classes/base-crud-controller.d.ts +5 -4
- package/browser/lib/base-classes/base-repository.d.ts +3 -0
- package/browser/lib/config/method-config.d.ts +1 -0
- package/browser/lib/decorators/http/http-decorators.d.ts +2 -1
- package/browser/lib/decorators/http/http-methods-decorators.d.ts +35 -4
- package/browser/lib/endpoint-context.d.ts +3 -0
- package/browser/lib/get-response-value.d.ts +1 -1
- package/browser/lib/helpers/taon-helpers.d.ts +1 -0
- package/browser/lib/index.d.ts +4 -0
- package/browser/lib/models.d.ts +4 -10
- package/browser/lib/realtime/realtime-client.d.ts +18 -14
- package/browser/lib/realtime/realtime-server.d.ts +28 -3
- package/browser/lib/realtime/realtime.models.d.ts +15 -2
- package/browser/package.json +1 -1
- package/icon-menu-taon.svg +15 -15
- package/lib/base-classes/base-class.d.ts +8 -1
- package/lib/base-classes/base-class.js +20 -2
- package/lib/base-classes/base-class.js.map +1 -1
- package/lib/base-classes/base-controller.d.ts +57 -5
- package/lib/base-classes/base-controller.js +83 -12
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/base-classes/base-crud-controller.d.ts +5 -4
- package/lib/base-classes/base-crud-controller.js +16 -4
- package/lib/base-classes/base-crud-controller.js.map +1 -1
- package/lib/base-classes/base-repository.d.ts +3 -0
- package/lib/base-classes/base-repository.js +3 -0
- package/lib/base-classes/base-repository.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/config/method-config.d.ts +1 -0
- package/lib/config/method-config.js.map +1 -1
- package/lib/decorators/http/http-decorators.d.ts +2 -1
- package/lib/decorators/http/http-decorators.js +2 -1
- package/lib/decorators/http/http-decorators.js.map +1 -1
- package/lib/decorators/http/http-methods-decorators.d.ts +35 -4
- package/lib/decorators/http/http-methods-decorators.js +34 -1
- package/lib/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib/endpoint-context.d.ts +3 -0
- package/lib/endpoint-context.js +152 -122
- package/lib/endpoint-context.js.map +1 -1
- package/lib/get-response-value.d.ts +1 -1
- package/lib/get-response-value.js +0 -4
- package/lib/get-response-value.js.map +1 -1
- package/lib/helpers/taon-helpers.d.ts +1 -0
- package/lib/helpers/taon-helpers.js +6 -0
- package/lib/helpers/taon-helpers.js.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.js +8 -2
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +4 -10
- package/lib/models.js +5 -23
- package/lib/models.js.map +1 -1
- package/lib/realtime/realtime-client.d.ts +18 -14
- package/lib/realtime/realtime-client.js +33 -25
- package/lib/realtime/realtime-client.js.map +1 -1
- package/lib/realtime/realtime-server.d.ts +28 -3
- package/lib/realtime/realtime-server.js +28 -2
- package/lib/realtime/realtime-server.js.map +1 -1
- package/lib/realtime/realtime.models.d.ts +15 -2
- 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/README.md +24 -24
- package/websql/fesm2022/taon.mjs +273 -70
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-class.d.ts +8 -1
- package/websql/lib/base-classes/base-controller.d.ts +56 -4
- package/websql/lib/base-classes/base-crud-controller.d.ts +5 -4
- package/websql/lib/base-classes/base-repository.d.ts +3 -0
- package/websql/lib/config/method-config.d.ts +1 -0
- package/websql/lib/decorators/http/http-decorators.d.ts +2 -1
- package/websql/lib/decorators/http/http-methods-decorators.d.ts +35 -4
- package/websql/lib/endpoint-context.d.ts +3 -0
- package/websql/lib/get-response-value.d.ts +1 -1
- package/websql/lib/helpers/taon-helpers.d.ts +1 -0
- package/websql/lib/index.d.ts +4 -0
- package/websql/lib/models.d.ts +4 -10
- package/websql/lib/realtime/realtime-client.d.ts +18 -14
- package/websql/lib/realtime/realtime-server.d.ts +28 -3
- package/websql/lib/realtime/realtime.models.d.ts +15 -2
- package/websql/package.json +1 -1
|
@@ -5,5 +5,12 @@ export declare class BaseClass<CloneT extends BaseClass = any> {
|
|
|
5
5
|
* taon after class instance creation
|
|
6
6
|
*/
|
|
7
7
|
_(): Promise<void>;
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param overrideObjOrFn if object is provided it will override values in cloned object,
|
|
11
|
+
* if function is provided it will be called with old cloned values and should return
|
|
12
|
+
* object with values to override
|
|
13
|
+
* @returns cloned instance of the class
|
|
14
|
+
*/
|
|
15
|
+
clone(overrideObjOrFn?: Partial<CloneT> | ((oldValues: Partial<CloneT>) => Partial<CloneT>)): CloneT;
|
|
9
16
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
import { RestErrorResponseWrapper, HttpResponseError } from 'ng2-rest/websql';
|
|
2
3
|
import type { ContextsEndpointStorage } from '../endpoint-context-storage';
|
|
3
4
|
import type { Models } from '../models';
|
|
4
5
|
import { BaseInjector } from './base-injector';
|
|
@@ -13,7 +14,7 @@ export interface MulterFileUploadResponse {
|
|
|
13
14
|
size: number;
|
|
14
15
|
mimetype: string;
|
|
15
16
|
}
|
|
16
|
-
export declare class BaseController<
|
|
17
|
+
export declare class BaseController<UPLOAD_FILE_QUERY_PARAMS = {}> extends BaseInjector {
|
|
17
18
|
/**
|
|
18
19
|
* Hook that is called when taon app is inited
|
|
19
20
|
* (all contexts are created and inited)
|
|
@@ -21,11 +22,62 @@ export declare class BaseController<T = any> extends BaseInjector {
|
|
|
21
22
|
afterAllCtxInited(options: {
|
|
22
23
|
ctxStorage: ContextsEndpointStorage;
|
|
23
24
|
}): Promise<void>;
|
|
24
|
-
uploadFormDataToServer(formData: FormData): Models.Http.Response<MulterFileUploadResponse[]>;
|
|
25
|
+
uploadFormDataToServer(formData: FormData, queryParams?: UPLOAD_FILE_QUERY_PARAMS): Models.Http.Response<MulterFileUploadResponse[]>;
|
|
25
26
|
/**
|
|
26
27
|
* Hook after file is uploaded
|
|
27
28
|
* through `uploadFormDataToServer` or `uploadLocalFileToServer`
|
|
28
29
|
*/
|
|
29
|
-
protected afterFileUploadAction(file
|
|
30
|
-
uploadLocalFileToServer(absFilePath: string, options?: Pick<Models.Http.Rest.Ng2RestAxiosRequestConfig, 'onUploadProgress'
|
|
30
|
+
protected afterFileUploadAction(file?: MulterFileUploadResponse, queryParams?: UPLOAD_FILE_QUERY_PARAMS): void | Promise<void>;
|
|
31
|
+
uploadLocalFileToServer(absFilePath: string, options?: Pick<Models.Http.Rest.Ng2RestAxiosRequestConfig, 'onUploadProgress'>, queryParams?: UPLOAD_FILE_QUERY_PARAMS): Promise<MulterFileUploadResponse[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Easy way to wait for status change with http (1s default) pooling.
|
|
34
|
+
*
|
|
35
|
+
* example (in sub class):
|
|
36
|
+
* ```ts
|
|
37
|
+
async check() {
|
|
38
|
+
await this.waitForProperStatusChange({
|
|
39
|
+
request: () => this.uploadFormDataToServer(void 0, void 0).request(),
|
|
40
|
+
statusCheck: resp => resp.body.json[0].ok,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
_waitForProperStatusChange<T>(options: {
|
|
46
|
+
actionName: string;
|
|
47
|
+
/**
|
|
48
|
+
* Request for pooling
|
|
49
|
+
*/
|
|
50
|
+
request: (opt?: {
|
|
51
|
+
/**
|
|
52
|
+
* optional index number to identify request in logs
|
|
53
|
+
* (starts from 0 and increments by 1 on each try)
|
|
54
|
+
*/
|
|
55
|
+
reqIndexNum?: number;
|
|
56
|
+
httpErrorsCount?: number;
|
|
57
|
+
}) => ReturnType<Models.Http.Response<T>['request']>;
|
|
58
|
+
poolingInterval?: number;
|
|
59
|
+
/**
|
|
60
|
+
* default infinite tries
|
|
61
|
+
*/
|
|
62
|
+
maxTries?: number;
|
|
63
|
+
/**
|
|
64
|
+
* default infiniti allowed http errors
|
|
65
|
+
*/
|
|
66
|
+
allowedHttpErrors?: number;
|
|
67
|
+
/**
|
|
68
|
+
* condition to be met
|
|
69
|
+
*/
|
|
70
|
+
statusCheck?: (response: Awaited<ReturnType<typeof options.request>>) => boolean;
|
|
71
|
+
/**
|
|
72
|
+
* if return true.. loop will continue
|
|
73
|
+
* if false .. will exit the loop
|
|
74
|
+
*/
|
|
75
|
+
loopRequestsOnBackendError?: (opt: {
|
|
76
|
+
unknownError: Error;
|
|
77
|
+
unknownHttpError: HttpResponseError<any>;
|
|
78
|
+
taonError: HttpResponseError<RestErrorResponseWrapper>;
|
|
79
|
+
reqIndexNum?: number;
|
|
80
|
+
httpErrorsCount?: number;
|
|
81
|
+
}) => boolean | Promise<boolean>;
|
|
82
|
+
}): Promise<void>;
|
|
31
83
|
}
|
|
@@ -5,10 +5,10 @@ import { BaseRepository } from './base-repository';
|
|
|
5
5
|
/**
|
|
6
6
|
* Please override property entityClassFn with entity class.
|
|
7
7
|
*/
|
|
8
|
-
export declare abstract class BaseCrudController<Entity> extends BaseController {
|
|
8
|
+
export declare abstract class BaseCrudController<Entity, UPLOAD_FILE_QUERY_PARAMS = {}> extends BaseController<UPLOAD_FILE_QUERY_PARAMS> {
|
|
9
9
|
protected db: BaseRepository<Entity>;
|
|
10
10
|
/**
|
|
11
|
-
* Please provide entity as class
|
|
11
|
+
* Please provide entity as class property entityClassFn:
|
|
12
12
|
* @returns class function
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
@@ -21,8 +21,9 @@ export declare abstract class BaseCrudController<Entity> extends BaseController
|
|
|
21
21
|
updateById(id: number | string, item: Entity): Models.Http.Response<Entity>;
|
|
22
22
|
patchById(id: number | string, item: Entity): Models.Http.Response<Entity>;
|
|
23
23
|
bulkUpdate(items: Entity[]): Models.Http.Response<Entity[]>;
|
|
24
|
-
deleteById(id: number): Models.Http.Response<Entity>;
|
|
24
|
+
deleteById(id: number | string): Models.Http.Response<Entity>;
|
|
25
25
|
bulkDelete(ids: (number | string)[]): Models.Http.Response<(number | string | Entity)[]>;
|
|
26
|
-
|
|
26
|
+
clearTable(): Models.Http.Response<void>;
|
|
27
|
+
save(item: Entity): Models.Http.Response<Entity>;
|
|
27
28
|
bulkCreate(items: Entity): Models.Http.Response<Entity[]>;
|
|
28
29
|
}
|
|
@@ -61,6 +61,9 @@ export declare abstract class BaseRepository<Entity extends {
|
|
|
61
61
|
bulkSave(items: Entity[], options?: SaveOptions & {
|
|
62
62
|
reload: false;
|
|
63
63
|
}): Promise<Entity[]>;
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated use bulkSave instead
|
|
66
|
+
*/
|
|
64
67
|
bulkCreate(items: Entity[], options?: SaveOptions & {
|
|
65
68
|
reload: false;
|
|
66
69
|
}): Promise<Entity[]>;
|
|
@@ -17,6 +17,7 @@ export declare class MethodConfig implements Pick<TaonHttpDecoratorOptions, 'pat
|
|
|
17
17
|
* override default axiso response type
|
|
18
18
|
*/
|
|
19
19
|
responseType?: any;
|
|
20
|
+
overrideExpressSendAsHtml?: boolean;
|
|
20
21
|
path: string;
|
|
21
22
|
descriptor: PropertyDescriptor;
|
|
22
23
|
type: CoreModels.HttpMethod;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
import { Models } from 'ng2-rest/websql';
|
|
2
3
|
import * as methods from './http-methods-decorators';
|
|
3
4
|
import * as params from './http-params-decorators';
|
|
4
|
-
import { Models } from 'ng2-rest/websql';
|
|
5
5
|
export declare namespace Http {
|
|
6
6
|
export import GET = methods.GET;
|
|
7
7
|
export import POST = methods.POST;
|
|
@@ -9,6 +9,7 @@ export declare namespace Http {
|
|
|
9
9
|
export import DELETE = methods.DELETE;
|
|
10
10
|
export import PATCH = methods.PATCH;
|
|
11
11
|
export import HEAD = methods.HEAD;
|
|
12
|
+
export import HTML = methods.HTML;
|
|
12
13
|
export import Response = Models.HttpResponse;
|
|
13
14
|
namespace Param {
|
|
14
15
|
export import Query = params.Query;
|
|
@@ -18,21 +18,52 @@ export type TaonMiddlewareFunction = (options: {
|
|
|
18
18
|
export interface TaonHttpDecoratorOptions {
|
|
19
19
|
/**
|
|
20
20
|
* @deprecated don't use in production - keep stuff encapsulated
|
|
21
|
-
* path is
|
|
22
|
-
* ! BE CAREFUL ! global path IS NOT GLOBAL inside dockerized app
|
|
23
|
-
* (/api/contextName is automatically added to global path in docker)
|
|
21
|
+
* normally path is generated from method name and its params
|
|
24
22
|
*/
|
|
25
23
|
path?: string;
|
|
26
24
|
/**
|
|
27
|
-
* ! BE CAREFULL
|
|
28
25
|
* If true, the path will be global
|
|
26
|
+
*
|
|
27
|
+
* ! BE CAREFUL ! global path IS NOT GLOBAL inside dockerized app
|
|
28
|
+
* (/api/contextName is automatically added to global path in docker)
|
|
29
|
+
*
|
|
30
|
+
* @deprecated don't use in production - keep stuff encapsulated
|
|
29
31
|
*/
|
|
30
32
|
pathIsGlobal?: boolean;
|
|
31
33
|
overrideContentType?: CoreModels.ContentType;
|
|
32
34
|
overrideResponseType?: ModelsNg2Rest.ResponseTypeAxios;
|
|
35
|
+
/**
|
|
36
|
+
* Express will send response as HTML string with proper headers
|
|
37
|
+
*/
|
|
38
|
+
overrideExpressSendAsHtml?: boolean;
|
|
33
39
|
middlewares?: TaonMiddlewareFunction;
|
|
34
40
|
}
|
|
35
41
|
export declare function GET(pathOrOptions?: string | TaonHttpDecoratorOptions, pathIsGlobal?: boolean): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Method for sending html website from text
|
|
44
|
+
* Example
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* ...
|
|
48
|
+
* // in your taon controller
|
|
49
|
+
* ..Taon.Http.HTML()
|
|
50
|
+
* sendHtmlDummyWebsite(): Taon.ResponseHtml {
|
|
51
|
+
* return `
|
|
52
|
+
<html>
|
|
53
|
+
<head>
|
|
54
|
+
<title>Dummy website</title>
|
|
55
|
+
</head>
|
|
56
|
+
<body>
|
|
57
|
+
<h1>This is dummy website</h1>
|
|
58
|
+
<p>Served as HTML string from Taon controller method</p>
|
|
59
|
+
</body>
|
|
60
|
+
</html>
|
|
61
|
+
* `; *
|
|
62
|
+
* }
|
|
63
|
+
* ...
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function HTML(pathOrOptions?: Pick<TaonHttpDecoratorOptions, 'path' | 'pathIsGlobal'>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
36
67
|
export declare function HEAD(pathOrOptions?: string | TaonHttpDecoratorOptions, pathIsGlobal?: boolean): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
37
68
|
export declare function POST(pathOrOptions?: string | TaonHttpDecoratorOptions, pathIsGlobal?: boolean): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
38
69
|
export declare function PUT(pathOrOptions?: string | TaonHttpDecoratorOptions, pathIsGlobal?: boolean): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import type { Server } from 'http';
|
|
3
3
|
import type { NgZone } from '@angular/core';
|
|
4
|
+
import * as express from 'express';
|
|
4
5
|
import type { Application } from 'express';
|
|
5
6
|
import type { Repository } from 'taon-typeorm/websql';
|
|
6
7
|
import { DataSource } from 'taon-typeorm/websql';
|
|
@@ -68,6 +69,7 @@ export declare class EndpointContext {
|
|
|
68
69
|
get logHttp(): boolean;
|
|
69
70
|
get logRealtime(): boolean;
|
|
70
71
|
get logFramework(): boolean;
|
|
72
|
+
get logRoutes(): boolean;
|
|
71
73
|
get logDb(): boolean;
|
|
72
74
|
get logMigrations(): boolean;
|
|
73
75
|
/**
|
|
@@ -187,6 +189,7 @@ export declare class EndpointContext {
|
|
|
187
189
|
private initCustomBackendMiddlewares;
|
|
188
190
|
private initBackendMiddlewares;
|
|
189
191
|
private initServer;
|
|
192
|
+
protected sendError(res: express.Response, error: unknown, req: express.Request, expressPath: string): void;
|
|
190
193
|
/**
|
|
191
194
|
* client can be browser or nodejs (when remote host)
|
|
192
195
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import { Models } from './models';
|
|
3
2
|
import { Response as ExpressResponse, Request as ExpressRequest } from 'express';
|
|
3
|
+
import { Models } from './models';
|
|
4
4
|
export declare const getResponseValue: <T>(response: Models.Http.Response<T>, options?: {
|
|
5
5
|
req: ExpressRequest;
|
|
6
6
|
res: ExpressResponse;
|
|
@@ -4,6 +4,7 @@ import { MethodConfig } from '../config/method-config';
|
|
|
4
4
|
export declare namespace TaonHelpers {
|
|
5
5
|
const fillUpTo: (s: string, nCharacters: number) => string;
|
|
6
6
|
const isGoodPath: (p: string) => boolean;
|
|
7
|
+
const firstStringOrElemFromArray: (stringOrArrayOfString: string[] | string) => string;
|
|
7
8
|
const tryTransformParam: (param: any) => any;
|
|
8
9
|
const getExpressPath: (c: ControllerConfig, pathOrClassConfig: Partial<MethodConfig>) => string;
|
|
9
10
|
const defaultType: (value: any) => {};
|
package/websql/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import { NgZone } from '@angular/core';
|
|
4
|
+
import { RestErrorResponseWrapper } from 'ng2-rest/websql';
|
|
4
5
|
import * as base from './base-classes/base';
|
|
5
6
|
import * as controllerDecorator from './decorators/classes/controller-decorator';
|
|
6
7
|
import * as entityDecorator from './decorators/classes/entity-decorator';
|
|
@@ -23,6 +24,7 @@ export { BaseProvider } from './base-classes/base-provider';
|
|
|
23
24
|
export { BaseEntity } from './base-classes/base-entity';
|
|
24
25
|
export { BaseContext } from './base-classes/base-context';
|
|
25
26
|
export { BaseMigration } from './base-classes/base-migration';
|
|
27
|
+
export { BaseClass } from './base-classes/base-class';
|
|
26
28
|
export { TaonAdditionalMiddlewareMethodInfo } from './base-classes/base-middleware';
|
|
27
29
|
export { createContext, TaonContext } from './create-context';
|
|
28
30
|
export { inject } from './inject';
|
|
@@ -34,6 +36,8 @@ export { ContextsEndpointStorage } from './endpoint-context-storage';
|
|
|
34
36
|
export { ClassHelpers } from './helpers/class-helpers';
|
|
35
37
|
export type { TaonClientMiddlewareInterceptOptions, TaonServerMiddlewareInterceptOptions, } from 'ng2-rest/websql';
|
|
36
38
|
export declare namespace Taon {
|
|
39
|
+
const error: (opt: Pick<RestErrorResponseWrapper, "message" | "status" | "details" | "code">) => void;
|
|
40
|
+
type ResponseHtml = models.Models.Http.Response<string>;
|
|
37
41
|
export import Response = models.Models.Http.Response;
|
|
38
42
|
export import Http = http.Http;
|
|
39
43
|
export import Base = base.Base;
|
package/websql/lib/models.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import type { RequestHandler } from 'express';
|
|
3
3
|
import { Response as ExpressResponse, Request as ExpressRequest } from 'express';
|
|
4
|
-
import { Models as ModelsNg2Rest } from 'ng2-rest/websql';
|
|
4
|
+
import { Models as ModelsNg2Rest, RestResponseWrapper } from 'ng2-rest/websql';
|
|
5
5
|
import { CoreModels } from 'tnp-core/websql';
|
|
6
6
|
import type { EndpointContext } from './endpoint-context';
|
|
7
|
+
export declare class TaonRestResponseWrapper extends RestResponseWrapper {
|
|
8
|
+
}
|
|
7
9
|
export declare namespace Models {
|
|
8
10
|
type FrameworkMode = 'backend-frontend(tcp+udp)' | 'remote-backend(tcp+udp)' | 'backend-frontend(ipc-electron)' | 'backend-frontend(websql-electron)' | 'backend-frontend(websql)';
|
|
9
11
|
enum ClassType {
|
|
@@ -83,6 +85,7 @@ export declare namespace Models {
|
|
|
83
85
|
framework?: boolean;
|
|
84
86
|
db?: boolean;
|
|
85
87
|
migrations?: boolean;
|
|
88
|
+
routes?: boolean;
|
|
86
89
|
};
|
|
87
90
|
interface ContextOptions<CONTEXTS, CONTROLLERS, ENTITIES, REPOSITORIES, PROVIDERS, SUBSCRIBERS, MIGRATIONS, MIDDLEWARES> {
|
|
88
91
|
appId?: string;
|
|
@@ -231,15 +234,6 @@ export declare namespace Models {
|
|
|
231
234
|
(req?: ExpressRequest, res?: ExpressResponse): Promise<SyncResponse<T> | SyncResponseFunc<T>>;
|
|
232
235
|
}
|
|
233
236
|
type Response<T = string> = AsyncResponse<T> & ClientAction<T>;
|
|
234
|
-
class Errors {
|
|
235
|
-
message: string;
|
|
236
|
-
private code;
|
|
237
|
-
toString: () => string;
|
|
238
|
-
private constructor();
|
|
239
|
-
private static create;
|
|
240
|
-
static entityNotFound(entity?: Function): Errors;
|
|
241
|
-
static custom(message: string, code?: ModelsNg2Rest.HttpCode): Errors;
|
|
242
|
-
}
|
|
243
237
|
interface AuthCallBack {
|
|
244
238
|
(methodReference: Function): RequestHandler;
|
|
245
239
|
}
|
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import type { BaseEntity } from '../base-classes/base-entity';
|
|
4
3
|
import { RealtimeCore } from './realtime-core';
|
|
5
4
|
import { RealtimeModels } from './realtime.models';
|
|
5
|
+
/**
|
|
6
|
+
* Client for realtime communication
|
|
7
|
+
* you can listen to:
|
|
8
|
+
* - entity changes (any property in table changed)
|
|
9
|
+
* - entity custom property changes (specific property changed)
|
|
10
|
+
* - entity table changes (new instance added, instance removed)
|
|
11
|
+
* - custom events
|
|
12
|
+
*/
|
|
6
13
|
export declare class RealtimeClient {
|
|
7
14
|
private core;
|
|
8
15
|
private subsManagers;
|
|
9
16
|
constructor(core: RealtimeCore);
|
|
10
17
|
private init;
|
|
11
18
|
/**
|
|
19
|
+
* Usage:
|
|
20
|
+
* myContext.realtimeClient.listenChangesEntity(myEntityInstance);
|
|
21
|
+
*
|
|
22
|
+
*
|
|
12
23
|
* Changes trigger on backend needs to be done manually.. example code:
|
|
13
24
|
*
|
|
14
|
-
*
|
|
15
|
-
* Context.Realtime.Server.TrigggerEntityChanges(myEntityInstance);
|
|
25
|
+
* myContext.realtimeServer.triggerEntityChanges(myEntityInstance);
|
|
16
26
|
* ...
|
|
17
27
|
*/
|
|
18
|
-
listenChangesEntity(
|
|
19
|
-
listenChangesEntityTable(entityClassFn: Function): Observable<unknown>;
|
|
28
|
+
listenChangesEntity<RESULT = any>(entityClassFnOrObj: Function | object, options?: RealtimeModels.ChangeOption): Observable<RESULT>;
|
|
20
29
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* ...
|
|
24
|
-
* Context.Realtime.Server.TrigggerEntityChanges(myEntityInstance);
|
|
25
|
-
* // or
|
|
26
|
-
* Context.Realtime.Server.TrigggerEntityPropertyChanges(myEntityInstance,{ property: 'geolocationX' });
|
|
27
|
-
* ...
|
|
30
|
+
* Listen changes entity table
|
|
31
|
+
* Example: for pagination, lists update ...
|
|
28
32
|
*/
|
|
29
|
-
|
|
30
|
-
listenChangesCustomEvent(customEvent: string): Observable<
|
|
33
|
+
listenChangesEntityTable<RESULT = any>(entityClassFn: Function): Observable<RESULT>;
|
|
34
|
+
listenChangesCustomEvent<RESULT = any>(customEvent: string): Observable<RESULT>;
|
|
31
35
|
/**
|
|
32
36
|
* Trigger custom event on backend
|
|
33
37
|
* @param customEvent global event name
|
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import type { BaseEntity } from '../base-classes/base-entity';
|
|
4
3
|
import { RealtimeCore } from './realtime-core';
|
|
4
|
+
/**
|
|
5
|
+
* Server for realtime communication
|
|
6
|
+
* you can trigger:
|
|
7
|
+
* - entity changes (any property in table changed)
|
|
8
|
+
* - entity custom property changes (specific property changed)
|
|
9
|
+
* - entity table changes (new instance added, instance removed)
|
|
10
|
+
* - custom events
|
|
11
|
+
*
|
|
12
|
+
* and also listen to:
|
|
13
|
+
* - custom events from yourself
|
|
14
|
+
*/
|
|
5
15
|
export declare class RealtimeServer {
|
|
6
16
|
private core;
|
|
7
17
|
constructor(core: RealtimeCore);
|
|
8
18
|
private init;
|
|
9
19
|
private triggerChanges;
|
|
10
|
-
triggerEntityChanges(entityObjOrClass: Function
|
|
11
|
-
|
|
20
|
+
triggerEntityChanges(entityObjOrClass: Function | object,
|
|
21
|
+
/**
|
|
22
|
+
* value of unique key property of entity instance
|
|
23
|
+
* (this value is not needed if entityObjOrClass is instance of entity)
|
|
24
|
+
*/
|
|
25
|
+
idToTrigger?: number | string): void;
|
|
26
|
+
triggerEntityPropertyChanges(entityObjOrClass: Function | object,
|
|
27
|
+
/**
|
|
28
|
+
* property name or array of property names that changed
|
|
29
|
+
* for entity instance
|
|
30
|
+
*/
|
|
31
|
+
property: string | string[],
|
|
32
|
+
/**
|
|
33
|
+
* value of unique key property of entity instance
|
|
34
|
+
* (this value is not needed if entityObjOrClass is instance of entity)
|
|
35
|
+
*/
|
|
36
|
+
idToTrigger?: number | string): void;
|
|
12
37
|
triggerEntityTableChanges(entityClassOrInstance: Function | object): void;
|
|
13
38
|
triggerCustomEvent(customEvent: string, dataToPush: any): void;
|
|
14
39
|
/**
|
|
@@ -7,9 +7,22 @@ export declare namespace RealtimeModels {
|
|
|
7
7
|
roomName: string;
|
|
8
8
|
property: string;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
interface ChangeOption {
|
|
11
|
+
/**
|
|
12
|
+
* Specify property name to listen changes on that property only;
|
|
13
|
+
*/
|
|
11
14
|
property?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Override custom event name to listen
|
|
17
|
+
*/
|
|
12
18
|
customEvent?: string;
|
|
13
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Value from entity object.
|
|
21
|
+
* Key for this value is usually id or unique key
|
|
22
|
+
* property defined in entity decorator.
|
|
23
|
+
* TODO @LAST IMPLEMENT unique key support
|
|
24
|
+
*/
|
|
25
|
+
idOrUniqValue?: any;
|
|
26
|
+
}
|
|
14
27
|
type EventHandler = (...args: any[]) => void;
|
|
15
28
|
}
|