@opra/common 1.19.7 → 1.20.0

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 (100) hide show
  1. package/browser/index.cjs +5 -5
  2. package/browser/index.mjs +5 -5
  3. package/cjs/document/api-document.js +14 -2
  4. package/cjs/document/common/document-node.js +12 -1
  5. package/cjs/document/constants.js +2 -1
  6. package/cjs/document/data-type/api-field.js +7 -6
  7. package/cjs/document/data-type/array-type.js +78 -0
  8. package/cjs/document/data-type/complex-type-base.js +3 -4
  9. package/cjs/document/data-type/extended-types/base64.type.js +6 -1
  10. package/cjs/document/data-type/extended-types/date-time.type.js +1 -1
  11. package/cjs/document/data-type/extended-types/date.type.js +1 -1
  12. package/cjs/document/data-type/extended-types/field-path.type.js +3 -3
  13. package/cjs/document/data-type/extended-types/filter.type.js +1 -1
  14. package/cjs/document/data-type/simple-type.js +10 -2
  15. package/cjs/document/decorators/http-operation.decorator.js +13 -0
  16. package/cjs/document/decorators/mq-operation.decorator.js +12 -8
  17. package/cjs/document/decorators/ws-controller.decorator.js +4 -4
  18. package/cjs/document/decorators/ws-operation.decorator.js +6 -7
  19. package/cjs/document/decorators/ws-param.decorator.js +22 -0
  20. package/cjs/document/factory/api-document.factory.js +9 -0
  21. package/cjs/document/factory/data-type.factory.js +27 -0
  22. package/cjs/document/factory/mq-api.factory.js +4 -4
  23. package/cjs/document/factory/ws-api.factory.js +26 -4
  24. package/cjs/document/http/http-media-type.js +13 -4
  25. package/cjs/document/http/http-parameter.js +8 -0
  26. package/cjs/document/index.js +2 -0
  27. package/cjs/document/mq/mq-header.js +8 -0
  28. package/cjs/document/mq/mq-operation-response.js +9 -9
  29. package/cjs/document/mq/mq-operation.js +23 -10
  30. package/cjs/document/ws/ws-operation.js +22 -20
  31. package/cjs/filter/filter-rules.js +2 -2
  32. package/cjs/schema/data-type/array-type.interface.js +7 -0
  33. package/cjs/schema/opra-schema.js +1 -0
  34. package/cjs/schema/type-guards.js +7 -1
  35. package/esm/document/api-document.js +14 -2
  36. package/esm/document/common/document-node.js +12 -1
  37. package/esm/document/constants.js +1 -0
  38. package/esm/document/data-type/api-field.js +7 -6
  39. package/esm/document/data-type/array-type.js +75 -0
  40. package/esm/document/data-type/complex-type-base.js +3 -4
  41. package/esm/document/data-type/extended-types/base64.type.js +6 -1
  42. package/esm/document/data-type/extended-types/date-time.type.js +1 -1
  43. package/esm/document/data-type/extended-types/date.type.js +1 -1
  44. package/esm/document/data-type/extended-types/field-path.type.js +3 -3
  45. package/esm/document/data-type/extended-types/filter.type.js +1 -1
  46. package/esm/document/data-type/simple-type.js +10 -2
  47. package/esm/document/decorators/http-operation.decorator.js +13 -0
  48. package/esm/document/decorators/mq-operation.decorator.js +13 -9
  49. package/esm/document/decorators/ws-controller.decorator.js +5 -5
  50. package/esm/document/decorators/ws-operation.decorator.js +7 -8
  51. package/esm/document/decorators/ws-param.decorator.js +19 -0
  52. package/esm/document/factory/api-document.factory.js +9 -0
  53. package/esm/document/factory/data-type.factory.js +27 -0
  54. package/esm/document/factory/mq-api.factory.js +4 -4
  55. package/esm/document/factory/ws-api.factory.js +27 -5
  56. package/esm/document/http/http-media-type.js +13 -4
  57. package/esm/document/http/http-parameter.js +8 -0
  58. package/esm/document/index.js +2 -0
  59. package/esm/document/mq/mq-header.js +8 -0
  60. package/esm/document/mq/mq-operation-response.js +9 -9
  61. package/esm/document/mq/mq-operation.js +23 -10
  62. package/esm/document/ws/ws-operation.js +22 -20
  63. package/esm/filter/filter-rules.js +2 -2
  64. package/esm/schema/data-type/array-type.interface.js +4 -0
  65. package/esm/schema/opra-schema.js +1 -0
  66. package/esm/schema/type-guards.js +6 -1
  67. package/package.json +1 -1
  68. package/types/document/api-document.d.ts +6 -3
  69. package/types/document/common/document-node.d.ts +7 -0
  70. package/types/document/constants.d.ts +1 -0
  71. package/types/document/data-type/api-field.d.ts +6 -9
  72. package/types/document/data-type/array-type.d.ts +76 -0
  73. package/types/document/data-type/extended-types/base64.type.d.ts +2 -1
  74. package/types/document/data-type/extended-types/date-time.type.d.ts +2 -1
  75. package/types/document/data-type/extended-types/date.type.d.ts +2 -1
  76. package/types/document/data-type/extended-types/field-path.type.d.ts +5 -2
  77. package/types/document/data-type/extended-types/filter.type.d.ts +3 -1
  78. package/types/document/data-type/simple-type.d.ts +6 -2
  79. package/types/document/decorators/mq-operation.decorator.d.ts +5 -5
  80. package/types/document/decorators/ws-controller.decorator.d.ts +0 -2
  81. package/types/document/decorators/ws-operation.decorator.d.ts +5 -5
  82. package/types/document/decorators/ws-param.decorator.d.ts +2 -0
  83. package/types/document/factory/data-type.factory.d.ts +12 -2
  84. package/types/document/http/http-media-type.d.ts +3 -1
  85. package/types/document/http/http-parameter.d.ts +5 -1
  86. package/types/document/index.d.ts +2 -0
  87. package/types/document/mq/mq-header.d.ts +5 -1
  88. package/types/document/mq/mq-operation-response.d.ts +8 -4
  89. package/types/document/mq/mq-operation.d.ts +13 -6
  90. package/types/document/ws/ws-controller.d.ts +0 -1
  91. package/types/document/ws/ws-operation.d.ts +14 -14
  92. package/types/schema/data-type/array-type.interface.d.ts +16 -0
  93. package/types/schema/data-type/data-type.interface.d.ts +3 -2
  94. package/types/schema/data-type/field.interface.d.ts +1 -0
  95. package/types/schema/http/http-media-type.interface.d.ts +1 -0
  96. package/types/schema/mq/mq-operation.interface.d.ts +2 -2
  97. package/types/schema/opra-schema.d.ts +1 -0
  98. package/types/schema/type-guards.d.ts +2 -0
  99. package/types/schema/value.interface.d.ts +1 -0
  100. package/types/schema/ws/ws-operation.interface.d.ts +3 -2
