@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
@@ -1,5 +1,6 @@
1
1
  import { omitUndefined } from '@jsopen/objects';
2
2
  import { asMutable } from 'ts-gems';
3
+ import { vg } 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';
@@ -12,9 +13,9 @@ import { MQOperationDecoratorFactory, } from '../decorators/mq-operation.decorat
12
13
  export const MQOperation = function (...args) {
13
14
  // Decorator
14
15
  if (!this) {
15
- const [payloadType, options] = args;
16
+ const [type, options] = args;
16
17
  const decoratorChain = [];
17
- return MQOperation[DECORATOR].call(undefined, decoratorChain, payloadType, options);
18
+ return MQOperation[DECORATOR].call(undefined, decoratorChain, type, options);
18
19
  }
19
20
  // Constructor
20
21
  const [resource, initArgs] = args;
@@ -27,11 +28,11 @@ export const MQOperation = function (...args) {
27
28
  _this.name = initArgs.name;
28
29
  _this.description = initArgs.description;
29
30
  _this.channel = initArgs.channel;
30
- if (initArgs?.payloadType) {
31
- _this.payloadType =
32
- initArgs?.payloadType instanceof DataType
33
- ? initArgs.payloadType
34
- : _this.owner.node.getDataType(initArgs.payloadType);
31
+ if (initArgs?.type) {
32
+ _this.type =
33
+ initArgs?.type instanceof DataType
34
+ ? initArgs.type
35
+ : _this.owner.node.getDataType(initArgs.type);
35
36
  }
36
37
  if (initArgs?.keyType) {
37
38
  _this.keyType =
@@ -39,6 +40,8 @@ export const MQOperation = function (...args) {
39
40
  ? initArgs.keyType
40
41
  : _this.owner.node.getDataType(initArgs.keyType);
41
42
  }
43
+ _this.designType = initArgs.designType;
44
+ _this.keyDesignType = initArgs.keyDesignType;
42
45
  };
43
46
  /**
44
47
  * @class MQOperation
@@ -62,9 +65,7 @@ class MQOperationClass extends DocumentElement {
62
65
  kind: OpraSchema.MQOperation.Kind,
63
66
  description: this.description,
64
67
  channel: this.channel,
65
- payloadType: this.payloadType.name
66
- ? this.payloadType.name
67
- : this.payloadType.toJSON(),
68
+ type: this.type.name ? this.type.name : this.type.toJSON(),
68
69
  keyType: this.keyType
69
70
  ? this.keyType.name
70
71
  ? this.keyType.name
@@ -80,6 +81,18 @@ class MQOperationClass extends DocumentElement {
80
81
  }
81
82
  return out;
82
83
  }
84
+ generateCodec(codec, options, properties) {
85
+ return (this.type?.generateCodec(codec, options, {
86
+ ...properties,
87
+ designType: this.designType,
88
+ }) || vg.isAny());
89
+ }
90
+ generateKeyCodec(codec, options, properties) {
91
+ return (this.keyType?.generateCodec(codec, options, {
92
+ ...properties,
93
+ designType: this.keyDesignType,
94
+ }) || vg.isAny());
95
+ }
83
96
  }
84
97
  MQOperation.prototype = MQOperationClass.prototype;
85
98
  MQOperation[DECORATOR] = MQOperationDecoratorFactory;
@@ -6,15 +6,16 @@ import { DocumentElement } from '../common/document-element.js';
6
6
  import { CLASS_NAME_PATTERN, DECORATOR, kDataTypeMap } from '../constants.js';
7
7
  import { DataType } from '../data-type/data-type.js';
8
8
  import { WSOperationDecoratorFactory, } from '../decorators/ws-operation.decorator.js';
9
+ import { parseRegExp } from '../utils/parse-regexp.util.js';
9
10
  /**
10
11
  * WSOperation
11
12
  */
12
13
  export const WSOperation = function (...args) {
13
14
  // Decorator
14
15
  if (!this) {
15
- const [payloadType, options] = args;
16
+ const [type, options] = args;
16
17
  const decoratorChain = [];
17
- return WSOperation[DECORATOR].call(undefined, decoratorChain, payloadType, options);
18
+ return WSOperation[DECORATOR].call(undefined, decoratorChain, type, options);
18
19
  }
19
20
  // Constructor
20
21
  const [resource, initArgs] = args;
@@ -25,34 +26,35 @@ export const WSOperation = function (...args) {
25
26
  _this.types = _this.node[kDataTypeMap] = new DataTypeMap();
26
27
  _this.name = initArgs.name;
27
28
  _this.description = initArgs.description;
28
- _this.channel = initArgs.channel;
29
- if (initArgs?.payloadType) {
30
- _this.payloadType =
31
- initArgs?.payloadType instanceof DataType
32
- ? initArgs.payloadType
33
- : _this.owner.node.getDataType(initArgs.payloadType);
34
- }
35
- if (initArgs?.keyType) {
36
- _this.keyType =
37
- initArgs?.keyType instanceof DataType
38
- ? initArgs.keyType
39
- : _this.owner.node.getDataType(initArgs.keyType);
29
+ if (initArgs.event)
30
+ this.event =
31
+ initArgs.event instanceof RegExp
32
+ ? initArgs.event
33
+ : initArgs.event.startsWith('/')
34
+ ? parseRegExp(initArgs.event)
35
+ : initArgs.event;
36
+ else
37
+ _this.event = this.name;
38
+ if (initArgs?.arguments) {
39
+ _this.arguments = initArgs.arguments.map(arg => arg instanceof DataType ? arg : _this.owner.node.getDataType(arg));
40
40
  }
41
+ if (initArgs?.response)
42
+ _this.response =
43
+ initArgs.response instanceof DataType
44
+ ? initArgs.response
45
+ : _this.owner.node.getDataType(initArgs.response);
41
46
  };
42
47
  /**
43
48
  * @class WSOperation
44
49
  */
45
50
  class WSOperationClass extends DocumentElement {
46
51
  toJSON() {
47
- const out = omitUndefined({
52
+ return omitUndefined({
48
53
  kind: OpraSchema.WSOperation.Kind,
49
54
  description: this.description,
50
- channel: this.channel,
51
- payloadType: this.payloadType.name
52
- ? this.payloadType.name
53
- : this.payloadType.toJSON(),
55
+ event: this.event,
56
+ arguments: this.arguments?.map(arg => arg.name ? arg.name : arg.toJSON()),
54
57
  });
55
- return out;
56
58
  }
57
59
  }
58
60
  WSOperation.prototype = WSOperationClass.prototype;
@@ -122,10 +122,10 @@ export class FilterRules {
122
122
  else
123
123
  decoder = this._decoderCache.get(comp.left.field);
124
124
  if (!decoder) {
125
- decoder = comp.left.field.type.generateCodec('decode', {
125
+ decoder = comp.left.field.generateCodec('decode', {
126
126
  scope,
127
127
  projection: '*',
128
- ignoreWriteonlyFields: true,
128
+ ignoreReadonlyFields: true,
129
129
  coerce: true,
130
130
  });
131
131
  this._decoderCache.set(comp.left.field, decoder);
@@ -0,0 +1,4 @@
1
+ export var ArrayType;
2
+ (function (ArrayType) {
3
+ ArrayType.Kind = 'ArrayType';
4
+ })(ArrayType || (ArrayType = {}));
@@ -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 { EnumType } from './data-type/enum-type.interface.js';
3
4
  import { MappedType } from './data-type/mapped-type.interface.js';
@@ -8,7 +9,8 @@ import { HttpController } from './http/http-controller.interface.js';
8
9
  export function isDataType(obj) {
9
10
  return (obj &&
10
11
  typeof obj === 'object' &&
11
- (obj.kind === ComplexType.Kind ||
12
+ (obj.kind === ArrayType.Kind ||
13
+ obj.kind === ComplexType.Kind ||
12
14
  obj.kind === EnumType.Kind ||
13
15
  obj.kind === MappedType.Kind ||
14
16
  obj.kind === SimpleType.Kind ||
@@ -33,6 +35,9 @@ export function isEnumType(obj) {
33
35
  export function isUnionType(obj) {
34
36
  return obj && typeof obj === 'object' && obj.kind === UnionType.Kind;
35
37
  }
38
+ export function isArrayType(obj) {
39
+ return obj && typeof obj === 'object' && obj.kind === ArrayType.Kind;
40
+ }
36
41
  export function isHttpController(obj) {
37
42
  return obj && typeof obj === 'object' && obj.kind === HttpController.Kind;
38
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.19.7",
3
+ "version": "1.20.0",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -28,9 +28,12 @@ export declare class ApiDocument extends DocumentElement {
28
28
  */
29
29
  getDataTypeNs(nameOrCtor: string | Type | Function | EnumType.EnumArray | EnumType.EnumObject | DataType): string | undefined;
30
30
  findDocument(id: string): ApiDocument | undefined;
31
- get httpApi(): HttpApi;
32
- get mqApi(): MQApi;
33
- get wsApi(): WSApi;
31
+ get httpApi(): HttpApi | undefined;
32
+ get mqApi(): MQApi | undefined;
33
+ get wsApi(): WSApi | undefined;
34
+ getHttpApi(): HttpApi;
35
+ getMqApi(): MQApi;
36
+ getWsApi(): WSApi;
34
37
  toJSON(): OpraSchema.ApiDocument;
35
38
  /**
36
39
  * Export as Opra schema definition object
@@ -1,6 +1,7 @@
1
1
  import type { Type } from 'ts-gems';
2
2
  import type { ApiDocument } from '../api-document.js';
3
3
  import { kDataTypeMap } from '../constants.js';
4
+ import type { ArrayType } from '../data-type/array-type.js';
4
5
  import type { ComplexType } from '../data-type/complex-type.js';
5
6
  import type { DataType } from '../data-type/data-type.js';
6
7
  import type { EnumType } from '../data-type/enum-type.js';
@@ -27,6 +28,12 @@ export declare class DocumentNode {
27
28
  */
28
29
  getDataType(nameOrCtor: string | Type | Function | object | any[], scope?: string | '*'): DataType;
29
30
  getDataTypeNameWithNs(dataType: DataType): string | undefined;
31
+ /**
32
+ * Returns EnumType instance by name or Constructor.
33
+ * Returns undefined if not found
34
+ * Throws error if data type is not a UnionType
35
+ */
36
+ getArrayType(nameOrCtor: string | object | any[], scope?: string | '*'): ArrayType;
30
37
  /**
31
38
  * Returns ComplexType instance by name or Constructor.
32
39
  * Returns undefined if not found
@@ -2,6 +2,7 @@ export declare const DATATYPE_METADATA: unique symbol;
2
2
  export declare const HTTP_CONTROLLER_METADATA: unique symbol;
3
3
  export declare const MQ_CONTROLLER_METADATA: unique symbol;
4
4
  export declare const WS_CONTROLLER_METADATA: unique symbol;
5
+ export declare const WS_PARAM_METADATA: unique symbol;
5
6
  export declare const RPC_CONTROLLER_METADATA: unique symbol;
6
7
  export declare const DECODER: unique symbol;
7
8
  export declare const ENCODER: unique symbol;
@@ -1,4 +1,5 @@
1
- import type { Combine, StrictOmit, TypeThunkAsync } from 'ts-gems';
1
+ import type { Combine, StrictOmit, Type, TypeThunkAsync } from 'ts-gems';
2
+ import type { Validator } from 'valgen';
2
3
  import { OpraSchema } from '../../schema/index.js';
3
4
  import type { ApiDocument } from '../api-document.js';
4
5
  import { DocumentElement } from '../common/document-element.js';
@@ -39,10 +40,11 @@ declare class ApiFieldClass extends DocumentElement {
39
40
  readonly owner: ComplexType | MappedType | MixinType;
40
41
  readonly origin?: ComplexType | MappedType | MixinType;
41
42
  readonly scopePattern?: (string | RegExp)[];
42
- readonly convertToNative?: boolean;
43
+ readonly designType?: Type;
43
44
  readonly name: string;
44
45
  readonly type: DataType;
45
46
  readonly description?: string;
47
+ /** @deprecated */
46
48
  readonly isArray?: boolean;
47
49
  readonly isNestedEntity?: boolean;
48
50
  readonly default?: any;
@@ -59,6 +61,7 @@ declare class ApiFieldClass extends DocumentElement {
59
61
  inScope(scope?: string | '*'): boolean;
60
62
  forScope(scope?: string): this;
61
63
  toJSON(options?: ApiDocument.ExportOptions): OpraSchema.Field;
64
+ generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions, properties?: any): Validator;
62
65
  }
63
66
  /**
64
67
  * @namespace ApiField
@@ -68,9 +71,8 @@ export declare namespace ApiField {
68
71
  type?: string | OpraSchema.DataType | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
69
72
  }, OpraSchema.Field> {
70
73
  scopePattern?: (string | RegExp) | (string | RegExp)[];
71
- convertToNative?: boolean;
72
74
  override?: StrictOmit<Metadata, 'override' | 'type' | 'isArray' | 'isNestedEntity'>[];
73
- designType?: Function;
75
+ designType?: Type;
74
76
  }
75
77
  interface Options extends Partial<StrictOmit<Metadata, 'override' | 'scopePattern'>> {
76
78
  /**
@@ -81,11 +83,6 @@ export declare namespace ApiField {
81
83
  * - If an array is provided, each element within the array is used as a valid scope pattern.
82
84
  */
83
85
  scopePattern?: (string | RegExp) | (string | RegExp)[];
84
- /**
85
- * Convert values to native objects. If enabled, some simple types
86
- * like "date" will be decoded as Date instances
87
- */
88
- convertToNative?: boolean;
89
86
  }
90
87
  interface InitArguments extends Combine<{
91
88
  name: string;
@@ -0,0 +1,76 @@
1
+ import 'reflect-metadata';
2
+ import type { Combine, Type } from 'ts-gems';
3
+ import { Validator } from 'valgen';
4
+ import { OpraSchema } from '../../schema/index.js';
5
+ import type { ApiDocument } from '../api-document.js';
6
+ import type { DocumentElement } from '../common/document-element.js';
7
+ import type { ComplexType } from './complex-type.js';
8
+ import { DataType } from './data-type.js';
9
+ import { EnumType } from './enum-type.js';
10
+ import type { MappedType } from './mapped-type.js';
11
+ import type { MixinType } from './mixin-type.js';
12
+ import type { SimpleType } from './simple-type.js';
13
+ import type { UnionType } from './union-type.js';
14
+ /**
15
+ * @namespace ArrayType
16
+ */
17
+ export declare namespace ArrayType {
18
+ interface Metadata extends Combine<{
19
+ kind: OpraSchema.ArrayType.Kind;
20
+ name?: string;
21
+ type: Type;
22
+ }, DataType.Metadata, OpraSchema.ArrayType> {
23
+ }
24
+ interface InitArguments extends Combine<{
25
+ kind: OpraSchema.ArrayType.Kind;
26
+ type: ArrayType | ComplexType | EnumType | MappedType | MixinType | SimpleType | UnionType;
27
+ ctor?: Type;
28
+ }, DataType.InitArguments, ArrayType.Metadata> {
29
+ }
30
+ interface Options extends Combine<Pick<OpraSchema.ArrayType, 'minOccurs' | 'maxOccurs'>, DataType.Options> {
31
+ }
32
+ }
33
+ /**
34
+ * Type definition for ArrayType
35
+ * @class ArrayType
36
+ */
37
+ export interface ArrayTypeStatic {
38
+ /**
39
+ * Class constructor of ArrayType
40
+ *
41
+ * @param owner
42
+ * @param args
43
+ * @constructor
44
+ */
45
+ new (owner: DocumentElement, args: ArrayType.InitArguments): ArrayType;
46
+ /**
47
+ * Create a new mixin type from the given data type
48
+ */
49
+ (type: string | Type, options?: ArrayType.Options): Type;
50
+ prototype: ArrayType;
51
+ }
52
+ /**
53
+ * Type definition of ArrayType prototype
54
+ * @interface
55
+ */
56
+ export interface ArrayType extends ArrayTypeClass {
57
+ }
58
+ /**
59
+ * @class ArrayType
60
+ */
61
+ export declare const ArrayType: ArrayTypeStatic;
62
+ /**
63
+ *
64
+ * @class ArrayType
65
+ */
66
+ declare class ArrayTypeClass extends DataType {
67
+ readonly kind: OpraSchema.ArrayType.Kind;
68
+ readonly type: ComplexType | MixinType | MappedType | SimpleType | UnionType | EnumType | ArrayType;
69
+ readonly minOccurs?: number;
70
+ readonly maxOccurs?: number;
71
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.ArrayType;
72
+ generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions, properties?: object): Validator;
73
+ extendsFrom(): boolean;
74
+ protected _locateBase(): ArrayType | undefined;
75
+ }
76
+ export {};
@@ -1,7 +1,8 @@
1
+ import { Type } from 'ts-gems';
1
2
  import { type Validator } from 'valgen';
2
3
  import { DECODER, ENCODER } from '../../constants.js';
3
4
  export declare class Base64Type {
4
- convertToNative?: boolean;
5
+ designType?: Type;
5
6
  constructor(attributes?: Partial<Base64Type>);
6
7
  protected [DECODER](properties: Partial<this>): Validator;
7
8
  protected [ENCODER](): Validator;
@@ -1,7 +1,8 @@
1
+ import { Type } from 'ts-gems';
1
2
  import { type Validator } from 'valgen';
2
3
  import { DECODER, ENCODER } from '../../constants.js';
3
4
  export declare class DateTimeType {
4
- convertToNative?: boolean;
5
+ designType?: Type;
5
6
  constructor(attributes?: Partial<DateTimeType>);
6
7
  protected [DECODER](properties: Partial<this>): Validator;
7
8
  protected [ENCODER](properties: Partial<this>): Validator;
@@ -1,7 +1,8 @@
1
+ import { Type } from 'ts-gems';
1
2
  import { type Validator } from 'valgen';
2
3
  import { DECODER, ENCODER } from '../../constants.js';
3
4
  export declare class DateType {
4
- convertToNative?: boolean;
5
+ designType?: Type;
5
6
  constructor(attributes?: Partial<DateType>);
6
7
  protected [DECODER](properties: Partial<this>): Validator;
7
8
  protected [ENCODER](properties: Partial<this>): Validator;
@@ -7,8 +7,11 @@ export declare class FieldPathType {
7
7
  constructor(attributes?: Partial<FieldPathType>);
8
8
  dataType?: Type | string;
9
9
  allowSigns?: 'first' | 'each';
10
- [DECODER](properties: Partial<this>, element: DocumentElement, scope?: string): Validator;
11
- [ENCODER](properties: Partial<this>, element: DocumentElement, scope?: string): Validator;
10
+ [DECODER](properties: Partial<this>, { element, scope, }: {
11
+ element: DocumentElement;
12
+ scope?: string;
13
+ }): Validator;
14
+ [ENCODER](properties: Partial<this>, args: any): Validator;
12
15
  toJSON(properties: Partial<FieldPathType>, element: DocumentElement, options?: ApiDocument.ExportOptions): {
13
16
  dataType: string | import("../../../schema/opra-schema.js").ComplexType;
14
17
  allowSigns: "first" | "each" | undefined;
@@ -8,7 +8,9 @@ export declare class FilterType {
8
8
  constructor(attributes?: Partial<FilterType>);
9
9
  dataType?: Type | string;
10
10
  rules?: Record<string, FilterRules.Rule>;
11
- protected [DECODER](properties: Partial<this>, element: DocumentElement): Validator;
11
+ protected [DECODER](properties: Partial<this>, { element }: {
12
+ element: DocumentElement;
13
+ }): Validator;
12
14
  protected [ENCODER](): Validator;
13
15
  toJSON(properties: Partial<FilterType>, element: DocumentElement, options?: ApiDocument.ExportOptions): {
14
16
  dataType: string | import("../../../schema/opra-schema.js").ComplexType;
@@ -22,14 +22,18 @@ export declare namespace SimpleType {
22
22
  base?: SimpleType;
23
23
  ctor?: Type;
24
24
  properties?: object;
25
- convertToNative?: boolean;
25
+ designType?: boolean;
26
26
  generateDecoder?: SimpleType.ValidatorGenerator;
27
27
  generateEncoder?: SimpleType.ValidatorGenerator;
28
28
  }, DataType.InitArguments, SimpleType.Metadata> {
29
29
  }
30
30
  interface Attribute extends OpraSchema.Attribute {
31
31
  }
32
- type ValidatorGenerator = (properties: Record<string, any>, element: DocumentElement, scope?: string) => Validator;
32
+ type ValidatorGenerator = (properties: Record<string, any>, args: {
33
+ dataType: SimpleType;
34
+ element: DocumentElement;
35
+ scope?: string;
36
+ }) => Validator;
33
37
  }
34
38
  /**
35
39
  * Type definition for MixinType
@@ -5,7 +5,7 @@ import type { MQOperationResponse } from '../mq/mq-operation-response.js';
5
5
  export interface MQOperationDecorator {
6
6
  (target: Object, propertyKey: string): void;
7
7
  Header(name: string | RegExp, optionsOrType?: MQHeader.Options | string | TypeThunkAsync): this;
8
- Response(payloadType: TypeThunkAsync | string, options?: MQOperationResponse.Options): MQOperationResponseDecorator;
8
+ Response(type: TypeThunkAsync | string, options?: MQOperationResponse.Options): MQOperationResponseDecorator;
9
9
  UseType(...type: Type[]): this;
10
10
  }
11
11
  export interface MQOperationResponseDecorator {
@@ -19,14 +19,14 @@ export interface MQOperationDecoratorFactory {
19
19
  /**
20
20
  * Property decorator
21
21
  * @param decoratorChain
22
- * @param payloadType
22
+ * @param type
23
23
  * @param options
24
- */ <T extends MQOperation.Options>(decoratorChain: Function[], payloadType: ThunkAsync<Type> | string, options?: T): MQOperationDecorator;
24
+ */ <T extends MQOperation.Options>(decoratorChain: Function[], type: ThunkAsync<Type> | string, options?: T): MQOperationDecorator;
25
25
  }
26
26
  export declare namespace MQOperationDecoratorFactory {
27
- type AugmentationFunction = (decorator: MQOperationDecorator, decoratorChain: Function[], payloadType: ThunkAsync<Type> | string, options?: MQOperation.Options) => void;
27
+ type AugmentationFunction = (decorator: MQOperationDecorator, decoratorChain: Function[], type: ThunkAsync<Type> | string, options?: MQOperation.Options) => void;
28
28
  }
29
- export declare function MQOperationDecoratorFactory(decoratorChain: Function[], payloadType: ThunkAsync<Type> | string | TypeThunkAsync, options?: MQOperation.Options): MQOperationDecorator;
29
+ export declare function MQOperationDecoratorFactory(decoratorChain: Function[], type: ThunkAsync<Type> | string | TypeThunkAsync, options?: MQOperation.Options): MQOperationDecorator;
30
30
  export declare namespace MQOperationDecoratorFactory {
31
31
  var augment: (fn: MQOperationDecoratorFactory.AugmentationFunction) => void;
32
32
  }
@@ -1,8 +1,6 @@
1
1
  import type { TypeThunkAsync } from 'ts-gems';
2
- import type { MQHeader } from '../mq/mq-header';
3
2
  import type { WSController } from '../ws/ws-controller.js';
4
3
  export interface WSControllerDecorator<T extends WSControllerDecorator<any> = WSControllerDecorator<any>> extends ClassDecorator {
5
- Header(name: string | RegExp, optionsOrType?: MQHeader.Options | string | TypeThunkAsync | false): T;
6
4
  UseType(...type: TypeThunkAsync[]): T;
7
5
  }
8
6
  export interface WSControllerDecoratorFactory {
@@ -1,4 +1,4 @@
1
- import type { ThunkAsync, Type, TypeThunkAsync } from 'ts-gems';
1
+ import type { ThunkAsync, Type } from 'ts-gems';
2
2
  import type { WSOperation } from '../ws/ws-operation.js';
3
3
  export interface WSOperationDecorator {
4
4
  (target: Object, propertyKey: string): void;
@@ -11,14 +11,14 @@ export interface WSOperationDecoratorFactory {
11
11
  /**
12
12
  * Property decorator
13
13
  * @param decoratorChain
14
- * @param payloadType
14
+ * @param type
15
15
  * @param options
16
- */ <T extends WSOperation.Options>(decoratorChain: Function[], payloadType: ThunkAsync<Type> | string, options?: T): WSOperationDecorator;
16
+ */ <T extends WSOperation.Options>(decoratorChain: Function[], type: ThunkAsync<Type> | string, options?: T): WSOperationDecorator;
17
17
  }
18
18
  export declare namespace WSOperationDecoratorFactory {
19
- type AugmentationFunction = (decorator: WSOperationDecorator, decoratorChain: Function[], payloadType: ThunkAsync<Type> | string, options?: WSOperation.Options) => void;
19
+ type AugmentationFunction = (decorator: WSOperationDecorator, decoratorChain: Function[], options?: WSOperation.Options) => void;
20
20
  }
21
- export declare function WSOperationDecoratorFactory(decoratorChain: Function[], payloadType: ThunkAsync<Type> | string | TypeThunkAsync, options?: WSOperation.Options): WSOperationDecorator;
21
+ export declare function WSOperationDecoratorFactory(decoratorChain: Function[], options?: WSOperation.Options): WSOperationDecorator;
22
22
  export declare namespace WSOperationDecoratorFactory {
23
23
  var augment: (fn: WSOperationDecoratorFactory.AugmentationFunction) => void;
24
24
  }
@@ -0,0 +1,2 @@
1
+ import { TypeThunkAsync } from 'ts-gems';
2
+ export declare function WsParam(type?: TypeThunkAsync | string): ParameterDecorator;
@@ -4,6 +4,7 @@ import { OpraSchema } from '../../schema/index.js';
4
4
  import { DocumentElement } from '../common/document-element.js';
5
5
  import { DocumentInitContext } from '../common/document-init-context.js';
6
6
  import { ApiField } from '../data-type/api-field.js';
7
+ import { ArrayType } from '../data-type/array-type.js';
7
8
  import { ComplexType } from '../data-type/complex-type.js';
8
9
  import { DataType } from '../data-type/data-type.js';
9
10
  import { EnumType } from '../data-type/enum-type.js';
@@ -18,6 +19,11 @@ import { UnionType } from '../data-type/union-type.js';
18
19
  export declare namespace DataTypeFactory {
19
20
  type DataTypeSources = ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray | object>[] | Record<string, OpraSchema.DataType>;
20
21
  type DataTypeThunk = Type | EnumType.EnumObject | EnumType.EnumArray | object;
22
+ interface ArrayTypeInit extends Combine<{
23
+ _instance?: ArrayType;
24
+ type: (string | SimpleTypeInit | ComplexTypeInit | MappedTypeInit | MixinTypeInit | UnionTypeInit | ArrayTypeInit)[];
25
+ }, ArrayType.InitArguments> {
26
+ }
21
27
  interface ComplexTypeInit extends Combine<{
22
28
  _instance?: ComplexType;
23
29
  base?: string | ComplexTypeInit | MappedTypeInit | MixinTypeInit;
@@ -54,7 +60,7 @@ export declare namespace DataTypeFactory {
54
60
  type: string | DataTypeInitArguments;
55
61
  }, ApiField.InitArguments> {
56
62
  }
57
- type DataTypeInitArguments = ComplexTypeInit | EnumTypeInit | MappedTypeInit | MixinTypeInit | SimpleTypeInit | UnionTypeInit;
63
+ type DataTypeInitArguments = ComplexTypeInit | EnumTypeInit | MappedTypeInit | MixinTypeInit | SimpleTypeInit | UnionTypeInit | ArrayTypeInit;
58
64
  interface Context extends DocumentInitContext {
59
65
  importQueue?: ResponsiveMap<any>;
60
66
  initArgsMap?: ResponsiveMap<DataTypeInitArguments>;
@@ -98,6 +104,9 @@ export declare class DataTypeFactory {
98
104
  */
99
105
  protected static _importDataTypeArgs(context: DataTypeFactory.Context, owner: DocumentElement, thunk: string | Type | OpraSchema.DataType | object, checkCircularDeps?: boolean): Promise<DataTypeFactory.DataTypeInitArguments | string | void>;
100
106
  protected static _prepareDataTypeArgs(context: DataTypeFactory.Context, initArgs: DataTypeFactory.DataTypeInitArguments, metadata: OpraSchema.DataTypeBase | DataType.Metadata): Promise<void>;
107
+ protected static _prepareArrayTypeArgs(context: DataTypeFactory.Context, owner: DocumentElement, initArgs: DataTypeFactory.ArrayTypeInit, metadata: (ArrayType.Metadata | OpraSchema.ArrayType) & {
108
+ ctor?: Type;
109
+ }): Promise<void>;
101
110
  protected static _prepareComplexTypeArgs(context: DataTypeFactory.Context, owner: DocumentElement, initArgs: DataTypeFactory.ComplexTypeInit, metadata: ComplexType.Metadata | OpraSchema.ComplexType): Promise<void>;
102
111
  protected static _prepareEnumTypeArgs(context: DataTypeFactory.Context, owner: DocumentElement, initArgs: DataTypeFactory.EnumTypeInit, metadata: EnumType.Metadata | OpraSchema.EnumType): Promise<void>;
103
112
  protected static _prepareSimpleTypeArgs(context: DataTypeFactory.Context, owner: DocumentElement, initArgs: DataTypeFactory.SimpleTypeInit, metadata: SimpleType.Metadata | OpraSchema.SimpleType): Promise<void>;
@@ -110,7 +119,8 @@ export declare class DataTypeFactory {
110
119
  }): Promise<void>;
111
120
  protected static _createDataType(context: DocumentInitContext & {
112
121
  initArgsMap?: ResponsiveMap<DataTypeFactory.DataTypeInitArguments>;
113
- }, owner: DocumentElement, args: DataTypeFactory.DataTypeInitArguments | string): ComplexType | EnumType | MappedType | MixinType | SimpleType | UnionType | undefined;
122
+ }, owner: DocumentElement, args: DataTypeFactory.DataTypeInitArguments | string): ArrayType | ComplexType | EnumType | MappedType | MixinType | SimpleType | UnionType | undefined;
123
+ protected static _createArrayType(context: DocumentInitContext, owner: DocumentElement, args: DataTypeFactory.ArrayTypeInit): ArrayType;
114
124
  protected static _createComplexType(context: DocumentInitContext, owner: DocumentElement, args: DataTypeFactory.ComplexTypeInit): ComplexType;
115
125
  protected static _createEnumType(context: DocumentInitContext, owner: DocumentElement, args: DataTypeFactory.EnumTypeInit): EnumType;
116
126
  protected static _createMappedType(context: DocumentInitContext, owner: DocumentElement, args: DataTypeFactory.MappedTypeInit): MappedType;
@@ -12,6 +12,7 @@ export declare namespace HttpMediaType {
12
12
  interface Metadata extends Partial<StrictOmit<OpraSchema.HttpMediaType, 'type' | 'multipartFields'>> {
13
13
  type?: Type | string;
14
14
  multipartFields?: HttpMultipartField.Metadata[];
15
+ designType?: Type;
15
16
  }
16
17
  interface Options extends Partial<StrictOmit<OpraSchema.HttpMediaType, 'type' | 'multipartFields'>> {
17
18
  type?: Type | string;
@@ -54,8 +55,9 @@ declare class HttpMediaTypeClass extends DocumentElement {
54
55
  maxFiles?: number;
55
56
  maxFileSize?: number;
56
57
  maxTotalFileSize?: number;
58
+ designType?: Type;
57
59
  findMultipartField(fieldName: string, fieldType?: OpraSchema.HttpMultipartFieldType): HttpMultipartField | undefined;
58
60
  toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpMediaType;
59
- generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions): Validator;
61
+ generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions, properties?: object): Validator;
60
62
  }
61
63
  export {};
@@ -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 type { ApiDocument } from '../api-document';
4
5
  import { DocumentElement } from '../common/document-element.js';
@@ -13,6 +14,7 @@ export declare namespace HttpParameter {
13
14
  name: string | RegExp;
14
15
  type?: string | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
15
16
  keyParam?: boolean;
17
+ designType?: Type;
16
18
  }
17
19
  interface Options extends Partial<StrictOmit<Metadata, 'type'>> {
18
20
  type?: string | TypeThunkAsync | object;
@@ -50,6 +52,8 @@ declare class HttpParameterClass extends Value {
50
52
  required?: boolean;
51
53
  arraySeparator?: string;
52
54
  parser?: (v: any) => any;
55
+ designType?: Type;
53
56
  toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpParameter;
57
+ generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions, properties?: any): Validator;
54
58
  }
55
59
  export {};