@opra/common 1.0.0-beta.2 → 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 (105) 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/rpc-controller.decorator.js +69 -0
  11. package/cjs/document/decorators/rpc-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/rpc-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/http/http-operation.js +6 -0
  19. package/cjs/document/index.js +8 -0
  20. package/cjs/document/rpc/rpc-api.js +54 -0
  21. package/cjs/document/rpc/rpc-controller.js +116 -0
  22. package/cjs/document/rpc/rpc-header.js +40 -0
  23. package/cjs/document/rpc/rpc-operation-response.js +58 -0
  24. package/cjs/document/rpc/rpc-operation.js +80 -0
  25. package/cjs/enums/index.js +7 -0
  26. package/cjs/exception/http-errors/forbidden.error.js +1 -1
  27. package/cjs/exception/http-errors/resource-not.available.error.js +1 -1
  28. package/cjs/index.js +1 -1
  29. package/cjs/schema/opra-schema.js +3 -0
  30. package/cjs/schema/rpc/rpc-controller.interface.js +11 -0
  31. package/cjs/schema/rpc/rpc-header.interface.js +2 -0
  32. package/cjs/schema/rpc/rpc-operation.interface.js +7 -0
  33. package/esm/document/api-document.js +14 -0
  34. package/esm/document/common/api-base.js +5 -3
  35. package/esm/document/common/document-node.js +6 -2
  36. package/esm/document/constants.js +1 -0
  37. package/esm/document/decorators/http-controller.decorator.js +1 -1
  38. package/esm/document/decorators/http-operation-entity.decorator.js +1 -1
  39. package/esm/document/decorators/http-operation.decorator.js +5 -5
  40. package/esm/document/decorators/rpc-controller.decorator.js +65 -0
  41. package/esm/document/decorators/rpc-operation.decorator.js +76 -0
  42. package/esm/document/factory/api-document.factory.js +9 -3
  43. package/esm/document/factory/data-type.factory.js +20 -0
  44. package/esm/document/factory/http-api.factory.js +50 -77
  45. package/esm/document/factory/rpc-api.factory.js +198 -0
  46. package/esm/document/http/http-api.js +5 -4
  47. package/esm/document/http/http-controller.js +17 -1
  48. package/esm/document/http/http-operation.js +6 -0
  49. package/esm/document/index.js +8 -0
  50. package/esm/document/rpc/rpc-api.js +50 -0
  51. package/esm/document/rpc/rpc-controller.js +113 -0
  52. package/esm/document/rpc/rpc-header.js +37 -0
  53. package/esm/document/rpc/rpc-operation-response.js +54 -0
  54. package/esm/document/rpc/rpc-operation.js +77 -0
  55. package/esm/enums/index.js +4 -0
  56. package/esm/exception/http-errors/forbidden.error.js +1 -1
  57. package/esm/exception/http-errors/resource-not.available.error.js +1 -1
  58. package/esm/index.js +1 -1
  59. package/esm/schema/opra-schema.js +3 -0
  60. package/esm/schema/rpc/rpc-controller.interface.js +8 -0
  61. package/esm/schema/rpc/rpc-header.interface.js +1 -0
  62. package/esm/schema/rpc/rpc-operation.interface.js +4 -0
  63. package/package.json +2 -2
  64. package/types/document/api-document.d.ts +5 -2
  65. package/types/document/common/api-base.d.ts +3 -2
  66. package/types/document/constants.d.ts +1 -0
  67. package/types/document/decorators/http-operation.decorator.d.ts +3 -3
  68. package/types/document/decorators/rpc-controller.decorator.d.ts +20 -0
  69. package/types/document/decorators/rpc-operation.decorator.d.ts +32 -0
  70. package/types/document/factory/api-document.factory.d.ts +2 -1
  71. package/types/document/factory/data-type.factory.d.ts +1 -0
  72. package/types/document/factory/http-api.factory.d.ts +10 -6
  73. package/types/document/factory/rpc-api.factory.d.ts +40 -0
  74. package/types/document/http/http-api.d.ts +8 -3
  75. package/types/document/http/http-controller.d.ts +8 -2
  76. package/types/document/index.d.ts +11 -0
  77. package/types/document/rpc/rpc-api.d.ts +27 -0
  78. package/types/document/rpc/rpc-controller.d.ts +89 -0
  79. package/types/document/rpc/rpc-header.d.ts +47 -0
  80. package/types/document/rpc/rpc-operation-response.d.ts +41 -0
  81. package/types/document/rpc/rpc-operation.d.ts +77 -0
  82. package/types/enums/index.d.ts +4 -0
  83. package/types/exception/http-errors/forbidden.error.d.ts +1 -1
  84. package/types/index.d.cts +1 -1
  85. package/types/index.d.ts +1 -1
  86. package/types/schema/api-document.interface.d.ts +25 -4
  87. package/types/schema/opra-schema.d.ts +3 -0
  88. package/types/schema/rpc/rpc-controller.interface.d.ts +22 -0
  89. package/types/schema/rpc/rpc-header.interface.d.ts +19 -0
  90. package/types/schema/rpc/rpc-operation.interface.d.ts +26 -0
  91. package/cjs/http/index.js +0 -7
  92. package/esm/http/index.js +0 -4
  93. package/types/http/index.d.ts +0 -4
  94. /package/cjs/{http/enums → enums}/http-headers-codes.enum.js +0 -0
  95. /package/cjs/{http/enums → enums}/http-status-codes.enum.js +0 -0
  96. /package/cjs/{http/enums → enums}/http-status-messages.js +0 -0
  97. /package/cjs/{http/enums → enums}/mime-types.enum.js +0 -0
  98. /package/esm/{http/enums → enums}/http-headers-codes.enum.js +0 -0
  99. /package/esm/{http/enums → enums}/http-status-codes.enum.js +0 -0
  100. /package/esm/{http/enums → enums}/http-status-messages.js +0 -0
  101. /package/esm/{http/enums → enums}/mime-types.enum.js +0 -0
  102. /package/types/{http/enums → enums}/http-headers-codes.enum.d.ts +0 -0
  103. /package/types/{http/enums → enums}/http-status-codes.enum.d.ts +0 -0
  104. /package/types/{http/enums → enums}/http-status-messages.d.ts +0 -0
  105. /package/types/{http/enums → enums}/mime-types.enum.d.ts +0 -0
