@opra/common 1.0.0-beta.3 → 1.0.0-beta.4
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/index.cjs +5 -5
- package/browser/index.mjs +5 -5
- package/cjs/document/api-document.js +4 -4
- package/cjs/document/constants.js +2 -2
- package/cjs/document/decorators/{msg-controller.decorator.js → rpc-controller.decorator.js} +13 -8
- package/cjs/document/decorators/{msg-operation.decorator.js → rpc-operation.decorator.js} +6 -6
- package/cjs/document/factory/api-document.factory.js +3 -3
- package/cjs/document/factory/{msg-api.factory.js → rpc-api.factory.js} +28 -28
- package/cjs/document/http/http-operation.js +6 -0
- package/cjs/document/index.js +8 -6
- package/cjs/document/{msg/msg-api.js → rpc/rpc-api.js} +5 -5
- package/cjs/document/{msg/msg-controller.js → rpc/rpc-controller.js} +20 -20
- package/cjs/document/{msg/msg-header.js → rpc/rpc-header.js} +5 -5
- package/cjs/document/{msg/msg-operation-response.js → rpc/rpc-operation-response.js} +4 -4
- package/cjs/document/{msg/msg-operation.js → rpc/rpc-operation.js} +10 -10
- package/cjs/schema/opra-schema.js +3 -3
- package/cjs/schema/rpc/rpc-controller.interface.js +11 -0
- package/cjs/schema/rpc/rpc-operation.interface.js +7 -0
- package/esm/document/api-document.js +4 -4
- package/esm/document/constants.js +1 -1
- package/esm/document/decorators/{msg-controller.decorator.js → rpc-controller.decorator.js} +13 -8
- package/esm/document/decorators/{msg-operation.decorator.js → rpc-operation.decorator.js} +6 -6
- package/esm/document/factory/api-document.factory.js +3 -3
- package/esm/document/factory/{msg-api.factory.js → rpc-api.factory.js} +27 -27
- package/esm/document/http/http-operation.js +6 -0
- package/esm/document/index.js +8 -6
- package/esm/document/{msg/msg-api.js → rpc/rpc-api.js} +3 -3
- package/esm/document/{msg/msg-controller.js → rpc/rpc-controller.js} +20 -20
- package/esm/document/{msg/msg-header.js → rpc/rpc-header.js} +4 -4
- package/esm/document/{msg/msg-operation-response.js → rpc/rpc-operation-response.js} +2 -2
- package/esm/document/{msg/msg-operation.js → rpc/rpc-operation.js} +9 -9
- package/esm/schema/opra-schema.js +3 -3
- package/esm/schema/rpc/rpc-controller.interface.js +8 -0
- package/esm/schema/rpc/rpc-operation.interface.js +4 -0
- package/package.json +1 -1
- package/types/document/api-document.d.ts +3 -3
- package/types/document/constants.d.ts +1 -1
- package/types/document/decorators/rpc-controller.decorator.d.ts +20 -0
- package/types/document/decorators/rpc-operation.decorator.d.ts +32 -0
- package/types/document/factory/api-document.factory.d.ts +2 -2
- package/types/document/factory/rpc-api.factory.d.ts +40 -0
- package/types/document/index.d.ts +11 -8
- package/types/document/rpc/rpc-api.d.ts +27 -0
- package/types/document/rpc/rpc-controller.d.ts +89 -0
- package/types/document/{msg/msg-header.d.ts → rpc/rpc-header.d.ts} +15 -15
- package/types/document/{msg/msg-operation-response.d.ts → rpc/rpc-operation-response.d.ts} +13 -13
- package/types/document/{msg/msg-operation.d.ts → rpc/rpc-operation.d.ts} +27 -27
- package/types/schema/api-document.interface.d.ts +9 -11
- package/types/schema/opra-schema.d.ts +3 -3
- package/types/schema/rpc/rpc-controller.interface.d.ts +22 -0
- package/types/schema/{msg/msg-header.interface.d.ts → rpc/rpc-header.interface.d.ts} +2 -2
- package/types/schema/{msg/msg-operation.interface.d.ts → rpc/rpc-operation.interface.d.ts} +11 -11
- package/cjs/schema/msg/msg-controller.interface.js +0 -11
- package/cjs/schema/msg/msg-operation.interface.js +0 -7
- package/esm/schema/msg/msg-controller.interface.js +0 -8
- package/esm/schema/msg/msg-operation.interface.js +0 -4
- package/types/document/decorators/msg-controller.decorator.d.ts +0 -11
- package/types/document/decorators/msg-operation.decorator.d.ts +0 -29
- package/types/document/factory/msg-api.factory.d.ts +0 -40
- package/types/document/msg/msg-api.d.ts +0 -27
- package/types/document/msg/msg-controller.d.ts +0 -89
- package/types/schema/msg/msg-controller.interface.d.ts +0 -22
- /package/cjs/schema/{msg/msg-header.interface.js → rpc/rpc-header.interface.js} +0 -0
- /package/esm/schema/{msg/msg-header.interface.js → rpc/rpc-header.interface.js} +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ThunkAsync, Type, TypeThunkAsync } from 'ts-gems';
|
|
2
|
+
import type { RpcHeader } from '../rpc/rpc-header';
|
|
3
|
+
import type { RpcOperation } from '../rpc/rpc-operation';
|
|
4
|
+
import type { RpcOperationResponse } from '../rpc/rpc-operation-response';
|
|
5
|
+
export interface RpcOperationDecorator {
|
|
6
|
+
(target: Object, propertyKey: string): void;
|
|
7
|
+
Header(name: string | RegExp, optionsOrType?: RpcHeader.Options | string | TypeThunkAsync): this;
|
|
8
|
+
Response(payloadType: TypeThunkAsync | string, options?: RpcOperationResponse.Options): RpcOperationResponseDecorator;
|
|
9
|
+
UseType(...type: Type[]): this;
|
|
10
|
+
}
|
|
11
|
+
export interface RpcOperationResponseDecorator {
|
|
12
|
+
(target: Object, propertyKey: string): void;
|
|
13
|
+
Header(name: string | RegExp, optionsOrType?: RpcHeader.Options | string | TypeThunkAsync): this;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @namespace RpcOperationDecoratorFactory
|
|
17
|
+
*/
|
|
18
|
+
export interface RpcOperationDecoratorFactory {
|
|
19
|
+
/**
|
|
20
|
+
* Property decorator
|
|
21
|
+
* @param decoratorChain
|
|
22
|
+
* @param payloadType
|
|
23
|
+
* @param options
|
|
24
|
+
*/ <T extends RpcOperation.Options>(decoratorChain: Function[], payloadType: ThunkAsync<Type> | string, options?: T): RpcOperationDecorator;
|
|
25
|
+
}
|
|
26
|
+
export declare namespace RpcOperationDecoratorFactory {
|
|
27
|
+
type AugmentationFunction = (decorator: RpcOperationDecorator, decoratorChain: Function[], payloadType: ThunkAsync<Type> | string, options?: RpcOperation.Options) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare function RpcOperationDecoratorFactory(decoratorChain: Function[], payloadType: ThunkAsync<Type> | string | TypeThunkAsync, options?: RpcOperation.Options): RpcOperationDecorator;
|
|
30
|
+
export declare namespace RpcOperationDecoratorFactory {
|
|
31
|
+
var augment: (fn: RpcOperationDecoratorFactory.AugmentationFunction) => void;
|
|
32
|
+
}
|
|
@@ -4,12 +4,12 @@ import { ApiDocument } from '../api-document.js';
|
|
|
4
4
|
import { DocumentInitContext } from '../common/document-init-context.js';
|
|
5
5
|
import { DataTypeFactory } from './data-type.factory.js';
|
|
6
6
|
import { HttpApiFactory } from './http-api.factory.js';
|
|
7
|
-
import {
|
|
7
|
+
import { RpcApiFactory } from './rpc-api.factory.js';
|
|
8
8
|
export declare namespace ApiDocumentFactory {
|
|
9
9
|
interface InitArguments extends PartialSome<StrictOmit<OpraSchema.ApiDocument, 'id' | 'references' | 'types' | 'api'>, 'spec'> {
|
|
10
10
|
references?: Record<string, ReferenceThunk>;
|
|
11
11
|
types?: DataTypeInitSources;
|
|
12
|
-
api?: StrictOmit<HttpApiFactory.InitArguments, 'owner'> | StrictOmit<
|
|
12
|
+
api?: StrictOmit<HttpApiFactory.InitArguments, 'owner'> | StrictOmit<RpcApiFactory.InitArguments, 'owner'>;
|
|
13
13
|
}
|
|
14
14
|
type ReferenceSource = string | OpraSchema.ApiDocument | InitArguments | ApiDocument;
|
|
15
15
|
type ReferenceThunk = ThunkAsync<ReferenceSource>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Type } from 'ts-gems';
|
|
2
|
+
import { OpraSchema } from '../../schema/index.js';
|
|
3
|
+
import { DocumentInitContext } from '../common/document-init-context.js';
|
|
4
|
+
import { RpcApi } from '../rpc/rpc-api.js';
|
|
5
|
+
import { RpcController } from '../rpc/rpc-controller.js';
|
|
6
|
+
import { RpcOperation } from '../rpc/rpc-operation.js';
|
|
7
|
+
import { RpcOperationResponse } from '../rpc/rpc-operation-response.js';
|
|
8
|
+
export declare namespace RpcApiFactory {
|
|
9
|
+
interface InitArguments extends RpcApi.InitArguments {
|
|
10
|
+
controllers: Type[] | any[] | ((parent: any) => any) | OpraSchema.RpcApi['controllers'];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @class RpcApiFactory
|
|
15
|
+
*/
|
|
16
|
+
export declare class RpcApiFactory {
|
|
17
|
+
/**
|
|
18
|
+
* Generates RpcApi
|
|
19
|
+
* @param context
|
|
20
|
+
* @param init
|
|
21
|
+
*/
|
|
22
|
+
static createApi(context: DocumentInitContext, init: RpcApiFactory.InitArguments): Promise<RpcApi>;
|
|
23
|
+
protected static _createController(context: DocumentInitContext, parent: RpcApi, thunk: Type | object | Function | OpraSchema.RpcController, name?: string): Promise<RpcController | undefined | void>;
|
|
24
|
+
/**
|
|
25
|
+
* Initializes RpcOperation
|
|
26
|
+
* @param context
|
|
27
|
+
* @param operation
|
|
28
|
+
* @param metadata
|
|
29
|
+
* @protected
|
|
30
|
+
*/
|
|
31
|
+
protected static _initRpcOperation(context: DocumentInitContext, operation: RpcOperation, metadata: RpcOperation.Metadata | OpraSchema.RpcOperation): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Initializes RpcOperationResponse
|
|
34
|
+
* @param context
|
|
35
|
+
* @param response
|
|
36
|
+
* @param metadata
|
|
37
|
+
* @protected
|
|
38
|
+
*/
|
|
39
|
+
protected static _initRpcOperationResponse(context: DocumentInitContext, response: RpcOperationResponse, metadata: RpcOperationResponse.Metadata | OpraSchema.RpcOperationResponse): Promise<void>;
|
|
40
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import * as
|
|
2
|
+
import * as RpcControllerDecorator_ from './decorators/rpc-controller.decorator.js';
|
|
3
|
+
import * as RpcOperationDecorator_ from './decorators/rpc-operation.decorator.js';
|
|
3
4
|
import * as DataTypeFactory_ from './factory/data-type.factory.js';
|
|
4
5
|
import * as HttpApiFactory_ from './factory/http-api.factory.js';
|
|
5
6
|
export * from './api-document.js';
|
|
@@ -24,7 +25,8 @@ export * from './data-type/primitive-types/index.js';
|
|
|
24
25
|
export * from './data-type/required-type.js';
|
|
25
26
|
export * from './data-type/simple-type.js';
|
|
26
27
|
export * from './decorators/http-operation-entity.decorator.js';
|
|
27
|
-
export type {
|
|
28
|
+
export type { RpcControllerDecorator } from './decorators/rpc-controller.decorator.js';
|
|
29
|
+
export type { RpcOperationDecorator } from './decorators/rpc-operation.decorator.js';
|
|
28
30
|
export * from './factory/api-document.factory.js';
|
|
29
31
|
export * from './http/http-api.js';
|
|
30
32
|
export * from './http/http-controller.js';
|
|
@@ -35,13 +37,14 @@ export * from './http/http-operation-response.js';
|
|
|
35
37
|
export * from './http/http-parameter.js';
|
|
36
38
|
export * from './http/http-request-body.js';
|
|
37
39
|
export * from './http/http-status-range.js';
|
|
38
|
-
export * from './
|
|
39
|
-
export * from './
|
|
40
|
-
export * from './
|
|
41
|
-
export * from './
|
|
42
|
-
export type {
|
|
40
|
+
export * from './rpc/rpc-api.js';
|
|
41
|
+
export * from './rpc/rpc-controller.js';
|
|
42
|
+
export * from './rpc/rpc-header.js';
|
|
43
|
+
export * from './rpc/rpc-operation.js';
|
|
44
|
+
export type { RpcOperationResponse } from './rpc/rpc-operation-response';
|
|
43
45
|
export declare namespace classes {
|
|
44
46
|
export import HttpApiFactory = HttpApiFactory_.HttpApiFactory;
|
|
45
47
|
export import DataTypeFactory = DataTypeFactory_.DataTypeFactory;
|
|
46
|
-
export import
|
|
48
|
+
export import RpcOperationDecoratorFactory = RpcOperationDecorator_.RpcOperationDecoratorFactory;
|
|
49
|
+
export import RpcControllerDecoratorFactory = RpcControllerDecorator_.RpcControllerDecoratorFactory;
|
|
47
50
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { StrictOmit, Type } from 'ts-gems';
|
|
2
|
+
import { ResponsiveMap } from '../../helpers/index.js';
|
|
3
|
+
import { OpraSchema } from '../../schema/index.js';
|
|
4
|
+
import type { ApiDocument } from '../api-document';
|
|
5
|
+
import { ApiBase } from '../common/api-base.js';
|
|
6
|
+
import { RpcController } from './rpc-controller.js';
|
|
7
|
+
import { RpcOperation } from './rpc-operation.js';
|
|
8
|
+
export declare namespace RpcApi {
|
|
9
|
+
interface InitArguments extends ApiBase.InitArguments, StrictOmit<OpraSchema.RpcApi, 'controllers'> {
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @class RpcApi
|
|
14
|
+
*/
|
|
15
|
+
export declare class RpcApi extends ApiBase {
|
|
16
|
+
protected _controllerReverseMap: WeakMap<Type, RpcController | null>;
|
|
17
|
+
readonly owner: ApiDocument;
|
|
18
|
+
readonly transport = "rpc";
|
|
19
|
+
platform: string;
|
|
20
|
+
controllers: ResponsiveMap<RpcController>;
|
|
21
|
+
constructor(init: RpcApi.InitArguments);
|
|
22
|
+
findController(controller: Type): RpcController | undefined;
|
|
23
|
+
findController(name: string): RpcController | undefined;
|
|
24
|
+
findOperation(controller: Type, operationName: string): RpcOperation | undefined;
|
|
25
|
+
findOperation(controllerName: string, operationName: string): RpcOperation | undefined;
|
|
26
|
+
toJSON(): OpraSchema.RpcApi;
|
|
27
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Combine, ThunkAsync, Type } from 'ts-gems';
|
|
2
|
+
import { ResponsiveMap } from '../../helpers/index.js';
|
|
3
|
+
import { OpraSchema } from '../../schema/index.js';
|
|
4
|
+
import { DataTypeMap } from '../common/data-type-map.js';
|
|
5
|
+
import { DocumentElement } from '../common/document-element.js';
|
|
6
|
+
import type { EnumType } from '../data-type/enum-type.js';
|
|
7
|
+
import { RpcControllerDecoratorFactory } from '../decorators/rpc-controller.decorator.js';
|
|
8
|
+
import { nodeInspectCustom } from '../utils/inspect.util.js';
|
|
9
|
+
import type { RpcApi } from './rpc-api';
|
|
10
|
+
import type { RpcHeader } from './rpc-header.js';
|
|
11
|
+
import type { RpcOperation } from './rpc-operation';
|
|
12
|
+
/**
|
|
13
|
+
* @namespace RpcController
|
|
14
|
+
*/
|
|
15
|
+
export declare namespace RpcController {
|
|
16
|
+
interface Metadata extends Pick<OpraSchema.RpcController, 'description'> {
|
|
17
|
+
name: string;
|
|
18
|
+
types?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[];
|
|
19
|
+
operations?: Record<string, RpcOperation.Metadata>;
|
|
20
|
+
headers?: RpcHeader.Metadata[];
|
|
21
|
+
onInit?: (resource: RpcController) => void;
|
|
22
|
+
onShutdown?: (resource: RpcController) => void | Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
interface Options extends Partial<Pick<OpraSchema.RpcController, 'description'>> {
|
|
25
|
+
name?: string;
|
|
26
|
+
}
|
|
27
|
+
interface InitArguments extends Combine<{
|
|
28
|
+
instance?: object;
|
|
29
|
+
ctor?: Type;
|
|
30
|
+
}, Pick<Metadata, 'name' | 'description' | 'onInit' | 'onShutdown'>> {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Type definition for RpcController
|
|
35
|
+
* @class RpcController
|
|
36
|
+
*/
|
|
37
|
+
export interface RpcControllerStatic extends RpcControllerDecoratorFactory {
|
|
38
|
+
/**
|
|
39
|
+
* Class constructor of RpcController
|
|
40
|
+
* @param owner
|
|
41
|
+
* @param args
|
|
42
|
+
*/
|
|
43
|
+
new (owner: RpcApi | RpcController, args: RpcController.InitArguments): RpcController;
|
|
44
|
+
prototype: RpcController;
|
|
45
|
+
OnInit(): PropertyDecorator;
|
|
46
|
+
OnShutdown(): PropertyDecorator;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Type definition of RpcController prototype
|
|
50
|
+
* @interface RpcController
|
|
51
|
+
*/
|
|
52
|
+
export interface RpcController extends RpcControllerClass {
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* RpcController
|
|
56
|
+
*/
|
|
57
|
+
export declare const RpcController: RpcControllerStatic;
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @class RpcController
|
|
61
|
+
*/
|
|
62
|
+
declare class RpcControllerClass extends DocumentElement {
|
|
63
|
+
protected _controllerReverseMap: WeakMap<Type, RpcController | null>;
|
|
64
|
+
readonly kind: OpraSchema.RpcController.Kind;
|
|
65
|
+
readonly name: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
path: string;
|
|
68
|
+
instance?: any;
|
|
69
|
+
ctor?: Type;
|
|
70
|
+
headers: RpcHeader[];
|
|
71
|
+
operations: ResponsiveMap<RpcOperation>;
|
|
72
|
+
types: DataTypeMap;
|
|
73
|
+
onInit?: (resource: RpcController) => void;
|
|
74
|
+
onShutdown?: (resource: RpcController) => void | Promise<void>;
|
|
75
|
+
findHeader(paramName: string, location?: OpraSchema.HttpParameterLocation): RpcHeader | undefined;
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
toString(): string;
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
toJSON(): OpraSchema.RpcController;
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
*/
|
|
87
|
+
protected [nodeInspectCustom](): string;
|
|
88
|
+
}
|
|
89
|
+
export {};
|
|
@@ -5,10 +5,10 @@ import { Value } from '../common/value.js';
|
|
|
5
5
|
import { DataType } from '../data-type/data-type.js';
|
|
6
6
|
import type { EnumType } from '../data-type/enum-type.js';
|
|
7
7
|
/**
|
|
8
|
-
* @namespace
|
|
8
|
+
* @namespace RpcHeader
|
|
9
9
|
*/
|
|
10
|
-
export declare namespace
|
|
11
|
-
interface Metadata extends StrictOmit<OpraSchema.
|
|
10
|
+
export declare namespace RpcHeader {
|
|
11
|
+
interface Metadata extends StrictOmit<OpraSchema.RpcHeader, 'type'> {
|
|
12
12
|
name: string | RegExp;
|
|
13
13
|
type?: string | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
|
|
14
14
|
}
|
|
@@ -21,27 +21,27 @@ export declare namespace MsgHeader {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Type definition for
|
|
25
|
-
* @class
|
|
24
|
+
* Type definition for RpcHeader
|
|
25
|
+
* @class RpcHeader
|
|
26
26
|
*/
|
|
27
|
-
interface
|
|
28
|
-
new (owner: DocumentElement, args:
|
|
29
|
-
prototype:
|
|
27
|
+
interface RpcHeaderStatic {
|
|
28
|
+
new (owner: DocumentElement, args: RpcHeader.InitArguments): RpcHeader;
|
|
29
|
+
prototype: RpcHeader;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* Type definition of
|
|
33
|
-
* @interface
|
|
32
|
+
* Type definition of RpcHeader prototype
|
|
33
|
+
* @interface RpcHeader
|
|
34
34
|
*/
|
|
35
|
-
export interface
|
|
35
|
+
export interface RpcHeader extends RpcHeaderClass {
|
|
36
36
|
}
|
|
37
|
-
export declare const
|
|
37
|
+
export declare const RpcHeader: RpcHeaderStatic;
|
|
38
38
|
/**
|
|
39
|
-
* @class
|
|
39
|
+
* @class RpcHeader
|
|
40
40
|
*/
|
|
41
|
-
declare class
|
|
41
|
+
declare class RpcHeaderClass extends Value {
|
|
42
42
|
readonly owner: DocumentElement;
|
|
43
43
|
deprecated?: boolean | string;
|
|
44
44
|
required?: boolean;
|
|
45
|
-
toJSON(): OpraSchema.
|
|
45
|
+
toJSON(): OpraSchema.RpcHeader;
|
|
46
46
|
}
|
|
47
47
|
export {};
|
|
@@ -3,17 +3,17 @@ import { TypeThunkAsync } from 'ts-gems/lib/types';
|
|
|
3
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
4
|
import { DocumentElement } from '../common/document-element.js';
|
|
5
5
|
import { DataType } from '../data-type/data-type.js';
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
6
|
+
import type { RpcHeader } from './rpc-header';
|
|
7
|
+
import type { RpcOperation } from './rpc-operation';
|
|
8
8
|
/**
|
|
9
|
-
* @namespace
|
|
9
|
+
* @namespace RpcOperationResponse
|
|
10
10
|
*/
|
|
11
|
-
export declare namespace
|
|
11
|
+
export declare namespace RpcOperationResponse {
|
|
12
12
|
interface Metadata extends Combine<{
|
|
13
13
|
payloadType?: TypeThunkAsync | string;
|
|
14
14
|
keyType?: TypeThunkAsync | string;
|
|
15
|
-
headers?:
|
|
16
|
-
}, OpraSchema.
|
|
15
|
+
headers?: RpcHeader.Metadata[];
|
|
16
|
+
}, OpraSchema.RpcOperationResponse> {
|
|
17
17
|
}
|
|
18
18
|
interface Options extends Combine<{
|
|
19
19
|
keyType?: Type | string;
|
|
@@ -26,16 +26,16 @@ export declare namespace MsgOperationResponse {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* @class
|
|
29
|
+
* @class RpcOperationResponse
|
|
30
30
|
*/
|
|
31
|
-
export declare class
|
|
32
|
-
readonly owner:
|
|
31
|
+
export declare class RpcOperationResponse extends DocumentElement {
|
|
32
|
+
readonly owner: RpcOperation;
|
|
33
33
|
channel?: string | RegExp | (string | RegExp)[];
|
|
34
34
|
description?: string;
|
|
35
35
|
payloadType: DataType;
|
|
36
36
|
keyType?: DataType;
|
|
37
|
-
headers:
|
|
38
|
-
constructor(owner:
|
|
39
|
-
findHeader(paramName: string):
|
|
40
|
-
toJSON(): OpraSchema.
|
|
37
|
+
headers: RpcHeader[];
|
|
38
|
+
constructor(owner: RpcOperation, initArgs?: RpcOperationResponse.InitArguments);
|
|
39
|
+
findHeader(paramName: string): RpcHeader | undefined;
|
|
40
|
+
toJSON(): OpraSchema.RpcOperationResponse;
|
|
41
41
|
}
|
|
@@ -5,20 +5,20 @@ import { DataTypeMap } from '../common/data-type-map.js';
|
|
|
5
5
|
import { DocumentElement } from '../common/document-element.js';
|
|
6
6
|
import { DataType } from '../data-type/data-type.js';
|
|
7
7
|
import type { EnumType } from '../data-type/enum-type.js';
|
|
8
|
-
import {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
8
|
+
import { RpcOperationDecorator } from '../decorators/rpc-operation.decorator.js';
|
|
9
|
+
import type { RpcController } from './rpc-controller';
|
|
10
|
+
import type { RpcHeader } from './rpc-header';
|
|
11
|
+
import type { RpcOperationResponse } from './rpc-operation-response';
|
|
12
12
|
/**
|
|
13
|
-
* @namespace
|
|
13
|
+
* @namespace RpcOperation
|
|
14
14
|
*/
|
|
15
|
-
export declare namespace
|
|
16
|
-
interface Metadata extends Pick<OpraSchema.
|
|
15
|
+
export declare namespace RpcOperation {
|
|
16
|
+
interface Metadata extends Pick<OpraSchema.RpcOperation, 'description' | 'channel'> {
|
|
17
17
|
payloadType: TypeThunkAsync | string;
|
|
18
18
|
keyType?: TypeThunkAsync | string;
|
|
19
19
|
types?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[];
|
|
20
|
-
headers?:
|
|
21
|
-
response?:
|
|
20
|
+
headers?: RpcHeader.Metadata[];
|
|
21
|
+
response?: RpcOperationResponse.Metadata;
|
|
22
22
|
}
|
|
23
23
|
interface Options extends Partial<Pick<Metadata, 'description' | 'keyType'>> {
|
|
24
24
|
channel?: (string | RegExp) | (string | RegExp)[];
|
|
@@ -32,46 +32,46 @@ export declare namespace MsgOperation {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Type definition for
|
|
36
|
-
* @class
|
|
35
|
+
* Type definition for RpcOperation
|
|
36
|
+
* @class RpcOperation
|
|
37
37
|
*/
|
|
38
|
-
export interface
|
|
38
|
+
export interface RpcOperationStatic {
|
|
39
39
|
/**
|
|
40
|
-
* Class constructor of
|
|
40
|
+
* Class constructor of RpcOperation
|
|
41
41
|
* @param controller
|
|
42
42
|
* @param args
|
|
43
43
|
*/
|
|
44
|
-
new (controller:
|
|
44
|
+
new (controller: RpcController, args: RpcOperation.InitArguments): RpcOperation;
|
|
45
45
|
/**
|
|
46
46
|
* Property decorator
|
|
47
47
|
* @param payloadType
|
|
48
48
|
* @param options
|
|
49
|
-
*/ <T extends
|
|
50
|
-
prototype:
|
|
49
|
+
*/ <T extends RpcOperation.Options>(payloadType: ThunkAsync<Type> | string, options?: T): RpcOperationDecorator;
|
|
50
|
+
prototype: RpcOperation;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* @class
|
|
53
|
+
* @class RpcOperation
|
|
54
54
|
*/
|
|
55
|
-
export interface
|
|
55
|
+
export interface RpcOperation extends RpcOperationClass {
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* RpcOperation
|
|
59
59
|
*/
|
|
60
|
-
export declare const
|
|
60
|
+
export declare const RpcOperation: RpcOperationStatic;
|
|
61
61
|
/**
|
|
62
|
-
* @class
|
|
62
|
+
* @class RpcOperation
|
|
63
63
|
*/
|
|
64
|
-
declare class
|
|
65
|
-
readonly owner:
|
|
64
|
+
declare class RpcOperationClass extends DocumentElement {
|
|
65
|
+
readonly owner: RpcController;
|
|
66
66
|
readonly name: string;
|
|
67
67
|
channel: string | RegExp | (string | RegExp)[];
|
|
68
68
|
description?: string;
|
|
69
69
|
payloadType: DataType;
|
|
70
70
|
keyType?: DataType;
|
|
71
71
|
types: DataTypeMap;
|
|
72
|
-
headers:
|
|
73
|
-
response:
|
|
74
|
-
findHeader(paramName: string):
|
|
75
|
-
toJSON(): OpraSchema.
|
|
72
|
+
headers: RpcHeader[];
|
|
73
|
+
response: RpcOperationResponse;
|
|
74
|
+
findHeader(paramName: string): RpcHeader | undefined;
|
|
75
|
+
toJSON(): OpraSchema.RpcOperation;
|
|
76
76
|
}
|
|
77
77
|
export {};
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import type { SpecVersion } from './constants.js';
|
|
2
2
|
import type { DataTypeContainer } from './data-type-container.interface.js';
|
|
3
3
|
import type { HttpController } from './http/http-controller.interface.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { RpcController } from './rpc/rpc-controller.interface.js';
|
|
5
5
|
export type Transport =
|
|
6
6
|
/** HTTP **/
|
|
7
7
|
'http'
|
|
8
8
|
/** WebSocket*/
|
|
9
9
|
| 'ws'
|
|
10
|
-
/** Remote Procedure Call */
|
|
11
|
-
| 'rpc'
|
|
12
|
-
/** Message (Kafka, RabbitMQ, MQTT etc) */
|
|
13
|
-
| 'msg';
|
|
10
|
+
/** Remote Procedure Call (Kafka, RabbitMQ, MQTT etc) */
|
|
11
|
+
| 'rpc';
|
|
14
12
|
/**
|
|
15
13
|
* @interface ApiDocument
|
|
16
14
|
*/
|
|
@@ -20,7 +18,7 @@ export interface ApiDocument extends DataTypeContainer {
|
|
|
20
18
|
url?: string;
|
|
21
19
|
info?: DocumentInfo;
|
|
22
20
|
references?: Record<string, DocumentReference>;
|
|
23
|
-
api?: HttpApi |
|
|
21
|
+
api?: HttpApi | RpcApi;
|
|
24
22
|
}
|
|
25
23
|
/**
|
|
26
24
|
* @interface DocumentInfo
|
|
@@ -77,14 +75,14 @@ export interface HttpApi extends Api {
|
|
|
77
75
|
}
|
|
78
76
|
/**
|
|
79
77
|
* Message Api (Kafka, RabbitMQ, MQTT etc)
|
|
80
|
-
* @interface
|
|
78
|
+
* @interface RpcApi
|
|
81
79
|
*/
|
|
82
|
-
export interface
|
|
83
|
-
transport: '
|
|
80
|
+
export interface RpcApi extends Api {
|
|
81
|
+
transport: 'rpc';
|
|
84
82
|
/**
|
|
85
|
-
* Name of the
|
|
83
|
+
* Name of the platform. (Kafka, RabbitMQ, etc.)
|
|
86
84
|
*/
|
|
87
85
|
platform: string;
|
|
88
86
|
description?: string;
|
|
89
|
-
controllers: Record<string,
|
|
87
|
+
controllers: Record<string, RpcController>;
|
|
90
88
|
}
|
|
@@ -16,9 +16,9 @@ export * from './http/http-operation-response.interface.js';
|
|
|
16
16
|
export * from './http/http-parameter.interface.js';
|
|
17
17
|
export * from './http/http-request-body.interface.js';
|
|
18
18
|
export * from './http/http-status-range.interface.js';
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
21
|
-
export * from './
|
|
19
|
+
export * from './rpc/rpc-controller.interface.js';
|
|
20
|
+
export * from './rpc/rpc-header.interface.js';
|
|
21
|
+
export * from './rpc/rpc-operation.interface.js';
|
|
22
22
|
export * from './type-guards.js';
|
|
23
23
|
export * from './types.js';
|
|
24
24
|
export * from './value.interface.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DataTypeContainer } from '../data-type-container.interface.js';
|
|
2
|
+
import type { RpcHeader } from './rpc-header.interface.js';
|
|
3
|
+
import type { RpcOperation } from './rpc-operation.interface.js';
|
|
4
|
+
/**
|
|
5
|
+
* RPC Controller
|
|
6
|
+
* @interface RpcController
|
|
7
|
+
*/
|
|
8
|
+
export interface RpcController extends DataTypeContainer {
|
|
9
|
+
kind: RpcController.Kind;
|
|
10
|
+
description?: string;
|
|
11
|
+
operations?: Record<string, RpcOperation>;
|
|
12
|
+
headers?: RpcHeader[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @namespace RpcController
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace RpcController {
|
|
19
|
+
type Name = string;
|
|
20
|
+
const Kind = "RpcController";
|
|
21
|
+
type Kind = 'RpcController';
|
|
22
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Value } from '../value.interface.js';
|
|
2
2
|
/**
|
|
3
3
|
*
|
|
4
|
-
* @interface
|
|
4
|
+
* @interface RpcHeader
|
|
5
5
|
*/
|
|
6
|
-
export interface
|
|
6
|
+
export interface RpcHeader extends Value {
|
|
7
7
|
/**
|
|
8
8
|
* Name of the parameter. RegExp pattern can be used matching parameter name
|
|
9
9
|
*/
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { DataType } from '../data-type/data-type.interface.js';
|
|
2
2
|
import type { DataTypeContainer } from '../data-type-container.interface.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { RpcHeader } from './rpc-header.interface.js';
|
|
4
4
|
/**
|
|
5
|
-
* @interface
|
|
5
|
+
* @interface RpcOperation
|
|
6
6
|
*/
|
|
7
|
-
export interface
|
|
8
|
-
kind:
|
|
7
|
+
export interface RpcOperation extends DataTypeContainer {
|
|
8
|
+
kind: RpcOperation.Kind;
|
|
9
9
|
description?: string;
|
|
10
10
|
channel: string | RegExp | (string | RegExp)[];
|
|
11
11
|
payloadType: string | DataType;
|
|
12
12
|
keyType?: string | DataType;
|
|
13
|
-
headers?:
|
|
14
|
-
response?:
|
|
13
|
+
headers?: RpcHeader[];
|
|
14
|
+
response?: RpcOperationResponse;
|
|
15
15
|
}
|
|
16
|
-
export interface
|
|
16
|
+
export interface RpcOperationResponse {
|
|
17
17
|
description?: string;
|
|
18
18
|
channel?: string | RegExp | (string | RegExp)[];
|
|
19
19
|
payloadType: string | DataType;
|
|
20
20
|
keyType?: string | DataType;
|
|
21
|
-
headers?:
|
|
21
|
+
headers?: RpcHeader[];
|
|
22
22
|
}
|
|
23
|
-
export declare namespace
|
|
24
|
-
const Kind = "
|
|
25
|
-
type Kind = '
|
|
23
|
+
export declare namespace RpcOperation {
|
|
24
|
+
const Kind = "RpcOperation";
|
|
25
|
+
type Kind = 'RpcOperation';
|
|
26
26
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MsgController = void 0;
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @namespace MsgController
|
|
7
|
-
*/
|
|
8
|
-
var MsgController;
|
|
9
|
-
(function (MsgController) {
|
|
10
|
-
MsgController.Kind = 'MsgController';
|
|
11
|
-
})(MsgController || (exports.MsgController = MsgController = {}));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TypeThunkAsync } from 'ts-gems';
|
|
2
|
-
import type { MsgController } from '../msg/msg-controller.js';
|
|
3
|
-
import type { MsgHeader } from '../msg/msg-header.js';
|
|
4
|
-
export interface MsgControllerDecorator<T extends MsgControllerDecorator<any> = MsgControllerDecorator<any>> extends ClassDecorator {
|
|
5
|
-
Header(name: string | RegExp, optionsOrType?: MsgHeader.Options | string | TypeThunkAsync | false): T;
|
|
6
|
-
UseType(...type: TypeThunkAsync[]): T;
|
|
7
|
-
}
|
|
8
|
-
export interface MsgControllerDecoratorFactory {
|
|
9
|
-
<T extends MsgController.Options>(options?: T): MsgControllerDecorator;
|
|
10
|
-
}
|
|
11
|
-
export declare function MsgControllerDecoratorFactory<O extends MsgController.Options>(options?: O): MsgControllerDecorator;
|