@opra/common 1.0.0-beta.1 → 1.0.0-beta.3

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 (103) hide show
  1. package/browser/index.cjs +5 -5
  2. package/browser/index.mjs +5 -5
  3. package/cjs/document/api-document.js +14 -0
  4. package/cjs/document/common/api-base.js +5 -3
  5. package/cjs/document/common/document-node.js +6 -2
  6. package/cjs/document/constants.js +2 -1
  7. package/cjs/document/decorators/http-controller.decorator.js +1 -1
  8. package/cjs/document/decorators/http-operation-entity.decorator.js +1 -1
  9. package/cjs/document/decorators/http-operation.decorator.js +5 -5
  10. package/cjs/document/decorators/msg-controller.decorator.js +64 -0
  11. package/cjs/document/decorators/msg-operation.decorator.js +80 -0
  12. package/cjs/document/factory/api-document.factory.js +9 -3
  13. package/cjs/document/factory/data-type.factory.js +20 -0
  14. package/cjs/document/factory/http-api.factory.js +50 -77
  15. package/cjs/document/factory/msg-api.factory.js +202 -0
  16. package/cjs/document/http/http-api.js +5 -4
  17. package/cjs/document/http/http-controller.js +16 -0
  18. package/cjs/document/index.js +6 -0
  19. package/cjs/document/msg/msg-api.js +54 -0
  20. package/cjs/document/msg/msg-controller.js +116 -0
  21. package/cjs/document/msg/msg-header.js +40 -0
  22. package/cjs/document/msg/msg-operation-response.js +58 -0
  23. package/cjs/document/msg/msg-operation.js +80 -0
  24. package/cjs/enums/index.js +7 -0
  25. package/cjs/exception/http-errors/forbidden.error.js +1 -1
  26. package/cjs/exception/http-errors/resource-not.available.error.js +1 -1
  27. package/cjs/index.js +1 -1
  28. package/cjs/schema/msg/msg-controller.interface.js +11 -0
  29. package/cjs/schema/msg/msg-header.interface.js +2 -0
  30. package/cjs/schema/msg/msg-operation.interface.js +7 -0
  31. package/cjs/schema/opra-schema.js +3 -0
  32. package/esm/document/api-document.js +14 -0
  33. package/esm/document/common/api-base.js +5 -3
  34. package/esm/document/common/document-node.js +6 -2
  35. package/esm/document/constants.js +1 -0
  36. package/esm/document/decorators/http-controller.decorator.js +1 -1
  37. package/esm/document/decorators/http-operation-entity.decorator.js +1 -1
  38. package/esm/document/decorators/http-operation.decorator.js +5 -5
  39. package/esm/document/decorators/msg-controller.decorator.js +60 -0
  40. package/esm/document/decorators/msg-operation.decorator.js +76 -0
  41. package/esm/document/factory/api-document.factory.js +9 -3
  42. package/esm/document/factory/data-type.factory.js +20 -0
  43. package/esm/document/factory/http-api.factory.js +50 -77
  44. package/esm/document/factory/msg-api.factory.js +198 -0
  45. package/esm/document/http/http-api.js +5 -4
  46. package/esm/document/http/http-controller.js +17 -1
  47. package/esm/document/index.js +6 -0
  48. package/esm/document/msg/msg-api.js +50 -0
  49. package/esm/document/msg/msg-controller.js +113 -0
  50. package/esm/document/msg/msg-header.js +37 -0
  51. package/esm/document/msg/msg-operation-response.js +54 -0
  52. package/esm/document/msg/msg-operation.js +77 -0
  53. package/esm/enums/index.js +4 -0
  54. package/esm/exception/http-errors/forbidden.error.js +1 -1
  55. package/esm/exception/http-errors/resource-not.available.error.js +1 -1
  56. package/esm/index.js +1 -1
  57. package/esm/schema/msg/msg-controller.interface.js +8 -0
  58. package/esm/schema/msg/msg-header.interface.js +1 -0
  59. package/esm/schema/msg/msg-operation.interface.js +4 -0
  60. package/esm/schema/opra-schema.js +3 -0
  61. package/package.json +2 -2
  62. package/types/document/api-document.d.ts +5 -2
  63. package/types/document/common/api-base.d.ts +3 -2
  64. package/types/document/constants.d.ts +1 -0
  65. package/types/document/decorators/http-operation.decorator.d.ts +3 -3
  66. package/types/document/decorators/msg-controller.decorator.d.ts +11 -0
  67. package/types/document/decorators/msg-operation.decorator.d.ts +29 -0
  68. package/types/document/factory/api-document.factory.d.ts +2 -1
  69. package/types/document/factory/data-type.factory.d.ts +1 -0
  70. package/types/document/factory/http-api.factory.d.ts +10 -6
  71. package/types/document/factory/msg-api.factory.d.ts +40 -0
  72. package/types/document/http/http-api.d.ts +8 -3
  73. package/types/document/http/http-controller.d.ts +8 -2
  74. package/types/document/index.d.ts +8 -0
  75. package/types/document/msg/msg-api.d.ts +27 -0
  76. package/types/document/msg/msg-controller.d.ts +89 -0
  77. package/types/document/msg/msg-header.d.ts +47 -0
  78. package/types/document/msg/msg-operation-response.d.ts +41 -0
  79. package/types/document/msg/msg-operation.d.ts +77 -0
  80. package/types/enums/index.d.ts +4 -0
  81. package/types/exception/http-errors/forbidden.error.d.ts +1 -1
  82. package/types/index.d.cts +1 -1
  83. package/types/index.d.ts +1 -1
  84. package/types/schema/api-document.interface.d.ts +27 -4
  85. package/types/schema/msg/msg-controller.interface.d.ts +22 -0
  86. package/types/schema/msg/msg-header.interface.d.ts +19 -0
  87. package/types/schema/msg/msg-operation.interface.d.ts +26 -0
  88. package/types/schema/opra-schema.d.ts +3 -0
  89. package/cjs/http/index.js +0 -7
  90. package/esm/http/index.js +0 -4
  91. package/types/http/index.d.ts +0 -4
  92. /package/cjs/{http/enums → enums}/http-headers-codes.enum.js +0 -0
  93. /package/cjs/{http/enums → enums}/http-status-codes.enum.js +0 -0
  94. /package/cjs/{http/enums → enums}/http-status-messages.js +0 -0
  95. /package/cjs/{http/enums → enums}/mime-types.enum.js +0 -0
  96. /package/esm/{http/enums → enums}/http-headers-codes.enum.js +0 -0
  97. /package/esm/{http/enums → enums}/http-status-codes.enum.js +0 -0
  98. /package/esm/{http/enums → enums}/http-status-messages.js +0 -0
  99. /package/esm/{http/enums → enums}/mime-types.enum.js +0 -0
  100. /package/types/{http/enums → enums}/http-headers-codes.enum.d.ts +0 -0
  101. /package/types/{http/enums → enums}/http-status-codes.enum.d.ts +0 -0
  102. /package/types/{http/enums → enums}/http-status-messages.d.ts +0 -0
  103. /package/types/{http/enums → enums}/mime-types.enum.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  "super-fast-md5": "^1.0.3",
