@opra/common 1.0.0-alpha.1 → 1.0.0-alpha.11

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 (177) hide show
  1. package/browser.js +5535 -5248
  2. package/cjs/document/api-document.js +18 -12
  3. package/cjs/document/common/data-type-map.js +1 -1
  4. package/cjs/document/common/document-element.js +2 -1
  5. package/cjs/document/constants.js +1 -1
  6. package/cjs/document/data-type/api-field.js +7 -2
  7. package/cjs/document/data-type/complex-type-base.js +6 -1
  8. package/cjs/document/data-type/complex-type.js +8 -5
  9. package/cjs/document/data-type/data-type.js +2 -1
  10. package/cjs/document/data-type/enum-type.js +5 -2
  11. package/cjs/document/data-type/extended-types/base64.type.js +6 -1
  12. package/cjs/document/data-type/extended-types/date-string.type.js +10 -3
  13. package/cjs/document/data-type/extended-types/date-time-string.type.js +10 -3
  14. package/cjs/document/data-type/extended-types/date-time.type.js +10 -3
  15. package/cjs/document/data-type/extended-types/date.type.js +10 -3
  16. package/cjs/document/data-type/extended-types/email.type.js +24 -10
  17. package/cjs/document/data-type/extended-types/field-path.type.js +13 -7
  18. package/cjs/document/data-type/extended-types/filter.type.js +25 -20
  19. package/cjs/document/data-type/extended-types/object-id.type.js +6 -1
  20. package/cjs/document/data-type/extended-types/operation-result.type.js +20 -10
  21. package/cjs/document/data-type/extended-types/time.type.js +10 -3
  22. package/cjs/document/data-type/extended-types/url.type.js +6 -1
  23. package/cjs/document/data-type/extended-types/uuid.type.js +8 -2
  24. package/cjs/document/data-type/mapped-type.js +12 -5
  25. package/cjs/document/data-type/mixin-type.js +5 -1
  26. package/cjs/document/data-type/primitive-types/any.type.js +2 -1
  27. package/cjs/document/data-type/primitive-types/bigint.type.js +6 -1
  28. package/cjs/document/data-type/primitive-types/boolean.type.js +6 -1
  29. package/cjs/document/data-type/primitive-types/integer.type.js +6 -1
  30. package/cjs/document/data-type/primitive-types/null.type.js +6 -1
  31. package/cjs/document/data-type/primitive-types/number.type.js +10 -3
  32. package/cjs/document/data-type/primitive-types/object.type.js +2 -1
  33. package/cjs/document/data-type/primitive-types/string.type.js +14 -5
  34. package/cjs/document/data-type/simple-type.js +16 -10
  35. package/cjs/document/data-type/utils/create-mapped-class.js +2 -1
  36. package/cjs/document/decorators/http-controller.decorator.js +25 -0
  37. package/cjs/document/decorators/http-operation-entity.decorator.js +55 -19
  38. package/cjs/document/decorators/http-operation.decorator.js +8 -4
  39. package/cjs/document/factory/api-document.factory.js +6 -3
  40. package/cjs/document/factory/data-type.factory.js +98 -57
  41. package/cjs/document/factory/http-api.factory.js +4 -2
  42. package/cjs/document/http/http-api.js +2 -2
  43. package/cjs/document/http/http-controller.js +25 -13
  44. package/cjs/document/http/http-media-type.js +4 -2
  45. package/cjs/document/http/http-operation-response.js +2 -1
  46. package/cjs/document/http/http-operation.js +18 -4
  47. package/cjs/document/http/http-parameter.js +2 -0
  48. package/cjs/document/http/http-status-range.js +1 -2
  49. package/cjs/document/index.js +5 -5
  50. package/cjs/exception/index.js +5 -5
  51. package/cjs/filter/antlr/OpraFilterParser.js +28 -82
  52. package/cjs/filter/ast/index.js +1 -1
  53. package/cjs/filter/build.js +1 -3
  54. package/cjs/filter/filter-rules.js +4 -2
  55. package/cjs/filter/opra-filter.ns.js +2 -2
  56. package/cjs/filter/parse.js +1 -3
  57. package/cjs/helpers/mixin-utils.js +2 -1
  58. package/cjs/helpers/monkey-patches.js +4 -2
  59. package/cjs/helpers/parse-fields-projection.js +1 -3
  60. package/cjs/helpers/responsive-map.js +5 -4
  61. package/cjs/i18n/i18n.js +4 -3
  62. package/cjs/i18n/index.js +1 -1
  63. package/cjs/index.js +1 -1
  64. package/esm/document/api-document.js +18 -12
  65. package/esm/document/common/data-type-map.js +1 -1
  66. package/esm/document/common/document-element.js +2 -1
  67. package/esm/document/constants.js +1 -1
  68. package/esm/document/data-type/api-field.js +7 -2
  69. package/esm/document/data-type/complex-type-base.js +6 -1
  70. package/esm/document/data-type/complex-type.js +8 -5
  71. package/esm/document/data-type/data-type.js +2 -1
  72. package/esm/document/data-type/enum-type.js +5 -2
  73. package/esm/document/data-type/extended-types/base64.type.js +7 -2
  74. package/esm/document/data-type/extended-types/date-string.type.js +11 -4
  75. package/esm/document/data-type/extended-types/date-time-string.type.js +11 -4
  76. package/esm/document/data-type/extended-types/date-time.type.js +11 -4
  77. package/esm/document/data-type/extended-types/date.type.js +11 -4
  78. package/esm/document/data-type/extended-types/email.type.js +25 -11
  79. package/esm/document/data-type/extended-types/field-path.type.js +14 -8
  80. package/esm/document/data-type/extended-types/filter.type.js +26 -21
  81. package/esm/document/data-type/extended-types/object-id.type.js +7 -2
  82. package/esm/document/data-type/extended-types/operation-result.type.js +21 -11
  83. package/esm/document/data-type/extended-types/time.type.js +11 -4
  84. package/esm/document/data-type/extended-types/url.type.js +7 -2
  85. package/esm/document/data-type/extended-types/uuid.type.js +9 -3
  86. package/esm/document/data-type/mapped-type.js +12 -5
  87. package/esm/document/data-type/mixin-type.js +5 -1
  88. package/esm/document/data-type/primitive-types/any.type.js +3 -2
  89. package/esm/document/data-type/primitive-types/bigint.type.js +7 -2
  90. package/esm/document/data-type/primitive-types/boolean.type.js +7 -2
  91. package/esm/document/data-type/primitive-types/integer.type.js +7 -2
  92. package/esm/document/data-type/primitive-types/null.type.js +7 -2
  93. package/esm/document/data-type/primitive-types/number.type.js +11 -4
  94. package/esm/document/data-type/primitive-types/object.type.js +3 -2
  95. package/esm/document/data-type/primitive-types/string.type.js +15 -6
  96. package/esm/document/data-type/simple-type.js +16 -10
  97. package/esm/document/data-type/utils/create-mapped-class.js +2 -1
  98. package/esm/document/decorators/http-controller.decorator.js +25 -0
  99. package/esm/document/decorators/http-operation-entity.decorator.js +55 -19
  100. package/esm/document/decorators/http-operation.decorator.js +8 -4
  101. package/esm/document/factory/api-document.factory.js +5 -3
  102. package/esm/document/factory/data-type.factory.js +98 -57
  103. package/esm/document/factory/http-api.factory.js +4 -2
  104. package/esm/document/http/http-api.js +2 -2
  105. package/esm/document/http/http-controller.js +24 -13
  106. package/esm/document/http/http-media-type.js +4 -2
  107. package/esm/document/http/http-operation-response.js +2 -1
  108. package/esm/document/http/http-operation.js +17 -4
  109. package/esm/document/http/http-parameter.js +2 -0
  110. package/esm/document/http/http-status-range.js +1 -2
  111. package/esm/document/index.js +5 -5
  112. package/esm/exception/index.js +5 -5
  113. package/esm/filter/antlr/OpraFilterParser.js +28 -82
  114. package/esm/filter/ast/index.js +1 -1
  115. package/esm/filter/build.js +1 -3
  116. package/esm/filter/filter-rules.js +4 -2
  117. package/esm/filter/opra-filter.ns.js +2 -2
  118. package/esm/filter/parse.js +1 -3
  119. package/esm/helpers/mixin-utils.js +2 -1
  120. package/esm/helpers/monkey-patches.js +4 -2
  121. package/esm/helpers/parse-fields-projection.js +1 -3
  122. package/esm/helpers/responsive-map.js +5 -4
  123. package/esm/i18n/i18n.js +4 -3
  124. package/esm/i18n/index.js +1 -1
  125. package/esm/index.js +1 -1
  126. package/package.json +8 -7
  127. package/types/document/api-document.d.ts +3 -6
  128. package/types/document/data-type/api-field.d.ts +2 -0
  129. package/types/document/data-type/complex-type.d.ts +1 -1
  130. package/types/document/data-type/data-type.d.ts +4 -2
  131. package/types/document/data-type/enum-type.d.ts +2 -2
  132. package/types/document/data-type/mapped-type.d.ts +2 -2
  133. package/types/document/data-type/mixin-type.d.ts +2 -2
  134. package/types/document/data-type/simple-type.d.ts +4 -2
  135. package/types/document/decorators/http-controller.decorator.d.ts +1 -0
  136. package/types/document/factory/api-document.factory.d.ts +1 -1
  137. package/types/document/factory/data-type.factory.d.ts +5 -0
  138. package/types/document/http/http-controller.d.ts +1 -0
  139. package/types/document/http/http-operation.d.ts +1 -0
  140. package/types/document/http/http-parameter.d.ts +3 -2
  141. package/types/document/index.d.ts +5 -5
  142. package/types/exception/index.d.ts +5 -5
  143. package/types/filter/ast/index.d.ts +1 -1
  144. package/types/filter/opra-filter.ns.d.ts +2 -2
  145. package/types/i18n/i18n.d.ts +21 -19
  146. package/types/index.d.ts +1 -1
  147. package/types/schema/data-type/simple-type.interface.d.ts +4 -0
  148. package/types/schema/document.interface.d.ts +13 -1
  149. package/types/schema/http/http-parameter.interface.d.ts +4 -0
  150. package/types/schema/index.d.ts +1 -0
  151. package/cjs/document/data-type/decorators/api-field-decorator.js +0 -26
  152. package/cjs/document/data-type/decorators/complex-type.decorator.js +0 -33
  153. package/cjs/document/data-type/decorators/simple-type.decorator.js +0 -67
  154. package/cjs/document/http/decorators/http-controller.decorator.js +0 -117
  155. package/cjs/document/http/decorators/http-operation-entity.decorator.js +0 -461
  156. package/cjs/document/http/decorators/http-operation.decorator.js +0 -183
  157. package/cjs/helpers/is-url-string.js +0 -12
  158. package/cjs/http/opra-url-path.js +0 -266
  159. package/cjs/http/opra-url.js +0 -253
  160. package/esm/document/data-type/decorators/api-field-decorator.js +0 -22
  161. package/esm/document/data-type/decorators/complex-type.decorator.js +0 -28
  162. package/esm/document/data-type/decorators/simple-type.decorator.js +0 -61
  163. package/esm/document/http/decorators/http-controller.decorator.js +0 -112
  164. package/esm/document/http/decorators/http-operation-entity.decorator.js +0 -459
  165. package/esm/document/http/decorators/http-operation.decorator.js +0 -178
  166. package/esm/helpers/is-url-string.js +0 -7
  167. package/esm/http/opra-url-path.js +0 -260
  168. package/esm/http/opra-url.js +0 -249
  169. package/types/document/data-type/decorators/api-field-decorator.d.ts +0 -5
  170. package/types/document/data-type/decorators/complex-type.decorator.d.ts +0 -2
  171. package/types/document/data-type/decorators/simple-type.decorator.d.ts +0 -20
  172. package/types/document/http/decorators/http-controller.decorator.d.ts +0 -14
  173. package/types/document/http/decorators/http-operation-entity.decorator.d.ts +0 -100
  174. package/types/document/http/decorators/http-operation.decorator.d.ts +0 -30
  175. package/types/helpers/is-url-string.d.ts +0 -2
  176. package/types/http/opra-url-path.d.ts +0 -55
  177. package/types/http/opra-url.d.ts +0 -66
