@opra/common 1.0.0-alpha.3 → 1.0.0-alpha.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser.js +6035 -5791
- package/cjs/document/api-document.js +11 -0
- package/cjs/document/common/api-base.js +1 -1
- package/cjs/document/common/document-element.js +4 -1
- package/cjs/document/data-type/api-field.js +12 -6
- package/cjs/document/data-type/complex-type-base.js +10 -3
- package/cjs/document/data-type/complex-type.js +6 -2
- package/cjs/document/data-type/data-type.js +2 -1
- package/cjs/document/data-type/enum-type.js +5 -2
- package/cjs/document/data-type/extended-types/base64.type.js +4 -0
- package/cjs/document/data-type/extended-types/date-string.type.js +6 -2
- package/cjs/document/data-type/extended-types/date-time-string.type.js +6 -2
- package/cjs/document/data-type/extended-types/date-time.type.js +6 -2
- package/cjs/document/data-type/extended-types/date.type.js +6 -2
- package/cjs/document/data-type/extended-types/email.type.js +6 -2
- package/cjs/document/data-type/extended-types/field-path.type.js +5 -3
- package/cjs/document/data-type/extended-types/filter.type.js +19 -17
- package/cjs/document/data-type/extended-types/object-id.type.js +4 -0
- package/cjs/document/data-type/extended-types/time.type.js +6 -2
- package/cjs/document/data-type/extended-types/url.type.js +6 -2
- package/cjs/document/data-type/extended-types/uuid.type.js +4 -0
- package/cjs/document/data-type/mapped-type.js +12 -5
- package/cjs/document/data-type/mixin-type.js +5 -1
- package/cjs/document/data-type/omit-type.js +7 -2
- package/cjs/document/data-type/partial-type.js +7 -2
- package/cjs/document/data-type/pick-type.js +1 -2
- package/cjs/document/data-type/primitive-types/bigint.type.js +4 -0
- package/cjs/document/data-type/primitive-types/boolean.type.js +4 -0
- package/cjs/document/data-type/primitive-types/integer.type.js +4 -0
- package/cjs/document/data-type/primitive-types/null.type.js +4 -0
- package/cjs/document/data-type/primitive-types/number.type.js +4 -0
- package/cjs/document/data-type/primitive-types/object.type.js +0 -3
- package/cjs/document/data-type/primitive-types/string.type.js +4 -0
- package/cjs/document/data-type/required-type.js +1 -2
- package/cjs/document/data-type/simple-type.js +17 -16
- package/cjs/document/data-type/utils/create-mapped-class.js +3 -3
- package/cjs/document/data-type/utils/get-is-inherited-predicate-fn.js +1 -2
- package/cjs/document/decorators/api-field-decorator.js +4 -6
- package/cjs/document/decorators/complex-type.decorator.js +1 -2
- package/cjs/document/decorators/http-controller.decorator.js +26 -2
- package/cjs/document/decorators/http-operation-entity.decorator.js +123 -93
- package/cjs/document/decorators/http-operation.decorator.js +12 -6
- package/cjs/document/decorators/simple-type.decorator.js +2 -3
- package/cjs/document/factory/api-document.factory.js +14 -11
- package/cjs/document/factory/data-type.factory.js +97 -56
- package/cjs/document/factory/http-api.factory.js +3 -1
- package/cjs/document/http/http-api.js +2 -3
- package/cjs/document/http/http-controller.js +26 -14
- package/cjs/document/http/http-media-type.js +21 -4
- package/cjs/document/http/http-operation-response.js +2 -2
- package/cjs/document/http/http-operation.js +28 -4
- package/cjs/document/http/http-parameter.js +4 -0
- package/cjs/document/http/http-request-body.js +0 -1
- package/cjs/document/http/http-status-range.js +6 -4
- package/cjs/document/index.js +5 -5
- package/cjs/document/utils/parse-regexp.util.js +1 -2
- package/cjs/document/utils/string-compare.util.js +1 -2
- package/cjs/exception/index.js +5 -5
- package/cjs/exception/opra-exception.js +1 -0
- package/cjs/filter/antlr/OpraFilterParser.js +28 -82
- package/cjs/filter/ast/index.js +1 -1
- package/cjs/filter/build.js +22 -25
- package/cjs/filter/filter-rules.js +4 -2
- package/cjs/filter/opra-filter.ns.js +2 -2
- package/cjs/filter/parse.js +2 -5
- package/cjs/filter/utils.js +2 -3
- package/cjs/helpers/function-utils.js +1 -2
- package/cjs/helpers/get-stack-filename.js +2 -3
- package/cjs/helpers/mixin-utils.js +4 -4
- package/cjs/helpers/monkey-patches.js +4 -2
- package/cjs/helpers/object-utils.js +5 -6
- package/cjs/helpers/parse-fields-projection.js +4 -6
- package/cjs/helpers/responsive-map.js +5 -4
- package/cjs/helpers/type-guards.js +10 -11
- package/cjs/i18n/i18n.js +4 -3
- package/cjs/i18n/index.js +1 -1
- package/cjs/i18n/string-utils.js +2 -3
- package/cjs/i18n/translate.js +1 -2
- package/cjs/index.js +1 -1
- package/cjs/schema/type-guards.js +7 -8
- package/esm/document/api-document.js +11 -0
- package/esm/document/common/api-base.js +1 -1
- package/esm/document/common/document-element.js +4 -1
- package/esm/document/data-type/api-field.js +12 -6
- package/esm/document/data-type/complex-type-base.js +10 -3
- package/esm/document/data-type/complex-type.js +6 -2
- package/esm/document/data-type/data-type.js +2 -1
- package/esm/document/data-type/enum-type.js +5 -2
- package/esm/document/data-type/extended-types/base64.type.js +4 -0
- package/esm/document/data-type/extended-types/date-string.type.js +6 -2
- package/esm/document/data-type/extended-types/date-time-string.type.js +6 -2
- package/esm/document/data-type/extended-types/date-time.type.js +6 -2
- package/esm/document/data-type/extended-types/date.type.js +6 -2
- package/esm/document/data-type/extended-types/email.type.js +6 -2
- package/esm/document/data-type/extended-types/field-path.type.js +5 -3
- package/esm/document/data-type/extended-types/filter.type.js +19 -17
- package/esm/document/data-type/extended-types/object-id.type.js +4 -0
- package/esm/document/data-type/extended-types/time.type.js +6 -2
- package/esm/document/data-type/extended-types/url.type.js +6 -2
- package/esm/document/data-type/extended-types/uuid.type.js +4 -0
- package/esm/document/data-type/mapped-type.js +12 -5
- package/esm/document/data-type/mixin-type.js +5 -1
- package/esm/document/data-type/omit-type.js +6 -0
- package/esm/document/data-type/partial-type.js +6 -0
- package/esm/document/data-type/primitive-types/bigint.type.js +4 -0
- package/esm/document/data-type/primitive-types/boolean.type.js +4 -0
- package/esm/document/data-type/primitive-types/integer.type.js +4 -0
- package/esm/document/data-type/primitive-types/null.type.js +4 -0
- package/esm/document/data-type/primitive-types/number.type.js +4 -0
- package/esm/document/data-type/primitive-types/object.type.js +0 -3
- package/esm/document/data-type/primitive-types/string.type.js +4 -0
- package/esm/document/data-type/simple-type.js +17 -16
- package/esm/document/data-type/utils/create-mapped-class.js +2 -1
- package/esm/document/decorators/api-field-decorator.js +1 -2
- package/esm/document/decorators/http-controller.decorator.js +25 -0
- package/esm/document/decorators/http-operation-entity.decorator.js +80 -50
- package/esm/document/decorators/http-operation.decorator.js +11 -4
- package/esm/document/factory/api-document.factory.js +14 -10
- package/esm/document/factory/data-type.factory.js +97 -56
- package/esm/document/factory/http-api.factory.js +3 -1
- package/esm/document/http/http-api.js +2 -3
- package/esm/document/http/http-controller.js +25 -14
- package/esm/document/http/http-media-type.js +20 -4
- package/esm/document/http/http-operation-response.js +2 -2
- package/esm/document/http/http-operation.js +27 -4
- package/esm/document/http/http-parameter.js +4 -0
- package/esm/document/http/http-request-body.js +0 -1
- package/esm/document/http/http-status-range.js +6 -4
- package/esm/document/index.js +5 -5
- package/esm/exception/index.js +5 -5
- package/esm/exception/opra-exception.js +1 -0
- package/esm/filter/antlr/OpraFilterParser.js +28 -82
- package/esm/filter/ast/index.js +1 -1
- package/esm/filter/build.js +1 -3
- package/esm/filter/filter-rules.js +4 -2
- package/esm/filter/opra-filter.ns.js +2 -2
- package/esm/filter/parse.js +1 -3
- package/esm/helpers/mixin-utils.js +2 -1
- package/esm/helpers/monkey-patches.js +4 -2
- package/esm/helpers/object-utils.js +2 -2
- package/esm/helpers/parse-fields-projection.js +1 -3
- package/esm/helpers/responsive-map.js +5 -4
- package/esm/i18n/i18n.js +4 -3
- package/esm/i18n/index.js +1 -1
- package/esm/index.js +1 -1
- package/package.json +12 -8
- package/types/document/api-document.d.ts +1 -0
- package/types/document/common/api-base.d.ts +1 -1
- package/types/document/common/document-element.d.ts +1 -0
- package/types/document/data-type/api-field.d.ts +12 -0
- package/types/document/data-type/complex-type-base.d.ts +1 -1
- package/types/document/data-type/complex-type.d.ts +1 -1
- package/types/document/data-type/data-type.d.ts +5 -2
- package/types/document/data-type/enum-type.d.ts +2 -2
- package/types/document/data-type/mapped-type.d.ts +3 -3
- package/types/document/data-type/mixin-type.d.ts +2 -2
- package/types/document/data-type/omit-type.d.ts +0 -6
- package/types/document/data-type/partial-type.d.ts +0 -6
- package/types/document/data-type/pick-type.d.ts +2 -2
- package/types/document/data-type/required-type.d.ts +7 -7
- package/types/document/data-type/simple-type.d.ts +4 -2
- package/types/document/decorators/http-controller.decorator.d.ts +1 -0
- package/types/document/decorators/http-operation-entity.decorator.d.ts +1 -0
- package/types/document/factory/data-type.factory.d.ts +5 -0
- package/types/document/http/http-api.d.ts +1 -1
- package/types/document/http/http-controller.d.ts +1 -0
- package/types/document/http/http-media-type.d.ts +2 -1
- package/types/document/http/http-operation.d.ts +5 -3
- package/types/document/http/http-parameter.d.ts +3 -2
- package/types/document/http/http-status-range.d.ts +2 -1
- package/types/document/index.d.ts +5 -5
- package/types/exception/index.d.ts +5 -5
- package/types/filter/ast/index.d.ts +1 -1
- package/types/filter/opra-filter.ns.d.ts +2 -2
- package/types/helpers/type-guards.d.ts +0 -2
- package/types/i18n/i18n.d.ts +21 -19
- package/types/index.d.ts +1 -1
- package/types/schema/data-type/data-type.interface.d.ts +1 -1
- package/types/schema/data-type/mapped-type.interface.d.ts +2 -2
- package/types/schema/data-type/simple-type.interface.d.ts +4 -0
- package/types/schema/data-type-container.interface.d.ts +1 -1
- package/types/schema/document.interface.d.ts +1 -1
- package/types/schema/http/http-controller.interface.d.ts +2 -2
- package/types/schema/http/http-media-type.interface.d.ts +1 -1
- package/types/schema/http/http-operation-response.interface.d.ts +2 -2
- package/types/schema/http/http-operation.interface.d.ts +8 -4
- package/types/schema/http/http-parameter.interface.d.ts +5 -1
package/cjs/filter/build.js
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.$
|
|
3
|
+
exports.$or = $or;
|
|
4
|
+
exports.$and = $and;
|
|
5
|
+
exports.$date = $date;
|
|
6
|
+
exports.$time = $time;
|
|
7
|
+
exports.$number = $number;
|
|
8
|
+
exports.$array = $array;
|
|
9
|
+
exports.$field = $field;
|
|
10
|
+
exports.$eq = $eq;
|
|
11
|
+
exports.$ne = $ne;
|
|
12
|
+
exports.$gt = $gt;
|
|
13
|
+
exports.$gte = $gte;
|
|
14
|
+
exports.$lt = $lt;
|
|
15
|
+
exports.$lte = $lte;
|
|
16
|
+
exports.$in = $in;
|
|
17
|
+
exports.$notIn = $notIn;
|
|
18
|
+
exports.$like = $like;
|
|
19
|
+
exports.$notLike = $notLike;
|
|
20
|
+
exports.$ilike = $ilike;
|
|
21
|
+
exports.$notILike = $notILike;
|
|
22
|
+
exports.$paren = $paren;
|
|
23
|
+
exports.$arithmetic = $arithmetic;
|
|
4
24
|
const index_js_1 = require("./ast/index.js");
|
|
5
25
|
function $or(...items) {
|
|
6
26
|
return new index_js_1.LogicalExpression({ op: 'or', items });
|
|
7
27
|
}
|
|
8
|
-
exports.$or = $or;
|
|
9
28
|
function $and(...items) {
|
|
10
29
|
return new index_js_1.LogicalExpression({ op: 'and', items });
|
|
11
30
|
}
|
|
12
|
-
exports.$and = $and;
|
|
13
31
|
function $date(v) {
|
|
14
32
|
return new index_js_1.DateLiteral(v);
|
|
15
33
|
}
|
|
16
|
-
exports.$date = $date;
|
|
17
34
|
function $time(v) {
|
|
18
35
|
return new index_js_1.TimeLiteral(v);
|
|
19
36
|
}
|
|
20
|
-
exports.$time = $time;
|
|
21
37
|
function $number(v) {
|
|
22
38
|
return new index_js_1.NumberLiteral(v);
|
|
23
39
|
}
|
|
24
|
-
exports.$number = $number;
|
|
25
40
|
function $array(...items) {
|
|
26
41
|
return new index_js_1.ArrayExpression(items.map(wrapEntryValue));
|
|
27
42
|
}
|
|
28
|
-
exports.$array = $array;
|
|
29
43
|
function $field(v) {
|
|
30
44
|
return new index_js_1.QualifiedIdentifier(v);
|
|
31
45
|
}
|
|
32
|
-
exports.$field = $field;
|
|
33
46
|
function $eq(left, right) {
|
|
34
47
|
return comparisonExpression('=', left, right);
|
|
35
48
|
}
|
|
36
|
-
exports.$eq = $eq;
|
|
37
49
|
function $ne(left, right) {
|
|
38
50
|
return comparisonExpression('!=', left, right);
|
|
39
51
|
}
|
|
40
|
-
exports.$ne = $ne;
|
|
41
52
|
function $gt(left, right) {
|
|
42
53
|
return comparisonExpression('>', left, right);
|
|
43
54
|
}
|
|
44
|
-
exports.$gt = $gt;
|
|
45
55
|
function $gte(left, right) {
|
|
46
56
|
return comparisonExpression('>=', left, right);
|
|
47
57
|
}
|
|
48
|
-
exports.$gte = $gte;
|
|
49
58
|
function $lt(left, right) {
|
|
50
59
|
return comparisonExpression('<', left, right);
|
|
51
60
|
}
|
|
52
|
-
exports.$lt = $lt;
|
|
53
61
|
function $lte(left, right) {
|
|
54
62
|
return comparisonExpression('<=', left, right);
|
|
55
63
|
}
|
|
56
|
-
exports.$lte = $lte;
|
|
57
64
|
function $in(left, right) {
|
|
58
65
|
return comparisonExpression('in', left, right);
|
|
59
66
|
}
|
|
60
|
-
exports.$in = $in;
|
|
61
67
|
function $notIn(left, right) {
|
|
62
68
|
return comparisonExpression('!in', left, right);
|
|
63
69
|
}
|
|
64
|
-
exports.$notIn = $notIn;
|
|
65
70
|
function $like(left, right) {
|
|
66
71
|
return comparisonExpression('like', left, right);
|
|
67
72
|
}
|
|
68
|
-
exports.$like = $like;
|
|
69
73
|
function $notLike(left, right) {
|
|
70
74
|
return comparisonExpression('!like', left, right);
|
|
71
75
|
}
|
|
72
|
-
exports.$notLike = $notLike;
|
|
73
76
|
function $ilike(left, right) {
|
|
74
77
|
return comparisonExpression('ilike', left, right);
|
|
75
78
|
}
|
|
76
|
-
exports.$ilike = $ilike;
|
|
77
79
|
function $notILike(left, right) {
|
|
78
80
|
return comparisonExpression('!ilike', left, right);
|
|
79
81
|
}
|
|
80
|
-
exports.$notILike = $notILike;
|
|
81
82
|
function $paren(expression) {
|
|
82
83
|
return new index_js_1.ParenthesizedExpression(expression);
|
|
83
84
|
}
|
|
84
|
-
exports.$paren = $paren;
|
|
85
85
|
function $arithmetic(n) {
|
|
86
86
|
const exp = new index_js_1.ArithmeticExpression();
|
|
87
87
|
exp.add = (expression) => {
|
|
@@ -103,15 +103,12 @@ function $arithmetic(n) {
|
|
|
103
103
|
exp.append('+', wrapEntryValue(n));
|
|
104
104
|
return exp;
|
|
105
105
|
}
|
|
106
|
-
exports.$arithmetic = $arithmetic;
|
|
107
106
|
function comparisonExpression(op, left, right) {
|
|
108
107
|
const lex = wrapEntryValue(left);
|
|
109
108
|
const rex = wrapEntryValue(right);
|
|
110
109
|
return new index_js_1.ComparisonExpression({ op, left: lex, right: rex });
|
|
111
110
|
}
|
|
112
|
-
const wrapEntryValue = (v) =>
|
|
113
|
-
return Array.isArray(v) ? $array(...v.map(_wrapEntryValue)) : _wrapEntryValue(v);
|
|
114
|
-
};
|
|
111
|
+
const wrapEntryValue = (v) => Array.isArray(v) ? $array(...v.map(_wrapEntryValue)) : _wrapEntryValue(v);
|
|
115
112
|
const _wrapEntryValue = (v) => {
|
|
116
113
|
if (v instanceof index_js_1.Expression)
|
|
117
114
|
return v;
|
|
@@ -33,8 +33,9 @@ class FilterRules {
|
|
|
33
33
|
const ast = typeof filter === 'string' ? index_js_2.OpraFilter.parse(filter) : filter;
|
|
34
34
|
if (ast instanceof index_js_2.OpraFilter.ComparisonExpression) {
|
|
35
35
|
this.normalizeFilter(ast.left, dataType);
|
|
36
|
-
if (!(ast.left instanceof index_js_2.OpraFilter.QualifiedIdentifier && ast.left.field))
|
|
36
|
+
if (!(ast.left instanceof index_js_2.OpraFilter.QualifiedIdentifier && ast.left.field)) {
|
|
37
37
|
throw new TypeError(`Invalid filter query. Left side should be a data field.`);
|
|
38
|
+
}
|
|
38
39
|
// Check if filtering accepted for given field
|
|
39
40
|
// const findManyOp = this.getOperation('findMany');
|
|
40
41
|
const rule = this._rules.get(ast.left.value);
|
|
@@ -48,7 +49,7 @@ class FilterRules {
|
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
// Check if filtering endpoint accepted for given field
|
|
51
|
-
if (rule.operators && !rule.operators.includes(ast.op))
|
|
52
|
+
if (rule.operators && !rule.operators.includes(ast.op)) {
|
|
52
53
|
throw new index_js_1.OpraException({
|
|
53
54
|
message: (0, index_js_4.translate)('error:UNACCEPTED_FILTER_OPERATION', { field: ast.left.value }),
|
|
54
55
|
code: 'UNACCEPTED_FILTER_OPERATION',
|
|
@@ -57,6 +58,7 @@ class FilterRules {
|
|
|
57
58
|
operator: ast.op,
|
|
58
59
|
},
|
|
59
60
|
});
|
|
61
|
+
}
|
|
60
62
|
this.normalizeFilter(ast.right, dataType);
|
|
61
63
|
return ast;
|
|
62
64
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./ast/index.js"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./parse.js"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./build.js"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./opra-error-listener.js"), exports);
|
|
8
6
|
tslib_1.__exportStar(require("./filter-tree-visitor.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./opra-error-listener.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./parse.js"), exports);
|
package/cjs/filter/parse.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parse =
|
|
3
|
+
exports.parse = parse;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const antlr4_1 = require("@browsery/antlr4");
|
|
6
6
|
const OpraFilterLexer_js_1 = tslib_1.__importDefault(require("./antlr/OpraFilterLexer.js"));
|
|
@@ -25,9 +25,7 @@ function parse(text, visitor) {
|
|
|
25
25
|
const errMsgs = [];
|
|
26
26
|
for (const err of errors) {
|
|
27
27
|
errMsgs.push(err.message +
|
|
28
|
-
(text.includes('\n')
|
|
29
|
-
? ' at ' + 'line: ' + err.line + ' column: ' + err.column
|
|
30
|
-
: ' at ' + ' column: ' + err.column));
|
|
28
|
+
(text.includes('\n') ? ' at line: ' + err.line + ' column: ' + err.column : ' at column: ' + err.column));
|
|
31
29
|
}
|
|
32
30
|
const e = new errors_js_1.SyntaxError(errMsgs.join('\n'));
|
|
33
31
|
e.errors = errors;
|
|
@@ -36,4 +34,3 @@ function parse(text, visitor) {
|
|
|
36
34
|
visitor = visitor || new filter_tree_visitor_js_1.FilterTreeVisitor();
|
|
37
35
|
return visitor.visit(tree);
|
|
38
36
|
}
|
|
39
|
-
exports.parse = parse;
|
package/cjs/filter/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.quoteFilterString = quoteFilterString;
|
|
4
|
+
exports.unquoteFilterString = unquoteFilterString;
|
|
4
5
|
const quotesRegEx = /'/g;
|
|
5
6
|
const escapeRegEx = /(\\)/g;
|
|
6
7
|
const unescapeRegEx = /\\(.)/g;
|
|
@@ -13,7 +14,6 @@ function unescapeString(s) {
|
|
|
13
14
|
function quoteFilterString(s) {
|
|
14
15
|
return "'" + escapeString(s).replace(quotesRegEx, "\\'") + "'";
|
|
15
16
|
}
|
|
16
|
-
exports.quoteFilterString = quoteFilterString;
|
|
17
17
|
function unquoteFilterString(s) {
|
|
18
18
|
if (s && (s.startsWith("'") || s.startsWith('"')) && s.endsWith(s.charAt(0))) {
|
|
19
19
|
return unescapeString(s.substring(1, s.length - 1));
|
|
@@ -21,4 +21,3 @@ function unquoteFilterString(s) {
|
|
|
21
21
|
/* istanbul ignore next */
|
|
22
22
|
return s;
|
|
23
23
|
}
|
|
24
|
-
exports.unquoteFilterString = unquoteFilterString;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveThunk =
|
|
3
|
+
exports.resolveThunk = resolveThunk;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const putil_promisify_1 = tslib_1.__importDefault(require("putil-promisify"));
|
|
6
6
|
const type_guards_js_1 = require("./type-guards.js");
|
|
@@ -13,4 +13,3 @@ async function resolveThunk(thunk) {
|
|
|
13
13
|
}
|
|
14
14
|
return thunk;
|
|
15
15
|
}
|
|
16
|
-
exports.resolveThunk = resolveThunk;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getStackFileName = getStackFileName;
|
|
4
|
+
exports.getErrorStack = getErrorStack;
|
|
4
5
|
const PATH_PATTERN = /^(?:file:\/\/)?(.+)$/;
|
|
5
6
|
function getStackFileName(position = 1) {
|
|
6
7
|
if (position >= Error.stackTraceLimit) {
|
|
@@ -23,7 +24,6 @@ function getStackFileName(position = 1) {
|
|
|
23
24
|
}
|
|
24
25
|
return '';
|
|
25
26
|
}
|
|
26
|
-
exports.getStackFileName = getStackFileName;
|
|
27
27
|
function getErrorStack(position = 1) {
|
|
28
28
|
if (position >= Error.stackTraceLimit) {
|
|
29
29
|
throw new TypeError('getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `' +
|
|
@@ -45,4 +45,3 @@ function getErrorStack(position = 1) {
|
|
|
45
45
|
}
|
|
46
46
|
return '';
|
|
47
47
|
}
|
|
48
|
-
exports.getErrorStack = getErrorStack;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.mergePrototype = mergePrototype;
|
|
4
|
+
exports.inheritPropertyInitializers = inheritPropertyInitializers;
|
|
4
5
|
function mergePrototype(targetProto, baseProto, filter) {
|
|
5
6
|
for (const k of Object.getOwnPropertyNames(baseProto)) {
|
|
6
|
-
if (k === 'constructor' || k === '__proto__' || k === 'toJSON' || k === 'toString' || (filter && !filter(k)))
|
|
7
|
+
if (k === 'constructor' || k === '__proto__' || k === 'toJSON' || k === 'toString' || (filter && !filter(k))) {
|
|
7
8
|
continue;
|
|
9
|
+
}
|
|
8
10
|
Object.defineProperty(targetProto, k, Object.getOwnPropertyDescriptor(baseProto, k) || Object.create(null));
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
|
-
exports.mergePrototype = mergePrototype;
|
|
12
13
|
// noinspection JSUnusedLocalSymbols
|
|
13
14
|
function inheritPropertyInitializers(target, clazz,
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -27,4 +28,3 @@ isPropertyInherited = (key) => true) {
|
|
|
27
28
|
//
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
exports.inheritPropertyInitializers = inheritPropertyInitializers;
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
/** monkey patch (hijack)
|
|
3
3
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json
|
|
4
4
|
*/
|
|
5
|
-
if (!BigInt.prototype.toJSON)
|
|
5
|
+
if (!BigInt.prototype.toJSON) {
|
|
6
6
|
BigInt.prototype.toJSON = function () {
|
|
7
7
|
return this.toString();
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
}
|
|
10
|
+
if (!RegExp.prototype.toJSON) {
|
|
10
11
|
RegExp.prototype.toJSON = function () {
|
|
11
12
|
return this.toString();
|
|
12
13
|
};
|
|
14
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.cloneObject = cloneObject;
|
|
4
|
+
exports.omitUndefined = omitUndefined;
|
|
5
|
+
exports.omitNullish = omitNullish;
|
|
4
6
|
const tslib_1 = require("tslib");
|
|
5
7
|
const putil_isplainobject_1 = tslib_1.__importDefault(require("putil-isplainobject"));
|
|
6
8
|
const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
|
|
@@ -8,14 +10,13 @@ const constants_js_1 = require("../document/constants.js");
|
|
|
8
10
|
function cloneObject(obj, jsonOnly) {
|
|
9
11
|
return (0, putil_merge_1.default)({}, obj, {
|
|
10
12
|
deep: v => (0, putil_isplainobject_1.default)(v) && !v[constants_js_1.DATATYPE_METADATA],
|
|
13
|
+
descriptor: true,
|
|
11
14
|
filter: (source, key) => {
|
|
12
15
|
const v = source[key];
|
|
13
|
-
return (
|
|
14
|
-
(typeof v !== 'function' && (typeof v !== 'object' || (0, putil_isplainobject_1.default)(v) || Array.isArray(v))));
|
|
16
|
+
return !jsonOnly || (typeof v !== 'function' && (typeof v !== 'object' || (0, putil_isplainobject_1.default)(v) || Array.isArray(v)));
|
|
15
17
|
},
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
|
-
exports.cloneObject = cloneObject;
|
|
19
20
|
function omitUndefined(obj, recursive) {
|
|
20
21
|
if (!(obj && typeof obj === 'object'))
|
|
21
22
|
return obj;
|
|
@@ -27,7 +28,6 @@ function omitUndefined(obj, recursive) {
|
|
|
27
28
|
}
|
|
28
29
|
return obj;
|
|
29
30
|
}
|
|
30
|
-
exports.omitUndefined = omitUndefined;
|
|
31
31
|
function omitNullish(obj, recursive) {
|
|
32
32
|
if (!(obj && typeof obj === 'object'))
|
|
33
33
|
return obj;
|
|
@@ -39,4 +39,3 @@ function omitNullish(obj, recursive) {
|
|
|
39
39
|
}
|
|
40
40
|
return obj;
|
|
41
41
|
}
|
|
42
|
-
exports.omitNullish = omitNullish;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FieldsProjection = void 0;
|
|
4
|
+
exports.parseFieldsProjection = parseFieldsProjection;
|
|
5
|
+
exports.parse = parse;
|
|
4
6
|
const fast_tokenizer_1 = require("fast-tokenizer");
|
|
5
7
|
const FIELD_PATTERN = /^([+-])?([a-z_$]\w*)$/i;
|
|
6
8
|
const NO_DOT_BRACKET_PATTERN = /[^.]\(/g;
|
|
@@ -24,12 +26,9 @@ function parseFieldsProjection(projection, keepCase) {
|
|
|
24
26
|
}
|
|
25
27
|
return out;
|
|
26
28
|
}
|
|
27
|
-
exports.parseFieldsProjection = parseFieldsProjection;
|
|
28
29
|
function parse(input, target) {
|
|
29
30
|
/** Add dot before brackets which is required to split fields */
|
|
30
|
-
input = input.replace(NO_DOT_BRACKET_PATTERN, s =>
|
|
31
|
-
return s.charAt(0) + '.' + s.substring(1);
|
|
32
|
-
});
|
|
31
|
+
input = input.replace(NO_DOT_BRACKET_PATTERN, s => s.charAt(0) + '.' + s.substring(1));
|
|
33
32
|
const fields = (0, fast_tokenizer_1.splitString)(input, {
|
|
34
33
|
delimiters: '.',
|
|
35
34
|
brackets: true,
|
|
@@ -64,4 +63,3 @@ function parse(input, target) {
|
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
|
-
exports.parse = parse;
|
|
@@ -41,13 +41,14 @@ class ResponsiveMap {
|
|
|
41
41
|
},
|
|
42
42
|
enumerable: false,
|
|
43
43
|
});
|
|
44
|
-
if (options?.wellKnownKeys)
|
|
44
|
+
if (options?.wellKnownKeys) {
|
|
45
45
|
options.wellKnownKeys.forEach(k => {
|
|
46
46
|
if (caseSensitive)
|
|
47
47
|
this[kWellKnownKeys][k] = k;
|
|
48
48
|
else
|
|
49
49
|
this[kWellKnownKeys][k.toLowerCase()] = k;
|
|
50
50
|
});
|
|
51
|
+
}
|
|
51
52
|
this.clear();
|
|
52
53
|
if (init)
|
|
53
54
|
this.setAll(init);
|
|
@@ -73,12 +74,12 @@ class ResponsiveMap {
|
|
|
73
74
|
has(key) {
|
|
74
75
|
if (!key)
|
|
75
76
|
return false;
|
|
76
|
-
return this[kEntries]
|
|
77
|
+
return Object.prototype.hasOwnProperty.call(this[kEntries], this._getStoringKey(key));
|
|
77
78
|
}
|
|
78
79
|
set(key, value) {
|
|
79
80
|
const storeKey = this._getStoringKey(key);
|
|
80
81
|
key = this._getOriginalKey(key);
|
|
81
|
-
const exists = this[kEntries]
|
|
82
|
+
const exists = Object.prototype.hasOwnProperty.call(this[kEntries], storeKey);
|
|
82
83
|
this[kEntries][storeKey] = value;
|
|
83
84
|
if (!exists)
|
|
84
85
|
this[kSize]++;
|
|
@@ -103,7 +104,7 @@ class ResponsiveMap {
|
|
|
103
104
|
}
|
|
104
105
|
delete(key) {
|
|
105
106
|
const storeKey = this._getStoringKey(key);
|
|
106
|
-
const exists = this[kEntries]
|
|
107
|
+
const exists = Object.prototype.hasOwnProperty.call(this[kEntries], storeKey);
|
|
107
108
|
delete this[kEntries][storeKey];
|
|
108
109
|
delete this[kKeyMap][storeKey];
|
|
109
110
|
if (!exists)
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isConstructor = isConstructor;
|
|
4
|
+
exports.isStream = isStream;
|
|
5
|
+
exports.isReadable = isReadable;
|
|
6
|
+
exports.isWritable = isWritable;
|
|
7
|
+
exports.isReadableStream = isReadableStream;
|
|
8
|
+
exports.isBlob = isBlob;
|
|
9
|
+
exports.isFormData = isFormData;
|
|
10
|
+
exports.isURL = isURL;
|
|
11
|
+
exports.isIterable = isIterable;
|
|
12
|
+
exports.isAsyncIterable = isAsyncIterable;
|
|
4
13
|
function isConstructor(fn) {
|
|
5
14
|
return (typeof fn === 'function' &&
|
|
6
15
|
fn.prototype &&
|
|
@@ -8,26 +17,21 @@ function isConstructor(fn) {
|
|
|
8
17
|
fn.prototype.constructor.name !== 'Function' &&
|
|
9
18
|
fn.prototype.constructor.name !== 'embedded');
|
|
10
19
|
}
|
|
11
|
-
exports.isConstructor = isConstructor;
|
|
12
20
|
function isStream(x) {
|
|
13
21
|
return x !== null && typeof x === 'object' && typeof x.pipe === 'function';
|
|
14
22
|
}
|
|
15
|
-
exports.isStream = isStream;
|
|
16
23
|
function isReadable(x) {
|
|
17
24
|
return isStream(x) && typeof x._read === 'function' && typeof x._readableState === 'object';
|
|
18
25
|
}
|
|
19
|
-
exports.isReadable = isReadable;
|
|
20
26
|
function isWritable(x) {
|
|
21
27
|
return isStream(x) && typeof x._write === 'function';
|
|
22
28
|
}
|
|
23
|
-
exports.isWritable = isWritable;
|
|
24
29
|
function isReadableStream(x) {
|
|
25
30
|
return (isStream(x) &&
|
|
26
31
|
typeof x.getReader === 'function' &&
|
|
27
32
|
typeof x.pipeThrough === 'function' &&
|
|
28
33
|
typeof x.pipeTo === 'function');
|
|
29
34
|
}
|
|
30
|
-
exports.isReadableStream = isReadableStream;
|
|
31
35
|
function isBlob(x) {
|
|
32
36
|
return (x !== null &&
|
|
33
37
|
typeof x === 'object' &&
|
|
@@ -35,7 +39,6 @@ function isBlob(x) {
|
|
|
35
39
|
typeof x.arrayBuffer === 'function' &&
|
|
36
40
|
typeof x.stream === 'function');
|
|
37
41
|
}
|
|
38
|
-
exports.isBlob = isBlob;
|
|
39
42
|
function isFormData(x) {
|
|
40
43
|
return (x !== null &&
|
|
41
44
|
typeof x.constructor === 'function' &&
|
|
@@ -43,16 +46,12 @@ function isFormData(x) {
|
|
|
43
46
|
typeof x.append === 'function' &&
|
|
44
47
|
typeof x.getAll === 'function');
|
|
45
48
|
}
|
|
46
|
-
exports.isFormData = isFormData;
|
|
47
49
|
function isURL(x) {
|
|
48
50
|
return x !== null && typeof x == 'object' && typeof x.host === 'string' && typeof x.href === 'string';
|
|
49
51
|
}
|
|
50
|
-
exports.isURL = isURL;
|
|
51
52
|
function isIterable(x) {
|
|
52
53
|
return Symbol.iterator in x;
|
|
53
54
|
}
|
|
54
|
-
exports.isIterable = isIterable;
|
|
55
55
|
function isAsyncIterable(x) {
|
|
56
56
|
return Symbol.asyncIterator in x;
|
|
57
57
|
}
|
|
58
|
-
exports.isAsyncIterable = isAsyncIterable;
|
package/cjs/i18n/i18n.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.I18n = exports.BaseI18n = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fast_tokenizer_1 = require("fast-tokenizer");
|
|
6
5
|
const i18next_1 = tslib_1.__importDefault(require("@browsery/i18next"));
|
|
6
|
+
const fast_tokenizer_1 = require("fast-tokenizer");
|
|
7
7
|
const string_utils_js_1 = require("./string-utils.js");
|
|
8
8
|
exports.BaseI18n = Object.getPrototypeOf(i18next_1.default.createInstance()).constructor;
|
|
9
9
|
class I18n extends exports.BaseI18n {
|
|
@@ -42,7 +42,7 @@ class I18n extends exports.BaseI18n {
|
|
|
42
42
|
const objectStack = new WeakMap();
|
|
43
43
|
return this._deepTranslate(input, objectStack, options);
|
|
44
44
|
}
|
|
45
|
-
createInstance(options
|
|
45
|
+
createInstance(options, callback) {
|
|
46
46
|
return new I18n(options, callback);
|
|
47
47
|
}
|
|
48
48
|
static createInstance(options, callback) {
|
|
@@ -106,8 +106,9 @@ class I18n extends exports.BaseI18n {
|
|
|
106
106
|
input instanceof Map ||
|
|
107
107
|
input instanceof Set ||
|
|
108
108
|
input instanceof WeakMap ||
|
|
109
|
-
input instanceof WeakSet)
|
|
109
|
+
input instanceof WeakSet) {
|
|
110
110
|
return input;
|
|
111
|
+
}
|
|
111
112
|
const out = {};
|
|
112
113
|
objectStack.set(input, out);
|
|
113
114
|
const keys = Object.keys(input);
|
package/cjs/i18n/index.js
CHANGED
package/cjs/i18n/string-utils.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.escapeString = escapeString;
|
|
4
|
+
exports.unescapeString = unescapeString;
|
|
4
5
|
const unescapeRegEx = /\\(.)/g;
|
|
5
6
|
const escapeRegEx = /(\\)/g;
|
|
6
7
|
function escapeString(s) {
|
|
7
8
|
return s.replace(escapeRegEx, '\\\\');
|
|
8
9
|
}
|
|
9
|
-
exports.escapeString = escapeString;
|
|
10
10
|
function unescapeString(s) {
|
|
11
11
|
return s.replace(unescapeRegEx, '$1');
|
|
12
12
|
}
|
|
13
|
-
exports.unescapeString = unescapeString;
|
package/cjs/i18n/translate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.translate =
|
|
3
|
+
exports.translate = translate;
|
|
4
4
|
const string_utils_js_1 = require("./string-utils.js");
|
|
5
5
|
const bracketRegEx = /(\))/g;
|
|
6
6
|
function translate(key, arg0, arg1) {
|
|
@@ -12,4 +12,3 @@ function translate(key, arg0, arg1) {
|
|
|
12
12
|
(fallback ? '?' + (0, string_utils_js_1.escapeString)(fallback).replace(bracketRegEx, '\\$1') : '') +
|
|
13
13
|
')');
|
|
14
14
|
}
|
|
15
|
-
exports.translate = translate;
|
package/cjs/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.uid = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
tslib_1.__exportStar(require("./types.js"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./document/index.js"), exports);
|
|
7
6
|
tslib_1.__exportStar(require("./exception/index.js"), exports);
|
|
8
7
|
tslib_1.__exportStar(require("./filter/index.js"), exports);
|
|
@@ -10,5 +9,6 @@ tslib_1.__exportStar(require("./helpers/index.js"), exports);
|
|
|
10
9
|
tslib_1.__exportStar(require("./http/index.js"), exports);
|
|
11
10
|
tslib_1.__exportStar(require("./i18n/index.js"), exports);
|
|
12
11
|
tslib_1.__exportStar(require("./schema/index.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./types.js"), exports);
|
|
13
13
|
var uid_1 = require("uid");
|
|
14
14
|
Object.defineProperty(exports, "uid", { enumerable: true, get: function () { return uid_1.uid; } });
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isDataType = isDataType;
|
|
4
|
+
exports.isComplexType = isComplexType;
|
|
5
|
+
exports.isSimpleType = isSimpleType;
|
|
6
|
+
exports.isMixinType = isMixinType;
|
|
7
|
+
exports.isMappedType = isMappedType;
|
|
8
|
+
exports.isEnumType = isEnumType;
|
|
9
|
+
exports.isHttpController = isHttpController;
|
|
4
10
|
const complex_type_interface_js_1 = require("./data-type/complex-type.interface.js");
|
|
5
11
|
const enum_type_interface_js_1 = require("./data-type/enum-type.interface.js");
|
|
6
12
|
const mapped_type_interface_js_1 = require("./data-type/mapped-type.interface.js");
|
|
@@ -16,28 +22,21 @@ function isDataType(obj) {
|
|
|
16
22
|
obj.kind === simple_type_interface_js_1.SimpleType.Kind ||
|
|
17
23
|
obj.kind === mixin_type_interface_js_1.MixinType.Kind));
|
|
18
24
|
}
|
|
19
|
-
exports.isDataType = isDataType;
|
|
20
25
|
function isComplexType(obj) {
|
|
21
26
|
return obj && typeof obj === 'object' && obj.kind === complex_type_interface_js_1.ComplexType.Kind;
|
|
22
27
|
}
|
|
23
|
-
exports.isComplexType = isComplexType;
|
|
24
28
|
function isSimpleType(obj) {
|
|
25
29
|
return obj && typeof obj === 'object' && obj.kind === simple_type_interface_js_1.SimpleType.Kind;
|
|
26
30
|
}
|
|
27
|
-
exports.isSimpleType = isSimpleType;
|
|
28
31
|
function isMixinType(obj) {
|
|
29
32
|
return obj && typeof obj === 'object' && obj.kind === mixin_type_interface_js_1.MixinType.Kind;
|
|
30
33
|
}
|
|
31
|
-
exports.isMixinType = isMixinType;
|
|
32
34
|
function isMappedType(obj) {
|
|
33
35
|
return obj && typeof obj === 'object' && obj.kind === mapped_type_interface_js_1.MappedType.Kind;
|
|
34
36
|
}
|
|
35
|
-
exports.isMappedType = isMappedType;
|
|
36
37
|
function isEnumType(obj) {
|
|
37
38
|
return obj && typeof obj === 'object' && obj.kind === enum_type_interface_js_1.EnumType.Kind;
|
|
38
39
|
}
|
|
39
|
-
exports.isEnumType = isEnumType;
|
|
40
40
|
function isHttpController(obj) {
|
|
41
41
|
return obj && typeof obj === 'object' && obj.kind === http_controller_interface_js_1.HttpController.Kind;
|
|
42
42
|
}
|
|
43
|
-
exports.isHttpController = isHttpController;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var _a;
|
|
2
|
+
import { md5 } from 'super-fast-md5';
|
|
2
3
|
import { cloneObject, omitUndefined, ResponsiveMap } from '../helpers/index.js';
|
|
3
4
|
import { OpraSchema } from '../schema/index.js';
|
|
4
5
|
import { DataTypeMap } from './common/data-type-map.js';
|
|
@@ -13,6 +14,8 @@ export class ApiDocument extends DocumentElement {
|
|
|
13
14
|
constructor() {
|
|
14
15
|
super(null);
|
|
15
16
|
this[_a] = new WeakMap();
|
|
17
|
+
this.id = '';
|
|
18
|
+
this.info = {};
|
|
16
19
|
this.references = new ResponsiveMap();
|
|
17
20
|
this.types = new DataTypeMap();
|
|
18
21
|
this.node[kDataTypeMap] = this.types;
|
|
@@ -77,6 +80,14 @@ export class ApiDocument extends DocumentElement {
|
|
|
77
80
|
out.api = this.api.toJSON();
|
|
78
81
|
return out;
|
|
79
82
|
}
|
|
83
|
+
invalidate() {
|
|
84
|
+
/** Generate id */
|
|
85
|
+
const x = this.export();
|
|
86
|
+
delete x.id;
|
|
87
|
+
this.id = md5(JSON.stringify(x));
|
|
88
|
+
/** Clear [kTypeNSMap] */
|
|
89
|
+
this[kTypeNSMap] = new WeakMap();
|
|
90
|
+
}
|
|
80
91
|
_findDataType(nameOrCtor, visitedRefs) {
|
|
81
92
|
let result = this.types.get(nameOrCtor);
|
|
82
93
|
if (result || !this.references.size)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { asMutable } from 'ts-gems';
|
|
2
|
+
import { uid } from 'uid';
|
|
2
3
|
import { DocumentNode } from './document-node.js';
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
@@ -8,17 +9,19 @@ export const DocumentElement = function (owner) {
|
|
|
8
9
|
if (!this)
|
|
9
10
|
throw new TypeError('"this" should be passed to call class constructor');
|
|
10
11
|
const _this = asMutable(this);
|
|
12
|
+
_this.id = uid(16);
|
|
11
13
|
Object.defineProperty(_this, 'node', {
|
|
12
14
|
value: new DocumentNode(this, owner?.node),
|
|
13
15
|
enumerable: false,
|
|
14
16
|
writable: true,
|
|
15
17
|
});
|
|
16
|
-
if (owner)
|
|
18
|
+
if (owner) {
|
|
17
19
|
Object.defineProperty(_this, 'owner', {
|
|
18
20
|
value: owner,
|
|
19
21
|
enumerable: false,
|
|
20
22
|
writable: true,
|
|
21
23
|
});
|
|
24
|
+
}
|
|
22
25
|
};
|
|
23
26
|
/**
|
|
24
27
|
* @class DocumentElement
|