@opra/common 0.22.0 → 0.23.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.js +957 -1566
- package/cjs/document/api-document.js +7 -3
- package/cjs/document/data-type/api-field.js +2 -2
- package/cjs/document/data-type/complex-type.js +17 -63
- package/cjs/document/data-type/data-type.js +0 -9
- package/cjs/document/data-type/enum-type.js +2 -8
- package/cjs/document/data-type/mapped-type.js +0 -36
- package/cjs/document/data-type/simple-type.js +2 -8
- package/cjs/document/data-type/union-type.js +1 -37
- package/cjs/document/index.js +2 -0
- package/cjs/document/resource/collection.js +75 -32
- package/cjs/document/resource/singleton.js +31 -20
- package/cjs/document/resource/storage.js +6 -20
- package/cjs/document/utils/generate-codec.js +39 -0
- package/cjs/exception/http-errors/bad-request.error.js +2 -3
- package/cjs/exception/http-errors/failed-dependency.error.js +2 -3
- package/cjs/exception/http-errors/forbidden.error.js +2 -3
- package/cjs/exception/http-errors/internal-server.error.js +2 -3
- package/cjs/exception/http-errors/method-not-allowed.error.js +2 -3
- package/cjs/exception/http-errors/not-acceptable.error.js +2 -3
- package/cjs/exception/http-errors/not-found.error.js +2 -3
- package/cjs/exception/http-errors/unauthorized.error.js +2 -3
- package/cjs/exception/http-errors/unprocessable-entity.error.js +2 -2
- package/cjs/exception/opra-exception.js +48 -33
- package/cjs/exception/resource-errors/resource-not-found.error.js +2 -3
- package/cjs/exception/wrap-exception.js +16 -16
- package/cjs/helpers/index.js +1 -1
- package/cjs/helpers/is-url-string.js +14 -0
- package/cjs/helpers/object-utils.js +2 -2
- package/cjs/helpers/responsive-map.js +4 -4
- package/cjs/helpers/type-guards.js +15 -3
- package/cjs/http/index.js +2 -9
- package/cjs/http/opra-url-path.js +251 -0
- package/cjs/{url → http}/opra-url.js +53 -109
- package/cjs/i18n/i18n.js +1 -1
- package/cjs/index.js +0 -2
- package/cjs/schema/opra-schema.ns.js +1 -1
- package/cjs/schema/resource/operation.interface.js +2 -0
- package/esm/document/api-document.js +9 -5
- package/esm/document/data-type/api-field.js +2 -2
- package/esm/document/data-type/complex-type.js +13 -59
- package/esm/document/data-type/data-type.js +0 -9
- package/esm/document/data-type/enum-type.js +2 -8
- package/esm/document/data-type/mapped-type.js +0 -36
- package/esm/document/data-type/simple-type.js +2 -8
- package/esm/document/data-type/union-type.js +1 -37
- package/esm/document/index.js +2 -0
- package/esm/document/resource/collection.js +75 -32
- package/esm/document/resource/singleton.js +31 -20
- package/esm/document/resource/storage.js +6 -20
- package/esm/document/utils/generate-codec.js +33 -0
- package/esm/exception/http-errors/bad-request.error.js +2 -3
- package/esm/exception/http-errors/failed-dependency.error.js +2 -3
- package/esm/exception/http-errors/forbidden.error.js +2 -3
- package/esm/exception/http-errors/internal-server.error.js +2 -3
- package/esm/exception/http-errors/method-not-allowed.error.js +2 -3
- package/esm/exception/http-errors/not-acceptable.error.js +2 -3
- package/esm/exception/http-errors/not-found.error.js +2 -3
- package/esm/exception/http-errors/unauthorized.error.js +2 -3
- package/esm/exception/http-errors/unprocessable-entity.error.js +2 -2
- package/esm/exception/opra-exception.js +47 -32
- package/esm/exception/resource-errors/resource-not-found.error.js +2 -3
- package/esm/exception/wrap-exception.js +16 -16
- package/esm/helpers/index.js +1 -1
- package/esm/helpers/is-url-string.js +9 -0
- package/esm/helpers/object-utils.js +2 -2
- package/esm/helpers/responsive-map.js +4 -4
- package/esm/helpers/type-guards.js +11 -2
- package/esm/http/index.js +2 -9
- package/esm/http/opra-url-path.js +246 -0
- package/esm/{url → http}/opra-url.js +53 -109
- package/esm/i18n/i18n.js +2 -2
- package/esm/index.js +0 -2
- package/esm/schema/opra-schema.ns.js +1 -1
- package/esm/schema/resource/operation.interface.js +1 -0
- package/package.json +5 -5
- package/types/document/api-document.d.ts +4 -1
- package/types/document/data-type/complex-type.d.ts +7 -12
- package/types/document/data-type/data-type.d.ts +0 -6
- package/types/document/data-type/enum-type.d.ts +2 -4
- package/types/document/data-type/mapped-type.d.ts +1 -5
- package/types/document/data-type/simple-type.d.ts +2 -4
- package/types/document/data-type/union-type.d.ts +1 -5
- package/types/document/index.d.ts +2 -0
- package/types/document/interfaces/collection-resource.interface.d.ts +10 -0
- package/types/document/interfaces/singleton-resource.interface.d.ts +7 -0
- package/types/document/interfaces/storage-resource.interface.d.ts +8 -0
- package/types/document/resource/collection.d.ts +41 -35
- package/types/document/resource/resource.d.ts +1 -0
- package/types/document/resource/singleton.d.ts +24 -21
- package/types/document/resource/storage.d.ts +14 -17
- package/types/document/utils/generate-codec.d.ts +10 -0
- package/types/exception/error-issue.d.ts +2 -1
- package/types/exception/http-errors/bad-request.error.d.ts +2 -1
- package/types/exception/http-errors/failed-dependency.error.d.ts +2 -1
- package/types/exception/http-errors/forbidden.error.d.ts +2 -1
- package/types/exception/http-errors/internal-server.error.d.ts +2 -1
- package/types/exception/http-errors/method-not-allowed.error.d.ts +2 -1
- package/types/exception/http-errors/not-acceptable.error.d.ts +2 -1
- package/types/exception/http-errors/not-found.error.d.ts +2 -1
- package/types/exception/http-errors/unauthorized.error.d.ts +2 -1
- package/types/exception/http-errors/unprocessable-entity.error.d.ts +2 -1
- package/types/exception/opra-exception.d.ts +13 -8
- package/types/exception/wrap-exception.d.ts +1 -1
- package/types/helpers/index.d.ts +1 -1
- package/types/helpers/is-url-string.d.ts +2 -0
- package/types/helpers/object-utils.d.ts +1 -1
- package/types/helpers/type-guards.d.ts +3 -0
- package/types/http/index.d.ts +2 -9
- package/types/http/opra-url-path.d.ts +54 -0
- package/types/{url → http}/opra-url.d.ts +9 -13
- package/types/index.d.ts +0 -2
- package/types/schema/data-type/complex-type.interface.d.ts +1 -1
- package/types/schema/opra-schema.ns.d.ts +1 -1
- package/types/schema/resource/collection.interface.d.ts +29 -8
- package/types/schema/resource/operation.interface.d.ts +3 -0
- package/types/schema/resource/singleton.interface.d.ts +5 -5
- package/types/schema/resource/storage.interface.d.ts +42 -5
- package/cjs/helpers/is-url.js +0 -8
- package/cjs/http/codecs/boolean-codec.js +0 -24
- package/cjs/http/codecs/date-codec.js +0 -41
- package/cjs/http/codecs/filter-codec.js +0 -17
- package/cjs/http/codecs/integer-codec.js +0 -19
- package/cjs/http/codecs/number-codec.js +0 -24
- package/cjs/http/codecs/string-codec.js +0 -23
- package/cjs/http/http-params.js +0 -353
- package/cjs/http/multipart/batch-multipart.js +0 -170
- package/cjs/http/multipart/http-request-content.js +0 -17
- package/cjs/http/multipart/http-response-content.js +0 -14
- package/cjs/http/multipart/index.js +0 -2
- package/cjs/url/index.js +0 -8
- package/cjs/url/opra-url-path-component.js +0 -30
- package/cjs/url/opra-url-path.js +0 -155
- package/cjs/url/utils/decode-path-component.js +0 -41
- package/cjs/url/utils/encode-path-component.js +0 -27
- package/cjs/utils/path-utils.js +0 -24
- package/esm/helpers/is-url.js +0 -4
- package/esm/http/codecs/boolean-codec.js +0 -20
- package/esm/http/codecs/date-codec.js +0 -37
- package/esm/http/codecs/filter-codec.js +0 -13
- package/esm/http/codecs/integer-codec.js +0 -15
- package/esm/http/codecs/number-codec.js +0 -20
- package/esm/http/codecs/string-codec.js +0 -19
- package/esm/http/http-params.js +0 -348
- package/esm/http/multipart/batch-multipart.js +0 -170
- package/esm/http/multipart/http-request-content.js +0 -17
- package/esm/http/multipart/http-response-content.js +0 -14
- package/esm/http/multipart/index.js +0 -2
- package/esm/url/index.js +0 -5
- package/esm/url/opra-url-path-component.js +0 -26
- package/esm/url/opra-url-path.js +0 -151
- package/esm/url/utils/decode-path-component.js +0 -37
- package/esm/url/utils/encode-path-component.js +0 -22
- package/esm/utils/path-utils.js +0 -19
- package/types/helpers/is-url.d.ts +0 -1
- package/types/http/codecs/boolean-codec.d.ts +0 -5
- package/types/http/codecs/date-codec.d.ts +0 -16
- package/types/http/codecs/filter-codec.d.ts +0 -6
- package/types/http/codecs/integer-codec.d.ts +0 -11
- package/types/http/codecs/number-codec.d.ts +0 -14
- package/types/http/codecs/string-codec.d.ts +0 -16
- package/types/http/http-params.d.ts +0 -114
- package/types/http/interfaces/client-http-headers.interface.d.ts +0 -65
- package/types/http/interfaces/server-http-headers.interface.d.ts +0 -1
- package/types/http/multipart/batch-multipart.d.ts +0 -0
- package/types/http/multipart/http-request-content.d.ts +0 -0
- package/types/http/multipart/http-response-content.d.ts +0 -0
- package/types/http/multipart/index.d.ts +0 -0
- package/types/schema/resource/endpoint.interface.d.ts +0 -29
- package/types/url/index.d.ts +0 -5
- package/types/url/opra-url-path-component.d.ts +0 -15
- package/types/url/opra-url-path.d.ts +0 -36
- package/types/url/utils/decode-path-component.d.ts +0 -5
- package/types/url/utils/encode-path-component.d.ts +0 -1
- package/types/utils/path-utils.d.ts +0 -2
- /package/cjs/{http/interfaces/client-http-headers.interface.js → document/interfaces/collection-resource.interface.js} +0 -0
- /package/cjs/{http/interfaces/server-http-headers.interface.js → document/interfaces/singleton-resource.interface.js} +0 -0
- /package/cjs/{schema/resource/endpoint.interface.js → document/interfaces/storage-resource.interface.js} +0 -0
- /package/esm/{http/interfaces/client-http-headers.interface.js → document/interfaces/collection-resource.interface.js} +0 -0
- /package/esm/{http/interfaces/server-http-headers.interface.js → document/interfaces/singleton-resource.interface.js} +0 -0
- /package/esm/{schema/resource/endpoint.interface.js → document/interfaces/storage-resource.interface.js} +0 -0
|
@@ -16,6 +16,7 @@ export declare abstract class Resource {
|
|
|
16
16
|
readonly name: string;
|
|
17
17
|
readonly description?: string;
|
|
18
18
|
readonly controller?: object | Type;
|
|
19
|
+
abstract readonly operations: Record<string, any>;
|
|
19
20
|
protected constructor(document: ApiDocument, init: Resource.InitArguments);
|
|
20
21
|
exportSchema(): OpraSchema.ResourceBase;
|
|
21
22
|
toString(): string;
|
|
@@ -1,51 +1,54 @@
|
|
|
1
1
|
import { StrictOmit, Type } from 'ts-gems';
|
|
2
|
+
import * as vg from 'valgen';
|
|
2
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
4
|
import type { TypeThunkAsync } from '../../types.js';
|
|
4
5
|
import type { ApiDocument } from '../api-document.js';
|
|
5
6
|
import { ComplexType } from '../data-type/complex-type.js';
|
|
6
7
|
import { Resource } from './resource.js';
|
|
7
8
|
export declare namespace Singleton {
|
|
8
|
-
|
|
9
|
+
interface InitArguments extends Resource.InitArguments, StrictOmit<OpraSchema.Singleton, 'kind' | 'type'> {
|
|
9
10
|
type: ComplexType;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
interface DecoratorOptions extends Resource.DecoratorOptions {
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
interface Metadata extends StrictOmit<OpraSchema.Singleton, 'type'> {
|
|
14
15
|
name: string;
|
|
15
16
|
type: TypeThunkAsync | string;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
handlerName?: string;
|
|
18
|
+
namespace Create {
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
create?: OpraSchema.Singleton.CreateOperation & Operation;
|
|
22
|
-
delete?: OpraSchema.Singleton.DeleteOperation & Operation;
|
|
23
|
-
get?: OpraSchema.Singleton.GetOperation & Operation;
|
|
24
|
-
update?: OpraSchema.Singleton.UpdateOperation & Operation;
|
|
20
|
+
namespace Delete {
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
namespace Get {
|
|
23
|
+
}
|
|
24
|
+
namespace Update {
|
|
25
|
+
}
|
|
26
|
+
type CreateOperationOptions = OpraSchema.Singleton.CreateOperation;
|
|
27
|
+
type DeleteOperationOptions = OpraSchema.Singleton.DeleteOperation;
|
|
28
|
+
type GetOperationOptions = OpraSchema.Singleton.GetOperation;
|
|
29
|
+
type UpdateOperationOptions = OpraSchema.Singleton.UpdateOperation;
|
|
31
30
|
}
|
|
32
31
|
declare class SingletonClass extends Resource {
|
|
32
|
+
private _decoders;
|
|
33
|
+
private _encoders;
|
|
33
34
|
readonly type: ComplexType;
|
|
34
35
|
readonly kind = "Singleton";
|
|
35
|
-
readonly operations: Singleton.Operations;
|
|
36
|
+
readonly operations: OpraSchema.Singleton.Operations;
|
|
36
37
|
readonly controller?: object | Type;
|
|
37
38
|
constructor(document: ApiDocument, init: Singleton.InitArguments);
|
|
38
39
|
exportSchema(): OpraSchema.Singleton;
|
|
39
|
-
normalizeFieldPath(this: Singleton, path: string | []): string |
|
|
40
|
+
normalizeFieldPath(this: Singleton, path: string | string[]): string[] | undefined;
|
|
41
|
+
getDecoder(operation: keyof OpraSchema.Singleton.Operations): vg.Validator<any, any>;
|
|
42
|
+
getEncoder(operation: keyof OpraSchema.Singleton.Operations): vg.Validator<any, any>;
|
|
40
43
|
}
|
|
41
44
|
export interface SingletonConstructor {
|
|
42
45
|
prototype: Singleton;
|
|
43
46
|
new (document: ApiDocument, init: Singleton.InitArguments): Singleton;
|
|
44
47
|
(type: TypeThunkAsync | string, options?: Singleton.DecoratorOptions): ClassDecorator;
|
|
45
|
-
Create: (options?: Singleton.CreateOperationOptions) =>
|
|
46
|
-
Delete: (options?: Singleton.DeleteOperationOptions) =>
|
|
47
|
-
Get: (options?: Singleton.GetOperationOptions) =>
|
|
48
|
-
Update: (options?: Singleton.UpdateOperationOptions) =>
|
|
48
|
+
Create: (options?: Singleton.CreateOperationOptions) => ((target: Object, propertyKey: 'create') => void);
|
|
49
|
+
Delete: (options?: Singleton.DeleteOperationOptions) => ((target: Object, propertyKey: 'delete') => void);
|
|
50
|
+
Get: (options?: Singleton.GetOperationOptions) => ((target: Object, propertyKey: 'get') => void);
|
|
51
|
+
Update: (options?: Singleton.UpdateOperationOptions) => ((target: Object, propertyKey: 'update') => void);
|
|
49
52
|
}
|
|
50
53
|
export interface Singleton extends SingletonClass {
|
|
51
54
|
}
|
|
@@ -3,29 +3,26 @@ import { OpraSchema } from '../../schema/index.js';
|
|
|
3
3
|
import type { ApiDocument } from '../api-document.js';
|
|
4
4
|
import { Resource } from './resource.js';
|
|
5
5
|
export declare namespace Storage {
|
|
6
|
-
|
|
6
|
+
interface InitArguments extends Resource.InitArguments, StrictOmit<OpraSchema.Storage, 'kind'> {
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
interface DecoratorOptions extends Resource.DecoratorOptions {
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
interface Metadata extends OpraSchema.Storage {
|
|
11
11
|
name: string;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
handlerName?: string;
|
|
13
|
+
namespace Delete {
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
delete?: OpraSchema.Storage.DeleteOperation & Operation;
|
|
18
|
-
get?: OpraSchema.Storage.GetOperation & Operation;
|
|
19
|
-
put?: OpraSchema.Storage.PutOperation & Operation;
|
|
15
|
+
namespace Get {
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
namespace Post {
|
|
18
|
+
}
|
|
19
|
+
type DeleteOperationOptions = OpraSchema.Storage.DeleteOperation;
|
|
20
|
+
type GetOperationOptions = OpraSchema.Storage.GetOperation;
|
|
21
|
+
type PostOperationOptions = OpraSchema.Storage.PostOperation;
|
|
25
22
|
}
|
|
26
23
|
declare class StorageClass extends Resource {
|
|
27
24
|
readonly kind = "Storage";
|
|
28
|
-
readonly operations: Storage.Operations;
|
|
25
|
+
readonly operations: OpraSchema.Storage.Operations;
|
|
29
26
|
readonly controller?: object | Type;
|
|
30
27
|
constructor(document: ApiDocument, init: Storage.InitArguments);
|
|
31
28
|
exportSchema(): OpraSchema.Storage;
|
|
@@ -34,9 +31,9 @@ export interface StorageConstructor {
|
|
|
34
31
|
prototype: Storage;
|
|
35
32
|
new (document: ApiDocument, init: Storage.InitArguments): Storage;
|
|
36
33
|
(options?: Storage.DecoratorOptions): ClassDecorator;
|
|
37
|
-
Delete: (options?: Storage.DeleteOperationOptions) =>
|
|
38
|
-
Get: (options?: Storage.GetOperationOptions) =>
|
|
39
|
-
|
|
34
|
+
Delete: (options?: Storage.DeleteOperationOptions) => ((target: Object, propertyKey: 'delete') => void);
|
|
35
|
+
Get: (options?: Storage.GetOperationOptions) => ((target: Object, propertyKey: 'get') => void);
|
|
36
|
+
Post: (options?: Storage.PostOperationOptions) => ((target: Object, propertyKey: 'post') => void);
|
|
40
37
|
}
|
|
41
38
|
export interface Storage extends StorageClass {
|
|
42
39
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as vg from 'valgen';
|
|
2
|
+
import { ComplexType } from '../data-type/complex-type.js';
|
|
3
|
+
import { MappedType } from '../data-type/mapped-type.js';
|
|
4
|
+
import { UnionType } from '../data-type/union-type.js';
|
|
5
|
+
export interface GenerateDecoderOptions {
|
|
6
|
+
omit?: string[];
|
|
7
|
+
partial?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function generateCodec(type: ComplexType, codec: 'decode' | 'encode', options: GenerateDecoderOptions): vg.Validator<any, any>;
|
|
10
|
+
export declare function _generateDecoder(type: ComplexType | MappedType | UnionType, codec: 'decode' | 'encode', options: GenerateDecoderOptions): vg.Validator<any, any>;
|
|
@@ -2,8 +2,9 @@ import { IssueSeverity } from './issue-severity.enum.js';
|
|
|
2
2
|
export interface ErrorIssue {
|
|
3
3
|
message: string;
|
|
4
4
|
severity: IssueSeverity.Type;
|
|
5
|
+
system?: string;
|
|
5
6
|
code?: string;
|
|
6
7
|
details?: any;
|
|
7
8
|
diagnostics?: string | string[];
|
|
8
|
-
|
|
9
|
+
stack?: string[];
|
|
9
10
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorIssue } from '../error-issue.js';
|
|
1
2
|
import { OpraException } from '../opra-exception.js';
|
|
2
3
|
/**
|
|
3
4
|
* 400 Bad Request
|
|
@@ -6,5 +7,5 @@ import { OpraException } from '../opra-exception.js';
|
|
|
6
7
|
*/
|
|
7
8
|
export declare class BadRequestError extends OpraException {
|
|
8
9
|
status: number;
|
|
9
|
-
|
|
10
|
+
protected init(issue: Partial<ErrorIssue>): void;
|
|
10
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorIssue } from '../error-issue.js';
|
|
1
2
|
import { OpraException } from '../opra-exception.js';
|
|
2
3
|
/**
|
|
3
4
|
* 424 Failed Dependency
|
|
@@ -5,5 +6,5 @@ import { OpraException } from '../opra-exception.js';
|
|
|
5
6
|
*/
|
|
6
7
|
export declare class FailedDependencyError extends OpraException {
|
|
7
8
|
status: number;
|
|
8
|
-
|
|
9
|
+
protected init(issue: Partial<ErrorIssue>): void;
|
|
9
10
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorIssue } from '../error-issue.js';
|
|
1
2
|
import { OpraException } from '../opra-exception.js';
|
|
2
3
|
/**
|
|
3
4
|
* 403 Forbidden
|
|
@@ -7,5 +8,5 @@ import { OpraException } from '../opra-exception.js';
|
|
|
7
8
|
*/
|
|
8
9
|
export declare class ForbiddenError extends OpraException {
|
|
9
10
|
status: number;
|
|
10
|
-
|
|
11
|
+
protected init(issue: Partial<ErrorIssue>): void;
|
|
11
12
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorIssue } from '../error-issue.js';
|
|
1
2
|
import { OpraException } from '../opra-exception.js';
|
|
2
3
|
/**
|
|
3
4
|
* 500 Internal Server Error
|
|
@@ -5,5 +6,5 @@ import { OpraException } from '../opra-exception.js';
|
|
|
5
6
|
*/
|
|
6
7
|
export declare class InternalServerError extends OpraException {
|
|
7
8
|
status: number;
|
|
8
|
-
|
|
9
|
+
protected init(issue: Partial<ErrorIssue>): void;
|
|
9
10
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorIssue } from '../error-issue.js';
|
|
1
2
|
import { OpraException } from '../opra-exception.js';
|
|
2
3
|
/**
|
|
3
4
|
* 405 Method Not Allowed
|
|
@@ -6,5 +7,5 @@ import { OpraException } from '../opra-exception.js';
|
|
|
6
7
|
*/
|
|
7
8
|
export declare class MethodNotAllowedError extends OpraException {
|
|
8
9
|
status: number;
|
|
9
|
-
|
|
10
|
+
protected init(issue: Partial<ErrorIssue>): void;
|
|
10
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorIssue } from '../error-issue.js';
|
|
1
2
|
import { OpraException } from '../opra-exception.js';
|
|
2
3
|
/**
|
|
3
4
|
* 406 Not Acceptable
|
|
@@ -6,5 +7,5 @@ import { OpraException } from '../opra-exception.js';
|
|
|
6
7
|
*/
|
|
7
8
|
export declare class NotAcceptableError extends OpraException {
|
|
8
9
|
status: number;
|
|
9
|
-
|
|
10
|
+
protected init(issue: Partial<ErrorIssue>): void;
|
|
10
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorIssue } from '../error-issue.js';
|
|
1
2
|
import { OpraException } from '../opra-exception.js';
|
|
2
3
|
/**
|
|
3
4
|
* 404 Not Found
|
|
@@ -9,5 +10,5 @@ import { OpraException } from '../opra-exception.js';
|
|
|
9
10
|
*/
|
|
10
11
|
export declare class NotFoundError extends OpraException {
|
|
11
12
|
status: number;
|
|
12
|
-
|
|
13
|
+
protected init(issue: Partial<ErrorIssue>): void;
|
|
13
14
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorIssue } from '../error-issue.js';
|
|
1
2
|
import { OpraException } from '../opra-exception.js';
|
|
2
3
|
/**
|
|
3
4
|
* 401 Unauthorized
|
|
@@ -6,5 +7,5 @@ import { OpraException } from '../opra-exception.js';
|
|
|
6
7
|
*/
|
|
7
8
|
export declare class UnauthorizedError extends OpraException {
|
|
8
9
|
status: number;
|
|
9
|
-
|
|
10
|
+
protected init(issue: Partial<ErrorIssue>): void;
|
|
10
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorIssue } from '../error-issue.js';
|
|
1
2
|
import { OpraException } from '../opra-exception.js';
|
|
2
3
|
/**
|
|
3
4
|
* 422 Unprocessable Entity
|
|
@@ -5,5 +6,5 @@ import { OpraException } from '../opra-exception.js';
|
|
|
5
6
|
*/
|
|
6
7
|
export declare class UnprocessableEntityError extends OpraException {
|
|
7
8
|
status: number;
|
|
8
|
-
|
|
9
|
+
protected init(issue: Partial<ErrorIssue>): void;
|
|
9
10
|
}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { ErrorIssue } from './error-issue.js';
|
|
2
|
+
import { IssueSeverity } from './issue-severity.enum.js';
|
|
2
3
|
/**
|
|
3
4
|
* Defines the base Opra exception, which is handled by the default Exceptions Handler.
|
|
4
5
|
*/
|
|
5
6
|
export declare class OpraException extends Error {
|
|
6
|
-
protected _issue: ErrorIssue;
|
|
7
|
-
status: number;
|
|
8
7
|
cause?: Error;
|
|
8
|
+
status: number;
|
|
9
|
+
severity: IssueSeverity.Type;
|
|
10
|
+
system?: string;
|
|
11
|
+
code?: string;
|
|
12
|
+
details?: any;
|
|
9
13
|
constructor();
|
|
10
|
-
constructor(issue: string | Partial<ErrorIssue> | Error);
|
|
11
|
-
constructor(issue: string | Partial<ErrorIssue>, cause?: Error);
|
|
12
|
-
get issue(): ErrorIssue;
|
|
13
|
-
setIssue(issue: Partial<ErrorIssue>): void;
|
|
14
|
+
constructor(issue: string | Partial<ErrorIssue> | Error, status?: number);
|
|
15
|
+
constructor(issue: string | Partial<ErrorIssue>, cause?: Error, status?: number);
|
|
14
16
|
setStatus(status: number): this;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
toString(): string;
|
|
18
|
+
toJSON(): ErrorIssue;
|
|
19
|
+
protected init(issue: Partial<ErrorIssue>): void;
|
|
20
|
+
protected initString(issue: string): void;
|
|
21
|
+
protected initError(issue: Error): void;
|
|
17
22
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { OpraException } from './opra-exception.js';
|
|
2
|
-
export declare function wrapException(
|
|
2
|
+
export declare function wrapException(error: any): OpraException;
|
package/types/helpers/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function cloneObject<T extends {}>(obj: T, jsonOnly?: boolean): T;
|
|
2
|
-
export declare function omitUndefined(obj:
|
|
2
|
+
export declare function omitUndefined<T>(obj: T, recursive?: boolean): T;
|
|
@@ -5,7 +5,10 @@ import { Type } from 'ts-gems';
|
|
|
5
5
|
export declare function isConstructor(fn: any): fn is Type;
|
|
6
6
|
export declare function isStream(stream: any): boolean;
|
|
7
7
|
export declare function isReadable(x: any): x is Readable;
|
|
8
|
+
export declare function isWritable(x: any): x is Readable;
|
|
8
9
|
export declare function isReadableStream(x: any): x is ReadableStream;
|
|
9
10
|
export declare function isBlob(x: any): x is Blob;
|
|
10
11
|
export declare function isFormData(x: any): x is FormData;
|
|
11
12
|
export declare function isURL(x: any): x is URL;
|
|
13
|
+
export declare function isIterable<T = unknown>(x: any): x is Iterable<T>;
|
|
14
|
+
export declare function isAsyncIterable<T = unknown>(x: any): x is AsyncIterableIterator<T>;
|
package/types/http/index.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './opra-url.js';
|
|
2
|
+
export * from './opra-url-path.js';
|
|
2
3
|
export * from './enums/http-headers-codes.enum.js';
|
|
3
4
|
export * from './enums/http-status-codes.enum.js';
|
|
4
5
|
export * from './enums/http-status-messages.js';
|
|
5
|
-
export * from './interfaces/client-http-headers.interface.js';
|
|
6
|
-
export * from './interfaces/server-http-headers.interface.js';
|
|
7
|
-
export * from './codecs/date-codec.js';
|
|
8
|
-
export * from './codecs/boolean-codec.js';
|
|
9
|
-
export * from './codecs/filter-codec.js';
|
|
10
|
-
export * from './codecs/integer-codec.js';
|
|
11
|
-
export * from './codecs/number-codec.js';
|
|
12
|
-
export * from './codecs/string-codec.js';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
declare const nodeInspectCustom: unique symbol;
|
|
2
|
+
declare const kLength: unique symbol;
|
|
3
|
+
type ResourceKey = Record<string, string | number | boolean | null>;
|
|
4
|
+
/**
|
|
5
|
+
* @class OpraURLPath
|
|
6
|
+
*/
|
|
7
|
+
export declare class OpraURLPath {
|
|
8
|
+
protected [kLength]: number;
|
|
9
|
+
[index: number]: OpraURLPathComponent;
|
|
10
|
+
constructor(...init: (OpraURLPath.ComponentLike | null | undefined)[]);
|
|
11
|
+
get length(): number;
|
|
12
|
+
resolve(...items: OpraURLPath.ComponentLike[]): this;
|
|
13
|
+
join(...items: OpraURLPath.ComponentLike[]): OpraURLPath;
|
|
14
|
+
isRelativeTo(basePath: string | OpraURLPath): boolean;
|
|
15
|
+
forEach(callback: (component: OpraURLPathComponent, index: number, _this: this) => void): void;
|
|
16
|
+
values(): IterableIterator<OpraURLPathComponent>;
|
|
17
|
+
toString(): string;
|
|
18
|
+
[nodeInspectCustom](): string;
|
|
19
|
+
[Symbol.iterator](): IterableIterator<OpraURLPathComponent>;
|
|
20
|
+
protected _resolve(items: OpraURLPath.ComponentLike | OpraURLPath.ComponentLike[], join?: boolean): void;
|
|
21
|
+
static join(...items: OpraURLPath.ComponentLike[]): OpraURLPath;
|
|
22
|
+
static resolve(...items: OpraURLPath.ComponentLike[]): OpraURLPath;
|
|
23
|
+
static relative(source: string | OpraURLPath, basePath: string | OpraURLPath): OpraURLPath | undefined;
|
|
24
|
+
}
|
|
25
|
+
export declare namespace OpraURLPath {
|
|
26
|
+
type ComponentLike = string | OpraURLPath | OpraURLPathComponent | OpraURLPathComponent.Initiator;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @class OpraURLPathComponent
|
|
31
|
+
*/
|
|
32
|
+
declare class OpraURLPathComponent {
|
|
33
|
+
resource: string;
|
|
34
|
+
key?: string | number | ResourceKey;
|
|
35
|
+
args?: Record<string, any>;
|
|
36
|
+
typeCast?: string;
|
|
37
|
+
constructor(init: OpraURLPathComponent.Initiator);
|
|
38
|
+
toString(): string;
|
|
39
|
+
[nodeInspectCustom](): string;
|
|
40
|
+
/**
|
|
41
|
+
* Factory method.
|
|
42
|
+
* @param input
|
|
43
|
+
*/
|
|
44
|
+
static parse(input: string): OpraURLPathComponent;
|
|
45
|
+
}
|
|
46
|
+
export declare namespace OpraURLPathComponent {
|
|
47
|
+
interface Initiator {
|
|
48
|
+
resource: string;
|
|
49
|
+
key?: string | number | ResourceKey;
|
|
50
|
+
args?: Record<string, any>;
|
|
51
|
+
typeCast?: string;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import { HttpParams } from '../http/index.js';
|
|
2
1
|
import { OpraURLPath } from './opra-url-path.js';
|
|
3
|
-
import { OpraURLPathComponentInit } from './opra-url-path-component.js';
|
|
4
2
|
declare const nodeInspectCustom: unique symbol;
|
|
5
3
|
declare const kContext: unique symbol;
|
|
6
4
|
declare const kPath: unique symbol;
|
|
7
|
-
declare const
|
|
5
|
+
declare const kSearchParams: unique symbol;
|
|
8
6
|
export declare class OpraURL {
|
|
9
7
|
protected static kContext: symbol;
|
|
10
8
|
protected static kPath: symbol;
|
|
11
9
|
protected static kParams: symbol;
|
|
12
10
|
protected [kPath]: OpraURLPath;
|
|
13
|
-
protected [
|
|
11
|
+
protected [kSearchParams]: URLSearchParams;
|
|
14
12
|
protected [kContext]: {
|
|
15
13
|
protocol: string;
|
|
16
14
|
username: string;
|
|
17
15
|
pathname?: string;
|
|
18
|
-
prefix: string;
|
|
19
16
|
hostname: string;
|
|
20
17
|
port: string;
|
|
21
18
|
hash: string;
|
|
22
19
|
password: string;
|
|
23
|
-
search?: string;
|
|
24
20
|
address?: string;
|
|
25
21
|
};
|
|
26
22
|
constructor(input?: string | URL | OpraURL, base?: string | URL | OpraURL);
|
|
@@ -34,24 +30,26 @@ export declare class OpraURL {
|
|
|
34
30
|
set password(v: string);
|
|
35
31
|
get port(): string;
|
|
36
32
|
set port(value: string | number);
|
|
37
|
-
get prefix(): string;
|
|
38
|
-
set prefix(value: string);
|
|
39
33
|
get protocol(): string;
|
|
40
34
|
set protocol(v: string);
|
|
41
35
|
get username(): string;
|
|
42
36
|
set username(v: string);
|
|
43
37
|
get origin(): string;
|
|
44
38
|
get path(): OpraURLPath;
|
|
39
|
+
set path(path: OpraURLPath);
|
|
45
40
|
get pathname(): string;
|
|
46
41
|
set pathname(v: string);
|
|
47
42
|
get hash(): string;
|
|
48
43
|
set hash(v: string);
|
|
49
44
|
get search(): string;
|
|
50
45
|
set search(v: string);
|
|
51
|
-
get searchParams():
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
get searchParams(): URLSearchParams;
|
|
47
|
+
set setSearchParams(v: URLSearchParams);
|
|
48
|
+
invalidate(): void;
|
|
49
|
+
join(...items: OpraURLPath.ComponentLike[]): this;
|
|
50
|
+
resolve(...items: OpraURLPath.ComponentLike[]): OpraURL;
|
|
54
51
|
toString(): string;
|
|
52
|
+
protected _parse(input: string): void;
|
|
55
53
|
[nodeInspectCustom](): {
|
|
56
54
|
protocol: string;
|
|
57
55
|
username: string;
|
|
@@ -59,12 +57,10 @@ export declare class OpraURL {
|
|
|
59
57
|
host: string;
|
|
60
58
|
hostname: string;
|
|
61
59
|
origin: string;
|
|
62
|
-
pathPrefix: string;
|
|
63
60
|
path: OpraURLPath;
|
|
64
61
|
pathname: string;
|
|
65
62
|
search: string;
|
|
66
63
|
hash: string;
|
|
67
64
|
};
|
|
68
|
-
protected _setPathname(v: string, trimPrefix?: boolean): void;
|
|
69
65
|
}
|
|
70
66
|
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface ComplexType extends DataTypeBase {
|
|
|
8
8
|
base?: DataType.Name | ComplexType | UnionType | MappedType;
|
|
9
9
|
abstract?: boolean;
|
|
10
10
|
fields?: Record<Field.Name, Field | DataType.Name>;
|
|
11
|
-
additionalFields?: boolean;
|
|
11
|
+
additionalFields?: boolean | 'error';
|
|
12
12
|
}
|
|
13
13
|
export declare namespace ComplexType {
|
|
14
14
|
const Kind = "ComplexType";
|
|
@@ -7,7 +7,7 @@ export * from './data-type/mapped-type.interface.js';
|
|
|
7
7
|
export * from './data-type/union-type.interface.js';
|
|
8
8
|
export * from './resource/collection.interface.js';
|
|
9
9
|
export * from './resource/container.interface.js';
|
|
10
|
-
export * from './resource/
|
|
10
|
+
export * from './resource/operation.interface.js';
|
|
11
11
|
export * from './resource/resource.interface.js';
|
|
12
12
|
export * from './resource/singleton.interface.js';
|
|
13
13
|
export * from './resource/storage.interface.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { OpraFilter } from '../../filter/index.js';
|
|
1
2
|
import type { DataType } from '../data-type/data-type.interface.js';
|
|
2
3
|
import type { Field } from '../data-type/field.interface';
|
|
3
|
-
import type {
|
|
4
|
+
import type { Operation } from './operation.interface';
|
|
4
5
|
import type { ResourceBase } from './resource.interface.js';
|
|
5
6
|
export interface Collection extends ResourceBase {
|
|
6
7
|
kind: Collection.Kind;
|
|
@@ -11,16 +12,16 @@ export interface Collection extends ResourceBase {
|
|
|
11
12
|
export declare namespace Collection {
|
|
12
13
|
const Kind = "Collection";
|
|
13
14
|
type Kind = 'Collection';
|
|
14
|
-
type CreateOperation =
|
|
15
|
-
type DeleteOperation =
|
|
16
|
-
type DeleteManyOperation =
|
|
17
|
-
type GetOperation =
|
|
18
|
-
type FindManyOperation =
|
|
15
|
+
type CreateOperation = Operation & _OperationInput & _OperationResponse;
|
|
16
|
+
type DeleteOperation = Operation;
|
|
17
|
+
type DeleteManyOperation = Operation & _OperationFilter;
|
|
18
|
+
type GetOperation = Operation & _OperationResponse;
|
|
19
|
+
type FindManyOperation = Operation & _OperationFilter & _OperationResponse & {
|
|
19
20
|
sortFields?: string[];
|
|
20
21
|
defaultSort?: string[];
|
|
21
22
|
};
|
|
22
|
-
type UpdateOperation =
|
|
23
|
-
type UpdateManyOperation =
|
|
23
|
+
type UpdateOperation = Operation & _OperationInput & _OperationResponse;
|
|
24
|
+
type UpdateManyOperation = Operation & _OperationInput & _OperationFilter;
|
|
24
25
|
interface Operations {
|
|
25
26
|
create?: CreateOperation;
|
|
26
27
|
delete?: DeleteOperation;
|
|
@@ -31,3 +32,23 @@ export declare namespace Collection {
|
|
|
31
32
|
updateMany?: UpdateManyOperation;
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
interface _OperationFilter {
|
|
36
|
+
filters?: {
|
|
37
|
+
field: Field.QualifiedName;
|
|
38
|
+
operators?: OpraFilter.ComparisonOperator[];
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
41
|
+
interface _OperationInput {
|
|
42
|
+
input?: {
|
|
43
|
+
maxContentSize?: number | string;
|
|
44
|
+
pick?: Field.QualifiedName[];
|
|
45
|
+
omit?: Field.QualifiedName[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
interface _OperationResponse {
|
|
49
|
+
response?: {
|
|
50
|
+
pick?: Field.QualifiedName[];
|
|
51
|
+
omit?: Field.QualifiedName[];
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../data-type/data-type.interface.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Collection } from './collection.interface.js';
|
|
3
3
|
import type { ResourceBase } from './resource.interface.js';
|
|
4
4
|
export interface Singleton extends ResourceBase {
|
|
5
5
|
kind: Singleton.Kind;
|
|
@@ -9,10 +9,10 @@ export interface Singleton extends ResourceBase {
|
|
|
9
9
|
export declare namespace Singleton {
|
|
10
10
|
const Kind = "Singleton";
|
|
11
11
|
type Kind = 'Singleton';
|
|
12
|
-
type CreateOperation =
|
|
13
|
-
type DeleteOperation =
|
|
14
|
-
type GetOperation =
|
|
15
|
-
type UpdateOperation =
|
|
12
|
+
type CreateOperation = Collection.CreateOperation;
|
|
13
|
+
type DeleteOperation = Collection.DeleteOperation;
|
|
14
|
+
type GetOperation = Collection.GetOperation;
|
|
15
|
+
type UpdateOperation = Collection.UpdateOperation;
|
|
16
16
|
interface Operations {
|
|
17
17
|
create?: CreateOperation;
|
|
18
18
|
delete?: DeleteOperation;
|