@opra/common 1.4.4 → 1.5.1
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 +12 -8
- package/cjs/document/common/api-base.js +2 -1
- package/cjs/document/common/document-node.js +24 -29
- package/cjs/document/common/value.js +6 -2
- package/cjs/document/constants.js +1 -2
- package/cjs/document/data-type/api-field.js +12 -8
- package/cjs/document/data-type/complex-type-base.js +22 -11
- package/cjs/document/data-type/complex-type.js +22 -8
- package/cjs/document/data-type/data-type.js +14 -1
- package/cjs/document/data-type/enum-type.js +13 -3
- package/cjs/document/data-type/extended-types/base64.type.js +1 -0
- package/cjs/document/data-type/extended-types/date-string.type.js +1 -0
- package/cjs/document/data-type/extended-types/date-time-string.type.js +1 -0
- package/cjs/document/data-type/extended-types/date-time.type.js +1 -0
- package/cjs/document/data-type/extended-types/date.type.js +1 -0
- package/cjs/document/data-type/extended-types/email.type.js +1 -0
- package/cjs/document/data-type/extended-types/field-path.type.js +10 -6
- package/cjs/document/data-type/extended-types/filter.type.js +11 -4
- package/cjs/document/data-type/extended-types/object-id.type.js +1 -0
- package/cjs/document/data-type/extended-types/operation-result.type.js +1 -0
- package/cjs/document/data-type/extended-types/time.type.js +1 -0
- package/cjs/document/data-type/extended-types/url.type.js +1 -0
- package/cjs/document/data-type/extended-types/uuid.type.js +1 -0
- package/cjs/document/data-type/mapped-type.js +12 -3
- package/cjs/document/data-type/mixin-type.js +17 -5
- package/cjs/document/data-type/primitive-types/any.type.js +1 -0
- package/cjs/document/data-type/primitive-types/bigint.type.js +1 -0
- package/cjs/document/data-type/primitive-types/boolean.type.js +1 -0
- package/cjs/document/data-type/primitive-types/integer.type.js +1 -0
- package/cjs/document/data-type/primitive-types/null.type.js +1 -0
- package/cjs/document/data-type/primitive-types/number.type.js +1 -0
- package/cjs/document/data-type/primitive-types/string.type.js +1 -0
- package/cjs/document/data-type/simple-type.js +13 -11
- package/cjs/document/decorators/api-field-decorator.js +37 -3
- package/cjs/document/decorators/complex-type.decorator.js +1 -1
- package/cjs/document/decorators/simple-type.decorator.js +3 -1
- package/cjs/document/http/http-api.js +2 -2
- package/cjs/document/http/http-controller.js +5 -5
- package/cjs/document/http/http-media-type.js +3 -3
- package/cjs/document/http/http-multipart-field.js +2 -2
- package/cjs/document/http/http-operation-response.js +3 -3
- package/cjs/document/http/http-operation.js +5 -5
- package/cjs/document/http/http-parameter.js +2 -2
- package/cjs/document/http/http-request-body.js +4 -2
- package/cjs/document/utils/test-scope-match.js +13 -0
- package/cjs/filter/filter-rules.js +6 -6
- package/esm/document/api-document.js +12 -8
- package/esm/document/common/api-base.js +2 -1
- package/esm/document/common/document-node.js +24 -29
- package/esm/document/common/value.js +6 -2
- package/esm/document/constants.js +0 -1
- package/esm/document/data-type/api-field.js +13 -9
- package/esm/document/data-type/complex-type-base.js +22 -11
- package/esm/document/data-type/complex-type.js +22 -8
- package/esm/document/data-type/data-type.js +14 -1
- package/esm/document/data-type/enum-type.js +13 -3
- package/esm/document/data-type/extended-types/base64.type.js +1 -0
- package/esm/document/data-type/extended-types/date-string.type.js +1 -0
- package/esm/document/data-type/extended-types/date-time-string.type.js +1 -0
- package/esm/document/data-type/extended-types/date-time.type.js +1 -0
- package/esm/document/data-type/extended-types/date.type.js +1 -0
- package/esm/document/data-type/extended-types/email.type.js +1 -0
- package/esm/document/data-type/extended-types/field-path.type.js +10 -6
- package/esm/document/data-type/extended-types/filter.type.js +11 -4
- package/esm/document/data-type/extended-types/object-id.type.js +1 -0
- package/esm/document/data-type/extended-types/operation-result.type.js +1 -0
- package/esm/document/data-type/extended-types/time.type.js +1 -0
- package/esm/document/data-type/extended-types/url.type.js +1 -0
- package/esm/document/data-type/extended-types/uuid.type.js +1 -0
- package/esm/document/data-type/mapped-type.js +12 -3
- package/esm/document/data-type/mixin-type.js +17 -5
- package/esm/document/data-type/primitive-types/any.type.js +1 -0
- package/esm/document/data-type/primitive-types/bigint.type.js +1 -0
- package/esm/document/data-type/primitive-types/boolean.type.js +1 -0
- package/esm/document/data-type/primitive-types/integer.type.js +1 -0
- package/esm/document/data-type/primitive-types/null.type.js +1 -0
- package/esm/document/data-type/primitive-types/number.type.js +1 -0
- package/esm/document/data-type/primitive-types/string.type.js +1 -0
- package/esm/document/data-type/simple-type.js +13 -11
- package/esm/document/decorators/api-field-decorator.js +36 -2
- package/esm/document/decorators/complex-type.decorator.js +2 -2
- package/esm/document/decorators/simple-type.decorator.js +4 -2
- package/esm/document/http/http-api.js +2 -2
- package/esm/document/http/http-controller.js +5 -5
- package/esm/document/http/http-media-type.js +3 -3
- package/esm/document/http/http-multipart-field.js +2 -2
- package/esm/document/http/http-operation-response.js +3 -3
- package/esm/document/http/http-operation.js +5 -5
- package/esm/document/http/http-parameter.js +2 -2
- package/esm/document/http/http-request-body.js +4 -2
- package/esm/document/utils/test-scope-match.js +10 -0
- package/esm/filter/filter-rules.js +6 -6
- package/package.json +1 -1
- package/types/document/api-document.d.ts +7 -2
- package/types/document/common/api-base.d.ts +1 -1
- package/types/document/common/document-init-context.d.ts +1 -0
- package/types/document/common/document-node.d.ts +8 -14
- package/types/document/common/value.d.ts +2 -1
- package/types/document/constants.d.ts +0 -1
- package/types/document/data-type/api-field.d.ts +42 -34
- package/types/document/data-type/complex-type-base.d.ts +4 -2
- package/types/document/data-type/complex-type.d.ts +3 -1
- package/types/document/data-type/data-type.d.ts +8 -2
- package/types/document/data-type/enum-type.d.ts +3 -1
- package/types/document/data-type/extended-types/field-path.type.d.ts +4 -3
- package/types/document/data-type/extended-types/filter.type.d.ts +2 -1
- package/types/document/data-type/mapped-type.d.ts +3 -1
- package/types/document/data-type/mixin-type.d.ts +3 -1
- package/types/document/data-type/simple-type.d.ts +3 -2
- 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 -0
- package/types/document/http/http-api.d.ts +1 -1
- package/types/document/http/http-controller.d.ts +2 -1
- package/types/document/http/http-media-type.d.ts +2 -1
- package/types/document/http/http-multipart-field.d.ts +2 -1
- package/types/document/http/http-operation-response.d.ts +2 -1
- package/types/document/http/http-operation.d.ts +2 -1
- package/types/document/http/http-parameter.d.ts +2 -1
- package/types/document/http/http-request-body.d.ts +2 -1
- package/types/document/utils/test-scope-match.d.ts +1 -0
- package/types/filter/filter-rules.d.ts +2 -2
|
@@ -1,59 +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
|
+
import type { ApiDocument } from '../api-document.js';
|
|
3
4
|
import { DocumentElement } from '../common/document-element.js';
|
|
4
|
-
import {
|
|
5
|
+
import { ApiFieldDecoratorFactory } from '../decorators/api-field-decorator.js';
|
|
5
6
|
import type { ComplexType } from './complex-type.js';
|
|
6
7
|
import type { DataType } from './data-type.js';
|
|
7
8
|
import type { EnumType } from './enum-type.js';
|
|
8
9
|
import type { MappedType } from './mapped-type.js';
|
|
9
10
|
import type { MixinType } from './mixin-type.js';
|
|
10
|
-
/**
|
|
11
|
-
* @namespace ApiField
|
|
12
|
-
*/
|
|
13
|
-
export declare namespace ApiField {
|
|
14
|
-
interface Metadata extends Combine<{
|
|
15
|
-
type?: string | OpraSchema.DataType | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
|
|
16
|
-
}, 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
|
-
}
|
|
23
|
-
interface Options extends Partial<Metadata> {
|
|
24
|
-
}
|
|
25
|
-
interface InitArguments extends Combine<{
|
|
26
|
-
name: string;
|
|
27
|
-
origin?: ComplexType | MappedType | MixinType;
|
|
28
|
-
type?: DataType;
|
|
29
|
-
}, Metadata> {
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
11
|
/**
|
|
33
12
|
* Type definition of ComplexType constructor type
|
|
34
13
|
* @type ApiFieldConstructor
|
|
35
14
|
*/
|
|
36
|
-
export interface ApiFieldConstructor extends
|
|
15
|
+
export interface ApiFieldConstructor extends ApiFieldDecoratorFactory {
|
|
37
16
|
prototype: ApiField;
|
|
38
17
|
new (owner: ComplexType | MappedType | MixinType, args: ApiField.InitArguments): ApiField;
|
|
39
18
|
}
|
|
40
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
|
+
*
|
|
41
24
|
* @class ApiField
|
|
42
25
|
*/
|
|
43
26
|
export interface ApiField extends ApiFieldClass {
|
|
44
27
|
}
|
|
45
28
|
/**
|
|
46
|
-
* @constructor ApiField
|
|
47
29
|
* @decorator ApiField
|
|
48
30
|
*/
|
|
49
31
|
export declare const ApiField: ApiFieldConstructor;
|
|
50
32
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
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.
|
|
53
36
|
*/
|
|
54
37
|
declare class ApiFieldClass extends DocumentElement {
|
|
55
38
|
readonly owner: ComplexType | MappedType | MixinType;
|
|
56
39
|
readonly origin?: ComplexType | MappedType | MixinType;
|
|
40
|
+
readonly scopePattern?: (string | RegExp)[];
|
|
57
41
|
readonly name: string;
|
|
58
42
|
readonly type: DataType;
|
|
59
43
|
readonly description?: string;
|
|
@@ -68,11 +52,35 @@ declare class ApiFieldClass extends DocumentElement {
|
|
|
68
52
|
readonly readonly?: boolean;
|
|
69
53
|
readonly writeonly?: boolean;
|
|
70
54
|
readonly examples?: any[] | Record<string, any>;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
55
|
+
inScope(scope: string): boolean;
|
|
56
|
+
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.Field;
|
|
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
|
+
}
|
|
77
85
|
}
|
|
78
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
|
*
|
|
@@ -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,7 @@ 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;
|
|
77
|
+
protected _locateBase(callback: (base: ComplexTypeBase) => boolean): ComplexTypeBase | undefined;
|
|
76
78
|
}
|
|
77
79
|
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
|
+
scopePattern?: (string | RegExp) | (string | RegExp)[];
|
|
18
20
|
}
|
|
19
21
|
interface InitArguments extends DataType.Metadata {
|
|
22
|
+
scopePattern?: (string | RegExp)[];
|
|
20
23
|
}
|
|
21
24
|
interface GenerateCodecOptions extends ValidationOptions {
|
|
22
25
|
documentElement?: DocumentElement;
|
|
26
|
+
scope?: 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 scopePattern?: (string | RegExp)[];
|
|
53
57
|
readonly name?: string;
|
|
54
58
|
readonly description?: string;
|
|
55
59
|
readonly abstract?: boolean;
|
|
@@ -57,8 +61,10 @@ 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
|
-
|
|
64
|
+
inScope(scope: string): boolean;
|
|
65
|
+
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.DataType;
|
|
61
66
|
toString(): string;
|
|
67
|
+
protected abstract _locateBase(callback: (base: DataType) => boolean): DataType | undefined;
|
|
62
68
|
[nodeInspectCustom](): string;
|
|
63
69
|
}
|
|
64
70
|
export {};
|
|
@@ -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,7 @@ 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;
|
|
70
|
+
protected _locateBase(callback: (base: EnumType) => boolean): EnumType | undefined;
|
|
69
71
|
}
|
|
70
72
|
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
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 {
|
|
6
7
|
constructor(attributes?: Partial<FieldPathType>);
|
|
7
8
|
dataType?: Type | string;
|
|
8
9
|
allowSigns?: 'first' | 'each';
|
|
9
|
-
[DECODER](properties: Partial<this>, element: DocumentElement): Validator;
|
|
10
|
-
[ENCODER](properties: Partial<this>, element: DocumentElement): Validator;
|
|
11
|
-
toJSON(properties: Partial<FieldPathType>, element: DocumentElement): {
|
|
10
|
+
[DECODER](properties: Partial<this>, element: DocumentElement, scope?: string): Validator;
|
|
11
|
+
[ENCODER](properties: Partial<this>, element: DocumentElement, scope?: string): Validator;
|
|
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,7 @@ 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;
|
|
73
|
+
protected _locateBase(callback: (base: ComplexTypeBase) => boolean): ComplexTypeBase | undefined;
|
|
72
74
|
}
|
|
73
75
|
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,7 @@ 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;
|
|
82
|
+
protected _locateBase(callback: (base: ComplexTypeBase) => boolean): ComplexTypeBase | undefined;
|
|
81
83
|
}
|
|
82
84
|
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';
|
|
@@ -27,7 +28,7 @@ export declare namespace SimpleType {
|
|
|
27
28
|
}
|
|
28
29
|
interface Attribute extends OpraSchema.Attribute {
|
|
29
30
|
}
|
|
30
|
-
type ValidatorGenerator = (properties: Record<string, any>, element: DocumentElement) => Validator;
|
|
31
|
+
type ValidatorGenerator = (properties: Record<string, any>, element: DocumentElement, scope?: string) => Validator;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Type definition for MixinType
|
|
@@ -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 {};
|
|
@@ -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,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>;
|
|
@@ -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
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function testScopeMatch(scope: string, pattern?: (string | RegExp) | (string | RegExp)[]): boolean;
|
|
@@ -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, 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
|
}
|