@redocly/cli 2.41.2 → 2.43.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/README.md +15 -0
- package/THIRD_PARTY_NOTICES +3 -2
- package/lib/chunks/32XCOMOR.js +7 -0
- package/lib/chunks/3BCHPW6T.js +22 -0
- package/lib/chunks/3VZLNQK3.js +47 -0
- package/lib/chunks/4VF6MPJJ.js +11 -0
- package/lib/chunks/55GMSQDD.js +7 -0
- package/lib/chunks/5E3VKU5T.js +7 -0
- package/lib/chunks/AE6JGTY4.js +7 -0
- package/lib/chunks/C35TOMVY.js +8 -0
- package/lib/chunks/D5T6ETPZ.js +8 -0
- package/lib/chunks/DNOXLF53.js +8 -0
- package/lib/chunks/E36IFTLX.js +59 -0
- package/lib/chunks/ECZUPR2N.js +7 -0
- package/lib/chunks/EU6GURJZ.js +7 -0
- package/lib/chunks/HXYO6QS2.js +3132 -0
- package/lib/chunks/IW4HG6VD.js +19 -0
- package/lib/chunks/KIVPQZDC.js +31 -0
- package/lib/chunks/KLY5RV3W.js +7 -0
- package/lib/chunks/KM7RL6C4.js +2317 -0
- package/lib/chunks/L3YH7RCT.js +8 -0
- package/lib/chunks/NEWT5A6S.js +159 -0
- package/lib/chunks/NGPG6D6W.js +7 -0
- package/lib/chunks/O6MCQRCP.js +59 -0
- package/lib/chunks/O6PRCLSV.js +13 -0
- package/lib/chunks/OFAMJNQ6.js +7 -0
- package/lib/chunks/P26PQ2RU.js +7 -0
- package/lib/chunks/PFD7KGH7.js +93 -0
- package/lib/chunks/QFG7TTKG.js +22 -0
- package/lib/chunks/RFWIIJFG.js +7 -0
- package/lib/chunks/RS5PUOTT.js +18 -0
- package/lib/chunks/TMQJQANP.js +7 -0
- package/lib/chunks/UPPWQBGX.js +7 -0
- package/lib/chunks/UXH3ZSSV.js +9 -0
- package/lib/chunks/UYZXI3NO.js +7 -0
- package/lib/chunks/WNTLDT6L.js +184 -0
- package/lib/chunks/WZXA5XPB.js +7 -0
- package/lib/chunks/X6IKW6K4.js +7 -0
- package/lib/index.js +226 -13885
- package/package.json +1 -1
- package/lib/chunks/3CX2Z7JI.js +0 -496
- package/lib/chunks/3UUTQVCJ.js +0 -3614
- package/lib/chunks/4FB5ZIPP.js +0 -1133
- package/lib/chunks/5ILQMFXK.js +0 -59
- package/lib/chunks/7F5O43EU.js +0 -1756
- package/lib/chunks/7IX44JLO.js +0 -16
- package/lib/chunks/7MOL2QVN.js +0 -92635
- package/lib/chunks/A3VFVVHD.js +0 -25
- package/lib/chunks/A6JSOHCP.js +0 -41
- package/lib/chunks/AIT3U3JT.js +0 -22
- package/lib/chunks/ASYQPOQY.js +0 -681
- package/lib/chunks/BVP23YP7.js +0 -13374
- package/lib/chunks/FO6BDVGE.js +0 -25
- package/lib/chunks/GFU5KGSW.js +0 -92
- package/lib/chunks/ICPYP2LP.js +0 -401
- package/lib/chunks/KPMZLKQG.js +0 -79
- package/lib/chunks/KRMBH6JF.js +0 -17902
- package/lib/chunks/NLIKC7UP.js +0 -528
- package/lib/chunks/NW3XJZXQ.js +0 -175
- package/lib/chunks/P6UGG7F6.js +0 -414
- package/lib/chunks/RRC5IDC3.js +0 -2416
- package/lib/chunks/T6UZU3XM.js +0 -17
- package/lib/chunks/TS33ZDKX.js +0 -35
- package/lib/chunks/UUU33DK3.js +0 -125
- package/lib/chunks/VUDTNFRL.js +0 -42
- package/lib/chunks/VXIQEZPR.js +0 -2564
- package/lib/chunks/W7G5WVPB.js +0 -44
- package/lib/chunks/XB6C62FW.js +0 -18497
- package/lib/chunks/XHPY6UJF.js +0 -1638
- package/lib/chunks/Y6DTFCLS.js +0 -15
- package/lib/chunks/Z2664VV5.js +0 -39331
- package/lib/chunks/Z2I5YXYN.js +0 -20272
- package/lib/chunks/ZK3QRKL5.js +0 -129
package/lib/chunks/VXIQEZPR.js
DELETED
|
@@ -1,2564 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
const require = __createRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
__commonJS,
|
|
5
|
-
__require
|
|
6
|
-
} from "./5ILQMFXK.js";
|
|
7
|
-
|
|
8
|
-
// ../../node_modules/foreach/index.js
|
|
9
|
-
var require_foreach = __commonJS({
|
|
10
|
-
"../../node_modules/foreach/index.js"(exports, module) {
|
|
11
|
-
var hasOwn = Object.prototype.hasOwnProperty;
|
|
12
|
-
var toString = Object.prototype.toString;
|
|
13
|
-
module.exports = function forEach(obj, fn, ctx) {
|
|
14
|
-
if (toString.call(fn) !== "[object Function]") {
|
|
15
|
-
throw new TypeError("iterator must be a function");
|
|
16
|
-
}
|
|
17
|
-
var l = obj.length;
|
|
18
|
-
if (l === +l) {
|
|
19
|
-
for (var i = 0; i < l; i++) {
|
|
20
|
-
fn.call(ctx, obj[i], i, obj);
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
for (var k in obj) {
|
|
24
|
-
if (hasOwn.call(obj, k)) {
|
|
25
|
-
fn.call(ctx, obj[k], k, obj);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// ../../node_modules/json-pointer/index.js
|
|
34
|
-
var require_json_pointer = __commonJS({
|
|
35
|
-
"../../node_modules/json-pointer/index.js"(exports, module) {
|
|
36
|
-
"use strict";
|
|
37
|
-
var each = require_foreach();
|
|
38
|
-
module.exports = api;
|
|
39
|
-
function api(obj, pointer, value) {
|
|
40
|
-
if (arguments.length === 3) {
|
|
41
|
-
return api.set(obj, pointer, value);
|
|
42
|
-
}
|
|
43
|
-
if (arguments.length === 2) {
|
|
44
|
-
return api.get(obj, pointer);
|
|
45
|
-
}
|
|
46
|
-
var wrapped = api.bind(api, obj);
|
|
47
|
-
for (var name in api) {
|
|
48
|
-
if (api.hasOwnProperty(name)) {
|
|
49
|
-
wrapped[name] = api[name].bind(wrapped, obj);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return wrapped;
|
|
53
|
-
}
|
|
54
|
-
api.get = function get(obj, pointer) {
|
|
55
|
-
var refTokens = Array.isArray(pointer) ? pointer : api.parse(pointer);
|
|
56
|
-
for (var i = 0; i < refTokens.length; ++i) {
|
|
57
|
-
var tok = refTokens[i];
|
|
58
|
-
if (!(typeof obj == "object" && tok in obj)) {
|
|
59
|
-
throw new Error("Invalid reference token: " + tok);
|
|
60
|
-
}
|
|
61
|
-
obj = obj[tok];
|
|
62
|
-
}
|
|
63
|
-
return obj;
|
|
64
|
-
};
|
|
65
|
-
api.set = function set(obj, pointer, value) {
|
|
66
|
-
var refTokens = Array.isArray(pointer) ? pointer : api.parse(pointer), nextTok = refTokens[0];
|
|
67
|
-
if (refTokens.length === 0) {
|
|
68
|
-
throw Error("Can not set the root object");
|
|
69
|
-
}
|
|
70
|
-
for (var i = 0; i < refTokens.length - 1; ++i) {
|
|
71
|
-
var tok = refTokens[i];
|
|
72
|
-
if (typeof tok !== "string" && typeof tok !== "number") {
|
|
73
|
-
tok = String(tok);
|
|
74
|
-
}
|
|
75
|
-
if (tok === "__proto__" || tok === "constructor" || tok === "prototype") {
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (tok === "-" && Array.isArray(obj)) {
|
|
79
|
-
tok = obj.length;
|
|
80
|
-
}
|
|
81
|
-
nextTok = refTokens[i + 1];
|
|
82
|
-
if (!(tok in obj)) {
|
|
83
|
-
if (nextTok.match(/^(\d+|-)$/)) {
|
|
84
|
-
obj[tok] = [];
|
|
85
|
-
} else {
|
|
86
|
-
obj[tok] = {};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
obj = obj[tok];
|
|
90
|
-
}
|
|
91
|
-
if (nextTok === "-" && Array.isArray(obj)) {
|
|
92
|
-
nextTok = obj.length;
|
|
93
|
-
}
|
|
94
|
-
obj[nextTok] = value;
|
|
95
|
-
return this;
|
|
96
|
-
};
|
|
97
|
-
api.remove = function(obj, pointer) {
|
|
98
|
-
var refTokens = Array.isArray(pointer) ? pointer : api.parse(pointer);
|
|
99
|
-
var finalToken = refTokens[refTokens.length - 1];
|
|
100
|
-
if (finalToken === void 0) {
|
|
101
|
-
throw new Error('Invalid JSON pointer for remove: "' + pointer + '"');
|
|
102
|
-
}
|
|
103
|
-
var parent = api.get(obj, refTokens.slice(0, -1));
|
|
104
|
-
if (Array.isArray(parent)) {
|
|
105
|
-
var index = +finalToken;
|
|
106
|
-
if (finalToken === "" && isNaN(index)) {
|
|
107
|
-
throw new Error('Invalid array index: "' + finalToken + '"');
|
|
108
|
-
}
|
|
109
|
-
Array.prototype.splice.call(parent, index, 1);
|
|
110
|
-
} else {
|
|
111
|
-
delete parent[finalToken];
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
api.dict = function dict(obj, descend) {
|
|
115
|
-
var results = {};
|
|
116
|
-
api.walk(obj, function(value, pointer) {
|
|
117
|
-
results[pointer] = value;
|
|
118
|
-
}, descend);
|
|
119
|
-
return results;
|
|
120
|
-
};
|
|
121
|
-
api.walk = function walk(obj, iterator, descend) {
|
|
122
|
-
var refTokens = [];
|
|
123
|
-
descend = descend || function(value) {
|
|
124
|
-
var type = Object.prototype.toString.call(value);
|
|
125
|
-
return type === "[object Object]" || type === "[object Array]";
|
|
126
|
-
};
|
|
127
|
-
(function next(cur) {
|
|
128
|
-
each(cur, function(value, key) {
|
|
129
|
-
refTokens.push(String(key));
|
|
130
|
-
if (descend(value)) {
|
|
131
|
-
next(value);
|
|
132
|
-
} else {
|
|
133
|
-
iterator(value, api.compile(refTokens));
|
|
134
|
-
}
|
|
135
|
-
refTokens.pop();
|
|
136
|
-
});
|
|
137
|
-
})(obj);
|
|
138
|
-
};
|
|
139
|
-
api.has = function has(obj, pointer) {
|
|
140
|
-
try {
|
|
141
|
-
api.get(obj, pointer);
|
|
142
|
-
} catch (e) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
return true;
|
|
146
|
-
};
|
|
147
|
-
api.escape = function escape(str) {
|
|
148
|
-
return str.toString().replace(/~/g, "~0").replace(/\//g, "~1");
|
|
149
|
-
};
|
|
150
|
-
api.unescape = function unescape(str) {
|
|
151
|
-
return str.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
152
|
-
};
|
|
153
|
-
api.parse = function parse(pointer) {
|
|
154
|
-
if (pointer === "") {
|
|
155
|
-
return [];
|
|
156
|
-
}
|
|
157
|
-
if (pointer.charAt(0) !== "/") {
|
|
158
|
-
throw new Error("Invalid JSON pointer: " + pointer);
|
|
159
|
-
}
|
|
160
|
-
return pointer.substring(1).split(/\//).map(api.unescape);
|
|
161
|
-
};
|
|
162
|
-
api.compile = function compile(refTokens) {
|
|
163
|
-
if (refTokens.length === 0) {
|
|
164
|
-
return "";
|
|
165
|
-
}
|
|
166
|
-
return "/" + refTokens.map(api.escape).join("/");
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// ../../node_modules/openapi-sampler/dist/openapi-sampler.js
|
|
172
|
-
var require_openapi_sampler = __commonJS({
|
|
173
|
-
"../../node_modules/openapi-sampler/dist/openapi-sampler.js"(exports, module) {
|
|
174
|
-
(function(f) {
|
|
175
|
-
if (typeof exports === "object" && typeof module !== "undefined") {
|
|
176
|
-
module.exports = f();
|
|
177
|
-
} else if (typeof define === "function" && define.amd) {
|
|
178
|
-
define([], f);
|
|
179
|
-
} else {
|
|
180
|
-
var g;
|
|
181
|
-
if (typeof window !== "undefined") {
|
|
182
|
-
g = window;
|
|
183
|
-
} else if (typeof global !== "undefined") {
|
|
184
|
-
g = global;
|
|
185
|
-
} else if (typeof self !== "undefined") {
|
|
186
|
-
g = self;
|
|
187
|
-
} else {
|
|
188
|
-
g = this;
|
|
189
|
-
}
|
|
190
|
-
g.OpenAPISampler = f();
|
|
191
|
-
}
|
|
192
|
-
})(function() {
|
|
193
|
-
var define2, module2, exports2;
|
|
194
|
-
return (/* @__PURE__ */ (function() {
|
|
195
|
-
function r(e, n, t) {
|
|
196
|
-
function o(i2, f) {
|
|
197
|
-
if (!n[i2]) {
|
|
198
|
-
if (!e[i2]) {
|
|
199
|
-
var c = "function" == typeof __require && __require;
|
|
200
|
-
if (!f && c) return c(i2, true);
|
|
201
|
-
if (u) return u(i2, true);
|
|
202
|
-
var a = new Error("Cannot find module '" + i2 + "'");
|
|
203
|
-
throw a.code = "MODULE_NOT_FOUND", a;
|
|
204
|
-
}
|
|
205
|
-
var p = n[i2] = { exports: {} };
|
|
206
|
-
e[i2][0].call(p.exports, function(r2) {
|
|
207
|
-
var n2 = e[i2][1][r2];
|
|
208
|
-
return o(n2 || r2);
|
|
209
|
-
}, p, p.exports, r, e, n, t);
|
|
210
|
-
}
|
|
211
|
-
return n[i2].exports;
|
|
212
|
-
}
|
|
213
|
-
for (var u = "function" == typeof __require && __require, i = 0; i < t.length; i++) o(t[i]);
|
|
214
|
-
return o;
|
|
215
|
-
}
|
|
216
|
-
return r;
|
|
217
|
-
})())({ 1: [function(require2, module3, exports3) {
|
|
218
|
-
(() => {
|
|
219
|
-
"use strict";
|
|
220
|
-
var t = { d: (e2, n2) => {
|
|
221
|
-
for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] });
|
|
222
|
-
}, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => {
|
|
223
|
-
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true });
|
|
224
|
-
} }, e = {};
|
|
225
|
-
t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt });
|
|
226
|
-
const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");
|
|
227
|
-
function s(t2, e2) {
|
|
228
|
-
const n2 = [];
|
|
229
|
-
let i2 = e2.exec(t2);
|
|
230
|
-
for (; i2; ) {
|
|
231
|
-
const s2 = [];
|
|
232
|
-
s2.startIndex = e2.lastIndex - i2[0].length;
|
|
233
|
-
const r2 = i2.length;
|
|
234
|
-
for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]);
|
|
235
|
-
n2.push(s2), i2 = e2.exec(t2);
|
|
236
|
-
}
|
|
237
|
-
return n2;
|
|
238
|
-
}
|
|
239
|
-
const r = function(t2) {
|
|
240
|
-
return !(null == i.exec(t2));
|
|
241
|
-
}, o = { allowBooleanAttributes: false, unpairedTags: [] };
|
|
242
|
-
function a(t2, e2) {
|
|
243
|
-
e2 = Object.assign({}, o, e2);
|
|
244
|
-
const n2 = [];
|
|
245
|
-
let i2 = false, s2 = false;
|
|
246
|
-
"\uFEFF" === t2[0] && (t2 = t2.substr(1));
|
|
247
|
-
for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) {
|
|
248
|
-
if (r2 += 2, r2 = u(t2, r2), r2.err) return r2;
|
|
249
|
-
} else {
|
|
250
|
-
if ("<" !== t2[r2]) {
|
|
251
|
-
if (l(t2[r2])) continue;
|
|
252
|
-
return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2));
|
|
253
|
-
}
|
|
254
|
-
{
|
|
255
|
-
let o2 = r2;
|
|
256
|
-
if (r2++, "!" === t2[r2]) {
|
|
257
|
-
r2 = d(t2, r2);
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
{
|
|
261
|
-
let a2 = false;
|
|
262
|
-
"/" === t2[r2] && (a2 = true, r2++);
|
|
263
|
-
let h2 = "";
|
|
264
|
-
for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2];
|
|
265
|
-
if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) {
|
|
266
|
-
let e3;
|
|
267
|
-
return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2));
|
|
268
|
-
}
|
|
269
|
-
const p2 = c(t2, r2);
|
|
270
|
-
if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2));
|
|
271
|
-
let f2 = p2.value;
|
|
272
|
-
if (r2 = p2.index, "/" === f2[f2.length - 1]) {
|
|
273
|
-
const n3 = r2 - f2.length;
|
|
274
|
-
f2 = f2.substring(0, f2.length - 1);
|
|
275
|
-
const s3 = g(f2, e2);
|
|
276
|
-
if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line));
|
|
277
|
-
i2 = true;
|
|
278
|
-
} else if (a2) {
|
|
279
|
-
if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2));
|
|
280
|
-
if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2));
|
|
281
|
-
if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2));
|
|
282
|
-
{
|
|
283
|
-
const e3 = n2.pop();
|
|
284
|
-
if (h2 !== e3.tagName) {
|
|
285
|
-
let n3 = N(t2, e3.tagStartPos);
|
|
286
|
-
return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2));
|
|
287
|
-
}
|
|
288
|
-
0 == n2.length && (s2 = true);
|
|
289
|
-
}
|
|
290
|
-
} else {
|
|
291
|
-
const a3 = g(f2, e2);
|
|
292
|
-
if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line));
|
|
293
|
-
if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2));
|
|
294
|
-
-1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true;
|
|
295
|
-
}
|
|
296
|
-
for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) {
|
|
297
|
-
if ("!" === t2[r2 + 1]) {
|
|
298
|
-
r2++, r2 = d(t2, r2);
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
if ("?" !== t2[r2 + 1]) break;
|
|
302
|
-
if (r2 = u(t2, ++r2), r2.err) return r2;
|
|
303
|
-
} else if ("&" === t2[r2]) {
|
|
304
|
-
const e3 = x(t2, r2);
|
|
305
|
-
if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2));
|
|
306
|
-
r2 = e3;
|
|
307
|
-
} else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2));
|
|
308
|
-
"<" === t2[r2] && r2--;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1);
|
|
313
|
-
}
|
|
314
|
-
function l(t2) {
|
|
315
|
-
return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2;
|
|
316
|
-
}
|
|
317
|
-
function u(t2, e2) {
|
|
318
|
-
const n2 = e2;
|
|
319
|
-
for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) {
|
|
320
|
-
const i2 = t2.substr(n2, e2 - n2);
|
|
321
|
-
if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2));
|
|
322
|
-
if ("?" == t2[e2] && ">" == t2[e2 + 1]) {
|
|
323
|
-
e2++;
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
return e2;
|
|
329
|
-
}
|
|
330
|
-
function d(t2, e2) {
|
|
331
|
-
if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) {
|
|
332
|
-
for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) {
|
|
333
|
-
e2 += 2;
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
} else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) {
|
|
337
|
-
let n2 = 1;
|
|
338
|
-
for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++;
|
|
339
|
-
else if (">" === t2[e2] && (n2--, 0 === n2)) break;
|
|
340
|
-
} else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) {
|
|
341
|
-
for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) {
|
|
342
|
-
e2 += 2;
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return e2;
|
|
347
|
-
}
|
|
348
|
-
const h = '"', p = "'";
|
|
349
|
-
function c(t2, e2) {
|
|
350
|
-
let n2 = "", i2 = "", s2 = false;
|
|
351
|
-
for (; e2 < t2.length; e2++) {
|
|
352
|
-
if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = "");
|
|
353
|
-
else if (">" === t2[e2] && "" === i2) {
|
|
354
|
-
s2 = true;
|
|
355
|
-
break;
|
|
356
|
-
}
|
|
357
|
-
n2 += t2[e2];
|
|
358
|
-
}
|
|
359
|
-
return "" === i2 && { value: n2, index: e2, tagClosed: s2 };
|
|
360
|
-
}
|
|
361
|
-
const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
362
|
-
function g(t2, e2) {
|
|
363
|
-
const n2 = s(t2, f), i2 = {};
|
|
364
|
-
for (let t3 = 0; t3 < n2.length; t3++) {
|
|
365
|
-
if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3]));
|
|
366
|
-
if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3]));
|
|
367
|
-
if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3]));
|
|
368
|
-
const s2 = n2[t3][2];
|
|
369
|
-
if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3]));
|
|
370
|
-
if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3]));
|
|
371
|
-
i2[s2] = 1;
|
|
372
|
-
}
|
|
373
|
-
return true;
|
|
374
|
-
}
|
|
375
|
-
function x(t2, e2) {
|
|
376
|
-
if (";" === t2[++e2]) return -1;
|
|
377
|
-
if ("#" === t2[e2]) return (function(t3, e3) {
|
|
378
|
-
let n3 = /\d/;
|
|
379
|
-
for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) {
|
|
380
|
-
if (";" === t3[e3]) return e3;
|
|
381
|
-
if (!t3[e3].match(n3)) break;
|
|
382
|
-
}
|
|
383
|
-
return -1;
|
|
384
|
-
})(t2, ++e2);
|
|
385
|
-
let n2 = 0;
|
|
386
|
-
for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) {
|
|
387
|
-
if (";" === t2[e2]) break;
|
|
388
|
-
return -1;
|
|
389
|
-
}
|
|
390
|
-
return e2;
|
|
391
|
-
}
|
|
392
|
-
function m(t2, e2, n2) {
|
|
393
|
-
return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } };
|
|
394
|
-
}
|
|
395
|
-
function E(t2) {
|
|
396
|
-
return r(t2);
|
|
397
|
-
}
|
|
398
|
-
function b(t2) {
|
|
399
|
-
return r(t2);
|
|
400
|
-
}
|
|
401
|
-
function N(t2, e2) {
|
|
402
|
-
const n2 = t2.substring(0, e2).split(/\r?\n/);
|
|
403
|
-
return { line: n2.length, col: n2[n2.length - 1].length + 1 };
|
|
404
|
-
}
|
|
405
|
-
function y(t2) {
|
|
406
|
-
return t2.startIndex + t2[1].length;
|
|
407
|
-
}
|
|
408
|
-
const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) {
|
|
409
|
-
return e2;
|
|
410
|
-
}, attributeValueProcessor: function(t2, e2) {
|
|
411
|
-
return e2;
|
|
412
|
-
}, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) {
|
|
413
|
-
return t2;
|
|
414
|
-
}, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true };
|
|
415
|
-
function w(t2) {
|
|
416
|
-
return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true);
|
|
417
|
-
}
|
|
418
|
-
const v = function(t2) {
|
|
419
|
-
const e2 = Object.assign({}, T, t2);
|
|
420
|
-
return e2.processEntities = w(e2.processEntities), e2;
|
|
421
|
-
};
|
|
422
|
-
let O;
|
|
423
|
-
O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata");
|
|
424
|
-
class I {
|
|
425
|
-
constructor(t2) {
|
|
426
|
-
this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null);
|
|
427
|
-
}
|
|
428
|
-
add(t2, e2) {
|
|
429
|
-
"__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 });
|
|
430
|
-
}
|
|
431
|
-
addChild(t2, e2) {
|
|
432
|
-
"__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 });
|
|
433
|
-
}
|
|
434
|
-
static getMetaDataSymbol() {
|
|
435
|
-
return O;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
class P {
|
|
439
|
-
constructor(t2) {
|
|
440
|
-
this.suppressValidationErr = !t2, this.options = t2;
|
|
441
|
-
}
|
|
442
|
-
readDocType(t2, e2) {
|
|
443
|
-
const n2 = /* @__PURE__ */ Object.create(null);
|
|
444
|
-
if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE");
|
|
445
|
-
{
|
|
446
|
-
e2 += 9;
|
|
447
|
-
let i2 = 1, s2 = false, r2 = false, o2 = "";
|
|
448
|
-
for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) {
|
|
449
|
-
if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break;
|
|
450
|
-
} else "[" === t2[e2] ? s2 = true : o2 += t2[e2];
|
|
451
|
-
else {
|
|
452
|
-
if (s2 && S(t2, "!ENTITY", e2)) {
|
|
453
|
-
let i3, s3;
|
|
454
|
-
if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) {
|
|
455
|
-
const t3 = i3.replace(/[.\-+*:]/g, "\\.");
|
|
456
|
-
n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 };
|
|
457
|
-
}
|
|
458
|
-
} else if (s2 && S(t2, "!ELEMENT", e2)) {
|
|
459
|
-
e2 += 8;
|
|
460
|
-
const { index: n3 } = this.readElementExp(t2, e2 + 1);
|
|
461
|
-
e2 = n3;
|
|
462
|
-
} else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8;
|
|
463
|
-
else if (s2 && S(t2, "!NOTATION", e2)) {
|
|
464
|
-
e2 += 9;
|
|
465
|
-
const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr);
|
|
466
|
-
e2 = n3;
|
|
467
|
-
} else {
|
|
468
|
-
if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE");
|
|
469
|
-
r2 = true;
|
|
470
|
-
}
|
|
471
|
-
i2++, o2 = "";
|
|
472
|
-
}
|
|
473
|
-
if (0 !== i2) throw new Error("Unclosed DOCTYPE");
|
|
474
|
-
}
|
|
475
|
-
return { entities: n2, i: e2 };
|
|
476
|
-
}
|
|
477
|
-
readEntityExp(t2, e2) {
|
|
478
|
-
e2 = A(t2, e2);
|
|
479
|
-
let n2 = "";
|
|
480
|
-
for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++;
|
|
481
|
-
if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) {
|
|
482
|
-
if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported");
|
|
483
|
-
if ("%" === t2[e2]) throw new Error("Parameter entities are not supported");
|
|
484
|
-
}
|
|
485
|
-
let i2 = "";
|
|
486
|
-
if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);
|
|
487
|
-
return [n2, i2, --e2];
|
|
488
|
-
}
|
|
489
|
-
readNotationExp(t2, e2) {
|
|
490
|
-
e2 = A(t2, e2);
|
|
491
|
-
let n2 = "";
|
|
492
|
-
for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++;
|
|
493
|
-
!this.suppressValidationErr && C(n2), e2 = A(t2, e2);
|
|
494
|
-
const i2 = t2.substring(e2, e2 + 6).toUpperCase();
|
|
495
|
-
if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`);
|
|
496
|
-
e2 += i2.length, e2 = A(t2, e2);
|
|
497
|
-
let s2 = null, r2 = null;
|
|
498
|
-
if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"));
|
|
499
|
-
else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
500
|
-
return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 };
|
|
501
|
-
}
|
|
502
|
-
readIdentifierVal(t2, e2, n2) {
|
|
503
|
-
let i2 = "";
|
|
504
|
-
const s2 = t2[e2];
|
|
505
|
-
if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`);
|
|
506
|
-
for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++;
|
|
507
|
-
if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`);
|
|
508
|
-
return [++e2, i2];
|
|
509
|
-
}
|
|
510
|
-
readElementExp(t2, e2) {
|
|
511
|
-
e2 = A(t2, e2);
|
|
512
|
-
let n2 = "";
|
|
513
|
-
for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++;
|
|
514
|
-
if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`);
|
|
515
|
-
let i2 = "";
|
|
516
|
-
if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4;
|
|
517
|
-
else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2;
|
|
518
|
-
else if ("(" === t2[e2]) {
|
|
519
|
-
for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++;
|
|
520
|
-
if (")" !== t2[e2]) throw new Error("Unterminated content model");
|
|
521
|
-
} else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`);
|
|
522
|
-
return { elementName: n2, contentModel: i2.trim(), index: e2 };
|
|
523
|
-
}
|
|
524
|
-
readAttlistExp(t2, e2) {
|
|
525
|
-
e2 = A(t2, e2);
|
|
526
|
-
let n2 = "";
|
|
527
|
-
for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++;
|
|
528
|
-
C(n2), e2 = A(t2, e2);
|
|
529
|
-
let i2 = "";
|
|
530
|
-
for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++;
|
|
531
|
-
if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`);
|
|
532
|
-
e2 = A(t2, e2);
|
|
533
|
-
let s2 = "";
|
|
534
|
-
if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) {
|
|
535
|
-
if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`);
|
|
536
|
-
e2++;
|
|
537
|
-
let n3 = [];
|
|
538
|
-
for (; e2 < t2.length && ")" !== t2[e2]; ) {
|
|
539
|
-
let i3 = "";
|
|
540
|
-
for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++;
|
|
541
|
-
if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`);
|
|
542
|
-
n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2));
|
|
543
|
-
}
|
|
544
|
-
if (")" !== t2[e2]) throw new Error("Unterminated list of notations");
|
|
545
|
-
e2++, s2 += " (" + n3.join("|") + ")";
|
|
546
|
-
} else {
|
|
547
|
-
for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++;
|
|
548
|
-
const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
|
|
549
|
-
if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`);
|
|
550
|
-
}
|
|
551
|
-
e2 = A(t2, e2);
|
|
552
|
-
let r2 = "";
|
|
553
|
-
return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 };
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
const A = (t2, e2) => {
|
|
557
|
-
for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++;
|
|
558
|
-
return e2;
|
|
559
|
-
};
|
|
560
|
-
function S(t2, e2, n2) {
|
|
561
|
-
for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false;
|
|
562
|
-
return true;
|
|
563
|
-
}
|
|
564
|
-
function C(t2) {
|
|
565
|
-
if (r(t2)) return t2;
|
|
566
|
-
throw new Error(`Invalid entity name ${t2}`);
|
|
567
|
-
}
|
|
568
|
-
const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true };
|
|
569
|
-
const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
|
|
570
|
-
class L {
|
|
571
|
-
constructor(t2) {
|
|
572
|
-
var e2;
|
|
573
|
-
if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => {
|
|
574
|
-
for (const n2 of e2) {
|
|
575
|
-
if ("string" == typeof n2 && t3 === n2) return true;
|
|
576
|
-
if (n2 instanceof RegExp && n2.test(t3)) return true;
|
|
577
|
-
}
|
|
578
|
-
} : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) {
|
|
579
|
-
this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set();
|
|
580
|
-
for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) {
|
|
581
|
-
const e3 = this.options.stopNodes[t3];
|
|
582
|
-
"string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3));
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
function F(t2) {
|
|
588
|
-
const e2 = Object.keys(t2);
|
|
589
|
-
for (let n2 = 0; n2 < e2.length; n2++) {
|
|
590
|
-
const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\.");
|
|
591
|
-
this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] };
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
function M(t2, e2, n2, i2, s2, r2, o2) {
|
|
595
|
-
if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) {
|
|
596
|
-
o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2));
|
|
597
|
-
const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2);
|
|
598
|
-
return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
function k(t2) {
|
|
602
|
-
if (this.options.removeNSPrefix) {
|
|
603
|
-
const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : "";
|
|
604
|
-
if ("xmlns" === e2[0]) return "";
|
|
605
|
-
2 === e2.length && (t2 = n2 + e2[1]);
|
|
606
|
-
}
|
|
607
|
-
return t2;
|
|
608
|
-
}
|
|
609
|
-
const _ = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
610
|
-
function U(t2, e2, n2) {
|
|
611
|
-
if (true !== this.options.ignoreAttributes && "string" == typeof t2) {
|
|
612
|
-
const i2 = s(t2, _), r2 = i2.length, o2 = {};
|
|
613
|
-
for (let t3 = 0; t3 < r2; t3++) {
|
|
614
|
-
const s2 = this.resolveNameSpace(i2[t3][1]);
|
|
615
|
-
if (this.ignoreAttributesFn(s2, e2)) continue;
|
|
616
|
-
let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2;
|
|
617
|
-
if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) {
|
|
618
|
-
this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2);
|
|
619
|
-
const t4 = this.options.attributeValueProcessor(s2, r3, e2);
|
|
620
|
-
o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions);
|
|
621
|
-
} else this.options.allowBooleanAttributes && (o2[a2] = true);
|
|
622
|
-
}
|
|
623
|
-
if (!Object.keys(o2).length) return;
|
|
624
|
-
if (this.options.attributesGroupName) {
|
|
625
|
-
const t3 = {};
|
|
626
|
-
return t3[this.options.attributesGroupName] = o2, t3;
|
|
627
|
-
}
|
|
628
|
-
return o2;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
const R = function(t2) {
|
|
632
|
-
t2 = t2.replace(/\r\n?/g, "\n");
|
|
633
|
-
const e2 = new I("!xml");
|
|
634
|
-
let n2 = e2, i2 = "", s2 = "";
|
|
635
|
-
this.entityExpansionCount = 0, this.currentExpandedLength = 0;
|
|
636
|
-
const r2 = new P(this.options.processEntities);
|
|
637
|
-
for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) {
|
|
638
|
-
const e3 = z(t2, ">", o2, "Closing Tag is not closed.");
|
|
639
|
-
let r3 = t2.substring(o2 + 2, e3).trim();
|
|
640
|
-
if (this.options.removeNSPrefix) {
|
|
641
|
-
const t3 = r3.indexOf(":");
|
|
642
|
-
-1 !== t3 && (r3 = r3.substr(t3 + 1));
|
|
643
|
-
}
|
|
644
|
-
this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2));
|
|
645
|
-
const a2 = s2.substring(s2.lastIndexOf(".") + 1);
|
|
646
|
-
if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: </${r3}>`);
|
|
647
|
-
let l2 = 0;
|
|
648
|
-
a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3;
|
|
649
|
-
} else if ("?" === t2[o2 + 1]) {
|
|
650
|
-
let e3 = W(t2, o2, false, "?>");
|
|
651
|
-
if (!e3) throw new Error("Pi Tag is not closed.");
|
|
652
|
-
if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ;
|
|
653
|
-
else {
|
|
654
|
-
const t3 = new I(e3.tagName);
|
|
655
|
-
t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2);
|
|
656
|
-
}
|
|
657
|
-
o2 = e3.closeIndex + 1;
|
|
658
|
-
} else if ("!--" === t2.substr(o2 + 1, 3)) {
|
|
659
|
-
const e3 = z(t2, "-->", o2 + 4, "Comment is not closed.");
|
|
660
|
-
if (this.options.commentPropName) {
|
|
661
|
-
const r3 = t2.substring(o2 + 4, e3 - 2);
|
|
662
|
-
i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]);
|
|
663
|
-
}
|
|
664
|
-
o2 = e3;
|
|
665
|
-
} else if ("!D" === t2.substr(o2 + 1, 2)) {
|
|
666
|
-
const e3 = r2.readDocType(t2, o2);
|
|
667
|
-
this.docTypeEntities = e3.entities, o2 = e3.i;
|
|
668
|
-
} else if ("![" === t2.substr(o2 + 1, 2)) {
|
|
669
|
-
const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3);
|
|
670
|
-
i2 = this.saveTextToParentTag(i2, n2, s2);
|
|
671
|
-
let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true);
|
|
672
|
-
null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2;
|
|
673
|
-
} else {
|
|
674
|
-
let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName;
|
|
675
|
-
const l2 = r3.rawTagName;
|
|
676
|
-
let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex;
|
|
677
|
-
if (this.options.transformTagName) {
|
|
678
|
-
const t3 = this.options.transformTagName(a2);
|
|
679
|
-
u2 === a2 && (u2 = t3), a2 = t3;
|
|
680
|
-
}
|
|
681
|
-
if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`);
|
|
682
|
-
n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false));
|
|
683
|
-
const p2 = n2;
|
|
684
|
-
p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2);
|
|
685
|
-
const c2 = o2;
|
|
686
|
-
if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) {
|
|
687
|
-
let e3 = "";
|
|
688
|
-
if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex;
|
|
689
|
-
else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex;
|
|
690
|
-
else {
|
|
691
|
-
const n3 = this.readStopNodeData(t2, l2, h2 + 1);
|
|
692
|
-
if (!n3) throw new Error(`Unexpected end of ${l2}`);
|
|
693
|
-
o2 = n3.i, e3 = n3.tagContent;
|
|
694
|
-
}
|
|
695
|
-
const i3 = new I(a2);
|
|
696
|
-
a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2);
|
|
697
|
-
} else {
|
|
698
|
-
if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) {
|
|
699
|
-
if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) {
|
|
700
|
-
const t4 = this.options.transformTagName(a2);
|
|
701
|
-
u2 === a2 && (u2 = t4), a2 = t4;
|
|
702
|
-
}
|
|
703
|
-
const t3 = new I(a2);
|
|
704
|
-
a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf("."));
|
|
705
|
-
} else {
|
|
706
|
-
if (-1 !== this.options.unpairedTags.indexOf(a2)) {
|
|
707
|
-
const t3 = new I(a2);
|
|
708
|
-
a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex;
|
|
709
|
-
continue;
|
|
710
|
-
}
|
|
711
|
-
{
|
|
712
|
-
const t3 = new I(a2);
|
|
713
|
-
if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded");
|
|
714
|
-
this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
i2 = "", o2 = h2;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
else i2 += t2[o2];
|
|
721
|
-
return e2.child;
|
|
722
|
-
};
|
|
723
|
-
function B(t2, e2, n2, i2) {
|
|
724
|
-
this.options.captureMetaData || (i2 = void 0);
|
|
725
|
-
const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]);
|
|
726
|
-
false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2));
|
|
727
|
-
}
|
|
728
|
-
const Y = function(t2, e2, n2) {
|
|
729
|
-
if (-1 === t2.indexOf("&")) return t2;
|
|
730
|
-
const i2 = this.options.processEntities;
|
|
731
|
-
if (!i2.enabled) return t2;
|
|
732
|
-
if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2;
|
|
733
|
-
if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2;
|
|
734
|
-
for (let e3 in this.docTypeEntities) {
|
|
735
|
-
const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx);
|
|
736
|
-
if (s2) {
|
|
737
|
-
if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`);
|
|
738
|
-
const e4 = t2.length;
|
|
739
|
-
if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
if (-1 === t2.indexOf("&")) return t2;
|
|
743
|
-
for (let e3 in this.lastEntities) {
|
|
744
|
-
const n3 = this.lastEntities[e3];
|
|
745
|
-
t2 = t2.replace(n3.regex, n3.val);
|
|
746
|
-
}
|
|
747
|
-
if (-1 === t2.indexOf("&")) return t2;
|
|
748
|
-
if (this.options.htmlEntities) for (let e3 in this.htmlEntities) {
|
|
749
|
-
const n3 = this.htmlEntities[e3];
|
|
750
|
-
t2 = t2.replace(n3.regex, n3.val);
|
|
751
|
-
}
|
|
752
|
-
return t2.replace(this.ampEntity.regex, this.ampEntity.val);
|
|
753
|
-
};
|
|
754
|
-
function G(t2, e2, n2, i2) {
|
|
755
|
-
return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2;
|
|
756
|
-
}
|
|
757
|
-
function X(t2, e2, n2, i2) {
|
|
758
|
-
return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2));
|
|
759
|
-
}
|
|
760
|
-
function z(t2, e2, n2, i2) {
|
|
761
|
-
const s2 = t2.indexOf(e2, n2);
|
|
762
|
-
if (-1 === s2) throw new Error(i2);
|
|
763
|
-
return s2 + e2.length - 1;
|
|
764
|
-
}
|
|
765
|
-
function W(t2, e2, n2, i2 = ">") {
|
|
766
|
-
const s2 = (function(t3, e3, n3 = ">") {
|
|
767
|
-
let i3, s3 = "";
|
|
768
|
-
for (let r3 = e3; r3 < t3.length; r3++) {
|
|
769
|
-
let e4 = t3[r3];
|
|
770
|
-
if (i3) e4 === i3 && (i3 = "");
|
|
771
|
-
else if ('"' === e4 || "'" === e4) i3 = e4;
|
|
772
|
-
else if (e4 === n3[0]) {
|
|
773
|
-
if (!n3[1]) return { data: s3, index: r3 };
|
|
774
|
-
if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 };
|
|
775
|
-
} else " " === e4 && (e4 = " ");
|
|
776
|
-
s3 += e4;
|
|
777
|
-
}
|
|
778
|
-
})(t2, e2 + 1, i2);
|
|
779
|
-
if (!s2) return;
|
|
780
|
-
let r2 = s2.data;
|
|
781
|
-
const o2 = s2.index, a2 = r2.search(/\s/);
|
|
782
|
-
let l2 = r2, u2 = true;
|
|
783
|
-
-1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart());
|
|
784
|
-
const d2 = l2;
|
|
785
|
-
if (n2) {
|
|
786
|
-
const t3 = l2.indexOf(":");
|
|
787
|
-
-1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1));
|
|
788
|
-
}
|
|
789
|
-
return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 };
|
|
790
|
-
}
|
|
791
|
-
function q(t2, e2, n2) {
|
|
792
|
-
const i2 = n2;
|
|
793
|
-
let s2 = 1;
|
|
794
|
-
for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) {
|
|
795
|
-
const r2 = z(t2, ">", n2, `${e2} is not closed`);
|
|
796
|
-
if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 };
|
|
797
|
-
n2 = r2;
|
|
798
|
-
} else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed.");
|
|
799
|
-
else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed.");
|
|
800
|
-
else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2;
|
|
801
|
-
else {
|
|
802
|
-
const i3 = W(t2, n2, ">");
|
|
803
|
-
i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex);
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
function Z(t2, e2, n2) {
|
|
807
|
-
if (e2 && "string" == typeof t2) {
|
|
808
|
-
const e3 = t2.trim();
|
|
809
|
-
return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) {
|
|
810
|
-
if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3;
|
|
811
|
-
let n3 = t3.trim();
|
|
812
|
-
if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3;
|
|
813
|
-
if ("0" === t3) return 0;
|
|
814
|
-
if (e4.hex && $.test(n3)) return (function(t4) {
|
|
815
|
-
if (parseInt) return parseInt(t4, 16);
|
|
816
|
-
if (Number.parseInt) return Number.parseInt(t4, 16);
|
|
817
|
-
if (window && window.parseInt) return window.parseInt(t4, 16);
|
|
818
|
-
throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
819
|
-
})(n3);
|
|
820
|
-
if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) {
|
|
821
|
-
if (!n4.eNotation) return t4;
|
|
822
|
-
const i3 = e5.match(j);
|
|
823
|
-
if (i3) {
|
|
824
|
-
let s2 = i3[1] || "";
|
|
825
|
-
const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2;
|
|
826
|
-
return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5);
|
|
827
|
-
}
|
|
828
|
-
return t4;
|
|
829
|
-
})(t3, n3, e4);
|
|
830
|
-
{
|
|
831
|
-
const s2 = V.exec(n3);
|
|
832
|
-
if (s2) {
|
|
833
|
-
const r2 = s2[1] || "", o2 = s2[2];
|
|
834
|
-
let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2;
|
|
835
|
-
const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length];
|
|
836
|
-
if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3;
|
|
837
|
-
{
|
|
838
|
-
const i3 = Number(n3), s3 = String(i3);
|
|
839
|
-
if (0 === i3) return i3;
|
|
840
|
-
if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3;
|
|
841
|
-
if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3;
|
|
842
|
-
let l3 = o2 ? a2 : n3;
|
|
843
|
-
return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3;
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
return t3;
|
|
847
|
-
}
|
|
848
|
-
var i2;
|
|
849
|
-
})(t2, n2);
|
|
850
|
-
}
|
|
851
|
-
return void 0 !== t2 ? t2 : "";
|
|
852
|
-
}
|
|
853
|
-
function K(t2, e2, n2) {
|
|
854
|
-
const i2 = Number.parseInt(t2, e2);
|
|
855
|
-
return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";";
|
|
856
|
-
}
|
|
857
|
-
const Q = I.getMetaDataSymbol();
|
|
858
|
-
function J(t2, e2) {
|
|
859
|
-
return H(t2, e2);
|
|
860
|
-
}
|
|
861
|
-
function H(t2, e2, n2) {
|
|
862
|
-
let i2;
|
|
863
|
-
const s2 = {};
|
|
864
|
-
for (let r2 = 0; r2 < t2.length; r2++) {
|
|
865
|
-
const o2 = t2[r2], a2 = tt(o2);
|
|
866
|
-
let l2 = "";
|
|
867
|
-
if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2];
|
|
868
|
-
else {
|
|
869
|
-
if (void 0 === a2) continue;
|
|
870
|
-
if (o2[a2]) {
|
|
871
|
-
let t3 = H(o2[a2], e2, l2);
|
|
872
|
-
const n3 = nt(t3, e2);
|
|
873
|
-
o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3;
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2;
|
|
878
|
-
}
|
|
879
|
-
function tt(t2) {
|
|
880
|
-
const e2 = Object.keys(t2);
|
|
881
|
-
for (let t3 = 0; t3 < e2.length; t3++) {
|
|
882
|
-
const n2 = e2[t3];
|
|
883
|
-
if (":@" !== n2) return n2;
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
function et(t2, e2, n2, i2) {
|
|
887
|
-
if (e2) {
|
|
888
|
-
const s2 = Object.keys(e2), r2 = s2.length;
|
|
889
|
-
for (let o2 = 0; o2 < r2; o2++) {
|
|
890
|
-
const r3 = s2[o2];
|
|
891
|
-
i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3];
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
function nt(t2, e2) {
|
|
896
|
-
const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length;
|
|
897
|
-
return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]);
|
|
898
|
-
}
|
|
899
|
-
class it {
|
|
900
|
-
constructor(t2) {
|
|
901
|
-
this.externalEntities = {}, this.options = v(t2);
|
|
902
|
-
}
|
|
903
|
-
parse(t2, e2) {
|
|
904
|
-
if ("string" != typeof t2 && t2.toString) t2 = t2.toString();
|
|
905
|
-
else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
906
|
-
if (e2) {
|
|
907
|
-
true === e2 && (e2 = {});
|
|
908
|
-
const n3 = a(t2, e2);
|
|
909
|
-
if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`);
|
|
910
|
-
}
|
|
911
|
-
const n2 = new L(this.options);
|
|
912
|
-
n2.addExternalEntities(this.externalEntities);
|
|
913
|
-
const i2 = n2.parseXml(t2);
|
|
914
|
-
return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options);
|
|
915
|
-
}
|
|
916
|
-
addEntity(t2, e2) {
|
|
917
|
-
if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'");
|
|
918
|
-
if (-1 !== t2.indexOf("&") || -1 !== t2.indexOf(";")) throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");
|
|
919
|
-
if ("&" === e2) throw new Error("An entity with value '&' is not permitted");
|
|
920
|
-
this.externalEntities[t2] = e2;
|
|
921
|
-
}
|
|
922
|
-
static getMetaDataSymbol() {
|
|
923
|
-
return I.getMetaDataSymbol();
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
function st(t2, e2) {
|
|
927
|
-
let n2 = "";
|
|
928
|
-
return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2);
|
|
929
|
-
}
|
|
930
|
-
function rt(t2, e2, n2, i2) {
|
|
931
|
-
let s2 = "", r2 = false;
|
|
932
|
-
if (!Array.isArray(t2)) {
|
|
933
|
-
if (null != t2) {
|
|
934
|
-
let n3 = t2.toString();
|
|
935
|
-
return n3 = ut(n3, e2), n3;
|
|
936
|
-
}
|
|
937
|
-
return "";
|
|
938
|
-
}
|
|
939
|
-
for (let o2 = 0; o2 < t2.length; o2++) {
|
|
940
|
-
const a2 = t2[o2], l2 = ot(a2);
|
|
941
|
-
if (void 0 === l2) continue;
|
|
942
|
-
let u2 = "";
|
|
943
|
-
if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) {
|
|
944
|
-
let t3 = a2[l2];
|
|
945
|
-
lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false;
|
|
946
|
-
continue;
|
|
947
|
-
}
|
|
948
|
-
if (l2 === e2.cdataPropName) {
|
|
949
|
-
r2 && (s2 += i2), s2 += `<![CDATA[${a2[l2][0][e2.textNodeName]}]]>`, r2 = false;
|
|
950
|
-
continue;
|
|
951
|
-
}
|
|
952
|
-
if (l2 === e2.commentPropName) {
|
|
953
|
-
s2 += i2 + `<!--${a2[l2][0][e2.textNodeName]}-->`, r2 = true;
|
|
954
|
-
continue;
|
|
955
|
-
}
|
|
956
|
-
if ("?" === l2[0]) {
|
|
957
|
-
const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2;
|
|
958
|
-
let o3 = a2[l2][0][e2.textNodeName];
|
|
959
|
-
o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true;
|
|
960
|
-
continue;
|
|
961
|
-
}
|
|
962
|
-
let d2 = i2;
|
|
963
|
-
"" !== d2 && (d2 += e2.indentBy);
|
|
964
|
-
const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2);
|
|
965
|
-
-1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}</${l2}>` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("</")) ? s2 += i2 + e2.indentBy + p2 + i2 : s2 += p2, s2 += `</${l2}>`) : s2 += h2 + "/>", r2 = true;
|
|
966
|
-
}
|
|
967
|
-
return s2;
|
|
968
|
-
}
|
|
969
|
-
function ot(t2) {
|
|
970
|
-
const e2 = Object.keys(t2);
|
|
971
|
-
for (let n2 = 0; n2 < e2.length; n2++) {
|
|
972
|
-
const i2 = e2[n2];
|
|
973
|
-
if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2;
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
function at(t2, e2) {
|
|
977
|
-
let n2 = "";
|
|
978
|
-
if (t2 && !e2.ignoreAttributes) for (let i2 in t2) {
|
|
979
|
-
if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue;
|
|
980
|
-
let s2 = e2.attributeValueProcessor(i2, t2[i2]);
|
|
981
|
-
s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`;
|
|
982
|
-
}
|
|
983
|
-
return n2;
|
|
984
|
-
}
|
|
985
|
-
function lt(t2, e2) {
|
|
986
|
-
let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1);
|
|
987
|
-
for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true;
|
|
988
|
-
return false;
|
|
989
|
-
}
|
|
990
|
-
function ut(t2, e2) {
|
|
991
|
-
if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) {
|
|
992
|
-
const i2 = e2.entities[n2];
|
|
993
|
-
t2 = t2.replace(i2.regex, i2.val);
|
|
994
|
-
}
|
|
995
|
-
return t2;
|
|
996
|
-
}
|
|
997
|
-
const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) {
|
|
998
|
-
return e2;
|
|
999
|
-
}, attributeValueProcessor: function(t2, e2) {
|
|
1000
|
-
return e2;
|
|
1001
|
-
}, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false };
|
|
1002
|
-
function ht(t2) {
|
|
1003
|
-
var e2;
|
|
1004
|
-
this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() {
|
|
1005
|
-
return false;
|
|
1006
|
-
} : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => {
|
|
1007
|
-
for (const n2 of e2) {
|
|
1008
|
-
if ("string" == typeof n2 && t3 === n2) return true;
|
|
1009
|
-
if (n2 instanceof RegExp && n2.test(t3)) return true;
|
|
1010
|
-
}
|
|
1011
|
-
} : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() {
|
|
1012
|
-
return "";
|
|
1013
|
-
}, this.tagEndChar = ">", this.newLine = "");
|
|
1014
|
-
}
|
|
1015
|
-
function pt(t2, e2, n2, i2) {
|
|
1016
|
-
const s2 = this.j2x(t2, n2 + 1, i2.concat(e2));
|
|
1017
|
-
return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2);
|
|
1018
|
-
}
|
|
1019
|
-
function ct(t2) {
|
|
1020
|
-
return this.options.indentBy.repeat(t2);
|
|
1021
|
-
}
|
|
1022
|
-
function ft(t2) {
|
|
1023
|
-
return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen);
|
|
1024
|
-
}
|
|
1025
|
-
ht.prototype.build = function(t2) {
|
|
1026
|
-
return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val);
|
|
1027
|
-
}, ht.prototype.j2x = function(t2, e2, n2) {
|
|
1028
|
-
let i2 = "", s2 = "";
|
|
1029
|
-
const r2 = n2.join(".");
|
|
1030
|
-
for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += "");
|
|
1031
|
-
else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar;
|
|
1032
|
-
else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2);
|
|
1033
|
-
else if ("object" != typeof t2[o2]) {
|
|
1034
|
-
const n3 = this.isAttribute(o2);
|
|
1035
|
-
if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]);
|
|
1036
|
-
else if (!n3) if (o2 === this.options.textNodeName) {
|
|
1037
|
-
let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]);
|
|
1038
|
-
s2 += this.replaceEntitiesValue(e3);
|
|
1039
|
-
} else s2 += this.buildTextValNode(t2[o2], o2, "", e2);
|
|
1040
|
-
} else if (Array.isArray(t2[o2])) {
|
|
1041
|
-
const i3 = t2[o2].length;
|
|
1042
|
-
let r3 = "", a2 = "";
|
|
1043
|
-
for (let l2 = 0; l2 < i3; l2++) {
|
|
1044
|
-
const i4 = t2[o2][l2];
|
|
1045
|
-
if (void 0 === i4) ;
|
|
1046
|
-
else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar;
|
|
1047
|
-
else if ("object" == typeof i4) if (this.options.oneListGroup) {
|
|
1048
|
-
const t3 = this.j2x(i4, e2 + 1, n2.concat(o2));
|
|
1049
|
-
r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr);
|
|
1050
|
-
} else r3 += this.processTextOrObjNode(i4, o2, e2, n2);
|
|
1051
|
-
else if (this.options.oneListGroup) {
|
|
1052
|
-
let t3 = this.options.tagValueProcessor(o2, i4);
|
|
1053
|
-
t3 = this.replaceEntitiesValue(t3), r3 += t3;
|
|
1054
|
-
} else r3 += this.buildTextValNode(i4, o2, "", e2);
|
|
1055
|
-
}
|
|
1056
|
-
this.options.oneListGroup && (r3 = this.buildObjectNode(r3, o2, a2, e2)), s2 += r3;
|
|
1057
|
-
} else if (this.options.attributesGroupName && o2 === this.options.attributesGroupName) {
|
|
1058
|
-
const e3 = Object.keys(t2[o2]), n3 = e3.length;
|
|
1059
|
-
for (let s3 = 0; s3 < n3; s3++) i2 += this.buildAttrPairStr(e3[s3], "" + t2[o2][e3[s3]]);
|
|
1060
|
-
} else s2 += this.processTextOrObjNode(t2[o2], o2, e2, n2);
|
|
1061
|
-
return { attrStr: i2, val: s2 };
|
|
1062
|
-
}, ht.prototype.buildAttrPairStr = function(t2, e2) {
|
|
1063
|
-
return e2 = this.options.attributeValueProcessor(t2, "" + e2), e2 = this.replaceEntitiesValue(e2), this.options.suppressBooleanAttributes && "true" === e2 ? " " + t2 : " " + t2 + '="' + e2 + '"';
|
|
1064
|
-
}, ht.prototype.buildObjectNode = function(t2, e2, n2, i2) {
|
|
1065
|
-
if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar;
|
|
1066
|
-
{
|
|
1067
|
-
let s2 = "</" + e2 + this.tagEndChar, r2 = "";
|
|
1068
|
-
return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `<!--${t2}-->` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2;
|
|
1069
|
-
}
|
|
1070
|
-
}, ht.prototype.closeTag = function(t2) {
|
|
1071
|
-
let e2 = "";
|
|
1072
|
-
return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `></${t2}`, e2;
|
|
1073
|
-
}, ht.prototype.buildTextValNode = function(t2, e2, n2, i2) {
|
|
1074
|
-
if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(i2) + `<![CDATA[${t2}]]>` + this.newLine;
|
|
1075
|
-
if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `<!--${t2}-->` + this.newLine;
|
|
1076
|
-
if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar;
|
|
1077
|
-
{
|
|
1078
|
-
let s2 = this.options.tagValueProcessor(e2, t2);
|
|
1079
|
-
return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "</" + e2 + this.tagEndChar;
|
|
1080
|
-
}
|
|
1081
|
-
}, ht.prototype.replaceEntitiesValue = function(t2) {
|
|
1082
|
-
if (t2 && t2.length > 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) {
|
|
1083
|
-
const n2 = this.options.entities[e2];
|
|
1084
|
-
t2 = t2.replace(n2.regex, n2.val);
|
|
1085
|
-
}
|
|
1086
|
-
return t2;
|
|
1087
|
-
};
|
|
1088
|
-
const gt = ht, xt = { validate: a };
|
|
1089
|
-
module3.exports = e;
|
|
1090
|
-
})();
|
|
1091
|
-
}, {}], 2: [function(require2, module3, exports3) {
|
|
1092
|
-
var hasOwn = Object.prototype.hasOwnProperty;
|
|
1093
|
-
var toString = Object.prototype.toString;
|
|
1094
|
-
module3.exports = function forEach(obj, fn, ctx) {
|
|
1095
|
-
if (toString.call(fn) !== "[object Function]") {
|
|
1096
|
-
throw new TypeError("iterator must be a function");
|
|
1097
|
-
}
|
|
1098
|
-
var l = obj.length;
|
|
1099
|
-
if (l === +l) {
|
|
1100
|
-
for (var i = 0; i < l; i++) {
|
|
1101
|
-
fn.call(ctx, obj[i], i, obj);
|
|
1102
|
-
}
|
|
1103
|
-
} else {
|
|
1104
|
-
for (var k in obj) {
|
|
1105
|
-
if (hasOwn.call(obj, k)) {
|
|
1106
|
-
fn.call(ctx, obj[k], k, obj);
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
};
|
|
1111
|
-
}, {}], 3: [function(require2, module3, exports3) {
|
|
1112
|
-
"use strict";
|
|
1113
|
-
var each = require2("foreach");
|
|
1114
|
-
module3.exports = api;
|
|
1115
|
-
function api(obj, pointer, value) {
|
|
1116
|
-
if (arguments.length === 3) {
|
|
1117
|
-
return api.set(obj, pointer, value);
|
|
1118
|
-
}
|
|
1119
|
-
if (arguments.length === 2) {
|
|
1120
|
-
return api.get(obj, pointer);
|
|
1121
|
-
}
|
|
1122
|
-
var wrapped = api.bind(api, obj);
|
|
1123
|
-
for (var name in api) {
|
|
1124
|
-
if (api.hasOwnProperty(name)) {
|
|
1125
|
-
wrapped[name] = api[name].bind(wrapped, obj);
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
return wrapped;
|
|
1129
|
-
}
|
|
1130
|
-
api.get = function get(obj, pointer) {
|
|
1131
|
-
var refTokens = Array.isArray(pointer) ? pointer : api.parse(pointer);
|
|
1132
|
-
for (var i = 0; i < refTokens.length; ++i) {
|
|
1133
|
-
var tok = refTokens[i];
|
|
1134
|
-
if (!(typeof obj == "object" && tok in obj)) {
|
|
1135
|
-
throw new Error("Invalid reference token: " + tok);
|
|
1136
|
-
}
|
|
1137
|
-
obj = obj[tok];
|
|
1138
|
-
}
|
|
1139
|
-
return obj;
|
|
1140
|
-
};
|
|
1141
|
-
api.set = function set(obj, pointer, value) {
|
|
1142
|
-
var refTokens = Array.isArray(pointer) ? pointer : api.parse(pointer), nextTok = refTokens[0];
|
|
1143
|
-
if (refTokens.length === 0) {
|
|
1144
|
-
throw Error("Can not set the root object");
|
|
1145
|
-
}
|
|
1146
|
-
for (var i = 0; i < refTokens.length - 1; ++i) {
|
|
1147
|
-
var tok = refTokens[i];
|
|
1148
|
-
if (typeof tok !== "string" && typeof tok !== "number") {
|
|
1149
|
-
tok = String(tok);
|
|
1150
|
-
}
|
|
1151
|
-
if (tok === "__proto__" || tok === "constructor" || tok === "prototype") {
|
|
1152
|
-
continue;
|
|
1153
|
-
}
|
|
1154
|
-
if (tok === "-" && Array.isArray(obj)) {
|
|
1155
|
-
tok = obj.length;
|
|
1156
|
-
}
|
|
1157
|
-
nextTok = refTokens[i + 1];
|
|
1158
|
-
if (!(tok in obj)) {
|
|
1159
|
-
if (nextTok.match(/^(\d+|-)$/)) {
|
|
1160
|
-
obj[tok] = [];
|
|
1161
|
-
} else {
|
|
1162
|
-
obj[tok] = {};
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
obj = obj[tok];
|
|
1166
|
-
}
|
|
1167
|
-
if (nextTok === "-" && Array.isArray(obj)) {
|
|
1168
|
-
nextTok = obj.length;
|
|
1169
|
-
}
|
|
1170
|
-
obj[nextTok] = value;
|
|
1171
|
-
return this;
|
|
1172
|
-
};
|
|
1173
|
-
api.remove = function(obj, pointer) {
|
|
1174
|
-
var refTokens = Array.isArray(pointer) ? pointer : api.parse(pointer);
|
|
1175
|
-
var finalToken = refTokens[refTokens.length - 1];
|
|
1176
|
-
if (finalToken === void 0) {
|
|
1177
|
-
throw new Error('Invalid JSON pointer for remove: "' + pointer + '"');
|
|
1178
|
-
}
|
|
1179
|
-
var parent = api.get(obj, refTokens.slice(0, -1));
|
|
1180
|
-
if (Array.isArray(parent)) {
|
|
1181
|
-
var index = +finalToken;
|
|
1182
|
-
if (finalToken === "" && isNaN(index)) {
|
|
1183
|
-
throw new Error('Invalid array index: "' + finalToken + '"');
|
|
1184
|
-
}
|
|
1185
|
-
Array.prototype.splice.call(parent, index, 1);
|
|
1186
|
-
} else {
|
|
1187
|
-
delete parent[finalToken];
|
|
1188
|
-
}
|
|
1189
|
-
};
|
|
1190
|
-
api.dict = function dict(obj, descend) {
|
|
1191
|
-
var results = {};
|
|
1192
|
-
api.walk(obj, function(value, pointer) {
|
|
1193
|
-
results[pointer] = value;
|
|
1194
|
-
}, descend);
|
|
1195
|
-
return results;
|
|
1196
|
-
};
|
|
1197
|
-
api.walk = function walk(obj, iterator, descend) {
|
|
1198
|
-
var refTokens = [];
|
|
1199
|
-
descend = descend || function(value) {
|
|
1200
|
-
var type = Object.prototype.toString.call(value);
|
|
1201
|
-
return type === "[object Object]" || type === "[object Array]";
|
|
1202
|
-
};
|
|
1203
|
-
(function next(cur) {
|
|
1204
|
-
each(cur, function(value, key) {
|
|
1205
|
-
refTokens.push(String(key));
|
|
1206
|
-
if (descend(value)) {
|
|
1207
|
-
next(value);
|
|
1208
|
-
} else {
|
|
1209
|
-
iterator(value, api.compile(refTokens));
|
|
1210
|
-
}
|
|
1211
|
-
refTokens.pop();
|
|
1212
|
-
});
|
|
1213
|
-
})(obj);
|
|
1214
|
-
};
|
|
1215
|
-
api.has = function has(obj, pointer) {
|
|
1216
|
-
try {
|
|
1217
|
-
api.get(obj, pointer);
|
|
1218
|
-
} catch (e) {
|
|
1219
|
-
return false;
|
|
1220
|
-
}
|
|
1221
|
-
return true;
|
|
1222
|
-
};
|
|
1223
|
-
api.escape = function escape(str) {
|
|
1224
|
-
return str.toString().replace(/~/g, "~0").replace(/\//g, "~1");
|
|
1225
|
-
};
|
|
1226
|
-
api.unescape = function unescape(str) {
|
|
1227
|
-
return str.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1228
|
-
};
|
|
1229
|
-
api.parse = function parse(pointer) {
|
|
1230
|
-
if (pointer === "") {
|
|
1231
|
-
return [];
|
|
1232
|
-
}
|
|
1233
|
-
if (pointer.charAt(0) !== "/") {
|
|
1234
|
-
throw new Error("Invalid JSON pointer: " + pointer);
|
|
1235
|
-
}
|
|
1236
|
-
return pointer.substring(1).split(/\//).map(api.unescape);
|
|
1237
|
-
};
|
|
1238
|
-
api.compile = function compile(refTokens) {
|
|
1239
|
-
if (refTokens.length === 0) {
|
|
1240
|
-
return "";
|
|
1241
|
-
}
|
|
1242
|
-
return "/" + refTokens.map(api.escape).join("/");
|
|
1243
|
-
};
|
|
1244
|
-
}, { "foreach": 2 }], 4: [function(require2, module3, exports3) {
|
|
1245
|
-
"use strict";
|
|
1246
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
1247
|
-
value: true
|
|
1248
|
-
});
|
|
1249
|
-
exports3.allOfSample = allOfSample;
|
|
1250
|
-
var _traverse = require2("./traverse");
|
|
1251
|
-
var _utils = require2("./utils");
|
|
1252
|
-
function ownKeys(e, r) {
|
|
1253
|
-
var t = Object.keys(e);
|
|
1254
|
-
if (Object.getOwnPropertySymbols) {
|
|
1255
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
1256
|
-
r && (o = o.filter(function(r2) {
|
|
1257
|
-
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
1258
|
-
})), t.push.apply(t, o);
|
|
1259
|
-
}
|
|
1260
|
-
return t;
|
|
1261
|
-
}
|
|
1262
|
-
function _objectSpread(e) {
|
|
1263
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
1264
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
1265
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
1266
|
-
_defineProperty(e, r2, t[r2]);
|
|
1267
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
1268
|
-
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
1269
|
-
});
|
|
1270
|
-
}
|
|
1271
|
-
return e;
|
|
1272
|
-
}
|
|
1273
|
-
function _defineProperty(e, r, t) {
|
|
1274
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
1275
|
-
}
|
|
1276
|
-
function _toPropertyKey(t) {
|
|
1277
|
-
var i = _toPrimitive(t, "string");
|
|
1278
|
-
return "symbol" == typeof i ? i : i + "";
|
|
1279
|
-
}
|
|
1280
|
-
function _toPrimitive(t, r) {
|
|
1281
|
-
if ("object" != typeof t || !t) return t;
|
|
1282
|
-
var e = t[Symbol.toPrimitive];
|
|
1283
|
-
if (void 0 !== e) {
|
|
1284
|
-
var i = e.call(t, r || "default");
|
|
1285
|
-
if ("object" != typeof i) return i;
|
|
1286
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1287
|
-
}
|
|
1288
|
-
return ("string" === r ? String : Number)(t);
|
|
1289
|
-
}
|
|
1290
|
-
function allOfSample(into, children, options, spec, context) {
|
|
1291
|
-
let res = (0, _traverse.traverse)(into, options, spec);
|
|
1292
|
-
const subSamples = [];
|
|
1293
|
-
for (let subSchema of children) {
|
|
1294
|
-
const {
|
|
1295
|
-
type,
|
|
1296
|
-
readOnly,
|
|
1297
|
-
writeOnly,
|
|
1298
|
-
value
|
|
1299
|
-
} = (0, _traverse.traverse)(_objectSpread({
|
|
1300
|
-
type: res.type
|
|
1301
|
-
}, subSchema), options, spec, _objectSpread(_objectSpread({}, context), {}, {
|
|
1302
|
-
isAllOfChild: true
|
|
1303
|
-
}));
|
|
1304
|
-
if (res.type && type && type !== res.type) {
|
|
1305
|
-
console.warn("allOf: schemas with different types can't be merged");
|
|
1306
|
-
res.type = type;
|
|
1307
|
-
}
|
|
1308
|
-
res.type = res.type || type;
|
|
1309
|
-
res.readOnly = res.readOnly || readOnly;
|
|
1310
|
-
res.writeOnly = res.writeOnly || writeOnly;
|
|
1311
|
-
if (value != null) subSamples.push(value);
|
|
1312
|
-
}
|
|
1313
|
-
if (res.type === "object") {
|
|
1314
|
-
res.value = (0, _utils.mergeDeep)(res.value || {}, ...subSamples.filter((sample) => typeof sample === "object"));
|
|
1315
|
-
for (const key in res.value) {
|
|
1316
|
-
if (res.value[key] === _utils.SKIP_SYMBOL) {
|
|
1317
|
-
delete res.value[key];
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
return res;
|
|
1321
|
-
} else {
|
|
1322
|
-
if (res.type === "array") {
|
|
1323
|
-
if (!options.quiet) console.warn('OpenAPI Sampler: found allOf with "array" type. Result may be incorrect');
|
|
1324
|
-
}
|
|
1325
|
-
const lastSample = subSamples[subSamples.length - 1];
|
|
1326
|
-
res.value = lastSample != null ? lastSample : res.value;
|
|
1327
|
-
return res;
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
}, { "./traverse": 14, "./utils": 15 }], 5: [function(require2, module3, exports3) {
|
|
1331
|
-
"use strict";
|
|
1332
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
1333
|
-
value: true
|
|
1334
|
-
});
|
|
1335
|
-
exports3.inferType = inferType;
|
|
1336
|
-
const schemaKeywordTypes = {
|
|
1337
|
-
multipleOf: "number",
|
|
1338
|
-
maximum: "number",
|
|
1339
|
-
exclusiveMaximum: "number",
|
|
1340
|
-
minimum: "number",
|
|
1341
|
-
exclusiveMinimum: "number",
|
|
1342
|
-
maxLength: "string",
|
|
1343
|
-
minLength: "string",
|
|
1344
|
-
pattern: "string",
|
|
1345
|
-
items: "array",
|
|
1346
|
-
maxItems: "array",
|
|
1347
|
-
minItems: "array",
|
|
1348
|
-
uniqueItems: "array",
|
|
1349
|
-
additionalItems: "array",
|
|
1350
|
-
maxProperties: "object",
|
|
1351
|
-
minProperties: "object",
|
|
1352
|
-
required: "object",
|
|
1353
|
-
additionalProperties: "object",
|
|
1354
|
-
properties: "object",
|
|
1355
|
-
patternProperties: "object",
|
|
1356
|
-
dependencies: "object"
|
|
1357
|
-
};
|
|
1358
|
-
function inferType(schema) {
|
|
1359
|
-
if (schema.type !== void 0) {
|
|
1360
|
-
return Array.isArray(schema.type) ? schema.type.length === 0 ? null : schema.type[0] : schema.type;
|
|
1361
|
-
}
|
|
1362
|
-
const keywords = Object.keys(schemaKeywordTypes);
|
|
1363
|
-
for (var i = 0; i < keywords.length; i++) {
|
|
1364
|
-
let keyword = keywords[i];
|
|
1365
|
-
let type = schemaKeywordTypes[keyword];
|
|
1366
|
-
if (schema[keyword] !== void 0) {
|
|
1367
|
-
return type;
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
return null;
|
|
1371
|
-
}
|
|
1372
|
-
}, {}], 6: [function(require2, module3, exports3) {
|
|
1373
|
-
"use strict";
|
|
1374
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
1375
|
-
value: true
|
|
1376
|
-
});
|
|
1377
|
-
exports3._registerSampler = _registerSampler;
|
|
1378
|
-
exports3._samplers = void 0;
|
|
1379
|
-
Object.defineProperty(exports3, "inferType", {
|
|
1380
|
-
enumerable: true,
|
|
1381
|
-
get: function() {
|
|
1382
|
-
return _infer.inferType;
|
|
1383
|
-
}
|
|
1384
|
-
});
|
|
1385
|
-
exports3.sample = sample;
|
|
1386
|
-
var _traverse = require2("./traverse");
|
|
1387
|
-
var _index = require2("./samplers/index");
|
|
1388
|
-
var _fastXmlParser = require2("fast-xml-parser");
|
|
1389
|
-
var _infer = require2("./infer");
|
|
1390
|
-
var _samplers = exports3._samplers = {};
|
|
1391
|
-
const defaults = {
|
|
1392
|
-
skipReadOnly: false,
|
|
1393
|
-
maxSampleDepth: 15
|
|
1394
|
-
};
|
|
1395
|
-
function convertJsonToXml(obj, schema) {
|
|
1396
|
-
if (!obj) {
|
|
1397
|
-
throw new Error("Unknown format output for building XML.");
|
|
1398
|
-
}
|
|
1399
|
-
if (Array.isArray(obj) || Object.keys(obj).length > 1) {
|
|
1400
|
-
var _schema$xml;
|
|
1401
|
-
obj = {
|
|
1402
|
-
[(schema === null || schema === void 0 || (_schema$xml = schema.xml) === null || _schema$xml === void 0 ? void 0 : _schema$xml.name) || "root"]: obj
|
|
1403
|
-
};
|
|
1404
|
-
}
|
|
1405
|
-
const builder = new _fastXmlParser.XMLBuilder({
|
|
1406
|
-
ignoreAttributes: false,
|
|
1407
|
-
format: true,
|
|
1408
|
-
attributeNamePrefix: "$",
|
|
1409
|
-
textNodeName: "#text",
|
|
1410
|
-
cdataPropName: "#cdata"
|
|
1411
|
-
});
|
|
1412
|
-
return builder.build(obj);
|
|
1413
|
-
}
|
|
1414
|
-
function sample(schema, options, spec) {
|
|
1415
|
-
let opts = Object.assign({}, defaults, options);
|
|
1416
|
-
(0, _traverse.clearCache)();
|
|
1417
|
-
let result = (0, _traverse.traverse)(schema, opts, spec).value;
|
|
1418
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.format) === "xml") {
|
|
1419
|
-
return convertJsonToXml(result, schema);
|
|
1420
|
-
}
|
|
1421
|
-
return result;
|
|
1422
|
-
}
|
|
1423
|
-
;
|
|
1424
|
-
function _registerSampler(type, sampler) {
|
|
1425
|
-
_samplers[type] = sampler;
|
|
1426
|
-
}
|
|
1427
|
-
;
|
|
1428
|
-
_registerSampler("array", _index.sampleArray);
|
|
1429
|
-
_registerSampler("boolean", _index.sampleBoolean);
|
|
1430
|
-
_registerSampler("integer", _index.sampleNumber);
|
|
1431
|
-
_registerSampler("number", _index.sampleNumber);
|
|
1432
|
-
_registerSampler("object", _index.sampleObject);
|
|
1433
|
-
_registerSampler("string", _index.sampleString);
|
|
1434
|
-
}, { "./infer": 5, "./samplers/index": 9, "./traverse": 14, "fast-xml-parser": 1 }], 7: [function(require2, module3, exports3) {
|
|
1435
|
-
"use strict";
|
|
1436
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
1437
|
-
value: true
|
|
1438
|
-
});
|
|
1439
|
-
exports3.sampleArray = sampleArray;
|
|
1440
|
-
var _traverse = require2("../traverse");
|
|
1441
|
-
var _utils = require2("../utils");
|
|
1442
|
-
function ownKeys(e, r) {
|
|
1443
|
-
var t = Object.keys(e);
|
|
1444
|
-
if (Object.getOwnPropertySymbols) {
|
|
1445
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
1446
|
-
r && (o = o.filter(function(r2) {
|
|
1447
|
-
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
1448
|
-
})), t.push.apply(t, o);
|
|
1449
|
-
}
|
|
1450
|
-
return t;
|
|
1451
|
-
}
|
|
1452
|
-
function _objectSpread(e) {
|
|
1453
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
1454
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
1455
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
1456
|
-
_defineProperty(e, r2, t[r2]);
|
|
1457
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
1458
|
-
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
1459
|
-
});
|
|
1460
|
-
}
|
|
1461
|
-
return e;
|
|
1462
|
-
}
|
|
1463
|
-
function _defineProperty(e, r, t) {
|
|
1464
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
1465
|
-
}
|
|
1466
|
-
function _toPropertyKey(t) {
|
|
1467
|
-
var i = _toPrimitive(t, "string");
|
|
1468
|
-
return "symbol" == typeof i ? i : i + "";
|
|
1469
|
-
}
|
|
1470
|
-
function _toPrimitive(t, r) {
|
|
1471
|
-
if ("object" != typeof t || !t) return t;
|
|
1472
|
-
var e = t[Symbol.toPrimitive];
|
|
1473
|
-
if (void 0 !== e) {
|
|
1474
|
-
var i = e.call(t, r || "default");
|
|
1475
|
-
if ("object" != typeof i) return i;
|
|
1476
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1477
|
-
}
|
|
1478
|
-
return ("string" === r ? String : Number)(t);
|
|
1479
|
-
}
|
|
1480
|
-
function sampleArray(schema) {
|
|
1481
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1482
|
-
let spec = arguments.length > 2 ? arguments[2] : void 0;
|
|
1483
|
-
let context = arguments.length > 3 ? arguments[3] : void 0;
|
|
1484
|
-
const depth = context && context.depth || 1;
|
|
1485
|
-
let arrayLength = Math.min(schema.maxItems != void 0 ? schema.maxItems : Infinity, schema.minItems || 1);
|
|
1486
|
-
const items = schema.prefixItems || schema.items || schema.contains;
|
|
1487
|
-
if (Array.isArray(items)) {
|
|
1488
|
-
arrayLength = Math.max(arrayLength, items.length);
|
|
1489
|
-
}
|
|
1490
|
-
let itemSchemaGetter = (itemNumber) => {
|
|
1491
|
-
if (Array.isArray(items)) {
|
|
1492
|
-
return items[itemNumber] || {};
|
|
1493
|
-
}
|
|
1494
|
-
return items || {};
|
|
1495
|
-
};
|
|
1496
|
-
let res = [];
|
|
1497
|
-
if (!items) return res;
|
|
1498
|
-
for (let i = 0; i < arrayLength; i++) {
|
|
1499
|
-
let itemSchema = itemSchemaGetter(i);
|
|
1500
|
-
let {
|
|
1501
|
-
value: sample
|
|
1502
|
-
} = (0, _traverse.traverse)(itemSchema, options, spec, {
|
|
1503
|
-
depth: depth + 1
|
|
1504
|
-
});
|
|
1505
|
-
if ((options === null || options === void 0 ? void 0 : options.format) === "xml") {
|
|
1506
|
-
const {
|
|
1507
|
-
value,
|
|
1508
|
-
propertyName
|
|
1509
|
-
} = (0, _utils.applyXMLAttributes)({
|
|
1510
|
-
value: sample
|
|
1511
|
-
}, itemSchema, context);
|
|
1512
|
-
if (propertyName) {
|
|
1513
|
-
var _res;
|
|
1514
|
-
if (!((_res = res) !== null && _res !== void 0 && _res[propertyName])) {
|
|
1515
|
-
res = _objectSpread(_objectSpread({}, res), {}, {
|
|
1516
|
-
[propertyName]: []
|
|
1517
|
-
});
|
|
1518
|
-
}
|
|
1519
|
-
res[propertyName].push(value);
|
|
1520
|
-
} else {
|
|
1521
|
-
res = _objectSpread(_objectSpread({}, res), value);
|
|
1522
|
-
}
|
|
1523
|
-
} else {
|
|
1524
|
-
res.push(sample);
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
if ((options === null || options === void 0 ? void 0 : options.format) === "xml" && depth === 1) {
|
|
1528
|
-
const {
|
|
1529
|
-
value,
|
|
1530
|
-
propertyName
|
|
1531
|
-
} = (0, _utils.applyXMLAttributes)({
|
|
1532
|
-
value: null
|
|
1533
|
-
}, schema, context);
|
|
1534
|
-
if (propertyName) {
|
|
1535
|
-
if (value) {
|
|
1536
|
-
res = Array.isArray(res) ? {
|
|
1537
|
-
[propertyName]: _objectSpread(_objectSpread({}, value), res.map((item) => ({
|
|
1538
|
-
["#text"]: _objectSpread({}, item)
|
|
1539
|
-
})))
|
|
1540
|
-
} : {
|
|
1541
|
-
[propertyName]: _objectSpread(_objectSpread({}, res), value)
|
|
1542
|
-
};
|
|
1543
|
-
} else {
|
|
1544
|
-
res = {
|
|
1545
|
-
[propertyName]: res
|
|
1546
|
-
};
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
return res;
|
|
1551
|
-
}
|
|
1552
|
-
}, { "../traverse": 14, "../utils": 15 }], 8: [function(require2, module3, exports3) {
|
|
1553
|
-
"use strict";
|
|
1554
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
1555
|
-
value: true
|
|
1556
|
-
});
|
|
1557
|
-
exports3.sampleBoolean = sampleBoolean;
|
|
1558
|
-
function sampleBoolean(schema) {
|
|
1559
|
-
return true;
|
|
1560
|
-
}
|
|
1561
|
-
}, {}], 9: [function(require2, module3, exports3) {
|
|
1562
|
-
"use strict";
|
|
1563
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
1564
|
-
value: true
|
|
1565
|
-
});
|
|
1566
|
-
Object.defineProperty(exports3, "sampleArray", {
|
|
1567
|
-
enumerable: true,
|
|
1568
|
-
get: function() {
|
|
1569
|
-
return _array.sampleArray;
|
|
1570
|
-
}
|
|
1571
|
-
});
|
|
1572
|
-
Object.defineProperty(exports3, "sampleBoolean", {
|
|
1573
|
-
enumerable: true,
|
|
1574
|
-
get: function() {
|
|
1575
|
-
return _boolean.sampleBoolean;
|
|
1576
|
-
}
|
|
1577
|
-
});
|
|
1578
|
-
Object.defineProperty(exports3, "sampleNumber", {
|
|
1579
|
-
enumerable: true,
|
|
1580
|
-
get: function() {
|
|
1581
|
-
return _number.sampleNumber;
|
|
1582
|
-
}
|
|
1583
|
-
});
|
|
1584
|
-
Object.defineProperty(exports3, "sampleObject", {
|
|
1585
|
-
enumerable: true,
|
|
1586
|
-
get: function() {
|
|
1587
|
-
return _object.sampleObject;
|
|
1588
|
-
}
|
|
1589
|
-
});
|
|
1590
|
-
Object.defineProperty(exports3, "sampleString", {
|
|
1591
|
-
enumerable: true,
|
|
1592
|
-
get: function() {
|
|
1593
|
-
return _string.sampleString;
|
|
1594
|
-
}
|
|
1595
|
-
});
|
|
1596
|
-
var _array = require2("./array");
|
|
1597
|
-
var _boolean = require2("./boolean");
|
|
1598
|
-
var _number = require2("./number");
|
|
1599
|
-
var _object = require2("./object");
|
|
1600
|
-
var _string = require2("./string");
|
|
1601
|
-
}, { "./array": 7, "./boolean": 8, "./number": 10, "./object": 11, "./string": 13 }], 10: [function(require2, module3, exports3) {
|
|
1602
|
-
"use strict";
|
|
1603
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
1604
|
-
value: true
|
|
1605
|
-
});
|
|
1606
|
-
exports3.sampleNumber = sampleNumber;
|
|
1607
|
-
function sampleNumber(schema) {
|
|
1608
|
-
let res = 0;
|
|
1609
|
-
if (schema.type === "number" && (schema.format === "float" || schema.format === "double")) {
|
|
1610
|
-
res = 0.1;
|
|
1611
|
-
}
|
|
1612
|
-
if (typeof schema.exclusiveMinimum === "boolean" || typeof schema.exclusiveMaximum === "boolean") {
|
|
1613
|
-
if (schema.maximum && schema.minimum) {
|
|
1614
|
-
res = schema.exclusiveMinimum ? Math.floor(schema.minimum) + 1 : schema.minimum;
|
|
1615
|
-
if (schema.exclusiveMaximum && res >= schema.maximum || !schema.exclusiveMaximum && res > schema.maximum) {
|
|
1616
|
-
res = (schema.maximum + schema.minimum) / 2;
|
|
1617
|
-
}
|
|
1618
|
-
return res;
|
|
1619
|
-
}
|
|
1620
|
-
if (schema.minimum) {
|
|
1621
|
-
if (schema.exclusiveMinimum) {
|
|
1622
|
-
return Math.floor(schema.minimum) + 1;
|
|
1623
|
-
} else {
|
|
1624
|
-
return schema.minimum;
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
if (schema.maximum) {
|
|
1628
|
-
if (schema.exclusiveMaximum) {
|
|
1629
|
-
return schema.maximum > 0 ? 0 : Math.floor(schema.maximum) - 1;
|
|
1630
|
-
} else {
|
|
1631
|
-
return schema.maximum > 0 ? 0 : schema.maximum;
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
} else {
|
|
1635
|
-
if (schema.minimum) {
|
|
1636
|
-
return schema.minimum;
|
|
1637
|
-
}
|
|
1638
|
-
if (schema.exclusiveMinimum) {
|
|
1639
|
-
res = Math.floor(schema.exclusiveMinimum) + 1;
|
|
1640
|
-
if (res === schema.exclusiveMaximum) {
|
|
1641
|
-
res = (res + Math.floor(schema.exclusiveMaximum) - 1) / 2;
|
|
1642
|
-
}
|
|
1643
|
-
} else if (schema.exclusiveMaximum) {
|
|
1644
|
-
res = Math.floor(schema.exclusiveMaximum) - 1;
|
|
1645
|
-
} else if (schema.maximum) {
|
|
1646
|
-
res = schema.maximum;
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
|
-
return res;
|
|
1650
|
-
}
|
|
1651
|
-
}, {}], 11: [function(require2, module3, exports3) {
|
|
1652
|
-
"use strict";
|
|
1653
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
1654
|
-
value: true
|
|
1655
|
-
});
|
|
1656
|
-
exports3.sampleObject = sampleObject;
|
|
1657
|
-
var _traverse = require2("../traverse");
|
|
1658
|
-
var _utils = require2("../utils");
|
|
1659
|
-
function ownKeys(e, r) {
|
|
1660
|
-
var t = Object.keys(e);
|
|
1661
|
-
if (Object.getOwnPropertySymbols) {
|
|
1662
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
1663
|
-
r && (o = o.filter(function(r2) {
|
|
1664
|
-
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
1665
|
-
})), t.push.apply(t, o);
|
|
1666
|
-
}
|
|
1667
|
-
return t;
|
|
1668
|
-
}
|
|
1669
|
-
function _objectSpread(e) {
|
|
1670
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
1671
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
1672
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
1673
|
-
_defineProperty(e, r2, t[r2]);
|
|
1674
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
1675
|
-
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
1676
|
-
});
|
|
1677
|
-
}
|
|
1678
|
-
return e;
|
|
1679
|
-
}
|
|
1680
|
-
function _defineProperty(e, r, t) {
|
|
1681
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
1682
|
-
}
|
|
1683
|
-
function _toPropertyKey(t) {
|
|
1684
|
-
var i = _toPrimitive(t, "string");
|
|
1685
|
-
return "symbol" == typeof i ? i : i + "";
|
|
1686
|
-
}
|
|
1687
|
-
function _toPrimitive(t, r) {
|
|
1688
|
-
if ("object" != typeof t || !t) return t;
|
|
1689
|
-
var e = t[Symbol.toPrimitive];
|
|
1690
|
-
if (void 0 !== e) {
|
|
1691
|
-
var i = e.call(t, r || "default");
|
|
1692
|
-
if ("object" != typeof i) return i;
|
|
1693
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1694
|
-
}
|
|
1695
|
-
return ("string" === r ? String : Number)(t);
|
|
1696
|
-
}
|
|
1697
|
-
function sampleObject(schema) {
|
|
1698
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1699
|
-
let spec = arguments.length > 2 ? arguments[2] : void 0;
|
|
1700
|
-
let context = arguments.length > 3 ? arguments[3] : void 0;
|
|
1701
|
-
let res = {};
|
|
1702
|
-
const depth = context && context.depth || 1;
|
|
1703
|
-
if (schema && typeof schema.properties === "object") {
|
|
1704
|
-
const requiredProperties = Array.isArray(schema.required) ? schema.required : [];
|
|
1705
|
-
const requiredPropertiesMap = {};
|
|
1706
|
-
for (const requiredProperty of requiredProperties) {
|
|
1707
|
-
requiredPropertiesMap[requiredProperty] = true;
|
|
1708
|
-
}
|
|
1709
|
-
Object.keys(schema.properties).forEach((propertyName) => {
|
|
1710
|
-
if (options.skipNonRequired && !requiredPropertiesMap.hasOwnProperty(propertyName)) {
|
|
1711
|
-
return;
|
|
1712
|
-
}
|
|
1713
|
-
const sample = (0, _traverse.traverse)(schema.properties[propertyName], options, spec, {
|
|
1714
|
-
propertyName,
|
|
1715
|
-
depth: depth + 1
|
|
1716
|
-
});
|
|
1717
|
-
if (options.skipReadOnly && sample.readOnly) {
|
|
1718
|
-
if (context !== null && context !== void 0 && context.isAllOfChild) {
|
|
1719
|
-
res[propertyName] = _utils.SKIP_SYMBOL;
|
|
1720
|
-
}
|
|
1721
|
-
return;
|
|
1722
|
-
}
|
|
1723
|
-
if (options.skipWriteOnly && sample.writeOnly) {
|
|
1724
|
-
if (context !== null && context !== void 0 && context.isAllOfChild) {
|
|
1725
|
-
res[propertyName] = _utils.SKIP_SYMBOL;
|
|
1726
|
-
}
|
|
1727
|
-
return;
|
|
1728
|
-
}
|
|
1729
|
-
if ((options === null || options === void 0 ? void 0 : options.format) === "xml") {
|
|
1730
|
-
const {
|
|
1731
|
-
propertyName: newPropertyName,
|
|
1732
|
-
value
|
|
1733
|
-
} = (0, _utils.applyXMLAttributes)(sample, schema.properties[propertyName], {
|
|
1734
|
-
propertyName
|
|
1735
|
-
});
|
|
1736
|
-
if (newPropertyName) {
|
|
1737
|
-
res[newPropertyName] = value;
|
|
1738
|
-
} else if (value !== null && typeof value === "object") {
|
|
1739
|
-
res = _objectSpread(_objectSpread({}, res), value);
|
|
1740
|
-
}
|
|
1741
|
-
} else {
|
|
1742
|
-
res[propertyName] = sample.value;
|
|
1743
|
-
}
|
|
1744
|
-
});
|
|
1745
|
-
}
|
|
1746
|
-
if (schema && typeof schema.additionalProperties === "object") {
|
|
1747
|
-
const propertyName = schema.additionalProperties["x-additionalPropertiesName"] || "property";
|
|
1748
|
-
res["".concat(String(propertyName), "1")] = (0, _traverse.traverse)(schema.additionalProperties, options, spec, {
|
|
1749
|
-
depth: depth + 1
|
|
1750
|
-
}).value;
|
|
1751
|
-
res["".concat(String(propertyName), "2")] = (0, _traverse.traverse)(schema.additionalProperties, options, spec, {
|
|
1752
|
-
depth: depth + 1
|
|
1753
|
-
}).value;
|
|
1754
|
-
}
|
|
1755
|
-
if (schema && typeof schema.properties === "object" && schema.maxProperties !== void 0 && Object.keys(res).length > schema.maxProperties) {
|
|
1756
|
-
const filteredResult = {};
|
|
1757
|
-
let propertiesAdded = 0;
|
|
1758
|
-
const requiredProperties = Array.isArray(schema.required) ? schema.required : [];
|
|
1759
|
-
requiredProperties.forEach((propName) => {
|
|
1760
|
-
if (res[propName] !== void 0) {
|
|
1761
|
-
filteredResult[propName] = res[propName];
|
|
1762
|
-
propertiesAdded++;
|
|
1763
|
-
}
|
|
1764
|
-
});
|
|
1765
|
-
Object.keys(res).forEach((propName) => {
|
|
1766
|
-
if (propertiesAdded < schema.maxProperties && !filteredResult.hasOwnProperty(propName)) {
|
|
1767
|
-
filteredResult[propName] = res[propName];
|
|
1768
|
-
propertiesAdded++;
|
|
1769
|
-
}
|
|
1770
|
-
});
|
|
1771
|
-
res = filteredResult;
|
|
1772
|
-
}
|
|
1773
|
-
return res;
|
|
1774
|
-
}
|
|
1775
|
-
}, { "../traverse": 14, "../utils": 15 }], 12: [function(require2, module3, exports3) {
|
|
1776
|
-
"use strict";
|
|
1777
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
1778
|
-
value: true
|
|
1779
|
-
});
|
|
1780
|
-
exports3.regexSample = regexSample;
|
|
1781
|
-
function boolSample() {
|
|
1782
|
-
return true;
|
|
1783
|
-
}
|
|
1784
|
-
function intSample(min, _max) {
|
|
1785
|
-
return min;
|
|
1786
|
-
}
|
|
1787
|
-
function getRepetitionsBasedOnQuantifierParameters(quantifierSymbol, quantifierMin, quantifierMax) {
|
|
1788
|
-
let repetitions = 1;
|
|
1789
|
-
if (quantifierSymbol) {
|
|
1790
|
-
switch (quantifierSymbol) {
|
|
1791
|
-
case "?": {
|
|
1792
|
-
repetitions = boolSample() ? 0 : 1;
|
|
1793
|
-
break;
|
|
1794
|
-
}
|
|
1795
|
-
case "*": {
|
|
1796
|
-
const limit = 8;
|
|
1797
|
-
repetitions = intSample(0, limit);
|
|
1798
|
-
break;
|
|
1799
|
-
}
|
|
1800
|
-
case "+": {
|
|
1801
|
-
const limit = 8;
|
|
1802
|
-
repetitions = intSample(1, limit);
|
|
1803
|
-
break;
|
|
1804
|
-
}
|
|
1805
|
-
default:
|
|
1806
|
-
throw new Error("Unknown quantifier symbol provided.");
|
|
1807
|
-
}
|
|
1808
|
-
} else if (quantifierMin != null && quantifierMax != null) {
|
|
1809
|
-
repetitions = intSample(parseInt(quantifierMin), parseInt(quantifierMax));
|
|
1810
|
-
} else if (quantifierMin != null && quantifierMax == null) {
|
|
1811
|
-
repetitions = parseInt(quantifierMin);
|
|
1812
|
-
}
|
|
1813
|
-
return repetitions;
|
|
1814
|
-
}
|
|
1815
|
-
function regexSample(pattern) {
|
|
1816
|
-
let isCaseInsensitive = false;
|
|
1817
|
-
if (pattern instanceof RegExp) {
|
|
1818
|
-
var _pattern$match$, _pattern$match;
|
|
1819
|
-
isCaseInsensitive = pattern.flags.includes("i");
|
|
1820
|
-
pattern = pattern.toString();
|
|
1821
|
-
pattern = (_pattern$match$ = (_pattern$match = pattern.match(/\/(.+?)\//)) === null || _pattern$match === void 0 ? void 0 : _pattern$match[1]) !== null && _pattern$match$ !== void 0 ? _pattern$match$ : "";
|
|
1822
|
-
}
|
|
1823
|
-
pattern = pattern.replace(/^(\^)?(.*?)(\$)?$/, "$2");
|
|
1824
|
-
let min;
|
|
1825
|
-
let max;
|
|
1826
|
-
let repetitions;
|
|
1827
|
-
const SINGLE_CHAR_REG = /([.A-Za-z0-9])(?:\{(\d+)(?:\,(\d+)|)\}|(\?|\*|\+))(?![^[]*]|[^{]*})/;
|
|
1828
|
-
let token = pattern.match(SINGLE_CHAR_REG);
|
|
1829
|
-
while (token != null) {
|
|
1830
|
-
const quantifierMin = token[2];
|
|
1831
|
-
const quantifierMax = token[3];
|
|
1832
|
-
const quantifierSymbol = token[4];
|
|
1833
|
-
repetitions = getRepetitionsBasedOnQuantifierParameters(quantifierSymbol, quantifierMin, quantifierMax);
|
|
1834
|
-
pattern = pattern.slice(0, token.index) + token[1].repeat(repetitions) + pattern.slice(token.index + token[0].length);
|
|
1835
|
-
token = pattern.match(SINGLE_CHAR_REG);
|
|
1836
|
-
}
|
|
1837
|
-
const SINGLE_RANGE_REG = /(\d-\d|\w-\w|\d|\w|[-!@#$&()`.+,/"])/;
|
|
1838
|
-
const RANGE_ALPHANUMEMRIC_REG = /\[(\^|)(-|)(.+?)\](?:\{(\d+)(?:\,(\d+)|)\}|(\?|\*|\+)|)/;
|
|
1839
|
-
token = pattern.match(RANGE_ALPHANUMEMRIC_REG);
|
|
1840
|
-
while (token != null) {
|
|
1841
|
-
const isNegated = token[1] === "^";
|
|
1842
|
-
const includesDash = token[2] === "-";
|
|
1843
|
-
const quantifierMin = token[4];
|
|
1844
|
-
const quantifierMax = token[5];
|
|
1845
|
-
const quantifierSymbol = token[6];
|
|
1846
|
-
const rangeCodes = [];
|
|
1847
|
-
let ranges = token[3];
|
|
1848
|
-
let range = ranges.match(SINGLE_RANGE_REG);
|
|
1849
|
-
if (includesDash) {
|
|
1850
|
-
rangeCodes.push(45);
|
|
1851
|
-
}
|
|
1852
|
-
while (range != null) {
|
|
1853
|
-
if (range[0].indexOf("-") === -1) {
|
|
1854
|
-
if (isCaseInsensitive && isNaN(Number(range[0]))) {
|
|
1855
|
-
rangeCodes.push(range[0].toUpperCase().charCodeAt(0));
|
|
1856
|
-
rangeCodes.push(range[0].toLowerCase().charCodeAt(0));
|
|
1857
|
-
} else {
|
|
1858
|
-
rangeCodes.push(range[0].charCodeAt(0));
|
|
1859
|
-
}
|
|
1860
|
-
} else {
|
|
1861
|
-
const rangeMinMax = range[0].split("-").map((x) => x.charCodeAt(0));
|
|
1862
|
-
min = rangeMinMax[0];
|
|
1863
|
-
max = rangeMinMax[1];
|
|
1864
|
-
if (min > max) {
|
|
1865
|
-
throw new Error("Character range provided is out of order.");
|
|
1866
|
-
}
|
|
1867
|
-
for (let i = min; i <= max; i++) {
|
|
1868
|
-
if (isCaseInsensitive && isNaN(Number(String.fromCharCode(i)))) {
|
|
1869
|
-
const ch = String.fromCharCode(i);
|
|
1870
|
-
rangeCodes.push(ch.toUpperCase().charCodeAt(0));
|
|
1871
|
-
rangeCodes.push(ch.toLowerCase().charCodeAt(0));
|
|
1872
|
-
} else {
|
|
1873
|
-
rangeCodes.push(i);
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
ranges = ranges.substring(range[0].length);
|
|
1878
|
-
range = ranges.match(SINGLE_RANGE_REG);
|
|
1879
|
-
}
|
|
1880
|
-
repetitions = getRepetitionsBasedOnQuantifierParameters(quantifierSymbol, quantifierMin, quantifierMax);
|
|
1881
|
-
if (isNegated) {
|
|
1882
|
-
let index = -1;
|
|
1883
|
-
for (let i = 48; i <= 57; i++) {
|
|
1884
|
-
index = rangeCodes.indexOf(i);
|
|
1885
|
-
if (index > -1) {
|
|
1886
|
-
rangeCodes.splice(index, 1);
|
|
1887
|
-
continue;
|
|
1888
|
-
}
|
|
1889
|
-
rangeCodes.push(i);
|
|
1890
|
-
}
|
|
1891
|
-
for (let i = 65; i <= 90; i++) {
|
|
1892
|
-
index = rangeCodes.indexOf(i);
|
|
1893
|
-
if (index > -1) {
|
|
1894
|
-
rangeCodes.splice(index, 1);
|
|
1895
|
-
continue;
|
|
1896
|
-
}
|
|
1897
|
-
rangeCodes.push(i);
|
|
1898
|
-
}
|
|
1899
|
-
for (let i = 97; i <= 122; i++) {
|
|
1900
|
-
index = rangeCodes.indexOf(i);
|
|
1901
|
-
if (index > -1) {
|
|
1902
|
-
rangeCodes.splice(index, 1);
|
|
1903
|
-
continue;
|
|
1904
|
-
}
|
|
1905
|
-
rangeCodes.push(i);
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
const generatedString = Array.from({
|
|
1909
|
-
length: repetitions
|
|
1910
|
-
}, () => String.fromCharCode(rangeCodes[intSample(0, rangeCodes.length - 1)])).join("");
|
|
1911
|
-
pattern = pattern.slice(0, token.index) + generatedString + pattern.slice(token.index + token[0].length);
|
|
1912
|
-
token = pattern.match(RANGE_ALPHANUMEMRIC_REG);
|
|
1913
|
-
}
|
|
1914
|
-
const RANGE_REP_REG = /(.)\{(\d+)\,(\d+)\}/;
|
|
1915
|
-
token = pattern.match(RANGE_REP_REG);
|
|
1916
|
-
while (token != null) {
|
|
1917
|
-
min = parseInt(token[2]);
|
|
1918
|
-
max = parseInt(token[3]);
|
|
1919
|
-
if (min > max) {
|
|
1920
|
-
throw new Error("Numbers out of order in {} quantifier.");
|
|
1921
|
-
}
|
|
1922
|
-
repetitions = intSample(min, max);
|
|
1923
|
-
pattern = pattern.slice(0, token.index) + token[1].repeat(repetitions) + pattern.slice(token.index + token[0].length);
|
|
1924
|
-
token = pattern.match(RANGE_REP_REG);
|
|
1925
|
-
}
|
|
1926
|
-
const REP_REG = /(.)\{(\d+)\}/;
|
|
1927
|
-
token = pattern.match(REP_REG);
|
|
1928
|
-
while (token != null) {
|
|
1929
|
-
repetitions = parseInt(token[2]);
|
|
1930
|
-
pattern = pattern.slice(0, token.index) + token[1].repeat(repetitions) + pattern.slice(token.index + token[0].length);
|
|
1931
|
-
token = pattern.match(REP_REG);
|
|
1932
|
-
}
|
|
1933
|
-
return pattern;
|
|
1934
|
-
}
|
|
1935
|
-
}, {}], 13: [function(require2, module3, exports3) {
|
|
1936
|
-
"use strict";
|
|
1937
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
1938
|
-
value: true
|
|
1939
|
-
});
|
|
1940
|
-
exports3.sampleString = sampleString;
|
|
1941
|
-
var _utils = require2("../utils");
|
|
1942
|
-
var faker = _interopRequireWildcard(require2("./string-regex"));
|
|
1943
|
-
function _interopRequireWildcard(e, t) {
|
|
1944
|
-
if ("function" == typeof WeakMap) var r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap();
|
|
1945
|
-
return (_interopRequireWildcard = function(e2, t2) {
|
|
1946
|
-
if (!t2 && e2 && e2.__esModule) return e2;
|
|
1947
|
-
var o, i, f = { __proto__: null, default: e2 };
|
|
1948
|
-
if (null === e2 || "object" != typeof e2 && "function" != typeof e2) return f;
|
|
1949
|
-
if (o = t2 ? n : r) {
|
|
1950
|
-
if (o.has(e2)) return o.get(e2);
|
|
1951
|
-
o.set(e2, f);
|
|
1952
|
-
}
|
|
1953
|
-
for (const t3 in e2) "default" !== t3 && {}.hasOwnProperty.call(e2, t3) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e2, t3)) && (i.get || i.set) ? o(f, t3, i) : f[t3] = e2[t3]);
|
|
1954
|
-
return f;
|
|
1955
|
-
})(e, t);
|
|
1956
|
-
}
|
|
1957
|
-
const passwordSymbols = "qwerty!@#$%^123456";
|
|
1958
|
-
function emailSample() {
|
|
1959
|
-
return "user@example.com";
|
|
1960
|
-
}
|
|
1961
|
-
function idnEmailSample() {
|
|
1962
|
-
return "\u043F\u043E\u0448\u0442\u0430@\u0443\u043A\u0440.\u043D\u0435\u0442";
|
|
1963
|
-
}
|
|
1964
|
-
function passwordSample(min, max) {
|
|
1965
|
-
let res = "pa$$word";
|
|
1966
|
-
if (min > res.length) {
|
|
1967
|
-
res += "_";
|
|
1968
|
-
res += (0, _utils.ensureMinLength)(passwordSymbols, min - res.length).substring(0, min - res.length);
|
|
1969
|
-
}
|
|
1970
|
-
return res;
|
|
1971
|
-
}
|
|
1972
|
-
function commonDateTimeSample(_ref) {
|
|
1973
|
-
let {
|
|
1974
|
-
min,
|
|
1975
|
-
max,
|
|
1976
|
-
omitTime,
|
|
1977
|
-
omitDate
|
|
1978
|
-
} = _ref;
|
|
1979
|
-
let res = (0, _utils.toRFCDateTime)(/* @__PURE__ */ new Date("2019-08-24T14:15:22.123Z"), omitTime, omitDate, false);
|
|
1980
|
-
if (res.length < min) {
|
|
1981
|
-
console.warn("Using minLength = ".concat(min, ' is incorrect with format "date-time"'));
|
|
1982
|
-
}
|
|
1983
|
-
if (max && res.length > max) {
|
|
1984
|
-
console.warn("Using maxLength = ".concat(max, ' is incorrect with format "date-time"'));
|
|
1985
|
-
}
|
|
1986
|
-
return res;
|
|
1987
|
-
}
|
|
1988
|
-
function dateTimeSample(min, max) {
|
|
1989
|
-
return commonDateTimeSample({
|
|
1990
|
-
min,
|
|
1991
|
-
max,
|
|
1992
|
-
omitTime: false,
|
|
1993
|
-
omitDate: false
|
|
1994
|
-
});
|
|
1995
|
-
}
|
|
1996
|
-
function dateSample(min, max) {
|
|
1997
|
-
return commonDateTimeSample({
|
|
1998
|
-
min,
|
|
1999
|
-
max,
|
|
2000
|
-
omitTime: true,
|
|
2001
|
-
omitDate: false
|
|
2002
|
-
});
|
|
2003
|
-
}
|
|
2004
|
-
function timeSample(min, max) {
|
|
2005
|
-
return commonDateTimeSample({
|
|
2006
|
-
min,
|
|
2007
|
-
max,
|
|
2008
|
-
omitTime: false,
|
|
2009
|
-
omitDate: true
|
|
2010
|
-
}).slice(1);
|
|
2011
|
-
}
|
|
2012
|
-
function defaultSample(min, max, _propertyName, pattern) {
|
|
2013
|
-
let enablePatterns = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
|
|
2014
|
-
if (pattern && enablePatterns) {
|
|
2015
|
-
return faker.regexSample(pattern);
|
|
2016
|
-
}
|
|
2017
|
-
let res = (0, _utils.ensureMinLength)("string", min);
|
|
2018
|
-
if (max && res.length > max) {
|
|
2019
|
-
res = res.substring(0, max);
|
|
2020
|
-
}
|
|
2021
|
-
return res;
|
|
2022
|
-
}
|
|
2023
|
-
function ipv4Sample() {
|
|
2024
|
-
return "192.168.0.1";
|
|
2025
|
-
}
|
|
2026
|
-
function ipv6Sample() {
|
|
2027
|
-
return "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
|
|
2028
|
-
}
|
|
2029
|
-
function hostnameSample() {
|
|
2030
|
-
return "example.com";
|
|
2031
|
-
}
|
|
2032
|
-
function idnHostnameSample() {
|
|
2033
|
-
return "\u043F\u0440\u0438\u043A\u043B\u0430\u0434.\u0443\u043A\u0440";
|
|
2034
|
-
}
|
|
2035
|
-
function uriSample() {
|
|
2036
|
-
return "http://example.com";
|
|
2037
|
-
}
|
|
2038
|
-
function uriReferenceSample() {
|
|
2039
|
-
return "../dictionary";
|
|
2040
|
-
}
|
|
2041
|
-
function uriTemplateSample() {
|
|
2042
|
-
return "http://example.com/{endpoint}";
|
|
2043
|
-
}
|
|
2044
|
-
function iriSample() {
|
|
2045
|
-
return "http://example.com/entity/1";
|
|
2046
|
-
}
|
|
2047
|
-
function iriReferenceSample() {
|
|
2048
|
-
return "/entity/1";
|
|
2049
|
-
}
|
|
2050
|
-
function uuidSample(_min, _max, propertyName) {
|
|
2051
|
-
return (0, _utils.uuid)(propertyName || "id");
|
|
2052
|
-
}
|
|
2053
|
-
function jsonPointerSample() {
|
|
2054
|
-
return "/json/pointer";
|
|
2055
|
-
}
|
|
2056
|
-
function relativeJsonPointerSample() {
|
|
2057
|
-
return "1/relative/json/pointer";
|
|
2058
|
-
}
|
|
2059
|
-
function regexSample() {
|
|
2060
|
-
return "/regex/";
|
|
2061
|
-
}
|
|
2062
|
-
const stringFormats = {
|
|
2063
|
-
"email": emailSample,
|
|
2064
|
-
"idn-email": idnEmailSample,
|
|
2065
|
-
// https://tools.ietf.org/html/rfc6531#section-3.3
|
|
2066
|
-
"password": passwordSample,
|
|
2067
|
-
"date-time": dateTimeSample,
|
|
2068
|
-
"date": dateSample,
|
|
2069
|
-
"time": timeSample,
|
|
2070
|
-
// full-time in https://tools.ietf.org/html/rfc3339#section-5.6
|
|
2071
|
-
"ipv4": ipv4Sample,
|
|
2072
|
-
"ipv6": ipv6Sample,
|
|
2073
|
-
"hostname": hostnameSample,
|
|
2074
|
-
"idn-hostname": idnHostnameSample,
|
|
2075
|
-
// https://tools.ietf.org/html/rfc5890#section-2.3.2.3
|
|
2076
|
-
"iri": iriSample,
|
|
2077
|
-
// https://tools.ietf.org/html/rfc3987
|
|
2078
|
-
"iri-reference": iriReferenceSample,
|
|
2079
|
-
"uri": uriSample,
|
|
2080
|
-
"uri-reference": uriReferenceSample,
|
|
2081
|
-
// either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1
|
|
2082
|
-
"uri-template": uriTemplateSample,
|
|
2083
|
-
"uuid": uuidSample,
|
|
2084
|
-
"default": defaultSample,
|
|
2085
|
-
"json-pointer": jsonPointerSample,
|
|
2086
|
-
"relative-json-pointer": relativeJsonPointerSample,
|
|
2087
|
-
// https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01
|
|
2088
|
-
"regex": regexSample
|
|
2089
|
-
};
|
|
2090
|
-
function sampleString(schema, options, spec, context) {
|
|
2091
|
-
let format = schema.format || "default";
|
|
2092
|
-
let sampler = stringFormats[format] || defaultSample;
|
|
2093
|
-
let propertyName = context && context.propertyName;
|
|
2094
|
-
return sampler(schema.minLength || 0, schema.maxLength, propertyName, schema.pattern, options === null || options === void 0 ? void 0 : options.enablePatterns);
|
|
2095
|
-
}
|
|
2096
|
-
}, { "../utils": 15, "./string-regex": 12 }], 14: [function(require2, module3, exports3) {
|
|
2097
|
-
"use strict";
|
|
2098
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
2099
|
-
value: true
|
|
2100
|
-
});
|
|
2101
|
-
exports3.clearCache = clearCache;
|
|
2102
|
-
exports3.traverse = traverse;
|
|
2103
|
-
var _openapiSampler = require2("./openapi-sampler");
|
|
2104
|
-
var _allOf = require2("./allOf");
|
|
2105
|
-
var _infer = require2("./infer");
|
|
2106
|
-
var _utils = require2("./utils");
|
|
2107
|
-
var _jsonPointer = _interopRequireDefault(require2("json-pointer"));
|
|
2108
|
-
const _excluded = ["if", "then"];
|
|
2109
|
-
function _interopRequireDefault(e) {
|
|
2110
|
-
return e && e.__esModule ? e : { default: e };
|
|
2111
|
-
}
|
|
2112
|
-
function _objectWithoutProperties(e, t) {
|
|
2113
|
-
if (null == e) return {};
|
|
2114
|
-
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
2115
|
-
if (Object.getOwnPropertySymbols) {
|
|
2116
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
2117
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
2118
|
-
}
|
|
2119
|
-
return i;
|
|
2120
|
-
}
|
|
2121
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
2122
|
-
if (null == r) return {};
|
|
2123
|
-
var t = {};
|
|
2124
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
2125
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
2126
|
-
t[n] = r[n];
|
|
2127
|
-
}
|
|
2128
|
-
return t;
|
|
2129
|
-
}
|
|
2130
|
-
function ownKeys(e, r) {
|
|
2131
|
-
var t = Object.keys(e);
|
|
2132
|
-
if (Object.getOwnPropertySymbols) {
|
|
2133
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
2134
|
-
r && (o = o.filter(function(r2) {
|
|
2135
|
-
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
2136
|
-
})), t.push.apply(t, o);
|
|
2137
|
-
}
|
|
2138
|
-
return t;
|
|
2139
|
-
}
|
|
2140
|
-
function _objectSpread(e) {
|
|
2141
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
2142
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
2143
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
2144
|
-
_defineProperty(e, r2, t[r2]);
|
|
2145
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
2146
|
-
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
2147
|
-
});
|
|
2148
|
-
}
|
|
2149
|
-
return e;
|
|
2150
|
-
}
|
|
2151
|
-
function _defineProperty(e, r, t) {
|
|
2152
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
2153
|
-
}
|
|
2154
|
-
function _toPropertyKey(t) {
|
|
2155
|
-
var i = _toPrimitive(t, "string");
|
|
2156
|
-
return "symbol" == typeof i ? i : i + "";
|
|
2157
|
-
}
|
|
2158
|
-
function _toPrimitive(t, r) {
|
|
2159
|
-
if ("object" != typeof t || !t) return t;
|
|
2160
|
-
var e = t[Symbol.toPrimitive];
|
|
2161
|
-
if (void 0 !== e) {
|
|
2162
|
-
var i = e.call(t, r || "default");
|
|
2163
|
-
if ("object" != typeof i) return i;
|
|
2164
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2165
|
-
}
|
|
2166
|
-
return ("string" === r ? String : Number)(t);
|
|
2167
|
-
}
|
|
2168
|
-
let $refCache = {};
|
|
2169
|
-
let seenSchemasStack = [];
|
|
2170
|
-
function clearCache() {
|
|
2171
|
-
$refCache = {};
|
|
2172
|
-
seenSchemasStack = [];
|
|
2173
|
-
}
|
|
2174
|
-
function inferExample(schema) {
|
|
2175
|
-
let example;
|
|
2176
|
-
if (schema.const !== void 0) {
|
|
2177
|
-
example = schema.const;
|
|
2178
|
-
} else if (schema.examples !== void 0 && schema.examples.length) {
|
|
2179
|
-
example = schema.examples[0];
|
|
2180
|
-
} else if (schema.enum !== void 0 && schema.enum.length) {
|
|
2181
|
-
example = schema.enum[0];
|
|
2182
|
-
} else if (schema.default !== void 0) {
|
|
2183
|
-
example = schema.default;
|
|
2184
|
-
}
|
|
2185
|
-
return example;
|
|
2186
|
-
}
|
|
2187
|
-
function tryInferExample(schema) {
|
|
2188
|
-
const example = inferExample(schema);
|
|
2189
|
-
if (example !== void 0) {
|
|
2190
|
-
return {
|
|
2191
|
-
value: example,
|
|
2192
|
-
readOnly: schema.readOnly,
|
|
2193
|
-
writeOnly: schema.writeOnly,
|
|
2194
|
-
type: null
|
|
2195
|
-
};
|
|
2196
|
-
}
|
|
2197
|
-
return;
|
|
2198
|
-
}
|
|
2199
|
-
function traverse(schema, options, spec, context) {
|
|
2200
|
-
if (context) {
|
|
2201
|
-
if (seenSchemasStack.includes(schema)) return (0, _utils.getResultForCircular)((0, _infer.inferType)(schema));
|
|
2202
|
-
seenSchemasStack.push(schema);
|
|
2203
|
-
}
|
|
2204
|
-
if (context && context.depth > options.maxSampleDepth) {
|
|
2205
|
-
(0, _utils.popSchemaStack)(seenSchemasStack, context);
|
|
2206
|
-
return (0, _utils.getResultForCircular)((0, _infer.inferType)(schema));
|
|
2207
|
-
}
|
|
2208
|
-
if (schema.$ref) {
|
|
2209
|
-
if (!spec) {
|
|
2210
|
-
throw new Error("Your schema contains $ref. You must provide full specification in the third parameter.");
|
|
2211
|
-
}
|
|
2212
|
-
let ref = decodeURIComponent(schema.$ref);
|
|
2213
|
-
if (ref.startsWith("#")) {
|
|
2214
|
-
ref = ref.substring(1);
|
|
2215
|
-
}
|
|
2216
|
-
const referenced = _jsonPointer.default.get(spec, ref);
|
|
2217
|
-
let result;
|
|
2218
|
-
if ($refCache[ref] !== true) {
|
|
2219
|
-
$refCache[ref] = true;
|
|
2220
|
-
const traverseResult = traverse(referenced, options, spec, context);
|
|
2221
|
-
if (options.format === "xml") {
|
|
2222
|
-
const refName = ref.split("/").pop();
|
|
2223
|
-
const xmlContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
2224
|
-
propertyName: (context === null || context === void 0 ? void 0 : context.propertyName) || refName
|
|
2225
|
-
});
|
|
2226
|
-
const {
|
|
2227
|
-
propertyName,
|
|
2228
|
-
value
|
|
2229
|
-
} = (0, _utils.applyXMLAttributes)(traverseResult, referenced, xmlContext);
|
|
2230
|
-
result = _objectSpread(_objectSpread({}, traverseResult), {}, {
|
|
2231
|
-
value: {
|
|
2232
|
-
[propertyName || "root"]: value
|
|
2233
|
-
}
|
|
2234
|
-
});
|
|
2235
|
-
} else {
|
|
2236
|
-
result = traverseResult;
|
|
2237
|
-
}
|
|
2238
|
-
$refCache[ref] = false;
|
|
2239
|
-
} else {
|
|
2240
|
-
const referencedType = (0, _infer.inferType)(referenced);
|
|
2241
|
-
result = (0, _utils.getResultForCircular)(referencedType);
|
|
2242
|
-
}
|
|
2243
|
-
(0, _utils.popSchemaStack)(seenSchemasStack, context);
|
|
2244
|
-
return result;
|
|
2245
|
-
}
|
|
2246
|
-
if (schema.example !== void 0) {
|
|
2247
|
-
(0, _utils.popSchemaStack)(seenSchemasStack, context);
|
|
2248
|
-
return {
|
|
2249
|
-
value: schema.example,
|
|
2250
|
-
readOnly: schema.readOnly,
|
|
2251
|
-
writeOnly: schema.writeOnly,
|
|
2252
|
-
type: schema.type
|
|
2253
|
-
};
|
|
2254
|
-
}
|
|
2255
|
-
if (schema.allOf !== void 0) {
|
|
2256
|
-
(0, _utils.popSchemaStack)(seenSchemasStack, context);
|
|
2257
|
-
return tryInferExample(schema) || (0, _allOf.allOfSample)(_objectSpread(_objectSpread({}, schema), {}, {
|
|
2258
|
-
allOf: void 0
|
|
2259
|
-
}), schema.allOf, options, spec, context);
|
|
2260
|
-
}
|
|
2261
|
-
if (schema.oneOf && schema.oneOf.length) {
|
|
2262
|
-
if (schema.anyOf) {
|
|
2263
|
-
if (!options.quiet) console.warn("oneOf and anyOf are not supported on the same level. Skipping anyOf");
|
|
2264
|
-
}
|
|
2265
|
-
(0, _utils.popSchemaStack)(seenSchemasStack, context);
|
|
2266
|
-
const firstOneOf = Object.assign({
|
|
2267
|
-
readOnly: schema.readOnly,
|
|
2268
|
-
writeOnly: schema.writeOnly
|
|
2269
|
-
}, schema.oneOf[0]);
|
|
2270
|
-
return traverseOneOrAnyOf(schema, firstOneOf);
|
|
2271
|
-
}
|
|
2272
|
-
if (schema.anyOf && schema.anyOf.length) {
|
|
2273
|
-
(0, _utils.popSchemaStack)(seenSchemasStack, context);
|
|
2274
|
-
const firstAnyOf = Object.assign({
|
|
2275
|
-
readOnly: schema.readOnly,
|
|
2276
|
-
writeOnly: schema.writeOnly
|
|
2277
|
-
}, schema.anyOf[0]);
|
|
2278
|
-
return traverseOneOrAnyOf(schema, firstAnyOf);
|
|
2279
|
-
}
|
|
2280
|
-
if (schema.if && schema.then) {
|
|
2281
|
-
(0, _utils.popSchemaStack)(seenSchemasStack, context);
|
|
2282
|
-
const {
|
|
2283
|
-
if: ifSchema,
|
|
2284
|
-
then
|
|
2285
|
-
} = schema, rest = _objectWithoutProperties(schema, _excluded);
|
|
2286
|
-
return traverse((0, _utils.mergeDeep)(rest, ifSchema, then), options, spec, context);
|
|
2287
|
-
}
|
|
2288
|
-
let example = inferExample(schema);
|
|
2289
|
-
let type = null;
|
|
2290
|
-
if (example === void 0) {
|
|
2291
|
-
example = null;
|
|
2292
|
-
type = schema.type;
|
|
2293
|
-
if (Array.isArray(type) && schema.type.length > 0) {
|
|
2294
|
-
type = schema.type[0];
|
|
2295
|
-
}
|
|
2296
|
-
if (!type) {
|
|
2297
|
-
type = (0, _infer.inferType)(schema);
|
|
2298
|
-
}
|
|
2299
|
-
let sampler = _openapiSampler._samplers[type];
|
|
2300
|
-
if (sampler) {
|
|
2301
|
-
example = sampler(schema, options, spec, context);
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
(0, _utils.popSchemaStack)(seenSchemasStack, context);
|
|
2305
|
-
return {
|
|
2306
|
-
value: example,
|
|
2307
|
-
readOnly: schema.readOnly,
|
|
2308
|
-
writeOnly: schema.writeOnly,
|
|
2309
|
-
type
|
|
2310
|
-
};
|
|
2311
|
-
function traverseOneOrAnyOf(schema2, selectedSubSchema) {
|
|
2312
|
-
const inferred = tryInferExample(schema2);
|
|
2313
|
-
if (inferred !== void 0) {
|
|
2314
|
-
return inferred;
|
|
2315
|
-
}
|
|
2316
|
-
const localExample = traverse(_objectSpread(_objectSpread({}, schema2), {}, {
|
|
2317
|
-
oneOf: void 0,
|
|
2318
|
-
anyOf: void 0
|
|
2319
|
-
}), options, spec, context);
|
|
2320
|
-
const subSchemaExample = traverse(selectedSubSchema, options, spec, context);
|
|
2321
|
-
if (typeof localExample.value === "object" && typeof subSchemaExample.value === "object") {
|
|
2322
|
-
const mergedExample = (0, _utils.mergeDeep)(localExample.value, subSchemaExample.value);
|
|
2323
|
-
return _objectSpread(_objectSpread({}, subSchemaExample), {}, {
|
|
2324
|
-
value: mergedExample
|
|
2325
|
-
});
|
|
2326
|
-
}
|
|
2327
|
-
return subSchemaExample;
|
|
2328
|
-
}
|
|
2329
|
-
}
|
|
2330
|
-
}, { "./allOf": 4, "./infer": 5, "./openapi-sampler": 6, "./utils": 15, "json-pointer": 3 }], 15: [function(require2, module3, exports3) {
|
|
2331
|
-
"use strict";
|
|
2332
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
2333
|
-
value: true
|
|
2334
|
-
});
|
|
2335
|
-
exports3.SKIP_SYMBOL = void 0;
|
|
2336
|
-
exports3.applyXMLAttributes = applyXMLAttributes;
|
|
2337
|
-
exports3.ensureMinLength = ensureMinLength;
|
|
2338
|
-
exports3.getResultForCircular = getResultForCircular;
|
|
2339
|
-
exports3.getXMLAttributes = getXMLAttributes;
|
|
2340
|
-
exports3.mergeDeep = mergeDeep;
|
|
2341
|
-
exports3.popSchemaStack = popSchemaStack;
|
|
2342
|
-
exports3.toRFCDateTime = toRFCDateTime;
|
|
2343
|
-
exports3.uuid = uuid;
|
|
2344
|
-
function ownKeys(e, r) {
|
|
2345
|
-
var t = Object.keys(e);
|
|
2346
|
-
if (Object.getOwnPropertySymbols) {
|
|
2347
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
2348
|
-
r && (o = o.filter(function(r2) {
|
|
2349
|
-
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
2350
|
-
})), t.push.apply(t, o);
|
|
2351
|
-
}
|
|
2352
|
-
return t;
|
|
2353
|
-
}
|
|
2354
|
-
function _objectSpread(e) {
|
|
2355
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
2356
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
2357
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
2358
|
-
_defineProperty(e, r2, t[r2]);
|
|
2359
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
2360
|
-
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
2361
|
-
});
|
|
2362
|
-
}
|
|
2363
|
-
return e;
|
|
2364
|
-
}
|
|
2365
|
-
function _defineProperty(e, r, t) {
|
|
2366
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
2367
|
-
}
|
|
2368
|
-
function _toPropertyKey(t) {
|
|
2369
|
-
var i = _toPrimitive(t, "string");
|
|
2370
|
-
return "symbol" == typeof i ? i : i + "";
|
|
2371
|
-
}
|
|
2372
|
-
function _toPrimitive(t, r) {
|
|
2373
|
-
if ("object" != typeof t || !t) return t;
|
|
2374
|
-
var e = t[Symbol.toPrimitive];
|
|
2375
|
-
if (void 0 !== e) {
|
|
2376
|
-
var i = e.call(t, r || "default");
|
|
2377
|
-
if ("object" != typeof i) return i;
|
|
2378
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2379
|
-
}
|
|
2380
|
-
return ("string" === r ? String : Number)(t);
|
|
2381
|
-
}
|
|
2382
|
-
const SKIP_SYMBOL = exports3.SKIP_SYMBOL = /* @__PURE__ */ Symbol("skip");
|
|
2383
|
-
function pad(number) {
|
|
2384
|
-
if (number < 10) {
|
|
2385
|
-
return "0" + number;
|
|
2386
|
-
}
|
|
2387
|
-
return number;
|
|
2388
|
-
}
|
|
2389
|
-
function toRFCDateTime(date, omitTime, omitDate, milliseconds) {
|
|
2390
|
-
var res = omitDate ? "" : date.getUTCFullYear() + "-" + pad(date.getUTCMonth() + 1) + "-" + pad(date.getUTCDate());
|
|
2391
|
-
if (!omitTime) {
|
|
2392
|
-
res += "T" + pad(date.getUTCHours()) + ":" + pad(date.getUTCMinutes()) + ":" + pad(date.getUTCSeconds()) + (milliseconds ? "." + (date.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) : "") + "Z";
|
|
2393
|
-
}
|
|
2394
|
-
return res;
|
|
2395
|
-
}
|
|
2396
|
-
;
|
|
2397
|
-
function ensureMinLength(sample, min) {
|
|
2398
|
-
if (min > sample.length) {
|
|
2399
|
-
return sample.repeat(Math.trunc(min / sample.length) + 1).substring(0, min);
|
|
2400
|
-
}
|
|
2401
|
-
return sample;
|
|
2402
|
-
}
|
|
2403
|
-
function mergeDeep() {
|
|
2404
|
-
const isObject = (obj) => obj && typeof obj === "object";
|
|
2405
|
-
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2406
|
-
objects[_key] = arguments[_key];
|
|
2407
|
-
}
|
|
2408
|
-
return objects.reduce((prev, obj) => {
|
|
2409
|
-
Object.keys(obj || {}).forEach((key) => {
|
|
2410
|
-
const pVal = prev[key];
|
|
2411
|
-
const oVal = obj[key];
|
|
2412
|
-
if (isObject(pVal) && isObject(oVal)) {
|
|
2413
|
-
prev[key] = mergeDeep(pVal, oVal);
|
|
2414
|
-
} else {
|
|
2415
|
-
prev[key] = oVal;
|
|
2416
|
-
}
|
|
2417
|
-
});
|
|
2418
|
-
return prev;
|
|
2419
|
-
}, Array.isArray(objects[objects.length - 1]) ? [] : {});
|
|
2420
|
-
}
|
|
2421
|
-
function uuid(str) {
|
|
2422
|
-
var hash = hashCode(str);
|
|
2423
|
-
var random = jsf32(hash, hash, hash, hash);
|
|
2424
|
-
var uuid2 = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
2425
|
-
var r = random() * 16 % 16 | 0;
|
|
2426
|
-
return (c == "x" ? r : r & 3 | 8).toString(16);
|
|
2427
|
-
});
|
|
2428
|
-
return uuid2;
|
|
2429
|
-
}
|
|
2430
|
-
function getResultForCircular(type) {
|
|
2431
|
-
return {
|
|
2432
|
-
value: type === "object" ? {} : type === "array" ? [] : void 0
|
|
2433
|
-
};
|
|
2434
|
-
}
|
|
2435
|
-
function popSchemaStack(seenSchemasStack, context) {
|
|
2436
|
-
if (context) seenSchemasStack.pop();
|
|
2437
|
-
}
|
|
2438
|
-
function getXMLAttributes(schema) {
|
|
2439
|
-
var _schema$xml, _schema$xml2, _schema$xml3, _schema$xml$attribute, _schema$xml4, _schema$xml$wrapped, _schema$xml5;
|
|
2440
|
-
return {
|
|
2441
|
-
name: (schema === null || schema === void 0 || (_schema$xml = schema.xml) === null || _schema$xml === void 0 ? void 0 : _schema$xml.name) || "",
|
|
2442
|
-
prefix: (schema === null || schema === void 0 || (_schema$xml2 = schema.xml) === null || _schema$xml2 === void 0 ? void 0 : _schema$xml2.prefix) || "",
|
|
2443
|
-
namespace: (schema === null || schema === void 0 || (_schema$xml3 = schema.xml) === null || _schema$xml3 === void 0 ? void 0 : _schema$xml3.namespace) || null,
|
|
2444
|
-
attribute: (_schema$xml$attribute = schema === null || schema === void 0 || (_schema$xml4 = schema.xml) === null || _schema$xml4 === void 0 ? void 0 : _schema$xml4.attribute) !== null && _schema$xml$attribute !== void 0 ? _schema$xml$attribute : false,
|
|
2445
|
-
wrapped: (_schema$xml$wrapped = schema === null || schema === void 0 || (_schema$xml5 = schema.xml) === null || _schema$xml5 === void 0 ? void 0 : _schema$xml5.wrapped) !== null && _schema$xml$wrapped !== void 0 ? _schema$xml$wrapped : false
|
|
2446
|
-
};
|
|
2447
|
-
}
|
|
2448
|
-
function resolveNodeType(schema) {
|
|
2449
|
-
const xml = schema === null || schema === void 0 ? void 0 : schema.xml;
|
|
2450
|
-
if (xml !== null && xml !== void 0 && xml.nodeType) {
|
|
2451
|
-
return xml.nodeType;
|
|
2452
|
-
}
|
|
2453
|
-
if ((xml === null || xml === void 0 ? void 0 : xml.attribute) === true) {
|
|
2454
|
-
return "attribute";
|
|
2455
|
-
}
|
|
2456
|
-
if ((xml === null || xml === void 0 ? void 0 : xml.wrapped) === true && (schema === null || schema === void 0 ? void 0 : schema.type) === "array") {
|
|
2457
|
-
return "element";
|
|
2458
|
-
}
|
|
2459
|
-
if (schema !== null && schema !== void 0 && schema.$ref || schema !== null && schema !== void 0 && schema.$dynamicRef || (schema === null || schema === void 0 ? void 0 : schema.type) === "array") {
|
|
2460
|
-
return "none";
|
|
2461
|
-
}
|
|
2462
|
-
if (schema !== null && schema !== void 0 && schema.oneOf || schema !== null && schema !== void 0 && schema.anyOf || schema !== null && schema !== void 0 && schema.allOf) {
|
|
2463
|
-
return "none";
|
|
2464
|
-
}
|
|
2465
|
-
return "element";
|
|
2466
|
-
}
|
|
2467
|
-
function applyXMLAttributes(result) {
|
|
2468
|
-
let schema = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2469
|
-
let context = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
2470
|
-
const {
|
|
2471
|
-
value: oldValue
|
|
2472
|
-
} = result;
|
|
2473
|
-
const {
|
|
2474
|
-
propertyName: oldPropertyName
|
|
2475
|
-
} = context;
|
|
2476
|
-
const {
|
|
2477
|
-
name,
|
|
2478
|
-
prefix,
|
|
2479
|
-
namespace
|
|
2480
|
-
} = getXMLAttributes(schema);
|
|
2481
|
-
const effectiveNodeType = resolveNodeType(schema);
|
|
2482
|
-
let propertyName = name || oldPropertyName ? "".concat(prefix ? prefix + ":" : "").concat(name || oldPropertyName) : null;
|
|
2483
|
-
let value = typeof oldValue === "object" ? Array.isArray(oldValue) ? [...oldValue] : _objectSpread({}, oldValue) : oldValue;
|
|
2484
|
-
switch (effectiveNodeType) {
|
|
2485
|
-
case "attribute":
|
|
2486
|
-
if (propertyName) {
|
|
2487
|
-
propertyName = "$".concat(propertyName);
|
|
2488
|
-
}
|
|
2489
|
-
break;
|
|
2490
|
-
case "text":
|
|
2491
|
-
propertyName = "#text";
|
|
2492
|
-
break;
|
|
2493
|
-
case "cdata":
|
|
2494
|
-
propertyName = "#cdata";
|
|
2495
|
-
break;
|
|
2496
|
-
case "none":
|
|
2497
|
-
if (schema.type === "array") {
|
|
2498
|
-
propertyName = null;
|
|
2499
|
-
if (schema.example !== void 0) {
|
|
2500
|
-
var _schema$items;
|
|
2501
|
-
propertyName = ((_schema$items = schema.items) === null || _schema$items === void 0 || (_schema$items = _schema$items.xml) === null || _schema$items === void 0 ? void 0 : _schema$items.name) || propertyName;
|
|
2502
|
-
}
|
|
2503
|
-
} else {
|
|
2504
|
-
propertyName = null;
|
|
2505
|
-
}
|
|
2506
|
-
break;
|
|
2507
|
-
default:
|
|
2508
|
-
if (schema.type === "array") {
|
|
2509
|
-
if (Array.isArray(value)) {
|
|
2510
|
-
value = {
|
|
2511
|
-
[propertyName]: [...value]
|
|
2512
|
-
};
|
|
2513
|
-
}
|
|
2514
|
-
}
|
|
2515
|
-
break;
|
|
2516
|
-
}
|
|
2517
|
-
if (namespace && effectiveNodeType !== "text" && effectiveNodeType !== "cdata" && effectiveNodeType !== "none") {
|
|
2518
|
-
if (typeof value === "object") {
|
|
2519
|
-
value["$xmlns".concat(prefix ? ":" + prefix : "")] = namespace;
|
|
2520
|
-
} else {
|
|
2521
|
-
value = {
|
|
2522
|
-
["$xmlns".concat(prefix ? ":" + prefix : "")]: namespace,
|
|
2523
|
-
["#text"]: value
|
|
2524
|
-
};
|
|
2525
|
-
}
|
|
2526
|
-
}
|
|
2527
|
-
return {
|
|
2528
|
-
propertyName,
|
|
2529
|
-
value
|
|
2530
|
-
};
|
|
2531
|
-
}
|
|
2532
|
-
function hashCode(str) {
|
|
2533
|
-
var hash = 0;
|
|
2534
|
-
if (str.length == 0) return hash;
|
|
2535
|
-
for (var i = 0; i < str.length; i++) {
|
|
2536
|
-
var char = str.charCodeAt(i);
|
|
2537
|
-
hash = (hash << 5) - hash + char;
|
|
2538
|
-
hash = hash & hash;
|
|
2539
|
-
}
|
|
2540
|
-
return hash;
|
|
2541
|
-
}
|
|
2542
|
-
function jsf32(a, b, c, d) {
|
|
2543
|
-
return function() {
|
|
2544
|
-
a |= 0;
|
|
2545
|
-
b |= 0;
|
|
2546
|
-
c |= 0;
|
|
2547
|
-
d |= 0;
|
|
2548
|
-
var t = a - (b << 27 | b >>> 5) | 0;
|
|
2549
|
-
a = b ^ (c << 17 | c >>> 15);
|
|
2550
|
-
b = c + d | 0;
|
|
2551
|
-
c = d + t | 0;
|
|
2552
|
-
d = a + t | 0;
|
|
2553
|
-
return (d >>> 0) / 4294967296;
|
|
2554
|
-
};
|
|
2555
|
-
}
|
|
2556
|
-
}, {}] }, {}, [6])(6);
|
|
2557
|
-
});
|
|
2558
|
-
}
|
|
2559
|
-
});
|
|
2560
|
-
|
|
2561
|
-
export {
|
|
2562
|
-
require_json_pointer,
|
|
2563
|
-
require_openapi_sampler
|
|
2564
|
-
};
|