@opra/client 0.11.2 → 0.11.4
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/package.json +23 -2
- package/typings/client-error.d.ts +1 -1
- package/typings/common/constants.d.ts +0 -0
- package/typings/common/exception/enums/issue-severity.enum.d.ts +13 -0
- package/typings/common/exception/error-issue.d.ts +9 -0
- package/typings/common/exception/http-errors/bad-request.error.d.ts +10 -0
- package/typings/common/exception/http-errors/failed-dependency.error.d.ts +9 -0
- package/typings/common/exception/http-errors/forbidden.error.d.ts +11 -0
- package/typings/common/exception/http-errors/internal-server.error.d.ts +9 -0
- package/typings/common/exception/http-errors/method-not-allowed.error.d.ts +10 -0
- package/typings/common/exception/http-errors/not-acceptable.error.d.ts +10 -0
- package/typings/common/exception/http-errors/not-found.error.d.ts +13 -0
- package/typings/common/exception/http-errors/unauthorized.error.d.ts +10 -0
- package/typings/common/exception/http-errors/unprocessable-entity.error.d.ts +9 -0
- package/typings/common/exception/index.d.ts +15 -0
- package/typings/common/exception/opra-exception.d.ts +15 -0
- package/typings/common/exception/resource-errors/resource-conflict.error.d.ts +5 -0
- package/typings/common/exception/resource-errors/resource-not-found.error.d.ts +4 -0
- package/typings/common/exception/wrap-exception.d.ts +2 -0
- package/typings/common/filter/antlr/OpraFilterLexer.d.ts +77 -0
- package/typings/common/filter/antlr/OpraFilterListener.d.ts +430 -0
- package/typings/common/filter/antlr/OpraFilterParser.d.ts +437 -0
- package/typings/common/filter/antlr/OpraFilterVisitor.d.ts +260 -0
- package/typings/common/filter/ast/abstract/ast.d.ts +5 -0
- package/typings/common/filter/ast/abstract/expression.d.ts +3 -0
- package/typings/common/filter/ast/abstract/literal.d.ts +6 -0
- package/typings/common/filter/ast/abstract/term.d.ts +3 -0
- package/typings/common/filter/ast/expressions/arithmetic-expression.d.ts +13 -0
- package/typings/common/filter/ast/expressions/array-expression.d.ts +7 -0
- package/typings/common/filter/ast/expressions/comparison-expression.d.ts +10 -0
- package/typings/common/filter/ast/expressions/logical-expression.d.ts +8 -0
- package/typings/common/filter/ast/expressions/parentheses-expression.d.ts +6 -0
- package/typings/common/filter/ast/index.d.ts +16 -0
- package/typings/common/filter/ast/terms/boolean-literal.d.ts +5 -0
- package/typings/common/filter/ast/terms/date-literal.d.ts +6 -0
- package/typings/common/filter/ast/terms/external-constant.d.ts +5 -0
- package/typings/common/filter/ast/terms/null-literal.d.ts +5 -0
- package/typings/common/filter/ast/terms/number-literal.d.ts +6 -0
- package/typings/common/filter/ast/terms/qualified-identifier.d.ts +4 -0
- package/typings/common/filter/ast/terms/string-literal.d.ts +5 -0
- package/typings/common/filter/ast/terms/time-literal.d.ts +6 -0
- package/typings/common/filter/build.d.ts +31 -0
- package/typings/common/filter/errors.d.ts +18 -0
- package/typings/common/filter/filter-tree-visitor.d.ts +32 -0
- package/typings/common/filter/index.d.ts +5 -0
- package/typings/common/filter/opra-error-listener.d.ts +8 -0
- package/typings/common/filter/parse.d.ts +2 -0
- package/typings/common/filter/utils.d.ts +2 -0
- package/typings/common/helpers/index.d.ts +1 -0
- package/typings/common/helpers/responsive-map.d.ts +18 -0
- package/typings/common/http/enums/http-headers.enum.d.ts +379 -0
- package/typings/common/http/enums/http-status.enum.d.ts +290 -0
- package/typings/common/http/http-request.d.ts +34 -0
- package/typings/common/http/index.d.ts +6 -0
- package/typings/common/http/interfaces/client-http-headers.interface.d.ts +65 -0
- package/typings/common/http/interfaces/server-http-headers.interface.d.ts +1 -0
- package/typings/common/http/multipart/batch-multipart.d.ts +31 -0
- package/typings/common/http/multipart/http-request-content.d.ts +8 -0
- package/typings/common/http/multipart/http-response-content.d.ts +7 -0
- package/typings/common/http/multipart/index.d.ts +1 -0
- package/typings/common/http/utils/normalize-headers.d.ts +1 -0
- package/typings/common/i18n/i18n.d.ts +28 -0
- package/typings/common/i18n/index.d.ts +5 -0
- package/typings/common/i18n/string-utils.d.ts +2 -0
- package/typings/common/i18n/translate.d.ts +4 -0
- package/typings/common/index.d.ts +10 -0
- package/typings/common/schema/constants.d.ts +8 -0
- package/typings/common/schema/decorators/opr-collection-resource.decorator.d.ts +8 -0
- package/typings/common/schema/decorators/opr-complex-type.decorator.d.ts +6 -0
- package/typings/common/schema/decorators/opr-field.decorator.d.ts +3 -0
- package/typings/common/schema/decorators/opr-resolver.decorator.d.ts +8 -0
- package/typings/common/schema/decorators/opr-simple-type.decorator.d.ts +6 -0
- package/typings/common/schema/decorators/opr-singleton-resource.decorator.d.ts +8 -0
- package/typings/common/schema/implementation/data-type/builtin/any.type.d.ts +2 -0
- package/typings/common/schema/implementation/data-type/builtin/base64-binary.type.d.ts +2 -0
- package/typings/common/schema/implementation/data-type/builtin/bigint.type.d.ts +2 -0
- package/typings/common/schema/implementation/data-type/builtin/boolean.type.d.ts +2 -0
- package/typings/common/schema/implementation/data-type/builtin/date-string.type.d.ts +2 -0
- package/typings/common/schema/implementation/data-type/builtin/date.type.d.ts +2 -0
- package/typings/common/schema/implementation/data-type/builtin/guid.type.d.ts +2 -0
- package/typings/common/schema/implementation/data-type/builtin/integer.type.d.ts +2 -0
- package/typings/common/schema/implementation/data-type/builtin/number.type.d.ts +2 -0
- package/typings/common/schema/implementation/data-type/builtin/object.type.d.ts +2 -0
- package/typings/common/schema/implementation/data-type/builtin/string.type.d.ts +2 -0
- package/typings/common/schema/implementation/data-type/builtin-data-types.d.ts +4 -0
- package/typings/common/schema/implementation/data-type/complex-type.d.ts +29 -0
- package/typings/common/schema/implementation/data-type/data-type.d.ts +16 -0
- package/typings/common/schema/implementation/data-type/simple-type.d.ts +12 -0
- package/typings/common/schema/implementation/data-type/union-type.d.ts +16 -0
- package/typings/common/schema/implementation/document-builder.d.ts +16 -0
- package/typings/common/schema/implementation/opra-document.d.ts +44 -0
- package/typings/common/schema/implementation/query/collection-count-query.d.ts +14 -0
- package/typings/common/schema/implementation/query/collection-create-query.d.ts +18 -0
- package/typings/common/schema/implementation/query/collection-delete-many-query.d.ts +14 -0
- package/typings/common/schema/implementation/query/collection-delete-query.d.ts +10 -0
- package/typings/common/schema/implementation/query/collection-get-query.d.ts +21 -0
- package/typings/common/schema/implementation/query/collection-search-query.d.ts +30 -0
- package/typings/common/schema/implementation/query/collection-update-many-query.d.ts +15 -0
- package/typings/common/schema/implementation/query/collection-update-query.d.ts +19 -0
- package/typings/common/schema/implementation/query/field-get-query.d.ts +30 -0
- package/typings/common/schema/implementation/query/index.d.ts +27 -0
- package/typings/common/schema/implementation/query/singleton-get-query.d.ts +20 -0
- package/typings/common/schema/implementation/resource/collection-resource-info.d.ts +19 -0
- package/typings/common/schema/implementation/resource/container-resource-info.d.ts +13 -0
- package/typings/common/schema/implementation/resource/resource-info.d.ts +17 -0
- package/typings/common/schema/implementation/resource/singleton-resource-info.d.ts +14 -0
- package/typings/common/schema/implementation/schema-builder/extract-resource-metadata.util.d.ts +3 -0
- package/typings/common/schema/implementation/schema-builder/extract-type-metadata.util.d.ts +4 -0
- package/typings/common/schema/index.d.ts +25 -0
- package/typings/common/schema/interfaces/child-field-query.interface.d.ts +4 -0
- package/typings/common/schema/interfaces/data-type.metadata.d.ts +18 -0
- package/typings/common/schema/interfaces/resource-container.interface.d.ts +8 -0
- package/typings/common/schema/interfaces/resource.metadata.d.ts +18 -0
- package/typings/common/schema/opra-schema.definition.d.ts +178 -0
- package/typings/common/schema/type-helpers/extend-type.helper.d.ts +3 -0
- package/typings/common/schema/type-helpers/mixin-type.helper.d.ts +2 -0
- package/typings/common/schema/type-helpers/mixin.utils.d.ts +3 -0
- package/typings/common/schema/types.d.ts +14 -0
- package/typings/common/schema/utils/class.utils.d.ts +2 -0
- package/typings/common/schema/utils/clone-object.util.d.ts +1 -0
- package/typings/common/schema/utils/inspect.util.d.ts +4 -0
- package/typings/common/schema/utils/normalize-field-array.util.d.ts +3 -0
- package/typings/common/schema/utils/path-to-tree.util.d.ts +4 -0
- package/typings/common/schema/utils/string-compare.util.d.ts +1 -0
- package/typings/common/url/formats/boolean-format.d.ts +5 -0
- package/typings/common/url/formats/date-format.d.ts +16 -0
- package/typings/common/url/formats/filter-format.d.ts +6 -0
- package/typings/common/url/formats/format.d.ts +4 -0
- package/typings/common/url/formats/integer-format.d.ts +9 -0
- package/typings/common/url/formats/number-format.d.ts +12 -0
- package/typings/common/url/formats/string-format.d.ts +14 -0
- package/typings/common/url/index.d.ts +5 -0
- package/typings/common/url/opra-url-path-component.d.ts +15 -0
- package/typings/common/url/opra-url-path.d.ts +30 -0
- package/typings/common/url/opra-url-search-params.d.ts +44 -0
- package/typings/common/url/opra-url.d.ts +79 -0
- package/typings/common/url/utils/path-utils.d.ts +8 -0
- package/typings/common/utils/index.d.ts +3 -0
- package/typings/common/utils/is-url.d.ts +1 -0
- package/typings/common/utils/path-to-tree.d.ts +4 -0
- package/typings/common/utils/type-guards.d.ts +9 -0
- package/typings/http/http-client.d.ts +1 -1
- package/typings/http/http-collection-service.d.ts +1 -1
- package/typings/http/http-request.d.ts +1 -1
- package/typings/http/http-singleton-service.d.ts +1 -1
- package/typings/http/http-types.d.ts +1 -1
- package/typings/http/requests/batch-request.d.ts +1 -1
- package/typings/http/requests/collection-create-request.d.ts +1 -1
- package/typings/http/requests/collection-delete-many-request.d.ts +1 -1
- package/typings/http/requests/collection-delete-request.d.ts +1 -1
- package/typings/http/requests/collection-get-request.d.ts +1 -1
- package/typings/http/requests/collection-search-request.d.ts +1 -1
- package/typings/http/requests/collection-update-many-request.d.ts +1 -1
- package/typings/http/requests/collection-update-request.d.ts +1 -1
- package/typings/http/requests/http-singleton-get-request.d.ts +1 -1
- package/typings/interfaces/http-options.interface.d.ts +1 -1
- package/typings/interfaces/http-request-config.interface.d.ts +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CollectionResourceInfo } from '../resource/collection-resource-info.js';
|
|
2
|
+
export declare type CollectionUpdateQueryOptions = {
|
|
3
|
+
pick?: string[];
|
|
4
|
+
omit?: string[];
|
|
5
|
+
include?: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare class CollectionUpdateQuery {
|
|
8
|
+
readonly resource: CollectionResourceInfo;
|
|
9
|
+
data: any;
|
|
10
|
+
readonly kind = "CollectionUpdateQuery";
|
|
11
|
+
readonly method = "update";
|
|
12
|
+
readonly operation = "update";
|
|
13
|
+
keyValue: any;
|
|
14
|
+
pick?: string[];
|
|
15
|
+
omit?: string[];
|
|
16
|
+
include?: string[];
|
|
17
|
+
constructor(resource: CollectionResourceInfo, keyValue: any, data: any, options?: CollectionUpdateQueryOptions);
|
|
18
|
+
get dataType(): import("../data-type/complex-type.js").ComplexType;
|
|
19
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { IChildFieldQuery } from '../../interfaces/child-field-query.interface.js';
|
|
2
|
+
import { ComplexType, Field } from '../data-type/complex-type.js';
|
|
3
|
+
import type { DataType } from '../data-type/data-type.js';
|
|
4
|
+
import type { CollectionResourceInfo } from '../resource/collection-resource-info.js';
|
|
5
|
+
import type { SingletonResourceInfo } from '../resource/singleton-resource-info.js';
|
|
6
|
+
import type { CollectionGetQuery } from './collection-get-query.js';
|
|
7
|
+
import type { SingletonGetQuery } from './singleton-get-query.js';
|
|
8
|
+
export declare type FieldGetQueryOptions = {
|
|
9
|
+
pick?: string[];
|
|
10
|
+
omit?: string[];
|
|
11
|
+
include?: string[];
|
|
12
|
+
castingType?: ComplexType;
|
|
13
|
+
};
|
|
14
|
+
export declare class FieldGetQuery implements IChildFieldQuery {
|
|
15
|
+
readonly parent: CollectionGetQuery | SingletonGetQuery | FieldGetQuery;
|
|
16
|
+
readonly resource: CollectionResourceInfo | SingletonResourceInfo;
|
|
17
|
+
readonly kind = "FieldGetQuery";
|
|
18
|
+
readonly method = "get";
|
|
19
|
+
readonly operation = "read";
|
|
20
|
+
readonly fieldName: string;
|
|
21
|
+
readonly field?: Field;
|
|
22
|
+
readonly path: string;
|
|
23
|
+
readonly dataType: DataType;
|
|
24
|
+
readonly parentType: ComplexType;
|
|
25
|
+
pick?: string[];
|
|
26
|
+
omit?: string[];
|
|
27
|
+
include?: string[];
|
|
28
|
+
child?: FieldGetQuery;
|
|
29
|
+
constructor(parent: CollectionGetQuery | SingletonGetQuery | FieldGetQuery, fieldName: string, options?: FieldGetQueryOptions);
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IChildFieldQuery } from '../../interfaces/child-field-query.interface.js';
|
|
2
|
+
import { CollectionCountQuery } from './collection-count-query.js';
|
|
3
|
+
import { CollectionCreateQuery } from './collection-create-query.js';
|
|
4
|
+
import { CollectionDeleteManyQuery } from './collection-delete-many-query.js';
|
|
5
|
+
import { CollectionDeleteQuery } from './collection-delete-query.js';
|
|
6
|
+
import { CollectionGetQuery } from './collection-get-query.js';
|
|
7
|
+
import { CollectionSearchQuery } from './collection-search-query.js';
|
|
8
|
+
import { CollectionUpdateManyQuery } from './collection-update-many-query.js';
|
|
9
|
+
import { CollectionUpdateQuery } from './collection-update-query.js';
|
|
10
|
+
import { FieldGetQuery } from './field-get-query.js';
|
|
11
|
+
import { SingletonGetQuery } from './singleton-get-query.js';
|
|
12
|
+
export * from './collection-create-query.js';
|
|
13
|
+
export * from './collection-count-query.js';
|
|
14
|
+
export * from './collection-delete-many-query.js';
|
|
15
|
+
export * from './collection-delete-query.js';
|
|
16
|
+
export * from './collection-delete-many-query.js';
|
|
17
|
+
export * from './collection-get-query.js';
|
|
18
|
+
export * from './field-get-query.js';
|
|
19
|
+
export * from './singleton-get-query.js';
|
|
20
|
+
export * from './collection-search-query.js';
|
|
21
|
+
export * from './collection-update-many-query.js';
|
|
22
|
+
export * from './collection-update-query.js';
|
|
23
|
+
export declare type CollectionQuery = CollectionCountQuery | CollectionCreateQuery | CollectionDeleteManyQuery | CollectionDeleteQuery | CollectionGetQuery | CollectionSearchQuery | CollectionUpdateManyQuery | CollectionUpdateQuery;
|
|
24
|
+
export declare type FieldQuery = FieldGetQuery;
|
|
25
|
+
export declare type SingletonQuery = SingletonGetQuery;
|
|
26
|
+
export declare type OpraQuery = CollectionQuery | SingletonQuery | FieldQuery;
|
|
27
|
+
export declare function isChildFieldQuery(query: any): query is IChildFieldQuery;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IChildFieldQuery } from '../../interfaces/child-field-query.interface.js';
|
|
2
|
+
import type { SingletonResourceInfo } from '../resource/singleton-resource-info.js';
|
|
3
|
+
import type { FieldGetQuery } from './field-get-query.js';
|
|
4
|
+
export declare type SingletonGetQueryOptions = {
|
|
5
|
+
pick?: string[];
|
|
6
|
+
omit?: string[];
|
|
7
|
+
include?: string[];
|
|
8
|
+
};
|
|
9
|
+
export declare class SingletonGetQuery implements IChildFieldQuery {
|
|
10
|
+
readonly resource: SingletonResourceInfo;
|
|
11
|
+
readonly kind = "SingletonGetQuery";
|
|
12
|
+
readonly method = "get";
|
|
13
|
+
readonly operation = "read";
|
|
14
|
+
pick?: string[];
|
|
15
|
+
omit?: string[];
|
|
16
|
+
include?: string[];
|
|
17
|
+
child?: FieldGetQuery;
|
|
18
|
+
constructor(resource: SingletonResourceInfo, options?: SingletonGetQueryOptions);
|
|
19
|
+
get dataType(): import("../data-type/complex-type.js").ComplexType;
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OpraSchema } from '../../opra-schema.definition.js';
|
|
2
|
+
import { ComplexType } from '../data-type/complex-type.js';
|
|
3
|
+
import type { OpraDocument } from '../opra-document';
|
|
4
|
+
import { ResourceInfo } from './resource-info.js';
|
|
5
|
+
export declare class CollectionResourceInfo extends ResourceInfo {
|
|
6
|
+
readonly metadata: OpraSchema.CollectionResource;
|
|
7
|
+
readonly dataType: ComplexType;
|
|
8
|
+
constructor(document: OpraDocument, name: string, dataType: ComplexType, metadata: OpraSchema.CollectionResource);
|
|
9
|
+
get keyFields(): string[];
|
|
10
|
+
get create(): OpraSchema.CreateMethodResolver | undefined;
|
|
11
|
+
get count(): OpraSchema.MethodResolver | undefined;
|
|
12
|
+
get delete(): OpraSchema.MethodResolver | undefined;
|
|
13
|
+
get deleteMany(): OpraSchema.DeleteManyMethodResolver | undefined;
|
|
14
|
+
get get(): OpraSchema.GetMethodResolver | undefined;
|
|
15
|
+
get update(): OpraSchema.UpdateMethodResolver | undefined;
|
|
16
|
+
get updateMany(): OpraSchema.UpdateManyMethodResolver | undefined;
|
|
17
|
+
get search(): OpraSchema.SearchMethodResolver | undefined;
|
|
18
|
+
getSchema(jsonOnly?: boolean): OpraSchema.CollectionResource;
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IResourceContainer } from '../../interfaces/resource-container.interface.js';
|
|
2
|
+
import { OpraSchema } from '../../opra-schema.definition.js';
|
|
3
|
+
import type { OpraDocument } from '../opra-document.js';
|
|
4
|
+
import { CollectionResourceInfo } from './collection-resource-info.js';
|
|
5
|
+
import { ResourceInfo } from './resource-info.js';
|
|
6
|
+
import { SingletonResourceInfo } from './singleton-resource-info.js';
|
|
7
|
+
export declare class ContainerResourceInfo extends ResourceInfo implements IResourceContainer {
|
|
8
|
+
readonly metadata: OpraSchema.ContainerResource;
|
|
9
|
+
constructor(service: OpraDocument, name: string, metadata: OpraSchema.ContainerResource);
|
|
10
|
+
getResource<T extends ResourceInfo>(name: string): T;
|
|
11
|
+
getCollectionResource(name: string): CollectionResourceInfo;
|
|
12
|
+
getSingletonResource(name: string): SingletonResourceInfo;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OpraSchema } from '../../opra-schema.definition.js';
|
|
2
|
+
import { nodeInspectCustom } from '../../utils/inspect.util.js';
|
|
3
|
+
import type { OpraDocument } from '../opra-document.js';
|
|
4
|
+
export declare abstract class ResourceInfo {
|
|
5
|
+
readonly metadata: OpraSchema.Resource;
|
|
6
|
+
readonly document: OpraDocument;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
protected path: string;
|
|
9
|
+
protected constructor(document: OpraDocument, name: string, metadata: OpraSchema.Resource);
|
|
10
|
+
get instance(): {} | undefined;
|
|
11
|
+
get kind(): OpraSchema.ResourceKind;
|
|
12
|
+
get description(): string | undefined;
|
|
13
|
+
toString(): string;
|
|
14
|
+
validateQueryOptions(): any;
|
|
15
|
+
getSchema(jsonOnly?: boolean): OpraSchema.Resource;
|
|
16
|
+
[nodeInspectCustom](): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OpraSchema } from '../../opra-schema.definition.js';
|
|
2
|
+
import { ComplexType } from '../data-type/complex-type.js';
|
|
3
|
+
import type { OpraDocument } from '../opra-document.js';
|
|
4
|
+
import { ResourceInfo } from './resource-info.js';
|
|
5
|
+
export declare class SingletonResourceInfo extends ResourceInfo {
|
|
6
|
+
readonly metadata: OpraSchema.SingletonResource;
|
|
7
|
+
readonly dataType: ComplexType;
|
|
8
|
+
constructor(document: OpraDocument, name: string, dataType: ComplexType, metadata: OpraSchema.SingletonResource);
|
|
9
|
+
get create(): OpraSchema.CreateMethodResolver | undefined;
|
|
10
|
+
get delete(): OpraSchema.MethodResolver | undefined;
|
|
11
|
+
get get(): OpraSchema.GetMethodResolver | undefined;
|
|
12
|
+
get update(): OpraSchema.UpdateMethodResolver | undefined;
|
|
13
|
+
getSchema(jsonOnly?: boolean): OpraSchema.SingletonResource;
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
export * from './constants.js';
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export * from './opra-schema.definition.js';
|
|
5
|
+
export * from './decorators/opr-complex-type.decorator.js';
|
|
6
|
+
export * from './decorators/opr-field.decorator.js';
|
|
7
|
+
export * from './decorators/opr-collection-resource.decorator.js';
|
|
8
|
+
export * from './decorators/opr-singleton-resource.decorator.js';
|
|
9
|
+
export * from './decorators/opr-resolver.decorator.js';
|
|
10
|
+
export * from './interfaces/resource-container.interface.js';
|
|
11
|
+
export * from './implementation/document-builder.js';
|
|
12
|
+
export * from './implementation/opra-document.js';
|
|
13
|
+
export * from './implementation/data-type/data-type.js';
|
|
14
|
+
export * from './implementation/data-type/complex-type.js';
|
|
15
|
+
export * from './implementation/data-type/simple-type.js';
|
|
16
|
+
export * from './implementation/data-type/union-type.js';
|
|
17
|
+
export * from './implementation/resource/resource-info.js';
|
|
18
|
+
export * from './implementation/resource/container-resource-info.js';
|
|
19
|
+
export * from './implementation/resource/collection-resource-info.js';
|
|
20
|
+
export * from './implementation/resource/singleton-resource-info.js';
|
|
21
|
+
export * from './implementation/query/index.js';
|
|
22
|
+
export * from './type-helpers/mixin-type.helper.js';
|
|
23
|
+
export * from './type-helpers/extend-type.helper.js';
|
|
24
|
+
export * from './implementation/schema-builder/extract-type-metadata.util.js';
|
|
25
|
+
export * from './implementation/schema-builder/extract-resource-metadata.util.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StrictOmit, Type } from 'ts-gems';
|
|
2
|
+
import { OpraSchema } from '../opra-schema.definition.js';
|
|
3
|
+
import { TypeThunkAsync } from '../types.js';
|
|
4
|
+
export declare type SimpleTypeMetadata = OpraSchema.SimpleType & {
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
export declare type ComplexTypeMetadata = StrictOmit<OpraSchema.ComplexType, 'fields' | 'extends'> & {
|
|
8
|
+
name: string;
|
|
9
|
+
extends?: ComplexTypeExtendingMetadata[];
|
|
10
|
+
fields?: Record<string, FieldMetadata>;
|
|
11
|
+
};
|
|
12
|
+
export declare type FieldMetadata = StrictOmit<OpraSchema.Field, 'type'> & {
|
|
13
|
+
type?: string | TypeThunkAsync | (string | TypeThunkAsync)[];
|
|
14
|
+
};
|
|
15
|
+
declare type ComplexTypeExtendingMetadata = StrictOmit<OpraSchema.ComplexTypeExtendingInfo, 'type'> & {
|
|
16
|
+
type: string | Type;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CollectionResourceInfo } from '../implementation/resource/collection-resource-info.js';
|
|
2
|
+
import { ResourceInfo } from '../implementation/resource/resource-info.js';
|
|
3
|
+
import { SingletonResourceInfo } from '../implementation/resource/singleton-resource-info.js';
|
|
4
|
+
export interface IResourceContainer {
|
|
5
|
+
getResource<T extends ResourceInfo>(name: string): T;
|
|
6
|
+
getCollectionResource(name: string): CollectionResourceInfo;
|
|
7
|
+
getSingletonResource(name: string): SingletonResourceInfo;
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PartialSome, StrictOmit } from 'ts-gems';
|
|
2
|
+
import { OpraSchema } from '../opra-schema.definition.js';
|
|
3
|
+
import { TypeThunkAsync } from '../types.js';
|
|
4
|
+
export declare type CollectionResourceMetadata = PartialSome<StrictOmit<OpraSchema.CollectionResource, 'type'>, 'keyFields'> & {
|
|
5
|
+
type: TypeThunkAsync | string;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type SingletonResourceMetadata = StrictOmit<OpraSchema.SingletonResource, 'type'> & {
|
|
9
|
+
type: TypeThunkAsync | string;
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export declare type ICreateResolverMetadata = StrictOmit<OpraSchema.CreateMethodResolver, 'handler'>;
|
|
13
|
+
export declare type IDeleteResolverMetadata = StrictOmit<OpraSchema.DeleteMethodResolver, 'handler'>;
|
|
14
|
+
export declare type IDeleteManyResolverMetadata = StrictOmit<OpraSchema.DeleteManyMethodResolver, 'handler'>;
|
|
15
|
+
export declare type IGetResolverMetadata = StrictOmit<OpraSchema.GetMethodResolver, 'handler'>;
|
|
16
|
+
export declare type IUpdateResolverMetadata = StrictOmit<OpraSchema.UpdateMethodResolver, 'handler'>;
|
|
17
|
+
export declare type IUpdateManyResolverMetadata = StrictOmit<OpraSchema.UpdateManyMethodResolver, 'handler'>;
|
|
18
|
+
export declare type ISearchResolverMetadata = StrictOmit<OpraSchema.SearchMethodResolver, 'handler'>;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { Type } from 'ts-gems';
|
|
2
|
+
import { ComparisonOperator } from '../filter/index.js';
|
|
3
|
+
export declare namespace OpraSchema {
|
|
4
|
+
/**
|
|
5
|
+
* *** === Constants === ***
|
|
6
|
+
*/
|
|
7
|
+
export const Version = "1.0";
|
|
8
|
+
/**
|
|
9
|
+
* *** === Type definitions === ***
|
|
10
|
+
*/
|
|
11
|
+
export type Extensible<T = any> = {
|
|
12
|
+
[key: `$${string}`]: T;
|
|
13
|
+
};
|
|
14
|
+
export type ResourceKind = 'ContainerResource' | 'CollectionResource' | 'SingletonResource';
|
|
15
|
+
export type DataTypeKind = 'SimpleType' | 'ComplexType' | 'UnionType';
|
|
16
|
+
export type SingletonMethod = 'get' | 'create' | 'update' | 'delete';
|
|
17
|
+
export type CollectionMethod = SingletonMethod | 'search' | 'count' | 'updateMany' | 'deleteMany';
|
|
18
|
+
/**
|
|
19
|
+
* *** === Document related === ***
|
|
20
|
+
*/
|
|
21
|
+
export interface Document {
|
|
22
|
+
version: string;
|
|
23
|
+
info: DocumentInfo;
|
|
24
|
+
references?: Record<string, Reference>;
|
|
25
|
+
types?: Record<string, DataType>;
|
|
26
|
+
resources?: Record<string, Resource>;
|
|
27
|
+
servers?: ServerInfo[];
|
|
28
|
+
}
|
|
29
|
+
export type ServerInfo = Extensible & {
|
|
30
|
+
url: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
};
|
|
33
|
+
export type Reference = Extensible & {
|
|
34
|
+
url?: string;
|
|
35
|
+
document?: Document;
|
|
36
|
+
};
|
|
37
|
+
export type DocumentInfo = Extensible & {
|
|
38
|
+
title: string;
|
|
39
|
+
version: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
termsOfService?: string;
|
|
42
|
+
contact?: ContactPerson[];
|
|
43
|
+
license?: LicenseInfo;
|
|
44
|
+
};
|
|
45
|
+
export type ContactPerson = Extensible & {
|
|
46
|
+
name?: string;
|
|
47
|
+
email?: string;
|
|
48
|
+
url?: string;
|
|
49
|
+
};
|
|
50
|
+
export type LicenseInfo = Extensible & {
|
|
51
|
+
name: string;
|
|
52
|
+
url?: string;
|
|
53
|
+
content?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* *** === Data Type related === ***
|
|
57
|
+
*/
|
|
58
|
+
export type DataType = ComplexType | SimpleType | UnionType;
|
|
59
|
+
export type BaseDataType = {
|
|
60
|
+
kind: DataTypeKind;
|
|
61
|
+
description?: string;
|
|
62
|
+
ctor?: Type;
|
|
63
|
+
parse?: (v: any) => any;
|
|
64
|
+
serialize?: (v: any) => any;
|
|
65
|
+
};
|
|
66
|
+
export interface SimpleType extends BaseDataType {
|
|
67
|
+
kind: 'SimpleType';
|
|
68
|
+
}
|
|
69
|
+
export interface UnionType extends BaseDataType {
|
|
70
|
+
kind: 'UnionType';
|
|
71
|
+
types: DataType[];
|
|
72
|
+
}
|
|
73
|
+
export interface ComplexType extends BaseDataType {
|
|
74
|
+
kind: 'ComplexType';
|
|
75
|
+
description?: string;
|
|
76
|
+
abstract?: boolean;
|
|
77
|
+
extends?: ComplexTypeExtendingInfo[];
|
|
78
|
+
fields?: Record<string, Field>;
|
|
79
|
+
additionalFields?: boolean | string | Pick<Field, 'type' | 'format' | 'isArray' | 'enum'>;
|
|
80
|
+
}
|
|
81
|
+
export interface ComplexTypeExtendingInfo {
|
|
82
|
+
type: string;
|
|
83
|
+
pick?: string[];
|
|
84
|
+
omit?: string[];
|
|
85
|
+
}
|
|
86
|
+
export type Field = Extensible & {
|
|
87
|
+
type: string;
|
|
88
|
+
description?: string;
|
|
89
|
+
required?: boolean;
|
|
90
|
+
isArray?: boolean;
|
|
91
|
+
format?: string;
|
|
92
|
+
default?: any;
|
|
93
|
+
fixed?: string | number;
|
|
94
|
+
enum?: string | string[] | Record<string, string>;
|
|
95
|
+
enumName?: string;
|
|
96
|
+
examples?: any[] | Record<string, any>;
|
|
97
|
+
deprecated?: boolean | string;
|
|
98
|
+
/**
|
|
99
|
+
* If true, this property will not be included in results by default.
|
|
100
|
+
* The client side should include the property name in the "include" query parameter.
|
|
101
|
+
*/
|
|
102
|
+
exclusive?: boolean;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* *** === Resource related === ***
|
|
106
|
+
*/
|
|
107
|
+
export type Resource = ContainerResource | CollectionResource | SingletonResource;
|
|
108
|
+
export interface BaseResource {
|
|
109
|
+
kind: ResourceKind;
|
|
110
|
+
description?: string;
|
|
111
|
+
instance?: {};
|
|
112
|
+
}
|
|
113
|
+
export interface CollectionResource extends BaseResource {
|
|
114
|
+
kind: 'CollectionResource';
|
|
115
|
+
type: string;
|
|
116
|
+
keyFields: string | string[];
|
|
117
|
+
create?: CreateMethodResolver;
|
|
118
|
+
count?: CountMethodResolver;
|
|
119
|
+
delete?: DeleteMethodResolver;
|
|
120
|
+
deleteMany?: DeleteManyMethodResolver;
|
|
121
|
+
get?: GetMethodResolver;
|
|
122
|
+
update?: UpdateMethodResolver;
|
|
123
|
+
updateMany?: UpdateManyMethodResolver;
|
|
124
|
+
search?: SearchMethodResolver;
|
|
125
|
+
}
|
|
126
|
+
export interface SingletonResource extends BaseResource {
|
|
127
|
+
kind: 'SingletonResource';
|
|
128
|
+
type: string;
|
|
129
|
+
create?: CreateMethodResolver;
|
|
130
|
+
get?: GetMethodResolver;
|
|
131
|
+
update?: UpdateMethodResolver;
|
|
132
|
+
delete?: DeleteMethodResolver;
|
|
133
|
+
}
|
|
134
|
+
export interface ContainerResource extends BaseResource {
|
|
135
|
+
kind: 'ContainerResource';
|
|
136
|
+
resources: Resource[];
|
|
137
|
+
}
|
|
138
|
+
export type MethodResolver = {
|
|
139
|
+
handler?: Function;
|
|
140
|
+
};
|
|
141
|
+
type MethodResolverInputOptions = {
|
|
142
|
+
inputPick?: string[];
|
|
143
|
+
inputOmit?: string[];
|
|
144
|
+
};
|
|
145
|
+
type MethodResolverOutputOptions = {
|
|
146
|
+
outputPick?: string[];
|
|
147
|
+
outputOmit?: string[];
|
|
148
|
+
};
|
|
149
|
+
type MethodResolverFilterOptions = {
|
|
150
|
+
filters?: {
|
|
151
|
+
field: string;
|
|
152
|
+
operators?: ComparisonOperator[];
|
|
153
|
+
}[];
|
|
154
|
+
};
|
|
155
|
+
export type CreateMethodResolver = MethodResolver & MethodResolverInputOptions & MethodResolverOutputOptions;
|
|
156
|
+
export type CountMethodResolver = MethodResolver & {};
|
|
157
|
+
export type DeleteMethodResolver = MethodResolver & {};
|
|
158
|
+
export type DeleteManyMethodResolver = MethodResolver & MethodResolverFilterOptions;
|
|
159
|
+
export type GetMethodResolver = MethodResolver & MethodResolverOutputOptions;
|
|
160
|
+
export type UpdateMethodResolver = MethodResolver & MethodResolverInputOptions & MethodResolverOutputOptions;
|
|
161
|
+
export type UpdateManyMethodResolver = MethodResolver & MethodResolverFilterOptions;
|
|
162
|
+
export type SearchMethodResolver = MethodResolver & MethodResolverOutputOptions & {
|
|
163
|
+
sortFields?: string[];
|
|
164
|
+
defaultSort?: string[];
|
|
165
|
+
} & MethodResolverFilterOptions;
|
|
166
|
+
/**
|
|
167
|
+
* *** === Type Guards === ***
|
|
168
|
+
*/
|
|
169
|
+
export function isDataType(obj: any): obj is DataType;
|
|
170
|
+
export function isComplexType(obj: any): obj is ComplexType;
|
|
171
|
+
export function isSimpleType(obj: any): obj is SimpleType;
|
|
172
|
+
export function isUnionTypee(obj: any): obj is UnionType;
|
|
173
|
+
export function isResource(obj: any): obj is Resource;
|
|
174
|
+
export function isCollectionResource(obj: any): obj is CollectionResource;
|
|
175
|
+
export function isSingletonResource(obj: any): obj is SingletonResource;
|
|
176
|
+
export function isContainerResource(obj: any): obj is ContainerResource;
|
|
177
|
+
export {};
|
|
178
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Class } from 'ts-gems';
|
|
2
|
+
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'>;
|
|
3
|
+
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'>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Class } from 'ts-gems';
|
|
2
|
+
export declare function MixinType<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>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Type } from 'ts-gems';
|
|
2
|
+
export declare function applyMixins(derivedCtor: any, baseCtor: any, filter?: (k: string) => boolean): void;
|
|
3
|
+
export declare function inheritPropertyInitializers(target: Record<string, any>, sourceClass: Type, isPropertyInherited?: (key: string) => boolean): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Builtin, DeepPickWritable, Type } from 'ts-gems';
|
|
2
|
+
export declare type PartialInput<T> = DeepNullablePartial<DeepPickWritable<T>>;
|
|
3
|
+
export declare type PartialOutput<T> = DeepNullablePartial<T>;
|
|
4
|
+
declare type DeepNullablePartial<T> = T extends Builtin ? T : T extends Promise<infer U> ? Promise<DeepNullablePartial<U>> : T extends (infer U)[] ? DeepNullablePartial<U>[] : {
|
|
5
|
+
[P in keyof T]?: DeepNullablePartial<Exclude<T[P], undefined>> | null;
|
|
6
|
+
};
|
|
7
|
+
export declare type Thunk<T> = T | (() => T);
|
|
8
|
+
export declare type ThunkAsync<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
|
|
9
|
+
export declare type TypeThunk<T = any> = Thunk<Type<T>>;
|
|
10
|
+
export declare type TypeThunkAsync<T = any> = ThunkAsync<Type<T>>;
|
|
11
|
+
export declare type Named<T> = T & {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cloneObject<T extends {}>(obj: T, jsonOnly?: boolean): T;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ComplexType } from '../implementation/data-type/complex-type.js';
|
|
2
|
+
import type { OpraDocument } from '../implementation/opra-document.js';
|
|
3
|
+
export declare function normalizeFieldArray(document: OpraDocument, dataType: ComplexType | undefined, fields: string[], parentPath?: string): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stringCompare(a: string, b: string): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Format } from './format.js';
|
|
2
|
+
export interface DateFormatOptions {
|
|
3
|
+
time?: boolean;
|
|
4
|
+
timeZone?: boolean;
|
|
5
|
+
min?: string;
|
|
6
|
+
max?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class DateFormat extends Format {
|
|
9
|
+
time: boolean;
|
|
10
|
+
timeZone: boolean;
|
|
11
|
+
min?: string;
|
|
12
|
+
max?: string;
|
|
13
|
+
constructor(options?: DateFormatOptions);
|
|
14
|
+
parse(value: string): string;
|
|
15
|
+
stringify(value: any): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NumberFormat, NumberFormatOptions } from './number-format.js';
|
|
2
|
+
export interface IntegerFormatOptions extends NumberFormatOptions {
|
|
3
|
+
enum?: number[];
|
|
4
|
+
}
|
|
5
|
+
export declare class IntegerFormat extends NumberFormat {
|
|
6
|
+
enum?: number[];
|
|
7
|
+
constructor(options?: IntegerFormatOptions);
|
|
8
|
+
parse(value: string): number;
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Format } from './format.js';
|
|
2
|
+
export interface NumberFormatOptions {
|
|
3
|
+
max?: number;
|
|
4
|
+
min?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class NumberFormat extends Format {
|
|
7
|
+
max?: number;
|
|
8
|
+
min?: number;
|
|
9
|
+
constructor(options?: NumberFormatOptions);
|
|
10
|
+
parse(value: string): number;
|
|
11
|
+
stringify(value: any): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Format } from './format.js';
|
|
2
|
+
export interface StringFormatOptions {
|
|
3
|
+
maxLength?: number;
|
|
4
|
+
minLength?: number;
|
|
5
|
+
enum?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare class StringFormat extends Format {
|
|
8
|
+
maxLength?: number;
|
|
9
|
+
minLength?: number;
|
|
10
|
+
enum?: string[];
|
|
11
|
+
constructor(options?: StringFormatOptions);
|
|
12
|
+
parse(value: string): string;
|
|
13
|
+
stringify(value: any): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const nodeInspectCustom: unique symbol;
|
|
2
|
+
export declare type OpraURLPathComponentInit = {
|
|
3
|
+
resource: string;
|
|
4
|
+
key?: any;
|
|
5
|
+
typeCast?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class OpraURLPathComponent {
|
|
8
|
+
resource: string;
|
|
9
|
+
key?: any;
|
|
10
|
+
typeCast?: string;
|
|
11
|
+
constructor(init: OpraURLPathComponentInit);
|
|
12
|
+
toString(): string;
|
|
13
|
+
[nodeInspectCustom](): any;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { OpraURLPathComponent, OpraURLPathComponentInit } from './opra-url-path-component.js';
|
|
4
|
+
declare const nodeInspectCustom: unique symbol;
|
|
5
|
+
export declare class OpraURLPath extends EventEmitter {
|
|
6
|
+
private _entries;
|
|
7
|
+
constructor(...components: (OpraURLPathComponent | OpraURLPathComponentInit)[]);
|
|
8
|
+
constructor(init?: string | OpraURLPath | URL | OpraURLPathComponent | OpraURLPathComponentInit);
|
|
9
|
+
get size(): number;
|
|
10
|
+
add(component: OpraURLPathComponent | {
|
|
11
|
+
resource: string;
|
|
12
|
+
key?: any;
|
|
13
|
+
typeCast?: string;
|
|
14
|
+
}): void;
|
|
15
|
+
add(name: string, key?: any, typeCast?: string): void;
|
|
16
|
+
clear(): void;
|
|
17
|
+
get(index: number): OpraURLPathComponent;
|
|
18
|
+
join(pathString: string): this;
|
|
19
|
+
entries(): IterableIterator<[OpraURLPathComponent, number]>;
|
|
20
|
+
values(): IterableIterator<OpraURLPathComponent>;
|
|
21
|
+
forEach(callback: (name: string, key: any, _this: this) => void): void;
|
|
22
|
+
getResource(index: number): string | undefined;
|
|
23
|
+
getKey(index: number): any;
|
|
24
|
+
toString(): string;
|
|
25
|
+
[Symbol.iterator](): IterableIterator<[OpraURLPathComponent, number]>;
|
|
26
|
+
[nodeInspectCustom](): OpraURLPathComponent[];
|
|
27
|
+
protected _add(component: any, key?: any, typeCast?: string): void;
|
|
28
|
+
protected _parse(v: string): void;
|
|
29
|
+
}
|
|
30
|
+
export {};
|