@opra/common 1.4.3 → 1.5.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 (182) hide show
  1. package/browser/index.cjs +5 -5
  2. package/browser/index.mjs +5 -5
  3. package/cjs/document/api-document.js +16 -9
  4. package/cjs/document/common/api-base.js +4 -2
  5. package/cjs/document/common/data-type-map.js +14 -3
  6. package/cjs/document/common/document-init-context.js +5 -0
  7. package/cjs/document/common/document-node.js +25 -29
  8. package/cjs/document/common/value.js +9 -3
  9. package/cjs/document/constants.js +1 -2
  10. package/cjs/document/data-type/api-field.js +19 -4
  11. package/cjs/document/data-type/complex-type-base.js +24 -7
  12. package/cjs/document/data-type/complex-type.js +17 -6
  13. package/cjs/document/data-type/data-type.js +16 -1
  14. package/cjs/document/data-type/enum-type.js +12 -3
  15. package/cjs/document/data-type/extended-types/base64.type.js +1 -0
  16. package/cjs/document/data-type/extended-types/date-string.type.js +1 -0
  17. package/cjs/document/data-type/extended-types/date-time-string.type.js +1 -0
  18. package/cjs/document/data-type/extended-types/date-time.type.js +6 -1
  19. package/cjs/document/data-type/extended-types/date.type.js +6 -1
  20. package/cjs/document/data-type/extended-types/email.type.js +1 -0
  21. package/cjs/document/data-type/extended-types/field-path.type.js +9 -3
  22. package/cjs/document/data-type/extended-types/filter.type.js +14 -5
  23. package/cjs/document/data-type/extended-types/object-id.type.js +1 -0
  24. package/cjs/document/data-type/extended-types/operation-result.type.js +1 -0
  25. package/cjs/document/data-type/extended-types/time.type.js +1 -0
  26. package/cjs/document/data-type/extended-types/url.type.js +1 -0
  27. package/cjs/document/data-type/extended-types/uuid.type.js +1 -0
  28. package/cjs/document/data-type/mapped-type.js +21 -9
  29. package/cjs/document/data-type/mixin-type.js +10 -5
  30. package/cjs/document/data-type/primitive-types/any.type.js +1 -0
  31. package/cjs/document/data-type/primitive-types/bigint.type.js +4 -1
  32. package/cjs/document/data-type/primitive-types/boolean.type.js +1 -0
  33. package/cjs/document/data-type/primitive-types/integer.type.js +4 -1
  34. package/cjs/document/data-type/primitive-types/null.type.js +1 -0
  35. package/cjs/document/data-type/primitive-types/number.type.js +4 -1
  36. package/cjs/document/data-type/primitive-types/string.type.js +4 -1
  37. package/cjs/document/data-type/simple-type.js +17 -5
  38. package/cjs/document/data-type/utils/create-mapped-class.js +3 -1
  39. package/cjs/document/decorators/api-field-decorator.js +2 -1
  40. package/cjs/document/decorators/complex-type.decorator.js +1 -1
  41. package/cjs/document/decorators/http-controller.decorator.js +7 -1
  42. package/cjs/document/decorators/http-operation-entity.decorator.js +20 -10
  43. package/cjs/document/decorators/http-operation.decorator.js +23 -10
  44. package/cjs/document/decorators/rpc-operation.decorator.js +1 -2
  45. package/cjs/document/decorators/simple-type.decorator.js +3 -2
  46. package/cjs/document/factory/api-document.factory.js +12 -3
  47. package/cjs/document/factory/data-type.factory.js +19 -7
  48. package/cjs/document/factory/http-api.factory.js +13 -4
  49. package/cjs/document/http/http-api.js +2 -2
  50. package/cjs/document/http/http-controller.js +7 -6
  51. package/cjs/document/http/http-media-type.js +18 -8
  52. package/cjs/document/http/http-multipart-field.js +2 -2
  53. package/cjs/document/http/http-operation-response.js +11 -6
  54. package/cjs/document/http/http-operation.js +8 -6
  55. package/cjs/document/http/http-parameter.js +2 -2
  56. package/cjs/document/http/http-request-body.js +4 -2
  57. package/cjs/document/http/http-status-range.js +3 -1
  58. package/cjs/document/rpc/rpc-operation-response.js +11 -3
  59. package/cjs/document/rpc/rpc-operation.js +11 -3
  60. package/cjs/document/utils/parse-regexp.util.js +2 -2
  61. package/cjs/exception/opra-exception.js +3 -1
  62. package/cjs/filter/antlr/OpraFilterLexer.js +190 -123
  63. package/cjs/filter/antlr/OpraFilterParser.js +53 -35
  64. package/cjs/filter/ast/expressions/arithmetic-expression.js +3 -1
  65. package/cjs/filter/ast/terms/number-literal.js +3 -1
  66. package/cjs/filter/filter-rules.js +18 -8
  67. package/cjs/filter/filter-tree-visitor.js +2 -1
  68. package/cjs/filter/opra-error-listener.js +7 -1
  69. package/cjs/filter/parse.js +3 -1
  70. package/cjs/filter/utils.js +3 -1
  71. package/cjs/helpers/get-stack-filename.js +6 -2
  72. package/cjs/helpers/mixin-utils.js +7 -2
  73. package/cjs/helpers/object-utils.js +3 -1
  74. package/cjs/helpers/parse-fields-projection.js +4 -2
  75. package/cjs/helpers/type-guards.js +7 -2
  76. package/cjs/i18n/i18n.js +13 -3
  77. package/cjs/i18n/translate.js +3 -1
  78. package/cjs/polifils/array-find-last.js +0 -2
  79. package/esm/document/api-document.js +17 -10
  80. package/esm/document/common/api-base.js +4 -2
  81. package/esm/document/common/data-type-map.js +14 -3
  82. package/esm/document/common/document-init-context.js +5 -0
  83. package/esm/document/common/document-node.js +25 -29
  84. package/esm/document/common/value.js +9 -3
  85. package/esm/document/constants.js +0 -1
  86. package/esm/document/data-type/api-field.js +19 -4
  87. package/esm/document/data-type/complex-type-base.js +25 -8
  88. package/esm/document/data-type/complex-type.js +17 -6
  89. package/esm/document/data-type/data-type.js +17 -2
  90. package/esm/document/data-type/enum-type.js +12 -3
  91. package/esm/document/data-type/extended-types/base64.type.js +1 -0
  92. package/esm/document/data-type/extended-types/date-string.type.js +1 -0
  93. package/esm/document/data-type/extended-types/date-time-string.type.js +1 -0
  94. package/esm/document/data-type/extended-types/date-time.type.js +6 -1
  95. package/esm/document/data-type/extended-types/date.type.js +6 -1
  96. package/esm/document/data-type/extended-types/email.type.js +1 -0
  97. package/esm/document/data-type/extended-types/field-path.type.js +9 -3
  98. package/esm/document/data-type/extended-types/filter.type.js +14 -5
  99. package/esm/document/data-type/extended-types/object-id.type.js +1 -0
  100. package/esm/document/data-type/extended-types/operation-result.type.js +1 -0
  101. package/esm/document/data-type/extended-types/time.type.js +1 -0
  102. package/esm/document/data-type/extended-types/url.type.js +1 -0
  103. package/esm/document/data-type/extended-types/uuid.type.js +1 -0
  104. package/esm/document/data-type/mapped-type.js +21 -9
  105. package/esm/document/data-type/mixin-type.js +11 -6
  106. package/esm/document/data-type/primitive-types/any.type.js +1 -0
  107. package/esm/document/data-type/primitive-types/bigint.type.js +4 -1
  108. package/esm/document/data-type/primitive-types/boolean.type.js +1 -0
  109. package/esm/document/data-type/primitive-types/integer.type.js +4 -1
  110. package/esm/document/data-type/primitive-types/null.type.js +1 -0
  111. package/esm/document/data-type/primitive-types/number.type.js +4 -1
  112. package/esm/document/data-type/primitive-types/string.type.js +4 -1
  113. package/esm/document/data-type/simple-type.js +18 -6
  114. package/esm/document/data-type/utils/create-mapped-class.js +4 -2
  115. package/esm/document/decorators/api-field-decorator.js +2 -1
  116. package/esm/document/decorators/complex-type.decorator.js +2 -2
  117. package/esm/document/decorators/http-controller.decorator.js +7 -1
  118. package/esm/document/decorators/http-operation-entity.decorator.js +22 -12
  119. package/esm/document/decorators/http-operation.decorator.js +23 -10
  120. package/esm/document/decorators/rpc-operation.decorator.js +1 -2
  121. package/esm/document/decorators/simple-type.decorator.js +4 -3
  122. package/esm/document/factory/api-document.factory.js +12 -3
  123. package/esm/document/factory/data-type.factory.js +21 -9
  124. package/esm/document/factory/http-api.factory.js +13 -4
  125. package/esm/document/http/http-api.js +2 -2
  126. package/esm/document/http/http-controller.js +8 -7
  127. package/esm/document/http/http-media-type.js +18 -8
  128. package/esm/document/http/http-multipart-field.js +2 -2
  129. package/esm/document/http/http-operation-response.js +11 -6
  130. package/esm/document/http/http-operation.js +9 -7
  131. package/esm/document/http/http-parameter.js +3 -3
  132. package/esm/document/http/http-request-body.js +4 -2
  133. package/esm/document/http/http-status-range.js +3 -1
  134. package/esm/document/rpc/rpc-controller.js +1 -1
  135. package/esm/document/rpc/rpc-header.js +1 -1
  136. package/esm/document/rpc/rpc-operation-response.js +11 -3
  137. package/esm/document/rpc/rpc-operation.js +12 -4
  138. package/esm/document/utils/parse-regexp.util.js +2 -2
  139. package/esm/exception/opra-exception.js +3 -1
  140. package/esm/filter/antlr/OpraFilterLexer.js +190 -123
  141. package/esm/filter/antlr/OpraFilterParser.js +53 -35
  142. package/esm/filter/ast/expressions/arithmetic-expression.js +3 -1
  143. package/esm/filter/ast/terms/number-literal.js +3 -1
  144. package/esm/filter/filter-rules.js +18 -8
  145. package/esm/filter/filter-tree-visitor.js +2 -1
  146. package/esm/filter/opra-error-listener.js +8 -2
  147. package/esm/filter/parse.js +3 -1
  148. package/esm/filter/utils.js +3 -1
  149. package/esm/helpers/get-stack-filename.js +6 -2
  150. package/esm/helpers/mixin-utils.js +7 -2
  151. package/esm/helpers/object-utils.js +3 -1
  152. package/esm/helpers/parse-fields-projection.js +4 -2
  153. package/esm/helpers/type-guards.js +7 -2
  154. package/esm/i18n/i18n.js +13 -3
  155. package/esm/i18n/translate.js +3 -1
  156. package/esm/polifils/array-find-last.js +0 -2
  157. package/package.json +1 -1
  158. package/types/document/api-document.d.ts +8 -2
  159. package/types/document/common/api-base.d.ts +1 -1
  160. package/types/document/common/document-init-context.d.ts +2 -0
  161. package/types/document/common/document-node.d.ts +8 -14
  162. package/types/document/common/value.d.ts +2 -1
  163. package/types/document/constants.d.ts +0 -1
  164. package/types/document/data-type/api-field.d.ts +6 -11
  165. package/types/document/data-type/complex-type.d.ts +2 -1
  166. package/types/document/data-type/data-type.d.ts +7 -2
  167. package/types/document/data-type/enum-type.d.ts +2 -1
  168. package/types/document/data-type/extended-types/field-path.type.d.ts +2 -1
  169. package/types/document/data-type/extended-types/filter.type.d.ts +2 -1
  170. package/types/document/data-type/mapped-type.d.ts +2 -1
  171. package/types/document/data-type/mixin-type.d.ts +2 -1
  172. package/types/document/data-type/simple-type.d.ts +2 -1
  173. package/types/document/factory/api-document.factory.d.ts +2 -1
  174. package/types/document/http/http-api.d.ts +1 -1
  175. package/types/document/http/http-controller.d.ts +2 -1
  176. package/types/document/http/http-media-type.d.ts +2 -1
  177. package/types/document/http/http-multipart-field.d.ts +2 -1
  178. package/types/document/http/http-operation-response.d.ts +2 -1
  179. package/types/document/http/http-operation.d.ts +2 -1
  180. package/types/document/http/http-parameter.d.ts +2 -1
  181. package/types/document/http/http-request-body.d.ts +2 -1
  182. package/types/filter/filter-rules.d.ts +3 -3
