@opra/common 1.5.0 → 1.5.2
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.
- package/browser/index.cjs +5 -5
- package/browser/index.mjs +5 -5
- package/cjs/document/api-document.js +2 -3
- package/cjs/document/common/document-init-context.js +0 -5
- package/cjs/document/common/document-node.js +2 -3
- package/cjs/document/data-type/api-field.js +9 -18
- package/cjs/document/data-type/complex-type-base.js +16 -14
- package/cjs/document/data-type/complex-type.js +14 -7
- package/cjs/document/data-type/data-type.js +12 -14
- package/cjs/document/data-type/enum-type.js +12 -9
- package/cjs/document/data-type/extended-types/field-path.type.js +7 -7
- package/cjs/document/data-type/extended-types/filter.type.js +5 -5
- package/cjs/document/data-type/mapped-type.js +10 -4
- package/cjs/document/data-type/mixin-type.js +13 -4
- package/cjs/document/data-type/simple-type.js +11 -16
- package/cjs/document/decorators/api-field-decorator.js +37 -3
- package/cjs/document/decorators/simple-type.decorator.js +2 -0
- package/cjs/document/factory/api-document.factory.js +0 -1
- package/cjs/document/utils/test-scope-match.js +13 -0
- package/cjs/filter/filter-rules.js +6 -7
- package/esm/document/api-document.js +2 -3
- package/esm/document/common/document-init-context.js +0 -5
- package/esm/document/common/document-node.js +2 -3
- package/esm/document/data-type/api-field.js +10 -19
- package/esm/document/data-type/complex-type-base.js +16 -14
- package/esm/document/data-type/complex-type.js +14 -7
- package/esm/document/data-type/data-type.js +12 -14
- package/esm/document/data-type/enum-type.js +12 -9
- package/esm/document/data-type/extended-types/field-path.type.js +7 -7
- package/esm/document/data-type/extended-types/filter.type.js +5 -5
- package/esm/document/data-type/mapped-type.js +10 -4
- package/esm/document/data-type/mixin-type.js +13 -4
- package/esm/document/data-type/simple-type.js +11 -16
- package/esm/document/decorators/api-field-decorator.js +36 -2
- package/esm/document/decorators/simple-type.decorator.js +2 -0
- package/esm/document/factory/api-document.factory.js +0 -1
- package/esm/document/utils/test-scope-match.js +10 -0
- package/esm/filter/filter-rules.js +6 -7
- package/package.json +1 -1
- package/types/document/api-document.d.ts +2 -3
- package/types/document/common/document-init-context.d.ts +0 -1
- package/types/document/common/document-node.d.ts +8 -8
- package/types/document/data-type/api-field.d.ts +40 -27
- package/types/document/data-type/complex-type-base.d.ts +4 -2
- package/types/document/data-type/complex-type.d.ts +1 -0
- package/types/document/data-type/data-type.d.ts +6 -5
- package/types/document/data-type/enum-type.d.ts +1 -0
- package/types/document/data-type/extended-types/field-path.type.d.ts +2 -2
- package/types/document/data-type/mapped-type.d.ts +1 -0
- package/types/document/data-type/mixin-type.d.ts +1 -0
- package/types/document/data-type/simple-type.d.ts +1 -1
- package/types/document/decorators/api-field-decorator.d.ts +5 -3
- package/types/document/decorators/simple-type.decorator.d.ts +34 -0
- package/types/document/factory/api-document.factory.d.ts +1 -2
- package/types/document/http/http-api.d.ts +1 -1
- package/types/document/utils/test-scope-match.d.ts +1 -0
- package/types/filter/filter-rules.d.ts +3 -3
|
@@ -15,7 +15,6 @@ 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[];
|
|
19
18
|
url?: string;
|
|
20
19
|
info: OpraSchema.DocumentInfo;
|
|
21
20
|
references: ResponsiveMap<ApiDocument>;
|
|
@@ -36,10 +35,10 @@ export declare class ApiDocument extends DocumentElement {
|
|
|
36
35
|
*/
|
|
37
36
|
export(options?: ApiDocument.ExportOptions): OpraSchema.ApiDocument;
|
|
38
37
|
invalidate(): void;
|
|
39
|
-
protected _findDataType(nameOrCtor: string | Type | Function | EnumType.EnumArray | EnumType.EnumObject, scope?: string
|
|
38
|
+
protected _findDataType(nameOrCtor: string | Type | Function | EnumType.EnumArray | EnumType.EnumObject, scope?: string, visitedRefs?: WeakMap<ApiDocument, boolean>): DataType | undefined;
|
|
40
39
|
}
|
|
41
40
|
export declare namespace ApiDocument {
|
|
42
41
|
interface ExportOptions {
|
|
43
|
-
|
|
42
|
+
scope?: string;
|
|
44
43
|
}
|
|
45
44
|
}
|
|
@@ -10,7 +10,6 @@ export declare class DocumentInitContext {
|
|
|
10
10
|
error: OpraDocumentError;
|
|
11
11
|
maxErrors: number;
|
|
12
12
|
showErrorDetails: boolean;
|
|
13
|
-
scopes?: string[];
|
|
14
13
|
constructor(options?: DocumentInitContext.Options);
|
|
15
14
|
addError(error: Error | OpraDocumentError.ErrorDetail | string): void;
|
|
16
15
|
enter(path: string, fn: () => any): any;
|
|
@@ -19,41 +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[], scope?: string
|
|
23
|
-
findDataType(nameOrCtor: string | Type | Function | object | any[], scope?: string
|
|
22
|
+
hasDataType(nameOrCtor: string | Type | Function | object | any[], scope?: string): boolean;
|
|
23
|
+
findDataType(nameOrCtor: string | Type | Function | object | any[], scope?: string): DataType | undefined;
|
|
24
24
|
/**
|
|
25
25
|
* Returns DataType instance by name or Constructor. Returns undefined if not found
|
|
26
26
|
*/
|
|
27
|
-
getDataType(nameOrCtor: string | Type | Function | object | any[], scope?: string
|
|
27
|
+
getDataType(nameOrCtor: string | Type | Function | object | any[], scope?: string): DataType;
|
|
28
28
|
getDataTypeNameWithNs(dataType: DataType): string | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Returns ComplexType instance by name or Constructor.
|
|
31
31
|
* Returns undefined if not found
|
|
32
32
|
* Throws error if data type is not a ComplexType
|
|
33
33
|
*/
|
|
34
|
-
getComplexType(nameOrCtor: string | Type | Function, scope?: string
|
|
34
|
+
getComplexType(nameOrCtor: string | Type | Function, scope?: string): ComplexType;
|
|
35
35
|
/**
|
|
36
36
|
* Returns SimpleType instance by name or Constructor.
|
|
37
37
|
* Returns undefined if not found
|
|
38
38
|
* Throws error if data type is not a SimpleType
|
|
39
39
|
*/
|
|
40
|
-
getSimpleType(nameOrCtor: string | Type, scope?: string
|
|
40
|
+
getSimpleType(nameOrCtor: string | Type, scope?: string): SimpleType;
|
|
41
41
|
/**
|
|
42
42
|
* Returns EnumType instance by name or Constructor.
|
|
43
43
|
* Returns undefined if not found
|
|
44
44
|
* Throws error if data type is not a EnumType
|
|
45
45
|
*/
|
|
46
|
-
getEnumType(nameOrCtor: string | object | any[], scope?: string
|
|
46
|
+
getEnumType(nameOrCtor: string | object | any[], scope?: string): EnumType;
|
|
47
47
|
/**
|
|
48
48
|
* Returns EnumType instance by name or Constructor.
|
|
49
49
|
* Returns undefined if not found
|
|
50
50
|
* Throws error if data type is not a MappedType
|
|
51
51
|
*/
|
|
52
|
-
getMappedType(nameOrCtor: string | object | any[], scope?: string
|
|
52
|
+
getMappedType(nameOrCtor: string | object | any[], scope?: string): MappedType;
|
|
53
53
|
/**
|
|
54
54
|
* Returns EnumType instance by name or Constructor.
|
|
55
55
|
* Returns undefined if not found
|
|
56
56
|
* Throws error if data type is not a MixinType
|
|
57
57
|
*/
|
|
58
|
-
getMixinType(nameOrCtor: string | object | any[], scope?: string
|
|
58
|
+
getMixinType(nameOrCtor: string | object | any[], scope?: string): MixinType;
|
|
59
59
|
}
|
|
@@ -1,58 +1,43 @@
|
|
|
1
|
-
import type { Combine, TypeThunkAsync } from 'ts-gems';
|
|
1
|
+
import type { Combine, StrictOmit, TypeThunkAsync } from 'ts-gems';
|
|
2
2
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
3
|
import type { ApiDocument } from '../api-document.js';
|
|
4
4
|
import { DocumentElement } from '../common/document-element.js';
|
|
5
|
-
import {
|
|
5
|
+
import { ApiFieldDecoratorFactory } from '../decorators/api-field-decorator.js';
|
|
6
6
|
import type { ComplexType } from './complex-type.js';
|
|
7
7
|
import type { DataType } from './data-type.js';
|
|
8
8
|
import type { EnumType } from './enum-type.js';
|
|
9
9
|
import type { MappedType } from './mapped-type.js';
|
|
10
10
|
import type { MixinType } from './mixin-type.js';
|
|
11
|
-
/**
|
|
12
|
-
* @namespace ApiField
|
|
13
|
-
*/
|
|
14
|
-
export declare namespace ApiField {
|
|
15
|
-
interface Metadata extends Combine<{
|
|
16
|
-
type?: string | OpraSchema.DataType | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
|
|
17
|
-
}, OpraSchema.Field> {
|
|
18
|
-
}
|
|
19
|
-
interface Options extends Partial<Metadata> {
|
|
20
|
-
scopes?: (string | RegExp)[];
|
|
21
|
-
}
|
|
22
|
-
interface InitArguments extends Combine<{
|
|
23
|
-
name: string;
|
|
24
|
-
origin?: ComplexType | MappedType | MixinType;
|
|
25
|
-
type?: DataType;
|
|
26
|
-
}, Metadata> {
|
|
27
|
-
scopes?: (string | RegExp)[];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
11
|
/**
|
|
31
12
|
* Type definition of ComplexType constructor type
|
|
32
13
|
* @type ApiFieldConstructor
|
|
33
14
|
*/
|
|
34
|
-
export interface ApiFieldConstructor extends
|
|
15
|
+
export interface ApiFieldConstructor extends ApiFieldDecoratorFactory {
|
|
35
16
|
prototype: ApiField;
|
|
36
17
|
new (owner: ComplexType | MappedType | MixinType, args: ApiField.InitArguments): ApiField;
|
|
37
18
|
}
|
|
38
19
|
/**
|
|
20
|
+
* The ApiField represents a descriptive metadata structure for API fields,
|
|
21
|
+
* supporting features like data type definition, scoping, localization, and constraints.
|
|
22
|
+
* This class extends DocumentElement, inheriting base document structure capabilities.
|
|
23
|
+
*
|
|
39
24
|
* @class ApiField
|
|
40
25
|
*/
|
|
41
26
|
export interface ApiField extends ApiFieldClass {
|
|
42
27
|
}
|
|
43
28
|
/**
|
|
44
|
-
* @constructor ApiField
|
|
45
29
|
* @decorator ApiField
|
|
46
30
|
*/
|
|
47
31
|
export declare const ApiField: ApiFieldConstructor;
|
|
48
32
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
33
|
+
* The ApiFieldClass represents a descriptive metadata structure for API fields,
|
|
34
|
+
* supporting features like data type definition, scoping, localization, and constraints.
|
|
35
|
+
* This class extends DocumentElement, inheriting base document structure capabilities.
|
|
51
36
|
*/
|
|
52
37
|
declare class ApiFieldClass extends DocumentElement {
|
|
53
38
|
readonly owner: ComplexType | MappedType | MixinType;
|
|
54
39
|
readonly origin?: ComplexType | MappedType | MixinType;
|
|
55
|
-
readonly
|
|
40
|
+
readonly scopePattern?: (string | RegExp)[];
|
|
56
41
|
readonly name: string;
|
|
57
42
|
readonly type: DataType;
|
|
58
43
|
readonly description?: string;
|
|
@@ -67,7 +52,35 @@ declare class ApiFieldClass extends DocumentElement {
|
|
|
67
52
|
readonly readonly?: boolean;
|
|
68
53
|
readonly writeonly?: boolean;
|
|
69
54
|
readonly examples?: any[] | Record<string, any>;
|
|
70
|
-
inScope(
|
|
55
|
+
inScope(scope: string): boolean;
|
|
71
56
|
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.Field;
|
|
72
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* @namespace ApiField
|
|
60
|
+
*/
|
|
61
|
+
export declare namespace ApiField {
|
|
62
|
+
interface Metadata extends Combine<{
|
|
63
|
+
type?: string | OpraSchema.DataType | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
|
|
64
|
+
}, OpraSchema.Field> {
|
|
65
|
+
scopePattern?: (string | RegExp)[];
|
|
66
|
+
overrides?: StrictOmit<Metadata, 'overrides' | 'type' | 'isArray'>[];
|
|
67
|
+
}
|
|
68
|
+
interface Options extends Partial<StrictOmit<Metadata, 'overrides' | 'scopePattern'>> {
|
|
69
|
+
/**
|
|
70
|
+
* A variable that defines the pattern or patterns used to determine scope.
|
|
71
|
+
* This can either be a single string or regular expression, or an array containing multiple strings or regular expressions.
|
|
72
|
+
*
|
|
73
|
+
* - If a single string or RegExp is provided, it is directly used as the scope pattern.
|
|
74
|
+
* - If an array is provided, each element within the array is used as a valid scope pattern.
|
|
75
|
+
*/
|
|
76
|
+
scopePattern?: (string | RegExp) | (string | RegExp)[];
|
|
77
|
+
}
|
|
78
|
+
interface InitArguments extends Combine<{
|
|
79
|
+
name: string;
|
|
80
|
+
origin?: ComplexType | MappedType | MixinType;
|
|
81
|
+
type?: DataType;
|
|
82
|
+
}, Metadata> {
|
|
83
|
+
scopePattern?: (string | RegExp)[];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
73
86
|
export {};
|
|
@@ -46,22 +46,24 @@ declare abstract class ComplexTypeBaseClass extends DataType {
|
|
|
46
46
|
/**
|
|
47
47
|
*
|
|
48
48
|
*/
|
|
49
|
-
findField(nameOrPath: string): ApiField | undefined;
|
|
49
|
+
findField(nameOrPath: string, scope?: string): ApiField | undefined;
|
|
50
50
|
/**
|
|
51
51
|
*
|
|
52
52
|
*/
|
|
53
|
-
getField(nameOrPath: string): ApiField;
|
|
53
|
+
getField(nameOrPath: string, scope?: string): ApiField;
|
|
54
54
|
/**
|
|
55
55
|
*
|
|
56
56
|
*/
|
|
57
57
|
parseFieldPath(fieldPath: string, options?: {
|
|
58
58
|
allowSigns?: 'first' | 'each';
|
|
59
|
+
scope?: string;
|
|
59
60
|
}): ComplexType.ParsedFieldPath[];
|
|
60
61
|
/**
|
|
61
62
|
*
|
|
62
63
|
*/
|
|
63
64
|
normalizeFieldPath(fieldPath: string, options?: {
|
|
64
65
|
allowSigns?: 'first' | 'each';
|
|
66
|
+
scope?: string;
|
|
65
67
|
}): string;
|
|
66
68
|
/**
|
|
67
69
|
*
|
|
@@ -74,5 +74,6 @@ declare abstract class ComplexTypeClass extends ComplexTypeBase {
|
|
|
74
74
|
readonly ctor?: Type;
|
|
75
75
|
extendsFrom(baseType: DataType | string | Type | object): boolean;
|
|
76
76
|
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.ComplexType;
|
|
77
|
+
protected _locateBase(callback: (base: ComplexTypeBase) => boolean): ComplexTypeBase | undefined;
|
|
77
78
|
}
|
|
78
79
|
export {};
|
|
@@ -16,14 +16,14 @@ export declare namespace DataType {
|
|
|
16
16
|
}
|
|
17
17
|
interface Options extends Partial<StrictOmit<Metadata, 'kind' | 'examples'>> {
|
|
18
18
|
embedded?: boolean;
|
|
19
|
-
|
|
19
|
+
scopePattern?: (string | RegExp) | (string | RegExp)[];
|
|
20
20
|
}
|
|
21
21
|
interface InitArguments extends DataType.Metadata {
|
|
22
|
-
|
|
22
|
+
scopePattern?: (string | RegExp)[];
|
|
23
23
|
}
|
|
24
24
|
interface GenerateCodecOptions extends ValidationOptions {
|
|
25
25
|
documentElement?: DocumentElement;
|
|
26
|
-
scope?: string
|
|
26
|
+
scope?: string;
|
|
27
27
|
caseInSensitive?: boolean;
|
|
28
28
|
partial?: boolean | 'deep';
|
|
29
29
|
projection?: string[] | FieldsProjection | '*';
|
|
@@ -53,7 +53,7 @@ export declare const DataType: DataTypeStatic;
|
|
|
53
53
|
declare abstract class DataTypeClass extends DocumentElement {
|
|
54
54
|
readonly kind: OpraSchema.DataType.Kind;
|
|
55
55
|
readonly owner: DocumentElement;
|
|
56
|
-
readonly
|
|
56
|
+
readonly scopePattern?: (string | RegExp)[];
|
|
57
57
|
readonly name?: string;
|
|
58
58
|
readonly description?: string;
|
|
59
59
|
readonly abstract?: boolean;
|
|
@@ -61,9 +61,10 @@ declare abstract class DataTypeClass extends DocumentElement {
|
|
|
61
61
|
abstract generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions): Validator;
|
|
62
62
|
get embedded(): any;
|
|
63
63
|
abstract extendsFrom(baseType: DataType | string | Type | object): boolean;
|
|
64
|
-
inScope(
|
|
64
|
+
inScope(scope: string): boolean;
|
|
65
65
|
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.DataType;
|
|
66
66
|
toString(): string;
|
|
67
|
+
protected abstract _locateBase(callback: (base: DataType) => boolean): DataType | undefined;
|
|
67
68
|
[nodeInspectCustom](): string;
|
|
68
69
|
}
|
|
69
70
|
export {};
|
|
@@ -67,5 +67,6 @@ declare class EnumTypeClass extends DataType {
|
|
|
67
67
|
extendsFrom(baseType: DataType | string | Type | object): boolean;
|
|
68
68
|
generateCodec(): Validator;
|
|
69
69
|
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.EnumType;
|
|
70
|
+
protected _locateBase(callback: (base: EnumType) => boolean): EnumType | undefined;
|
|
70
71
|
}
|
|
71
72
|
export {};
|
|
@@ -7,8 +7,8 @@ export declare class FieldPathType {
|
|
|
7
7
|
constructor(attributes?: Partial<FieldPathType>);
|
|
8
8
|
dataType?: Type | string;
|
|
9
9
|
allowSigns?: 'first' | 'each';
|
|
10
|
-
[DECODER](properties: Partial<this>, element: DocumentElement): Validator;
|
|
11
|
-
[ENCODER](properties: Partial<this>, element: DocumentElement): Validator;
|
|
10
|
+
[DECODER](properties: Partial<this>, element: DocumentElement, scope?: string): Validator;
|
|
11
|
+
[ENCODER](properties: Partial<this>, element: DocumentElement, scope?: string): Validator;
|
|
12
12
|
toJSON(properties: Partial<FieldPathType>, element: DocumentElement, options?: ApiDocument.ExportOptions): {
|
|
13
13
|
dataType: string | import("../../../schema/opra-schema.js").ComplexType;
|
|
14
14
|
allowSigns: "first" | "each" | undefined;
|
|
@@ -70,5 +70,6 @@ declare class MappedTypeClass extends ComplexTypeBase {
|
|
|
70
70
|
readonly required?: Field.Name[] | boolean;
|
|
71
71
|
extendsFrom(baseType: DataType | string | Type | object): boolean;
|
|
72
72
|
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.MappedType;
|
|
73
|
+
protected _locateBase(callback: (base: ComplexTypeBase) => boolean): ComplexTypeBase | undefined;
|
|
73
74
|
}
|
|
74
75
|
export {};
|
|
@@ -79,5 +79,6 @@ declare class MixinTypeClass extends ComplexTypeBase {
|
|
|
79
79
|
readonly types: (ComplexType | MixinType | MappedType)[];
|
|
80
80
|
extendsFrom(baseType: DataType | string | Type | object): boolean;
|
|
81
81
|
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.MixinType;
|
|
82
|
+
protected _locateBase(callback: (base: ComplexTypeBase) => boolean): ComplexTypeBase | undefined;
|
|
82
83
|
}
|
|
83
84
|
export {};
|
|
@@ -28,7 +28,7 @@ export declare namespace SimpleType {
|
|
|
28
28
|
}
|
|
29
29
|
interface Attribute extends OpraSchema.Attribute {
|
|
30
30
|
}
|
|
31
|
-
type ValidatorGenerator = (properties: Record<string, any>, element: DocumentElement) => Validator;
|
|
31
|
+
type ValidatorGenerator = (properties: Record<string, any>, element: DocumentElement, scope?: string) => Validator;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Type definition for MixinType
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ApiField } from '../data-type/api-field.js';
|
|
2
|
-
export interface ApiFieldDecorator {
|
|
3
|
-
(options?: ApiField.Options): PropertyDecorator;
|
|
2
|
+
export interface ApiFieldDecorator extends PropertyDecorator {
|
|
4
3
|
}
|
|
5
|
-
export
|
|
4
|
+
export interface ApiFieldDecoratorFactory {
|
|
5
|
+
(options?: ApiField.Options): ApiFieldDecorator;
|
|
6
|
+
}
|
|
7
|
+
export declare function ApiFieldDecoratorFactory(options?: ApiField.Options): ApiFieldDecorator;
|
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
import { OpraSchema } from '../../schema/index.js';
|
|
2
2
|
import type { SimpleType } from '../data-type/simple-type';
|
|
3
3
|
export interface SimpleTypeDecorator extends ClassDecorator {
|
|
4
|
+
/**
|
|
5
|
+
* This function is used to attach one or more usage examples to a `SimpleType` model.
|
|
6
|
+
* These examples serve as additional descriptive metadata, often useful for documentation
|
|
7
|
+
* or validation purposes. They can help define how a specific value should be used,
|
|
8
|
+
* making it easier to understand or test the defined `SimpleType` model.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The usage example to associate with the `SimpleType` model.
|
|
11
|
+
* It can be of any type and is intended to represent a realistic
|
|
12
|
+
* value that fits the model's constraints.
|
|
13
|
+
* For instance, if the `SimpleType` model represents a string with
|
|
14
|
+
* specific formatting, this parameter provides an example of a compliant string.
|
|
15
|
+
*
|
|
16
|
+
* @param description (optional) - A brief description explaining the purpose or
|
|
17
|
+
* context of the example provided in the `value` parameter.
|
|
18
|
+
* This description can provide additional context or
|
|
19
|
+
* clarify why the example is relevant.
|
|
20
|
+
* For instance, for a `SimpleType` representing email strings,
|
|
21
|
+
* the description could be: "An example of a valid email address".
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* class MyModel {
|
|
26
|
+
* @Example("example@example.com", "A valid email address example")
|
|
27
|
+
* email!: string;
|
|
28
|
+
*
|
|
29
|
+
* @Example(42, "An example of an integer age value")
|
|
30
|
+
* age!: number;
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* In the above example:
|
|
35
|
+
* - The `email` property is associated with a usage example of "example@example.com".
|
|
36
|
+
* - The `age` property includes an example of 42.
|
|
37
|
+
*/
|
|
4
38
|
Example(value: any, description?: string): SimpleTypeDecorator;
|
|
5
39
|
}
|
|
6
40
|
export interface SimpleTypeDecoratorFactory {
|
|
@@ -10,7 +10,6 @@ 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[];
|
|
14
13
|
}
|
|
15
14
|
type ReferenceSource = string | OpraSchema.ApiDocument | InitArguments | ApiDocument;
|
|
16
15
|
type ReferenceThunk = ThunkAsync<ReferenceSource>;
|
|
@@ -24,7 +23,7 @@ export declare class ApiDocumentFactory {
|
|
|
24
23
|
/**
|
|
25
24
|
* Creates ApiDocument instance from given schema object
|
|
26
25
|
*/
|
|
27
|
-
static createDocument(schemaOrUrl: string | PartialSome<OpraSchema.ApiDocument, 'spec'> | ApiDocumentFactory.InitArguments, options?: Partial<Pick<DocumentInitContext, 'maxErrors' | 'showErrorDetails'
|
|
26
|
+
static createDocument(schemaOrUrl: string | PartialSome<OpraSchema.ApiDocument, 'spec'> | ApiDocumentFactory.InitArguments, options?: Partial<Pick<DocumentInitContext, 'maxErrors' | 'showErrorDetails'>> | DocumentInitContext): Promise<ApiDocument>;
|
|
28
27
|
/**
|
|
29
28
|
* Downloads schema from the given URL and creates the document instance * @param url
|
|
30
29
|
*/
|
|
@@ -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(options
|
|
27
|
+
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpApi;
|
|
28
28
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function testScopeMatch(scope: string, pattern?: (string | RegExp) | (string | RegExp)[]): boolean;
|
|
@@ -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
|
|
4
|
+
import type { ComplexType } 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,
|
|
25
|
-
protected normalizeFilterAst(ast: Expression, stack: Expression[], currentType?: ComplexType,
|
|
24
|
+
normalizeFilter(filter: OpraSchema.Field.QualifiedName | Expression, currentType?: ComplexType, scope?: any): Expression | undefined;
|
|
25
|
+
protected normalizeFilterAst(ast: Expression, stack: Expression[], currentType?: ComplexType, scope?: string): Expression | undefined;
|
|
26
26
|
toJSON(): Record<string, FilterRules.Rule>;
|
|
27
27
|
[Symbol.iterator](): IterableIterator<[string, FilterRules.Rule]>;
|
|
28
28
|
}
|