@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.
Files changed (64) hide show
  1. package/browser/index.cjs +5 -5
  2. package/browser/index.mjs +5 -5
  3. package/cjs/document/api-document.js +4 -4
  4. package/cjs/document/constants.js +2 -2
  5. package/cjs/document/decorators/{msg-controller.decorator.js → rpc-controller.decorator.js} +13 -8
  6. package/cjs/document/decorators/{msg-operation.decorator.js → rpc-operation.decorator.js} +6 -6
  7. package/cjs/document/factory/api-document.factory.js +3 -3
  8. package/cjs/document/factory/{msg-api.factory.js → rpc-api.factory.js} +28 -28
  9. package/cjs/document/http/http-operation.js +6 -0
  10. package/cjs/document/index.js +8 -6
  11. package/cjs/document/{msg/msg-api.js → rpc/rpc-api.js} +5 -5
  12. package/cjs/document/{msg/msg-controller.js → rpc/rpc-controller.js} +20 -20
  13. package/cjs/document/{msg/msg-header.js → rpc/rpc-header.js} +5 -5
  14. package/cjs/document/{msg/msg-operation-response.js → rpc/rpc-operation-response.js} +4 -4
  15. package/cjs/document/{msg/msg-operation.js → rpc/rpc-operation.js} +10 -10
  16. package/cjs/schema/opra-schema.js +3 -3
  17. package/cjs/schema/rpc/rpc-controller.interface.js +11 -0
  18. package/cjs/schema/rpc/rpc-operation.interface.js +7 -0
  19. package/esm/document/api-document.js +4 -4
  20. package/esm/document/constants.js +1 -1
  21. package/esm/document/decorators/{msg-controller.decorator.js → rpc-controller.decorator.js} +13 -8
  22. package/esm/document/decorators/{msg-operation.decorator.js → rpc-operation.decorator.js} +6 -6
  23. package/esm/document/factory/api-document.factory.js +3 -3
  24. package/esm/document/factory/{msg-api.factory.js → rpc-api.factory.js} +27 -27
  25. package/esm/document/http/http-operation.js +6 -0
  26. package/esm/document/index.js +8 -6
  27. package/esm/document/{msg/msg-api.js → rpc/rpc-api.js} +3 -3
  28. package/esm/document/{msg/msg-controller.js → rpc/rpc-controller.js} +20 -20
  29. package/esm/document/{msg/msg-header.js → rpc/rpc-header.js} +4 -4
  30. package/esm/document/{msg/msg-operation-response.js → rpc/rpc-operation-response.js} +2 -2
  31. package/esm/document/{msg/msg-operation.js → rpc/rpc-operation.js} +9 -9
  32. package/esm/schema/opra-schema.js +3 -3
  33. package/esm/schema/rpc/rpc-controller.interface.js +8 -0
  34. package/esm/schema/rpc/rpc-operation.interface.js +4 -0
  35. package/package.json +1 -1
  36. package/types/document/api-document.d.ts +3 -3
  37. package/types/document/constants.d.ts +1 -1
  38. package/types/document/decorators/rpc-controller.decorator.d.ts +20 -0
  39. package/types/document/decorators/rpc-operation.decorator.d.ts +32 -0
  40. package/types/document/factory/api-document.factory.d.ts +2 -2
  41. package/types/document/factory/rpc-api.factory.d.ts +40 -0
  42. package/types/document/index.d.ts +11 -8
  43. package/types/document/rpc/rpc-api.d.ts +27 -0
  44. package/types/document/rpc/rpc-controller.d.ts +89 -0
  45. package/types/document/{msg/msg-header.d.ts → rpc/rpc-header.d.ts} +15 -15
  46. package/types/document/{msg/msg-operation-response.d.ts → rpc/rpc-operation-response.d.ts} +13 -13
  47. package/types/document/{msg/msg-operation.d.ts → rpc/rpc-operation.d.ts} +27 -27
  48. package/types/schema/api-document.interface.d.ts +9 -11
  49. package/types/schema/opra-schema.d.ts +3 -3
  50. package/types/schema/rpc/rpc-controller.interface.d.ts +22 -0
  51. package/types/schema/{msg/msg-header.interface.d.ts → rpc/rpc-header.interface.d.ts} +2 -2
  52. package/types/schema/{msg/msg-operation.interface.d.ts → rpc/rpc-operation.interface.d.ts} +11 -11
  53. package/cjs/schema/msg/msg-controller.interface.js +0 -11
  54. package/cjs/schema/msg/msg-operation.interface.js +0 -7
  55. package/esm/schema/msg/msg-controller.interface.js +0 -8
  56. package/esm/schema/msg/msg-operation.interface.js +0 -4
  57. package/types/document/decorators/msg-controller.decorator.d.ts +0 -11
  58. package/types/document/decorators/msg-operation.decorator.d.ts +0 -29
  59. package/types/document/factory/msg-api.factory.d.ts +0 -40
  60. package/types/document/msg/msg-api.d.ts +0 -27
  61. package/types/document/msg/msg-controller.d.ts +0 -89
  62. package/types/schema/msg/msg-controller.interface.d.ts +0 -22
  63. /package/cjs/schema/{msg/msg-header.interface.js → rpc/rpc-header.interface.js} +0 -0
  64. /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 { MsgApiFactory } from './msg-api.factory.js';
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<MsgApiFactory.InitArguments, 'owner'>;
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 MsgOperationDecorator_ from './decorators/msg-operation.decorator.js';
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 { MsgOperationDecorator } from './decorators/msg-operation.decorator.js';
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 './msg/msg-api.js';
39
- export * from './msg/msg-controller.js';
40
- export * from './msg/msg-header.js';
41
- export * from './msg/msg-operation.js';
42
- export type { MsgOperationResponse } from './msg/msg-operation-response.js';
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 MsgOperationDecoratorFactory = MsgOperationDecorator_.MsgOperationDecoratorFactory;
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 MsgHeader
8
+ * @namespace RpcHeader
9
9
  */
