@opra/common 0.18.4 → 0.20.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.
- package/browser.js +1327 -1578
- package/cjs/document/api-document.js +55 -38
- package/cjs/document/data-type/api-field.js +5 -5
- package/cjs/document/data-type/builtin/any.type.js +3 -5
- package/cjs/document/data-type/builtin/base64.type.js +5 -28
- package/cjs/document/data-type/builtin/bigint.type.js +7 -25
- package/cjs/document/data-type/builtin/boolean.type.js +5 -18
- package/cjs/document/data-type/builtin/date.type.js +13 -9
- package/cjs/document/data-type/builtin/index.js +5 -1
- package/cjs/document/data-type/builtin/integer.type.js +5 -18
- package/cjs/document/data-type/builtin/null.type.js +15 -0
- package/cjs/document/data-type/builtin/number.type.js +5 -23
- package/cjs/document/data-type/builtin/object-id.type.js +15 -0
- package/cjs/document/data-type/builtin/object.type.js +4 -9
- package/cjs/document/data-type/builtin/string.type.js +5 -14
- package/cjs/document/data-type/builtin/time.type.js +11 -23
- package/cjs/document/data-type/builtin/timestamp.type.js +8 -20
- package/cjs/document/data-type/builtin/uuid.type.js +15 -0
- package/cjs/document/data-type/complex-type.js +152 -92
- package/cjs/document/data-type/data-type.js +32 -31
- package/cjs/document/data-type/enum-type.js +50 -43
- package/cjs/document/data-type/mapped-type.js +116 -70
- package/cjs/document/data-type/simple-type.js +47 -45
- package/cjs/document/data-type/union-type.js +70 -36
- package/cjs/document/factory/create-document.js +6 -4
- package/cjs/document/factory/factory.js +23 -20
- package/cjs/document/factory/import-type-class.js +13 -4
- package/cjs/document/resource/collection.js +55 -59
- package/cjs/document/resource/resource.js +10 -21
- package/cjs/document/resource/singleton.js +36 -39
- package/cjs/exception/common-errors/validation.error.js +11 -0
- package/cjs/exception/index.js +2 -1
- package/cjs/exception/{enums/issue-severity.enum.js → issue-severity.enum.js} +1 -1
- package/cjs/exception/opra-exception.js +2 -2
- package/cjs/filter/antlr/OpraFilterLexer.js +1 -1
- package/cjs/filter/antlr/OpraFilterParser.js +1 -1
- package/cjs/filter/errors.js +5 -0
- package/cjs/http/enums/http-headers-codes.enum.js +1 -1
- package/cjs/http/enums/http-status-codes.enum.js +1 -1
- package/cjs/http/index.js +1 -2
- package/cjs/schema/data-type/complex-type.interface.js +1 -1
- package/cjs/schema/data-type/enum-type.interface.js +1 -1
- package/cjs/schema/data-type/mapped-type.interface.js +1 -1
- package/cjs/schema/data-type/simple-type.interface.js +1 -1
- package/cjs/schema/data-type/union-type.interface.js +1 -1
- package/cjs/schema/index.js +3 -41
- package/cjs/schema/opra-schema.ns.js +18 -0
- package/cjs/schema/resource/collection.interface.js +1 -1
- package/cjs/schema/resource/container.interface.js +1 -1
- package/cjs/schema/resource/singleton.interface.js +1 -1
- package/esm/document/api-document.js +55 -38
- package/esm/document/data-type/api-field.js +5 -5
- package/esm/document/data-type/builtin/any.type.js +2 -4
- package/esm/document/data-type/builtin/base64.type.js +4 -27
- package/esm/document/data-type/builtin/bigint.type.js +6 -24
- package/esm/document/data-type/builtin/boolean.type.js +4 -17
- package/esm/document/data-type/builtin/date.type.js +12 -8
- package/esm/document/data-type/builtin/index.js +5 -1
- package/esm/document/data-type/builtin/integer.type.js +4 -17
- package/esm/document/data-type/builtin/null.type.js +12 -0
- package/esm/document/data-type/builtin/number.type.js +4 -22
- package/esm/document/data-type/builtin/object-id.type.js +12 -0
- package/esm/document/data-type/builtin/object.type.js +3 -8
- package/esm/document/data-type/builtin/string.type.js +4 -13
- package/esm/document/data-type/builtin/time.type.js +10 -22
- package/esm/document/data-type/builtin/timestamp.type.js +7 -19
- package/esm/document/data-type/builtin/uuid.type.js +12 -0
- package/esm/document/data-type/complex-type.js +152 -92
- package/esm/document/data-type/data-type.js +31 -31
- package/esm/document/data-type/enum-type.js +50 -43
- package/esm/document/data-type/mapped-type.js +115 -70
- package/esm/document/data-type/simple-type.js +46 -44
- package/esm/document/data-type/union-type.js +69 -36
- package/esm/document/factory/create-document.js +7 -5
- package/esm/document/factory/factory.js +23 -20
- package/esm/document/factory/import-type-class.js +13 -4
- package/esm/document/resource/collection.js +55 -59
- package/esm/document/resource/resource.js +9 -21
- package/esm/document/resource/singleton.js +36 -39
- package/esm/exception/common-errors/validation.error.js +7 -0
- package/esm/exception/index.js +2 -1
- package/esm/exception/opra-exception.js +2 -2
- package/esm/filter/antlr/OpraFilterLexer.js +2 -1
- package/esm/filter/antlr/OpraFilterParser.js +2 -1
- package/esm/filter/errors.js +5 -0
- package/esm/http/index.js +1 -2
- package/esm/schema/index.js +2 -41
- package/esm/schema/opra-schema.ns.js +15 -0
- package/package.json +10 -23
- package/types/document/api-document.d.ts +3 -2
- package/types/document/data-type/builtin/base64.type.d.ts +0 -4
- package/types/document/data-type/builtin/bigint.type.d.ts +1 -5
- package/types/document/data-type/builtin/boolean.type.d.ts +0 -3
- package/types/document/data-type/builtin/date.type.d.ts +1 -3
- package/types/document/data-type/builtin/index.d.ts +5 -1
- package/types/document/data-type/builtin/integer.type.d.ts +1 -5
- package/types/document/data-type/builtin/null.type.d.ts +2 -0
- package/types/document/data-type/builtin/number.type.d.ts +0 -4
- package/types/document/data-type/builtin/object-id.type.d.ts +2 -0
- package/types/document/data-type/builtin/object.type.d.ts +0 -1
- package/types/document/data-type/builtin/string.type.d.ts +0 -3
- package/types/document/data-type/builtin/time.type.d.ts +1 -6
- package/types/document/data-type/builtin/timestamp.type.d.ts +0 -3
- package/types/document/data-type/builtin/uuid.type.d.ts +2 -0
- package/types/document/data-type/complex-type.d.ts +30 -16
- package/types/document/data-type/data-type.d.ts +19 -15
- package/types/document/data-type/enum-type.d.ts +16 -5
- package/types/document/data-type/mapped-type.d.ts +28 -5
- package/types/document/data-type/simple-type.d.ts +27 -12
- package/types/document/data-type/union-type.d.ts +21 -5
- package/types/document/factory/factory.d.ts +3 -2
- package/types/document/resource/collection.d.ts +11 -9
- package/types/document/resource/resource.d.ts +3 -9
- package/types/document/resource/singleton.d.ts +7 -5
- package/types/exception/common-errors/validation.error.d.ts +4 -0
- package/types/exception/error-issue.d.ts +1 -1
- package/types/exception/index.d.ts +2 -1
- package/types/exception/opra-exception.d.ts +4 -2
- package/types/filter/errors.d.ts +3 -0
- package/types/http/index.d.ts +1 -2
- package/types/schema/data-type/enum-type.interface.d.ts +5 -5
- package/types/schema/data-type/simple-type.interface.d.ts +5 -11
- package/types/schema/index.d.ts +2 -51
- package/types/schema/opra-schema.ns.d.ts +15 -0
- package/cjs/document/data-type/builtin/guid.type.js +0 -35
- package/cjs/http/http-message.host.js +0 -251
- package/cjs/http/http-request-message.js +0 -152
- package/cjs/http/http-response-message.js +0 -238
- package/cjs/http/interfaces/cookie-options.interface.js +0 -2
- package/esm/document/data-type/builtin/guid.type.js +0 -32
- package/esm/http/http-message.host.js +0 -246
- package/esm/http/http-request-message.js +0 -148
- package/esm/http/http-response-message.js +0 -233
- package/esm/http/interfaces/cookie-options.interface.js +0 -1
- package/types/document/data-type/builtin/guid.type.d.ts +0 -7
- package/types/http/http-message.host.d.ts +0 -122
- package/types/http/http-request-message.d.ts +0 -213
- package/types/http/http-response-message.d.ts +0 -318
- package/types/http/interfaces/cookie-options.interface.d.ts +0 -4
- /package/esm/exception/{enums/issue-severity.enum.js → issue-severity.enum.js} +0 -0
- /package/types/exception/{enums/issue-severity.enum.d.ts → issue-severity.enum.d.ts} +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
1
2
|
import { StrictOmit, Type } from 'ts-gems';
|
|
3
|
+
import * as vg from 'valgen';
|
|
2
4
|
import { ResponsiveMap } from '../../helpers/index.js';
|
|
3
5
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
6
|
import type { ApiDocument } from '../api-document.js';
|
|
5
7
|
import { ApiField } from './api-field.js';
|
|
6
8
|
import { DataType } from './data-type.js';
|
|
7
|
-
import type { UnionType } from './union-type';
|
|
9
|
+
import type { UnionType } from './union-type.js';
|
|
8
10
|
/**
|
|
9
11
|
* @namespace ComplexType
|
|
10
12
|
*/
|
|
@@ -12,10 +14,10 @@ export declare namespace ComplexType {
|
|
|
12
14
|
interface InitArguments extends DataType.InitArguments, Pick<OpraSchema.ComplexType, 'ctor' | 'abstract' | 'additionalFields'> {
|
|
13
15
|
base?: ComplexType | UnionType;
|
|
14
16
|
}
|
|
15
|
-
interface OwnProperties extends
|
|
16
|
-
|
|
17
|
+
interface OwnProperties extends Readonly<StrictOmit<OpraSchema.ComplexType, 'fields'>> {
|
|
18
|
+
fields: ResponsiveMap<ApiField>;
|
|
17
19
|
}
|
|
18
|
-
interface DecoratorOptions extends DataType.DecoratorOptions, Pick<InitArguments, 'ctor' | '
|
|
20
|
+
interface DecoratorOptions extends DataType.DecoratorOptions, Pick<InitArguments, 'ctor' | 'additionalFields' | 'abstract'> {
|
|
19
21
|
}
|
|
20
22
|
interface Metadata extends StrictOmit<OpraSchema.ComplexType, 'fields'> {
|
|
21
23
|
name: string;
|
|
@@ -23,34 +25,46 @@ export declare namespace ComplexType {
|
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @type ComplexType
|
|
28
|
+
* @class ComplexType
|
|
28
29
|
*/
|
|
29
|
-
|
|
30
|
+
declare class ComplexTypeClass extends DataType {
|
|
31
|
+
readonly kind = "ComplexType";
|
|
30
32
|
readonly ctor: Type;
|
|
31
33
|
readonly base?: ComplexType | UnionType;
|
|
32
34
|
readonly own: ComplexType.OwnProperties;
|
|
35
|
+
readonly fields: ResponsiveMap<ApiField>;
|
|
33
36
|
readonly abstract?: boolean;
|
|
34
|
-
readonly additionalFields?: boolean;
|
|
35
|
-
|
|
37
|
+
readonly additionalFields?: boolean | vg.Validator<any, any> | 'ignore';
|
|
38
|
+
protected _decoder?: vg.Validator<any, any>;
|
|
39
|
+
protected _encoder?: vg.Validator<any, any>;
|
|
40
|
+
constructor(document: ApiDocument, init: ComplexType.InitArguments);
|
|
36
41
|
addField(init: ApiField.InitArguments): ApiField;
|
|
37
|
-
iteratePath(path: string, silent?: boolean): IterableIterator<[string, ApiField | undefined, string]>;
|
|
38
|
-
getField(nameOrPath: string): ApiField;
|
|
39
42
|
findField(nameOrPath: string): ApiField | undefined;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
normalizeFieldPath(
|
|
43
|
+
getField(nameOrPath: string): ApiField;
|
|
44
|
+
iteratePath(path: string, silent?: boolean): IterableIterator<[string, ApiField | undefined, string]>;
|
|
45
|
+
normalizeFieldPath(fieldPath: string): string;
|
|
46
|
+
normalizeFieldPath(fieldPaths: string[]): string[];
|
|
47
|
+
exportSchema(): OpraSchema.ComplexType;
|
|
48
|
+
isTypeOf(t: Type | Function): boolean;
|
|
49
|
+
extendsFrom(t: string | Type | DataType): boolean;
|
|
50
|
+
decode(v: object): any;
|
|
51
|
+
encode(v: any): any;
|
|
52
|
+
validate(v: any): any;
|
|
53
|
+
protected _getDecoder(): vg.Validator<any, any>;
|
|
54
|
+
protected _getEncoder(): vg.Validator<any, any>;
|
|
43
55
|
}
|
|
44
56
|
/**
|
|
45
|
-
*
|
|
46
|
-
* @type ComplexTypeConstructor
|
|
57
|
+
* Callable class pattern for ComplexType
|
|
47
58
|
*/
|
|
48
59
|
export interface ComplexTypeConstructor {
|
|
49
60
|
new (document: ApiDocument, init: ComplexType.InitArguments): ComplexType;
|
|
50
61
|
(options?: ComplexType.DecoratorOptions): ClassDecorator;
|
|
51
62
|
prototype: ComplexType;
|
|
52
63
|
}
|
|
64
|
+
export interface ComplexType extends ComplexTypeClass {
|
|
65
|
+
}
|
|
53
66
|
/**
|
|
54
67
|
* @class ComplexType
|
|
55
68
|
*/
|
|
56
69
|
export declare const ComplexType: ComplexTypeConstructor;
|
|
70
|
+
export {};
|
|
@@ -1,33 +1,37 @@
|
|
|
1
|
-
import { Type } from 'ts-gems';
|
|
1
|
+
import { RequiredSome, Type } from 'ts-gems';
|
|
2
|
+
import * as vg from 'valgen';
|
|
2
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
4
|
import type { ApiDocument } from '../api-document.js';
|
|
4
5
|
import { nodeInspectCustom } from '../utils/inspect.util.js';
|
|
5
6
|
export declare namespace DataType {
|
|
6
|
-
interface InitArguments
|
|
7
|
+
interface InitArguments {
|
|
7
8
|
name?: string;
|
|
8
|
-
}
|
|
9
|
-
interface OwnProperties {
|
|
10
9
|
description?: string;
|
|
11
10
|
}
|
|
12
|
-
interface DecoratorOptions extends
|
|
11
|
+
interface DecoratorOptions extends InitArguments {
|
|
12
|
+
}
|
|
13
|
+
interface Metadata extends RequiredSome<DecoratorOptions, 'name'> {
|
|
14
|
+
kind: OpraSchema.DataType.Kind;
|
|
15
|
+
}
|
|
16
|
+
interface OwnProperties {
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
|
-
export
|
|
19
|
+
export declare abstract class DataType {
|
|
16
20
|
readonly document: ApiDocument;
|
|
17
21
|
readonly kind: OpraSchema.DataType.Kind;
|
|
18
22
|
readonly name?: string;
|
|
23
|
+
readonly base?: DataType;
|
|
19
24
|
readonly own: DataType.OwnProperties;
|
|
25
|
+
readonly description?: string;
|
|
20
26
|
readonly isAnonymous: boolean;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
protected constructor(document: ApiDocument, init?: DataType.InitArguments);
|
|
28
|
+
decode(v: any): any;
|
|
29
|
+
encode(v: any): any;
|
|
30
|
+
validate(v: any): any;
|
|
31
|
+
protected abstract _getDecoder(): vg.Validator<any, any>;
|
|
32
|
+
protected abstract _getEncoder(): vg.Validator<any, any>;
|
|
24
33
|
exportSchema(): OpraSchema.DataType;
|
|
34
|
+
extendsFrom(type: string | Type | DataType): any;
|
|
25
35
|
toString(): string;
|
|
26
36
|
[nodeInspectCustom](): string;
|
|
27
37
|
}
|
|
28
|
-
export interface DataTypeConstructor {
|
|
29
|
-
new (document: ApiDocument, init?: DataType.InitArguments): DataType;
|
|
30
|
-
(...args: any[]): void;
|
|
31
|
-
prototype: DataType;
|
|
32
|
-
}
|
|
33
|
-
export declare const DataType: DataTypeConstructor;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import * as vg from 'valgen';
|
|
2
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
4
|
import type { ApiDocument } from '../api-document.js';
|
|
4
5
|
import { DataType } from './data-type.js';
|
|
@@ -6,8 +7,6 @@ export declare namespace EnumType {
|
|
|
6
7
|
interface InitArguments extends DataType.InitArguments, Pick<OpraSchema.EnumType, 'base' | 'values' | 'meanings'> {
|
|
7
8
|
base?: EnumType;
|
|
8
9
|
}
|
|
9
|
-
interface OwnProperties extends DataType.OwnProperties, Required<Readonly<Pick<OpraSchema.EnumType, 'values' | 'meanings'>>> {
|
|
10
|
-
}
|
|
11
10
|
interface Options<T, Keys extends (string | number | symbol) = T extends readonly any[] ? T[number] : keyof T> extends DataType.DecoratorOptions {
|
|
12
11
|
name?: string;
|
|
13
12
|
base?: OpraSchema.EnumObject;
|
|
@@ -17,16 +16,28 @@ export declare namespace EnumType {
|
|
|
17
16
|
name: string;
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
|
|
19
|
+
declare class EnumTypeClass extends DataType {
|
|
20
|
+
readonly kind = "EnumType";
|
|
21
21
|
readonly base?: EnumType;
|
|
22
|
-
readonly
|
|
22
|
+
readonly values: Record<string, string | number>;
|
|
23
|
+
readonly meanings: Record<string, string>;
|
|
24
|
+
readonly ownValues: Record<string, string | number>;
|
|
25
|
+
readonly ownMeanings: Record<string, string>;
|
|
26
|
+
protected _decoder?: vg.Validator<any, any>;
|
|
27
|
+
protected _encoder?: vg.Validator<any, any>;
|
|
28
|
+
constructor(document: ApiDocument, init: EnumType.InitArguments);
|
|
23
29
|
exportSchema(): OpraSchema.EnumType;
|
|
30
|
+
protected _getDecoder(): vg.Validator<any, any>;
|
|
31
|
+
protected _getEncoder(): vg.Validator<any, any>;
|
|
24
32
|
}
|
|
25
33
|
export interface EnumTypeConstructor {
|
|
26
34
|
new (document: ApiDocument, init?: EnumType.InitArguments): EnumType;
|
|
27
35
|
<T extends OpraSchema.EnumObject | readonly (string | number)[]>(target: T, options?: EnumType.Options<T>): T;
|
|
28
36
|
}
|
|
37
|
+
export interface EnumType extends EnumTypeClass {
|
|
38
|
+
}
|
|
29
39
|
/**
|
|
30
40
|
* @class EnumType
|
|
31
41
|
*/
|
|
32
42
|
export declare const EnumType: EnumTypeConstructor;
|
|
43
|
+
export {};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
1
2
|
import { Class, StrictOmit, Type } from 'ts-gems';
|
|
3
|
+
import * as vg from 'valgen';
|
|
4
|
+
import { ResponsiveMap } from '../../helpers/index.js';
|
|
5
|
+
import { Field } from '../../schema/data-type/field.interface.js';
|
|
2
6
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
7
|
import type { ApiDocument } from '../api-document.js';
|
|
8
|
+
import { ApiField } from './api-field.js';
|
|
4
9
|
import { ComplexType } from './complex-type.js';
|
|
5
10
|
import { DataType } from './data-type.js';
|
|
6
11
|
/**
|
|
@@ -11,7 +16,6 @@ export declare namespace MappedType {
|
|
|
11
16
|
type: ComplexType;
|
|
12
17
|
}
|
|
13
18
|
interface OwnProperties extends DataType.OwnProperties, Pick<OpraSchema.MappedType, 'pick' | 'omit'> {
|
|
14
|
-
type: ComplexType;
|
|
15
19
|
}
|
|
16
20
|
interface Options<T, K = keyof T> {
|
|
17
21
|
pick?: readonly K[];
|
|
@@ -21,14 +25,26 @@ export declare namespace MappedType {
|
|
|
21
25
|
type: Type;
|
|
22
26
|
}
|
|
23
27
|
}
|
|
28
|
+
declare class MappedTypeClass extends DataType {
|
|
29
|
+
readonly kind = "MappedType";
|
|
30
|
+
readonly own: MappedType.OwnProperties;
|
|
31
|
+
readonly type: ComplexType;
|
|
32
|
+
readonly additionalFields?: boolean | vg.Validator<any, any> | 'ignore';
|
|
33
|
+
readonly fields: ResponsiveMap<ApiField>;
|
|
34
|
+
readonly omit?: Field.Name[];
|
|
35
|
+
readonly pick?: Field.Name[];
|
|
36
|
+
protected _decoder: vg.Validator<any, any>;
|
|
37
|
+
protected _encoder: vg.Validator<any, any>;
|
|
38
|
+
constructor(document: ApiDocument, init: MappedType.InitArguments);
|
|
39
|
+
exportSchema(): OpraSchema.MappedType;
|
|
40
|
+
protected _getDecoder(): vg.Validator<any, any>;
|
|
41
|
+
protected _getEncoder(): vg.Validator<any, any>;
|
|
42
|
+
}
|
|
24
43
|
/**
|
|
25
44
|
* Type definition of MappedType prototype
|
|
26
45
|
* @type MappedType
|
|
27
46
|
*/
|
|
28
|
-
export interface MappedType extends
|
|
29
|
-
readonly own: MappedType.OwnProperties;
|
|
30
|
-
readonly type: ComplexType;
|
|
31
|
-
exportSchema(): OpraSchema.MappedType;
|
|
47
|
+
export interface MappedType extends MappedTypeClass {
|
|
32
48
|
}
|
|
33
49
|
/**
|
|
34
50
|
* Type definition of MappedType constructor type
|
|
@@ -49,5 +65,12 @@ export interface MappedTypeConstructor {
|
|
|
49
65
|
* @class MappedType
|
|
50
66
|
*/
|
|
51
67
|
export declare const MappedType: MappedTypeConstructor;
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
52
71
|
export declare function PickType<T extends any[], I1, S1, K extends keyof I1>(classRef: Class<T, I1, S1>, keys: readonly K[]): Class<T, Pick<I1, K>> & Omit<Pick<S1, keyof typeof classRef>, 'prototype' | 'constructor'>;
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
53
75
|
export declare function OmitType<T extends any[], I1, S1, K extends keyof I1>(classRef: Class<T, I1, S1>, keys: readonly K[]): Class<T, Omit<I1, K>> & Omit<Pick<S1, keyof typeof classRef>, 'prototype' | 'constructor'>;
|
|
76
|
+
export {};
|
|
@@ -1,33 +1,48 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import * as vg from 'valgen';
|
|
2
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
4
|
import type { ApiDocument } from '../api-document.js';
|
|
4
5
|
import { DataType } from './data-type.js';
|
|
5
6
|
export declare namespace SimpleType {
|
|
6
|
-
interface InitArguments extends DataType.InitArguments
|
|
7
|
+
interface InitArguments extends DataType.InitArguments {
|
|
7
8
|
base?: SimpleType;
|
|
9
|
+
decoder?: vg.Validator<any, any>;
|
|
10
|
+
encoder?: vg.Validator<any, any>;
|
|
8
11
|
}
|
|
9
|
-
interface
|
|
12
|
+
interface DecoratorOptions extends DataType.DecoratorOptions {
|
|
13
|
+
decoder?: vg.Validator<any, any>;
|
|
14
|
+
encoder?: vg.Validator<any, any>;
|
|
10
15
|
}
|
|
11
|
-
interface
|
|
16
|
+
interface Metadata extends DataType.Metadata {
|
|
17
|
+
decoder?: vg.Validator<any, any>;
|
|
18
|
+
encoder?: vg.Validator<any, any>;
|
|
12
19
|
}
|
|
13
|
-
interface
|
|
14
|
-
name: string;
|
|
20
|
+
interface OwnProperties extends DataType.OwnProperties {
|
|
15
21
|
}
|
|
16
22
|
}
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @class SimpleType
|
|
25
|
+
*/
|
|
26
|
+
declare class SimpleTypeClass extends DataType {
|
|
27
|
+
readonly kind = "SimpleType";
|
|
19
28
|
readonly base?: SimpleType;
|
|
29
|
+
protected _decoder: vg.Validator<any, any>;
|
|
30
|
+
protected _encoder: vg.Validator<any, any>;
|
|
20
31
|
readonly own: SimpleType.OwnProperties;
|
|
32
|
+
constructor(document: ApiDocument, init: SimpleType.InitArguments);
|
|
33
|
+
protected _getDecoder(): vg.Validator<any, any>;
|
|
34
|
+
protected _getEncoder(): vg.Validator<any, any>;
|
|
21
35
|
exportSchema(): OpraSchema.SimpleType;
|
|
22
|
-
decode(value: any): any;
|
|
23
|
-
encode(value: any): any;
|
|
24
36
|
}
|
|
25
37
|
export interface SimpleTypeConstructor {
|
|
26
|
-
new (document: ApiDocument, init
|
|
27
|
-
(
|
|
38
|
+
new (document: ApiDocument, init: SimpleType.InitArguments): SimpleType;
|
|
39
|
+
(options?: SimpleType.DecoratorOptions): (target: any) => any;
|
|
28
40
|
prototype: SimpleType;
|
|
29
41
|
}
|
|
42
|
+
export interface SimpleType extends SimpleTypeClass {
|
|
43
|
+
}
|
|
30
44
|
/**
|
|
31
45
|
* @class SimpleType
|
|
32
46
|
*/
|
|
33
47
|
export declare const SimpleType: SimpleTypeConstructor;
|
|
48
|
+
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
1
2
|
import { Class, StrictOmit, Type } from 'ts-gems';
|
|
3
|
+
import * as vg from 'valgen';
|
|
4
|
+
import { ResponsiveMap } from '../../helpers/index.js';
|
|
2
5
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
6
|
import type { ApiDocument } from '../api-document.js';
|
|
7
|
+
import { ApiField } from './api-field.js';
|
|
4
8
|
import { ComplexType } from './complex-type.js';
|
|
5
9
|
import { DataType } from './data-type.js';
|
|
6
10
|
import { MappedType } from './mapped-type.js';
|
|
@@ -18,13 +22,18 @@ export declare namespace UnionType {
|
|
|
18
22
|
types: Type[];
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* @type UnionType
|
|
24
|
-
*/
|
|
25
|
-
export interface UnionType extends StrictOmit<DataType, 'own' | 'exportSchema'>, Pick<ComplexType, 'additionalFields' | 'fields'>, UnionType.OwnProperties {
|
|
25
|
+
declare class UnionTypeClass extends DataType {
|
|
26
|
+
readonly kind = "UnionType";
|
|
26
27
|
readonly own: UnionType.OwnProperties;
|
|
28
|
+
readonly types: (ComplexType | UnionType | MappedType)[];
|
|
29
|
+
readonly additionalFields?: boolean;
|
|
30
|
+
readonly fields: ResponsiveMap<ApiField>;
|
|
31
|
+
protected _decoder: vg.Validator<any, any>;
|
|
32
|
+
protected _encoder: vg.Validator<any, any>;
|
|
33
|
+
constructor(document: ApiDocument, init: UnionType.InitArguments);
|
|
27
34
|
exportSchema(): OpraSchema.UnionType;
|
|
35
|
+
protected _getDecoder(): vg.Validator<any, any>;
|
|
36
|
+
protected _getEncoder(): vg.Validator<any, any>;
|
|
28
37
|
}
|
|
29
38
|
/**
|
|
30
39
|
* Type definition of UnionType constructor type
|
|
@@ -36,7 +45,14 @@ export interface UnionTypeConstructor {
|
|
|
36
45
|
<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3?: Class<A3, I3, S3>, c4?: Class<A4, I4, S4>): Class<any[], I1 & I2 & I3 & I4, S1 & S2 & S3 & S4>;
|
|
37
46
|
_applyMixin(target: Type, ...sources: [Type]): void;
|
|
38
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Type definition of UnionType prototype
|
|
50
|
+
* @type UnionType
|
|
51
|
+
*/
|
|
52
|
+
export interface UnionType extends UnionTypeClass {
|
|
53
|
+
}
|
|
39
54
|
/**
|
|
40
55
|
* @class UnionType
|
|
41
56
|
*/
|
|
42
57
|
export declare const UnionType: UnionTypeConstructor;
|
|
58
|
+
export {};
|
|
@@ -13,16 +13,17 @@ import { addDataType, createDataTypeInstance, processTypes } from './process-typ
|
|
|
13
13
|
* @namespace DocumentFactory
|
|
14
14
|
*/
|
|
15
15
|
export declare namespace DocumentFactory {
|
|
16
|
-
|
|
16
|
+
interface InitArguments extends StrictOmit<OpraSchema.ApiDocument, 'references' | 'types' | 'resources'> {
|
|
17
17
|
references?: Record<string, string | OpraSchema.ApiDocument | ApiDocument>;
|
|
18
18
|
resources?: ThunkAsync<Type | object>[] | Record<OpraSchema.Resource.Name, OpraSchema.Resource>;
|
|
19
19
|
types?: ThunkAsync<Type | OpraSchema.EnumThunk>[] | Record<string, OpraSchema.DataType>;
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* @class DocumentFactory
|
|
24
24
|
*/
|
|
25
25
|
export declare class DocumentFactory {
|
|
26
|
+
static designTypeMap: Map<Function | Type<any>, string>;
|
|
26
27
|
protected document: ApiDocument;
|
|
27
28
|
protected typeQueue: ResponsiveMap<OpraSchema.DataType>;
|
|
28
29
|
protected resourceQueue: ResponsiveMap<OpraSchema.Resource>;
|
|
@@ -37,19 +37,18 @@ export declare namespace Collection {
|
|
|
37
37
|
export type UpdateManyOperationOptions = StrictOmit<OpraSchema.Collection.UpdateManyOperation, 'handler'>;
|
|
38
38
|
export {};
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
declare class CollectionClass extends Resource {
|
|
41
41
|
readonly type: ComplexType;
|
|
42
|
+
readonly kind = "Collection";
|
|
42
43
|
readonly operations: Collection.Operations;
|
|
43
44
|
readonly controller?: object;
|
|
44
45
|
readonly primaryKey: string[];
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
normalizeFieldPath(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
normalizeFilter(ast: string | OpraFilter.Expression): OpraFilter.Expression | undefined;
|
|
52
|
-
_construct(init: Collection.InitArguments): void;
|
|
46
|
+
constructor(document: ApiDocument, init: Collection.InitArguments);
|
|
47
|
+
exportSchema(this: Collection): OpraSchema.Collection;
|
|
48
|
+
parseKeyValue(this: Collection, value: any): any | undefined;
|
|
49
|
+
normalizeFieldPath(this: Collection, path: string | string[]): string | string[];
|
|
50
|
+
normalizeSortFields(this: Collection, fields: string | string[]): string | string[];
|
|
51
|
+
normalizeFilter(filter: string | OpraFilter.Expression): OpraFilter.Expression | undefined;
|
|
53
52
|
}
|
|
54
53
|
export interface CollectionConstructor {
|
|
55
54
|
prototype: Collection;
|
|
@@ -63,7 +62,10 @@ export interface CollectionConstructor {
|
|
|
63
62
|
DeleteMany: (options?: Collection.DeleteManyOperationOptions) => PropertyDecorator;
|
|
64
63
|
UpdateMany: (options?: Collection.UpdateManyOperationOptions) => PropertyDecorator;
|
|
65
64
|
}
|
|
65
|
+
export interface Collection extends CollectionClass {
|
|
66
|
+
}
|
|
66
67
|
/**
|
|
67
68
|
*
|
|
68
69
|
*/
|
|
69
70
|
export declare const Collection: CollectionConstructor;
|
|
71
|
+
export {};
|
|
@@ -10,20 +10,14 @@ export declare namespace Resource {
|
|
|
10
10
|
interface DecoratorOptions extends Partial<Pick<InitArguments, 'name' | 'description'>> {
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export declare abstract class Resource {
|
|
14
14
|
readonly document: ApiDocument;
|
|
15
|
-
readonly kind: OpraSchema.Resource.Kind;
|
|
15
|
+
abstract readonly kind: OpraSchema.Resource.Kind;
|
|
16
16
|
readonly name: string;
|
|
17
17
|
readonly description?: string;
|
|
18
18
|
readonly controller?: object | Type;
|
|
19
|
+
protected constructor(document: ApiDocument, init: Resource.InitArguments);
|
|
19
20
|
exportSchema(): OpraSchema.ResourceBase;
|
|
20
21
|
toString(): string;
|
|
21
22
|
[nodeInspectCustom](): string;
|
|
22
|
-
_construct(init: Resource.InitArguments): void;
|
|
23
23
|
}
|
|
24
|
-
export interface ResourceConstructor {
|
|
25
|
-
readonly prototype: Resource;
|
|
26
|
-
new (document: ApiDocument, init: Resource.InitArguments): Resource;
|
|
27
|
-
(...args: any[]): void;
|
|
28
|
-
}
|
|
29
|
-
export declare const Resource: ResourceConstructor;
|
|
@@ -29,15 +29,14 @@ export declare namespace Singleton {
|
|
|
29
29
|
export type UpdateOperationOptions = StrictOmit<OpraSchema.Singleton.UpdateOperation, 'handler'>;
|
|
30
30
|
export {};
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
declare class SingletonClass extends Resource {
|
|
33
33
|
readonly type: ComplexType;
|
|
34
|
+
readonly kind = "Singleton";
|
|
34
35
|
readonly operations: Singleton.Operations;
|
|
35
36
|
readonly controller?: object | Type;
|
|
37
|
+
constructor(document: ApiDocument, init: Singleton.InitArguments);
|
|
36
38
|
exportSchema(): OpraSchema.Singleton;
|
|
37
|
-
normalizeFieldPath(
|
|
38
|
-
normalizeFieldPath(fields: string[]): string[];
|
|
39
|
-
normalizeFieldPath(fields: string | string[]): string | string[];
|
|
40
|
-
_construct(init: Singleton.InitArguments): void;
|
|
39
|
+
normalizeFieldPath(this: Singleton, path: string | []): string | string[];
|
|
41
40
|
}
|
|
42
41
|
export interface SingletonConstructor {
|
|
43
42
|
prototype: Singleton;
|
|
@@ -48,4 +47,7 @@ export interface SingletonConstructor {
|
|
|
48
47
|
Get: (options?: Singleton.GetOperationOptions) => PropertyDecorator;
|
|
49
48
|
Update: (options?: Singleton.UpdateOperationOptions) => PropertyDecorator;
|
|
50
49
|
}
|
|
50
|
+
export interface Singleton extends SingletonClass {
|
|
51
|
+
}
|
|
51
52
|
export declare const Singleton: SingletonConstructor;
|
|
53
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './opra-exception.js';
|
|
2
2
|
export * from './error-issue.js';
|
|
3
3
|
export * from './wrap-exception.js';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './issue-severity.enum.js';
|
|
5
5
|
export * from './http-errors/bad-request.error.js';
|
|
6
6
|
export * from './http-errors/failed-dependency.error.js';
|
|
7
7
|
export * from './http-errors/forbidden.error.js';
|
|
@@ -13,3 +13,4 @@ export * from './http-errors/unauthorized.error.js';
|
|
|
13
13
|
export * from './http-errors/unprocessable-entity.error.js';
|
|
14
14
|
export * from './resource-errors/resource-conflict.error.js';
|
|
15
15
|
export * from './resource-errors/resource-not-found.error.js';
|
|
16
|
+
export * from './common-errors/validation.error.js';
|
|
@@ -6,10 +6,12 @@ export declare class OpraException extends Error {
|
|
|
6
6
|
protected _issue: ErrorIssue;
|
|
7
7
|
status: number;
|
|
8
8
|
cause?: Error;
|
|
9
|
-
constructor(
|
|
9
|
+
constructor();
|
|
10
|
+
constructor(issue: string | Partial<ErrorIssue> | Error);
|
|
11
|
+
constructor(issue: string | Partial<ErrorIssue>, cause?: Error);
|
|
10
12
|
get issue(): ErrorIssue;
|
|
11
13
|
setIssue(issue: Partial<ErrorIssue>): void;
|
|
12
14
|
setStatus(status: number): this;
|
|
13
15
|
protected _initName(): void;
|
|
14
|
-
protected _init(issue:
|
|
16
|
+
protected _init(issue: any): void;
|
|
15
17
|
}
|
package/types/filter/errors.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { Recognizer } from '@browsery/antlr4/typings/Recognizer';
|
|
|
3
3
|
export declare class SyntaxError extends TypeError {
|
|
4
4
|
}
|
|
5
5
|
export declare class ValidationError extends TypeError {
|
|
6
|
+
constructor(message?: string | {
|
|
7
|
+
message?: string;
|
|
8
|
+
});
|
|
6
9
|
}
|
|
7
10
|
export declare class FilterParseError extends Error {
|
|
8
11
|
recognizer: Recognizer<any>;
|
package/types/http/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export * from './http-headers.js';
|
|
2
2
|
export * from './http-params.js';
|
|
3
|
-
export * from './http-response-message.js';
|
|
4
|
-
export * from './http-request-message.js';
|
|
5
3
|
export * from './enums/http-headers-codes.enum.js';
|
|
6
4
|
export * from './enums/http-status-codes.enum.js';
|
|
5
|
+
export * from './enums/http-status-messages.js';
|
|
7
6
|
export * from './interfaces/client-http-headers.interface.js';
|
|
8
7
|
export * from './interfaces/server-http-headers.interface.js';
|
|
9
8
|
export * from './codecs/date-codec.js';
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { DataType, DataTypeBase } from './data-type.interface.js';
|
|
2
2
|
export interface EnumType extends DataTypeBase {
|
|
3
3
|
base?: DataType.Name | EnumType;
|
|
4
|
-
values: Record<EnumType.
|
|
5
|
-
meanings?: Record<EnumType.
|
|
4
|
+
values: Record<EnumType.Key, EnumType.Value>;
|
|
5
|
+
meanings?: Record<EnumType.Key, string>;
|
|
6
6
|
}
|
|
7
|
-
export type EnumObject = Record<EnumType.
|
|
7
|
+
export type EnumObject = Record<EnumType.Key, EnumType.Value>;
|
|
8
8
|
export type EnumArray = readonly (string | number)[];
|
|
9
9
|
export type EnumThunk = EnumObject | EnumArray;
|
|
10
10
|
export declare namespace EnumType {
|
|
11
11
|
const Kind = "EnumType";
|
|
12
12
|
type Kind = typeof Kind;
|
|
13
|
-
type
|
|
14
|
-
type
|
|
13
|
+
type Value = string | number;
|
|
14
|
+
type Key = string;
|
|
15
15
|
}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import * as vg from 'valgen';
|
|
2
|
+
import type { DataTypeBase } from './data-type.interface.js';
|
|
3
|
+
import { DataType } from './data-type.interface.js';
|
|
3
4
|
export interface SimpleType extends DataTypeBase {
|
|
4
|
-
ctor?: Type;
|
|
5
5
|
base?: DataType.Name | SimpleType;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
decoder?: vg.Validator<any, any>;
|
|
7
|
+
encoder?: vg.Validator<any, any>;
|
|
8
8
|
}
|
|
9
9
|
export declare namespace SimpleType {
|
|
10
10
|
const Kind = "SimpleType";
|
|
11
11
|
type Kind = 'SimpleType';
|
|
12
|
-
interface Codec {
|
|
13
|
-
decode?: (v: any) => any;
|
|
14
|
-
encode?: (v: any) => any;
|
|
15
|
-
coerce?: (v: any) => any;
|
|
16
|
-
validate?: (v: any) => void;
|
|
17
|
-
}
|
|
18
12
|
}
|
package/types/schema/index.d.ts
CHANGED
|
@@ -1,51 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { DataType as _DataType, DataTypeBase as _DataTypeBase } from './data-type/data-type.interface.js';
|
|
4
|
-
import { EnumArray as _EnumArray, EnumObject as _EnumObject, EnumThunk as _EnumThunk, EnumType as _EnumType } from './data-type/enum-type.interface.js';
|
|
5
|
-
import { Field as _Field } from './data-type/field.interface.js';
|
|
6
|
-
import { MappedType as _MappedType } from './data-type/mapped-type.interface.js';
|
|
7
|
-
import { SimpleType as _SimpleType } from './data-type/simple-type.interface.js';
|
|
8
|
-
import { UnionType as _UnionType } from './data-type/union-type.interface.js';
|
|
9
|
-
import { ApiDocument as _ApiDocument, ContactPerson as _ContactPerson, DocumentInfo as _DocumentInfo, LicenseInfo as _LicenseInfo, ServerInfo as _ServerInfo } from './document.interface.js';
|
|
10
|
-
import { Collection as _Collection } from './resource/collection.interface.js';
|
|
11
|
-
import { Container as _Container } from './resource/container.interface.js';
|
|
12
|
-
import { Endpoint as _Endpoint } from './resource/endpoint.interface.js';
|
|
13
|
-
import { Resource as _Resource, ResourceBase as _ResourceBase } from './resource/resource.interface.js';
|
|
14
|
-
import { Singleton as _Singleton } from './resource/singleton.interface.js';
|
|
15
|
-
import { isCollection as _isCollection, isComplexType as _isComplexType, isContainer as _isContainer, isDataType as _isDataType, isEnumType as _isEnumType, isMappedType as _isMappedType, isResource as _isResource, isSimpleType as _isSimpleType, isSingleton as _isSingleton, isUnionType as _isUnionType } from './type-guards.js';
|
|
16
|
-
export declare namespace OpraSchema {
|
|
17
|
-
const SpecVersion = "1.0";
|
|
18
|
-
type SpecVersion = _SpecVersion;
|
|
19
|
-
type EnumObject = _EnumObject;
|
|
20
|
-
type EnumArray = _EnumArray;
|
|
21
|
-
type EnumThunk = _EnumThunk;
|
|
22
|
-
type ApiDocument = _ApiDocument;
|
|
23
|
-
type ContactPerson = _ContactPerson;
|
|
24
|
-
type ServerInfo = _ServerInfo;
|
|
25
|
-
type LicenseInfo = _LicenseInfo;
|
|
26
|
-
type DocumentInfo = _DocumentInfo;
|
|
27
|
-
type DataTypeBase = _DataTypeBase;
|
|
28
|
-
type ResourceBase = _ResourceBase;
|
|
29
|
-
export import DataType = _DataType;
|
|
30
|
-
export import ComplexType = _ComplexType;
|
|
31
|
-
export import Field = _Field;
|
|
32
|
-
export import EnumType = _EnumType;
|
|
33
|
-
export import MappedType = _MappedType;
|
|
34
|
-
export import SimpleType = _SimpleType;
|
|
35
|
-
export import UnionType = _UnionType;
|
|
36
|
-
export import Resource = _Resource;
|
|
37
|
-
export import Collection = _Collection;
|
|
38
|
-
export import Container = _Container;
|
|
39
|
-
export import Singleton = _Singleton;
|
|
40
|
-
export import Endpoint = _Endpoint;
|
|
41
|
-
const isDataType: typeof _isDataType;
|
|
42
|
-
const isComplexType: typeof _isComplexType;
|
|
43
|
-
const isEnumType: typeof _isEnumType;
|
|
44
|
-
const isMappedType: typeof _isMappedType;
|
|
45
|
-
const isSimpleType: typeof _isSimpleType;
|
|
46
|
-
const isUnionType: typeof _isUnionType;
|
|
47
|
-
const isResource: typeof _isResource;
|
|
48
|
-
const isCollection: typeof _isCollection;
|
|
49
|
-
const isContainer: typeof _isContainer;
|
|
50
|
-
const isSingleton: typeof _isSingleton;
|
|
51
|
-
}
|
|
1
|
+
import * as OpraSchema from './opra-schema.ns.js';
|
|
2
|
+
export { OpraSchema };
|