@opra/common 1.0.0-alpha.37 → 1.0.0-alpha.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/index.cjs +5 -5
- package/browser/index.mjs +5 -5
- package/cjs/document/data-type/complex-type-base.js +1 -1
- package/cjs/document/data-type/extended-types/filter.type.js +1 -1
- package/cjs/filter/filter-rules.js +17 -16
- package/cjs/helpers/index.js +1 -0
- package/cjs/helpers/safe-json-stringify.js +16 -0
- package/cjs/schema/index.js +2 -27
- package/cjs/schema/opra-schema.js +24 -0
- package/esm/document/data-type/complex-type-base.js +1 -1
- package/esm/document/data-type/extended-types/filter.type.js +1 -1
- package/esm/filter/filter-rules.js +10 -9
- package/esm/helpers/index.js +1 -0
- package/esm/helpers/safe-json-stringify.js +13 -0
- package/esm/schema/index.js +2 -27
- package/esm/schema/opra-schema.js +21 -0
- package/package.json +2 -2
- package/types/document/api-document.d.ts +1 -1
- package/types/document/common/data-type-map.d.ts +1 -1
- package/types/document/common/document-node.d.ts +1 -1
- package/types/document/common/value.d.ts +1 -1
- package/types/document/data-type/api-field.d.ts +1 -1
- package/types/document/data-type/complex-type-base.d.ts +3 -4
- package/types/document/data-type/complex-type.d.ts +1 -1
- package/types/document/data-type/data-type.d.ts +2 -2
- package/types/document/data-type/enum-type.d.ts +2 -2
- package/types/document/data-type/extended-types/base64.type.d.ts +1 -1
- package/types/document/data-type/extended-types/date-string.type.d.ts +1 -1
- package/types/document/data-type/extended-types/date-time-string.type.d.ts +1 -1
- package/types/document/data-type/extended-types/date-time.type.d.ts +1 -1
- package/types/document/data-type/extended-types/date.type.d.ts +1 -1
- package/types/document/data-type/extended-types/email.type.d.ts +1 -1
- package/types/document/data-type/extended-types/field-path.type.d.ts +3 -3
- package/types/document/data-type/extended-types/filter.type.d.ts +3 -3
- package/types/document/data-type/extended-types/object-id.type.d.ts +1 -1
- package/types/document/data-type/extended-types/operation-result.type.d.ts +2 -2
- package/types/document/data-type/extended-types/time.type.d.ts +1 -1
- package/types/document/data-type/extended-types/url.type.d.ts +1 -1
- package/types/document/data-type/extended-types/uuid.type.d.ts +1 -1
- package/types/document/data-type/mapped-type.d.ts +1 -1
- package/types/document/data-type/mixin-type.d.ts +1 -1
- package/types/document/data-type/omit-type.d.ts +1 -1
- package/types/document/data-type/partial-type.d.ts +1 -1
- package/types/document/data-type/pick-type.d.ts +1 -1
- package/types/document/data-type/primitive-types/any.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/bigint.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/boolean.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/integer.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/null.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/number.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/string.type.d.ts +1 -1
- package/types/document/data-type/required-type.d.ts +1 -1
- package/types/document/data-type/simple-type.d.ts +2 -2
- package/types/document/data-type/utils/create-mapped-class.d.ts +1 -1
- package/types/document/decorators/http-controller.decorator.d.ts +1 -1
- package/types/document/decorators/http-operation-entity.decorator.d.ts +2 -2
- package/types/document/decorators/http-operation.decorator.d.ts +1 -1
- package/types/document/factory/api-document.factory.d.ts +1 -1
- package/types/document/factory/data-type.factory.d.ts +1 -1
- package/types/document/factory/http-api.factory.d.ts +1 -1
- package/types/document/http/http-api.d.ts +1 -1
- package/types/document/http/http-controller.d.ts +1 -1
- package/types/document/http/http-media-type.d.ts +2 -2
- package/types/document/http/http-multipart-field.d.ts +1 -1
- package/types/document/http/http-operation-response.d.ts +1 -1
- package/types/document/http/http-operation.d.ts +2 -2
- package/types/document/http/http-parameter.d.ts +1 -1
- package/types/document/http/http-request-body.d.ts +1 -1
- package/types/exception/http-errors/bad-request.error.d.ts +1 -1
- package/types/exception/http-errors/conflict.error.d.ts +1 -1
- package/types/exception/http-errors/failed-dependency.error.d.ts +1 -1
- package/types/exception/http-errors/forbidden.error.d.ts +1 -1
- package/types/exception/http-errors/internal-server.error.d.ts +1 -1
- package/types/exception/http-errors/method-not-allowed.error.d.ts +1 -1
- package/types/exception/http-errors/not-acceptable.error.d.ts +1 -1
- package/types/exception/http-errors/not-found.error.d.ts +1 -1
- package/types/exception/http-errors/permission.error.d.ts +1 -1
- package/types/exception/http-errors/unauthorized.error.d.ts +1 -1
- package/types/exception/http-errors/unprocessable-entity.error.d.ts +1 -1
- package/types/exception/opra-exception.d.ts +1 -1
- package/types/exception/opra-http-error.d.ts +1 -1
- package/types/filter/antlr/OpraFilterParser.d.ts +1 -1
- package/types/filter/ast/expressions/comparison-expression.d.ts +1 -1
- package/types/filter/errors.d.ts +1 -1
- package/types/filter/filter-rules.d.ts +5 -5
- package/types/filter/opra-error-listener.d.ts +1 -1
- package/types/helpers/function-utils.d.ts +1 -1
- package/types/helpers/index.d.ts +1 -0
- package/types/helpers/mixin-utils.d.ts +1 -1
- package/types/helpers/object-utils.d.ts +1 -1
- package/types/helpers/safe-json-stringify.d.ts +1 -0
- package/types/helpers/type-guards.d.ts +1 -1
- package/types/i18n/i18n.d.ts +2 -2
- package/types/i18n/translate.d.ts +1 -1
- package/types/schema/{document.interface.d.ts → api-document.interface.d.ts} +3 -3
- package/types/schema/data-type/complex-type.interface.d.ts +1 -1
- package/types/schema/data-type/enum-type.interface.d.ts +1 -1
- package/types/schema/data-type/mapped-type.interface.d.ts +1 -1
- package/types/schema/data-type/mixin-type.interface.d.ts +1 -1
- package/types/schema/http/http-parameter.interface.d.ts +1 -1
- package/types/schema/index.d.ts +2 -62
- package/types/schema/opra-schema.d.ts +21 -0
- package/types/schema/type-guards.d.ts +1 -1
- /package/cjs/schema/{document.interface.js → api-document.interface.js} +0 -0
- /package/esm/schema/{document.interface.js → api-document.interface.js} +0 -0
|
@@ -171,7 +171,7 @@ class ComplexTypeBaseClass extends data_type_js_1.DataType {
|
|
|
171
171
|
const fn = this._generateFieldCodec(codec, field, {
|
|
172
172
|
...context,
|
|
173
173
|
partial: context.partial === 'deep' ? context.partial : undefined,
|
|
174
|
-
projection,
|
|
174
|
+
projection: typeof projection === 'object' ? projection[fieldName]?.projection || '*' : projection,
|
|
175
175
|
currentPath: currentPath + (currentPath ? '.' : '') + fieldName,
|
|
176
176
|
});
|
|
177
177
|
schema[fieldName] = context.partial || !field.required ? valgen_1.vg.optional(fn) : valgen_1.vg.required(fn);
|
|
@@ -65,7 +65,7 @@ const decodeFilter = (dataType, rules) => (0, valgen_1.validator)('decodeFilter'
|
|
|
65
65
|
return filter;
|
|
66
66
|
}
|
|
67
67
|
catch (e) {
|
|
68
|
-
context.fail(_this, `Not a valid filter expression. ${e.message}`, input
|
|
68
|
+
context.fail(_this, `Not a valid filter expression. ${e.message}`, input);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FilterRules = void 0;
|
|
4
4
|
const index_js_1 = require("../exception/index.js");
|
|
5
|
-
const index_js_2 = require("../
|
|
6
|
-
const index_js_3 = require("../
|
|
7
|
-
const index_js_4 = require("
|
|
5
|
+
const index_js_2 = require("../helpers/index.js");
|
|
6
|
+
const index_js_3 = require("../i18n/index.js");
|
|
7
|
+
const index_js_4 = require("./ast/index.js");
|
|
8
|
+
const parse_js_1 = require("./parse.js");
|
|
8
9
|
class FilterRules {
|
|
9
10
|
constructor(rules, options) {
|
|
10
|
-
this._rules = new
|
|
11
|
+
this._rules = new index_js_2.ResponsiveMap();
|
|
11
12
|
Object.defineProperty(this, '_rules', {
|
|
12
|
-
value: new
|
|
13
|
+
value: new index_js_2.ResponsiveMap(null, { caseSensitive: options?.caseSensitive }),
|
|
13
14
|
enumerable: false,
|
|
14
15
|
});
|
|
15
16
|
if (rules) {
|
|
@@ -22,7 +23,7 @@ class FilterRules {
|
|
|
22
23
|
const operators = typeof options?.operators === 'string'
|
|
23
24
|
? options.operators.split(/\s*[,| ]\s*/)
|
|
24
25
|
: options?.operators;
|
|
25
|
-
this._rules.set(fieldName, (0,
|
|
26
|
+
this._rules.set(fieldName, (0, index_js_2.omitUndefined)({
|
|
26
27
|
...options,
|
|
27
28
|
operators,
|
|
28
29
|
}));
|
|
@@ -30,10 +31,10 @@ class FilterRules {
|
|
|
30
31
|
normalizeFilter(filter, dataType) {
|
|
31
32
|
if (!filter)
|
|
32
33
|
return;
|
|
33
|
-
const ast = typeof filter === 'string' ?
|
|
34
|
-
if (ast instanceof
|
|
34
|
+
const ast = typeof filter === 'string' ? (0, parse_js_1.parse)(filter) : filter;
|
|
35
|
+
if (ast instanceof index_js_4.ComparisonExpression) {
|
|
35
36
|
this.normalizeFilter(ast.left, dataType);
|
|
36
|
-
if (!(ast.left instanceof
|
|
37
|
+
if (!(ast.left instanceof index_js_4.QualifiedIdentifier && ast.left.field)) {
|
|
37
38
|
throw new TypeError(`Invalid filter query. Left side should be a data field.`);
|
|
38
39
|
}
|
|
39
40
|
// Check if filtering accepted for given field
|
|
@@ -41,7 +42,7 @@ class FilterRules {
|
|
|
41
42
|
const rule = this._rules.get(ast.left.value);
|
|
42
43
|
if (!rule) {
|
|
43
44
|
throw new index_js_1.OpraException({
|
|
44
|
-
message: (0,
|
|
45
|
+
message: (0, index_js_3.translate)('error:UNACCEPTED_FILTER_FIELD', { field: ast.left.value }),
|
|
45
46
|
code: 'UNACCEPTED_FILTER_FIELD',
|
|
46
47
|
details: {
|
|
47
48
|
field: ast.left.value,
|
|
@@ -51,7 +52,7 @@ class FilterRules {
|
|
|
51
52
|
// Check if filtering endpoint accepted for given field
|
|
52
53
|
if (rule.operators && !rule.operators.includes(ast.op)) {
|
|
53
54
|
throw new index_js_1.OpraException({
|
|
54
|
-
message: (0,
|
|
55
|
+
message: (0, index_js_3.translate)('error:UNACCEPTED_FILTER_OPERATION', { field: ast.left.value }),
|
|
55
56
|
code: 'UNACCEPTED_FILTER_OPERATION',
|
|
56
57
|
details: {
|
|
57
58
|
field: ast.left.value,
|
|
@@ -62,23 +63,23 @@ class FilterRules {
|
|
|
62
63
|
this.normalizeFilter(ast.right, dataType);
|
|
63
64
|
return ast;
|
|
64
65
|
}
|
|
65
|
-
if (ast instanceof
|
|
66
|
+
if (ast instanceof index_js_4.LogicalExpression) {
|
|
66
67
|
ast.items.forEach(item => this.normalizeFilter(item, dataType));
|
|
67
68
|
return ast;
|
|
68
69
|
}
|
|
69
|
-
if (ast instanceof
|
|
70
|
+
if (ast instanceof index_js_4.ArithmeticExpression) {
|
|
70
71
|
ast.items.forEach(item => this.normalizeFilter(item.expression, dataType));
|
|
71
72
|
return ast;
|
|
72
73
|
}
|
|
73
|
-
if (ast instanceof
|
|
74
|
+
if (ast instanceof index_js_4.ArrayExpression) {
|
|
74
75
|
ast.items.forEach(item => this.normalizeFilter(item, dataType));
|
|
75
76
|
return ast;
|
|
76
77
|
}
|
|
77
|
-
if (ast instanceof
|
|
78
|
+
if (ast instanceof index_js_4.ParenthesizedExpression) {
|
|
78
79
|
this.normalizeFilter(ast.expression, dataType);
|
|
79
80
|
return ast;
|
|
80
81
|
}
|
|
81
|
-
if (ast instanceof
|
|
82
|
+
if (ast instanceof index_js_4.QualifiedIdentifier && dataType) {
|
|
82
83
|
ast.value = dataType.normalizeFieldPath(ast.value);
|
|
83
84
|
ast.field = dataType.getField(ast.value);
|
|
84
85
|
ast.dataType = ast.field.type;
|
package/cjs/helpers/index.js
CHANGED
|
@@ -8,4 +8,5 @@ tslib_1.__exportStar(require("./mixin-utils.js"), exports);
|
|
|
8
8
|
tslib_1.__exportStar(require("./object-utils.js"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./parse-fields-projection.js"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./responsive-map.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./safe-json-stringify.js"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./type-guards.js"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.safeJsonStringify = safeJsonStringify;
|
|
4
|
+
function safeJsonStringify(value, replacer, space) {
|
|
5
|
+
const seen = new WeakSet();
|
|
6
|
+
return JSON.stringify(value, (k, v) => {
|
|
7
|
+
if (v !== null && typeof v === 'object') {
|
|
8
|
+
if (seen.has(v))
|
|
9
|
+
return;
|
|
10
|
+
seen.add(v);
|
|
11
|
+
}
|
|
12
|
+
if (replacer)
|
|
13
|
+
return replacer(k, v);
|
|
14
|
+
return v;
|
|
15
|
+
}, space);
|
|
16
|
+
}
|
package/cjs/schema/index.js
CHANGED
|
@@ -2,30 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OpraSchema = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const enumType_ = tslib_1.__importStar(require("./data-type/enum-type.interface.js"));
|
|
8
|
-
const mappedType_ = tslib_1.__importStar(require("./data-type/mapped-type.interface.js"));
|
|
9
|
-
const mixinType_ = tslib_1.__importStar(require("./data-type/mixin-type.interface.js"));
|
|
10
|
-
const simpleType_ = tslib_1.__importStar(require("./data-type/simple-type.interface.js"));
|
|
11
|
-
const controller_ = tslib_1.__importStar(require("./http/http-controller.interface.js"));
|
|
12
|
-
const operation_ = tslib_1.__importStar(require("./http/http-operation.interface.js"));
|
|
13
|
-
const typeGuards_ = tslib_1.__importStar(require("./type-guards.js"));
|
|
14
|
-
var OpraSchema;
|
|
15
|
-
(function (OpraSchema) {
|
|
16
|
-
OpraSchema.SpecVersion = constants_.SpecVersion;
|
|
17
|
-
OpraSchema.ComplexType = complexType_.ComplexType;
|
|
18
|
-
OpraSchema.EnumType = enumType_.EnumType;
|
|
19
|
-
OpraSchema.MappedType = mappedType_.MappedType;
|
|
20
|
-
OpraSchema.MixinType = mixinType_.MixinType;
|
|
21
|
-
OpraSchema.SimpleType = simpleType_.SimpleType;
|
|
22
|
-
OpraSchema.HttpController = controller_.HttpController;
|
|
23
|
-
OpraSchema.HttpOperation = operation_.HttpOperation;
|
|
24
|
-
OpraSchema.isComplexType = typeGuards_.isComplexType;
|
|
25
|
-
OpraSchema.isDataType = typeGuards_.isDataType;
|
|
26
|
-
OpraSchema.isSimpleType = typeGuards_.isSimpleType;
|
|
27
|
-
OpraSchema.isMixinType = typeGuards_.isMixinType;
|
|
28
|
-
OpraSchema.isMappedType = typeGuards_.isMappedType;
|
|
29
|
-
OpraSchema.isEnumType = typeGuards_.isEnumType;
|
|
30
|
-
OpraSchema.isHttpController = typeGuards_.isHttpController;
|
|
31
|
-
})(OpraSchema || (exports.OpraSchema = OpraSchema = {}));
|
|
5
|
+
const OpraSchema = tslib_1.__importStar(require("./opra-schema.js"));
|
|
6
|
+
exports.OpraSchema = OpraSchema;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./api-document.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./data-type/complex-type.interface.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./data-type/data-type.interface.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./data-type/enum-type.interface.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./data-type/field.interface.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./data-type/mapped-type.interface.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./data-type/mixin-type.interface.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./data-type/simple-type.interface.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./data-type-container.interface.js"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./http/http-controller.interface.js"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./http/http-media-type.interface.js"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./http/http-multipart-field.interface.js"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./http/http-operation.interface.js"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./http/http-operation-response.interface.js"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./http/http-parameter.interface.js"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./http/http-request-body.interface.js"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./http/http-status-range.interface.js"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./type-guards.js"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./types.js"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./value.interface.js"), exports);
|
|
@@ -168,7 +168,7 @@ class ComplexTypeBaseClass extends DataType {
|
|
|
168
168
|
const fn = this._generateFieldCodec(codec, field, {
|
|
169
169
|
...context,
|
|
170
170
|
partial: context.partial === 'deep' ? context.partial : undefined,
|
|
171
|
-
projection,
|
|
171
|
+
projection: typeof projection === 'object' ? projection[fieldName]?.projection || '*' : projection,
|
|
172
172
|
currentPath: currentPath + (currentPath ? '.' : '') + fieldName,
|
|
173
173
|
});
|
|
174
174
|
schema[fieldName] = context.partial || !field.required ? vg.optional(fn) : vg.required(fn);
|
|
@@ -62,7 +62,7 @@ const decodeFilter = (dataType, rules) => validator('decodeFilter', (input, cont
|
|
|
62
62
|
return filter;
|
|
63
63
|
}
|
|
64
64
|
catch (e) {
|
|
65
|
-
context.fail(_this, `Not a valid filter expression. ${e.message}`, input
|
|
65
|
+
context.fail(_this, `Not a valid filter expression. ${e.message}`, input);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { OpraException } from '../exception/index.js';
|
|
2
|
-
import { OpraFilter } from '../filter/index.js';
|
|
3
2
|
import { omitUndefined, ResponsiveMap } from '../helpers/index.js';
|
|
4
3
|
import { translate } from '../i18n/index.js';
|
|
4
|
+
import { ArithmeticExpression, ArrayExpression, ComparisonExpression, LogicalExpression, ParenthesizedExpression, QualifiedIdentifier, } from './ast/index.js';
|
|
5
|
+
import { parse } from './parse.js';
|
|
5
6
|
export class FilterRules {
|
|
6
7
|
constructor(rules, options) {
|
|
7
8
|
this._rules = new ResponsiveMap();
|
|
@@ -27,10 +28,10 @@ export class FilterRules {
|
|
|
27
28
|
normalizeFilter(filter, dataType) {
|
|
28
29
|
if (!filter)
|
|
29
30
|
return;
|
|
30
|
-
const ast = typeof filter === 'string' ?
|
|
31
|
-
if (ast instanceof
|
|
31
|
+
const ast = typeof filter === 'string' ? parse(filter) : filter;
|
|
32
|
+
if (ast instanceof ComparisonExpression) {
|
|
32
33
|
this.normalizeFilter(ast.left, dataType);
|
|
33
|
-
if (!(ast.left instanceof
|
|
34
|
+
if (!(ast.left instanceof QualifiedIdentifier && ast.left.field)) {
|
|
34
35
|
throw new TypeError(`Invalid filter query. Left side should be a data field.`);
|
|
35
36
|
}
|
|
36
37
|
// Check if filtering accepted for given field
|
|
@@ -59,23 +60,23 @@ export class FilterRules {
|
|
|
59
60
|
this.normalizeFilter(ast.right, dataType);
|
|
60
61
|
return ast;
|
|
61
62
|
}
|
|
62
|
-
if (ast instanceof
|
|
63
|
+
if (ast instanceof LogicalExpression) {
|
|
63
64
|
ast.items.forEach(item => this.normalizeFilter(item, dataType));
|
|
64
65
|
return ast;
|
|
65
66
|
}
|
|
66
|
-
if (ast instanceof
|
|
67
|
+
if (ast instanceof ArithmeticExpression) {
|
|
67
68
|
ast.items.forEach(item => this.normalizeFilter(item.expression, dataType));
|
|
68
69
|
return ast;
|
|
69
70
|
}
|
|
70
|
-
if (ast instanceof
|
|
71
|
+
if (ast instanceof ArrayExpression) {
|
|
71
72
|
ast.items.forEach(item => this.normalizeFilter(item, dataType));
|
|
72
73
|
return ast;
|
|
73
74
|
}
|
|
74
|
-
if (ast instanceof
|
|
75
|
+
if (ast instanceof ParenthesizedExpression) {
|
|
75
76
|
this.normalizeFilter(ast.expression, dataType);
|
|
76
77
|
return ast;
|
|
77
78
|
}
|
|
78
|
-
if (ast instanceof
|
|
79
|
+
if (ast instanceof QualifiedIdentifier && dataType) {
|
|
79
80
|
ast.value = dataType.normalizeFieldPath(ast.value);
|
|
80
81
|
ast.field = dataType.getField(ast.value);
|
|
81
82
|
ast.dataType = ast.field.type;
|
package/esm/helpers/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function safeJsonStringify(value, replacer, space) {
|
|
2
|
+
const seen = new WeakSet();
|
|
3
|
+
return JSON.stringify(value, (k, v) => {
|
|
4
|
+
if (v !== null && typeof v === 'object') {
|
|
5
|
+
if (seen.has(v))
|
|
6
|
+
return;
|
|
7
|
+
seen.add(v);
|
|
8
|
+
}
|
|
9
|
+
if (replacer)
|
|
10
|
+
return replacer(k, v);
|
|
11
|
+
return v;
|
|
12
|
+
}, space);
|
|
13
|
+
}
|
package/esm/schema/index.js
CHANGED
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
|
|
3
|
-
import * as enumType_ from './data-type/enum-type.interface.js';
|
|
4
|
-
import * as mappedType_ from './data-type/mapped-type.interface.js';
|
|
5
|
-
import * as mixinType_ from './data-type/mixin-type.interface.js';
|
|
6
|
-
import * as simpleType_ from './data-type/simple-type.interface.js';
|
|
7
|
-
import * as controller_ from './http/http-controller.interface.js';
|
|
8
|
-
import * as operation_ from './http/http-operation.interface.js';
|
|
9
|
-
import * as typeGuards_ from './type-guards.js';
|
|
10
|
-
export var OpraSchema;
|
|
11
|
-
(function (OpraSchema) {
|
|
12
|
-
OpraSchema.SpecVersion = constants_.SpecVersion;
|
|
13
|
-
OpraSchema.ComplexType = complexType_.ComplexType;
|
|
14
|
-
OpraSchema.EnumType = enumType_.EnumType;
|
|
15
|
-
OpraSchema.MappedType = mappedType_.MappedType;
|
|
16
|
-
OpraSchema.MixinType = mixinType_.MixinType;
|
|
17
|
-
OpraSchema.SimpleType = simpleType_.SimpleType;
|
|
18
|
-
OpraSchema.HttpController = controller_.HttpController;
|
|
19
|
-
OpraSchema.HttpOperation = operation_.HttpOperation;
|
|
20
|
-
OpraSchema.isComplexType = typeGuards_.isComplexType;
|
|
21
|
-
OpraSchema.isDataType = typeGuards_.isDataType;
|
|
22
|
-
OpraSchema.isSimpleType = typeGuards_.isSimpleType;
|
|
23
|
-
OpraSchema.isMixinType = typeGuards_.isMixinType;
|
|
24
|
-
OpraSchema.isMappedType = typeGuards_.isMappedType;
|
|
25
|
-
OpraSchema.isEnumType = typeGuards_.isEnumType;
|
|
26
|
-
OpraSchema.isHttpController = typeGuards_.isHttpController;
|
|
27
|
-
})(OpraSchema || (OpraSchema = {}));
|
|
1
|
+
import * as OpraSchema from './opra-schema.js';
|
|
2
|
+
export { OpraSchema };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from './api-document.interface';
|
|
2
|
+
export * from './constants.js';
|
|
3
|
+
export * from './data-type/complex-type.interface.js';
|
|
4
|
+
export * from './data-type/data-type.interface.js';
|
|
5
|
+
export * from './data-type/enum-type.interface.js';
|
|
6
|
+
export * from './data-type/field.interface.js';
|
|
7
|
+
export * from './data-type/mapped-type.interface.js';
|
|
8
|
+
export * from './data-type/mixin-type.interface.js';
|
|
9
|
+
export * from './data-type/simple-type.interface.js';
|
|
10
|
+
export * from './data-type-container.interface.js';
|
|
11
|
+
export * from './http/http-controller.interface.js';
|
|
12
|
+
export * from './http/http-media-type.interface.js';
|
|
13
|
+
export * from './http/http-multipart-field.interface.js';
|
|
14
|
+
export * from './http/http-operation.interface.js';
|
|
15
|
+
export * from './http/http-operation-response.interface.js';
|
|
16
|
+
export * from './http/http-parameter.interface.js';
|
|
17
|
+
export * from './http/http-request-body.interface.js';
|
|
18
|
+
export * from './http/http-status-range.interface.js';
|
|
19
|
+
export * from './type-guards.js';
|
|
20
|
+
export * from './types.js';
|
|
21
|
+
export * from './value.interface.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.39",
|
|
4
4
|
"description": "Opra common package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"putil-varhelpers": "^1.6.5",
|
|
19
19
|
"reflect-metadata": "^0.2.2",
|
|
20
20
|
"super-fast-md5": "^1.0.3",
|
|
21
|
-
"tslib": "^2.
|
|
21
|
+
"tslib": "^2.7.0",
|
|
22
22
|
"uid": "^2.0.1",
|
|
23
23
|
"valgen": "^5.9.0"
|
|
24
24
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Combine, StrictOmit, TypeThunkAsync } from 'ts-gems';
|
|
1
|
+
import type { Combine, StrictOmit, TypeThunkAsync } from 'ts-gems';
|
|
2
2
|
import type { OpraSchema } from '../../schema/index.js';
|
|
3
3
|
import { DataType } from '../data-type/data-type.js';
|
|
4
4
|
import type { EnumType } from '../data-type/enum-type.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Combine, TypeThunkAsync } from 'ts-gems';
|
|
1
|
+
import type { Combine, TypeThunkAsync } from 'ts-gems';
|
|
2
2
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
3
|
import { DocumentElement } from '../common/document-element.js';
|
|
4
4
|
import { ApiFieldDecorator } from '../decorators/api-field-decorator.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StrictOmit, Type } from 'ts-gems';
|
|
2
|
-
import { IsObject, Validator } from 'valgen';
|
|
1
|
+
import { type StrictOmit, type Type } from 'ts-gems';
|
|
2
|
+
import { type IsObject, type Validator } from 'valgen';
|
|
3
3
|
import { FieldsProjection, ResponsiveMap } from '../../helpers/index.js';
|
|
4
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
5
|
import type { DocumentElement } from '../common/document-element.js';
|
|
@@ -7,7 +7,6 @@ import { DocumentInitContext } from '../common/document-init-context.js';
|
|
|
7
7
|
import type { ApiField } from './api-field.js';
|
|
8
8
|
import type { ComplexType } from './complex-type.js';
|
|
9
9
|
import { DataType } from './data-type.js';
|
|
10
|
-
import Field = OpraSchema.Field;
|
|
11
10
|
export declare const FIELD_PATH_PATTERN: RegExp;
|
|
12
11
|
/**
|
|
13
12
|
* Type definition of class constructor for ComplexTypeBase
|
|
@@ -43,7 +42,7 @@ declare abstract class ComplexTypeBaseClass extends DataType {
|
|
|
43
42
|
readonly ctor?: Type;
|
|
44
43
|
readonly fields: ResponsiveMap<ApiField>;
|
|
45
44
|
readonly additionalFields?: boolean | DataType | ['error'] | ['error', string];
|
|
46
|
-
readonly keyField?: Field.Name;
|
|
45
|
+
readonly keyField?: OpraSchema.Field.Name;
|
|
47
46
|
/**
|
|
48
47
|
*
|
|
49
48
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { Combine, Type, TypeThunkAsync } from 'ts-gems';
|
|
2
|
+
import type { Combine, Type, TypeThunkAsync } from 'ts-gems';
|
|
3
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
4
|
import type { DocumentElement } from '../common/document-element.js';
|
|
5
5
|
import { DocumentInitContext } from '../common/document-init-context.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StrictOmit, Type } from 'ts-gems';
|
|
2
|
-
import { ValidationOptions, Validator } from 'valgen';
|
|
1
|
+
import { type StrictOmit, type Type } from 'ts-gems';
|
|
2
|
+
import type { ValidationOptions, Validator } from 'valgen';
|
|
3
3
|
import { FieldsProjection } from '../../helpers/index.js';
|
|
4
4
|
import type { DataTypeBase } from '../../schema/data-type/data-type.interface.js';
|
|
5
5
|
import { OpraSchema } from '../../schema/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { Combine, Type } from 'ts-gems';
|
|
3
|
-
import { Validator } from 'valgen';
|
|
2
|
+
import { type Combine, type Type } from 'ts-gems';
|
|
3
|
+
import { type Validator } from 'valgen';
|
|
4
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
5
|
import type { DocumentElement } from '../common/document-element.js';
|
|
6
6
|
import { DataType } from './data-type.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Type } from 'ts-gems';
|
|
2
|
-
import { Validator } from 'valgen';
|
|
1
|
+
import type { Type } from 'ts-gems';
|
|
2
|
+
import { type Validator } from 'valgen';
|
|
3
3
|
import { DocumentElement } from '../../common/document-element.js';
|
|
4
4
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
5
5
|
export declare class FieldPathType {
|
|
@@ -9,7 +9,7 @@ export declare class FieldPathType {
|
|
|
9
9
|
[DECODER](properties: Partial<this>, element: DocumentElement): Validator;
|
|
10
10
|
[ENCODER](properties: Partial<this>, element: DocumentElement): Validator;
|
|
11
11
|
toJSON(properties: Partial<FieldPathType>, element: DocumentElement): {
|
|
12
|
-
dataType: string | import("../../../schema/
|
|
12
|
+
dataType: string | import("../../../schema/opra-schema.js").ComplexType;
|
|
13
13
|
allowSigns: "first" | "each" | undefined;
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Type } from 'ts-gems';
|
|
2
|
-
import { Validator } from 'valgen';
|
|
1
|
+
import type { Type } from 'ts-gems';
|
|
2
|
+
import { type Validator } from 'valgen';
|
|
3
3
|
import { FilterRules } from '../../../filter/filter-rules.js';
|
|
4
4
|
import type { DocumentElement } from '../../common/document-element.js';
|
|
5
5
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
@@ -10,7 +10,7 @@ export declare class FilterType {
|
|
|
10
10
|
protected [DECODER](properties: Partial<this>, element: DocumentElement): Validator;
|
|
11
11
|
protected [ENCODER](): Validator;
|
|
12
12
|
toJSON(properties: Partial<FilterType>, element: DocumentElement): {
|
|
13
|
-
dataType: string | import("../../../schema/
|
|
13
|
+
dataType: string | import("../../../schema/opra-schema.js").ComplexType;
|
|
14
14
|
rules: Record<string, FilterRules.Rule> | undefined;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DeepPartial, Type } from 'ts-gems';
|
|
2
|
-
import { ErrorIssue } from '../../../exception/index.js';
|
|
1
|
+
import type { DeepPartial, Type } from 'ts-gems';
|
|
2
|
+
import type { ErrorIssue } from '../../../exception/index.js';
|
|
3
3
|
export declare class OperationResult<TPayload = any> {
|
|
4
4
|
constructor(init?: DeepPartial<OperationResult>);
|
|
5
5
|
affected?: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { Combine, Type } from 'ts-gems';
|
|
2
|
+
import { type Combine, type Type } from 'ts-gems';
|
|
3
3
|
import type { Field } from '../../schema/data-type/field.interface.js';
|
|
4
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
5
|
import { DocumentElement } from '../common/document-element.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { Class, Combine, Type } from 'ts-gems';
|
|
2
|
+
import type { Class, Combine, Type } from 'ts-gems';
|
|
3
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
4
|
import type { DocumentElement } from '../common/document-element.js';
|
|
5
5
|
import type { ComplexType } from './complex-type.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Class, PartialSome, Type } from 'ts-gems';
|
|
1
|
+
import type { Class, PartialSome, Type } from 'ts-gems';
|
|
2
2
|
import type { DataType } from './data-type.js';
|
|
3
3
|
export declare function PartialType(baseType: string | Type, keys: string[], options?: DataType.Options): Type;
|
|
4
4
|
/**
|