10
- export declare namespace MsgHeader {
11
- interface Metadata extends StrictOmit<OpraSchema.MsgHeader, 'type'> {
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 MsgHeader
25
- * @class MsgHeader
24
+ * Type definition for RpcHeader
25
+ * @class RpcHeader
26
26
  */
27
- interface MsgHeaderStatic {
28
- new (owner: DocumentElement, args: MsgHeader.InitArguments): MsgHeader;
29
- prototype: MsgHeader;
27
+ interface RpcHeaderStatic {
28
+ new (owner: DocumentElement, args: RpcHeader.InitArguments): RpcHeader;
29
+ prototype: RpcHeader;
30
30
  }
31
31
  /**
32
- * Type definition of MsgHeader prototype
33
- * @interface MsgHeader
32
+ * Type definition of RpcHeader prototype
33
+ * @interface RpcHeader
34
34
  */
35
- export interface MsgHeader extends MsgHeaderClass {
35
+ export interface RpcHeader extends RpcHeaderClass {
36
36
  }
37
- export declare const MsgHeader: MsgHeaderStatic;
37
+ export declare const RpcHeader: RpcHeaderStatic;
38
38
  /**
39
- * @class MsgHeader
39
+ * @class RpcHeader
40
40
  */
41
- declare class MsgHeaderClass extends Value {
41
+ declare class RpcHeaderClass extends Value {
42
42
  readonly owner: DocumentElement;
43
43
  deprecated?: boolean | string;
44
44
  required?: boolean;
45
- toJSON(): OpraSchema.MsgHeader;
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 { MsgHeader } from './msg-header.js';
7
- import type { MsgOperation } from './msg-operation.js';
6
+ import type { RpcHeader } from './rpc-header';
7
+ import type { RpcOperation } from './rpc-operation';
8
8
  /**
9
- * @namespace MsgOperationResponse
9
+ * @namespace RpcOperationResponse
10
10
  */
11
- export declare namespace MsgOperationResponse {
11
+ export declare namespace RpcOperationResponse {
12
12
  interface Metadata extends Combine<{
13
13
  payloadType?: TypeThunkAsync | string;
14
14
  keyType?: TypeThunkAsync | string;
15
- headers?: MsgHeader.Metadata[];
16
- }, OpraSchema.MsgOperationResponse> {
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 MsgOperationResponse
29
+ * @class RpcOperationResponse
30
30
  */
31
- export declare class MsgOperationResponse extends DocumentElement {
32
- readonly owner: MsgOperation;
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: MsgHeader[];
38
- constructor(owner: MsgOperation, initArgs?: MsgOperationResponse.InitArguments);
39
- findHeader(paramName: string): MsgHeader | undefined;
40
- toJSON(): OpraSchema.MsgOperationResponse;
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 { MsgOperationDecorator } from '../decorators/msg-operation.decorator.js';
9
- import type { MsgController } from './msg-controller.js';
10
- import type { MsgHeader } from './msg-header.js';
11
- import type { MsgOperationResponse } from './msg-operation-response.js';
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 MsgOperation
13
+ * @namespace RpcOperation
14
14
  */
15
- export declare namespace MsgOperation {
16
- interface Metadata extends Pick<OpraSchema.MsgOperation, 'description' | 'channel'> {
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?: MsgHeader.Metadata[];
21
- response?: MsgOperationResponse.Metadata;
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 MsgOperation
36
- * @class MsgOperation
35
+ * Type definition for RpcOperation
36
+ * @class RpcOperation
37
37
  */
38
- export interface MsgOperationStatic {
38
+ export interface RpcOperationStatic {
39
39
  /**
40
- * Class constructor of MsgOperation
40
+ * Class constructor of RpcOperation
41
41
  * @param controller
42
42
  * @param args
43
43
  */
44
- new (controller: MsgController, args: MsgOperation.InitArguments): MsgOperation;
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 MsgOperation.Options>(payloadType: ThunkAsync<Type> | string, options?: T): MsgOperationDecorator;
50
- prototype: MsgOperation;
49
+ */ <T extends RpcOperation.Options>(payloadType: ThunkAsync<Type> | string, options?: T): RpcOperationDecorator;
50
+ prototype: RpcOperation;
51
51
  }
52
52
  /**
53
- * @class MsgOperation
53
+ * @class RpcOperation
54
54
  */
55
- export interface MsgOperation extends MsgOperationClass {
55
+ export interface RpcOperation extends RpcOperationClass {
56
56
  }
57
57
  /**
58
- * MsgOperation
58
+ * RpcOperation
59
59
  */
60
- export declare const MsgOperation: MsgOperationStatic;
60
+ export declare const RpcOperation: RpcOperationStatic;
61
61
  /**
62
- * @class MsgOperation
62
+ * @class RpcOperation
63
63
  */
64
- declare class MsgOperationClass extends DocumentElement {
65
- readonly owner: MsgController;
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: MsgHeader[];
73
- response: MsgOperationResponse;
74
- findHeader(paramName: string): MsgHeader | undefined;
75
- toJSON(): OpraSchema.MsgOperation;
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 { MsgController } from './msg/msg-controller.interface.js';
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 | MsgApi;
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 MsgApi
78
+ * @interface RpcApi
81
79
  */
82
- export interface MsgApi extends Api {
83
- transport: 'msg';
80
+ export interface RpcApi extends Api {
81
+ transport: 'rpc';
84
82
  /**
85
- * Name of the message platform. (Kafka, RabbitMQ, etc.)
83
+ * Name of the platform. (Kafka, RabbitMQ, etc.)
86
84
  */
87
85
  platform: string;
88
86
  description?: string;
89
- controllers: Record<string, MsgController>;
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 './msg/msg-controller.interface.js';
20
- export * from './msg/msg-header.interface.js';
21
- export * from './msg/msg-operation.interface.js';
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 MsgHeader
4
+ * @interface RpcHeader
5
5
  */
6
- export interface MsgHeader extends Value {
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 { MsgHeader } from './msg-header.interface.js';
3
+ import type { RpcHeader } from './rpc-header.interface.js';
4
4
  /**
5
- * @interface MsgOperation
5
+ * @interface RpcOperation
6
6
  */
7
- export interface MsgOperation extends DataTypeContainer {
8
- kind: MsgOperation.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?: MsgHeader[];
14
- response?: MsgOperationResponse;
13
+ headers?: RpcHeader[];
14
+ response?: RpcOperationResponse;
15
15
  }
16
- export interface MsgOperationResponse {
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?: MsgHeader[];
21
+ headers?: RpcHeader[];
22
22
  }
23
- export declare namespace MsgOperation {
24
- const Kind = "MsgOperation";
25
- type Kind = 'MsgOperation';
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,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MsgOperation = void 0;
4
- var MsgOperation;
5
- (function (MsgOperation) {
6
- MsgOperation.Kind = 'MsgOperation';
7
- })(MsgOperation || (exports.MsgOperation = MsgOperation = {}));
@@ -1,8 +0,0 @@
1
- /**
2
- *
3
- * @namespace MsgController
4
- */
5
- export var MsgController;
6
- (function (MsgController) {
7
- MsgController.Kind = 'MsgController';
8
- })(MsgController || (MsgController = {}));
@@ -1,4 +0,0 @@
1
- export var MsgOperation;
2
- (function (MsgOperation) {
3
- MsgOperation.Kind = 'MsgOperation';
4
- })(MsgOperation || (MsgOperation = {}));
@@ -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;