@@ -4,7 +4,7 @@ import { OpraSchema } from '../../schema/index.js';
4
4
  import type { DocumentElement } from '../common/document-element.js';
5
5
  import type { ComplexType } from './complex-type.js';
6
6
  import { ComplexTypeBase } from './complex-type-base.js';
7
- import type { DataType } from './data-type.js';
7
+ import { DataType } from './data-type.js';
8
8
  import type { MappedType } from './mapped-type.js';
9
9
  /**
10
10
  * @namespace MixinType
@@ -76,7 +76,7 @@ export declare const MixinType: MixinTypeStatic;
76
76
  declare class MixinTypeClass extends ComplexTypeBase {
77
77
  readonly kind: OpraSchema.MixinType.Kind;
78
78
  readonly types: (ComplexType | MixinType | MappedType)[];
79
- extendsFrom(baseType: DataType): boolean;
79
+ extendsFrom(baseType: DataType | string | Type | object): boolean;
80
80
  toJSON(): OpraSchema.MixinType;
81
81
  }
82
82
  export {};
@@ -14,7 +14,7 @@ export declare namespace SimpleType {
14
14
  kind: OpraSchema.SimpleType.Kind;
15
15
  }, DataType.Metadata, OpraSchema.SimpleType> {
16
16
  }
17
- interface Options extends DataType.Options {
17
+ interface Options extends Combine<Pick<OpraSchema.SimpleType, 'nameMappings'>, DataType.Options> {
18
18
  }
19
19
  interface InitArguments extends Combine<{
20
20
  kind: OpraSchema.SimpleType.Kind;
@@ -64,11 +64,13 @@ declare abstract class SimpleTypeClass extends DataType {
64
64
  readonly kind: OpraSchema.SimpleType.Kind;
65
65
  readonly base?: SimpleType;
66
66
  readonly attributes: Record<string, SimpleType.Attribute>;
67
+ readonly nameMappings: Record<string, string>;
67
68
  readonly ownAttributes: Record<string, SimpleType.Attribute>;
69
+ readonly ownNameMappings: Record<string, string>;
68
70
  protected _generateDecoder?: SimpleType.ValidatorGenerator;
69
71
  protected _generateEncoder?: SimpleType.ValidatorGenerator;
70
72
  properties?: any;
71
- extendsFrom(baseType: DataType): boolean;
73
+ extendsFrom(baseType: DataType | string | Type | object): boolean;
72
74
  generateCodec<T extends Record<string, any> | object = object>(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions | null, properties?: Partial<T>): Validator;
73
75
  toJSON(): OpraSchema.SimpleType;
74
76
  }
@@ -6,6 +6,7 @@ export interface HttpControllerDecorator<T extends HttpControllerDecorator<any>
6
6
  Header(name: string | RegExp, optionsOrType?: StrictOmit<HttpParameter.Options, 'location'> | string | TypeThunkAsync | false): T;
7
7
  QueryParam(name: string | RegExp, optionsOrType?: StrictOmit<HttpParameter.Options, 'location'> | string | TypeThunkAsync | false): T;
8
8
  PathParam(name: string | RegExp, optionsOrType?: StrictOmit<HttpParameter.Options, 'location'> | string | TypeThunkAsync | false): T;
9
+ KeyParam(name: string | RegExp, optionsOrType?: StrictOmit<HttpParameter.Options, 'location'> | string | TypeThunkAsync | false): T;
9
10
  UseType(...type: TypeThunkAsync[]): T;
10
11
  }
11
12
  export interface HttpControllerDecoratorFactory {
@@ -5,7 +5,7 @@ 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
7
  export declare namespace ApiDocumentFactory {
8
- interface InitArguments extends PartialSome<StrictOmit<OpraSchema.ApiDocument, 'references' | 'types' | 'api'>, 'spec'> {
8
+ interface InitArguments extends PartialSome<StrictOmit<OpraSchema.ApiDocument, 'id' | 'references' | 'types' | 'api'>, 'spec'> {
9
9
  references?: Record<string, ReferenceThunk>;
10
10
  types?: DataTypeInitSources;
11
11
  api?: HttpApiFactory.InitArguments;
@@ -18,24 +18,29 @@ export declare namespace DataTypeFactory {
18
18
  type DataTypeSources = ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray | object>[] | Record<string, OpraSchema.DataType>;
19
19
  type DataTypeThunk = Type | EnumType.EnumObject | EnumType.EnumArray | object;
20
20
  interface ComplexTypeInit extends Combine<{
21
+ _instance?: ComplexType;
21
22
  base?: string | ComplexTypeInit | MappedTypeInit | MixinTypeInit;
22
23
  fields?: Record<string, ApiFieldInit>;
23
24
  additionalFields?: boolean | string | DataTypeFactory.DataTypeInitArguments | ['error'] | ['error', string];
24
25
  }, ComplexType.InitArguments> {
25
26
  }
26
27
  interface EnumTypeInit extends Combine<{
28
+ _instance?: MappedType;
27
29
  base?: string | EnumTypeInit;
28
30
  }, EnumType.InitArguments> {
29
31
  }
30
32
  interface MappedTypeInit extends Combine<{
33
+ _instance?: MappedType;
31
34
  base: string | ComplexTypeInit | MappedTypeInit | MixinTypeInit;
32
35
  }, MappedType.InitArguments> {
33
36
  }
34
37
  interface MixinTypeInit extends Combine<{
38
+ _instance?: MixinType;
35
39
  types: (string | ComplexTypeInit | MappedTypeInit | MixinTypeInit)[];
36
40
  }, MixinType.InitArguments> {
37
41
  }
38
42
  interface SimpleTypeInit extends Combine<{
43
+ _instance?: SimpleType;
39
44
  base?: string | SimpleTypeInit;
40
45
  }, SimpleType.InitArguments> {
41
46
  }
@@ -76,6 +76,7 @@ declare class HttpControllerClass extends DocumentElement {
76
76
  findController(controller: Type): HttpController | undefined;
77
77
  findController(resourcePath: string): HttpController | undefined;
78
78
  findParameter(paramName: string, location?: OpraSchema.HttpParameterLocation): HttpParameter | undefined;
79
+ getFullUrl(): string;
79
80
  /**
80
81
  *
81
82
  */