@@ -23,6 +23,7 @@ export * from './common/document-node.js';
23
23
  export * from './common/opra-document-error.js';
24
24
  export * from './constants.js';
25
25
  export * from './data-type/api-field.js';
26
+ export * from './data-type/array-type.js';
26
27
  export * from './data-type/complex-type.js';
27
28
  export * from './data-type/data-type.js';
28
29
  export * from './data-type/enum-type.js';
@@ -40,6 +41,7 @@ export type { MQControllerDecorator } from './decorators/mq-controller.decorator
40
41
  export type { MQOperationDecorator } from './decorators/mq-operation.decorator.js';
41
42
  export type { WSControllerDecorator } from './decorators/ws-controller.decorator.js';
42
43
  export type { WSOperationDecorator } from './decorators/ws-operation.decorator.js';
44
+ export * from './decorators/ws-param.decorator.js';
43
45
  export * from './factory/api-document.factory.js';
44
46
  export * from './http/http-api.js';
45
47
  export * from './http/http-controller.js';
@@ -1,4 +1,5 @@
1
- import { type Combine, type StrictOmit, type TypeThunkAsync } from 'ts-gems';
1
+ import { type Combine, type StrictOmit, Type, type TypeThunkAsync } from 'ts-gems';
2
+ import { Validator } from 'valgen';
2
3
  import type { OpraSchema } from '../../schema/index.js';