@@ -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';
@@ -1,7 +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
- export type Protocol = 'http' | 'ws' | 'rpc';
4
+ import type { RpcController } from './rpc/rpc-controller.interface.js';
5
+ export type Transport =
6
+ /** HTTP **/
7
+ 'http'
8
+ /** WebSocket*/
9
+ | 'ws'
10
+ /** Remote Procedure Call (Kafka, RabbitMQ, MQTT etc) */
11
+ | 'rpc';
5
12
  /**
6
13
  * @interface ApiDocument
7
14
  */
@@ -11,7 +18,7 @@ export interface ApiDocument extends DataTypeContainer {
11
18
  url?: string;
12
19
  info?: DocumentInfo;
13
20
  references?: Record<string, DocumentReference>;
14
- api?: HttpApi;
21
+ api?: HttpApi | RpcApi;
15
22
  }
16
23
  /**
17
24
  * @interface DocumentInfo
@@ -49,7 +56,7 @@ export interface DocumentReference extends Pick<ApiDocument, 'id' | 'url' | 'inf
49
56
  * @interface Api
50
57
  */
51
58
  export interface Api extends DataTypeContainer {
52
- protocol: Protocol;
59
+ transport: Transport;
53
60
  /**
54
61
  * Name of the api. Should be a computer friendly name
55
62
  */
@@ -57,11 +64,25 @@ export interface Api extends DataTypeContainer {
57
64
  description?: string;
58
65
  }
59
66
  /**
67
+ * HTTP Api
60
68
  * @interface HttpApi
61
69
  */
62
70
  export interface HttpApi extends Api {
63
- protocol: 'http';
71
+ transport: 'http';
64
72
  description?: string;
65
73
  url?: string;
66
74
  controllers: Record<string, HttpController>;
67
75
  }
76
+ /**
77
+ * Message Api (Kafka, RabbitMQ, MQTT etc)
78
+ * @interface RpcApi
79
+ */
80
+ export interface RpcApi extends Api {
81
+ transport: 'rpc';
82
+ /**
83
+ * Name of the platform. (Kafka, RabbitMQ, etc.)
84
+ */
85
+ platform: string;
86
+ description?: string;
87
+ controllers: Record<string, RpcController>;
88
+ }
@@ -16,6 +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 './rpc/rpc-controller.interface.js';
20
+ export * from './rpc/rpc-header.interface.js';
21
+ export * from './rpc/rpc-operation.interface.js';
19
22
  export * from './type-guards.js';
20
23
  export * from './types.js';
21
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
+ }
@@ -0,0 +1,19 @@
1
+ import type { Value } from '../value.interface.js';
2
+ /**
3
+ *
4
+ * @interface RpcHeader
5
+ */
6
+ export interface RpcHeader extends Value {
7
+ /**
8
+ * Name of the parameter. RegExp pattern can be used matching parameter name
9
+ */
10
+ name: string | RegExp;
11
+ /**
12
+ * Indicates if parameter value required
13
+ */
14
+ required?: boolean;
15
+ /**
16
+ * Indicates if the parameter is deprecated and can be removed in the next
17
+ */
18
+ deprecated?: boolean | string;
19
+ }
@@ -0,0 +1,26 @@
1
+ import { DataType } from '../data-type/data-type.interface.js';
2
+ import type { DataTypeContainer } from '../data-type-container.interface.js';
3
+ import type { RpcHeader } from './rpc-header.interface.js';
4
+ /**
5
+ * @interface RpcOperation
6
+ */
7
+ export interface RpcOperation extends DataTypeContainer {
8
+ kind: RpcOperation.Kind;
9
+ description?: string;
10
+ channel: string | RegExp | (string | RegExp)[];
11
+ payloadType: string | DataType;
12
+ keyType?: string | DataType;
13
+ headers?: RpcHeader[];
14
+ response?: RpcOperationResponse;
15
+ }
16
+ export interface RpcOperationResponse {
17
+ description?: string;
18
+ channel?: string | RegExp | (string | RegExp)[];
19
+ payloadType: string | DataType;
20
+ keyType?: string | DataType;
21
+ headers?: RpcHeader[];
22
+ }
23
+ export declare namespace RpcOperation {
24
+ const Kind = "RpcOperation";
25
+ type Kind = 'RpcOperation';
26
+ }
package/cjs/http/index.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./enums/http-headers-codes.enum.js"), exports);
5
- tslib_1.__exportStar(require("./enums/http-status-codes.enum.js"), exports);
6
- tslib_1.__exportStar(require("./enums/http-status-messages.js"), exports);
7
- tslib_1.__exportStar(require("./enums/mime-types.enum.js"), exports);
package/esm/http/index.js DELETED
@@ -1,4 +0,0 @@
1
- export * from './enums/http-headers-codes.enum.js';
2
- export * from './enums/http-status-codes.enum.js';
3
- export * from './enums/http-status-messages.js';
4
- export * from './enums/mime-types.enum.js';
@@ -1,4 +0,0 @@
1
- export * from './enums/http-headers-codes.enum.js';
2
- export * from './enums/http-status-codes.enum.js';
3
- export * from './enums/http-status-messages.js';
4
- export * from './enums/mime-types.enum.js';
File without changes
File without changes