@@ -79,6 +79,7 @@ declare class HttpOperationClass extends DocumentElement {
79
79
  composition?: string;
80
80
  compositionOptions?: Record<string, any>;
81
81
  findParameter(paramName: string, location?: OpraSchema.HttpParameterLocation): HttpParameter | undefined;
82
+ getFullUrl(): string;
82
83
  toJSON(): OpraSchema.HttpOperation;
83
84
  }
84
85
  export {};
@@ -1,6 +1,5 @@
1
1
  import { Combine, StrictOmit, TypeThunkAsync } from 'ts-gems';
2
2
  import type { OpraSchema } from '../../schema/index.js';
3
- import { HttpParameterLocation } from '../../schema/types.js';
4
3
  import { DocumentElement } from '../common/document-element.js';
5
4
  import { Value } from '../common/value.js';
6
5
  import { DataType } from '../data-type/data-type.js';
@@ -12,6 +11,7 @@ export declare namespace HttpParameter {
12
11
  interface Metadata extends StrictOmit<OpraSchema.HttpParameter, 'type'> {
13
12
  name: string | RegExp;
14
13
  type?: string | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
14
+ keyParam?: boolean;
15
15
  }
16
16
  interface Options extends Partial<StrictOmit<Metadata, 'type'>> {
17
17
  type?: string | TypeThunkAsync | object;
@@ -41,10 +41,11 @@ export declare const HttpParameter: HttpParameterStatic;
41
41
  */
42
42
  declare class HttpParameterClass extends Value {
43
43
  readonly owner: DocumentElement;
44
+ keyParam?: boolean;
44
45
  deprecated?: boolean | string;
45
46
  required?: boolean;
46
47
  arraySeparator?: string;
47
- location: HttpParameterLocation;
48
+ location: OpraSchema.HttpParameterLocation;
48
49
  toJSON(): OpraSchema.HttpParameter;
49
50
  }
50
51
  export {};
@@ -2,36 +2,36 @@ import 'reflect-metadata';
2
2
  import * as DataTypeFactory_ from './factory/data-type.factory.js';
3
3
  import * as HttpApiFactory_ from './factory/http-api.factory.js';
4
4
  export * from './api-document.js';
5
- export * from './constants.js';
6
5
  export * from './common/api-base.js';
7
6
  export * from './common/data-type-map.js';
8
7
  export * from './common/document-element.js';
9
8
  export * from './common/document-init-context.js';
10
9
  export * from './common/document-node.js';
11
10
  export * from './common/opra-document-error.js';
11
+ export * from './constants.js';
12
+ export * from './data-type/api-field.js';
12
13
  export * from './data-type/complex-type.js';
13
14
  export * from './data-type/data-type.js';
14
15
  export * from './data-type/enum-type.js';
15
- export * from './data-type/api-field.js';
16
+ export * from './data-type/extended-types/index.js';
16
17
  export * from './data-type/mapped-type.js';
17
18
  export * from './data-type/mixin-type.js';
18
19
  export * from './data-type/omit-type.js';
19
20
  export * from './data-type/partial-type.js';
20
21
  export * from './data-type/pick-type.js';
22
+ export * from './data-type/primitive-types/index.js';
21
23
  export * from './data-type/required-type.js';
22
24
  export * from './data-type/simple-type.js';
23
- export * from './data-type/primitive-types/index.js';
24
- export * from './data-type/extended-types/index.js';
25
25
  export * from './decorators/http-operation-entity.decorator.js';
26
26
  export * from './factory/api-document.factory.js';
27
27
  export * from './http/http-api.js';
28
+ export * from './http/http-controller.js';
28
29
  export * from './http/http-media-type.js';
29
30
  export * from './http/http-multipart-field.js';
30
31
  export * from './http/http-operation.js';
31
32
  export * from './http/http-operation-response.js';
32
33
  export * from './http/http-parameter.js';
33
34
  export * from './http/http-request-body.js';
34
- export * from './http/http-controller.js';
35
35
  export * from './http/http-status-range.js';
36
36
  export declare namespace classes {
37
37
  export import HttpApiFactory = HttpApiFactory_.HttpApiFactory;
@@ -1,7 +1,4 @@
1
- export * from './opra-exception.js';
2
- export * from './opra-http-error.js';
3
1
  export * from './error-issue.js';
4
- export * from './issue-severity.enum.js';
5
2
  export * from './http-errors/bad-request.error.js';
6
3
  export * from './http-errors/conflict.error.js';
7
4
  export * from './http-errors/failed-dependency.error.js';
@@ -10,8 +7,11 @@ export * from './http-errors/internal-server.error.js';
10
7
  export * from './http-errors/method-not-allowed.error.js';
11
8
  export * from './http-errors/not-acceptable.error.js';
12
9
  export * from './http-errors/not-found.error.js';
13
- export * from './http-errors/unauthorized.error.js';
14
- export * from './http-errors/unprocessable-entity.error.js';
15
10
  export * from './http-errors/permission.error.js';
16
11
  export * from './http-errors/resource-conflict.error.js';
17
12
  export * from './http-errors/resource-not.available.error.js';
13
+ export * from './http-errors/unauthorized.error.js';
14
+ export * from './http-errors/unprocessable-entity.error.js';
15
+ export * from './issue-severity.enum.js';
16
+ export * from './opra-exception.js';
17
+ export * from './opra-http-error.js';
@@ -6,8 +6,8 @@ export * from './expressions/arithmetic-expression.js';
6
6
  export * from './expressions/array-expression.js';
7
7
  export * from './expressions/comparison-expression.js';
8
8
  export * from './expressions/logical-expression.js';
9
- export * from './expressions/parenthesized-expression.js';
10
9
  export * from './expressions/negative-expression.js';
10
+ export * from './expressions/parenthesized-expression.js';
11
11
  export * from './terms/boolean-literal.js';
12
12
  export * from './terms/date-literal.js';
13
13
  export * from './terms/null-literal.js';
@@ -1,5 +1,5 @@
1
1
  export * from './ast/index.js';
2
- export * from './parse.js';
3
2
  export * from './build.js';
4
- export * from './opra-error-listener.js';
5
3
  export * from './filter-tree-visitor.js';
4
+ export * from './opra-error-listener.js';
5
+ export * from './parse.js';
@@ -1,26 +1,28 @@
1
- import { Type } from 'ts-gems';
2
- import { FallbackLng, Formatter as I18nextFormatter, i18n, InitOptions as I18nextInitOptions, Resource as I18nextResource, TFunction as I18nextTFunction, TOptions } from '@browsery/i18next';
1
+ import { FallbackLng as I18nextFallbackLng, Formatter as I18nextFormatter, i18n, InitOptions as I18nextInitOptions, Resource as I18nextResource, TFunction as I18nextTFunction, TOptions } from '@browsery/i18next';
3
2
  import * as I18next from '@browsery/i18next';
3
+ import { Type } from 'ts-gems';
4
4
  export interface BaseI18n extends Type<I18next.i18n> {
5
5
  }
6
- export declare const BaseI18n: BaseI18n;
7
- export type DeepTranslateOptions = TOptions & {
8
- ignore?: (input: any, inst: i18n) => boolean;
9
- };
10
- export type InitCallback = I18next.Callback;
11
- export type TranslateFunction = I18nextTFunction;
12
- export type Formatter = I18nextFormatter;
13
- export type LanguageResource = I18nextResource;
14
- export type { FallbackLng };
15
- export interface InitOptions extends I18nextInitOptions {
16
- resourceDirs?: string[];
6
+ export declare namespace I18n {
7
+ interface InitOptions extends I18nextInitOptions {
8
+ resourceDirs?: string[];
9
+ }
10
+ type DeepTranslateOptions = TOptions & {
11
+ ignore?: (input: any, inst: i18n) => boolean;
12
+ };
13
+ type InitCallback = I18next.Callback;
14
+ type TranslateFunction = I18nextTFunction;
15
+ type Formatter = I18nextFormatter;
16
+ type LanguageResource = I18nextResource;
17
+ type FallbackLng = I18nextFallbackLng;
17
18
  }
19
+ export declare const BaseI18n: BaseI18n;
18
20
  export declare class I18n extends BaseI18n {
19
- init(callback?: InitCallback): Promise<TranslateFunction>;
20
- init(options: InitOptions, callback?: InitCallback): Promise<TranslateFunction>;
21
- deep(input: any, options?: DeepTranslateOptions): any;
22
- createInstance(options: {} | undefined, callback: any): I18n;
23
- static createInstance(options?: InitOptions, callback?: InitCallback): I18n;
24
- protected _deepTranslate(input: any, objectStack: WeakMap<object, any>, options?: DeepTranslateOptions): any;
21
+ init(callback?: I18n.InitCallback): Promise<I18n.TranslateFunction>;
22
+ init(options: I18n.InitOptions, callback?: I18n.InitCallback): Promise<I18n.TranslateFunction>;
23
+ deep(input: any, options?: I18n.DeepTranslateOptions): any;
24
+ createInstance(options?: I18n.InitOptions, callback?: I18n.InitCallback): I18n;
25
+ static createInstance(options?: I18n.InitOptions, callback?: I18n.InitCallback): I18n;
26
+ protected _deepTranslate(input: any, objectStack: WeakMap<object, any>, options?: I18n.DeepTranslateOptions): any;
25
27
  static get defaultInstance(): I18n;
26
28
  }
package/types/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './types.js';
2
1
  export * from './document/index.js';
3
2
  export * from './exception/index.js';
4
3
  export * from './filter/index.js';
@@ -6,4 +5,5 @@ export * from './helpers/index.js';
6
5
  export * from './http/index.js';
7
6
  export * from './i18n/index.js';
8
7
  export * from './schema/index.js';
8
+ export * from './types.js';
9
9
  export { uid } from 'uid';
@@ -9,6 +9,10 @@ export interface SimpleType extends StrictOmit<DataTypeBase, 'kind'> {
9
9
  base?: DataType.Name;
10
10
  attributes?: Record<string, Attribute>;
11
11
  properties?: Record<string, any>;
12
+ /**
13
+ * Naming alternatives across software languages
14
+ */
15
+ nameMappings?: Record<string, string>;
12
16
  }
13
17
  export declare namespace SimpleType {
14
18
  const Kind = "SimpleType";
@@ -7,9 +7,10 @@ export type Protocol = 'http' | 'ws' | 'rpc';
7
7
  */
8
8
  export interface Document extends DataTypeContainer {
9
9
  spec: SpecVersion;
10
+ id: string;
10
11
  url?: string;
11
12
  info?: DocumentInfo;
12
- references?: Record<string, string | Document>;
13
+ references?: Record<string, DocumentReference>;
13
14
  api?: HttpApi;
14
15
  }
15
16
  /**
@@ -39,6 +40,14 @@ export interface LicenseInfo {
39
40
  url?: string;
40
41
  content?: string;
41
42
  }
43
+ /**
44
+ * @interface DocumentReference
45
+ */
46
+ export interface DocumentReference extends Pick<Document, 'id' | 'url' | 'info'> {
47
+ }
48
+ /**
49
+ * @interface Api
50
+ */
42
51
  export interface Api extends DataTypeContainer {
43
52
  protocol: Protocol;
44
53
  /**
@@ -47,6 +56,9 @@ export interface Api extends DataTypeContainer {
47
56
  name: string;
48
57
  description?: string;
49
58
  }
59
+ /**
60
+ * @interface HttpApi
61
+ */
50
62
  export interface HttpApi extends Api {
51
63
  protocol: 'http';
52
64
  description?: string;
@@ -13,6 +13,10 @@ export interface HttpParameter extends Value {
13
13
  * Name of the parameter. RegExp pattern can be used matching parameter name
14
14
  */
15
15
  name: string | RegExp;
16
+ /**
17
+ * Determines if parameter is key
18
+ */
19
+ keyParam?: boolean;
16
20
  /**
17
21
  * Defines array separator
18
22
  */
@@ -26,6 +26,7 @@ export declare namespace OpraSchema {
26
26
  export import DocumentInfo = apiDocument_.DocumentInfo;
27
27
  export import ContactPerson = apiDocument_.ContactPerson;
28
28
  export import LicenseInfo = apiDocument_.LicenseInfo;
29
+ export import DocumentReference = apiDocument_.DocumentReference;
29
30
  export import HttpApi = apiDocument_.HttpApi;
30
31
  export import Api = apiDocument_.Api;
31
32
  export import HttpMethod = types_.HttpMethod;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiFieldDecorator = void 0;
4
- const index_js_1 = require("../../../helpers/index.js");
5
- const index_js_2 = require("../../../schema/index.js");
6
- const constants_js_1 = require("../../constants.js");
7
- function ApiFieldDecorator(options) {
8
- return function (target, propertyKey) {
9
- if (typeof propertyKey !== 'string')
10
- throw new TypeError(`Symbol properties can't be used as a field`);
11
- const metadata = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, target.constructor) || {};
12
- metadata.kind = index_js_2.OpraSchema.ComplexType.Kind;
13
- metadata.fields = metadata.fields || {};
14
- const designType = Reflect.getMetadata('design:type', target, propertyKey);
15
- const elemMeta = (metadata.fields[propertyKey] = {
16
- ...options,
17
- });
18
- if (designType === Array) {
19
- elemMeta.isArray = true;
20
- }
21
- else
22
- elemMeta.type = elemMeta.type || designType;
23
- Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, (0, index_js_1.omitUndefined)(metadata), target.constructor);
24
- };
25
- }
26
- exports.ApiFieldDecorator = ApiFieldDecorator;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComplexTypeDecorator = void 0;
4
- const tslib_1 = require("tslib");
5
- const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
6
- const index_js_1 = require("../../../schema/index.js");
7
- const constants_js_1 = require("../../constants.js");
8
- function ComplexTypeDecorator(options) {
9
- return function (target) {
10
- let name;
11
- if (!options?.embedded) {
12
- if (options?.name) {
13
- if (!constants_js_1.CLASS_NAME_PATTERN.test(options.name))
14
- throw new TypeError(`"${options.name}" is not a valid type name`);
15
- name = options.name;
16
- }
17
- else {
18
- name = target.name.match(constants_js_1.EXTRACT_TYPENAME_PATTERN)?.[1] || target.name;
19
- }
20
- }
21
- let metadata = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, target);
22
- if (!metadata) {
23
- metadata = {};
24
- Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata, target);
25
- }
26
- metadata.kind = index_js_1.OpraSchema.ComplexType.Kind;
27
- metadata.name = name;
28
- // Merge options
29
- if (options)
30
- Object.assign(metadata, (0, lodash_omit_1.default)(options, ['kind', 'name', 'base', 'fields']));
31
- };
32
- }
33
- exports.ComplexTypeDecorator = ComplexTypeDecorator;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AttributeDecoratorFactory = exports.SimpleTypeDecoratorFactory = void 0;
4
- const tslib_1 = require("tslib");
5
- const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
6
- const index_js_1 = require("../../../schema/index.js");
7
- const constants_js_1 = require("../../constants.js");
8
- function SimpleTypeDecoratorFactory(options) {
9
- const decoratorChain = [];
10
- /**
11
- *
12
- */
13
- const decorator = function (target) {
14
- let name;
15
- if (!options?.embedded) {
16
- if (options?.name) {
17
- if (!constants_js_1.CLASS_NAME_PATTERN.test(options.name))
18
- throw new TypeError(`"${options.name}" is not a valid type name`);
19
- name = options.name;
20
- }
21
- else {
22
- name = target.name.match(constants_js_1.EXTRACT_TYPENAME_PATTERN)?.[1] || target.name;
23
- name = name.toLowerCase();
24
- }
25
- }
26
- const metadata = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, target) || {};
27
- metadata.kind = index_js_1.OpraSchema.SimpleType.Kind;
28
- metadata.name = name;
29
- if (options)
30
- Object.assign(metadata, (0, lodash_omit_1.default)(options, ['kind', 'name']));
31
- Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata, target);
32
- };
33
- decorator.Example = (value, description) => {
34
- decoratorChain.push((meta) => {
35
- meta.examples = meta.examples || [];
36
- meta.examples.push({
37
- description,
38
- value,
39
- });
40
- });
41
- return decorator;
42
- };
43
- return decorator;
44
- }
45
- exports.SimpleTypeDecoratorFactory = SimpleTypeDecoratorFactory;
46
- function AttributeDecoratorFactory(options) {
47
- return (target, propertyKey) => {
48
- if (typeof propertyKey !== 'string')
49
- throw new TypeError(`Symbol properties can't be decorated with Attribute`);
50
- const metadata = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, target.constructor) || {};
51
- const designType = Reflect.getMetadata('design:type', target, propertyKey);
52
- let format = 'string';
53
- if (designType === Boolean)
54
- format = 'boolean';
55
- else if (designType === Number)
56
- format = 'number';
57
- metadata.kind = index_js_1.OpraSchema.SimpleType.Kind;
58
- metadata.attributes = metadata.attributes || {};
59
- metadata.attributes[propertyKey] = {
60
- format: options?.format || format,
61
- description: options?.description,
62
- deprecated: options?.deprecated,
63
- };
64
- Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata, target.constructor);
65
- };
66
- }
67
- exports.AttributeDecoratorFactory = AttributeDecoratorFactory;
@@ -1,117 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpControllerDecoratorFactory = void 0;
4
- const tslib_1 = require("tslib");
5
- const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
6
- const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
7
- const index_js_1 = require("../../../schema/index.js");
8
- const constants_js_1 = require("../../constants.js");
9
- const CLASS_NAME_PATTERN = /^(.*)(Collection|Singleton|Resource|Controller)$/;
10
- function HttpControllerDecoratorFactory(options) {
11
- const decoratorChain = [];
12
- /**
13
- *
14
- */
15
- const decorator = function (target) {
16
- let name = options?.name;
17
- if (!name)
18
- name = CLASS_NAME_PATTERN.exec(target.name)?.[1] || target.name;
19
- const metadata = {};
20
- const baseMetadata = Reflect.getOwnMetadata(constants_js_1.HTTP_CONTROLLER_METADATA, Object.getPrototypeOf(target));
21
- if (baseMetadata)
22
- (0, putil_merge_1.default)(metadata, baseMetadata, { deep: true });
23
- const oldMetadata = Reflect.getOwnMetadata(constants_js_1.HTTP_CONTROLLER_METADATA, target);
24
- if (oldMetadata)
25
- (0, putil_merge_1.default)(metadata, oldMetadata, { deep: true });
26
- (0, putil_merge_1.default)(metadata, {
27
- kind: index_js_1.OpraSchema.HttpController.Kind,
28
- name,
29
- path: name,
30
- ...(0, lodash_omit_1.default)(options, ['kind', 'name', 'instance', 'endpoints', 'key']),
31
- }, { deep: true });
32
- Reflect.defineMetadata(constants_js_1.HTTP_CONTROLLER_METADATA, metadata, target);
33
- for (const fn of decoratorChain)
34
- fn(metadata);
35
- Reflect.defineMetadata(constants_js_1.HTTP_CONTROLLER_METADATA, metadata, target);
36
- };
37
- /**
38
- *
39
- */
40
- decorator.Cookie = (name, arg1) => {
41
- decoratorChain.push((meta) => {
42
- const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
43
- ? {
44
- name,
45
- location: 'cookie',
46
- type: arg1,
47
- }
48
- : { ...arg1, name, location: 'cookie' };
49
- meta.parameters = meta.parameters || [];
50
- meta.parameters.push(paramMeta);
51
- });
52
- return decorator;
53
- };
54
- /**
55
- *
56
- */
57
- decorator.Header = (name, arg1) => {
58
- decoratorChain.push((meta) => {
59
- const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
60
- ? {
61
- name,
62
- location: 'header',
63
- type: arg1,
64
- }
65
- : { ...arg1, name, location: 'header' };
66
- meta.parameters = meta.parameters || [];
67
- meta.parameters.push(paramMeta);
68
- });
69
- return decorator;
70
- };
71
- /**
72
- *
73
- */
74
- decorator.QueryParam = (name, arg1) => {
75
- decoratorChain.push((meta) => {
76
- const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
77
- ? {
78
- name,
79
- location: 'query',
80
- type: arg1,
81
- }
82
- : { ...arg1, name, location: 'query' };
83
- meta.parameters = meta.parameters || [];
84
- meta.parameters.push(paramMeta);
85
- });
86
- return decorator;
87
- };
88
- /**
89
- *
90
- */
91
- decorator.PathParam = (name, arg1) => {
92
- decoratorChain.push((meta) => {
93
- const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
94
- ? {
95
- name,
96
- location: 'path',
97
- type: arg1,
98
- }
99
- : { ...arg1, name, location: 'path' };
100
- meta.parameters = meta.parameters || [];
101
- meta.parameters.push(paramMeta);
102
- });
103
- return decorator;
104
- };
105
- /**
106
- *
107
- */
108
- decorator.UseType = (...type) => {
109
- decoratorChain.push((meta) => {
110
- meta.types = meta.types || [];
111
- meta.types.push(...type);
112
- });
113
- return decorator;
114
- };
115
- return decorator;
116
- }
117
- exports.HttpControllerDecoratorFactory = HttpControllerDecoratorFactory;