@opra/common 0.7.0 → 0.10.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/cjs/exception/http-errors/bad-request.error.js +4 -1
- package/cjs/exception/http-errors/failed-dependency.error.js +4 -1
- package/cjs/exception/http-errors/forbidden.error.js +4 -1
- package/cjs/exception/http-errors/internal-server.error.js +4 -1
- package/cjs/exception/http-errors/method-not-allowed.error.js +4 -1
- package/cjs/exception/http-errors/not-acceptable.error.js +4 -1
- package/cjs/exception/http-errors/not-found.error.js +4 -1
- package/cjs/exception/http-errors/unauthorized.error.js +4 -1
- package/cjs/exception/http-errors/unprocessable-entity.error.js +4 -1
- package/cjs/exception/opra-exception.js +1 -3
- package/cjs/exception/resource-errors/resource-conflict.error.js +1 -1
- package/cjs/filter/antlr/OpraFilterLexer.js +349 -350
- package/cjs/filter/antlr/OpraFilterParser.js +177 -178
- package/cjs/filter/ast/abstract/ast.js +0 -1
- package/cjs/filter/ast/expressions/arithmetic-expression.js +1 -3
- package/cjs/filter/ast/expressions/array-expression.js +0 -1
- package/cjs/filter/ast/expressions/comparison-expression.js +0 -3
- package/cjs/filter/ast/expressions/logical-expression.js +0 -2
- package/cjs/filter/ast/expressions/parentheses-expression.js +0 -1
- package/cjs/filter/ast/terms/date-literal.js +0 -1
- package/cjs/filter/ast/terms/null-literal.js +1 -1
- package/cjs/filter/ast/terms/number-literal.js +0 -1
- package/cjs/filter/ast/terms/time-literal.js +0 -1
- package/cjs/filter/error-listener.js +0 -1
- package/cjs/filter/errors.js +0 -5
- package/cjs/filter/filter-tree-visitor.js +0 -1
- package/cjs/helpers/responsive-map.js +3 -3
- package/cjs/http/http-request.js +4 -18
- package/cjs/http/multipart/batch-multipart.js +2 -3
- package/cjs/http/multipart/http-request-content.js +0 -4
- package/cjs/http/multipart/http-response-content.js +0 -3
- package/cjs/schema/implementation/data-type/complex-type.js +3 -4
- package/cjs/schema/implementation/data-type/data-type.js +0 -3
- package/cjs/schema/implementation/data-type/union-type.js +0 -2
- package/cjs/schema/implementation/document-builder.js +6 -7
- package/cjs/schema/implementation/opra-document.js +3 -3
- package/cjs/schema/implementation/query/collection-count-query.js +3 -5
- package/cjs/schema/implementation/query/collection-create-query.js +3 -8
- package/cjs/schema/implementation/query/collection-delete-many-query.js +3 -5
- package/cjs/schema/implementation/query/collection-delete-query.js +3 -5
- package/cjs/schema/implementation/query/collection-get-query.js +3 -9
- package/cjs/schema/implementation/query/collection-search-query.js +3 -13
- package/cjs/schema/implementation/query/collection-update-many-query.js +3 -6
- package/cjs/schema/implementation/query/collection-update-query.js +3 -9
- package/cjs/schema/implementation/query/field-get-query.js +3 -14
- package/cjs/schema/implementation/query/singleton-get-query.js +3 -8
- package/cjs/schema/implementation/resource/collection-resource-info.js +0 -1
- package/cjs/schema/implementation/resource/resource-info.js +0 -4
- package/cjs/schema/implementation/resource/singleton-resource-info.js +0 -1
- package/cjs/schema/implementation/schema-builder/extract-type-metadata.util.js +5 -5
- package/cjs/schema/type-helpers/extend-type.helper.js +4 -4
- package/cjs/schema/type-helpers/mixin-type.helper.js +4 -4
- package/cjs/url/formats/date-format.js +0 -4
- package/cjs/url/formats/integer-format.js +0 -1
- package/cjs/url/formats/number-format.js +0 -2
- package/cjs/url/formats/string-format.js +0 -3
- package/cjs/url/opra-url-path-component.js +0 -3
- package/cjs/url/opra-url-path.js +1 -1
- package/cjs/url/opra-url-search-params.js +4 -5
- package/cjs/url/opra-url.js +0 -3
- package/esm/exception/http-errors/bad-request.error.js +4 -1
- package/esm/exception/http-errors/failed-dependency.error.js +4 -1
- package/esm/exception/http-errors/forbidden.error.js +4 -1
- package/esm/exception/http-errors/internal-server.error.js +4 -1
- package/esm/exception/http-errors/method-not-allowed.error.js +4 -1
- package/esm/exception/http-errors/not-acceptable.error.js +4 -1
- package/esm/exception/http-errors/not-found.error.js +4 -1
- package/esm/exception/http-errors/unauthorized.error.js +4 -1
- package/esm/exception/http-errors/unprocessable-entity.error.js +4 -1
- package/esm/exception/opra-exception.js +1 -3
- package/esm/exception/resource-errors/resource-conflict.error.js +1 -1
- package/esm/filter/antlr/OpraFilterLexer.js +349 -350
- package/esm/filter/antlr/OpraFilterParser.js +177 -178
- package/esm/filter/ast/abstract/ast.js +0 -1
- package/esm/filter/ast/expressions/arithmetic-expression.js +1 -3
- package/esm/filter/ast/expressions/array-expression.js +0 -1
- package/esm/filter/ast/expressions/comparison-expression.js +0 -3
- package/esm/filter/ast/expressions/logical-expression.js +0 -2
- package/esm/filter/ast/expressions/parentheses-expression.js +0 -1
- package/esm/filter/ast/terms/date-literal.js +0 -1
- package/esm/filter/ast/terms/null-literal.js +1 -1
- package/esm/filter/ast/terms/number-literal.js +0 -1
- package/esm/filter/ast/terms/time-literal.js +0 -1
- package/esm/filter/error-listener.js +0 -1
- package/esm/filter/errors.js +0 -5
- package/esm/filter/filter-tree-visitor.js +0 -1
- package/esm/helpers/responsive-map.js +3 -3
- package/esm/http/http-request.js +4 -18
- package/esm/http/multipart/batch-multipart.d.ts +2 -1
- package/esm/http/multipart/batch-multipart.js +2 -3
- package/esm/http/multipart/http-request-content.js +0 -4
- package/esm/http/multipart/http-response-content.js +0 -3
- package/esm/schema/implementation/data-type/complex-type.js +3 -4
- package/esm/schema/implementation/data-type/data-type.js +0 -3
- package/esm/schema/implementation/data-type/union-type.js +0 -2
- package/esm/schema/implementation/document-builder.js +6 -6
- package/esm/schema/implementation/opra-document.js +3 -3
- package/esm/schema/implementation/query/collection-count-query.js +3 -5
- package/esm/schema/implementation/query/collection-create-query.js +3 -8
- package/esm/schema/implementation/query/collection-delete-many-query.js +3 -5
- package/esm/schema/implementation/query/collection-delete-query.js +3 -5
- package/esm/schema/implementation/query/collection-get-query.js +3 -9
- package/esm/schema/implementation/query/collection-search-query.js +3 -13
- package/esm/schema/implementation/query/collection-update-many-query.js +3 -6
- package/esm/schema/implementation/query/collection-update-query.js +3 -9
- package/esm/schema/implementation/query/field-get-query.js +3 -14
- package/esm/schema/implementation/query/singleton-get-query.js +3 -8
- package/esm/schema/implementation/resource/collection-resource-info.js +0 -1
- package/esm/schema/implementation/resource/resource-info.js +0 -4
- package/esm/schema/implementation/resource/singleton-resource-info.js +0 -1
- package/esm/schema/implementation/schema-builder/extract-type-metadata.util.js +5 -4
- package/esm/schema/type-helpers/extend-type.helper.js +4 -3
- package/esm/schema/type-helpers/mixin-type.helper.js +4 -3
- package/esm/url/formats/date-format.js +0 -4
- package/esm/url/formats/integer-format.js +0 -1
- package/esm/url/formats/number-format.js +0 -2
- package/esm/url/formats/string-format.js +0 -3
- package/esm/url/opra-url-path-component.js +0 -3
- package/esm/url/opra-url-path.js +1 -1
- package/esm/url/opra-url-search-params.d.ts +0 -2
- package/esm/url/opra-url-search-params.js +3 -4
- package/esm/url/opra-url.js +0 -3
- package/package.json +10 -17
- package/README.md +0 -3
- package/umd/opra-common.umd.min.js +0 -1
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DocumentBuilder = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const putil_promisify_1 = require("putil-promisify");
|
|
6
|
-
const Optionals = tslib_1.__importStar(require("@opra/optionals"));
|
|
7
5
|
const responsive_map_js_1 = require("../../helpers/responsive-map.js");
|
|
8
6
|
const opra_schema_definition_js_1 = require("../opra-schema.definition.js");
|
|
9
7
|
const class_utils_js_1 = require("../utils/class.utils.js");
|
|
10
8
|
const builtin_data_types_js_1 = require("./data-type/builtin-data-types.js");
|
|
11
9
|
const extract_resource_metadata_util_js_1 = require("./schema-builder/extract-resource-metadata.util.js");
|
|
12
10
|
const extract_type_metadata_util_js_1 = require("./schema-builder/extract-type-metadata.util.js");
|
|
11
|
+
const optionalsSymbol = Symbol.for('opra.optional-lib.sqb-connect');
|
|
13
12
|
class DocumentBuilder {
|
|
14
|
-
_args;
|
|
15
|
-
_dataTypes = new responsive_map_js_1.ResponsiveMap();
|
|
16
|
-
_resources = new responsive_map_js_1.ResponsiveMap();
|
|
17
13
|
constructor(args) {
|
|
14
|
+
this._dataTypes = new responsive_map_js_1.ResponsiveMap();
|
|
15
|
+
this._resources = new responsive_map_js_1.ResponsiveMap();
|
|
18
16
|
this._args = args;
|
|
19
17
|
}
|
|
20
18
|
buildSchema() {
|
|
@@ -97,8 +95,9 @@ class DocumentBuilder {
|
|
|
97
95
|
// Determine keyFields if not set
|
|
98
96
|
if (!schema.keyFields) {
|
|
99
97
|
const dataType = this._dataTypes.get(schema.type);
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
const SqbConnect = globalThis[optionalsSymbol]?.SqbConnect;
|
|
99
|
+
if (SqbConnect && dataType?.ctor) {
|
|
100
|
+
const sqbEntity = SqbConnect.EntityMetadata.get(dataType?.ctor);
|
|
102
101
|
if (sqbEntity?.indexes) {
|
|
103
102
|
const primaryIndex = sqbEntity.indexes.find(x => x.primary);
|
|
104
103
|
if (primaryIndex) {
|
|
@@ -14,10 +14,10 @@ const document_builder_js_1 = require("./document-builder.js");
|
|
|
14
14
|
const collection_resource_info_js_1 = require("./resource/collection-resource-info.js");
|
|
15
15
|
const singleton_resource_info_js_1 = require("./resource/singleton-resource-info.js");
|
|
16
16
|
class OpraDocument {
|
|
17
|
-
_ownTypes = new responsive_map_js_1.ResponsiveMap();
|
|
18
|
-
_types = new responsive_map_js_1.ResponsiveMap();
|
|
19
|
-
_resources = new responsive_map_js_1.ResponsiveMap();
|
|
20
17
|
constructor(schema) {
|
|
18
|
+
this._ownTypes = new responsive_map_js_1.ResponsiveMap();
|
|
19
|
+
this._types = new responsive_map_js_1.ResponsiveMap();
|
|
20
|
+
this._resources = new responsive_map_js_1.ResponsiveMap();
|
|
21
21
|
this._meta = (0, lodash_1.omit)(schema, ['types', 'resources']);
|
|
22
22
|
for (const [name, t] of builtin_data_types_js_1.builtInTypes.entries()) {
|
|
23
23
|
this._addDataType(name, t, false);
|
|
@@ -3,13 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CollectionCountQuery = void 0;
|
|
4
4
|
const index_js_1 = require("../../../filter/index.js");
|
|
5
5
|
class CollectionCountQuery {
|
|
6
|
-
resource;
|
|
7
|
-
kind = 'CollectionCountQuery';
|
|
8
|
-
method = 'count';
|
|
9
|
-
operation = 'read';
|
|
10
|
-
filter;
|
|
11
6
|
constructor(resource, options) {
|
|
12
7
|
this.resource = resource;
|
|
8
|
+
this.kind = 'CollectionCountQuery';
|
|
9
|
+
this.method = 'count';
|
|
10
|
+
this.operation = 'read';
|
|
13
11
|
this.filter = typeof options?.filter === 'string' ? (0, index_js_1.parseFilter)(options.filter) : options?.filter;
|
|
14
12
|
}
|
|
15
13
|
get dataType() {
|
|
@@ -3,17 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CollectionCreateQuery = void 0;
|
|
4
4
|
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
5
5
|
class CollectionCreateQuery {
|
|
6
|
-
resource;
|
|
7
|
-
data;
|
|
8
|
-
kind = 'CollectionCreateQuery';
|
|
9
|
-
method = 'create';
|
|
10
|
-
operation = 'create';
|
|
11
|
-
pick;
|
|
12
|
-
omit;
|
|
13
|
-
include;
|
|
14
6
|
constructor(resource, data, options) {
|
|
15
7
|
this.resource = resource;
|
|
16
8
|
this.data = data;
|
|
9
|
+
this.kind = 'CollectionCreateQuery';
|
|
10
|
+
this.method = 'create';
|
|
11
|
+
this.operation = 'create';
|
|
17
12
|
if (options?.pick)
|
|
18
13
|
this.pick = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.pick);
|
|
19
14
|
if (options?.omit)
|
|
@@ -3,13 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CollectionDeleteManyQuery = void 0;
|
|
4
4
|
const index_js_1 = require("../../../filter/index.js");
|
|
5
5
|
class CollectionDeleteManyQuery {
|
|
6
|
-
resource;
|
|
7
|
-
kind = 'CollectionDeleteManyQuery';
|
|
8
|
-
method = 'deleteMany';
|
|
9
|
-
operation = 'delete';
|
|
10
|
-
filter;
|
|
11
6
|
constructor(resource, options) {
|
|
12
7
|
this.resource = resource;
|
|
8
|
+
this.kind = 'CollectionDeleteManyQuery';
|
|
9
|
+
this.method = 'deleteMany';
|
|
10
|
+
this.operation = 'delete';
|
|
13
11
|
this.filter = typeof options?.filter === 'string' ? (0, index_js_1.parseFilter)(options.filter) : options?.filter;
|
|
14
12
|
}
|
|
15
13
|
get dataType() {
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CollectionDeleteQuery = void 0;
|
|
4
4
|
class CollectionDeleteQuery {
|
|
5
|
-
resource;
|
|
6
|
-
kind = 'CollectionDeleteQuery';
|
|
7
|
-
method = 'delete';
|
|
8
|
-
operation = 'delete';
|
|
9
|
-
keyValue;
|
|
10
5
|
constructor(resource, keyValue) {
|
|
11
6
|
this.resource = resource;
|
|
7
|
+
this.kind = 'CollectionDeleteQuery';
|
|
8
|
+
this.method = 'delete';
|
|
9
|
+
this.operation = 'delete';
|
|
12
10
|
if (resource.keyFields.length > 1) {
|
|
13
11
|
if (typeof keyValue !== 'object')
|
|
14
12
|
throw new Error(`You must provide an key/value object for all key fields (${resource.keyFields})`);
|
|
@@ -3,17 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CollectionGetQuery = void 0;
|
|
4
4
|
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
5
5
|
class CollectionGetQuery {
|
|
6
|
-
resource;
|
|
7
|
-
kind = 'CollectionGetQuery';
|
|
8
|
-
method = 'get';
|
|
9
|
-
operation = 'read';
|
|
10
|
-
keyValue;
|
|
11
|
-
pick;
|
|
12
|
-
omit;
|
|
13
|
-
include;
|
|
14
|
-
child;
|
|
15
6
|
constructor(resource, keyValue, options) {
|
|
16
7
|
this.resource = resource;
|
|
8
|
+
this.kind = 'CollectionGetQuery';
|
|
9
|
+
this.method = 'get';
|
|
10
|
+
this.operation = 'read';
|
|
17
11
|
if (resource.keyFields.length > 1) {
|
|
18
12
|
if (typeof keyValue !== 'object')
|
|
19
13
|
throw new Error(`You must provide an key/value object for all key fields (${resource.keyFields})`);
|
|
@@ -6,21 +6,11 @@ const index_js_2 = require("../../../filter/index.js");
|
|
|
6
6
|
const index_js_3 = require("../../../i18n/index.js");
|
|
7
7
|
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
8
8
|
class CollectionSearchQuery {
|
|
9
|
-
resource;
|
|
10
|
-
kind = 'CollectionSearchQuery';
|
|
11
|
-
method = 'search';
|
|
12
|
-
operation = 'read';
|
|
13
|
-
pick;
|
|
14
|
-
omit;
|
|
15
|
-
include;
|
|
16
|
-
filter;
|
|
17
|
-
limit;
|
|
18
|
-
skip;
|
|
19
|
-
distinct;
|
|
20
|
-
count;
|
|
21
|
-
sort;
|
|
22
9
|
constructor(resource, options) {
|
|
23
10
|
this.resource = resource;
|
|
11
|
+
this.kind = 'CollectionSearchQuery';
|
|
12
|
+
this.method = 'search';
|
|
13
|
+
this.operation = 'read';
|
|
24
14
|
if (options?.pick)
|
|
25
15
|
this.pick = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.pick);
|
|
26
16
|
if (options?.omit)
|
|
@@ -3,15 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CollectionUpdateManyQuery = void 0;
|
|
4
4
|
const index_js_1 = require("../../../filter/index.js");
|
|
5
5
|
class CollectionUpdateManyQuery {
|
|
6
|
-
resource;
|
|
7
|
-
data;
|
|
8
|
-
kind = 'CollectionUpdateManyQuery';
|
|
9
|
-
method = 'updateMany';
|
|
10
|
-
operation = 'update';
|
|
11
|
-
filter;
|
|
12
6
|
constructor(resource, data, options) {
|
|
13
7
|
this.resource = resource;
|
|
14
8
|
this.data = data;
|
|
9
|
+
this.kind = 'CollectionUpdateManyQuery';
|
|
10
|
+
this.method = 'updateMany';
|
|
11
|
+
this.operation = 'update';
|
|
15
12
|
this.filter = typeof options?.filter === 'string' ? (0, index_js_1.parseFilter)(options.filter) : options?.filter;
|
|
16
13
|
}
|
|
17
14
|
get dataType() {
|
|
@@ -3,18 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CollectionUpdateQuery = void 0;
|
|
4
4
|
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
5
5
|
class CollectionUpdateQuery {
|
|
6
|
-
resource;
|
|
7
|
-
data;
|
|
8
|
-
kind = 'CollectionUpdateQuery';
|
|
9
|
-
method = 'update';
|
|
10
|
-
operation = 'update';
|
|
11
|
-
keyValue;
|
|
12
|
-
pick;
|
|
13
|
-
omit;
|
|
14
|
-
include;
|
|
15
6
|
constructor(resource, keyValue, data, options) {
|
|
16
7
|
this.resource = resource;
|
|
17
8
|
this.data = data;
|
|
9
|
+
this.kind = 'CollectionUpdateQuery';
|
|
10
|
+
this.method = 'update';
|
|
11
|
+
this.operation = 'update';
|
|
18
12
|
if (resource.keyFields.length > 1) {
|
|
19
13
|
if (typeof keyValue !== 'object')
|
|
20
14
|
throw new Error(`You must provide an key/value object for all key fields (${resource.keyFields})`);
|
|
@@ -4,22 +4,11 @@ exports.FieldGetQuery = void 0;
|
|
|
4
4
|
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
5
5
|
const complex_type_js_1 = require("../data-type/complex-type.js");
|
|
6
6
|
class FieldGetQuery {
|
|
7
|
-
parent;
|
|
8
|
-
resource;
|
|
9
|
-
kind = 'FieldGetQuery';
|
|
10
|
-
method = 'get';
|
|
11
|
-
operation = 'read';
|
|
12
|
-
fieldName;
|
|
13
|
-
field;
|
|
14
|
-
path;
|
|
15
|
-
dataType;
|
|
16
|
-
parentType;
|
|
17
|
-
pick;
|
|
18
|
-
omit;
|
|
19
|
-
include;
|
|
20
|
-
child;
|
|
21
7
|
constructor(parent, fieldName, options) {
|
|
22
8
|
this.parent = parent;
|
|
9
|
+
this.kind = 'FieldGetQuery';
|
|
10
|
+
this.method = 'get';
|
|
11
|
+
this.operation = 'read';
|
|
23
12
|
this.resource = parent.resource;
|
|
24
13
|
const parentType = options?.castingType || parent.dataType;
|
|
25
14
|
if (!parentType || !(parentType instanceof complex_type_js_1.ComplexType))
|
|
@@ -3,16 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SingletonGetQuery = void 0;
|
|
4
4
|
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
5
5
|
class SingletonGetQuery {
|
|
6
|
-
resource;
|
|
7
|
-
kind = 'SingletonGetQuery';
|
|
8
|
-
method = 'get';
|
|
9
|
-
operation = 'read';
|
|
10
|
-
pick;
|
|
11
|
-
omit;
|
|
12
|
-
include;
|
|
13
|
-
child;
|
|
14
6
|
constructor(resource, options) {
|
|
15
7
|
this.resource = resource;
|
|
8
|
+
this.kind = 'SingletonGetQuery';
|
|
9
|
+
this.method = 'get';
|
|
10
|
+
this.operation = 'read';
|
|
16
11
|
if (options?.pick)
|
|
17
12
|
this.pick = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.pick);
|
|
18
13
|
if (options?.omit)
|
|
@@ -5,7 +5,6 @@ const constants_js_1 = require("../../constants.js");
|
|
|
5
5
|
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
6
6
|
const resource_info_js_1 = require("./resource-info.js");
|
|
7
7
|
class CollectionResourceInfo extends resource_info_js_1.ResourceInfo {
|
|
8
|
-
dataType;
|
|
9
8
|
constructor(document, name, dataType, metadata) {
|
|
10
9
|
if (!metadata.keyFields)
|
|
11
10
|
throw new TypeError(`You should provide key fields for ${name}`);
|
|
@@ -4,10 +4,6 @@ exports.ResourceInfo = void 0;
|
|
|
4
4
|
const clone_object_util_js_1 = require("../../utils/clone-object.util.js");
|
|
5
5
|
const inspect_util_js_1 = require("../../utils/inspect.util.js");
|
|
6
6
|
class ResourceInfo {
|
|
7
|
-
metadata;
|
|
8
|
-
document;
|
|
9
|
-
name;
|
|
10
|
-
path;
|
|
11
7
|
constructor(document, name, metadata) {
|
|
12
8
|
this.document = document;
|
|
13
9
|
this.name = name;
|
|
@@ -5,7 +5,6 @@ const constants_js_1 = require("../../constants.js");
|
|
|
5
5
|
const complex_type_js_1 = require("../data-type/complex-type.js");
|
|
6
6
|
const resource_info_js_1 = require("./resource-info.js");
|
|
7
7
|
class SingletonResourceInfo extends resource_info_js_1.ResourceInfo {
|
|
8
|
-
dataType;
|
|
9
8
|
constructor(document, name, dataType, metadata) {
|
|
10
9
|
// noinspection SuspiciousTypeOfGuard
|
|
11
10
|
if (!(dataType instanceof complex_type_js_1.ComplexType))
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractDataTypeSchema = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const Optionals = tslib_1.__importStar(require("@opra/optionals"));
|
|
6
4
|
const constants_js_1 = require("../../constants.js");
|
|
7
5
|
const opra_schema_definition_js_1 = require("../../opra-schema.definition.js");
|
|
8
6
|
const clone_object_util_js_1 = require("../../utils/clone-object.util.js");
|
|
9
7
|
const builtin_data_types_js_1 = require("../data-type/builtin-data-types.js");
|
|
8
|
+
const optionalsSymbol = Symbol.for('opra.optional-lib.sqb-connect');
|
|
10
9
|
async function extractDataTypeSchema(ctor) {
|
|
11
10
|
const metadata = Reflect.getMetadata(constants_js_1.DATATYPE_METADATA, ctor);
|
|
12
11
|
if (!metadata)
|
|
@@ -39,9 +38,10 @@ async function extractComplexTypeSchema(ctor, metadata) {
|
|
|
39
38
|
if (type)
|
|
40
39
|
field.type = type;
|
|
41
40
|
}
|
|
41
|
+
const SqbConnect = globalThis[optionalsSymbol]?.SqbConnect;
|
|
42
42
|
let sqbField;
|
|
43
|
-
if (
|
|
44
|
-
const { EntityMetadata, isAssociationField } =
|
|
43
|
+
if (SqbConnect) {
|
|
44
|
+
const { EntityMetadata, isAssociationField } = SqbConnect;
|
|
45
45
|
const meta = EntityMetadata.get(ctor);
|
|
46
46
|
sqbField = meta && EntityMetadata.getField(meta, fieldName);
|
|
47
47
|
if (sqbField) {
|
|
@@ -62,7 +62,7 @@ async function extractComplexTypeSchema(ctor, metadata) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
if (sqbField && sqbField.kind === 'column') {
|
|
65
|
-
const DataType =
|
|
65
|
+
const DataType = SqbConnect.DataType;
|
|
66
66
|
if (field.type === 'number' || field.type === Number) {
|
|
67
67
|
switch (sqbField.dataType) {
|
|
68
68
|
case DataType.INTEGER:
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OmitType = exports.PickType = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const Optionals = tslib_1.__importStar(require("@opra/optionals"));
|
|
6
4
|
const constants_js_1 = require("../constants.js");
|
|
7
5
|
const mixin_utils_js_1 = require("./mixin.utils.js");
|
|
6
|
+
const optionalsSymbol = Symbol.for('opra.optional-lib.sqb-connect');
|
|
8
7
|
function PickType(classRef, keys) {
|
|
9
8
|
return ExtendType(classRef, classRef, { pickKeys: keys });
|
|
10
9
|
}
|
|
@@ -52,8 +51,9 @@ function ExtendType(classRef, orgClassRef, options) {
|
|
|
52
51
|
}
|
|
53
52
|
else
|
|
54
53
|
throw new TypeError(`Class "${classRef}" doesn't have datatype metadata information`);
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
const SqbConnect = globalThis[optionalsSymbol]?.SqbConnect;
|
|
55
|
+
if (SqbConnect) {
|
|
56
|
+
const { Entity, EntityMetadata } = SqbConnect;
|
|
57
57
|
const srcMeta = Entity.getMetadata(classRef);
|
|
58
58
|
if (srcMeta) {
|
|
59
59
|
const trgMeta = EntityMetadata.define(MappedClass);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MixinType = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const Optionals = tslib_1.__importStar(require("@opra/optionals"));
|
|
6
4
|
const constants_js_1 = require("../constants.js");
|
|
7
5
|
const mixin_utils_js_1 = require("./mixin.utils.js");
|
|
6
|
+
const optionalsSymbol = Symbol.for('opra.optional-lib.sqb-connect');
|
|
8
7
|
function MixinType(c1, c2, c3, c4) {
|
|
9
8
|
const clasRefs = [...arguments].filter(x => !!x);
|
|
10
9
|
if (!clasRefs.length)
|
|
@@ -36,8 +35,9 @@ function MixinType(c1, c2, c3, c4) {
|
|
|
36
35
|
throw new TypeError(`Class "${c}" doesn't have datatype metadata information`);
|
|
37
36
|
(0, mixin_utils_js_1.applyMixins)(MappedClass, c);
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const SqbConnect = globalThis[optionalsSymbol]?.SqbConnect;
|
|
39
|
+
if (SqbConnect) {
|
|
40
|
+
const { Entity } = SqbConnect;
|
|
41
41
|
Entity.mixin(MappedClass, ...clasRefs);
|
|
42
42
|
}
|
|
43
43
|
Reflect.defineMetadata(constants_js_1.MAPPED_TYPE_METADATA, mappedTypeMetadata, MappedClass);
|
|
@@ -6,10 +6,6 @@ const format_js_1 = require("./format.js");
|
|
|
6
6
|
// noinspection RegExpUnnecessaryNonCapturingGroup
|
|
7
7
|
const DATE_FORMAT_PATTERN = /^(\d{4})(?:-?(0[1-9]|1[012])(?:-?([123]0|[012][1-9]|31))?)?(?:[T ]?([01][0-9]|2[0-3]):?([0-5][0-9]):?([0-5][0-9])?(?:\.(\d+))?(?:(Z)|(?:([+-])([01]?[0-9]|2[0-3]):?([0-5][0-9])?))?)?$/;
|
|
8
8
|
class DateFormat extends format_js_1.Format {
|
|
9
|
-
time;
|
|
10
|
-
timeZone;
|
|
11
|
-
min;
|
|
12
|
-
max;
|
|
13
9
|
constructor(options) {
|
|
14
10
|
super();
|
|
15
11
|
this.max = options?.max ? coerceToDateString(options.max) : undefined;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.IntegerFormat = void 0;
|
|
4
4
|
const number_format_js_1 = require("./number-format.js");
|
|
5
5
|
class IntegerFormat extends number_format_js_1.NumberFormat {
|
|
6
|
-
enum;
|
|
7
6
|
constructor(options) {
|
|
8
7
|
super(options);
|
|
9
8
|
this.enum = options?.enum;
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NumberFormat = void 0;
|
|
4
4
|
const format_js_1 = require("./format.js");
|
|
5
5
|
class NumberFormat extends format_js_1.Format {
|
|
6
|
-
max;
|
|
7
|
-
min;
|
|
8
6
|
constructor(options) {
|
|
9
7
|
super();
|
|
10
8
|
this.max = options?.max;
|
|
@@ -3,9 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StringFormat = void 0;
|
|
4
4
|
const format_js_1 = require("./format.js");
|
|
5
5
|
class StringFormat extends format_js_1.Format {
|
|
6
|
-
maxLength;
|
|
7
|
-
minLength;
|
|
8
|
-
enum;
|
|
9
6
|
constructor(options) {
|
|
10
7
|
super();
|
|
11
8
|
this.maxLength = options?.maxLength;
|
|
@@ -4,9 +4,6 @@ exports.OpraURLPathComponent = void 0;
|
|
|
4
4
|
const path_utils_js_1 = require("./utils/path-utils.js");
|
|
5
5
|
const nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
|
|
6
6
|
class OpraURLPathComponent {
|
|
7
|
-
resource;
|
|
8
|
-
key;
|
|
9
|
-
typeCast;
|
|
10
7
|
constructor(init) {
|
|
11
8
|
this.resource = init.resource;
|
|
12
9
|
this.key = init.key;
|
package/cjs/url/opra-url-path.js
CHANGED
|
@@ -8,9 +8,9 @@ const opra_url_path_component_js_1 = require("./opra-url-path-component.js");
|
|
|
8
8
|
const path_utils_js_1 = require("./utils/path-utils.js");
|
|
9
9
|
const nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
|
|
10
10
|
class OpraURLPath extends events_1.EventEmitter {
|
|
11
|
-
_entries = [];
|
|
12
11
|
constructor(...args) {
|
|
13
12
|
super();
|
|
13
|
+
this._entries = [];
|
|
14
14
|
for (const x of args) {
|
|
15
15
|
if ((0, index_js_1.isURL)(x)) {
|
|
16
16
|
this._parse(x.pathname);
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OpraURLSearchParams = void 0;
|
|
4
4
|
const events_1 = require("events");
|
|
5
5
|
const fast_tokenizer_1 = require("fast-tokenizer");
|
|
6
|
-
const url_1 = require("url");
|
|
7
6
|
const index_js_1 = require("../helpers/index.js");
|
|
8
7
|
const boolean_format_js_1 = require("./formats/boolean-format.js");
|
|
9
8
|
const date_format_js_1 = require("./formats/date-format.js");
|
|
@@ -21,11 +20,11 @@ const internalFormats = {
|
|
|
21
20
|
};
|
|
22
21
|
const nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
|
|
23
22
|
class OpraURLSearchParams extends events_1.EventEmitter {
|
|
24
|
-
_params = new index_js_1.ResponsiveMap();
|
|
25
|
-
_entries = new index_js_1.ResponsiveMap();
|
|
26
|
-
_size = 0;
|
|
27
23
|
constructor(init) {
|
|
28
24
|
super();
|
|
25
|
+
this._params = new index_js_1.ResponsiveMap();
|
|
26
|
+
this._entries = new index_js_1.ResponsiveMap();
|
|
27
|
+
this._size = 0;
|
|
29
28
|
this.defineParam('$filter', { format: 'filter' });
|
|
30
29
|
this.defineParam('$limit', { format: new integer_format_js_1.IntegerFormat({ min: 0 }) });
|
|
31
30
|
this.defineParam('$skip', { format: new integer_format_js_1.IntegerFormat({ min: 0 }) });
|
|
@@ -185,7 +184,7 @@ class OpraURLSearchParams extends events_1.EventEmitter {
|
|
|
185
184
|
this.emit('change');
|
|
186
185
|
}
|
|
187
186
|
toURLSearchParams() {
|
|
188
|
-
const out = new
|
|
187
|
+
const out = new URLSearchParams();
|
|
189
188
|
this.forEach((v, k) => {
|
|
190
189
|
const qi = this._params.get(k);
|
|
191
190
|
const format = qi
|
package/cjs/url/opra-url.js
CHANGED
|
@@ -14,9 +14,6 @@ const CONTEXT_KEY = Symbol.for('opra.url.context');
|
|
|
14
14
|
const PATH_KEY = Symbol.for('opra.url.path');
|
|
15
15
|
const SEARCHPARAMS_KEY = Symbol.for('opra.url.searchparams');
|
|
16
16
|
class OpraURL {
|
|
17
|
-
[CONTEXT_KEY];
|
|
18
|
-
[PATH_KEY];
|
|
19
|
-
[SEARCHPARAMS_KEY];
|
|
20
17
|
constructor(input, pathPrefix) {
|
|
21
18
|
Object.defineProperty(this, CONTEXT_KEY, {
|
|
22
19
|
writable: true,
|
|
@@ -6,7 +6,10 @@ import { OpraException } from '../opra-exception.js';
|
|
|
6
6
|
* (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
|
|
7
7
|
*/
|
|
8
8
|
export class BadRequestError extends OpraException {
|
|
9
|
-
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.status = 400;
|
|
12
|
+
}
|
|
10
13
|
setIssue(issue) {
|
|
11
14
|
super.setIssue({
|
|
12
15
|
message: translate('error:BAD_REQUEST', 'Bad request'),
|
|
@@ -5,7 +5,10 @@ import { OpraException } from '../opra-exception.js';
|
|
|
5
5
|
* The request failed due to failure of a previous request.
|
|
6
6
|
*/
|
|
7
7
|
export class FailedDependencyError extends OpraException {
|
|
8
|
-
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.status = 424;
|
|
11
|
+
}
|
|
9
12
|
setIssue(issue) {
|
|
10
13
|
super.setIssue({
|
|
11
14
|
message: translate('error:FAILED_DEPENDENCY', 'The request failed due to failure of a previous request'),
|
|
@@ -7,7 +7,10 @@ import { OpraException } from '../opra-exception.js';
|
|
|
7
7
|
* the client's identity is known to the server.
|
|
8
8
|
*/
|
|
9
9
|
export class ForbiddenError extends OpraException {
|
|
10
|
-
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.status = 403;
|
|
13
|
+
}
|
|
11
14
|
setIssue(issue) {
|
|
12
15
|
super.setIssue({
|
|
13
16
|
message: translate('error:FORBIDDEN', 'You are not authorized to perform this action'),
|
|
@@ -5,7 +5,10 @@ import { OpraException } from '../opra-exception.js';
|
|
|
5
5
|
* The server has encountered a situation it does not know how to handle.
|
|
6
6
|
*/
|
|
7
7
|
export class InternalServerError extends OpraException {
|
|
8
|
-
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.status = 500;
|
|
11
|
+
}
|
|
9
12
|
setIssue(issue) {
|
|
10
13
|
super.setIssue({
|
|
11
14
|
message: translate('error:INTERNAL_SERVER_ERROR', 'Internal server error'),
|
|
@@ -6,7 +6,10 @@ import { OpraException } from '../opra-exception.js';
|
|
|
6
6
|
* For example, an API may not allow calling DELETE to remove a resource.
|
|
7
7
|
*/
|
|
8
8
|
export class MethodNotAllowedError extends OpraException {
|
|
9
|
-
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.status = 405;
|
|
12
|
+
}
|
|
10
13
|
setIssue(issue) {
|
|
11
14
|
super.setIssue({
|
|
12
15
|
message: translate('error:METHOD_NOT_ALLOWED', 'Method not allowed'),
|
|
@@ -6,7 +6,10 @@ import { OpraException } from '../opra-exception.js';
|
|
|
6
6
|
* doesn't find any content that conforms to the criteria given by the user agent.
|
|
7
7
|
*/
|
|
8
8
|
export class NotAcceptableError extends OpraException {
|
|
9
|
-
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.status = 406;
|
|
12
|
+
}
|
|
10
13
|
setIssue(issue) {
|
|
11
14
|
super.setIssue({
|
|
12
15
|
message: translate('error:NOT_ACCEPTABLE', 'Not Acceptable'),
|
|
@@ -9,7 +9,10 @@ import { OpraException } from '../opra-exception.js';
|
|
|
9
9
|
* frequent occurrence on the web.
|
|
10
10
|
*/
|
|
11
11
|
export class NotFoundError extends OpraException {
|
|
12
|
-
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.status = 404;
|
|
15
|
+
}
|
|
13
16
|
setIssue(issue) {
|
|
14
17
|
super.setIssue({
|
|
15
18
|
message: translate('error:NOT_FOUND', 'Not found'),
|
|
@@ -6,7 +6,10 @@ import { OpraException } from '../opra-exception.js';
|
|
|
6
6
|
* That is, the client must authenticate itself to get the requested response.
|
|
7
7
|
*/
|
|
8
8
|
export class UnauthorizedError extends OpraException {
|
|
9
|
-
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.status = 401;
|
|
12
|
+
}
|
|
10
13
|
setIssue(issue) {
|
|
11
14
|
super.setIssue({
|
|
12
15
|
message: translate('error:UNAUTHORIZED', 'You have not been authenticated to perform this action'),
|
|
@@ -5,7 +5,10 @@ import { OpraException } from '../opra-exception.js';
|
|
|
5
5
|
* The request was well-formed but was unable to be followed due to semantic errors.
|
|
6
6
|
*/
|
|
7
7
|
export class UnprocessableEntityError extends OpraException {
|
|
8
|
-
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.status = 422;
|
|
11
|
+
}
|
|
9
12
|
setIssue(issue) {
|
|
10
13
|
super.setIssue({
|
|
11
14
|
message: translate('error:UNPROCESSABLE_ENTITY', 'Unprocessable entity'),
|
|
@@ -3,11 +3,9 @@ import { i18n } from '../i18n/index.js';
|
|
|
3
3
|
* Defines the base Opra exception, which is handled by the default Exceptions Handler.
|
|
4
4
|
*/
|
|
5
5
|
export class OpraException extends Error {
|
|
6
|
-
_issue;
|
|
7
|
-
status = 500;
|
|
8
|
-
cause;
|
|
9
6
|
constructor(issue, cause) {
|
|
10
7
|
super('');
|
|
8
|
+
this.status = 500;
|
|
11
9
|
this._initName();
|
|
12
10
|
if (cause) {
|
|
13
11
|
this.cause = cause;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { translate } from '../../i18n/index.js';
|
|
2
2
|
import { OpraException } from '../opra-exception.js';
|
|
3
3
|
export class ResourceConflictError extends OpraException {
|
|
4
|
-
status = 409;
|
|
5
4
|
constructor(resource, fields, cause) {
|
|
6
5
|
super({
|
|
7
6
|
message: translate(`error:RESOURCE_CONFLICT`, { resource, fields }, `There is already an other {{resource}} resource with same field values ({{fields}})`),
|
|
@@ -12,5 +11,6 @@ export class ResourceConflictError extends OpraException {
|
|
|
12
11
|
location: fields
|
|
13
12
|
},
|
|
14
13
|
}, cause);
|
|
14
|
+
this.status = 409;
|
|
15
15
|
}
|
|
16
16
|
}
|