@opra/common 1.4.4 → 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 (120) hide show
  1. package/browser/index.cjs +5 -5
  2. package/browser/index.mjs +5 -5
  3. package/cjs/document/api-document.js +13 -8
  4. package/cjs/document/common/api-base.js +2 -1
  5. package/cjs/document/common/document-init-context.js +5 -0
  6. package/cjs/document/common/document-node.js +25 -29
  7. package/cjs/document/common/value.js +6 -2
  8. package/cjs/document/constants.js +1 -2
  9. package/cjs/document/data-type/api-field.js +16 -3
  10. package/cjs/document/data-type/complex-type-base.js +12 -3
  11. package/cjs/document/data-type/complex-type.js +12 -5
  12. package/cjs/document/data-type/data-type.js +16 -1
  13. package/cjs/document/data-type/enum-type.js +9 -2
  14. package/cjs/document/data-type/extended-types/base64.type.js +1 -0
  15. package/cjs/document/data-type/extended-types/date-string.type.js +1 -0
  16. package/cjs/document/data-type/extended-types/date-time-string.type.js +1 -0
  17. package/cjs/document/data-type/extended-types/date-time.type.js +1 -0
  18. package/cjs/document/data-type/extended-types/date.type.js +1 -0
  19. package/cjs/document/data-type/extended-types/email.type.js +1 -0
  20. package/cjs/document/data-type/extended-types/field-path.type.js +6 -2
  21. package/cjs/document/data-type/extended-types/filter.type.js +11 -4
  22. package/cjs/document/data-type/extended-types/object-id.type.js +1 -0
  23. package/cjs/document/data-type/extended-types/operation-result.type.js +1 -0
  24. package/cjs/document/data-type/extended-types/time.type.js +1 -0
  25. package/cjs/document/data-type/extended-types/url.type.js +1 -0
  26. package/cjs/document/data-type/extended-types/uuid.type.js +1 -0
  27. package/cjs/document/data-type/mapped-type.js +6 -3
  28. package/cjs/document/data-type/mixin-type.js +7 -4
  29. package/cjs/document/data-type/primitive-types/any.type.js +1 -0
  30. package/cjs/document/data-type/primitive-types/bigint.type.js +1 -0
  31. package/cjs/document/data-type/primitive-types/boolean.type.js +1 -0
  32. package/cjs/document/data-type/primitive-types/integer.type.js +1 -0
  33. package/cjs/document/data-type/primitive-types/null.type.js +1 -0
  34. package/cjs/document/data-type/primitive-types/number.type.js +1 -0
  35. package/cjs/document/data-type/primitive-types/string.type.js +1 -0
  36. package/cjs/document/data-type/simple-type.js +10 -3
  37. package/cjs/document/decorators/complex-type.decorator.js +1 -1
  38. package/cjs/document/decorators/simple-type.decorator.js +1 -1
  39. package/cjs/document/factory/api-document.factory.js +1 -0
  40. package/cjs/document/http/http-api.js +2 -2
  41. package/cjs/document/http/http-controller.js +5 -5
  42. package/cjs/document/http/http-media-type.js +3 -3
  43. package/cjs/document/http/http-multipart-field.js +2 -2
  44. package/cjs/document/http/http-operation-response.js +3 -3
  45. package/cjs/document/http/http-operation.js +5 -5
  46. package/cjs/document/http/http-parameter.js +2 -2
  47. package/cjs/document/http/http-request-body.js +4 -2
  48. package/cjs/filter/filter-rules.js +5 -4
  49. package/esm/document/api-document.js +13 -8
  50. package/esm/document/common/api-base.js +2 -1
  51. package/esm/document/common/document-init-context.js +5 -0
  52. package/esm/document/common/document-node.js +25 -29
  53. package/esm/document/common/value.js +6 -2
  54. package/esm/document/constants.js +0 -1
  55. package/esm/document/data-type/api-field.js +16 -3
  56. package/esm/document/data-type/complex-type-base.js +12 -3
  57. package/esm/document/data-type/complex-type.js +12 -5
  58. package/esm/document/data-type/data-type.js +16 -1
  59. package/esm/document/data-type/enum-type.js +9 -2
  60. package/esm/document/data-type/extended-types/base64.type.js +1 -0
  61. package/esm/document/data-type/extended-types/date-string.type.js +1 -0
  62. package/esm/document/data-type/extended-types/date-time-string.type.js +1 -0
  63. package/esm/document/data-type/extended-types/date-time.type.js +1 -0
  64. package/esm/document/data-type/extended-types/date.type.js +1 -0
  65. package/esm/document/data-type/extended-types/email.type.js +1 -0
  66. package/esm/document/data-type/extended-types/field-path.type.js +6 -2
  67. package/esm/document/data-type/extended-types/filter.type.js +11 -4
  68. package/esm/document/data-type/extended-types/object-id.type.js +1 -0
  69. package/esm/document/data-type/extended-types/operation-result.type.js +1 -0
  70. package/esm/document/data-type/extended-types/time.type.js +1 -0
  71. package/esm/document/data-type/extended-types/url.type.js +1 -0
  72. package/esm/document/data-type/extended-types/uuid.type.js +1 -0
  73. package/esm/document/data-type/mapped-type.js +6 -3
  74. package/esm/document/data-type/mixin-type.js +7 -4
  75. package/esm/document/data-type/primitive-types/any.type.js +1 -0
  76. package/esm/document/data-type/primitive-types/bigint.type.js +1 -0
  77. package/esm/document/data-type/primitive-types/boolean.type.js +1 -0
  78. package/esm/document/data-type/primitive-types/integer.type.js +1 -0
  79. package/esm/document/data-type/primitive-types/null.type.js +1 -0
  80. package/esm/document/data-type/primitive-types/number.type.js +1 -0
  81. package/esm/document/data-type/primitive-types/string.type.js +1 -0
  82. package/esm/document/data-type/simple-type.js +10 -3
  83. package/esm/document/decorators/complex-type.decorator.js +2 -2
  84. package/esm/document/decorators/simple-type.decorator.js +2 -2
  85. package/esm/document/factory/api-document.factory.js +1 -0
  86. package/esm/document/http/http-api.js +2 -2
  87. package/esm/document/http/http-controller.js +5 -5
  88. package/esm/document/http/http-media-type.js +3 -3
  89. package/esm/document/http/http-multipart-field.js +2 -2
  90. package/esm/document/http/http-operation-response.js +3 -3
  91. package/esm/document/http/http-operation.js +5 -5
  92. package/esm/document/http/http-parameter.js +2 -2
  93. package/esm/document/http/http-request-body.js +4 -2
  94. package/esm/filter/filter-rules.js +5 -4
  95. package/package.json +1 -1
  96. package/types/document/api-document.d.ts +8 -2
  97. package/types/document/common/api-base.d.ts +1 -1
  98. package/types/document/common/document-init-context.d.ts +2 -0
  99. package/types/document/common/document-node.d.ts +8 -14
  100. package/types/document/common/value.d.ts +2 -1
  101. package/types/document/constants.d.ts +0 -1
  102. package/types/document/data-type/api-field.d.ts +6 -11
  103. package/types/document/data-type/complex-type.d.ts +2 -1
  104. package/types/document/data-type/data-type.d.ts +7 -2
  105. package/types/document/data-type/enum-type.d.ts +2 -1
  106. package/types/document/data-type/extended-types/field-path.type.d.ts +2 -1
  107. package/types/document/data-type/extended-types/filter.type.d.ts +2 -1
  108. package/types/document/data-type/mapped-type.d.ts +2 -1
  109. package/types/document/data-type/mixin-type.d.ts +2 -1
  110. package/types/document/data-type/simple-type.d.ts +2 -1
  111. package/types/document/factory/api-document.factory.d.ts +2 -1
  112. package/types/document/http/http-api.d.ts +1 -1
  113. package/types/document/http/http-controller.d.ts +2 -1
  114. package/types/document/http/http-media-type.d.ts +2 -1
  115. package/types/document/http/http-multipart-field.d.ts +2 -1
  116. package/types/document/http/http-operation-response.d.ts +2 -1
  117. package/types/document/http/http-operation.d.ts +2 -1
  118. package/types/document/http/http-parameter.d.ts +2 -1
  119. package/types/document/http/http-request-body.d.ts +2 -1
  120. package/types/filter/filter-rules.d.ts +3 -3