21
21
  "tslib": "^2.7.0",
22
22
  "uid": "^2.0.1",
23
- "valgen": "^5.9.0"
23
+ "valgen": "^5.10.0"
24
24
  },
25
25
  "type": "module",
26
26
  "exports": {
@@ -6,7 +6,8 @@ import { DocumentElement } from './common/document-element.js';
6
6
  import { kTypeNSMap } from './constants.js';
7
7
  import { DataType } from './data-type/data-type.js';
8
8
  import type { EnumType } from './data-type/enum-type.js';
9
- import type { HttpApi } from './http/http-api.js';
9
+ import { HttpApi } from './http/http-api.js';
10
+ import { MsgApi } from './msg/msg-api.js';
10
11
  /**
11
12
  *
12
13
  * @class ApiDocument
@@ -18,7 +19,7 @@ export declare class ApiDocument extends DocumentElement {
18
19
  info: OpraSchema.DocumentInfo;
19
20
  references: ResponsiveMap<ApiDocument>;
20
21
  types: DataTypeMap;
21
- api?: HttpApi;
22
+ api?: HttpApi | MsgApi;
22
23
  constructor();
23
24
  /**
24
25
  * Returns NS of datatype. Returns undefined if not found
@@ -26,6 +27,8 @@ export declare class ApiDocument extends DocumentElement {
26
27
  */
27
28
  getDataTypeNs(nameOrCtor: string | Type | Function | EnumType.EnumArray | EnumType.EnumObject | DataType): string | undefined;
28
29
  findDocument(id: string): ApiDocument | undefined;
30
+ get httpApi(): HttpApi;
31
+ get msgApi(): MsgApi;
29
32
  toJSON(): OpraSchema.ApiDocument;
30
33
  /**
31
34
  * Export as Opra schema definition object
@@ -4,14 +4,15 @@ import { DocumentElement } from './document-element.js';
4
4
  import type { DocumentInitContext } from './document-init-context';
5
5
  export declare namespace ApiBase {
6
6
  interface InitArguments extends Pick<OpraSchema.Api, 'description' | 'name'> {
7
+ owner: ApiDocument | ApiBase;
7
8
  }
8
9
  }
9
10
  export declare abstract class ApiBase extends DocumentElement {
10
- abstract readonly protocol: OpraSchema.Protocol;
11
+ abstract readonly transport: OpraSchema.Transport;
11
12
  readonly owner: ApiDocument | ApiBase;
12
13
  name: string;
13
14
  description?: string;
14
- protected constructor(owner: ApiDocument | ApiBase);
15
+ protected constructor(init: ApiBase.InitArguments);
15
16
  toJSON(): OpraSchema.Api;
16
17
  protected _initialize(init: ApiBase.InitArguments, context: DocumentInitContext): Promise<void>;
17
18
  }
@@ -1,5 +1,6 @@
1
1
  export declare const DATATYPE_METADATA: unique symbol;
2
2
  export declare const HTTP_CONTROLLER_METADATA: unique symbol;
3
+ export declare const MSG_CONTROLLER_METADATA: unique symbol;
3
4
  export declare const DECODER: unique symbol;
4
5
  export declare const ENCODER: unique symbol;
5
6
  export declare const DECORATOR: unique symbol;
@@ -1,9 +1,9 @@
1
1
  import type { StrictOmit, Type, TypeThunkAsync } from 'ts-gems';
2
2
  import { HttpMediaType } from '../http/http-media-type.js';
3
3
  import { HttpMultipartField } from '../http/http-multipart-field.js';
4
- import type { HttpOperation } from '../http/http-operation';
5
- import type { HttpOperationResponse } from '../http/http-operation-response';
6
- import type { HttpParameter } from '../http/http-parameter';
4
+ import type { HttpOperation } from '../http/http-operation.js';
5
+ import type { HttpOperationResponse } from '../http/http-operation-response.js';
6
+ import type { HttpParameter } from '../http/http-parameter.js';
7
7
  export interface HttpOperationDecorator {
8
8
  (target: Object, propertyKey: string): void;
9
9
  Cookie(name: string | RegExp, optionsOrType?: StrictOmit<HttpParameter.Options, 'location'> | string | Type): this;
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,29 @@
1
+ import type { ThunkAsync, Type, TypeThunkAsync } from 'ts-gems';
2
+ import type { MsgHeader } from '../msg/msg-header.js';
3
+ import type { MsgOperation } from '../msg/msg-operation.js';
4
+ import type { MsgOperationResponse } from '../msg/msg-operation-response.js';
5
+ export interface MsgOperationDecorator {
6
+ (target: Object, propertyKey: string): void;
7
+ Header(name: string | RegExp, optionsOrType?: MsgHeader.Options | string | TypeThunkAsync): this;
8
+ Response(payloadType: TypeThunkAsync | string, options?: MsgOperationResponse.Options): MsgOperationResponseDecorator;
9
+ UseType(...type: Type[]): this;
10
+ }
11
+ export interface MsgOperationResponseDecorator {
12
+ (target: Object, propertyKey: string): void;
13
+ Header(name: string | RegExp, optionsOrType?: MsgHeader.Options | string | TypeThunkAsync): this;
14
+ }
15
+ export interface MsgOperationDecoratorFactory {
16
+ /**
17
+ * Property decorator
18
+ * @param decoratorChain
19
+ * @param payloadType
20
+ * @param options
21
+ */ <T extends MsgOperation.Options>(decoratorChain: Function[], payloadType: ThunkAsync<Type> | string, options?: T): MsgOperationDecorator;
22
+ }
23
+ export declare namespace MsgOperationDecoratorFactory {
24
+ type AugmentationFunction = (decorator: MsgOperationDecorator, decoratorChain: Function[], payloadType: ThunkAsync<Type> | string, options?: MsgOperation.Options) => void;
25
+ }
26
+ export declare function MsgOperationDecoratorFactory(decoratorChain: Function[], payloadType: ThunkAsync<Type> | string | TypeThunkAsync, options?: MsgOperation.Options): MsgOperationDecorator;
27
+ export declare namespace MsgOperationDecoratorFactory {
28
+ var augment: (fn: MsgOperationDecoratorFactory.AugmentationFunction) => void;
29
+ }
@@ -4,11 +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
8
  export declare namespace ApiDocumentFactory {
8
9
  interface InitArguments extends PartialSome<StrictOmit<OpraSchema.ApiDocument, 'id' | 'references' | 'types' | 'api'>, 'spec'> {
9
10
  references?: Record<string, ReferenceThunk>;
10
11
  types?: DataTypeInitSources;
11
- api?: HttpApiFactory.InitArguments;
12
+ api?: StrictOmit<HttpApiFactory.InitArguments, 'owner'> | StrictOmit<MsgApiFactory.InitArguments, 'owner'>;
12
13
  }
13
14
  type ReferenceSource = string | OpraSchema.ApiDocument | InitArguments | ApiDocument;
14
15
  type ReferenceThunk = ThunkAsync<ReferenceSource>;
@@ -60,6 +60,7 @@ export declare namespace DataTypeFactory {
60
60
  */
61
61
  export declare class DataTypeFactory {
62
62
  static createDataType(context: DocumentInitContext | undefined, owner: DocumentElement, thunk: DataTypeFactory.DataTypeThunk): Promise<DataType | undefined>;
63
+ static resolveDataType(context: DocumentInitContext | undefined, owner: DocumentElement, v: any): Promise<DataType>;
63
64
  /**
64
65
  *
65
66
  * @param context
@@ -1,6 +1,5 @@
1
- import type { StrictOmit, Type } from 'ts-gems';
1
+ import type { Type } from 'ts-gems';
2
2
  import { OpraSchema } from '../../schema/index.js';
3
- import { ApiDocument } from '../api-document.js';
4
3
  import { DocumentInitContext } from '../common/document-init-context.js';
5
4
  import { HttpApi } from '../http/http-api.js';
6
5
  import { HttpController } from '../http/http-controller.js';
@@ -9,7 +8,7 @@ import { HttpOperation } from '../http/http-operation.js';
9
8
  import { HttpOperationResponse } from '../http/http-operation-response.js';
10
9
  import { HttpRequestBody } from '../http/http-request-body.js';
11
10
  export declare namespace HttpApiFactory {
12
- interface InitArguments extends StrictOmit<OpraSchema.HttpApi, 'controllers'> {
11
+ interface InitArguments extends HttpApi.InitArguments {
13
12
  controllers: Type[] | any[] | ((parent: any) => any) | OpraSchema.HttpApi['controllers'];
14
13
  }
15
14
  }
@@ -20,11 +19,16 @@ export declare class HttpApiFactory {
20
19
  /**
21
20
  * Generates HttpApi
22
21
  * @param context
23
- * @param document
24
22
  * @param init
25
23
  */
26
- static createApi(context: DocumentInitContext, document: ApiDocument, init: HttpApiFactory.InitArguments): Promise<HttpApi>;
27
- protected static _createController(context: DocumentInitContext, parent: HttpApi | HttpController, thunk: Type | object | Function | OpraSchema.HttpController, name?: string): Promise<HttpController | undefined | void>;
24
+ static createApi(context: DocumentInitContext, init: HttpApiFactory.InitArguments): Promise<HttpApi>;
25
+ protected static _createControllers(context: DocumentInitContext, parent: HttpApi | HttpController, controllers: Type[] | any[] | ((parent: any) => any) | OpraSchema.HttpApi['controllers']): Promise<void>;
26
+ protected static _resolveControllerMetadata(context: DocumentInitContext, parent: HttpApi | HttpController, thunk: Type | object | Function | OpraSchema.HttpController): Promise<{
27
+ metadata: HttpController.Metadata | OpraSchema.HttpController;
28
+ instance: any;
29
+ ctor: Type;
30
+ } | undefined | void>;
31
+ protected static _createController(context: DocumentInitContext, parent: HttpApi | HttpController, metadata: HttpController.Metadata | OpraSchema.HttpController, instance: any, ctor: Type): Promise<HttpController | undefined | void>;
28
32
  /**
29
33
  * Initializes HttpOperation
30
34
  * @param context
@@ -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 { MsgApi } from '../msg/msg-api.js';
5
+ import { MsgController } from '../msg/msg-controller.js';
6
+ import { MsgOperation } from '../msg/msg-operation.js';
7
+ import { MsgOperationResponse } from '../msg/msg-operation-response.js';
8
+ export declare namespace MsgApiFactory {
9
+ interface InitArguments extends MsgApi.InitArguments {
10
+ controllers: Type[] | any[] | ((parent: any) => any) | OpraSchema.MsgApi['controllers'];
11
+ }
12
+ }
13
+ /**
14
+ * @class MsgApiFactory
15
+ */
16
+ export declare class MsgApiFactory {
17
+ /**
18
+ * Generates MsgApi
19
+ * @param context
20
+ * @param init
21
+ */
22
+ static createApi(context: DocumentInitContext, init: MsgApiFactory.InitArguments): Promise<MsgApi>;
23
+ protected static _createController(context: DocumentInitContext, parent: MsgApi, thunk: Type | object | Function | OpraSchema.MsgController, name?: string): Promise<MsgController | undefined | void>;
24
+ /**
25
+ * Initializes MsgOperation
26
+ * @param context
27
+ * @param operation
28
+ * @param metadata
29
+ * @protected
30
+ */
31
+ protected static _initMsgOperation(context: DocumentInitContext, operation: MsgOperation, metadata: MsgOperation.Metadata | OpraSchema.MsgOperation): Promise<void>;
32
+ /**
33
+ * Initializes MsgOperationResponse
34
+ * @param context
35
+ * @param response
36
+ * @param metadata
37
+ * @protected
38
+ */
39
+ protected static _initMsgOperationResponse(context: DocumentInitContext, response: MsgOperationResponse, metadata: MsgOperationResponse.Metadata | OpraSchema.MsgOperationResponse): Promise<void>;
40
+ }
@@ -1,20 +1,25 @@
1
- import type { Type } from 'ts-gems';
1
+ import type { StrictOmit, Type } from 'ts-gems';
2
2
  import { ResponsiveMap } from '../../helpers/index.js';
3
3
  import { OpraSchema } from '../../schema/index.js';
4
4
  import type { ApiDocument } from '../api-document';
5
5
  import { ApiBase } from '../common/api-base.js';
6
6
  import { HttpController } from './http-controller.js';
7
7
  import type { HttpOperation } from './http-operation.js';
8
+ export declare namespace HttpApi {
9
+ interface InitArguments extends ApiBase.InitArguments, StrictOmit<OpraSchema.HttpApi, 'controllers'> {
10
+ transport: 'http';
11
+ }
12
+ }
8
13
  /**
9
14
  * @class HttpApi
10
15
  */
11
16
  export declare class HttpApi extends ApiBase {
12
17
  protected _controllerReverseMap: WeakMap<Type, HttpController | null>;
13
18
  readonly owner: ApiDocument;
14
- readonly protocol = "http";
19
+ readonly transport = "http";
15
20
  controllers: ResponsiveMap<HttpController>;
16
21
  url?: string;
17
- constructor(owner: ApiDocument);
22
+ constructor(init: HttpApi.InitArguments);
18
23
  findController(controller: Type): HttpController | undefined;
19
24
  findController(resourcePath: string): HttpController | undefined;
20
25
  findOperation(controller: Type, operationName: string): HttpOperation | undefined;
@@ -19,6 +19,8 @@ export declare namespace HttpController {
19
19
  types?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[];
20
20
  operations?: Record<string, HttpOperation.Metadata>;
21
21
  parameters?: HttpParameter.Metadata[];
22
+ onInit?: (resource: HttpController) => void;
23
+ onShutdown?: (resource: HttpController) => void | Promise<void>;
22
24
  }
23
25
  interface Options extends Partial<Pick<OpraSchema.HttpController, 'description' | 'path'>> {
24
26
  name?: string;
@@ -27,11 +29,11 @@ export declare namespace HttpController {
27
29
  interface InitArguments extends Combine<{
28
30
  instance?: object;
29
31
  ctor?: Type;
30
- }, Pick<Metadata, 'name' | 'description' | 'path'>> {
32
+ }, Pick<Metadata, 'name' | 'description' | 'path' | 'onInit' | 'onShutdown'>> {
31
33
  }
32
34
  }
33
35
  /**
34
- * Type definition for HttpOperation
36
+ * Type definition for HttpController
35
37
  * @class HttpController
36
38
  */
37
39
  export interface HttpControllerStatic extends HttpControllerDecoratorFactory {
@@ -42,6 +44,8 @@ export interface HttpControllerStatic extends HttpControllerDecoratorFactory {
42
44
  */
43
45
  new (owner: HttpApi | HttpController, args: HttpController.InitArguments): HttpController;
44
46
  prototype: HttpController;
47
+ OnInit(): PropertyDecorator;
48
+ OnShutdown(): PropertyDecorator;
45
49
  }
46
50
  /**
47
51
  * Type definition of HttpController prototype
@@ -69,6 +73,8 @@ declare class HttpControllerClass extends DocumentElement {
69
73
  operations: ResponsiveMap<HttpOperation>;
70
74
  controllers: ResponsiveMap<HttpController>;
71
75
  types: DataTypeMap;
76
+ onInit?: (resource: HttpController) => void;
77
+ onShutdown?: (resource: HttpController) => void | Promise<void>;
72
78
  /**
73
79
  * @property isRoot
74
80
  */
@@ -1,4 +1,5 @@
1
1
  import 'reflect-metadata';
2
+ import * as MsgOperationDecorator_ from './decorators/msg-operation.decorator.js';
2
3
  import * as DataTypeFactory_ from './factory/data-type.factory.js';
3
4
  import * as HttpApiFactory_ from './factory/http-api.factory.js';
4
5
  export * from './api-document.js';
@@ -23,6 +24,7 @@ export * from './data-type/primitive-types/index.js';
23
24
  export * from './data-type/required-type.js';
24
25
  export * from './data-type/simple-type.js';
25
26
  export * from './decorators/http-operation-entity.decorator.js';
27
+ export type { MsgOperationDecorator } from './decorators/msg-operation.decorator.js';
26
28
  export * from './factory/api-document.factory.js';
27
29
  export * from './http/http-api.js';
28
30
  export * from './http/http-controller.js';
@@ -33,7 +35,13 @@ export * from './http/http-operation-response.js';
33
35
  export * from './http/http-parameter.js';
34
36
  export * from './http/http-request-body.js';
35
37
  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';
36
43
  export declare namespace classes {
37
44
  export import HttpApiFactory = HttpApiFactory_.HttpApiFactory;
38
45
  export import DataTypeFactory = DataTypeFactory_.DataTypeFactory;
46
+ export import MsgOperationDecoratorFactory = MsgOperationDecorator_.MsgOperationDecoratorFactory;
39
47
  }
@@ -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 { MsgController } from './msg-controller.js';
7
+ import { MsgOperation } from './msg-operation.js';
8
+ export declare namespace MsgApi {
9
+ interface InitArguments extends ApiBase.InitArguments, StrictOmit<OpraSchema.MsgApi, 'controllers'> {
10
+ }
11
+ }
12
+ /**
13
+ * @class MsgApi
14
+ */
15
+ export declare class MsgApi extends ApiBase {
16
+ protected _controllerReverseMap: WeakMap<Type, MsgController | null>;
17
+ readonly owner: ApiDocument;
18
+ readonly transport = "msg";
19
+ platform: string;
20
+ controllers: ResponsiveMap<MsgController>;
21
+ constructor(init: MsgApi.InitArguments);
22
+ findController(controller: Type): MsgController | undefined;
23
+ findController(name: string): MsgController | undefined;
24
+ findOperation(controller: Type, operationName: string): MsgOperation | undefined;
25
+ findOperation(controllerName: string, operationName: string): MsgOperation | undefined;
26
+ toJSON(): OpraSchema.MsgApi;
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 { MsgControllerDecoratorFactory } from '../decorators/msg-controller.decorator.js';
8
+ import { nodeInspectCustom } from '../utils/inspect.util.js';
9
+ import type { MsgApi } from './msg-api.js';
10
+ import type { MsgHeader } from './msg-header.js';
11
+ import type { MsgOperation } from './msg-operation.js';
12
+ /**
13
+ * @namespace MsgController
14
+ */
15
+ export declare namespace MsgController {
16
+ interface Metadata extends Pick<OpraSchema.MsgController, 'description'> {
17
+ name: string;
18
+ types?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[];
19
+ operations?: Record<string, MsgOperation.Metadata>;
20
+ headers?: MsgHeader.Metadata[];
21
+ onInit?: (resource: MsgController) => void;
22
+ onShutdown?: (resource: MsgController) => void | Promise<void>;
23
+ }
24
+ interface Options extends Partial<Pick<OpraSchema.MsgController, '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 MsgController
35
+ * @class MsgController
36
+ */
37
+ export interface MsgControllerStatic extends MsgControllerDecoratorFactory {
38
+ /**
39
+ * Class constructor of MsgController
40
+ * @param owner
41
+ * @param args
42
+ */
43
+ new (owner: MsgApi | MsgController, args: MsgController.InitArguments): MsgController;
44
+ prototype: MsgController;
45
+ OnInit(): PropertyDecorator;
46
+ OnShutdown(): PropertyDecorator;
47
+ }
48
+ /**
49
+ * Type definition of MsgController prototype
50
+ * @interface MsgController
51
+ */
52
+ export interface MsgController extends MsgControllerClass {
53
+ }
54
+ /**
55
+ * MsgController
56
+ */
57
+ export declare const MsgController: MsgControllerStatic;
58
+ /**
59
+ *
60
+ * @class MsgController
61
+ */
62
+ declare class MsgControllerClass extends DocumentElement {
63
+ protected _controllerReverseMap: WeakMap<Type, MsgController | null>;
64
+ readonly kind: OpraSchema.MsgController.Kind;
65
+ readonly name: string;
66
+ description?: string;
67
+ path: string;
68
+ instance?: any;
69
+ ctor?: Type;
70
+ headers: MsgHeader[];
71
+ operations: ResponsiveMap<MsgOperation>;
72
+ types: DataTypeMap;
73
+ onInit?: (resource: MsgController) => void;
74
+ onShutdown?: (resource: MsgController) => void | Promise<void>;
75
+ findHeader(paramName: string, location?: OpraSchema.HttpParameterLocation): MsgHeader | undefined;
76
+ /**
77
+ *
78
+ */
79
+ toString(): string;
80
+ /**
81
+ *
82
+ */
83
+ toJSON(): OpraSchema.MsgController;
84
+ /**
85
+ *
86
+ */
87
+ protected [nodeInspectCustom](): string;
88
+ }
89
+ export {};
@@ -0,0 +1,47 @@
1
+ import { type Combine, type StrictOmit, type TypeThunkAsync } from 'ts-gems';
2
+ import type { OpraSchema } from '../../schema/index.js';
3
+ import { DocumentElement } from '../common/document-element.js';
4
+ import { Value } from '../common/value.js';
5
+ import { DataType } from '../data-type/data-type.js';
6
+ import type { EnumType } from '../data-type/enum-type.js';
7
+ /**
8
+ * @namespace MsgHeader
9
+ */
10
+ export declare namespace MsgHeader {
11
+ interface Metadata extends StrictOmit<OpraSchema.MsgHeader, 'type'> {
12
+ name: string | RegExp;
13
+ type?: string | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
14
+ }
15
+ interface Options extends Partial<StrictOmit<Metadata, 'type'>> {
16
+ type?: string | TypeThunkAsync | object;
17
+ }
18
+ interface InitArguments extends Combine<{
19
+ type?: DataType;
20
+ }, Metadata> {
21
+ }
22
+ }
23
+ /**
24
+ * Type definition for MsgHeader
25
+ * @class MsgHeader
26
+ */
27
+ interface MsgHeaderStatic {
28
+ new (owner: DocumentElement, args: MsgHeader.InitArguments): MsgHeader;
29
+ prototype: MsgHeader;
30
+ }
31
+ /**
32
+ * Type definition of MsgHeader prototype
33
+ * @interface MsgHeader
34
+ */
35
+ export interface MsgHeader extends MsgHeaderClass {
36
+ }
37
+ export declare const MsgHeader: MsgHeaderStatic;
38
+ /**
39
+ * @class MsgHeader
40
+ */
41
+ declare class MsgHeaderClass extends Value {
42
+ readonly owner: DocumentElement;
43
+ deprecated?: boolean | string;
44
+ required?: boolean;
45
+ toJSON(): OpraSchema.MsgHeader;
46
+ }
47
+ export {};
@@ -0,0 +1,41 @@
1
+ import type { Combine, Type } from 'ts-gems';
2
+ import { TypeThunkAsync } from 'ts-gems/lib/types';
3
+ import { OpraSchema } from '../../schema/index.js';
4
+ import { DocumentElement } from '../common/document-element.js';
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';
8
+ /**
9
+ * @namespace MsgOperationResponse
10
+ */
11
+ export declare namespace MsgOperationResponse {
12
+ interface Metadata extends Combine<{
13
+ payloadType?: TypeThunkAsync | string;
14
+ keyType?: TypeThunkAsync | string;
15
+ headers?: MsgHeader.Metadata[];
16
+ }, OpraSchema.MsgOperationResponse> {
17
+ }
18
+ interface Options extends Combine<{
19
+ keyType?: Type | string;
20
+ }, Pick<Metadata, 'channel' | 'description'>> {
21
+ }
22
+ interface InitArguments extends Combine<{
23
+ payloadType?: DataType | string | Type;
24
+ keyType?: DataType | string | Type;
25
+ }, Pick<Metadata, 'channel' | 'description'>> {
26
+ }
27
+ }
28
+ /**
29
+ * @class MsgOperationResponse
30
+ */
31
+ export declare class MsgOperationResponse extends DocumentElement {
32
+ readonly owner: MsgOperation;
33
+ channel?: string | RegExp | (string | RegExp)[];
34
+ description?: string;
35
+ payloadType: DataType;
36
+ keyType?: DataType;
37
+ headers: MsgHeader[];
38
+ constructor(owner: MsgOperation, initArgs?: MsgOperationResponse.InitArguments);
39
+ findHeader(paramName: string): MsgHeader | undefined;
40
+ toJSON(): OpraSchema.MsgOperationResponse;
41
+ }
@@ -0,0 +1,77 @@
1
+ import type { Combine, ThunkAsync, Type } from 'ts-gems';
2
+ import { TypeThunkAsync } from 'ts-gems/lib/types';
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 { DataType } from '../data-type/data-type.js';
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';
12
+ /**
13
+ * @namespace MsgOperation
14
+ */
15
+ export declare namespace MsgOperation {
16
+ interface Metadata extends Pick<OpraSchema.MsgOperation, 'description' | 'channel'> {
17
+ payloadType: TypeThunkAsync | string;
18
+ keyType?: TypeThunkAsync | string;
19
+ types?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[];
20
+ headers?: MsgHeader.Metadata[];
21
+ response?: MsgOperationResponse.Metadata;
22
+ }
23
+ interface Options extends Partial<Pick<Metadata, 'description' | 'keyType'>> {
24
+ channel?: (string | RegExp) | (string | RegExp)[];
25
+ }
26
+ interface InitArguments extends Combine<{
27
+ name: string;
28
+ types?: DataType[];
29
+ payloadType?: DataType | string | Type;
30
+ keyType?: DataType | string | Type;
31
+ }, Pick<Metadata, 'description' | 'channel'>> {
32
+ }
33
+ }
34
+ /**
35
+ * Type definition for MsgOperation
36
+ * @class MsgOperation
37
+ */
38
+ export interface MsgOperationStatic {
39
+ /**
40
+ * Class constructor of MsgOperation
41
+ * @param controller
42
+ * @param args
43
+ */
44
+ new (controller: MsgController, args: MsgOperation.InitArguments): MsgOperation;
45
+ /**
46
+ * Property decorator
47
+ * @param payloadType
48
+ * @param options
49
+ */ <T extends MsgOperation.Options>(payloadType: ThunkAsync<Type> | string, options?: T): MsgOperationDecorator;
50
+ prototype: MsgOperation;
51
+ }
52
+ /**
53
+ * @class MsgOperation
54
+ */
55
+ export interface MsgOperation extends MsgOperationClass {
56
+ }
57
+ /**
58
+ * MsgOperation
59
+ */
60
+ export declare const MsgOperation: MsgOperationStatic;
61
+ /**
62
+ * @class MsgOperation
63
+ */
64
+ declare class MsgOperationClass extends DocumentElement {
65
+ readonly owner: MsgController;
66
+ readonly name: string;
67
+ channel: string | RegExp | (string | RegExp)[];
68
+ description?: string;
69
+ payloadType: DataType;
70
+ keyType?: DataType;
71
+ types: DataTypeMap;
72
+ headers: MsgHeader[];
73
+ response: MsgOperationResponse;
74
+ findHeader(paramName: string): MsgHeader | undefined;
75
+ toJSON(): OpraSchema.MsgOperation;
76
+ }
77
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './http-headers-codes.enum.js';
2
+ export * from './http-status-codes.enum.js';
3
+ export * from './http-status-messages.js';
4
+ export * from './mime-types.enum.js';
@@ -1,4 +1,4 @@
1
- import { HttpStatusCode } from '../../http/index.js';
1
+ import { HttpStatusCode } from '../../enums/index.js';
2
2
  import type { ErrorIssue } from '../error-issue.js';
3
3
  import { OpraHttpError } from '../opra-http-error.js';
4
4
  /**
package/types/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  export * from './document/index.js';
2
+ export * from './enums/index.js';
2
3
  export * from './exception/index.js';
3
4
  export * from './filter/index.js';
4
5
  export * from './helpers/index.js';
5
- export * from './http/index.js';
6
6
  export * from './i18n/index.js';
7
7
  export * from './schema/index.js';
8
8
  export * from './types.js';
package/types/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export * from './document/index.js';
2
+ export * from './enums/index.js';
2
3
  export * from './exception/index.js';
3
4
  export * from './filter/index.js';
4
5
  export * from './helpers/index.js';
5
- export * from './http/index.js';
6
6
  export * from './i18n/index.js';
7
7
  export * from './schema/index.js';
8
8
  export * from './types.js';