@@ -10,6 +10,7 @@ export declare namespace ApiDocumentFactory {
10
10
  references?: Record<string, ReferenceThunk>;
11
11
  types?: DataTypeInitSources;
12
12
  api?: StrictOmit<HttpApiFactory.InitArguments, 'owner'> | StrictOmit<RpcApiFactory.InitArguments, 'owner'>;
13
+ scopes?: string | string[];
13
14
  }
14
15
  type ReferenceSource = string | OpraSchema.ApiDocument | InitArguments | ApiDocument;
15
16
  type ReferenceThunk = ThunkAsync<ReferenceSource>;
@@ -23,7 +24,7 @@ export declare class ApiDocumentFactory {
23
24
  /**
24
25
  * Creates ApiDocument instance from given schema object
25
26
  */
26
- static createDocument(schemaOrUrl: string | PartialSome<OpraSchema.ApiDocument, 'spec'> | ApiDocumentFactory.InitArguments, options?: Partial<Pick<DocumentInitContext, 'maxErrors' | 'showErrorDetails'>> | DocumentInitContext): Promise<ApiDocument>;
27
+ static createDocument(schemaOrUrl: string | PartialSome<OpraSchema.ApiDocument, 'spec'> | ApiDocumentFactory.InitArguments, options?: Partial<Pick<DocumentInitContext, 'maxErrors' | 'showErrorDetails' | 'scopes'>> | DocumentInitContext): Promise<ApiDocument>;
27
28
  /**
28
29
  * Downloads schema from the given URL and creates the document instance * @param url
29
30
  */
@@ -24,5 +24,5 @@ export declare class HttpApi extends ApiBase {
24
24
  findController(resourcePath: string): HttpController | undefined;
25
25
  findOperation(controller: Type, operationName: string): HttpOperation | undefined;
26
26
  findOperation(resourcePath: string, operationName: string): HttpOperation | undefined;
27
- toJSON(): OpraSchema.HttpApi;
27
+ toJSON(options: ApiDocument.ExportOptions): OpraSchema.HttpApi;
28
28
  }
@@ -1,6 +1,7 @@
1
1
  import type { Combine, ThunkAsync, Type } from 'ts-gems';
2
2
  import { ResponsiveMap } from '../../helpers/index.js';
3
3
  import { OpraSchema } from '../../schema/index.js';
4
+ import type { ApiDocument } from '../api-document.js';
4
5
  import { DataTypeMap } from '../common/data-type-map.js';
5
6
  import { DocumentElement } from '../common/document-element.js';
6
7
  import type { EnumType } from '../data-type/enum-type.js';
@@ -84,7 +85,7 @@ declare class HttpControllerClass extends DocumentElement {
84
85
  /**
85
86
  *
86
87
  */
87
- toJSON(): OpraSchema.HttpController;
88
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpController;
88
89
  /**
89
90
  *
90
91
  */
@@ -1,6 +1,7 @@
1
1
  import type { Combine, StrictOmit, Type } from 'ts-gems';
2
2
  import { type Validator } from 'valgen';
3
3
  import { OpraSchema } from '../../schema/index.js';
4
+ import type { ApiDocument } from '../api-document.js';
4
5
  import { DocumentElement } from '../common/document-element.js';
5
6
  import { DataType } from '../data-type/data-type.js';
6
7
  import type { HttpMultipartField } from './http-multipart-field.js';
@@ -54,7 +55,7 @@ declare class HttpMediaTypeClass extends DocumentElement {
54
55
  maxFileSize?: number;
55
56
  maxTotalFileSize?: number;
56
57
  findMultipartField(fieldName: string, fieldType?: OpraSchema.HttpMultipartFieldType): HttpMultipartField | undefined;
57
- toJSON(): OpraSchema.HttpMediaType;
58
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpMediaType;
58
59
  generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions): Validator;
59
60
  }
60
61
  export {};
@@ -1,5 +1,6 @@
1
1
  import type { Combine } from 'ts-gems';
2
2
  import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document';
3
4
  import { HttpMediaType } from './http-media-type.js';
4
5
  /**
5
6
  * @namespace HttpMultipartField
@@ -21,5 +22,5 @@ export declare class HttpMultipartField extends HttpMediaType {
21
22
  fieldType: OpraSchema.HttpMultipartFieldType;
22
23
  required?: boolean;
23
24
  constructor(owner: HttpMediaType | HttpMultipartField, initArgs: HttpMultipartField.InitArguments);
24
- toJSON(): OpraSchema.HttpMultipartField;
25
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpMultipartField;
25
26
  }
@@ -1,5 +1,6 @@
1
1
  import type { Combine, StrictOmit } from 'ts-gems';
2
2
  import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document';
3
4
  import { HttpMediaType } from './http-media-type.js';
4
5
  import { HttpOperation } from './http-operation.js';
5
6
  import type { HttpParameter } from './http-parameter.js';
@@ -32,5 +33,5 @@ export declare class HttpOperationResponse extends HttpMediaType {
32
33
  partial?: boolean | 'deep';
33
34
  constructor(owner: HttpOperation, init: HttpOperationResponse.InitArguments);
34
35
  findParameter(paramName: string, location?: OpraSchema.HttpParameterLocation): HttpParameter | undefined;
35
- toJSON(): OpraSchema.HttpOperationResponse;
36
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpOperationResponse;
36
37
  }
@@ -1,5 +1,6 @@
1
1
  import type { Combine, StrictOmit, ThunkAsync, Type } from 'ts-gems';
2
2
  import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document';
3
4
  import { DataTypeMap } from '../common/data-type-map.js';
4
5
  import { DocumentElement } from '../common/document-element.js';
5
6
  import type { DataType } from '../data-type/data-type.js';
@@ -82,6 +83,6 @@ declare class HttpOperationClass extends DocumentElement {
82
83
  compositionOptions?: Record<string, any>;
83
84
  findParameter(paramName: string, location?: OpraSchema.HttpParameterLocation): HttpParameter | undefined;
84
85
  getFullUrl(): string;
85
- toJSON(): OpraSchema.HttpOperation;
86
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpOperation;
86
87
  }
87
88
  export {};
@@ -1,5 +1,6 @@
1
1
  import { type Combine, type StrictOmit, type TypeThunkAsync } from 'ts-gems';
2
2
  import type { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document';
3
4
  import { DocumentElement } from '../common/document-element.js';
4
5
  import { Value } from '../common/value.js';
5
6
  import { DataType } from '../data-type/data-type.js';
@@ -46,6 +47,6 @@ declare class HttpParameterClass extends Value {
46
47
  deprecated?: boolean | string;
47
48
  required?: boolean;
48
49
  arraySeparator?: string;
49
- toJSON(): OpraSchema.HttpParameter;
50
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpParameter;
50
51
  }
51
52
  export {};
@@ -1,5 +1,6 @@
1
1
  import type { StrictOmit } from 'ts-gems';
2
2
  import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document';
3
4
  import { DocumentElement } from '../common/document-element.js';
4
5
  import { HttpMediaType } from './http-media-type.js';
5
6
  import type { HttpOperation } from './http-operation';
@@ -30,5 +31,5 @@ export declare class HttpRequestBody extends DocumentElement {
30
31
  partial?: boolean | 'deep';
31
32
  allowPatchOperators?: boolean;
32
33
  constructor(owner: HttpOperation);
33
- toJSON(): OpraSchema.HttpRequestBody;
34
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpRequestBody;
34
35
  }
@@ -1,7 +1,7 @@
1
1
  import '../polifils/array-find-last.js';
2
2
  import type { StrictOmit } from 'ts-gems';
3
3
  import { Validator } from 'valgen';
4
- import type { ComplexType } from '../document/index.js';
4
+ import type { ComplexType, DocumentElement } from '../document/index.js';
5
5
  import { ResponsiveMap } from '../helpers/index.js';
6
6
  import { OpraSchema } from '../schema/index.js';
7
7
  import { type ComparisonOperator, Expression } from './ast/index.js';
@@ -21,8 +21,8 @@ export declare class FilterRules {
21
21
  set(fieldName: string, options?: Partial<StrictOmit<FilterRules.Rule, 'operators'>> & {
22
22
  operators?: ComparisonOperator[] | string;
23
23
  }): void;
24
- normalizeFilter(filter: OpraSchema.Field.QualifiedName | Expression, currentType?: ComplexType): Expression | undefined;
25
- protected normalizeFilterAst(ast: Expression, stack: Expression[], currentType?: ComplexType): Expression | undefined;
24
+ normalizeFilter(filter: OpraSchema.Field.QualifiedName | Expression, currentType?: ComplexType, element?: DocumentElement): Expression | undefined;
25
+ protected normalizeFilterAst(ast: Expression, stack: Expression[], currentType?: ComplexType, scopes?: string[]): Expression | undefined;
26
26
  toJSON(): Record<string, FilterRules.Rule>;
27
27
  [Symbol.iterator](): IterableIterator<[string, FilterRules.Rule]>;
28
28
  }