@@ -29,11 +29,12 @@ export class FilterRules {
29
29
  operators,
30
30
  }));
31
31
  }
32
- normalizeFilter(filter, currentType) {
32
+ normalizeFilter(filter, currentType, element) {
33
33
  const ast = typeof filter === 'string' ? parse(filter) : filter;
34
- return this.normalizeFilterAst(ast, [], currentType);
34
+ const doc = element?.node.getDocument();
35
+ return this.normalizeFilterAst(ast, [], currentType, doc?.scopes);
35
36
  }
36
- normalizeFilterAst(ast, stack, currentType) {
37
+ normalizeFilterAst(ast, stack, currentType, scopes) {
37
38
  if (ast instanceof ComparisonExpression) {
38
39
  stack.push(ast);
39
40
  this.normalizeFilterAst(ast.left, stack, currentType);
@@ -125,9 +126,9 @@ export class FilterRules {
125
126
  decoder = this._decoderCache.get(comp.left.field);
126
127
  if (!decoder) {
127
128
  decoder = comp.left.field.type.generateCodec('decode', {
129
+ scope: scopes,
128
130
  projection: '*',
129
131
  ignoreWriteonlyFields: true,
130
- ignoreHiddenFields: true,
131
132
  coerce: true,
132
133
  });
133
134
  this._decoderCache.set(comp.left.field, decoder);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.4.4",
3
+ "version": "1.5.0",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -15,6 +15,7 @@ import { RpcApi } from './rpc/rpc-api.js';
15
15
  export declare class ApiDocument extends DocumentElement {
16
16
  protected [kTypeNSMap]: WeakMap<DataType, string>;
17
17
  readonly id: string;
18
+ scopes?: string[];
18
19
  url?: string;
19
20
  info: OpraSchema.DocumentInfo;
20
21
  references: ResponsiveMap<ApiDocument>;
@@ -33,7 +34,12 @@ export declare class ApiDocument extends DocumentElement {
33
34
  /**
34
35
  * Export as Opra schema definition object
35
36
  */
36
- export(): OpraSchema.ApiDocument;
37
+ export(options?: ApiDocument.ExportOptions): OpraSchema.ApiDocument;
37
38
  invalidate(): void;
38
- protected _findDataType(nameOrCtor: string | Type | Function | EnumType.EnumArray | EnumType.EnumObject, visitedRefs?: WeakMap<ApiDocument, boolean>): DataType | undefined;
39
+ protected _findDataType(nameOrCtor: string | Type | Function | EnumType.EnumArray | EnumType.EnumObject, scope?: string | string[], visitedRefs?: WeakMap<ApiDocument, boolean>): DataType | undefined;
40
+ }
41
+ export declare namespace ApiDocument {
42
+ interface ExportOptions {
43
+ scopes?: string[];
44
+ }
39
45
  }
@@ -13,6 +13,6 @@ export declare abstract class ApiBase extends DocumentElement {
13
13
  name: string;
14
14
  description?: string;
15
15
  protected constructor(init: ApiBase.InitArguments);
16
- toJSON(): OpraSchema.Api;
16
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.Api;
17
17
  protected _initialize(init: ApiBase.InitArguments, context: DocumentInitContext): Promise<void>;
18
18
  }
@@ -2,6 +2,7 @@ import { OpraDocumentError } from './opra-document-error.js';
2
2
  export declare namespace DocumentInitContext {
3
3
  interface Options {
4
4
  maxErrors?: number;
5
+ scopes?: string | string[];
5
6
  }
6
7
  }
7
8
  export declare class DocumentInitContext {
@@ -9,6 +10,7 @@ export declare class DocumentInitContext {
9
10
  error: OpraDocumentError;
10
11
  maxErrors: number;
11
12
  showErrorDetails: boolean;
13
+ scopes?: string[];
12
14
  constructor(options?: DocumentInitContext.Options);
13
15
  addError(error: Error | OpraDocumentError.ErrorDetail | string): void;
14
16
  enter(path: string, fn: () => any): any;
@@ -19,47 +19,41 @@ export declare class DocumentNode {
19
19
  readonly element: DocumentElement;
20
20
  constructor(element: DocumentElement, parent?: DocumentNode);
21
21
  getDocument(): ApiDocument;
22
- hasDataType(nameOrCtor: string | Type | Function | object | any[]): boolean;
23
- findDataType(nameOrCtor: string | Type | Function | object | any[]): DataType | undefined;
22
+ hasDataType(nameOrCtor: string | Type | Function | object | any[], scope?: string | string[]): boolean;
23
+ findDataType(nameOrCtor: string | Type | Function | object | any[], scope?: string | string[]): DataType | undefined;
24
24
  /**
25
25
  * Returns DataType instance by name or Constructor. Returns undefined if not found
26
- * @param nameOrCtor
27
26
  */
28
- getDataType(nameOrCtor: string | Type | Function | object | any[]): DataType;
27
+ getDataType(nameOrCtor: string | Type | Function | object | any[], scope?: string | string[]): DataType;
29
28
  getDataTypeNameWithNs(dataType: DataType): string | undefined;
30
29
  /**
31
30
  * Returns ComplexType instance by name or Constructor.
32
31
  * Returns undefined if not found
33
32
  * Throws error if data type is not a ComplexType
34
- * @param nameOrCtor
35
33
  */
36
- getComplexType(nameOrCtor: string | Type | Function): ComplexType;
34
+ getComplexType(nameOrCtor: string | Type | Function, scope?: string | string[]): ComplexType;
37
35
  /**
38
36
  * Returns SimpleType instance by name or Constructor.
39
37
  * Returns undefined if not found
40
38
  * Throws error if data type is not a SimpleType
41
- * @param nameOrCtor
42
39
  */
43
- getSimpleType(nameOrCtor: string | Type): SimpleType;
40
+ getSimpleType(nameOrCtor: string | Type, scope?: string | string[]): SimpleType;
44
41
  /**
45
42
  * Returns EnumType instance by name or Constructor.
46
43
  * Returns undefined if not found
47
44
  * Throws error if data type is not a EnumType
48
- * @param nameOrCtor
49
45
  */
50
- getEnumType(nameOrCtor: string | object | any[]): EnumType;
46
+ getEnumType(nameOrCtor: string | object | any[], scope?: string | string[]): EnumType;
51
47
  /**
52
48
  * Returns EnumType instance by name or Constructor.
53
49
  * Returns undefined if not found
54
50
  * Throws error if data type is not a MappedType
55
- * @param nameOrCtor
56
51
  */
57
- getMappedType(nameOrCtor: string | object | any[]): MappedType;
52
+ getMappedType(nameOrCtor: string | object | any[], scope?: string | string[]): MappedType;
58
53
  /**
59
54
  * Returns EnumType instance by name or Constructor.
60
55
  * Returns undefined if not found
61
56
  * Throws error if data type is not a MixinType
62
- * @param nameOrCtor
63
57
  */
64
- getMixinType(nameOrCtor: string | object | any[]): MixinType;
58
+ getMixinType(nameOrCtor: string | object | any[], scope?: string | string[]): MixinType;
65
59
  }
@@ -1,5 +1,6 @@
1
1
  import type { Combine, StrictOmit, TypeThunkAsync } from 'ts-gems';
2
2
  import type { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document';
3
4
  import { DataType } from '../data-type/data-type.js';
4
5
  import type { EnumType } from '../data-type/enum-type.js';
5
6
  import { DocumentElement } from './document-element.js';
@@ -43,6 +44,6 @@ declare class ValueClass extends DocumentElement {
43
44
  description?: string;
44
45
  examples?: any[] | Record<string, any>;
45
46
  isArray?: boolean;
46
- toJSON(): OpraSchema.Value;
47
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.Value;
47
48
  }
48
49
  export {};
@@ -7,7 +7,6 @@ export declare const DECORATOR: unique symbol;
7
7
  export declare const BUILTIN: unique symbol;
8
8
  export declare const NAMESPACE_PATTERN: RegExp;
9
9
  export declare const CLASS_NAME_PATTERN: RegExp;
10
- export declare const EXTRACT_TYPENAME_PATTERN: RegExp;
11
10
  export declare const kDataTypeMap: unique symbol;
12
11
  export declare const kCtorMap: unique symbol;
13
12
  export declare const kTypeNSMap: unique symbol;
@@ -1,5 +1,6 @@
1
1
  import type { Combine, TypeThunkAsync } from 'ts-gems';
2
2
  import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document.js';
3
4
  import { DocumentElement } from '../common/document-element.js';
4
5
  import { ApiFieldDecorator } from '../decorators/api-field-decorator.js';
5
6
  import type { ComplexType } from './complex-type.js';
@@ -14,19 +15,16 @@ export declare namespace ApiField {
14
15
  interface Metadata extends Combine<{
15
16
  type?: string | OpraSchema.DataType | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
16
17
  }, OpraSchema.Field> {
17
- /**
18
- * If set true, field will be available for server side only and
19
- * will be removed while encoding to send to the client
20
- */
21
- hidden?: boolean;
22
18
  }
23
19
  interface Options extends Partial<Metadata> {
20
+ scopes?: (string | RegExp)[];
24
21
  }
25
22
  interface InitArguments extends Combine<{
26
23
  name: string;
27
24
  origin?: ComplexType | MappedType | MixinType;
28
25
  type?: DataType;
29
26
  }, Metadata> {
27
+ scopes?: (string | RegExp)[];
30
28
  }
31
29
  }
32
30
  /**
@@ -54,6 +52,7 @@ export declare const ApiField: ApiFieldConstructor;
54
52
  declare class ApiFieldClass extends DocumentElement {
55
53
  readonly owner: ComplexType | MappedType | MixinType;
56
54
  readonly origin?: ComplexType | MappedType | MixinType;
55
+ readonly scopes?: (string | RegExp)[];
57
56
  readonly name: string;
58
57
  readonly type: DataType;
59
58
  readonly description?: string;
@@ -68,11 +67,7 @@ declare class ApiFieldClass extends DocumentElement {
68
67
  readonly readonly?: boolean;
69
68
  readonly writeonly?: boolean;
70
69
  readonly examples?: any[] | Record<string, any>;
71
- /**
72
- * If set true, field will be available for server side only and
73
- * will be removed while encoding to send to the client
74
- */
75
- readonly hidden?: boolean;
76
- toJSON(): OpraSchema.Field;
70
+ inScope(scopes?: string | string[]): boolean;
71
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.Field;
77
72
  }
78
73
  export {};
@@ -1,6 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
  import type { Combine, Type, TypeThunkAsync } from 'ts-gems';
3
3
  import { OpraSchema } from '../../schema/index.js';
4
+ import type { ApiDocument } from '../api-document.js';
4
5
  import type { DocumentElement } from '../common/document-element.js';
5
6
  import { DocumentInitContext } from '../common/document-init-context.js';
6
7
  import { ApiField } from './api-field.js';
@@ -72,6 +73,6 @@ declare abstract class ComplexTypeClass extends ComplexTypeBase {
72
73
  readonly base?: ComplexType | MappedType | MixinType;
73
74
  readonly ctor?: Type;
74
75
  extendsFrom(baseType: DataType | string | Type | object): boolean;
75
- toJSON(): OpraSchema.ComplexType;
76
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.ComplexType;
76
77
  }
77
78
  export {};
@@ -3,6 +3,7 @@ import type { ValidationOptions, Validator } from 'valgen';
3
3
  import { FieldsProjection } from '../../helpers/index.js';
4
4
  import type { DataTypeBase } from '../../schema/data-type/data-type.interface.js';
5
5
  import { OpraSchema } from '../../schema/index.js';
6
+ import type { ApiDocument } from '../api-document.js';
6
7
  import { DocumentElement } from '../common/document-element.js';
7
8
  import { DocumentInitContext } from '../common/document-init-context.js';
8
9
  import { nodeInspectCustom } from '../utils/inspect.util.js';
@@ -15,17 +16,19 @@ export declare namespace DataType {
15
16
  }
16
17
  interface Options extends Partial<StrictOmit<Metadata, 'kind' | 'examples'>> {
17
18
  embedded?: boolean;
19
+ scopes?: (string | RegExp)[];
18
20
  }
19
21
  interface InitArguments extends DataType.Metadata {
22
+ scopes?: (string | RegExp)[];
20
23
  }
21
24
  interface GenerateCodecOptions extends ValidationOptions {
22
25
  documentElement?: DocumentElement;
26
+ scope?: string | string[];
23
27
  caseInSensitive?: boolean;
24
28
  partial?: boolean | 'deep';
25
29
  projection?: string[] | FieldsProjection | '*';
26
30
  ignoreReadonlyFields?: boolean;
27
31
  ignoreWriteonlyFields?: boolean;
28
- ignoreHiddenFields?: boolean;
29
32
  allowPatchOperators?: boolean;
30
33
  }
31
34
  }
@@ -50,6 +53,7 @@ export declare const DataType: DataTypeStatic;
50
53
  declare abstract class DataTypeClass extends DocumentElement {
51
54
  readonly kind: OpraSchema.DataType.Kind;
52
55
  readonly owner: DocumentElement;
56
+ readonly scopes?: (string | RegExp)[];
53
57
  readonly name?: string;
54
58
  readonly description?: string;
55
59
  readonly abstract?: boolean;
@@ -57,7 +61,8 @@ declare abstract class DataTypeClass extends DocumentElement {
57
61
  abstract generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions): Validator;
58
62
  get embedded(): any;
59
63
  abstract extendsFrom(baseType: DataType | string | Type | object): boolean;
60
- toJSON(): OpraSchema.DataType;
64
+ inScope(scopes?: string | string[]): boolean;
65
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.DataType;
61
66
  toString(): string;
62
67
  [nodeInspectCustom](): string;
63
68
  }
@@ -2,6 +2,7 @@ import 'reflect-metadata';
2
2
  import { type Combine, type Type } from 'ts-gems';
3
3
  import { type Validator } from 'valgen';
4
4
  import { OpraSchema } from '../../schema/index.js';
5
+ import type { ApiDocument } from '../api-document.js';
5
6
  import type { DocumentElement } from '../common/document-element.js';
6
7
  import { DataType } from './data-type.js';
7
8
  /**
@@ -65,6 +66,6 @@ declare class EnumTypeClass extends DataType {
65
66
  readonly ownAttributes: Record<string | number, OpraSchema.EnumType.ValueInfo>;
66
67
  extendsFrom(baseType: DataType | string | Type | object): boolean;
67
68
  generateCodec(): Validator;
68
- toJSON(): OpraSchema.EnumType;
69
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.EnumType;
69
70
  }
70
71
  export {};
@@ -1,5 +1,6 @@
1
1
  import type { Type } from 'ts-gems';
2
2
  import { type Validator } from 'valgen';
3
+ import type { ApiDocument } from '../../api-document.js';
3
4
  import { DocumentElement } from '../../common/document-element.js';
4
5
  import { DECODER, ENCODER } from '../../constants.js';
5
6
  export declare class FieldPathType {
@@ -8,7 +9,7 @@ export declare class FieldPathType {
8
9
  allowSigns?: 'first' | 'each';
9
10
  [DECODER](properties: Partial<this>, element: DocumentElement): Validator;
10
11
  [ENCODER](properties: Partial<this>, element: DocumentElement): Validator;
11
- toJSON(properties: Partial<FieldPathType>, element: DocumentElement): {
12
+ toJSON(properties: Partial<FieldPathType>, element: DocumentElement, options?: ApiDocument.ExportOptions): {
12
13
  dataType: string | import("../../../schema/opra-schema.js").ComplexType;
13
14
  allowSigns: "first" | "each" | undefined;
14
15
  };
@@ -1,6 +1,7 @@
1
1
  import type { Type } from 'ts-gems';
2
2
  import { type Validator } from 'valgen';
3
3
  import { FilterRules } from '../../../filter/filter-rules.js';
4
+ import type { ApiDocument } from '../../api-document.js';
4
5
  import type { DocumentElement } from '../../common/document-element.js';
5
6
  import { DECODER, ENCODER } from '../../constants.js';
6
7
  export declare class FilterType {
@@ -9,7 +10,7 @@ export declare class FilterType {
9
10
  rules?: Record<string, FilterRules.Rule>;
10
11
  protected [DECODER](properties: Partial<this>, element: DocumentElement): Validator;
11
12
  protected [ENCODER](): Validator;
12
- toJSON(properties: Partial<FilterType>, element: DocumentElement): {
13
+ toJSON(properties: Partial<FilterType>, element: DocumentElement, options?: ApiDocument.ExportOptions): {
13
14
  dataType: string | import("../../../schema/opra-schema.js").ComplexType;
14
15
  rules: Record<string, FilterRules.Rule> | undefined;
15
16
  };
@@ -2,6 +2,7 @@ import 'reflect-metadata';
2
2
  import { type Combine, type Type } from 'ts-gems';
3
3
  import type { Field } from '../../schema/data-type/field.interface.js';
4
4
  import { OpraSchema } from '../../schema/index.js';
5
+ import type { ApiDocument } from '../api-document.js';
5
6
  import { DocumentElement } from '../common/document-element.js';
6
7
  import type { ComplexType } from './complex-type.js';
7
8
  import { ComplexTypeBase } from './complex-type-base.js';
@@ -68,6 +69,6 @@ declare class MappedTypeClass extends ComplexTypeBase {
68
69
  readonly partial?: Field.Name[] | boolean;
69
70
  readonly required?: Field.Name[] | boolean;
70
71
  extendsFrom(baseType: DataType | string | Type | object): boolean;
71
- toJSON(): OpraSchema.MappedType;
72
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.MappedType;
72
73
  }
73
74
  export {};
@@ -1,6 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
  import type { Class, Combine, Type } from 'ts-gems';
3
3
  import { OpraSchema } from '../../schema/index.js';
4
+ import type { ApiDocument } from '../api-document.js';
4
5
  import type { DocumentElement } from '../common/document-element.js';
5
6
  import type { ComplexType } from './complex-type.js';
6
7
  import { ComplexTypeBase } from './complex-type-base.js';
@@ -77,6 +78,6 @@ declare class MixinTypeClass extends ComplexTypeBase {
77
78
  readonly kind: OpraSchema.MixinType.Kind;
78
79
  readonly types: (ComplexType | MixinType | MappedType)[];
79
80
  extendsFrom(baseType: DataType | string | Type | object): boolean;
80
- toJSON(): OpraSchema.MixinType;
81
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.MixinType;
81
82
  }
82
83
  export {};
@@ -2,6 +2,7 @@ import 'reflect-metadata';
2
2
  import type { Combine, Type } from 'ts-gems';
3
3
  import { type Validator } from 'valgen';
4
4
  import { OpraSchema } from '../../schema/index.js';
5
+ import type { ApiDocument } from '../api-document.js';
5
6
  import type { DocumentElement } from '../common/document-element';
6
7
  import { DocumentInitContext } from '../common/document-init-context.js';
7
8
  import { AttributeDecoratorFactory, SimpleTypeDecoratorFactory } from '../decorators/simple-type.decorator.js';
@@ -72,6 +73,6 @@ declare abstract class SimpleTypeClass extends DataType {
72
73
  properties?: any;
73
74
  extendsFrom(baseType: DataType | string | Type | object): boolean;
74
75
  generateCodec<T extends Record<string, any> | object = object>(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions | null, properties?: Partial<T>): Validator;
75
- toJSON(): OpraSchema.SimpleType;
76
+ toJSON(options?: ApiDocument.ExportOptions): OpraSchema.SimpleType;
76
77
  }
77
78
  export {};
@@ -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
  }