@opra/common 0.21.0 → 0.23.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/browser.js +810 -1427
- package/cjs/document/api-document.js +8 -4
- package/cjs/document/data-type/api-field.js +2 -2
- package/cjs/document/data-type/complex-type.js +17 -63
- package/cjs/document/data-type/data-type.js +0 -9
- package/cjs/document/data-type/enum-type.js +2 -8
- package/cjs/document/data-type/mapped-type.js +0 -36
- package/cjs/document/data-type/simple-type.js +2 -8
- package/cjs/document/data-type/union-type.js +0 -36
- package/cjs/document/index.js +2 -0
- package/cjs/document/resource/collection.js +75 -32
- package/cjs/document/resource/singleton.js +31 -20
- package/cjs/document/resource/storage.js +6 -20
- package/cjs/document/utils/generate-codec.js +39 -0
- package/cjs/exception/resource-errors/resource-not-found.error.js +1 -1
- package/cjs/helpers/index.js +1 -1
- package/cjs/helpers/is-url-string.js +14 -0
- package/cjs/helpers/object-utils.js +2 -2
- package/cjs/helpers/responsive-map.js +4 -4
- package/cjs/helpers/type-guards.js +15 -3
- package/cjs/http/enums/http-headers-codes.enum.js +3 -5
- package/cjs/http/enums/http-status-codes.enum.js +1 -1
- package/cjs/http/index.js +2 -9
- package/cjs/http/opra-url-path.js +251 -0
- package/cjs/{url → http}/opra-url.js +53 -109
- package/cjs/i18n/i18n.js +3 -3
- package/cjs/index.js +0 -2
- package/cjs/schema/opra-schema.ns.js +1 -1
- package/cjs/schema/resource/operation.interface.js +2 -0
- package/esm/document/api-document.js +10 -6
- package/esm/document/data-type/api-field.js +2 -2
- package/esm/document/data-type/complex-type.js +13 -59
- package/esm/document/data-type/data-type.js +0 -9
- package/esm/document/data-type/enum-type.js +2 -8
- package/esm/document/data-type/mapped-type.js +0 -36
- package/esm/document/data-type/simple-type.js +2 -8
- package/esm/document/data-type/union-type.js +0 -36
- package/esm/document/index.js +2 -0
- package/esm/document/resource/collection.js +75 -32
- package/esm/document/resource/singleton.js +31 -20
- package/esm/document/resource/storage.js +6 -20
- package/esm/document/utils/generate-codec.js +33 -0
- package/esm/exception/resource-errors/resource-not-found.error.js +1 -1
- package/esm/helpers/index.js +1 -1
- package/esm/helpers/is-url-string.js +9 -0
- package/esm/helpers/object-utils.js +2 -2
- package/esm/helpers/responsive-map.js +4 -4
- package/esm/helpers/type-guards.js +11 -2
- package/esm/http/enums/http-headers-codes.enum.js +3 -5
- package/esm/http/enums/http-status-codes.enum.js +1 -1
- package/esm/http/index.js +2 -9
- package/esm/http/opra-url-path.js +246 -0
- package/esm/{url → http}/opra-url.js +53 -109
- package/esm/i18n/i18n.js +4 -4
- package/esm/index.js +0 -2
- package/esm/schema/opra-schema.ns.js +1 -1
- package/esm/schema/resource/operation.interface.js +1 -0
- package/package.json +1 -1
- package/types/document/api-document.d.ts +4 -1
- package/types/document/data-type/complex-type.d.ts +6 -11
- package/types/document/data-type/data-type.d.ts +0 -6
- package/types/document/data-type/enum-type.d.ts +2 -4
- package/types/document/data-type/mapped-type.d.ts +0 -4
- package/types/document/data-type/simple-type.d.ts +2 -4
- package/types/document/data-type/union-type.d.ts +0 -5
- package/types/document/index.d.ts +2 -0
- package/types/document/interfaces/collection-resource.interface.d.ts +10 -0
- package/types/document/interfaces/singleton-resource.interface.d.ts +7 -0
- package/types/document/interfaces/storage-resource.interface.d.ts +8 -0
- package/types/document/resource/collection.d.ts +42 -36
- package/types/document/resource/resource.d.ts +2 -1
- package/types/document/resource/singleton.d.ts +24 -21
- package/types/document/resource/storage.d.ts +14 -17
- package/types/document/utils/generate-codec.d.ts +10 -0
- package/types/filter/errors.d.ts +2 -2
- package/types/helpers/index.d.ts +1 -1
- package/types/helpers/is-url-string.d.ts +2 -0
- package/types/helpers/object-utils.d.ts +1 -1
- package/types/helpers/type-guards.d.ts +3 -0
- package/types/http/enums/http-headers-codes.enum.d.ts +2 -4
- package/types/http/enums/http-status-codes.enum.d.ts +1 -1
- package/types/http/index.d.ts +2 -9
- package/types/http/opra-url-path.d.ts +54 -0
- package/types/{url → http}/opra-url.d.ts +9 -13
- package/types/index.d.ts +0 -2
- package/types/schema/opra-schema.ns.d.ts +1 -1
- package/types/schema/resource/collection.interface.d.ts +29 -8
- package/types/schema/resource/operation.interface.d.ts +3 -0
- package/types/schema/resource/resource.interface.d.ts +1 -0
- package/types/schema/resource/singleton.interface.d.ts +5 -5
- package/types/schema/resource/storage.interface.d.ts +42 -5
- package/cjs/helpers/is-url.js +0 -8
- package/cjs/http/codecs/boolean-codec.js +0 -24
- package/cjs/http/codecs/date-codec.js +0 -41
- package/cjs/http/codecs/filter-codec.js +0 -17
- package/cjs/http/codecs/integer-codec.js +0 -19
- package/cjs/http/codecs/number-codec.js +0 -24
- package/cjs/http/codecs/string-codec.js +0 -23
- package/cjs/http/http-params.js +0 -353
- package/cjs/http/multipart/batch-multipart.js +0 -170
- package/cjs/http/multipart/http-request-content.js +0 -17
- package/cjs/http/multipart/http-response-content.js +0 -14
- package/cjs/http/multipart/index.js +0 -2
- package/cjs/url/index.js +0 -8
- package/cjs/url/opra-url-path-component.js +0 -30
- package/cjs/url/opra-url-path.js +0 -155
- package/cjs/url/utils/decode-path-component.js +0 -41
- package/cjs/url/utils/encode-path-component.js +0 -27
- package/cjs/utils/path-utils.js +0 -24
- package/esm/helpers/is-url.js +0 -4
- package/esm/http/codecs/boolean-codec.js +0 -20
- package/esm/http/codecs/date-codec.js +0 -37
- package/esm/http/codecs/filter-codec.js +0 -13
- package/esm/http/codecs/integer-codec.js +0 -15
- package/esm/http/codecs/number-codec.js +0 -20
- package/esm/http/codecs/string-codec.js +0 -19
- package/esm/http/http-params.js +0 -348
- package/esm/http/multipart/batch-multipart.js +0 -170
- package/esm/http/multipart/http-request-content.js +0 -17
- package/esm/http/multipart/http-response-content.js +0 -14
- package/esm/http/multipart/index.js +0 -2
- package/esm/url/index.js +0 -5
- package/esm/url/opra-url-path-component.js +0 -26
- package/esm/url/opra-url-path.js +0 -151
- package/esm/url/utils/decode-path-component.js +0 -37
- package/esm/url/utils/encode-path-component.js +0 -22
- package/esm/utils/path-utils.js +0 -19
- package/types/helpers/is-url.d.ts +0 -1
- package/types/http/codecs/boolean-codec.d.ts +0 -5
- package/types/http/codecs/date-codec.d.ts +0 -16
- package/types/http/codecs/filter-codec.d.ts +0 -6
- package/types/http/codecs/integer-codec.d.ts +0 -11
- package/types/http/codecs/number-codec.d.ts +0 -14
- package/types/http/codecs/string-codec.d.ts +0 -16
- package/types/http/http-params.d.ts +0 -114
- package/types/http/interfaces/client-http-headers.interface.d.ts +0 -65
- package/types/http/interfaces/server-http-headers.interface.d.ts +0 -1
- package/types/http/multipart/batch-multipart.d.ts +0 -0
- package/types/http/multipart/http-request-content.d.ts +0 -0
- package/types/http/multipart/http-response-content.d.ts +0 -0
- package/types/http/multipart/index.d.ts +0 -0
- package/types/schema/resource/endpoint.interface.d.ts +0 -29
- package/types/url/index.d.ts +0 -5
- package/types/url/opra-url-path-component.d.ts +0 -15
- package/types/url/opra-url-path.d.ts +0 -36
- package/types/url/utils/decode-path-component.d.ts +0 -5
- package/types/url/utils/encode-path-component.d.ts +0 -1
- package/types/utils/path-utils.d.ts +0 -2
- /package/cjs/{http/interfaces/client-http-headers.interface.js → document/interfaces/collection-resource.interface.js} +0 -0
- /package/cjs/{http/interfaces/server-http-headers.interface.js → document/interfaces/singleton-resource.interface.js} +0 -0
- /package/cjs/{schema/resource/endpoint.interface.js → document/interfaces/storage-resource.interface.js} +0 -0
- /package/esm/{http/interfaces/client-http-headers.interface.js → document/interfaces/collection-resource.interface.js} +0 -0
- /package/esm/{http/interfaces/server-http-headers.interface.js → document/interfaces/singleton-resource.interface.js} +0 -0
- /package/esm/{schema/resource/endpoint.interface.js → document/interfaces/storage-resource.interface.js} +0 -0
package/browser.js
CHANGED
|
@@ -37,11 +37,15 @@ function isStream(stream) {
|
|
|
37
37
|
}
|
|
38
38
|
__name(isStream, "isStream");
|
|
39
39
|
function isReadable(x) {
|
|
40
|
-
return isStream(x) &&
|
|
40
|
+
return isStream(x) && typeof x._read === "function" && typeof x._readableState === "object";
|
|
41
41
|
}
|
|
42
42
|
__name(isReadable, "isReadable");
|
|
43
|
+
function isWritable(x) {
|
|
44
|
+
return isStream(x) && typeof x._write === "function";
|
|
45
|
+
}
|
|
46
|
+
__name(isWritable, "isWritable");
|
|
43
47
|
function isReadableStream(x) {
|
|
44
|
-
return isStream(x) &&
|
|
48
|
+
return isStream(x) && typeof x.getReader === "function" && typeof x.pipeThrough === "function" && typeof x.pipeTo === "function";
|
|
45
49
|
}
|
|
46
50
|
__name(isReadableStream, "isReadableStream");
|
|
47
51
|
function isBlob(x) {
|
|
@@ -53,9 +57,17 @@ function isFormData(x) {
|
|
|
53
57
|
}
|
|
54
58
|
__name(isFormData, "isFormData");
|
|
55
59
|
function isURL(x) {
|
|
56
|
-
return x !== null && typeof x.host === "string" && typeof x.href === "string";
|
|
60
|
+
return x !== null && typeof x == "object" && typeof x.host === "string" && typeof x.href === "string";
|
|
57
61
|
}
|
|
58
62
|
__name(isURL, "isURL");
|
|
63
|
+
function isIterable(x) {
|
|
64
|
+
return Symbol.iterator in x;
|
|
65
|
+
}
|
|
66
|
+
__name(isIterable, "isIterable");
|
|
67
|
+
function isAsyncIterable(x) {
|
|
68
|
+
return Symbol.asyncIterator in x;
|
|
69
|
+
}
|
|
70
|
+
__name(isAsyncIterable, "isAsyncIterable");
|
|
59
71
|
|
|
60
72
|
// ../../build/common/esm/helpers/function-utils.js
|
|
61
73
|
async function resolveThunk(thunk) {
|
|
@@ -97,12 +109,16 @@ function getStackFileName(position = 1) {
|
|
|
97
109
|
}
|
|
98
110
|
__name(getStackFileName, "getStackFileName");
|
|
99
111
|
|
|
100
|
-
// ../../build/common/esm/helpers/is-url.js
|
|
112
|
+
// ../../build/common/esm/helpers/is-url-string.js
|
|
113
|
+
import { URL } from "url";
|
|
101
114
|
var URL_PATTERN = /^(https?:\/\/.)[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/i;
|
|
102
|
-
function
|
|
115
|
+
function isUrlString(url) {
|
|
103
116
|
return URL_PATTERN.test(url);
|
|
104
117
|
}
|
|
105
|
-
__name(
|
|
118
|
+
__name(isUrlString, "isUrlString");
|
|
119
|
+
var isAbsoluteUrl = /* @__PURE__ */ __name((urlString) => {
|
|
120
|
+
return !urlString.includes("://") && new URL(urlString, "http://tempuri.org/").host !== "tempuri.org";
|
|
121
|
+
}, "isAbsoluteUrl");
|
|
106
122
|
|
|
107
123
|
// ../../build/common/esm/helpers/mixin-utils.js
|
|
108
124
|
function mergePrototype(targetProto, baseProto, filter) {
|
|
@@ -139,13 +155,13 @@ function cloneObject(obj, jsonOnly) {
|
|
|
139
155
|
});
|
|
140
156
|
}
|
|
141
157
|
__name(cloneObject, "cloneObject");
|
|
142
|
-
function omitUndefined(obj) {
|
|
158
|
+
function omitUndefined(obj, recursive) {
|
|
143
159
|
if (!(obj && typeof obj === "object"))
|
|
144
160
|
return obj;
|
|
145
161
|
for (const k of Object.keys(obj)) {
|
|
146
162
|
if (obj[k] === void 0)
|
|
147
163
|
delete obj[k];
|
|
148
|
-
else if (typeof obj[k] === "object")
|
|
164
|
+
else if (recursive && typeof obj[k] === "object")
|
|
149
165
|
omitUndefined(obj[k]);
|
|
150
166
|
}
|
|
151
167
|
return obj;
|
|
@@ -188,10 +204,10 @@ function isMap(v) {
|
|
|
188
204
|
return v && typeof v.forEach === "function";
|
|
189
205
|
}
|
|
190
206
|
__name(isMap, "isMap");
|
|
191
|
-
var kKeyMap = Symbol("kKeyMap");
|
|
192
|
-
var kKeyOrder = Symbol("kKeyOrder");
|
|
193
|
-
var kWellKnownKeys = Symbol("kWellKnownKeys");
|
|
194
|
-
var kOptions = Symbol("kOptions");
|
|
207
|
+
var kKeyMap = Symbol.for("kKeyMap");
|
|
208
|
+
var kKeyOrder = Symbol.for("kKeyOrder");
|
|
209
|
+
var kWellKnownKeys = Symbol.for("kWellKnownKeys");
|
|
210
|
+
var kOptions = Symbol.for("kOptions");
|
|
195
211
|
var ResponsiveMap = class extends Map {
|
|
196
212
|
static {
|
|
197
213
|
__name(this, "ResponsiveMap");
|
|
@@ -413,7 +429,7 @@ var I18n = class _I18n extends BaseI18n {
|
|
|
413
429
|
}
|
|
414
430
|
async loadResourceBundle(lang, ns, filePath, deep, overwrite) {
|
|
415
431
|
let obj;
|
|
416
|
-
if (
|
|
432
|
+
if (isUrlString(filePath)) {
|
|
417
433
|
obj = (await fetch(filePath, { headers: { accept: "application/json" } })).json();
|
|
418
434
|
} else {
|
|
419
435
|
const content = fs.readFileSync(filePath, "utf8");
|
|
@@ -832,7 +848,7 @@ var ResourceNotFoundError = class extends OpraException {
|
|
|
832
848
|
}
|
|
833
849
|
constructor(resource, keyValue, cause) {
|
|
834
850
|
super({
|
|
835
|
-
message: translate(`error:RESOURCE_NOT_FOUND`, { resource: resource + (keyValue ? "@" + keyValue : "") }, `The resource '{{resource}}'
|
|
851
|
+
message: translate(`error:RESOURCE_NOT_FOUND`, { resource: resource + (keyValue ? "@" + keyValue : "") }, `The resource '{{resource}}' not found`),
|
|
836
852
|
severity: "error",
|
|
837
853
|
code: "RESOURCE_NOT_FOUND",
|
|
838
854
|
details: {
|
|
@@ -988,7 +1004,6 @@ __name(isContainer, "isContainer");
|
|
|
988
1004
|
import "reflect-metadata";
|
|
989
1005
|
import omit2 from "lodash.omit";
|
|
990
1006
|
import merge3 from "putil-merge";
|
|
991
|
-
import * as vg2 from "valgen";
|
|
992
1007
|
|
|
993
1008
|
// ../../build/common/esm/document/data-type/enum-type.js
|
|
994
1009
|
import "reflect-metadata";
|
|
@@ -1014,15 +1029,6 @@ var DataType = class _DataType {
|
|
|
1014
1029
|
this.description = init?.description;
|
|
1015
1030
|
this.isAnonymous = !this.name;
|
|
1016
1031
|
}
|
|
1017
|
-
decode(v) {
|
|
1018
|
-
return this._getDecoder()(v, { coerce: true });
|
|
1019
|
-
}
|
|
1020
|
-
encode(v) {
|
|
1021
|
-
return this._getEncoder()(v, { coerce: true });
|
|
1022
|
-
}
|
|
1023
|
-
validate(v) {
|
|
1024
|
-
return this._getEncoder()(v);
|
|
1025
|
-
}
|
|
1026
1032
|
exportSchema() {
|
|
1027
1033
|
return omitUndefined({
|
|
1028
1034
|
kind: this.kind,
|
|
@@ -1060,6 +1066,8 @@ var EnumTypeClass = class extends DataType {
|
|
|
1060
1066
|
this.ownMeanings = init.meanings || {};
|
|
1061
1067
|
this.values = { ...this.base?.values, ...this.ownValues };
|
|
1062
1068
|
this.meanings = { ...this.base?.meanings, ...this.ownMeanings };
|
|
1069
|
+
this.decode = vg.isEnum(Object.values(this.values));
|
|
1070
|
+
this.encode = vg.isEnum(Object.values(this.values));
|
|
1063
1071
|
}
|
|
1064
1072
|
exportSchema() {
|
|
1065
1073
|
const out = DataType.prototype.exportSchema.call(this);
|
|
@@ -1070,14 +1078,6 @@ var EnumTypeClass = class extends DataType {
|
|
|
1070
1078
|
}));
|
|
1071
1079
|
return out;
|
|
1072
1080
|
}
|
|
1073
|
-
_getDecoder() {
|
|
1074
|
-
if (!this._decoder)
|
|
1075
|
-
this._decoder = vg.isEnum(Object.values(this.values), { enumName: this.name });
|
|
1076
|
-
return this._decoder;
|
|
1077
|
-
}
|
|
1078
|
-
_getEncoder() {
|
|
1079
|
-
return this._getDecoder();
|
|
1080
|
-
}
|
|
1081
1081
|
};
|
|
1082
1082
|
var EnumType2 = /* @__PURE__ */ __name(function(...args) {
|
|
1083
1083
|
if (this) {
|
|
@@ -1161,14 +1161,14 @@ var ApiField = /* @__PURE__ */ __name(function(...args) {
|
|
|
1161
1161
|
}, "ApiField");
|
|
1162
1162
|
var proto = {
|
|
1163
1163
|
exportSchema() {
|
|
1164
|
-
return {
|
|
1164
|
+
return omitUndefined({
|
|
1165
1165
|
type: this.type.name ? this.type.name : this.type.exportSchema(),
|
|
1166
1166
|
description: this.description,
|
|
1167
1167
|
isArray: this.isArray,
|
|
1168
1168
|
default: this.default,
|
|
1169
1169
|
fixed: this.fixed,
|
|
1170
1170
|
required: this.required
|
|
1171
|
-
};
|
|
1171
|
+
});
|
|
1172
1172
|
}
|
|
1173
1173
|
};
|
|
1174
1174
|
Object.assign(ApiField.prototype, proto);
|
|
@@ -1182,7 +1182,7 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1182
1182
|
super(document, init);
|
|
1183
1183
|
this.kind = opra_schema_ns_exports.ComplexType.Kind;
|
|
1184
1184
|
const own = this.own = {};
|
|
1185
|
-
own.ctor = init?.ctor;
|
|
1185
|
+
own.ctor = init?.ctor || init?.base?.ctor;
|
|
1186
1186
|
own.abstract = init?.abstract;
|
|
1187
1187
|
own.additionalFields = init?.additionalFields;
|
|
1188
1188
|
own.fields = new ResponsiveMap();
|
|
@@ -1195,8 +1195,6 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1195
1195
|
if (this.base) {
|
|
1196
1196
|
if (this.additionalFields == null)
|
|
1197
1197
|
this.additionalFields = this.base.additionalFields;
|
|
1198
|
-
if (own.ctor == null && this.base instanceof ComplexType2)
|
|
1199
|
-
this.ctor = this.base.ctor;
|
|
1200
1198
|
if (this.base.fields)
|
|
1201
1199
|
for (const [k, el] of this.base.fields.entries()) {
|
|
1202
1200
|
const newEl = new ApiField(this, el);
|
|
@@ -1231,7 +1229,7 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1231
1229
|
} else
|
|
1232
1230
|
field = this.fields.get(nameOrPath);
|
|
1233
1231
|
if (!field)
|
|
1234
|
-
throw new Error(
|
|
1232
|
+
throw new Error(translate("error:UNKNOWN_FIELD", { field: nameOrPath }));
|
|
1235
1233
|
return field;
|
|
1236
1234
|
}
|
|
1237
1235
|
iteratePath(path2, silent) {
|
|
@@ -1264,7 +1262,7 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1264
1262
|
if (dataType && !dataType.additionalFields) {
|
|
1265
1263
|
if (silent)
|
|
1266
1264
|
return { done: true, value: [] };
|
|
1267
|
-
throw new Error(
|
|
1265
|
+
throw new Error(translate("error:UNKNOWN_FIELD", { field: curPath }));
|
|
1268
1266
|
}
|
|
1269
1267
|
}
|
|
1270
1268
|
}
|
|
@@ -1276,13 +1274,14 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1276
1274
|
};
|
|
1277
1275
|
}
|
|
1278
1276
|
normalizeFieldPath(fieldPaths) {
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1277
|
+
const array = (Array.isArray(fieldPaths) ? fieldPaths : [fieldPaths]).map((s) => {
|
|
1278
|
+
let curPath = "";
|
|
1279
|
+
for (const [, , p] of this.iteratePath(s)) {
|
|
1280
|
+
curPath = p;
|
|
1281
|
+
}
|
|
1282
|
+
return curPath;
|
|
1283
|
+
}).flat();
|
|
1284
|
+
return array.length ? array : void 0;
|
|
1286
1285
|
}
|
|
1287
1286
|
exportSchema() {
|
|
1288
1287
|
const out = super.exportSchema();
|
|
@@ -1311,52 +1310,6 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1311
1310
|
}
|
|
1312
1311
|
return false;
|
|
1313
1312
|
}
|
|
1314
|
-
decode(v) {
|
|
1315
|
-
return this._getDecoder()(v, { coerce: true });
|
|
1316
|
-
}
|
|
1317
|
-
encode(v) {
|
|
1318
|
-
return this._getEncoder()(v, { coerce: true });
|
|
1319
|
-
}
|
|
1320
|
-
validate(v) {
|
|
1321
|
-
return this._getEncoder()(v);
|
|
1322
|
-
}
|
|
1323
|
-
_getDecoder() {
|
|
1324
|
-
if (this._decoder)
|
|
1325
|
-
return this._decoder;
|
|
1326
|
-
const schema = {};
|
|
1327
|
-
for (const f of this.fields.values()) {
|
|
1328
|
-
let t = f.type._getDecoder();
|
|
1329
|
-
if (f.isArray)
|
|
1330
|
-
t = vg2.isArray(t);
|
|
1331
|
-
schema[f.name] = f.required ? vg2.required(t) : vg2.optional(t);
|
|
1332
|
-
}
|
|
1333
|
-
this._decoder = vg2.isObject(schema, {
|
|
1334
|
-
ctor: this.ctor,
|
|
1335
|
-
additionalFields: this.additionalFields ?? "ignore",
|
|
1336
|
-
name: this.name,
|
|
1337
|
-
caseInSensitive: true
|
|
1338
|
-
});
|
|
1339
|
-
return this._decoder;
|
|
1340
|
-
}
|
|
1341
|
-
_getEncoder() {
|
|
1342
|
-
if (this._encoder)
|
|
1343
|
-
return this._encoder;
|
|
1344
|
-
const schema = {};
|
|
1345
|
-
for (const f of this.fields.values()) {
|
|
1346
|
-
let t = f.type._getEncoder();
|
|
1347
|
-
if (f.isArray)
|
|
1348
|
-
t = vg2.isArray(t);
|
|
1349
|
-
schema[f.name] = t;
|
|
1350
|
-
}
|
|
1351
|
-
this._encoder = vg2.isObject(schema, {
|
|
1352
|
-
ctor: this.ctor,
|
|
1353
|
-
additionalFields: this.additionalFields,
|
|
1354
|
-
name: this.name,
|
|
1355
|
-
caseInSensitive: true,
|
|
1356
|
-
detectCircular: true
|
|
1357
|
-
});
|
|
1358
|
-
return this._encoder;
|
|
1359
|
-
}
|
|
1360
1313
|
};
|
|
1361
1314
|
var ComplexType2 = /* @__PURE__ */ __name(function(...args) {
|
|
1362
1315
|
if (this) {
|
|
@@ -1413,7 +1366,7 @@ var ApiDocument = class {
|
|
|
1413
1366
|
*/
|
|
1414
1367
|
getDataType(arg0, silent) {
|
|
1415
1368
|
let dataType;
|
|
1416
|
-
const name = typeof arg0 === "function" ? arg0.name : arg0;
|
|
1369
|
+
const name = typeof arg0 === "function" ? arg0.name : String(arg0);
|
|
1417
1370
|
const t = typeof arg0 === "string" ? this._typeCache.get(arg0) : this._typesCacheByCtor.get(arg0);
|
|
1418
1371
|
if (t)
|
|
1419
1372
|
return t;
|
|
@@ -1530,7 +1483,7 @@ var ApiDocument = class {
|
|
|
1530
1483
|
}
|
|
1531
1484
|
if (silent)
|
|
1532
1485
|
return;
|
|
1533
|
-
throw new
|
|
1486
|
+
throw new ResourceNotFoundError(path2);
|
|
1534
1487
|
}
|
|
1535
1488
|
getCollection(path2, silent) {
|
|
1536
1489
|
const t = this.getResource(path2);
|
|
@@ -1559,7 +1512,9 @@ var ApiDocument = class {
|
|
|
1559
1512
|
/**
|
|
1560
1513
|
* Export as Opra schema definition object
|
|
1561
1514
|
*/
|
|
1562
|
-
exportSchema() {
|
|
1515
|
+
exportSchema(options) {
|
|
1516
|
+
if (this._metadataCache)
|
|
1517
|
+
return cloneObject(this._metadataCache, options?.webSafe);
|
|
1563
1518
|
const schema = {
|
|
1564
1519
|
version: opra_schema_ns_exports.SpecVersion,
|
|
1565
1520
|
url: this.url,
|
|
@@ -1589,9 +1544,11 @@ var ApiDocument = class {
|
|
|
1589
1544
|
types[name] = r.exportSchema();
|
|
1590
1545
|
}
|
|
1591
1546
|
}
|
|
1592
|
-
|
|
1547
|
+
this._metadataCache = schema;
|
|
1548
|
+
return this._metadataCache;
|
|
1593
1549
|
}
|
|
1594
1550
|
invalidate() {
|
|
1551
|
+
this._metadataCache = void 0;
|
|
1595
1552
|
this._typeCache.clear();
|
|
1596
1553
|
this._typesCacheByCtor.clear();
|
|
1597
1554
|
}
|
|
@@ -1630,7 +1587,7 @@ __name(__decorate, "__decorate");
|
|
|
1630
1587
|
import "reflect-metadata";
|
|
1631
1588
|
import omit3 from "lodash.omit";
|
|
1632
1589
|
import merge4 from "putil-merge";
|
|
1633
|
-
import * as
|
|
1590
|
+
import * as vg2 from "valgen";
|
|
1634
1591
|
var SimpleTypeClass = class extends DataType {
|
|
1635
1592
|
static {
|
|
1636
1593
|
__name(this, "SimpleTypeClass");
|
|
@@ -1639,14 +1596,8 @@ var SimpleTypeClass = class extends DataType {
|
|
|
1639
1596
|
super(document, init);
|
|
1640
1597
|
this.kind = opra_schema_ns_exports.SimpleType.Kind;
|
|
1641
1598
|
this.base = init.base;
|
|
1642
|
-
this.
|
|
1643
|
-
this.
|
|
1644
|
-
}
|
|
1645
|
-
_getDecoder() {
|
|
1646
|
-
return this._decoder;
|
|
1647
|
-
}
|
|
1648
|
-
_getEncoder() {
|
|
1649
|
-
return this._encoder;
|
|
1599
|
+
this.decode = init.decoder || init.base?.decode || vg2.isAny();
|
|
1600
|
+
this.encode = init.encoder || init.base?.encode || vg2.isAny();
|
|
1650
1601
|
}
|
|
1651
1602
|
exportSchema() {
|
|
1652
1603
|
const out = super.exportSchema();
|
|
@@ -2145,7 +2096,8 @@ __name(extractFieldSchema, "extractFieldSchema");
|
|
|
2145
2096
|
|
|
2146
2097
|
// ../../build/common/esm/document/resource/collection.js
|
|
2147
2098
|
import omit4 from "lodash.omit";
|
|
2148
|
-
import
|
|
2099
|
+
import merge7 from "putil-merge";
|
|
2100
|
+
import * as vg4 from "valgen";
|
|
2149
2101
|
|
|
2150
2102
|
// ../../build/common/esm/filter/opra-filter.ns.js
|
|
2151
2103
|
var opra_filter_ns_exports = {};
|
|
@@ -9658,6 +9610,202 @@ var _wrapEntryValue = /* @__PURE__ */ __name((v) => {
|
|
|
9658
9610
|
return new StringLiteral("" + v);
|
|
9659
9611
|
}, "_wrapEntryValue");
|
|
9660
9612
|
|
|
9613
|
+
// ../../build/common/esm/document/utils/generate-codec.js
|
|
9614
|
+
import * as vg3 from "valgen";
|
|
9615
|
+
|
|
9616
|
+
// ../../build/common/esm/document/data-type/mapped-type.js
|
|
9617
|
+
import "reflect-metadata";
|
|
9618
|
+
import merge5 from "putil-merge";
|
|
9619
|
+
var MappedTypeClass = class extends DataType {
|
|
9620
|
+
static {
|
|
9621
|
+
__name(this, "MappedTypeClass");
|
|
9622
|
+
}
|
|
9623
|
+
constructor(document, init) {
|
|
9624
|
+
super(document, init);
|
|
9625
|
+
this.kind = opra_schema_ns_exports.MappedType.Kind;
|
|
9626
|
+
const own = this.own;
|
|
9627
|
+
own.pick = init.pick;
|
|
9628
|
+
own.omit = init.omit;
|
|
9629
|
+
this.kind = opra_schema_ns_exports.MappedType.Kind;
|
|
9630
|
+
this.type = init.type;
|
|
9631
|
+
this.pick = own.pick;
|
|
9632
|
+
this.omit = own.omit;
|
|
9633
|
+
this.fields = new ResponsiveMap();
|
|
9634
|
+
this.additionalFields = this.type.additionalFields;
|
|
9635
|
+
const isInheritedPredicate = getIsInheritedPredicateFn(init.pick, init.omit);
|
|
9636
|
+
for (const [elemName, elem] of this.type.fields.entries()) {
|
|
9637
|
+
if (isInheritedPredicate(elemName))
|
|
9638
|
+
this.fields.set(elemName, elem);
|
|
9639
|
+
}
|
|
9640
|
+
}
|
|
9641
|
+
exportSchema() {
|
|
9642
|
+
const out = DataType.prototype.exportSchema.call(this);
|
|
9643
|
+
Object.assign(out, omitUndefined({
|
|
9644
|
+
type: this.type.name ? this.type.name : this.type.exportSchema(),
|
|
9645
|
+
pick: this.own.pick,
|
|
9646
|
+
omit: this.own.omit
|
|
9647
|
+
}));
|
|
9648
|
+
return out;
|
|
9649
|
+
}
|
|
9650
|
+
};
|
|
9651
|
+
var MappedType2 = /* @__PURE__ */ __name(function(...args) {
|
|
9652
|
+
if (this) {
|
|
9653
|
+
const [document, init] = args;
|
|
9654
|
+
merge5(this, new MappedTypeClass(document, init), { descriptor: true });
|
|
9655
|
+
return;
|
|
9656
|
+
}
|
|
9657
|
+
const [source, options] = args;
|
|
9658
|
+
const isInheritedPredicate = getIsInheritedPredicateFn(options.pick, options.omit);
|
|
9659
|
+
class MappedClass {
|
|
9660
|
+
static {
|
|
9661
|
+
__name(this, "MappedClass");
|
|
9662
|
+
}
|
|
9663
|
+
constructor() {
|
|
9664
|
+
inheritPropertyInitializers(this, source, isInheritedPredicate);
|
|
9665
|
+
}
|
|
9666
|
+
}
|
|
9667
|
+
mergePrototype(MappedClass.prototype, source.prototype);
|
|
9668
|
+
const m = Reflect.getOwnMetadata(METADATA_KEY, source);
|
|
9669
|
+
if (!m)
|
|
9670
|
+
throw new TypeError(`Class "${source}" doesn't have datatype metadata information`);
|
|
9671
|
+
if (!(m.kind === opra_schema_ns_exports.ComplexType.Kind))
|
|
9672
|
+
throw new TypeError(`Class "${source}" is not a ${opra_schema_ns_exports.ComplexType.Kind}`);
|
|
9673
|
+
const metadata = {
|
|
9674
|
+
kind: "MappedType",
|
|
9675
|
+
type: source
|
|
9676
|
+
};
|
|
9677
|
+
if (options.pick)
|
|
9678
|
+
metadata.pick = options.pick;
|
|
9679
|
+
if (options.omit)
|
|
9680
|
+
metadata.omit = options.omit;
|
|
9681
|
+
Reflect.defineMetadata(METADATA_KEY, metadata, MappedClass);
|
|
9682
|
+
MappedType2._applyMixin(MappedClass, source, {
|
|
9683
|
+
...options,
|
|
9684
|
+
isInheritedPredicate
|
|
9685
|
+
});
|
|
9686
|
+
return MappedClass;
|
|
9687
|
+
}, "MappedType");
|
|
9688
|
+
MappedType2.prototype = MappedTypeClass.prototype;
|
|
9689
|
+
MappedType2._applyMixin = () => void 0;
|
|
9690
|
+
function getIsInheritedPredicateFn(pick, omit7) {
|
|
9691
|
+
const pickKeys = pick?.map((x) => String(x).toLowerCase());
|
|
9692
|
+
const omitKeys = omit7?.map((x) => String(x).toLowerCase());
|
|
9693
|
+
return (propertyName) => {
|
|
9694
|
+
if (omitKeys && omitKeys.includes(propertyName.toLowerCase()))
|
|
9695
|
+
return false;
|
|
9696
|
+
if (pickKeys)
|
|
9697
|
+
return pickKeys.includes(propertyName.toLowerCase());
|
|
9698
|
+
return true;
|
|
9699
|
+
};
|
|
9700
|
+
}
|
|
9701
|
+
__name(getIsInheritedPredicateFn, "getIsInheritedPredicateFn");
|
|
9702
|
+
function PickType(classRef, keys) {
|
|
9703
|
+
return MappedType2(classRef, { pick: keys });
|
|
9704
|
+
}
|
|
9705
|
+
__name(PickType, "PickType");
|
|
9706
|
+
function OmitType(classRef, keys) {
|
|
9707
|
+
return MappedType2(classRef, { omit: keys });
|
|
9708
|
+
}
|
|
9709
|
+
__name(OmitType, "OmitType");
|
|
9710
|
+
|
|
9711
|
+
// ../../build/common/esm/document/data-type/union-type.js
|
|
9712
|
+
import "reflect-metadata";
|
|
9713
|
+
import merge6 from "putil-merge";
|
|
9714
|
+
var UnionTypeClass = class extends DataType {
|
|
9715
|
+
static {
|
|
9716
|
+
__name(this, "UnionTypeClass");
|
|
9717
|
+
}
|
|
9718
|
+
constructor(document, init) {
|
|
9719
|
+
super(document, init);
|
|
9720
|
+
this.kind = opra_schema_ns_exports.UnionType.Kind;
|
|
9721
|
+
this.fields = new ResponsiveMap();
|
|
9722
|
+
const own = this.own;
|
|
9723
|
+
own.types = [];
|
|
9724
|
+
for (const base of init.types) {
|
|
9725
|
+
if (!(base instanceof ComplexType2 || base instanceof UnionType2 || base instanceof MappedType2))
|
|
9726
|
+
throw new TypeError(`${opra_schema_ns_exports.UnionType.Kind} shall contain ${opra_schema_ns_exports.ComplexType.Kind}, ${opra_schema_ns_exports.UnionType.Kind} of ${opra_schema_ns_exports.MappedType.Kind} types.`);
|
|
9727
|
+
own.types.push(base);
|
|
9728
|
+
if (base.additionalFields)
|
|
9729
|
+
this.additionalFields = true;
|
|
9730
|
+
this.fields.setAll(base.fields);
|
|
9731
|
+
}
|
|
9732
|
+
this.types = [...own.types];
|
|
9733
|
+
}
|
|
9734
|
+
exportSchema() {
|
|
9735
|
+
const out = super.exportSchema();
|
|
9736
|
+
Object.assign(out, omitUndefined({
|
|
9737
|
+
types: this.own.types.map((t) => t.name ? t.name : t.exportSchema())
|
|
9738
|
+
}));
|
|
9739
|
+
return out;
|
|
9740
|
+
}
|
|
9741
|
+
};
|
|
9742
|
+
var UnionType2 = /* @__PURE__ */ __name(function(...args) {
|
|
9743
|
+
if (this) {
|
|
9744
|
+
const [document, init] = args;
|
|
9745
|
+
merge6(this, new UnionTypeClass(document, init), { descriptor: true });
|
|
9746
|
+
return;
|
|
9747
|
+
}
|
|
9748
|
+
const clasRefs = [...args].filter((x) => !!x);
|
|
9749
|
+
if (!clasRefs.length)
|
|
9750
|
+
throw new TypeError("No Class has been provided");
|
|
9751
|
+
if (clasRefs.length === 1)
|
|
9752
|
+
return clasRefs[0];
|
|
9753
|
+
class UnionClass {
|
|
9754
|
+
static {
|
|
9755
|
+
__name(this, "UnionClass");
|
|
9756
|
+
}
|
|
9757
|
+
constructor() {
|
|
9758
|
+
for (const c of clasRefs)
|
|
9759
|
+
inheritPropertyInitializers(this, c);
|
|
9760
|
+
}
|
|
9761
|
+
}
|
|
9762
|
+
const metadata = {
|
|
9763
|
+
kind: opra_schema_ns_exports.UnionType.Kind,
|
|
9764
|
+
types: []
|
|
9765
|
+
};
|
|
9766
|
+
Reflect.defineMetadata(METADATA_KEY, metadata, UnionClass);
|
|
9767
|
+
for (const c of clasRefs) {
|
|
9768
|
+
const itemMeta = Reflect.getMetadata(METADATA_KEY, c);
|
|
9769
|
+
if (!(itemMeta && (itemMeta.kind === opra_schema_ns_exports.ComplexType.Kind || itemMeta.kind === opra_schema_ns_exports.UnionType.Kind || itemMeta.kind === opra_schema_ns_exports.MappedType.Kind)))
|
|
9770
|
+
throw new TypeError(`Class "${c.name}" is not a ${opra_schema_ns_exports.ComplexType.Kind}, ${opra_schema_ns_exports.UnionType.Kind} or ${opra_schema_ns_exports.MappedType.Kind}`);
|
|
9771
|
+
metadata.types.push(c);
|
|
9772
|
+
mergePrototype(UnionClass.prototype, c.prototype);
|
|
9773
|
+
}
|
|
9774
|
+
UnionType2._applyMixin(UnionClass, ...clasRefs);
|
|
9775
|
+
return UnionClass;
|
|
9776
|
+
}, "UnionType");
|
|
9777
|
+
UnionType2.prototype = UnionTypeClass.prototype;
|
|
9778
|
+
UnionType2._applyMixin = () => void 0;
|
|
9779
|
+
|
|
9780
|
+
// ../../build/common/esm/document/utils/generate-codec.js
|
|
9781
|
+
function generateCodec(type, codec, options) {
|
|
9782
|
+
return _generateDecoder(type, codec, options);
|
|
9783
|
+
}
|
|
9784
|
+
__name(generateCodec, "generateCodec");
|
|
9785
|
+
function _generateDecoder(type, codec, options) {
|
|
9786
|
+
const schema = {};
|
|
9787
|
+
for (const f of type.fields.values()) {
|
|
9788
|
+
let fn;
|
|
9789
|
+
if (f.type instanceof SimpleType2 || f.type instanceof EnumType2) {
|
|
9790
|
+
fn = f.type[codec];
|
|
9791
|
+
} else if (f.type instanceof ComplexType2 || f.type instanceof MappedType2 || f.type instanceof UnionType2) {
|
|
9792
|
+
fn = _generateDecoder(f.type, codec, options);
|
|
9793
|
+
}
|
|
9794
|
+
if (!fn)
|
|
9795
|
+
throw new TypeError(`Can't generate codec for (${f.type})`);
|
|
9796
|
+
if (f.isArray)
|
|
9797
|
+
fn = vg3.isArray(fn);
|
|
9798
|
+
schema[f.name] = !options.partial && f.required ? vg3.required(fn) : vg3.optional(fn);
|
|
9799
|
+
}
|
|
9800
|
+
return vg3.isObject(schema, {
|
|
9801
|
+
ctor: type.ctor,
|
|
9802
|
+
additionalFields: type.additionalFields ?? "ignore",
|
|
9803
|
+
name: type.name,
|
|
9804
|
+
caseInSensitive: true
|
|
9805
|
+
});
|
|
9806
|
+
}
|
|
9807
|
+
__name(_generateDecoder, "_generateDecoder");
|
|
9808
|
+
|
|
9661
9809
|
// ../../build/common/esm/document/resource/resource.js
|
|
9662
9810
|
var Resource = class {
|
|
9663
9811
|
static {
|
|
@@ -9692,9 +9840,11 @@ var CollectionClass = class extends Resource {
|
|
|
9692
9840
|
}
|
|
9693
9841
|
constructor(document, init) {
|
|
9694
9842
|
super(document, init);
|
|
9843
|
+
this._decoders = {};
|
|
9844
|
+
this._encoders = {};
|
|
9695
9845
|
this.kind = opra_schema_ns_exports.Collection.Kind;
|
|
9696
9846
|
this.controller = init.controller;
|
|
9697
|
-
|
|
9847
|
+
this.operations = { ...init.operations };
|
|
9698
9848
|
const dataType = this.type = init.type;
|
|
9699
9849
|
this.primaryKey = init.primaryKey ? Array.isArray(init.primaryKey) ? init.primaryKey : [init.primaryKey] : [];
|
|
9700
9850
|
if (!this.primaryKey.length)
|
|
@@ -9704,17 +9854,6 @@ var CollectionClass = class extends Resource {
|
|
|
9704
9854
|
if (!(field?.type instanceof SimpleType2))
|
|
9705
9855
|
throw new TypeError(`Only Simple type allowed for primary keys but "${f}" is a ${field.type.kind}`);
|
|
9706
9856
|
});
|
|
9707
|
-
if (this.controller) {
|
|
9708
|
-
const instance = typeof this.controller == "function" ? new this.controller() : this.controller;
|
|
9709
|
-
for (const operation of Object.values(operations)) {
|
|
9710
|
-
if (!operation.handler && operation.handlerName) {
|
|
9711
|
-
const fn = instance[operation.handlerName];
|
|
9712
|
-
if (!fn)
|
|
9713
|
-
throw new TypeError(`No such operation handler (${operation.handlerName}) found`);
|
|
9714
|
-
operation.handler = fn.bind(instance);
|
|
9715
|
-
}
|
|
9716
|
-
}
|
|
9717
|
-
}
|
|
9718
9857
|
}
|
|
9719
9858
|
exportSchema() {
|
|
9720
9859
|
const out = Resource.prototype.exportSchema.call(this);
|
|
@@ -9736,7 +9875,8 @@ var CollectionClass = class extends Resource {
|
|
|
9736
9875
|
}, {}) : value;
|
|
9737
9876
|
for (const [k, v] of Object.entries(obj)) {
|
|
9738
9877
|
const el = dataType.getField(k);
|
|
9739
|
-
|
|
9878
|
+
if (el.type instanceof SimpleType2)
|
|
9879
|
+
obj[k] = el.type.decode(v);
|
|
9740
9880
|
if (obj[k] == null)
|
|
9741
9881
|
throw new TypeError(`You must provide value of primary field(s) (${k})`);
|
|
9742
9882
|
}
|
|
@@ -9745,7 +9885,9 @@ var CollectionClass = class extends Resource {
|
|
|
9745
9885
|
if (typeof value === "object")
|
|
9746
9886
|
value = value[primaryKey];
|
|
9747
9887
|
const el = dataType.getField(primaryKey);
|
|
9748
|
-
|
|
9888
|
+
let result;
|
|
9889
|
+
if (el.type instanceof SimpleType2)
|
|
9890
|
+
result = el.type.decode(value);
|
|
9749
9891
|
if (result == null)
|
|
9750
9892
|
throw new TypeError(`You must provide value of primary field(s) (${primaryKey})`);
|
|
9751
9893
|
return result;
|
|
@@ -9756,12 +9898,14 @@ var CollectionClass = class extends Resource {
|
|
|
9756
9898
|
}
|
|
9757
9899
|
normalizeSortFields(fields) {
|
|
9758
9900
|
const normalized = this.type.normalizeFieldPath(fields);
|
|
9759
|
-
|
|
9760
|
-
|
|
9901
|
+
if (!normalized)
|
|
9902
|
+
return;
|
|
9903
|
+
const findManyOp = this.operations.findMany;
|
|
9904
|
+
const sortFields = findManyOp && findManyOp.sortFields;
|
|
9761
9905
|
(Array.isArray(normalized) ? normalized : [normalized]).forEach((field) => {
|
|
9762
9906
|
if (!sortFields?.find((x) => x === field))
|
|
9763
9907
|
throw new BadRequestError({
|
|
9764
|
-
message: translate("error:UNACCEPTED_SORT_FIELD", { field }
|
|
9908
|
+
message: translate("error:UNACCEPTED_SORT_FIELD", { field })
|
|
9765
9909
|
});
|
|
9766
9910
|
});
|
|
9767
9911
|
return normalized;
|
|
@@ -9774,22 +9918,72 @@ var CollectionClass = class extends Resource {
|
|
|
9774
9918
|
this.normalizeFilter(ast.left);
|
|
9775
9919
|
if (!(ast.left instanceof opra_filter_ns_exports.QualifiedIdentifier && ast.left.field))
|
|
9776
9920
|
throw new TypeError(`Invalid filter query. Left side should be a data field.`);
|
|
9921
|
+
const findManyOp = this.operations.findMany;
|
|
9922
|
+
const fieldLower = ast.left.value.toLowerCase();
|
|
9923
|
+
const filterDef = (findManyOp && findManyOp.filters || []).find((f) => f.field.toLowerCase() === fieldLower);
|
|
9924
|
+
if (!filterDef) {
|
|
9925
|
+
throw new BadRequestError({
|
|
9926
|
+
message: translate("error:UNACCEPTED_FILTER_FIELD", { field: ast.left.value })
|
|
9927
|
+
});
|
|
9928
|
+
}
|
|
9929
|
+
if (!filterDef.operators?.includes(ast.op))
|
|
9930
|
+
throw new BadRequestError({
|
|
9931
|
+
message: translate("error:UNACCEPTED_FILTER_OPERATION", { field: ast.left.value })
|
|
9932
|
+
});
|
|
9777
9933
|
this.normalizeFilter(ast.right);
|
|
9778
|
-
|
|
9934
|
+
return ast;
|
|
9935
|
+
}
|
|
9936
|
+
if (ast instanceof opra_filter_ns_exports.LogicalExpression) {
|
|
9779
9937
|
ast.items.forEach((item) => this.normalizeFilter(item));
|
|
9780
|
-
|
|
9938
|
+
return ast;
|
|
9939
|
+
}
|
|
9940
|
+
if (ast instanceof opra_filter_ns_exports.ArithmeticExpression) {
|
|
9781
9941
|
ast.items.forEach((item) => this.normalizeFilter(item.expression));
|
|
9782
|
-
|
|
9942
|
+
return ast;
|
|
9943
|
+
}
|
|
9944
|
+
if (ast instanceof opra_filter_ns_exports.ArrayExpression) {
|
|
9783
9945
|
ast.items.forEach((item) => this.normalizeFilter(item));
|
|
9784
|
-
|
|
9946
|
+
return ast;
|
|
9947
|
+
}
|
|
9948
|
+
if (ast instanceof opra_filter_ns_exports.ParenthesizedExpression) {
|
|
9785
9949
|
this.normalizeFilter(ast.expression);
|
|
9786
|
-
|
|
9787
|
-
|
|
9950
|
+
return ast;
|
|
9951
|
+
}
|
|
9952
|
+
if (ast instanceof opra_filter_ns_exports.QualifiedIdentifier) {
|
|
9953
|
+
const normalizedFieldPath = this.type.normalizeFieldPath(ast.value)?.join(".");
|
|
9954
|
+
ast.field = this.type.getField(normalizedFieldPath);
|
|
9788
9955
|
ast.dataType = ast.field?.type || this.document.getDataType("any");
|
|
9789
|
-
ast.value =
|
|
9956
|
+
ast.value = normalizedFieldPath;
|
|
9957
|
+
return ast;
|
|
9790
9958
|
}
|
|
9791
9959
|
return ast;
|
|
9792
9960
|
}
|
|
9961
|
+
getDecoder(operation) {
|
|
9962
|
+
let decoder = this._decoders[operation];
|
|
9963
|
+
if (decoder)
|
|
9964
|
+
return decoder;
|
|
9965
|
+
const options = {
|
|
9966
|
+
partial: operation !== "create"
|
|
9967
|
+
};
|
|
9968
|
+
if (operation !== "create")
|
|
9969
|
+
options.omit = [...this.primaryKey];
|
|
9970
|
+
decoder = generateCodec(this.type, "decode", options);
|
|
9971
|
+
this._decoders[operation] = decoder;
|
|
9972
|
+
return decoder;
|
|
9973
|
+
}
|
|
9974
|
+
getEncoder(operation) {
|
|
9975
|
+
let encoder = this._encoders[operation];
|
|
9976
|
+
if (encoder)
|
|
9977
|
+
return encoder;
|
|
9978
|
+
const options = {
|
|
9979
|
+
partial: true
|
|
9980
|
+
};
|
|
9981
|
+
encoder = generateCodec(this.type, "encode", options);
|
|
9982
|
+
if (operation === "findMany")
|
|
9983
|
+
return vg4.isArray(encoder);
|
|
9984
|
+
this._encoders[operation] = encoder;
|
|
9985
|
+
return encoder;
|
|
9986
|
+
}
|
|
9793
9987
|
};
|
|
9794
9988
|
var Collection2 = /* @__PURE__ */ __name(function(...args) {
|
|
9795
9989
|
if (!this) {
|
|
@@ -9799,7 +9993,7 @@ var Collection2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
9799
9993
|
const metadata = Reflect.getOwnMetadata(METADATA_KEY, target) || {};
|
|
9800
9994
|
const baseMetadata = Reflect.getOwnMetadata(METADATA_KEY, Object.getPrototypeOf(target));
|
|
9801
9995
|
if (baseMetadata) {
|
|
9802
|
-
|
|
9996
|
+
merge7(metadata, baseMetadata, { deep: true });
|
|
9803
9997
|
}
|
|
9804
9998
|
metadata.kind = opra_schema_ns_exports.Collection.Kind;
|
|
9805
9999
|
metadata.name = name;
|
|
@@ -9814,18 +10008,17 @@ var Collection2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
9814
10008
|
};
|
|
9815
10009
|
}
|
|
9816
10010
|
const [document, init] = args;
|
|
9817
|
-
|
|
10011
|
+
merge7(this, new CollectionClass(document, init), { descriptor: true });
|
|
9818
10012
|
}, "Collection");
|
|
9819
10013
|
Collection2.prototype = CollectionClass.prototype;
|
|
9820
10014
|
function createOperationDecorator(operation) {
|
|
9821
10015
|
return (options) => (target, propertyKey) => {
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
};
|
|
10016
|
+
if (propertyKey !== operation)
|
|
10017
|
+
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
10018
|
+
const operationMeta = { ...options };
|
|
9826
10019
|
const resourceMetadata = Reflect.getOwnMetadata(METADATA_KEY, target.constructor) || {};
|
|
9827
10020
|
resourceMetadata.operations = resourceMetadata.operations || {};
|
|
9828
|
-
resourceMetadata.operations[operation] =
|
|
10021
|
+
resourceMetadata.operations[operation] = operationMeta;
|
|
9829
10022
|
Reflect.defineMetadata(METADATA_KEY, resourceMetadata, target.constructor);
|
|
9830
10023
|
};
|
|
9831
10024
|
}
|
|
@@ -9840,7 +10033,7 @@ Collection2.UpdateMany = createOperationDecorator("updateMany");
|
|
|
9840
10033
|
|
|
9841
10034
|
// ../../build/common/esm/document/resource/singleton.js
|
|
9842
10035
|
import omit5 from "lodash.omit";
|
|
9843
|
-
import
|
|
10036
|
+
import merge8 from "putil-merge";
|
|
9844
10037
|
var NESTJS_INJECTABLE_WATERMARK2 = "__injectable__";
|
|
9845
10038
|
var NAME_PATTERN2 = /^(.*)(Resource|Singleton)$/;
|
|
9846
10039
|
var SingletonClass = class extends Resource {
|
|
@@ -9849,21 +10042,12 @@ var SingletonClass = class extends Resource {
|
|
|
9849
10042
|
}
|
|
9850
10043
|
constructor(document, init) {
|
|
9851
10044
|
super(document, init);
|
|
10045
|
+
this._decoders = {};
|
|
10046
|
+
this._encoders = {};
|
|
9852
10047
|
this.kind = opra_schema_ns_exports.Singleton.Kind;
|
|
9853
10048
|
this.controller = init.controller;
|
|
9854
|
-
|
|
10049
|
+
this.operations = { ...init.operations };
|
|
9855
10050
|
this.type = init.type;
|
|
9856
|
-
if (this.controller) {
|
|
9857
|
-
const instance = typeof this.controller == "function" ? new this.controller() : this.controller;
|
|
9858
|
-
for (const operation of Object.values(operations)) {
|
|
9859
|
-
if (!operation.handler && operation.handlerName) {
|
|
9860
|
-
const fn = instance[operation.handlerName];
|
|
9861
|
-
if (!fn)
|
|
9862
|
-
throw new TypeError(`No such operation handler (${operation.handlerName}) found`);
|
|
9863
|
-
operation.handler = fn.bind(instance);
|
|
9864
|
-
}
|
|
9865
|
-
}
|
|
9866
|
-
}
|
|
9867
10051
|
}
|
|
9868
10052
|
exportSchema() {
|
|
9869
10053
|
const out = Resource.prototype.exportSchema.call(this);
|
|
@@ -9876,6 +10060,28 @@ var SingletonClass = class extends Resource {
|
|
|
9876
10060
|
normalizeFieldPath(path2) {
|
|
9877
10061
|
return this.type.normalizeFieldPath(path2);
|
|
9878
10062
|
}
|
|
10063
|
+
getDecoder(operation) {
|
|
10064
|
+
let decoder = this._decoders[operation];
|
|
10065
|
+
if (decoder)
|
|
10066
|
+
return decoder;
|
|
10067
|
+
const options = {
|
|
10068
|
+
partial: operation !== "create"
|
|
10069
|
+
};
|
|
10070
|
+
decoder = generateCodec(this.type, "decode", options);
|
|
10071
|
+
this._decoders[operation] = decoder;
|
|
10072
|
+
return decoder;
|
|
10073
|
+
}
|
|
10074
|
+
getEncoder(operation) {
|
|
10075
|
+
let encoder = this._encoders[operation];
|
|
10076
|
+
if (encoder)
|
|
10077
|
+
return encoder;
|
|
10078
|
+
const options = {
|
|
10079
|
+
partial: true
|
|
10080
|
+
};
|
|
10081
|
+
encoder = generateCodec(this.type, "encode", options);
|
|
10082
|
+
this._encoders[operation] = encoder;
|
|
10083
|
+
return encoder;
|
|
10084
|
+
}
|
|
9879
10085
|
};
|
|
9880
10086
|
var Singleton2 = /* @__PURE__ */ __name(function(...args) {
|
|
9881
10087
|
if (!this) {
|
|
@@ -9896,18 +10102,17 @@ var Singleton2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
9896
10102
|
};
|
|
9897
10103
|
}
|
|
9898
10104
|
const [document, init] = args;
|
|
9899
|
-
|
|
10105
|
+
merge8(this, new SingletonClass(document, init), { descriptor: true });
|
|
9900
10106
|
}, "Singleton");
|
|
9901
10107
|
Singleton2.prototype = SingletonClass.prototype;
|
|
9902
10108
|
function createOperationDecorator2(operation) {
|
|
9903
10109
|
return (options) => (target, propertyKey) => {
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
};
|
|
10110
|
+
if (propertyKey !== operation)
|
|
10111
|
+
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
10112
|
+
const operationMeta = { ...options };
|
|
9908
10113
|
const resourceMetadata = Reflect.getOwnMetadata(METADATA_KEY, target.constructor) || {};
|
|
9909
10114
|
resourceMetadata.operations = resourceMetadata.operations || {};
|
|
9910
|
-
resourceMetadata.operations[operation] =
|
|
10115
|
+
resourceMetadata.operations[operation] = operationMeta;
|
|
9911
10116
|
Reflect.defineMetadata(METADATA_KEY, resourceMetadata, target.constructor);
|
|
9912
10117
|
};
|
|
9913
10118
|
}
|
|
@@ -9919,7 +10124,7 @@ Singleton2.Update = createOperationDecorator2("update");
|
|
|
9919
10124
|
|
|
9920
10125
|
// ../../build/common/esm/document/resource/storage.js
|
|
9921
10126
|
import omit6 from "lodash.omit";
|
|
9922
|
-
import
|
|
10127
|
+
import merge9 from "putil-merge";
|
|
9923
10128
|
var NESTJS_INJECTABLE_WATERMARK3 = "__injectable__";
|
|
9924
10129
|
var NAME_PATTERN3 = /^(.*)(Resource)$/;
|
|
9925
10130
|
var StorageClass = class extends Resource {
|
|
@@ -9930,18 +10135,7 @@ var StorageClass = class extends Resource {
|
|
|
9930
10135
|
super(document, init);
|
|
9931
10136
|
this.kind = opra_schema_ns_exports.Storage.Kind;
|
|
9932
10137
|
this.controller = init.controller;
|
|
9933
|
-
|
|
9934
|
-
if (this.controller) {
|
|
9935
|
-
const instance = typeof this.controller == "function" ? new this.controller() : this.controller;
|
|
9936
|
-
for (const operation of Object.values(operations)) {
|
|
9937
|
-
if (!operation.handler && operation.handlerName) {
|
|
9938
|
-
const fn = instance[operation.handlerName];
|
|
9939
|
-
if (!fn)
|
|
9940
|
-
throw new TypeError(`No such operation handler (${operation.handlerName}) found`);
|
|
9941
|
-
operation.handler = fn.bind(instance);
|
|
9942
|
-
}
|
|
9943
|
-
}
|
|
9944
|
-
}
|
|
10138
|
+
this.operations = { ...init.operations };
|
|
9945
10139
|
}
|
|
9946
10140
|
exportSchema() {
|
|
9947
10141
|
const out = Resource.prototype.exportSchema.call(this);
|
|
@@ -9969,25 +10163,24 @@ var Storage2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
9969
10163
|
};
|
|
9970
10164
|
}
|
|
9971
10165
|
const [document, init] = args;
|
|
9972
|
-
|
|
10166
|
+
merge9(this, new StorageClass(document, init), { descriptor: true });
|
|
9973
10167
|
}, "Storage");
|
|
9974
10168
|
Storage2.prototype = StorageClass.prototype;
|
|
9975
10169
|
function createOperationDecorator3(operation) {
|
|
9976
10170
|
return (options) => (target, propertyKey) => {
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
};
|
|
10171
|
+
if (propertyKey !== operation)
|
|
10172
|
+
throw new TypeError(`Name of the handler name should be '${operation}'`);
|
|
10173
|
+
const operationMeta = { ...options };
|
|
9981
10174
|
const resourceMetadata = Reflect.getOwnMetadata(METADATA_KEY, target.constructor) || {};
|
|
9982
10175
|
resourceMetadata.operations = resourceMetadata.operations || {};
|
|
9983
|
-
resourceMetadata.operations[operation] =
|
|
10176
|
+
resourceMetadata.operations[operation] = operationMeta;
|
|
9984
10177
|
Reflect.defineMetadata(METADATA_KEY, resourceMetadata, target.constructor);
|
|
9985
10178
|
};
|
|
9986
10179
|
}
|
|
9987
10180
|
__name(createOperationDecorator3, "createOperationDecorator");
|
|
9988
10181
|
Storage2.Delete = createOperationDecorator3("delete");
|
|
9989
10182
|
Storage2.Get = createOperationDecorator3("get");
|
|
9990
|
-
Storage2.
|
|
10183
|
+
Storage2.Post = createOperationDecorator3("post");
|
|
9991
10184
|
|
|
9992
10185
|
// ../../build/common/esm/document/factory/process-resources.js
|
|
9993
10186
|
async function processResourceQueue() {
|
|
@@ -10053,248 +10246,12 @@ async function createFileResource(name, schema) {
|
|
|
10053
10246
|
}
|
|
10054
10247
|
__name(createFileResource, "createFileResource");
|
|
10055
10248
|
|
|
10056
|
-
// ../../build/common/esm/document/
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
__name(this, "MappedTypeClass");
|
|
10063
|
-
}
|
|
10064
|
-
constructor(document, init) {
|
|
10065
|
-
super(document, init);
|
|
10066
|
-
this.kind = opra_schema_ns_exports.MappedType.Kind;
|
|
10067
|
-
const own = this.own;
|
|
10068
|
-
own.pick = init.pick;
|
|
10069
|
-
own.omit = init.omit;
|
|
10070
|
-
this.kind = opra_schema_ns_exports.MappedType.Kind;
|
|
10071
|
-
this.type = init.type;
|
|
10072
|
-
this.pick = own.pick;
|
|
10073
|
-
this.omit = own.omit;
|
|
10074
|
-
this.fields = new ResponsiveMap();
|
|
10075
|
-
this.additionalFields = this.type.additionalFields;
|
|
10076
|
-
const isInheritedPredicate = getIsInheritedPredicateFn(init.pick, init.omit);
|
|
10077
|
-
for (const [elemName, elem] of this.type.fields.entries()) {
|
|
10078
|
-
if (isInheritedPredicate(elemName))
|
|
10079
|
-
this.fields.set(elemName, elem);
|
|
10080
|
-
}
|
|
10081
|
-
}
|
|
10082
|
-
exportSchema() {
|
|
10083
|
-
const out = DataType.prototype.exportSchema.call(this);
|
|
10084
|
-
Object.assign(out, omitUndefined({
|
|
10085
|
-
type: this.type.name ? this.type.name : this.type.exportSchema(),
|
|
10086
|
-
pick: this.own.pick,
|
|
10087
|
-
omit: this.own.omit
|
|
10088
|
-
}));
|
|
10089
|
-
return out;
|
|
10090
|
-
}
|
|
10091
|
-
_getDecoder() {
|
|
10092
|
-
if (this._decoder)
|
|
10093
|
-
return this._decoder;
|
|
10094
|
-
const schema = {};
|
|
10095
|
-
for (const f of this.fields.values()) {
|
|
10096
|
-
let t = f.type.getDecoder();
|
|
10097
|
-
if (f.isArray)
|
|
10098
|
-
t = vg4.isArray(t);
|
|
10099
|
-
schema[f.name] = t;
|
|
10100
|
-
}
|
|
10101
|
-
this._decoder = vg4.isObject(schema, {
|
|
10102
|
-
additionalFields: this.additionalFields,
|
|
10103
|
-
name: this.name,
|
|
10104
|
-
caseInSensitive: true
|
|
10105
|
-
});
|
|
10106
|
-
return this._decoder;
|
|
10107
|
-
}
|
|
10108
|
-
_getEncoder() {
|
|
10109
|
-
if (this._encoder)
|
|
10110
|
-
return this._encoder;
|
|
10111
|
-
const schema = {};
|
|
10112
|
-
for (const f of this.fields.values()) {
|
|
10113
|
-
let t = f.type.getEncoder();
|
|
10114
|
-
if (f.isArray)
|
|
10115
|
-
t = vg4.isArray(t);
|
|
10116
|
-
schema[f.name] = t;
|
|
10117
|
-
}
|
|
10118
|
-
this._encoder = vg4.isObject(schema, {
|
|
10119
|
-
additionalFields: this.additionalFields,
|
|
10120
|
-
name: this.name,
|
|
10121
|
-
caseInSensitive: true,
|
|
10122
|
-
detectCircular: true
|
|
10123
|
-
});
|
|
10124
|
-
return this._encoder;
|
|
10125
|
-
}
|
|
10126
|
-
};
|
|
10127
|
-
var MappedType2 = /* @__PURE__ */ __name(function(...args) {
|
|
10128
|
-
if (this) {
|
|
10129
|
-
const [document, init] = args;
|
|
10130
|
-
merge8(this, new MappedTypeClass(document, init), { descriptor: true });
|
|
10131
|
-
return;
|
|
10132
|
-
}
|
|
10133
|
-
const [source, options] = args;
|
|
10134
|
-
const isInheritedPredicate = getIsInheritedPredicateFn(options.pick, options.omit);
|
|
10135
|
-
class MappedClass {
|
|
10136
|
-
static {
|
|
10137
|
-
__name(this, "MappedClass");
|
|
10138
|
-
}
|
|
10139
|
-
constructor() {
|
|
10140
|
-
inheritPropertyInitializers(this, source, isInheritedPredicate);
|
|
10141
|
-
}
|
|
10142
|
-
}
|
|
10143
|
-
mergePrototype(MappedClass.prototype, source.prototype);
|
|
10144
|
-
const m = Reflect.getOwnMetadata(METADATA_KEY, source);
|
|
10145
|
-
if (!m)
|
|
10146
|
-
throw new TypeError(`Class "${source}" doesn't have datatype metadata information`);
|
|
10147
|
-
if (!(m.kind === opra_schema_ns_exports.ComplexType.Kind))
|
|
10148
|
-
throw new TypeError(`Class "${source}" is not a ${opra_schema_ns_exports.ComplexType.Kind}`);
|
|
10149
|
-
const metadata = {
|
|
10150
|
-
kind: "MappedType",
|
|
10151
|
-
type: source
|
|
10152
|
-
};
|
|
10153
|
-
if (options.pick)
|
|
10154
|
-
metadata.pick = options.pick;
|
|
10155
|
-
if (options.omit)
|
|
10156
|
-
metadata.omit = options.omit;
|
|
10157
|
-
Reflect.defineMetadata(METADATA_KEY, metadata, MappedClass);
|
|
10158
|
-
MappedType2._applyMixin(MappedClass, source, {
|
|
10159
|
-
...options,
|
|
10160
|
-
isInheritedPredicate
|
|
10161
|
-
});
|
|
10162
|
-
return MappedClass;
|
|
10163
|
-
}, "MappedType");
|
|
10164
|
-
MappedType2.prototype = MappedTypeClass.prototype;
|
|
10165
|
-
MappedType2._applyMixin = () => void 0;
|
|
10166
|
-
function getIsInheritedPredicateFn(pick, omit7) {
|
|
10167
|
-
const pickKeys = pick?.map((x) => String(x).toLowerCase());
|
|
10168
|
-
const omitKeys = omit7?.map((x) => String(x).toLowerCase());
|
|
10169
|
-
return (propertyName) => {
|
|
10170
|
-
if (omitKeys && omitKeys.includes(propertyName.toLowerCase()))
|
|
10171
|
-
return false;
|
|
10172
|
-
if (pickKeys)
|
|
10173
|
-
return pickKeys.includes(propertyName.toLowerCase());
|
|
10174
|
-
return true;
|
|
10175
|
-
};
|
|
10176
|
-
}
|
|
10177
|
-
__name(getIsInheritedPredicateFn, "getIsInheritedPredicateFn");
|
|
10178
|
-
function PickType(classRef, keys) {
|
|
10179
|
-
return MappedType2(classRef, { pick: keys });
|
|
10180
|
-
}
|
|
10181
|
-
__name(PickType, "PickType");
|
|
10182
|
-
function OmitType(classRef, keys) {
|
|
10183
|
-
return MappedType2(classRef, { omit: keys });
|
|
10184
|
-
}
|
|
10185
|
-
__name(OmitType, "OmitType");
|
|
10186
|
-
|
|
10187
|
-
// ../../build/common/esm/document/data-type/union-type.js
|
|
10188
|
-
import "reflect-metadata";
|
|
10189
|
-
import merge9 from "putil-merge";
|
|
10190
|
-
import * as vg5 from "valgen";
|
|
10191
|
-
var UnionTypeClass = class extends DataType {
|
|
10192
|
-
static {
|
|
10193
|
-
__name(this, "UnionTypeClass");
|
|
10194
|
-
}
|
|
10195
|
-
constructor(document, init) {
|
|
10196
|
-
super(document, init);
|
|
10197
|
-
this.kind = opra_schema_ns_exports.UnionType.Kind;
|
|
10198
|
-
this.fields = new ResponsiveMap();
|
|
10199
|
-
const own = this.own;
|
|
10200
|
-
own.types = [];
|
|
10201
|
-
for (const base of init.types) {
|
|
10202
|
-
if (!(base instanceof ComplexType2 || base instanceof UnionType2 || base instanceof MappedType2))
|
|
10203
|
-
throw new TypeError(`${opra_schema_ns_exports.UnionType.Kind} shall contain ${opra_schema_ns_exports.ComplexType.Kind}, ${opra_schema_ns_exports.UnionType.Kind} of ${opra_schema_ns_exports.MappedType.Kind} types.`);
|
|
10204
|
-
own.types.push(base);
|
|
10205
|
-
if (base.additionalFields)
|
|
10206
|
-
this.additionalFields = true;
|
|
10207
|
-
this.fields.setAll(base.fields);
|
|
10208
|
-
}
|
|
10209
|
-
this.types = [...own.types];
|
|
10210
|
-
}
|
|
10211
|
-
exportSchema() {
|
|
10212
|
-
const out = super.exportSchema();
|
|
10213
|
-
Object.assign(out, omitUndefined({
|
|
10214
|
-
types: this.own.types.map((t) => t.name ? t.name : t.exportSchema())
|
|
10215
|
-
}));
|
|
10216
|
-
return out;
|
|
10217
|
-
}
|
|
10218
|
-
_getDecoder() {
|
|
10219
|
-
if (this._decoder)
|
|
10220
|
-
return this._decoder;
|
|
10221
|
-
const schema = {};
|
|
10222
|
-
for (const f of this.fields.values()) {
|
|
10223
|
-
let t = f.type.getDecoder();
|
|
10224
|
-
if (f.isArray)
|
|
10225
|
-
t = vg5.isArray(t);
|
|
10226
|
-
schema[f.name] = t;
|
|
10227
|
-
}
|
|
10228
|
-
this._decoder = vg5.isObject(schema, {
|
|
10229
|
-
additionalFields: this.additionalFields,
|
|
10230
|
-
name: this.name,
|
|
10231
|
-
caseInSensitive: true
|
|
10232
|
-
});
|
|
10233
|
-
return this._decoder;
|
|
10234
|
-
}
|
|
10235
|
-
_getEncoder() {
|
|
10236
|
-
if (this._encoder)
|
|
10237
|
-
return this._encoder;
|
|
10238
|
-
const schema = {};
|
|
10239
|
-
for (const f of this.fields.values()) {
|
|
10240
|
-
let t = f.type.getEncoder();
|
|
10241
|
-
if (f.isArray)
|
|
10242
|
-
t = vg5.isArray(t);
|
|
10243
|
-
schema[f.name] = t;
|
|
10244
|
-
}
|
|
10245
|
-
this._encoder = vg5.isObject(schema, {
|
|
10246
|
-
additionalFields: this.additionalFields,
|
|
10247
|
-
name: this.name,
|
|
10248
|
-
caseInSensitive: true,
|
|
10249
|
-
detectCircular: true
|
|
10250
|
-
});
|
|
10251
|
-
return this._encoder;
|
|
10252
|
-
}
|
|
10253
|
-
};
|
|
10254
|
-
var UnionType2 = /* @__PURE__ */ __name(function(...args) {
|
|
10255
|
-
if (this) {
|
|
10256
|
-
const [document, init] = args;
|
|
10257
|
-
merge9(this, new UnionTypeClass(document, init), { descriptor: true });
|
|
10258
|
-
return;
|
|
10259
|
-
}
|
|
10260
|
-
const clasRefs = [...args].filter((x) => !!x);
|
|
10261
|
-
if (!clasRefs.length)
|
|
10262
|
-
throw new TypeError("No Class has been provided");
|
|
10263
|
-
if (clasRefs.length === 1)
|
|
10264
|
-
return clasRefs[0];
|
|
10265
|
-
class UnionClass {
|
|
10266
|
-
static {
|
|
10267
|
-
__name(this, "UnionClass");
|
|
10268
|
-
}
|
|
10269
|
-
constructor() {
|
|
10270
|
-
for (const c of clasRefs)
|
|
10271
|
-
inheritPropertyInitializers(this, c);
|
|
10272
|
-
}
|
|
10273
|
-
}
|
|
10274
|
-
const metadata = {
|
|
10275
|
-
kind: opra_schema_ns_exports.UnionType.Kind,
|
|
10276
|
-
types: []
|
|
10277
|
-
};
|
|
10278
|
-
Reflect.defineMetadata(METADATA_KEY, metadata, UnionClass);
|
|
10279
|
-
for (const c of clasRefs) {
|
|
10280
|
-
const itemMeta = Reflect.getMetadata(METADATA_KEY, c);
|
|
10281
|
-
if (!(itemMeta && (itemMeta.kind === opra_schema_ns_exports.ComplexType.Kind || itemMeta.kind === opra_schema_ns_exports.UnionType.Kind || itemMeta.kind === opra_schema_ns_exports.MappedType.Kind)))
|
|
10282
|
-
throw new TypeError(`Class "${c.name}" is not a ${opra_schema_ns_exports.ComplexType.Kind}, ${opra_schema_ns_exports.UnionType.Kind} or ${opra_schema_ns_exports.MappedType.Kind}`);
|
|
10283
|
-
metadata.types.push(c);
|
|
10284
|
-
mergePrototype(UnionClass.prototype, c.prototype);
|
|
10285
|
-
}
|
|
10286
|
-
UnionType2._applyMixin(UnionClass, ...clasRefs);
|
|
10287
|
-
return UnionClass;
|
|
10288
|
-
}, "UnionType");
|
|
10289
|
-
UnionType2.prototype = UnionTypeClass.prototype;
|
|
10290
|
-
UnionType2._applyMixin = () => void 0;
|
|
10291
|
-
|
|
10292
|
-
// ../../build/common/esm/document/factory/process-types.js
|
|
10293
|
-
async function processTypes() {
|
|
10294
|
-
const { document, typeQueue } = this;
|
|
10295
|
-
for (const [name, schema] of typeQueue.entries()) {
|
|
10296
|
-
const dataType = this.createDataTypeInstance(schema.kind, name);
|
|
10297
|
-
document.types.set(name, dataType);
|
|
10249
|
+
// ../../build/common/esm/document/factory/process-types.js
|
|
10250
|
+
async function processTypes() {
|
|
10251
|
+
const { document, typeQueue } = this;
|
|
10252
|
+
for (const [name, schema] of typeQueue.entries()) {
|
|
10253
|
+
const dataType = this.createDataTypeInstance(schema.kind, name);
|
|
10254
|
+
document.types.set(name, dataType);
|
|
10298
10255
|
}
|
|
10299
10256
|
const typeNames = Array.from(typeQueue.keys());
|
|
10300
10257
|
for (const name of typeNames) {
|
|
@@ -10514,497 +10471,491 @@ DocumentFactory.designTypeMap = /* @__PURE__ */ new Map();
|
|
|
10514
10471
|
_a2.prototype.createFileResource = createFileResource;
|
|
10515
10472
|
})();
|
|
10516
10473
|
|
|
10517
|
-
// ../../build/common/esm/http/
|
|
10518
|
-
import { splitString as
|
|
10474
|
+
// ../../build/common/esm/http/opra-url.js
|
|
10475
|
+
import { splitString as splitString3, tokenize as tokenize3 } from "fast-tokenizer";
|
|
10519
10476
|
|
|
10520
|
-
// ../../build/common/esm/http/
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
var
|
|
10477
|
+
// ../../build/common/esm/http/opra-url-path.js
|
|
10478
|
+
import { splitString as splitString2, tokenize as tokenize2 } from "fast-tokenizer";
|
|
10479
|
+
import isPlainObject2 from "putil-isplainobject";
|
|
10480
|
+
var _a3;
|
|
10481
|
+
var nodeInspectCustom2 = Symbol.for("nodejs.util.inspect.custom");
|
|
10482
|
+
var kLength = Symbol.for("kLength");
|
|
10483
|
+
var pathComponentRegEx = /^([^/?#:@]+)(?:@([^/?#:]*))?(?:::(.*))?$/;
|
|
10484
|
+
var decimalPattern = /^[+-]?\d+(\.\d+)?$/;
|
|
10485
|
+
var booleanPattern = /^true|false$/;
|
|
10486
|
+
var OpraURLPath = class _OpraURLPath {
|
|
10524
10487
|
static {
|
|
10525
|
-
__name(this, "
|
|
10526
|
-
}
|
|
10527
|
-
decode(value) {
|
|
10528
|
-
if (value === "")
|
|
10529
|
-
return true;
|
|
10530
|
-
if (typeof value === "boolean")
|
|
10531
|
-
return value;
|
|
10532
|
-
if (trueValues.includes(value.toLowerCase()))
|
|
10533
|
-
return true;
|
|
10534
|
-
if (falseValues.includes(value.toLowerCase()))
|
|
10535
|
-
return false;
|
|
10536
|
-
throw new TypeError(`"${value}" is not a valid boolean`);
|
|
10537
|
-
}
|
|
10538
|
-
encode(value) {
|
|
10539
|
-
return typeof value === "boolean" ? value ? "true" : "false" : "";
|
|
10488
|
+
__name(this, "OpraURLPath");
|
|
10540
10489
|
}
|
|
10541
|
-
|
|
10542
|
-
|
|
10543
|
-
|
|
10544
|
-
var 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])?))?)?$/;
|
|
10545
|
-
var DateCodec = class {
|
|
10546
|
-
static {
|
|
10547
|
-
__name(this, "DateCodec");
|
|
10490
|
+
constructor(...init) {
|
|
10491
|
+
this[_a3] = 0;
|
|
10492
|
+
this._resolve(init.filter((x) => x));
|
|
10548
10493
|
}
|
|
10549
|
-
|
|
10550
|
-
this
|
|
10551
|
-
this.min = options?.min ? coerceToDateString(options.min) : void 0;
|
|
10552
|
-
this.time = options?.time ?? true;
|
|
10553
|
-
this.timeZone = options?.timeZone ?? true;
|
|
10554
|
-
}
|
|
10555
|
-
decode(value) {
|
|
10556
|
-
const v = coerceToDateString(value, this.time, this.timeZone);
|
|
10557
|
-
if (this.min != null && v < this.min)
|
|
10558
|
-
throw new TypeError(`Value must be ${this.min} or greater.`);
|
|
10559
|
-
if (this.max != null && v > this.max)
|
|
10560
|
-
throw new TypeError(`Value must be ${this.max} or less.`);
|
|
10561
|
-
return v;
|
|
10494
|
+
get length() {
|
|
10495
|
+
return this[kLength];
|
|
10562
10496
|
}
|
|
10563
|
-
|
|
10564
|
-
|
|
10497
|
+
resolve(...items) {
|
|
10498
|
+
this._resolve(items);
|
|
10499
|
+
return this;
|
|
10565
10500
|
}
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
return "";
|
|
10570
|
-
const m = value.match(DATE_FORMAT_PATTERN);
|
|
10571
|
-
if (!m)
|
|
10572
|
-
throw new TypeError(`"${value}" is not a valid date.`);
|
|
10573
|
-
let v = m[1] + "-" + (m[2] || "01") + "-" + (m[3] || "01");
|
|
10574
|
-
if (time) {
|
|
10575
|
-
v += "T" + (m[4] || "00") + ":" + (m[5] || "00") + ":" + (m[6] || "00") + (m[7] ? "." + m[7] : "");
|
|
10576
|
-
if (timeZone)
|
|
10577
|
-
v += m[8] ? "Z" : m[9] ? m[9] + (m[10] || "00") + ":" + (m[11] || "00") : "";
|
|
10578
|
-
}
|
|
10579
|
-
return v;
|
|
10580
|
-
}
|
|
10581
|
-
__name(coerceToDateString, "coerceToDateString");
|
|
10582
|
-
|
|
10583
|
-
// ../../build/common/esm/http/codecs/filter-codec.js
|
|
10584
|
-
var FilterCodec = class {
|
|
10585
|
-
static {
|
|
10586
|
-
__name(this, "FilterCodec");
|
|
10501
|
+
join(...items) {
|
|
10502
|
+
this._resolve(items, true);
|
|
10503
|
+
return this;
|
|
10587
10504
|
}
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
|
|
10505
|
+
isRelativeTo(basePath) {
|
|
10506
|
+
basePath = basePath instanceof _OpraURLPath ? basePath : new _OpraURLPath(basePath);
|
|
10507
|
+
let i;
|
|
10508
|
+
for (i = 0; i < basePath.length; i++) {
|
|
10509
|
+
if (String(this[i]) !== String(basePath[i]))
|
|
10510
|
+
return false;
|
|
10511
|
+
}
|
|
10512
|
+
return true;
|
|
10592
10513
|
}
|
|
10593
|
-
|
|
10594
|
-
|
|
10514
|
+
forEach(callback) {
|
|
10515
|
+
let i = 0;
|
|
10516
|
+
for (const item of this.values()) {
|
|
10517
|
+
callback.call(this, item, i++, this);
|
|
10518
|
+
}
|
|
10595
10519
|
}
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
__name(this, "NumberCodec");
|
|
10520
|
+
values() {
|
|
10521
|
+
const arr = new Array(this.length);
|
|
10522
|
+
for (let i = 0; i < this.length; i++)
|
|
10523
|
+
arr[i] = this[i];
|
|
10524
|
+
return arr.values();
|
|
10602
10525
|
}
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
}
|
|
10607
|
-
decode(value) {
|
|
10608
|
-
const v = typeof value === "number" ? value : parseFloat(value);
|
|
10609
|
-
if (isNaN(v))
|
|
10610
|
-
throw new TypeError(`"${value}" is not a valid number`);
|
|
10611
|
-
if (this.min != null && v < this.min)
|
|
10612
|
-
throw new TypeError(`Value must be ${this.min} or greater.`);
|
|
10613
|
-
if (this.max != null && v > this.max)
|
|
10614
|
-
throw new TypeError(`Value must be ${this.max} or less.`);
|
|
10615
|
-
return v;
|
|
10526
|
+
toString() {
|
|
10527
|
+
const v = Array.from(this).join("/");
|
|
10528
|
+
return v ? "/" + v : "";
|
|
10616
10529
|
}
|
|
10617
|
-
|
|
10618
|
-
|
|
10530
|
+
/* istanbul ignore next */
|
|
10531
|
+
[(_a3 = kLength, nodeInspectCustom2)]() {
|
|
10532
|
+
return `(UrlPath [${this.toString()}])`;
|
|
10619
10533
|
}
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10534
|
+
[Symbol.iterator]() {
|
|
10535
|
+
return this.values();
|
|
10536
|
+
}
|
|
10537
|
+
_resolve(items, join) {
|
|
10538
|
+
let paths = (Array.isArray(items) ? items : [items]).map((item) => {
|
|
10539
|
+
if (typeof item === "object" && !(item instanceof _OpraURLPath || item instanceof OpraURLPathComponent))
|
|
10540
|
+
item = new OpraURLPathComponent(item);
|
|
10541
|
+
item = String(item);
|
|
10542
|
+
if (item.includes("?"))
|
|
10543
|
+
item = splitString2(item, {
|
|
10544
|
+
delimiters: "?",
|
|
10545
|
+
quotes: true,
|
|
10546
|
+
brackets: true,
|
|
10547
|
+
keepBrackets: true,
|
|
10548
|
+
keepQuotes: true
|
|
10549
|
+
})[0];
|
|
10550
|
+
if (item.includes("#"))
|
|
10551
|
+
item = splitString2(item, {
|
|
10552
|
+
delimiters: "#",
|
|
10553
|
+
quotes: true,
|
|
10554
|
+
brackets: true,
|
|
10555
|
+
keepBrackets: true,
|
|
10556
|
+
keepQuotes: true
|
|
10557
|
+
})[0];
|
|
10558
|
+
return join ? removeLeadingSeparator(item) : item;
|
|
10559
|
+
});
|
|
10560
|
+
const oldLength = this.length;
|
|
10561
|
+
let n = 0;
|
|
10562
|
+
if (!join) {
|
|
10563
|
+
for (n = paths.length - 1; n >= 0; n--) {
|
|
10564
|
+
if (String(items[n]).startsWith("/"))
|
|
10565
|
+
break;
|
|
10566
|
+
}
|
|
10567
|
+
if (n > 0)
|
|
10568
|
+
paths = paths.slice(n);
|
|
10569
|
+
}
|
|
10570
|
+
const newPath = paths[0]?.startsWith("/") ? [] : Array.from(this).map(String);
|
|
10571
|
+
for (let i = 0; i < paths.length; i++) {
|
|
10572
|
+
const pathTokenizer = tokenize2(paths[i], { delimiters: "/", quotes: true, brackets: true });
|
|
10573
|
+
for (const x of pathTokenizer) {
|
|
10574
|
+
if (!x)
|
|
10575
|
+
continue;
|
|
10576
|
+
if (x.startsWith(".")) {
|
|
10577
|
+
if (x === ".")
|
|
10578
|
+
continue;
|
|
10579
|
+
if (x === "..") {
|
|
10580
|
+
newPath.pop();
|
|
10581
|
+
continue;
|
|
10582
|
+
}
|
|
10583
|
+
throw new TypeError("Invalid path string");
|
|
10584
|
+
}
|
|
10585
|
+
newPath.push(x);
|
|
10586
|
+
}
|
|
10587
|
+
}
|
|
10588
|
+
for (let i = 0; i < newPath.length; i++) {
|
|
10589
|
+
this[i] = OpraURLPathComponent.parse(newPath[i]);
|
|
10590
|
+
}
|
|
10591
|
+
for (let i = newPath.length; i < oldLength; i++) {
|
|
10592
|
+
delete this[i];
|
|
10593
|
+
}
|
|
10594
|
+
this[kLength] = newPath.length;
|
|
10626
10595
|
}
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
decode(value) {
|
|
10632
|
-
const v = super.decode(value);
|
|
10633
|
-
if (!Number.isInteger(v))
|
|
10634
|
-
throw new TypeError(`"${value}" is not a valid integer`);
|
|
10635
|
-
if (this.enum && !this.enum.includes(v))
|
|
10636
|
-
throw new TypeError(`"${value}" is not one of allowed enum values (${this.enum}).`);
|
|
10637
|
-
return v;
|
|
10596
|
+
static join(...items) {
|
|
10597
|
+
const instance = new _OpraURLPath();
|
|
10598
|
+
instance.join(...items);
|
|
10599
|
+
return instance;
|
|
10638
10600
|
}
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
// ../../build/common/esm/http/codecs/string-codec.js
|
|
10642
|
-
var StringCodec = class {
|
|
10643
|
-
static {
|
|
10644
|
-
__name(this, "StringCodec");
|
|
10601
|
+
static resolve(...items) {
|
|
10602
|
+
return new _OpraURLPath(...items);
|
|
10645
10603
|
}
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
throw new TypeError(`Value can be up to ${this.maxLength} character${this.maxLength > 1 ? "s" : ""} long.`);
|
|
10656
|
-
if (this.enum && !this.enum.includes(value))
|
|
10657
|
-
throw new TypeError(`"${value}" is not one of allowed enum values (${this.enum}).`);
|
|
10658
|
-
return value;
|
|
10659
|
-
}
|
|
10660
|
-
encode(value) {
|
|
10661
|
-
return value == null ? "" : "" + value;
|
|
10604
|
+
static relative(source, basePath) {
|
|
10605
|
+
source = source instanceof _OpraURLPath ? source : new _OpraURLPath(source);
|
|
10606
|
+
basePath = basePath instanceof _OpraURLPath ? basePath : new _OpraURLPath(basePath);
|
|
10607
|
+
let i;
|
|
10608
|
+
for (i = 0; i < basePath.length; i++) {
|
|
10609
|
+
if (String(source[i]) !== String(basePath[i]))
|
|
10610
|
+
return;
|
|
10611
|
+
}
|
|
10612
|
+
return new _OpraURLPath(Array.from(source).slice(i).join("/"));
|
|
10662
10613
|
}
|
|
10663
10614
|
};
|
|
10664
|
-
|
|
10665
|
-
// ../../build/common/esm/http/http-params.js
|
|
10666
|
-
var _a3;
|
|
10667
|
-
var _b2;
|
|
10668
|
-
var _c2;
|
|
10669
|
-
var kEntries = Symbol("kEntries");
|
|
10670
|
-
var kSize = Symbol("kSize");
|
|
10671
|
-
var kParamDefs = Symbol("kParamDefs");
|
|
10672
|
-
var kOptions2 = Symbol("kOptions");
|
|
10673
|
-
var HttpParams = class _HttpParams {
|
|
10615
|
+
var OpraURLPathComponent = class _OpraURLPathComponent {
|
|
10674
10616
|
static {
|
|
10675
|
-
__name(this, "
|
|
10676
|
-
}
|
|
10677
|
-
constructor(init, options) {
|
|
10678
|
-
this[_a3] = new ResponsiveMap();
|
|
10679
|
-
this[_b2] = 0;
|
|
10680
|
-
this[_c2] = /* @__PURE__ */ new Map();
|
|
10681
|
-
this[kOptions2] = { ...options, onChange: void 0 };
|
|
10682
|
-
const defineParams = options?.params;
|
|
10683
|
-
if (defineParams)
|
|
10684
|
-
Object.keys(defineParams).forEach((key) => this.define(key, defineParams[key]));
|
|
10685
|
-
if (init)
|
|
10686
|
-
this.appendAll(init);
|
|
10687
|
-
this[kOptions2].onChange = options?.onChange;
|
|
10688
|
-
}
|
|
10689
|
-
get size() {
|
|
10690
|
-
return this[kSize];
|
|
10617
|
+
__name(this, "OpraURLPathComponent");
|
|
10691
10618
|
}
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
this._append(name, value);
|
|
10698
|
-
this.changed();
|
|
10699
|
-
return this;
|
|
10619
|
+
constructor(init) {
|
|
10620
|
+
this.resource = init.resource;
|
|
10621
|
+
this.key = init.key;
|
|
10622
|
+
this.args = init.args;
|
|
10623
|
+
this.typeCast = init.typeCast;
|
|
10700
10624
|
}
|
|
10701
|
-
|
|
10702
|
-
|
|
10703
|
-
|
|
10704
|
-
|
|
10705
|
-
|
|
10706
|
-
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10625
|
+
toString() {
|
|
10626
|
+
let out = encodeURIComponent(this.resource).replace(/%24/, "$");
|
|
10627
|
+
if (this.key) {
|
|
10628
|
+
if (typeof this.key === "object" && isPlainObject2(this.key)) {
|
|
10629
|
+
const arr = [];
|
|
10630
|
+
for (const k of Object.keys(this.key)) {
|
|
10631
|
+
let v = this.key[k];
|
|
10632
|
+
if (typeof v === "number" || typeof v === "boolean")
|
|
10633
|
+
v = String(v);
|
|
10634
|
+
else
|
|
10635
|
+
v = '"' + encodeURIComponent(String(v)) + '"';
|
|
10636
|
+
arr.push(encodeURIComponent(k) + "=" + v);
|
|
10637
|
+
}
|
|
10638
|
+
out += "@" + arr.join(";");
|
|
10639
|
+
} else
|
|
10640
|
+
out += "@" + encodeURIComponent(String(this.key));
|
|
10641
|
+
}
|
|
10642
|
+
if (this.args) {
|
|
10643
|
+
const arr = [];
|
|
10644
|
+
for (const k of Object.keys(this.args)) {
|
|
10645
|
+
arr.push(encodeURIComponent(k) + "=" + encodeURIComponent(String(this.args[k])));
|
|
10719
10646
|
}
|
|
10720
|
-
|
|
10721
|
-
input.forEach((value, name) => this._append(name, value));
|
|
10722
|
-
else
|
|
10723
|
-
Object.keys(input).forEach((name) => this._append(name, input[name]));
|
|
10724
|
-
return this;
|
|
10725
|
-
}
|
|
10726
|
-
changed() {
|
|
10727
|
-
if (this[kOptions2].onChange)
|
|
10728
|
-
this[kOptions2].onChange();
|
|
10729
|
-
}
|
|
10730
|
-
clear() {
|
|
10731
|
-
if (this[kEntries].size) {
|
|
10732
|
-
this[kEntries].clear();
|
|
10733
|
-
this[kSize] = 0;
|
|
10734
|
-
this.changed();
|
|
10647
|
+
out += "(" + arr.join(";") + ")";
|
|
10735
10648
|
}
|
|
10649
|
+
if (this.typeCast)
|
|
10650
|
+
out += "::" + encodeURIComponent(this.typeCast);
|
|
10651
|
+
return out;
|
|
10736
10652
|
}
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
delete(name, value) {
|
|
10741
|
-
if (this._delete(name, value))
|
|
10742
|
-
this.changed();
|
|
10743
|
-
return this;
|
|
10653
|
+
/* istanbul ignore next */
|
|
10654
|
+
[nodeInspectCustom2]() {
|
|
10655
|
+
return this.toString();
|
|
10744
10656
|
}
|
|
10745
10657
|
/**
|
|
10746
|
-
*
|
|
10658
|
+
* Factory method.
|
|
10659
|
+
* @param input
|
|
10747
10660
|
*/
|
|
10748
|
-
|
|
10749
|
-
const
|
|
10750
|
-
|
|
10661
|
+
static parse(input) {
|
|
10662
|
+
const m = pathComponentRegEx.exec(input);
|
|
10663
|
+
if (!m)
|
|
10664
|
+
throw Object.assign(new TypeError("Invalid Opra URL"), {
|
|
10665
|
+
code: "ERR_INVALID_OPRA_URL",
|
|
10666
|
+
input
|
|
10667
|
+
});
|
|
10751
10668
|
let key;
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
if (
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10669
|
+
if (m[2]) {
|
|
10670
|
+
const s = decodeURIComponent(m[2]);
|
|
10671
|
+
const b = splitString2(s, { delimiters: ";", quotes: true, escape: false, keepQuotes: true, keepBrackets: true });
|
|
10672
|
+
for (const n of b) {
|
|
10673
|
+
const c = splitString2(n, { delimiters: "=", quotes: true, escape: false, keepQuotes: true, keepBrackets: true });
|
|
10674
|
+
if (b.length > 1 && c.length < 2 || (key && (c.length >= 2 && typeof key !== "object") || c.length < 2 && typeof key === "object"))
|
|
10675
|
+
throw Object.assign(new TypeError("Invalid Opra URL. name:value pair required for multiple key format"), {
|
|
10676
|
+
pathComponent: input,
|
|
10677
|
+
code: "ERR_INVALID_OPRA_URL"
|
|
10678
|
+
});
|
|
10679
|
+
if (c.length >= 2) {
|
|
10680
|
+
key = key || {};
|
|
10681
|
+
const k = c.shift() || "";
|
|
10682
|
+
let v = c.join("=");
|
|
10683
|
+
if (decimalPattern.test(v))
|
|
10684
|
+
v = Number(v);
|
|
10685
|
+
else if (booleanPattern.test(v))
|
|
10686
|
+
v = Boolean(v);
|
|
10687
|
+
else if (v.startsWith('"') && v.endsWith('"'))
|
|
10688
|
+
v = v.substring(1, v.length - 1);
|
|
10689
|
+
else if (v.startsWith("'") && v.endsWith("'"))
|
|
10690
|
+
v = v.substring(1, v.length - 1);
|
|
10691
|
+
key[k] = v;
|
|
10692
|
+
} else {
|
|
10693
|
+
if (decimalPattern.test(c[0]))
|
|
10694
|
+
key = Number(c[0]);
|
|
10695
|
+
else if (booleanPattern.test(c[0]))
|
|
10696
|
+
key = Boolean(c[0]);
|
|
10697
|
+
else
|
|
10698
|
+
key = c[0];
|
|
10770
10699
|
}
|
|
10771
|
-
return {
|
|
10772
|
-
done: false,
|
|
10773
|
-
value: [key, values[i++]]
|
|
10774
|
-
};
|
|
10775
10700
|
}
|
|
10701
|
+
return new _OpraURLPathComponent({
|
|
10702
|
+
resource: decodeURIComponent(m[1]),
|
|
10703
|
+
key,
|
|
10704
|
+
typeCast: m[3] ? decodeURIComponent(m[3]) : void 0
|
|
10705
|
+
});
|
|
10706
|
+
}
|
|
10707
|
+
return new _OpraURLPathComponent({
|
|
10708
|
+
resource: decodeURIComponent(m[1]),
|
|
10709
|
+
typeCast: m[3] ? decodeURIComponent(m[3]) : void 0
|
|
10710
|
+
});
|
|
10711
|
+
}
|
|
10712
|
+
};
|
|
10713
|
+
function removeLeadingSeparator(s) {
|
|
10714
|
+
const m = /^\/*(.*)/.exec(s);
|
|
10715
|
+
return m?.[1] || s;
|
|
10716
|
+
}
|
|
10717
|
+
__name(removeLeadingSeparator, "removeLeadingSeparator");
|
|
10718
|
+
|
|
10719
|
+
// ../../build/common/esm/http/opra-url.js
|
|
10720
|
+
var _a4;
|
|
10721
|
+
var nodeInspectCustom3 = Symbol.for("nodejs.util.inspect.custom");
|
|
10722
|
+
var urlRegEx = /^(?:((?:[A-Z][A-Z+-.]+:)+)\/\/([^/?]+))?(.*)?$/i;
|
|
10723
|
+
var schemeRegEx = /^([A-Z][A-Z+-.]+:?)+$/i;
|
|
10724
|
+
var hostRegEx = /^([^/:]+)(?::(\d+))?$/;
|
|
10725
|
+
var hostnameRegEx = /^([^/:]+)$/;
|
|
10726
|
+
var kContext = Symbol.for("kContext");
|
|
10727
|
+
var kPath = Symbol.for("kPath");
|
|
10728
|
+
var kSearchParams = Symbol.for("kSearchParams");
|
|
10729
|
+
var OpraURL = class _OpraURL {
|
|
10730
|
+
static {
|
|
10731
|
+
__name(this, "OpraURL");
|
|
10732
|
+
}
|
|
10733
|
+
constructor(input, base) {
|
|
10734
|
+
this[_a4] = {
|
|
10735
|
+
protocol: "",
|
|
10736
|
+
username: "",
|
|
10737
|
+
hostname: "",
|
|
10738
|
+
port: "",
|
|
10739
|
+
hash: "",
|
|
10740
|
+
password: ""
|
|
10776
10741
|
};
|
|
10742
|
+
this[kSearchParams] = new URLSearchParams();
|
|
10743
|
+
this[kPath] = new OpraURLPath();
|
|
10744
|
+
if (input)
|
|
10745
|
+
this._parse(String(input));
|
|
10746
|
+
if (base && !this.host) {
|
|
10747
|
+
const baseUrl = base instanceof _OpraURL ? base : new _OpraURL(base);
|
|
10748
|
+
this[kContext].protocol = baseUrl.protocol;
|
|
10749
|
+
this[kContext].hostname = baseUrl.hostname;
|
|
10750
|
+
this[kContext].username = baseUrl.username;
|
|
10751
|
+
this[kContext].password = baseUrl.password;
|
|
10752
|
+
this[kContext].port = baseUrl.port;
|
|
10753
|
+
this.path = OpraURLPath.join(baseUrl.path, this.path);
|
|
10754
|
+
}
|
|
10777
10755
|
}
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10756
|
+
get address() {
|
|
10757
|
+
if (this[kContext].address == null) {
|
|
10758
|
+
let address = "";
|
|
10759
|
+
if (this[kContext].hostname) {
|
|
10760
|
+
address += (this[kContext].protocol || "http:") + "//" + (this[kContext].username || this[kContext].password ? (this[kContext].username ? encodeURIComponent(this[kContext].username) : "") + (this[kContext].password ? ":" + encodeURIComponent(this[kContext].password) : "") + "@" : "") + this.host;
|
|
10761
|
+
}
|
|
10762
|
+
this[kContext].address = address + (this.pathname !== "/" ? this.pathname : "");
|
|
10784
10763
|
}
|
|
10764
|
+
return this[kContext].address;
|
|
10785
10765
|
}
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
*/
|
|
10789
|
-
get(name, index = 0) {
|
|
10790
|
-
const values = this[kEntries].get(name);
|
|
10791
|
-
return values && values.length > index ? values[index] : null;
|
|
10766
|
+
get host() {
|
|
10767
|
+
return this.hostname ? this.hostname + (this.port ? ":" + this.port : "") : "";
|
|
10792
10768
|
}
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10769
|
+
set host(v) {
|
|
10770
|
+
if (v) {
|
|
10771
|
+
const m = hostRegEx.exec(v);
|
|
10772
|
+
if (!m)
|
|
10773
|
+
throw Object.assign(new TypeError("Invalid host"), {
|
|
10774
|
+
host: v,
|
|
10775
|
+
code: "ERR_INVALID_URL"
|
|
10776
|
+
});
|
|
10777
|
+
this.hostname = m[1];
|
|
10778
|
+
this.port = m[2] || "";
|
|
10779
|
+
} else {
|
|
10780
|
+
this.hostname = "";
|
|
10781
|
+
this.port = "";
|
|
10782
|
+
}
|
|
10799
10783
|
}
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
*/
|
|
10803
|
-
keys() {
|
|
10804
|
-
return this[kEntries].keys();
|
|
10784
|
+
get hostname() {
|
|
10785
|
+
return this[kContext].hostname;
|
|
10805
10786
|
}
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10787
|
+
set hostname(v) {
|
|
10788
|
+
if (v) {
|
|
10789
|
+
if (!hostnameRegEx.test(v))
|
|
10790
|
+
throw Object.assign(new TypeError("Invalid hostname"), {
|
|
10791
|
+
hostname: v,
|
|
10792
|
+
code: "ERR_INVALID_URL"
|
|
10793
|
+
});
|
|
10794
|
+
this[kContext].hostname = v;
|
|
10795
|
+
} else
|
|
10796
|
+
this[kContext].hostname = "";
|
|
10797
|
+
this.invalidate();
|
|
10813
10798
|
}
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
*/
|
|
10817
|
-
has(name) {
|
|
10818
|
-
return this[kEntries].has(name);
|
|
10799
|
+
get href() {
|
|
10800
|
+
return this.address + this.search + this.hash;
|
|
10819
10801
|
}
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
* If the header already exists, its value is replaced with the given value
|
|
10823
|
-
*/
|
|
10824
|
-
set(name, value) {
|
|
10825
|
-
this._set(name, value);
|
|
10826
|
-
this.changed();
|
|
10827
|
-
return this;
|
|
10802
|
+
get password() {
|
|
10803
|
+
return this[kContext].password;
|
|
10828
10804
|
}
|
|
10829
|
-
|
|
10830
|
-
this[
|
|
10831
|
-
this.
|
|
10832
|
-
return this;
|
|
10805
|
+
set password(v) {
|
|
10806
|
+
this[kContext].password = v ?? "";
|
|
10807
|
+
this.invalidate();
|
|
10833
10808
|
}
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
* separated by `&`s.
|
|
10837
|
-
*/
|
|
10838
|
-
toString() {
|
|
10839
|
-
const out = [];
|
|
10840
|
-
this.forEach((v, k) => {
|
|
10841
|
-
out.push(encodeURIParam(k) + (v ? "=" + this.encodeValue(v, k) : ""));
|
|
10842
|
-
});
|
|
10843
|
-
return out.join("&");
|
|
10809
|
+
get port() {
|
|
10810
|
+
return this[kContext].port;
|
|
10844
10811
|
}
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
}
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
_this.set(p, newValue);
|
|
10858
|
-
return true;
|
|
10859
|
-
}
|
|
10860
|
-
return Reflect.set(target, p, newValue, receiver);
|
|
10861
|
-
}
|
|
10862
|
-
});
|
|
10812
|
+
set port(value) {
|
|
10813
|
+
if (value) {
|
|
10814
|
+
const v = typeof value === "number" ? value : parseInt(value, 10);
|
|
10815
|
+
if (isNaN(v) || v < 1 || v > 65535 || v % 1 > 0)
|
|
10816
|
+
throw Object.assign(new TypeError(`Invalid port number (${value})`), {
|
|
10817
|
+
hostname: v,
|
|
10818
|
+
code: "ERR_INVALID_URL"
|
|
10819
|
+
});
|
|
10820
|
+
this[kContext].port = String(v);
|
|
10821
|
+
} else
|
|
10822
|
+
this[kContext].port = "";
|
|
10823
|
+
this.invalidate();
|
|
10863
10824
|
}
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
for (const [name, def] of Object.entries(arg0))
|
|
10867
|
-
this.define(name, def);
|
|
10868
|
-
return this;
|
|
10869
|
-
}
|
|
10870
|
-
if (!arg0)
|
|
10871
|
-
throw new Error('"name" argument required');
|
|
10872
|
-
if (!options)
|
|
10873
|
-
throw new Error('"options" argument required');
|
|
10874
|
-
if (typeof options.codec === "string" && !_HttpParams.codecs[options.codec])
|
|
10875
|
-
throw new Error(`Unknown url parameter format name "${options.codec}"`);
|
|
10876
|
-
const codec = (typeof options?.codec === "string" ? _HttpParams.codecs[options.codec] : options?.codec) || _HttpParams.codecs.string;
|
|
10877
|
-
const meta = {
|
|
10878
|
-
...options,
|
|
10879
|
-
codec
|
|
10880
|
-
};
|
|
10881
|
-
this[kParamDefs].set(arg0, meta);
|
|
10882
|
-
return this;
|
|
10825
|
+
get protocol() {
|
|
10826
|
+
return this[kContext].protocol;
|
|
10883
10827
|
}
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
10894
|
-
|
|
10895
|
-
let val = value;
|
|
10896
|
-
if (prmDef) {
|
|
10897
|
-
if (prmDef.array) {
|
|
10898
|
-
val = splitString2(value, {
|
|
10899
|
-
delimiters: prmDef.arrayDelimiter || ",",
|
|
10900
|
-
brackets: true,
|
|
10901
|
-
quotes: true,
|
|
10902
|
-
keepQuotes: false
|
|
10903
|
-
}).map((x) => decodeURIComponent(x));
|
|
10904
|
-
} else
|
|
10905
|
-
val = decodeURIComponent(val);
|
|
10906
|
-
const fn = /* @__PURE__ */ __name((x) => prmDef.codec.decode(decodeURIComponent(x)), "fn");
|
|
10907
|
-
val = Array.isArray(val) ? val.map(fn) : fn(val);
|
|
10908
|
-
if (prmDef.array === "strict")
|
|
10909
|
-
val = Array.isArray(val) ? val : [val];
|
|
10910
|
-
else if (prmDef.array)
|
|
10911
|
-
val = Array.isArray(val) && val.length === 1 ? val[0] : val;
|
|
10912
|
-
if (Array.isArray(val)) {
|
|
10913
|
-
if (prmDef.minArrayItems && val.length < prmDef.minArrayItems)
|
|
10914
|
-
throw new Error(`"${key}" parameter requires at least ${prmDef.minArrayItems} values`);
|
|
10915
|
-
if (prmDef.maxArrayItems && val.length > prmDef.maxArrayItems)
|
|
10916
|
-
throw new Error(`"${key}" parameter accepts up to ${prmDef.maxArrayItems} values`);
|
|
10917
|
-
}
|
|
10918
|
-
return val;
|
|
10919
|
-
}
|
|
10920
|
-
return decodeURIComponent(value);
|
|
10828
|
+
set protocol(v) {
|
|
10829
|
+
if (v) {
|
|
10830
|
+
if (!schemeRegEx.test(v))
|
|
10831
|
+
throw Object.assign(new TypeError("Invalid protocol"), {
|
|
10832
|
+
protocol: v,
|
|
10833
|
+
code: "ERR_INVALID_URL"
|
|
10834
|
+
});
|
|
10835
|
+
this[kContext].protocol = v + (v.endsWith(":") ? "" : ":");
|
|
10836
|
+
} else
|
|
10837
|
+
this[kContext].protocol = "";
|
|
10838
|
+
this.invalidate();
|
|
10921
10839
|
}
|
|
10922
|
-
|
|
10923
|
-
return this.
|
|
10840
|
+
get username() {
|
|
10841
|
+
return this[kContext].username;
|
|
10924
10842
|
}
|
|
10925
|
-
|
|
10926
|
-
|
|
10843
|
+
set username(v) {
|
|
10844
|
+
this[kContext].username = v ?? "";
|
|
10845
|
+
this.invalidate();
|
|
10927
10846
|
}
|
|
10928
|
-
|
|
10929
|
-
|
|
10930
|
-
if (!values) {
|
|
10931
|
-
values = [];
|
|
10932
|
-
this[kEntries].set(name, values);
|
|
10933
|
-
}
|
|
10934
|
-
values.push(value ?? null);
|
|
10935
|
-
this[kSize] += 1;
|
|
10847
|
+
get origin() {
|
|
10848
|
+
return this.hostname ? this.protocol + "//" + this.hostname : "";
|
|
10936
10849
|
}
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10850
|
+
get path() {
|
|
10851
|
+
return this[kPath];
|
|
10852
|
+
}
|
|
10853
|
+
set path(path2) {
|
|
10854
|
+
this[kPath] = path2 instanceof OpraURLPath ? path2 : new OpraURLPath(path2);
|
|
10855
|
+
this[kContext].pathname = String(this[kPath]);
|
|
10856
|
+
this.invalidate();
|
|
10857
|
+
}
|
|
10858
|
+
get pathname() {
|
|
10859
|
+
if (this[kContext].pathname == null)
|
|
10860
|
+
this[kContext].pathname = this.path.toString() || "/";
|
|
10861
|
+
return this[kContext].pathname;
|
|
10862
|
+
}
|
|
10863
|
+
set pathname(v) {
|
|
10864
|
+
this[kPath] = new OpraURLPath(v);
|
|
10865
|
+
this.invalidate();
|
|
10866
|
+
}
|
|
10867
|
+
get hash() {
|
|
10868
|
+
return this[kContext].hash;
|
|
10869
|
+
}
|
|
10870
|
+
set hash(v) {
|
|
10871
|
+
this[kContext].hash = v ? v.startsWith("#") ? v : "#" + v : "";
|
|
10872
|
+
}
|
|
10873
|
+
get search() {
|
|
10874
|
+
const s = this[kSearchParams].toString();
|
|
10875
|
+
return s ? "?" + s : "";
|
|
10876
|
+
}
|
|
10877
|
+
set search(v) {
|
|
10878
|
+
this[kSearchParams] = new URLSearchParams(v);
|
|
10879
|
+
}
|
|
10880
|
+
get searchParams() {
|
|
10881
|
+
return this[kSearchParams];
|
|
10882
|
+
}
|
|
10883
|
+
set setSearchParams(v) {
|
|
10884
|
+
this[kSearchParams] = v;
|
|
10885
|
+
}
|
|
10886
|
+
invalidate() {
|
|
10887
|
+
this[kContext].address = void 0;
|
|
10888
|
+
this[kContext].pathname = void 0;
|
|
10889
|
+
}
|
|
10890
|
+
join(...items) {
|
|
10891
|
+
this.path = this.path.join(...items);
|
|
10892
|
+
this.invalidate();
|
|
10893
|
+
return this;
|
|
10894
|
+
}
|
|
10895
|
+
resolve(...items) {
|
|
10896
|
+
this.path = this.path.resolve(...items);
|
|
10897
|
+
this.invalidate();
|
|
10898
|
+
return this;
|
|
10899
|
+
}
|
|
10900
|
+
toString() {
|
|
10901
|
+
return this.href;
|
|
10902
|
+
}
|
|
10903
|
+
_parse(input) {
|
|
10904
|
+
const m = urlRegEx.exec(input);
|
|
10905
|
+
if (!m)
|
|
10906
|
+
throw Object.assign(new TypeError("Invalid URL"), {
|
|
10907
|
+
input,
|
|
10908
|
+
code: "ERR_INVALID_URL"
|
|
10909
|
+
});
|
|
10910
|
+
this.protocol = m[1];
|
|
10911
|
+
const isAbsolute = !!m[2];
|
|
10912
|
+
if (isAbsolute) {
|
|
10913
|
+
let tokens = splitString3(m[2], { delimiters: "@" });
|
|
10914
|
+
if (tokens.length > 1) {
|
|
10915
|
+
this.host = tokens[1];
|
|
10916
|
+
tokens = splitString3(tokens[0], { delimiters: ":" });
|
|
10917
|
+
this.username = tokens[0] ? decodeURIComponent(tokens[0]) : "";
|
|
10918
|
+
this.password = tokens[1] ? decodeURIComponent(tokens[1]) : "";
|
|
10919
|
+
} else
|
|
10920
|
+
this.host = tokens[0];
|
|
10946
10921
|
} else {
|
|
10947
|
-
this
|
|
10948
|
-
this
|
|
10922
|
+
this.host = "";
|
|
10923
|
+
this.username = "";
|
|
10924
|
+
this.password = "";
|
|
10949
10925
|
}
|
|
10950
|
-
|
|
10926
|
+
input = m[3] || "";
|
|
10927
|
+
let tokenizer = tokenize3(input, { delimiters: "#", quotes: true, brackets: true });
|
|
10928
|
+
input = tokenizer.next() || "";
|
|
10929
|
+
this.hash = tokenizer.join("#");
|
|
10930
|
+
tokenizer = tokenize3(input, { delimiters: "?", quotes: true, brackets: true });
|
|
10931
|
+
this.path = new OpraURLPath(tokenizer.next());
|
|
10932
|
+
this.search = tokenizer.join("&");
|
|
10951
10933
|
}
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
this
|
|
10960
|
-
this
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
this
|
|
10965
|
-
|
|
10966
|
-
return;
|
|
10967
|
-
}
|
|
10968
|
-
const oldLen = values.length;
|
|
10969
|
-
values[Math.min(index, values.length)] = value;
|
|
10970
|
-
this[kSize] += -oldLen + values.length;
|
|
10934
|
+
/* istanbul ignore next */
|
|
10935
|
+
[(_a4 = kContext, nodeInspectCustom3)]() {
|
|
10936
|
+
return {
|
|
10937
|
+
protocol: this.protocol,
|
|
10938
|
+
username: this.username,
|
|
10939
|
+
password: this.password,
|
|
10940
|
+
host: this.host,
|
|
10941
|
+
hostname: this.hostname,
|
|
10942
|
+
origin: this.origin,
|
|
10943
|
+
path: this.path,
|
|
10944
|
+
pathname: this.pathname,
|
|
10945
|
+
search: this.search,
|
|
10946
|
+
hash: this.hash
|
|
10947
|
+
};
|
|
10971
10948
|
}
|
|
10972
10949
|
};
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
HttpParams.kOptions = kOptions2;
|
|
10977
|
-
HttpParams.codecs = {
|
|
10978
|
-
"boolean": new BooleanCodec(),
|
|
10979
|
-
"date": new DateCodec(),
|
|
10980
|
-
"filter": new FilterCodec(),
|
|
10981
|
-
"integer": new IntegerCodec(),
|
|
10982
|
-
"number": new NumberCodec(),
|
|
10983
|
-
"string": new StringCodec()
|
|
10984
|
-
};
|
|
10985
|
-
var ENCODING_REGEX = /%(\d[a-f0-9])/gi;
|
|
10986
|
-
var ENCODING_REPLACEMENTS = {
|
|
10987
|
-
"2C": ",",
|
|
10988
|
-
"2F": "/",
|
|
10989
|
-
"24": "$",
|
|
10990
|
-
"3A": ":",
|
|
10991
|
-
"3B": ";",
|
|
10992
|
-
"3D": "=",
|
|
10993
|
-
"3F": "?",
|
|
10994
|
-
"40": "@"
|
|
10995
|
-
};
|
|
10996
|
-
function encodeURIParam(v) {
|
|
10997
|
-
return encodeURIComponent(v).replace(ENCODING_REGEX, (s, t) => ENCODING_REPLACEMENTS[t] ?? s);
|
|
10998
|
-
}
|
|
10999
|
-
__name(encodeURIParam, "encodeURIParam");
|
|
10950
|
+
OpraURL.kContext = kContext;
|
|
10951
|
+
OpraURL.kPath = kPath;
|
|
10952
|
+
OpraURL.kParams = kSearchParams;
|
|
11000
10953
|
|
|
11001
10954
|
// ../../build/common/esm/http/enums/http-headers-codes.enum.js
|
|
11002
10955
|
var HttpHeaderCodes;
|
|
11003
10956
|
(function(HttpHeaderCodes2) {
|
|
11004
|
-
HttpHeaderCodes2["X_Opra_Version"] = "X-
|
|
11005
|
-
HttpHeaderCodes2["
|
|
11006
|
-
HttpHeaderCodes2["X_Opra_Operation"] = "X-OPRA-Operation";
|
|
11007
|
-
HttpHeaderCodes2["X_Opra_Total_Matches"] = "X-OPRA-Total-Matches";
|
|
10957
|
+
HttpHeaderCodes2["X_Opra_Version"] = "X-Opra-Version";
|
|
10958
|
+
HttpHeaderCodes2["X_Total_Count"] = "X-Total-Count";
|
|
11008
10959
|
HttpHeaderCodes2["WWW_Authenticate"] = "WWW-Authenticate";
|
|
11009
10960
|
HttpHeaderCodes2["Authorization"] = "Authorization";
|
|
11010
10961
|
HttpHeaderCodes2["Proxy_Authenticate"] = "Proxy-Authenticate";
|
|
@@ -11140,7 +11091,7 @@ var HttpStatusCodes;
|
|
|
11140
11091
|
HttpStatusCodes2[HttpStatusCodes2["LOCKED"] = 423] = "LOCKED";
|
|
11141
11092
|
HttpStatusCodes2[HttpStatusCodes2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
11142
11093
|
HttpStatusCodes2[HttpStatusCodes2["TOO_EARLY"] = 425] = "TOO_EARLY";
|
|
11143
|
-
HttpStatusCodes2[HttpStatusCodes2["UPGRADE_REQUIRED"] =
|
|
11094
|
+
HttpStatusCodes2[HttpStatusCodes2["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
11144
11095
|
HttpStatusCodes2[HttpStatusCodes2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
11145
11096
|
HttpStatusCodes2[HttpStatusCodes2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
11146
11097
|
HttpStatusCodes2[HttpStatusCodes2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
@@ -11223,565 +11174,6 @@ var HttpStatusMessages = {
|
|
|
11223
11174
|
"511": "Network Authentication Required"
|
|
11224
11175
|
};
|
|
11225
11176
|
|
|
11226
|
-
// ../../build/common/esm/url/opra-url.js
|
|
11227
|
-
import { splitString as splitString4, tokenize as tokenize4 } from "fast-tokenizer";
|
|
11228
|
-
|
|
11229
|
-
// ../../build/common/esm/utils/path-utils.js
|
|
11230
|
-
function normalizePath(p, noLeadingSlash) {
|
|
11231
|
-
if (!p)
|
|
11232
|
-
return "";
|
|
11233
|
-
while (noLeadingSlash && p.startsWith("/"))
|
|
11234
|
-
p = p.substring(1);
|
|
11235
|
-
while (p.endsWith("/"))
|
|
11236
|
-
p = p.substring(0, p.length - 1);
|
|
11237
|
-
return p;
|
|
11238
|
-
}
|
|
11239
|
-
__name(normalizePath, "normalizePath");
|
|
11240
|
-
function joinPath(...p) {
|
|
11241
|
-
const out = [];
|
|
11242
|
-
let s;
|
|
11243
|
-
for (let i = 0, l = p.length; i < l; i++) {
|
|
11244
|
-
s = normalizePath(p[i], i > 0);
|
|
11245
|
-
if (s)
|
|
11246
|
-
out.push(s);
|
|
11247
|
-
}
|
|
11248
|
-
return out.join("/");
|
|
11249
|
-
}
|
|
11250
|
-
__name(joinPath, "joinPath");
|
|
11251
|
-
|
|
11252
|
-
// ../../build/common/esm/url/opra-url-path.js
|
|
11253
|
-
import { tokenize as tokenize3 } from "fast-tokenizer";
|
|
11254
|
-
|
|
11255
|
-
// ../../build/common/esm/url/utils/encode-path-component.js
|
|
11256
|
-
import isPlainObject2 from "putil-isplainobject";
|
|
11257
|
-
function encodePathComponent(resource, key, typeCast) {
|
|
11258
|
-
if (resource == null)
|
|
11259
|
-
return "";
|
|
11260
|
-
let keyString = "";
|
|
11261
|
-
if (key !== "" && key != null) {
|
|
11262
|
-
if (isPlainObject2(key)) {
|
|
11263
|
-
const arr = [];
|
|
11264
|
-
for (const k of Object.keys(key)) {
|
|
11265
|
-
arr.push(encodeURIComponent(k) + "=" + encodeURIComponent(key[k]));
|
|
11266
|
-
}
|
|
11267
|
-
keyString = arr.join(";");
|
|
11268
|
-
} else
|
|
11269
|
-
keyString = encodeURIComponent("" + key);
|
|
11270
|
-
}
|
|
11271
|
-
if (typeCast)
|
|
11272
|
-
typeCast = encodeURIComponent(typeCast);
|
|
11273
|
-
return encodeURIComponent(resource).replace(/%24/, "$") + (keyString ? "@" + keyString : "") + (typeCast ? "::" + typeCast : "");
|
|
11274
|
-
}
|
|
11275
|
-
__name(encodePathComponent, "encodePathComponent");
|
|
11276
|
-
|
|
11277
|
-
// ../../build/common/esm/url/opra-url-path-component.js
|
|
11278
|
-
var nodeInspectCustom2 = Symbol.for("nodejs.util.inspect.custom");
|
|
11279
|
-
var OpraURLPathComponent = class _OpraURLPathComponent {
|
|
11280
|
-
static {
|
|
11281
|
-
__name(this, "OpraURLPathComponent");
|
|
11282
|
-
}
|
|
11283
|
-
constructor(init) {
|
|
11284
|
-
this.resource = init.resource;
|
|
11285
|
-
this.key = init.key;
|
|
11286
|
-
this.typeCast = init.typeCast;
|
|
11287
|
-
}
|
|
11288
|
-
toString() {
|
|
11289
|
-
const obj = encodePathComponent(this.resource, this.key, this.typeCast);
|
|
11290
|
-
if (obj)
|
|
11291
|
-
Object.setPrototypeOf(obj, _OpraURLPathComponent.prototype);
|
|
11292
|
-
return obj;
|
|
11293
|
-
}
|
|
11294
|
-
/* istanbul ignore next */
|
|
11295
|
-
[nodeInspectCustom2]() {
|
|
11296
|
-
const out = {
|
|
11297
|
-
resource: this.resource
|
|
11298
|
-
};
|
|
11299
|
-
if (this.key != null)
|
|
11300
|
-
out.key = this.key;
|
|
11301
|
-
if (this.typeCast != null)
|
|
11302
|
-
out.typeCast = this.typeCast;
|
|
11303
|
-
return out;
|
|
11304
|
-
}
|
|
11305
|
-
};
|
|
11306
|
-
|
|
11307
|
-
// ../../build/common/esm/url/utils/decode-path-component.js
|
|
11308
|
-
import { splitString as splitString3 } from "fast-tokenizer";
|
|
11309
|
-
var pathComponentRegEx = /^([^/?#:@]+)(?:@([^/?#:]*))?(?:::(.*))?$/;
|
|
11310
|
-
function decodePathComponent(input) {
|
|
11311
|
-
const m = pathComponentRegEx.exec(input);
|
|
11312
|
-
if (!m)
|
|
11313
|
-
throw Object.assign(new TypeError("Invalid URL path"), {
|
|
11314
|
-
code: "ERR_INVALID_URL_PATH",
|
|
11315
|
-
input
|
|
11316
|
-
});
|
|
11317
|
-
const resource = decodeURIComponent(m[1]);
|
|
11318
|
-
let key;
|
|
11319
|
-
if (m[2]) {
|
|
11320
|
-
const s = decodeURIComponent(m[2] || "");
|
|
11321
|
-
const b = splitString3(s, { delimiters: ";", quotes: true, escape: false });
|
|
11322
|
-
for (const k of b) {
|
|
11323
|
-
const c = splitString3(k, { delimiters: "=", quotes: true, escape: false });
|
|
11324
|
-
if (b.length > 1 && c.length < 2 || (key && (c.length >= 2 && typeof key !== "object") || c.length < 2 && typeof key === "object"))
|
|
11325
|
-
throw Object.assign(new TypeError("Invalid URL path. name:value pair required for multiple key format"), {
|
|
11326
|
-
pathComponent: input,
|
|
11327
|
-
code: "ERR_INVALID_URL_PATH"
|
|
11328
|
-
});
|
|
11329
|
-
if (c.length >= 2) {
|
|
11330
|
-
key = key || {};
|
|
11331
|
-
key[c.shift() || ""] = c.join("=");
|
|
11332
|
-
} else
|
|
11333
|
-
key = c[0];
|
|
11334
|
-
}
|
|
11335
|
-
}
|
|
11336
|
-
if (m[3]) {
|
|
11337
|
-
return { resource, key, typeCast: m[3] };
|
|
11338
|
-
}
|
|
11339
|
-
return { resource, key };
|
|
11340
|
-
}
|
|
11341
|
-
__name(decodePathComponent, "decodePathComponent");
|
|
11342
|
-
|
|
11343
|
-
// ../../build/common/esm/url/opra-url-path.js
|
|
11344
|
-
var _a4;
|
|
11345
|
-
var nodeInspectCustom3 = Symbol.for("nodejs.util.inspect.custom");
|
|
11346
|
-
var kEntries2 = Symbol("kEntries");
|
|
11347
|
-
var kOptions3 = Symbol("kOptions");
|
|
11348
|
-
var OpraURLPath = class _OpraURLPath {
|
|
11349
|
-
static {
|
|
11350
|
-
__name(this, "OpraURLPath");
|
|
11351
|
-
}
|
|
11352
|
-
constructor(init, options) {
|
|
11353
|
-
this[_a4] = [];
|
|
11354
|
-
this[kOptions3] = { ...options, onChange: void 0 };
|
|
11355
|
-
if (Array.isArray(init))
|
|
11356
|
-
this.join(...init);
|
|
11357
|
-
else if (init)
|
|
11358
|
-
this.join(init);
|
|
11359
|
-
this[kOptions3].onChange = options?.onChange;
|
|
11360
|
-
}
|
|
11361
|
-
get size() {
|
|
11362
|
-
return this[kEntries2].length;
|
|
11363
|
-
}
|
|
11364
|
-
changed() {
|
|
11365
|
-
if (this[kOptions3].onChange)
|
|
11366
|
-
this[kOptions3].onChange();
|
|
11367
|
-
}
|
|
11368
|
-
clear() {
|
|
11369
|
-
this[kEntries2] = [];
|
|
11370
|
-
this.changed();
|
|
11371
|
-
}
|
|
11372
|
-
get(index) {
|
|
11373
|
-
return this[kEntries2][index];
|
|
11374
|
-
}
|
|
11375
|
-
join(...source) {
|
|
11376
|
-
source.forEach((x) => this._join(this[kEntries2], x));
|
|
11377
|
-
this.changed();
|
|
11378
|
-
return this;
|
|
11379
|
-
}
|
|
11380
|
-
entries() {
|
|
11381
|
-
let i = -1;
|
|
11382
|
-
const arr = [...this[kEntries2]];
|
|
11383
|
-
return {
|
|
11384
|
-
[Symbol.iterator]() {
|
|
11385
|
-
return this;
|
|
11386
|
-
},
|
|
11387
|
-
next() {
|
|
11388
|
-
i++;
|
|
11389
|
-
return {
|
|
11390
|
-
done: i >= arr.length,
|
|
11391
|
-
value: [arr[i], i]
|
|
11392
|
-
};
|
|
11393
|
-
}
|
|
11394
|
-
};
|
|
11395
|
-
}
|
|
11396
|
-
forEach(callback) {
|
|
11397
|
-
for (const item of this[kEntries2]) {
|
|
11398
|
-
callback.call(this, item, this);
|
|
11399
|
-
}
|
|
11400
|
-
}
|
|
11401
|
-
getResource(index) {
|
|
11402
|
-
const v = this[kEntries2][index];
|
|
11403
|
-
return v == null ? void 0 : v.resource;
|
|
11404
|
-
}
|
|
11405
|
-
getKey(index) {
|
|
11406
|
-
const v = this[kEntries2][index];
|
|
11407
|
-
return v == null ? void 0 : v.key;
|
|
11408
|
-
}
|
|
11409
|
-
pop() {
|
|
11410
|
-
const out = this[kEntries2].pop();
|
|
11411
|
-
this.changed();
|
|
11412
|
-
return out;
|
|
11413
|
-
}
|
|
11414
|
-
shift() {
|
|
11415
|
-
const out = this[kEntries2].shift();
|
|
11416
|
-
this.changed();
|
|
11417
|
-
return out;
|
|
11418
|
-
}
|
|
11419
|
-
slice(start, end) {
|
|
11420
|
-
return new _OpraURLPath(this[kEntries2].slice(start, end));
|
|
11421
|
-
}
|
|
11422
|
-
splice(start, deleteCount, join) {
|
|
11423
|
-
const items = join ? this._join([], join) : [];
|
|
11424
|
-
this[kEntries2].splice(start, deleteCount, ...items);
|
|
11425
|
-
this.changed();
|
|
11426
|
-
}
|
|
11427
|
-
unshift(join) {
|
|
11428
|
-
return this.splice(0, 0, join);
|
|
11429
|
-
}
|
|
11430
|
-
toString() {
|
|
11431
|
-
return this[kEntries2].map((x) => encodePathComponent(x.resource, x.key, x.typeCast)).join("/");
|
|
11432
|
-
}
|
|
11433
|
-
values() {
|
|
11434
|
-
let i = -1;
|
|
11435
|
-
const arr = [...this[kEntries2]];
|
|
11436
|
-
return {
|
|
11437
|
-
[Symbol.iterator]() {
|
|
11438
|
-
return this;
|
|
11439
|
-
},
|
|
11440
|
-
next() {
|
|
11441
|
-
i++;
|
|
11442
|
-
return {
|
|
11443
|
-
done: i >= arr.length,
|
|
11444
|
-
value: arr[i]
|
|
11445
|
-
};
|
|
11446
|
-
}
|
|
11447
|
-
};
|
|
11448
|
-
}
|
|
11449
|
-
_join(target, source) {
|
|
11450
|
-
if (typeof source === "string") {
|
|
11451
|
-
const pathTokenizer = tokenize3(normalizePath(source, true), {
|
|
11452
|
-
delimiters: "/",
|
|
11453
|
-
quotes: true,
|
|
11454
|
-
brackets: true
|
|
11455
|
-
});
|
|
11456
|
-
for (const x of pathTokenizer) {
|
|
11457
|
-
const p = decodePathComponent(x);
|
|
11458
|
-
target.push(new OpraURLPathComponent(p));
|
|
11459
|
-
}
|
|
11460
|
-
return;
|
|
11461
|
-
}
|
|
11462
|
-
if (source instanceof _OpraURLPath) {
|
|
11463
|
-
target.push(...source[kEntries2].map((x) => new OpraURLPathComponent(x)));
|
|
11464
|
-
return;
|
|
11465
|
-
}
|
|
11466
|
-
if (typeof source === "object" && source.path instanceof _OpraURLPath) {
|
|
11467
|
-
this._join(target, source.path);
|
|
11468
|
-
return;
|
|
11469
|
-
}
|
|
11470
|
-
if (isURL(source)) {
|
|
11471
|
-
this._join(target, source.pathname);
|
|
11472
|
-
return;
|
|
11473
|
-
}
|
|
11474
|
-
if (Array.isArray(source)) {
|
|
11475
|
-
source.forEach((x) => this._join(target, x));
|
|
11476
|
-
return;
|
|
11477
|
-
}
|
|
11478
|
-
target.push(new OpraURLPathComponent(source));
|
|
11479
|
-
}
|
|
11480
|
-
/* istanbul ignore next */
|
|
11481
|
-
[(_a4 = kEntries2, nodeInspectCustom3)]() {
|
|
11482
|
-
return this[kEntries2];
|
|
11483
|
-
}
|
|
11484
|
-
[Symbol.iterator]() {
|
|
11485
|
-
return this.entries();
|
|
11486
|
-
}
|
|
11487
|
-
get [Symbol.toStringTag]() {
|
|
11488
|
-
return "OpraURLPath";
|
|
11489
|
-
}
|
|
11490
|
-
};
|
|
11491
|
-
OpraURLPath.kEntries = kEntries2;
|
|
11492
|
-
OpraURLPath.kOptions = kOptions3;
|
|
11493
|
-
|
|
11494
|
-
// ../../build/common/esm/url/opra-url.js
|
|
11495
|
-
var _a5;
|
|
11496
|
-
var nodeInspectCustom4 = Symbol.for("nodejs.util.inspect.custom");
|
|
11497
|
-
var urlRegEx = /^(?:((?:[A-Z][A-Z+-.]+:)+)\/\/([^/?]+))?(.*)?$/i;
|
|
11498
|
-
var schemeRegEx = /^([A-Z][A-Z+-.]+:?)+$/i;
|
|
11499
|
-
var hostRegEx = /^([^/:]+)(?::(\d+))?$/;
|
|
11500
|
-
var hostnameRegEx = /^([^/:]+)$/;
|
|
11501
|
-
var kContext = Symbol("kContext");
|
|
11502
|
-
var kPath = Symbol("kPath");
|
|
11503
|
-
var kParams = Symbol("kParams");
|
|
11504
|
-
var OpraURL = class _OpraURL {
|
|
11505
|
-
static {
|
|
11506
|
-
__name(this, "OpraURL");
|
|
11507
|
-
}
|
|
11508
|
-
constructor(input, base) {
|
|
11509
|
-
this[_a5] = {
|
|
11510
|
-
protocol: "",
|
|
11511
|
-
username: "",
|
|
11512
|
-
prefix: "",
|
|
11513
|
-
hostname: "",
|
|
11514
|
-
port: "",
|
|
11515
|
-
hash: "",
|
|
11516
|
-
password: ""
|
|
11517
|
-
};
|
|
11518
|
-
this[kPath] = new OpraURLPath("", {
|
|
11519
|
-
onChange: () => {
|
|
11520
|
-
this[kContext].pathname = void 0;
|
|
11521
|
-
this[kContext].address = void 0;
|
|
11522
|
-
}
|
|
11523
|
-
});
|
|
11524
|
-
this[kParams] = new HttpParams("", {
|
|
11525
|
-
onChange: () => {
|
|
11526
|
-
this[kContext].search = void 0;
|
|
11527
|
-
}
|
|
11528
|
-
});
|
|
11529
|
-
if (input)
|
|
11530
|
-
this.parse(typeof input === "object" ? input.toString() : input);
|
|
11531
|
-
if (base) {
|
|
11532
|
-
const baseUrl = base instanceof _OpraURL ? base : new _OpraURL(base);
|
|
11533
|
-
this[kContext].protocol = baseUrl.protocol;
|
|
11534
|
-
this[kContext].hostname = baseUrl.hostname;
|
|
11535
|
-
this[kContext].port = baseUrl.port;
|
|
11536
|
-
this[kContext].prefix = baseUrl.pathname;
|
|
11537
|
-
}
|
|
11538
|
-
}
|
|
11539
|
-
get address() {
|
|
11540
|
-
if (this[kContext].address == null) {
|
|
11541
|
-
let address = "";
|
|
11542
|
-
if (this[kContext].hostname) {
|
|
11543
|
-
address += (this[kContext].protocol || "http:") + "//" + (this[kContext].username || this[kContext].password ? (this[kContext].username ? encodeURIComponent(this[kContext].username) : "") + (this[kContext].password ? ":" + encodeURIComponent(this[kContext].password) : "") + "@" : "") + this.host;
|
|
11544
|
-
}
|
|
11545
|
-
this[kContext].address = address + (this.prefix !== "/" ? this.prefix : "") + (this.pathname !== "/" ? this.pathname : "");
|
|
11546
|
-
}
|
|
11547
|
-
return this[kContext].address;
|
|
11548
|
-
}
|
|
11549
|
-
get host() {
|
|
11550
|
-
return this.hostname ? this.hostname + (this.port ? ":" + this.port : "") : "";
|
|
11551
|
-
}
|
|
11552
|
-
set host(v) {
|
|
11553
|
-
if (v) {
|
|
11554
|
-
const m = hostRegEx.exec(v);
|
|
11555
|
-
if (!m)
|
|
11556
|
-
throw Object.assign(new TypeError("Invalid host"), {
|
|
11557
|
-
host: v,
|
|
11558
|
-
code: "ERR_INVALID_URL"
|
|
11559
|
-
});
|
|
11560
|
-
this.hostname = m[1];
|
|
11561
|
-
this.port = m[2] || "";
|
|
11562
|
-
} else {
|
|
11563
|
-
this.hostname = "";
|
|
11564
|
-
this.port = "";
|
|
11565
|
-
}
|
|
11566
|
-
}
|
|
11567
|
-
get hostname() {
|
|
11568
|
-
return this[kContext].hostname;
|
|
11569
|
-
}
|
|
11570
|
-
set hostname(v) {
|
|
11571
|
-
if (v) {
|
|
11572
|
-
if (!hostnameRegEx.test(v))
|
|
11573
|
-
throw Object.assign(new TypeError("Invalid hostname"), {
|
|
11574
|
-
hostname: v,
|
|
11575
|
-
code: "ERR_INVALID_URL"
|
|
11576
|
-
});
|
|
11577
|
-
this[kContext].hostname = v;
|
|
11578
|
-
} else
|
|
11579
|
-
this[kContext].hostname = "";
|
|
11580
|
-
this[kContext].address = void 0;
|
|
11581
|
-
}
|
|
11582
|
-
get href() {
|
|
11583
|
-
return this.address + this.search + this.hash;
|
|
11584
|
-
}
|
|
11585
|
-
get password() {
|
|
11586
|
-
return this[kContext].password;
|
|
11587
|
-
}
|
|
11588
|
-
set password(v) {
|
|
11589
|
-
this[kContext].password = v ?? "";
|
|
11590
|
-
this[kContext].address = void 0;
|
|
11591
|
-
}
|
|
11592
|
-
get port() {
|
|
11593
|
-
return this[kContext].port;
|
|
11594
|
-
}
|
|
11595
|
-
set port(value) {
|
|
11596
|
-
if (value) {
|
|
11597
|
-
const v = typeof value === "number" ? value : parseInt(value, 10);
|
|
11598
|
-
if (isNaN(v) || v < 1 || v > 35535 || v % 1 > 0)
|
|
11599
|
-
throw Object.assign(new TypeError("Invalid port"), {
|
|
11600
|
-
hostname: v,
|
|
11601
|
-
code: "ERR_INVALID_URL"
|
|
11602
|
-
});
|
|
11603
|
-
this[kContext].port = String(v);
|
|
11604
|
-
} else
|
|
11605
|
-
this[kContext].port = "";
|
|
11606
|
-
}
|
|
11607
|
-
get prefix() {
|
|
11608
|
-
return this[kContext].prefix;
|
|
11609
|
-
}
|
|
11610
|
-
set prefix(value) {
|
|
11611
|
-
if (value) {
|
|
11612
|
-
const url = new _OpraURL(value);
|
|
11613
|
-
this[kContext].prefix = url.pathname;
|
|
11614
|
-
} else
|
|
11615
|
-
this[kContext].prefix = "";
|
|
11616
|
-
this[kContext].address = void 0;
|
|
11617
|
-
}
|
|
11618
|
-
get protocol() {
|
|
11619
|
-
return this[kContext].protocol;
|
|
11620
|
-
}
|
|
11621
|
-
set protocol(v) {
|
|
11622
|
-
if (v) {
|
|
11623
|
-
if (!schemeRegEx.test(v))
|
|
11624
|
-
throw Object.assign(new TypeError("Invalid protocol"), {
|
|
11625
|
-
protocol: v,
|
|
11626
|
-
code: "ERR_INVALID_URL"
|
|
11627
|
-
});
|
|
11628
|
-
this[kContext].protocol = v + (v.endsWith(":") ? "" : ":");
|
|
11629
|
-
} else
|
|
11630
|
-
this[kContext].protocol = "";
|
|
11631
|
-
this[kContext].address = void 0;
|
|
11632
|
-
}
|
|
11633
|
-
get username() {
|
|
11634
|
-
return this[kContext].username;
|
|
11635
|
-
}
|
|
11636
|
-
set username(v) {
|
|
11637
|
-
this[kContext].username = v ?? "";
|
|
11638
|
-
this[kContext].address = void 0;
|
|
11639
|
-
}
|
|
11640
|
-
get origin() {
|
|
11641
|
-
return this.hostname ? this.protocol + "//" + this.hostname : "";
|
|
11642
|
-
}
|
|
11643
|
-
get path() {
|
|
11644
|
-
return this[kPath];
|
|
11645
|
-
}
|
|
11646
|
-
get pathname() {
|
|
11647
|
-
if (this[kContext].pathname == null)
|
|
11648
|
-
this[kContext].pathname = "/" + this[kPath].toString();
|
|
11649
|
-
return this[kContext].pathname;
|
|
11650
|
-
}
|
|
11651
|
-
set pathname(v) {
|
|
11652
|
-
this._setPathname(v, false);
|
|
11653
|
-
}
|
|
11654
|
-
get hash() {
|
|
11655
|
-
return this[kContext].hash;
|
|
11656
|
-
}
|
|
11657
|
-
set hash(v) {
|
|
11658
|
-
this[kContext].hash = v ? v.startsWith("#") ? v : "#" + v : "";
|
|
11659
|
-
}
|
|
11660
|
-
get search() {
|
|
11661
|
-
if (this[kContext].search == null) {
|
|
11662
|
-
const s = this[kParams].toString();
|
|
11663
|
-
this[kContext].search = s ? "?" + s : "";
|
|
11664
|
-
}
|
|
11665
|
-
return this[kContext].search;
|
|
11666
|
-
}
|
|
11667
|
-
set search(v) {
|
|
11668
|
-
if (v) {
|
|
11669
|
-
this[kParams].clear();
|
|
11670
|
-
this[kParams].appendAll(v);
|
|
11671
|
-
}
|
|
11672
|
-
this[kContext].search = void 0;
|
|
11673
|
-
}
|
|
11674
|
-
get searchParams() {
|
|
11675
|
-
return this[kParams];
|
|
11676
|
-
}
|
|
11677
|
-
parse(input) {
|
|
11678
|
-
const m = urlRegEx.exec(input);
|
|
11679
|
-
if (!m)
|
|
11680
|
-
throw Object.assign(new TypeError("Invalid URL"), {
|
|
11681
|
-
input,
|
|
11682
|
-
code: "ERR_INVALID_URL"
|
|
11683
|
-
});
|
|
11684
|
-
this.protocol = m[1];
|
|
11685
|
-
const isAbsolute = !!m[2];
|
|
11686
|
-
if (isAbsolute) {
|
|
11687
|
-
let tokens = splitString4(m[2], { delimiters: "@" });
|
|
11688
|
-
if (tokens.length > 1) {
|
|
11689
|
-
this.host = tokens[1];
|
|
11690
|
-
tokens = splitString4(tokens[0], { delimiters: ":" });
|
|
11691
|
-
this.username = tokens[0] ? decodeURIComponent(tokens[0]) : "";
|
|
11692
|
-
this.password = tokens[1] ? decodeURIComponent(tokens[1]) : "";
|
|
11693
|
-
} else
|
|
11694
|
-
this.host = tokens[0];
|
|
11695
|
-
} else {
|
|
11696
|
-
this.host = "";
|
|
11697
|
-
this.username = "";
|
|
11698
|
-
this.password = "";
|
|
11699
|
-
}
|
|
11700
|
-
input = m[3] || "";
|
|
11701
|
-
let tokenizer = tokenize4(input, { delimiters: "#", quotes: true, brackets: true });
|
|
11702
|
-
input = tokenizer.next() || "";
|
|
11703
|
-
this.hash = tokenizer.join("#");
|
|
11704
|
-
tokenizer = tokenize4(input, { delimiters: "?", quotes: true, brackets: true });
|
|
11705
|
-
this._setPathname(tokenizer.next() || "", isAbsolute);
|
|
11706
|
-
this.search = tokenizer.join("&");
|
|
11707
|
-
}
|
|
11708
|
-
join(...source) {
|
|
11709
|
-
this.path.join(...source);
|
|
11710
|
-
return this;
|
|
11711
|
-
}
|
|
11712
|
-
toString() {
|
|
11713
|
-
return this.href;
|
|
11714
|
-
}
|
|
11715
|
-
/* istanbul ignore next */
|
|
11716
|
-
[(_a5 = kContext, nodeInspectCustom4)]() {
|
|
11717
|
-
return {
|
|
11718
|
-
protocol: this.protocol,
|
|
11719
|
-
username: this.username,
|
|
11720
|
-
password: this.password,
|
|
11721
|
-
host: this.host,
|
|
11722
|
-
hostname: this.hostname,
|
|
11723
|
-
origin: this.origin,
|
|
11724
|
-
pathPrefix: this.prefix,
|
|
11725
|
-
path: this.path,
|
|
11726
|
-
pathname: this.pathname,
|
|
11727
|
-
search: this.search,
|
|
11728
|
-
hash: this.hash
|
|
11729
|
-
};
|
|
11730
|
-
}
|
|
11731
|
-
//
|
|
11732
|
-
// protected _update() {
|
|
11733
|
-
// if (!this[kContext].needUpdate)
|
|
11734
|
-
// return;
|
|
11735
|
-
// const ctx = this[kContext];
|
|
11736
|
-
// ctx.needUpdate = false;
|
|
11737
|
-
// let s = this.path.toString();
|
|
11738
|
-
// ctx.pathname = s ? '/' + s : '';
|
|
11739
|
-
// s = this.searchParams.toString();
|
|
11740
|
-
// ctx.search = s ? '?' + s : '';
|
|
11741
|
-
//
|
|
11742
|
-
// let address = '';
|
|
11743
|
-
// if (ctx.hostname) {
|
|
11744
|
-
// address += (ctx.protocol || 'http:') + '//' +
|
|
11745
|
-
// (ctx.username || ctx.password
|
|
11746
|
-
// ? (
|
|
11747
|
-
// (ctx.username ? encodeURIComponent(ctx.username) : '') +
|
|
11748
|
-
// (ctx.password ? ':' + encodeURIComponent(ctx.password) : '') + '@'
|
|
11749
|
-
// )
|
|
11750
|
-
// : '') + this.host;
|
|
11751
|
-
// }
|
|
11752
|
-
// ctx.address = address + ctx.prefix + ctx.pathname;
|
|
11753
|
-
// }
|
|
11754
|
-
_setPathname(v, trimPrefix) {
|
|
11755
|
-
this.path.clear();
|
|
11756
|
-
if (!v)
|
|
11757
|
-
return;
|
|
11758
|
-
const pathTokenizer = tokenize4(normalizePath(v, true), {
|
|
11759
|
-
delimiters: "/",
|
|
11760
|
-
quotes: true,
|
|
11761
|
-
brackets: true
|
|
11762
|
-
});
|
|
11763
|
-
if (trimPrefix && this.prefix) {
|
|
11764
|
-
const prefixTokenizer = tokenize4(normalizePath(this.prefix, true), {
|
|
11765
|
-
delimiters: "/",
|
|
11766
|
-
quotes: true,
|
|
11767
|
-
brackets: true
|
|
11768
|
-
});
|
|
11769
|
-
for (const a of prefixTokenizer) {
|
|
11770
|
-
const b = pathTokenizer.next();
|
|
11771
|
-
if (a !== b)
|
|
11772
|
-
throw Object.assign(new Error("Invalid URL path. pathPrefix does not match"), { path: v, code: "ERR_INVALID_URL_PATH" });
|
|
11773
|
-
}
|
|
11774
|
-
}
|
|
11775
|
-
for (const x of pathTokenizer) {
|
|
11776
|
-
const p = decodePathComponent(x);
|
|
11777
|
-
this.path.join(p);
|
|
11778
|
-
}
|
|
11779
|
-
}
|
|
11780
|
-
};
|
|
11781
|
-
OpraURL.kContext = kContext;
|
|
11782
|
-
OpraURL.kPath = kPath;
|
|
11783
|
-
OpraURL.kParams = kParams;
|
|
11784
|
-
|
|
11785
11177
|
// ../../build/common/esm/index.js
|
|
11786
11178
|
import { uid } from "uid";
|
|
11787
11179
|
export {
|
|
@@ -11789,22 +11181,17 @@ export {
|
|
|
11789
11181
|
ApiField,
|
|
11790
11182
|
BadRequestError,
|
|
11791
11183
|
BaseI18n,
|
|
11792
|
-
BooleanCodec,
|
|
11793
11184
|
Collection2 as Collection,
|
|
11794
11185
|
ComplexType2 as ComplexType,
|
|
11795
11186
|
DataType,
|
|
11796
|
-
DateCodec,
|
|
11797
11187
|
DocumentFactory,
|
|
11798
11188
|
EnumType2 as EnumType,
|
|
11799
11189
|
FailedDependencyError,
|
|
11800
|
-
FilterCodec,
|
|
11801
11190
|
ForbiddenError,
|
|
11802
11191
|
HttpHeaderCodes,
|
|
11803
|
-
HttpParams,
|
|
11804
11192
|
HttpStatusCodes,
|
|
11805
11193
|
HttpStatusMessages,
|
|
11806
11194
|
I18n,
|
|
11807
|
-
IntegerCodec,
|
|
11808
11195
|
InternalServerError,
|
|
11809
11196
|
IssueSeverity,
|
|
11810
11197
|
METADATA_KEY,
|
|
@@ -11813,14 +11200,12 @@ export {
|
|
|
11813
11200
|
NAMESPACE_PATTERN,
|
|
11814
11201
|
NotAcceptableError,
|
|
11815
11202
|
NotFoundError,
|
|
11816
|
-
NumberCodec,
|
|
11817
11203
|
OmitType,
|
|
11818
11204
|
OpraException,
|
|
11819
11205
|
opra_filter_ns_exports as OpraFilter,
|
|
11820
11206
|
opra_schema_ns_exports as OpraSchema,
|
|
11821
11207
|
OpraURL,
|
|
11822
11208
|
OpraURLPath,
|
|
11823
|
-
OpraURLPathComponent,
|
|
11824
11209
|
PickType,
|
|
11825
11210
|
Resource,
|
|
11826
11211
|
ResourceConflictError,
|
|
@@ -11829,30 +11214,28 @@ export {
|
|
|
11829
11214
|
SimpleType2 as SimpleType,
|
|
11830
11215
|
Singleton2 as Singleton,
|
|
11831
11216
|
Storage2 as Storage,
|
|
11832
|
-
StringCodec,
|
|
11833
11217
|
TYPENAME_PATTERN,
|
|
11834
11218
|
UnauthorizedError,
|
|
11835
11219
|
UnionType2 as UnionType,
|
|
11836
11220
|
UnprocessableEntityError,
|
|
11837
11221
|
ValidationError,
|
|
11838
11222
|
cloneObject,
|
|
11839
|
-
decodePathComponent,
|
|
11840
|
-
encodePathComponent,
|
|
11841
|
-
encodeURIParam,
|
|
11842
11223
|
getStackFileName,
|
|
11843
11224
|
i18n,
|
|
11844
11225
|
inheritPropertyInitializers,
|
|
11226
|
+
isAbsoluteUrl,
|
|
11227
|
+
isAsyncIterable,
|
|
11845
11228
|
isBlob,
|
|
11846
11229
|
isConstructor,
|
|
11847
11230
|
isFormData,
|
|
11231
|
+
isIterable,
|
|
11848
11232
|
isReadable,
|
|
11849
11233
|
isReadableStream,
|
|
11850
11234
|
isStream,
|
|
11851
11235
|
isURL,
|
|
11852
|
-
|
|
11853
|
-
|
|
11236
|
+
isUrlString,
|
|
11237
|
+
isWritable,
|
|
11854
11238
|
mergePrototype,
|
|
11855
|
-
normalizePath,
|
|
11856
11239
|
omitUndefined,
|
|
11857
11240
|
pathToObjectTree,
|
|
11858
11241
|
resolveClass,
|