3
4
  import { DocumentElement } from '../common/document-element.js';
4
5
  import { Value } from '../common/value.js';
@@ -11,6 +12,7 @@ export declare namespace MQHeader {
11
12
  interface Metadata extends StrictOmit<OpraSchema.MQHeader, 'type'> {
12
13
  name: string | RegExp;
13
14
  type?: string | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
15
+ designType?: Type;
14
16
  }
15
17
  interface Options extends Partial<StrictOmit<Metadata, 'type'>> {
16
18
  type?: string | TypeThunkAsync | object;
@@ -42,6 +44,8 @@ declare class MQHeaderClass extends Value {
42
44
  readonly owner: DocumentElement;
43
45
  deprecated?: boolean | string;
44
46
  required?: boolean;
47
+ designType?: Type;
45
48
  toJSON(): OpraSchema.MQHeader;
49
+ generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions, properties?: any): Validator;
46
50
  }
47
51
  export {};
@@ -10,19 +10,21 @@ import type { MQOperation } from './mq-operation.js';
10
10
  */
11
11
  export declare namespace MQOperationResponse {
12
12
  interface Metadata extends Combine<{
13
- payloadType?: TypeThunkAsync | string;
13
+ type?: TypeThunkAsync | string;
14
14
  keyType?: TypeThunkAsync | string;
15
15
  headers?: MQHeader.Metadata[];
16
16
  }, OpraSchema.MQOperationResponse> {
17
+ designType?: Type;
18
+ keyDesignType?: Type;
17
19
  }
18
20
  interface Options extends Combine<{
19
21
  keyType?: Type | string;
20
22
  }, Pick<Metadata, 'channel' | 'description'>> {
21
23
  }
22
24
  interface InitArguments extends Combine<{
23
- payloadType?: DataType | string | Type;
25
+ type?: DataType | string | Type;
24
26
  keyType?: DataType | string | Type;
25
- }, Pick<Metadata, 'channel' | 'description'>> {
27
+ }, Pick<Metadata, 'channel' | 'description' | 'designType' | 'keyDesignType'>> {
26
28
  }
27
29
  }
28
30
  /**
@@ -32,9 +34,11 @@ export declare class MQOperationResponse extends DocumentElement {
32
34
  readonly owner: MQOperation;
33
35
  channel?: string | RegExp | (string | RegExp)[];
34
36
  description?: string;
35
- payloadType: DataType;
37
+ type: DataType;
36
38
  keyType?: DataType;
37
39
  headers: MQHeader[];
40
+ designType?: Type;
41
+ keyDesignType?: Type;
38
42
  constructor(owner: MQOperation, initArgs?: MQOperationResponse.InitArguments);
39
43
  findHeader(paramName: string): MQHeader | undefined;
40
44
  toJSON(): OpraSchema.MQOperationResponse;
@@ -1,5 +1,6 @@
1
1
  import type { Combine, ThunkAsync, Type } from 'ts-gems';
2
2
  import { TypeThunkAsync } from 'ts-gems/lib/types';
3
+ import { Validator } from 'valgen';
3
4
  import { OpraSchema } from '../../schema/index.js';
4
5
  import { DataTypeMap } from '../common/data-type-map.js';
5
6
  import { DocumentElement } from '../common/document-element.js';
@@ -14,11 +15,13 @@ import type { MQOperationResponse } from './mq-operation-response.js';
14
15
  */
15
16
  export declare namespace MQOperation {
16
17
  interface Metadata extends Pick<OpraSchema.MQOperation, 'description' | 'channel'> {
17
- payloadType: TypeThunkAsync | string;
18
+ type: TypeThunkAsync | string;
18
19
  keyType?: TypeThunkAsync | string;
19
20
  types?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[];
20
21
  headers?: MQHeader.Metadata[];
21
22
  response?: MQOperationResponse.Metadata;
23
+ designType?: Type;
24
+ keyDesignType?: Type;
22
25
  }
23
26
  interface Options extends Partial<Pick<Metadata, 'description' | 'keyType'>> {
24
27
  channel?: (string | RegExp) | (string | RegExp)[];
@@ -26,9 +29,9 @@ export declare namespace MQOperation {
26
29
  interface InitArguments extends Combine<{
27
30
  name: string;
28
31
  types?: DataType[];
29
- payloadType?: DataType | string | Type;
32
+ type?: DataType | string | Type;
30
33
  keyType?: DataType | string | Type;
31
- }, Pick<Metadata, 'description' | 'channel'>> {
34
+ }, Pick<Metadata, 'description' | 'channel' | 'designType' | 'keyDesignType'>> {
32
35
  }
33
36
  }
34
37
  /**
@@ -44,9 +47,9 @@ export interface MQOperationStatic {
44
47
  new (controller: MQController, args: MQOperation.InitArguments): MQOperation;
45
48
  /**
46
49
  * Property decorator
47
- * @param payloadType
50
+ * @param type
48
51
  * @param options
49
- */ <T extends MQOperation.Options>(payloadType: ThunkAsync<Type> | string, options?: T): MQOperationDecorator;
52
+ */ <T extends MQOperation.Options>(type: ThunkAsync<Type> | string, options?: T): MQOperationDecorator;
50
53
  prototype: MQOperation;
51
54
  }
52
55
  /**
@@ -66,12 +69,16 @@ declare class MQOperationClass extends DocumentElement {
66
69
  readonly name: string;
67
70
  channel: string | RegExp | (string | RegExp)[];
68
71
  description?: string;
69
- payloadType: DataType;
72
+ type: DataType;
70
73
  keyType?: DataType;
71
74
  types: DataTypeMap;
72
75
  headers: MQHeader[];
73
76
  response: MQOperationResponse;
77
+ designType?: Type;
78
+ keyDesignType?: Type;
74
79
  findHeader(paramName: string): MQHeader | undefined;
75
80
  toJSON(): OpraSchema.MQOperation;
81
+ generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions, properties?: any): Validator;
82
+ generateKeyCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions, properties?: any): Validator;
76
83
  }
77
84
  export {};
@@ -58,7 +58,6 @@ declare class WSControllerClass extends DocumentElement {
58
58
  readonly kind: OpraSchema.WSController.Kind;
59
59
  readonly name: string;
60
60
  description?: string;
61
- path: string;
62
61
  instance?: any;
63
62
  ctor?: Type;
64
63
  operations: ResponsiveMap<WSOperation>;
@@ -1,5 +1,4 @@
1
1
  import type { Combine, ThunkAsync, Type } from 'ts-gems';
2
- import { TypeThunkAsync } from 'ts-gems/lib/types';
3
2
  import { OpraSchema } from '../../schema/index.js';
4
3
  import { DataTypeMap } from '../common/data-type-map.js';
5
4
  import { DocumentElement } from '../common/document-element.js';
@@ -11,20 +10,22 @@ import { WSController } from './ws-controller.js';
11
10
  * @namespace WSOperation
12
11
  */
13
12
  export declare namespace WSOperation {
14
- interface Metadata extends Pick<OpraSchema.WSOperation, 'description' | 'channel'> {
15
- payloadType: TypeThunkAsync | string;
16
- keyType?: TypeThunkAsync | string;
13
+ interface Metadata extends Pick<OpraSchema.WSOperation, 'description' | 'event'> {
14
+ arguments?: (ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray> | string)[];
17
15
  types?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[];
16
+ response?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[];
18
17
  }
19
- interface Options extends Partial<Pick<Metadata, 'description' | 'keyType'>> {
20
- channel?: (string | RegExp) | (string | RegExp)[];
18
+ interface Options extends Partial<Pick<Metadata, 'description'>> {
19
+ event?: string | RegExp;
20
+ response?: string | ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>;
21
21
  }
22
22
  interface InitArguments extends Combine<{
23
23
  name: string;
24
24
  types?: DataType[];
25
- payloadType?: DataType | string | Type;
26
- keyType?: DataType | string | Type;
27
- }, Pick<Metadata, 'description' | 'channel'>> {
25
+ arguments?: (DataType | string | Type)[];
26
+ }, Pick<Metadata, 'description'>> {
27
+ event?: string | RegExp;
28
+ response?: DataType | string | Type;
28
29
  }
29
30
  }
30
31
  /**
@@ -40,9 +41,8 @@ export interface WSOperationStatic {
40
41
  new (controller: WSController, args: WSOperation.InitArguments): WSOperation;
41
42
  /**
42
43
  * Property decorator
43
- * @param payloadType
44
44
  * @param options
45
- */ <T extends WSOperation.Options>(payloadType: ThunkAsync<Type> | string, options?: T): WSOperationDecorator;
45
+ */ <T extends WSOperation.Options>(options?: T): WSOperationDecorator;
46
46
  prototype: WSOperation;
47
47
  }
48
48
  /**
@@ -60,11 +60,11 @@ export declare const WSOperation: WSOperationStatic;
60
60
  declare class WSOperationClass extends DocumentElement {
61
61
  readonly owner: WSController;
62
62
  readonly name: string;
63
- channel: string | RegExp | (string | RegExp)[];
64
63
  description?: string;
65
- payloadType: DataType;
66
- keyType?: DataType;
64
+ event: string | RegExp;
65
+ arguments?: DataType[];
67
66
  types: DataTypeMap;
67
+ response?: DataType;
68
68
  toJSON(): OpraSchema.WSOperation;
69
69
  }
70
70
  export {};
@@ -0,0 +1,16 @@
1
+ import type { StrictOmit } from 'ts-gems';
2
+ import type { DataType, DataTypeBase } from './data-type.interface.js';
3
+ /**
4
+ *
5
+ * @interface ArrayType
6
+ */
7
+ export interface ArrayType extends StrictOmit<DataTypeBase, 'kind'> {
8
+ kind: ArrayType.Kind;
9
+ type?: DataType.Name | DataType;
10
+ minOccurs?: number;
11
+ maxOccurs?: number;
12
+ }
13
+ export declare namespace ArrayType {
14
+ const Kind = "ArrayType";
15
+ type Kind = 'ArrayType';
16
+ }
@@ -1,13 +1,14 @@
1
+ import { ArrayType } from './array-type.interface.js';
1
2
  import type { ComplexType } from './complex-type.interface.js';
2
3
  import type { EnumType } from './enum-type.interface.js';
3
4
  import type { MappedType } from './mapped-type.interface.js';
4
5
  import type { MixinType } from './mixin-type.interface.js';
5
6
  import type { SimpleType } from './simple-type.interface.js';
6
7
  import type { UnionType } from './union-type.interface.js';
7
- export type DataType = SimpleType | EnumType | ComplexType | MappedType | MixinType | UnionType;
8
+ export type DataType = SimpleType | EnumType | ComplexType | MappedType | MixinType | UnionType | ArrayType;
8
9
  export declare namespace DataType {
9
10
  type Name = string;
10
- type Kind = ComplexType.Kind | EnumType.Kind | MappedType.Kind | SimpleType.Kind | MixinType.Kind | UnionType.Kind;
11
+ type Kind = ComplexType.Kind | EnumType.Kind | MappedType.Kind | SimpleType.Kind | MixinType.Kind | UnionType.Kind | ArrayType.Kind;
11
12
  }
12
13
  export interface DataTypeBase {
13
14
  kind: DataType.Kind;
@@ -44,6 +44,7 @@ export interface Field {
44
44
  * If true, the value is recognized as an array.
45
45
  * If false, the value is not an array.
46
46
  * This property is optional and may be undefined.
47
+ * @deprecated
47
48
  */
48
49
  isArray?: boolean;
49
50
  /**
@@ -24,6 +24,7 @@ export interface HttpMediaType {
24
24
  type?: DataType.Name | DataType;
25
25
  /**
26
26
  * Determines if content is array
27
+ * @deprecated
27
28
  */
28
29
  isArray?: boolean;
29
30
  /**
@@ -8,7 +8,7 @@ export interface MQOperation extends DataTypeContainer {
8
8
  kind: MQOperation.Kind;
9
9
  description?: string;
10
10
  channel: string | RegExp | (string | RegExp)[];
11
- payloadType: string | DataType;
11
+ type: string | DataType;
12
12
  keyType?: string | DataType;
13
13
  headers?: MQHeader[];
14
14
  response?: MQOperationResponse;
@@ -16,7 +16,7 @@ export interface MQOperation extends DataTypeContainer {
16
16
  export interface MQOperationResponse {
17
17
  description?: string;
18
18
  channel?: string | RegExp | (string | RegExp)[];
19
- payloadType: string | DataType;
19
+ type: string | DataType;
20
20
  keyType?: string | DataType;
21
21
  headers?: MQHeader[];
22
22
  }
@@ -1,6 +1,7 @@
1
1
  export * from './api.interface.js';
2
2
  export * from './api-document.interface.js';
3
3
  export * from './constants.js';
4
+ export * from './data-type/array-type.interface.js';
4
5
  export * from './data-type/complex-type.interface.js';
5
6
  export * from './data-type/data-type.interface.js';
6
7
  export * from './data-type/enum-type.interface.js';
@@ -1,3 +1,4 @@
1
+ import { ArrayType } from './data-type/array-type.interface.js';
1
2
  import { ComplexType } from './data-type/complex-type.interface.js';
2
3
  import type { DataType } from './data-type/data-type.interface.js';
3
4
  import { EnumType } from './data-type/enum-type.interface.js';
@@ -13,4 +14,5 @@ export declare function isMixinType(obj: any): obj is MixinType;
13
14
  export declare function isMappedType(obj: any): obj is MappedType;
14
15
  export declare function isEnumType(obj: any): obj is EnumType;
15
16
  export declare function isUnionType(obj: any): obj is UnionType;
17
+ export declare function isArrayType(obj: any): obj is ArrayType;
16
18
  export declare function isHttpController(obj: any): obj is HttpController;
@@ -10,6 +10,7 @@ export interface Value {
10
10
  type?: DataType.Name | DataType;
11
11
  /**
12
12
  * Indicates if the value is an array
13
+ * @deprecated
13
14
  */
14
15
  isArray?: boolean;
15
16
  /**
@@ -6,8 +6,9 @@ import type { DataTypeContainer } from '../data-type-container.interface.js';
6
6
  export interface WSOperation extends DataTypeContainer {
7
7
  kind: WSOperation.Kind;
8
8
  description?: string;
9
- channel: string | RegExp | (string | RegExp)[];
10
- payloadType: string | DataType;
9
+ event: string | RegExp;
10
+ arguments?: (string | DataType)[];
11
+ response?: string | DataType;
11
12
  }
12
13
  export declare namespace WSOperation {
13
14
  const Kind = "WSOperation";