@redocly/replay 0.18.0-next.4 → 0.18.0-next.6
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/dist/{replay-index-YCW_ryD-.js → replay-index-B0Zcyylo.js} +1 -1
- package/dist/{replay-index-B7WLshgt.js → replay-index-Cvzuhycf.js} +1 -1
- package/dist/replay-index-DBann2EA.js +5081 -0
- package/dist/replay-index-DMCNqMqM.js +32 -0
- package/dist/replay-index-D_u4Vywo.js +107229 -0
- package/dist/replay-index-DrxUtqUV.js +3775 -0
- package/dist/replay-tauri-path-D5u2Xoah.js +21 -0
- package/dist/replay-tauri-path-DD8eOHYl.js +1 -0
- package/dist/replay.cjs +1 -1
- package/dist/replay.d.ts +12 -0
- package/dist/replay.js +7 -4
- package/package.json +4 -4
- package/dist/replay-index-C0fi9844.js +0 -4307
- package/dist/replay-index-Cq-sID5X.js +0 -16623
- package/dist/replay-index-DXXDRz5U.js +0 -94942
- package/dist/replay-index-qEErFFDM.js +0 -134
- package/dist/replay-tauri-path-C2njauJF.js +0 -1
- package/dist/replay-tauri-path-r1HWHG5s.js +0 -16
|
@@ -0,0 +1,3775 @@
|
|
|
1
|
+
import { b as Gt, a as U, p as Y, c as _o, d as Ee, f as cr, g as Io, h as rr, k as Do, y as fr, l as X, m as Re, n as Zt, o as No, q as ur, t as Yt, u as we, R as Ze, v as Lo, w as jo, C as V, x as Dt, z as Wo, A as qo, S as es, U as rs, B as J, D as Uo, E as zo, F as Bo, G as xo, H as Mo, I as Vo, J as Ko, K as Ho, L as Jo, M as Nt, N as Xo, O as Lt, P as Qo, Q as Go } from "./replay-index-D_u4Vywo.js";
|
|
2
|
+
async function Zo(r) {
|
|
3
|
+
const { descriptionPath: t, externalRefResolver: e, base: n } = r, a = await Gt({
|
|
4
|
+
base: n,
|
|
5
|
+
ref: t,
|
|
6
|
+
config: r.config,
|
|
7
|
+
dereference: !0,
|
|
8
|
+
externalRefResolver: e
|
|
9
|
+
});
|
|
10
|
+
if (!a)
|
|
11
|
+
throw new Error(`Could not find source description file '${t}'.`);
|
|
12
|
+
return a.bundle.parsed;
|
|
13
|
+
}
|
|
14
|
+
function ts(r) {
|
|
15
|
+
if (typeof r != "object")
|
|
16
|
+
return;
|
|
17
|
+
const t = Object.keys(r)[0];
|
|
18
|
+
return t ? r[t]?.value : void 0;
|
|
19
|
+
}
|
|
20
|
+
const Yo = (r) => /\{.*?\}/.test(r);
|
|
21
|
+
function fe({ value: r, ctx: t, logger: e }) {
|
|
22
|
+
if (!r)
|
|
23
|
+
return r;
|
|
24
|
+
if (typeof r == "object") {
|
|
25
|
+
for (const n in r)
|
|
26
|
+
r[n] = fe({ value: r[n], ctx: t, logger: e });
|
|
27
|
+
return r;
|
|
28
|
+
}
|
|
29
|
+
return typeof r == "number" || typeof r == "boolean" ? r : r.toString().startsWith("$faker.") ? ze({ pointer: r.slice(1), ctx: t, logger: e }) : Yo(r) ? ti(r, t, e) : ni(r, t, e);
|
|
30
|
+
}
|
|
31
|
+
function ei(r, t, e) {
|
|
32
|
+
const n = r.indexOf("{");
|
|
33
|
+
if (n !== -1) {
|
|
34
|
+
const c = r.substring(n + 1).slice(0, -1), f = ze({ pointer: c.slice(1), ctx: t, logger: e });
|
|
35
|
+
return f && r.replace(/{(.*)}/, f);
|
|
36
|
+
} else
|
|
37
|
+
return r;
|
|
38
|
+
}
|
|
39
|
+
function ri(r, t) {
|
|
40
|
+
const e = Object.keys(t), n = Object.values(t);
|
|
41
|
+
return new Function(...e, `return ${r}`)(...n);
|
|
42
|
+
}
|
|
43
|
+
function ti(r, t, e) {
|
|
44
|
+
const n = /\{\$(\{[^{}]*\}|[^{}])*\}/g;
|
|
45
|
+
let a = r;
|
|
46
|
+
return a = a.replace(n, (c, f) => si(c, t, e)), a;
|
|
47
|
+
}
|
|
48
|
+
function si(r, t, e) {
|
|
49
|
+
if (!r.includes("$"))
|
|
50
|
+
return r;
|
|
51
|
+
if (r.includes("$faker."))
|
|
52
|
+
return ei(r, t, e);
|
|
53
|
+
const n = qe(t)(oi(r));
|
|
54
|
+
return n !== void 0 ? n : "";
|
|
55
|
+
}
|
|
56
|
+
const ni = (r, t, e) => {
|
|
57
|
+
if (!r)
|
|
58
|
+
return r;
|
|
59
|
+
const n = r.toString();
|
|
60
|
+
if (!n.includes("$"))
|
|
61
|
+
return r;
|
|
62
|
+
if (n.startsWith("$file(") && n.endsWith(")"))
|
|
63
|
+
return n.slice(7, -2);
|
|
64
|
+
if (n.startsWith("$sourceDescriptions.") && n.includes(".workflows.")) {
|
|
65
|
+
const a = n.split("."), c = a[1], f = a[3];
|
|
66
|
+
if (!c || !f)
|
|
67
|
+
return;
|
|
68
|
+
const l = qe(t)("$sourceDescriptions");
|
|
69
|
+
return l[c] ? l[c].workflows.find((h) => h.workflowId === f) : void 0;
|
|
70
|
+
}
|
|
71
|
+
return n && n.trim().startsWith("faker.") ? ze({ pointer: n, ctx: t, logger: e }) : n ? qe(t)(jt(n)) : n.replace(/\$\{([^}]+)}/g, (a, c) => qe(t)(jt(c)));
|
|
72
|
+
};
|
|
73
|
+
function oi(r) {
|
|
74
|
+
return r.replace(/\{(.*)\}/, "$1");
|
|
75
|
+
}
|
|
76
|
+
function jt(r) {
|
|
77
|
+
return r.replace(/\['(.*?)'\]/g, ".$1");
|
|
78
|
+
}
|
|
79
|
+
const qe = (r, t = "") => (e) => {
|
|
80
|
+
if (t || (t = e), !e)
|
|
81
|
+
return r;
|
|
82
|
+
const [n, ...a] = e.split(".");
|
|
83
|
+
if (!r)
|
|
84
|
+
throw Error(`Cannot get ${U(n)} from ${U(t)}`);
|
|
85
|
+
if (r?.[n] === void 0) {
|
|
86
|
+
const c = ` Undefined ${U(n)} at ${U(t)}.`, f = Object.keys(r).length ? `Did you mean to use another key? Available keys:
|
|
87
|
+
${Object.keys(r).join(", ")}.
|
|
88
|
+
` : "", l = `${c} ${f}`;
|
|
89
|
+
throw Error(l);
|
|
90
|
+
}
|
|
91
|
+
return qe(r[n], t)(a.join("."));
|
|
92
|
+
};
|
|
93
|
+
function ze({ pointer: r, ctx: t, logger: e }) {
|
|
94
|
+
const n = r.split("."), a = { ctx: { faker: t.$faker } };
|
|
95
|
+
try {
|
|
96
|
+
const c = n.map((f) => f.trim()).map((f, l) => (
|
|
97
|
+
// Dumb function check (if ends by ')'), if function goes first dont need to put '.',
|
|
98
|
+
// if goes second and so on - must be prepended by '.', like ["escaped-field"].func()
|
|
99
|
+
f.endsWith(")") ? `${l == 0 ? "" : "."}${f}` : `["${f}"]`
|
|
100
|
+
)).join("");
|
|
101
|
+
return ri(`ctx${c}`, a);
|
|
102
|
+
} catch (c) {
|
|
103
|
+
e.error(U(c.toString()));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function ss(r, t, e) {
|
|
108
|
+
if (typeof r == "string" && r)
|
|
109
|
+
return fe({ value: r, ctx: t, logger: e });
|
|
110
|
+
if (!(typeof r == "string" || typeof r == "number" || typeof r == "boolean" || typeof r > "u" || r instanceof Blob || r === null))
|
|
111
|
+
for (const n in r)
|
|
112
|
+
typeof r[n] == "string" ? r[n] && (r[n] = fe({ value: r[n], ctx: t, logger: e })) : ss(r[n], t, e);
|
|
113
|
+
}
|
|
114
|
+
function Wt(r, t, e) {
|
|
115
|
+
return ss(r, t, e) || r;
|
|
116
|
+
}
|
|
117
|
+
function qt(r, t) {
|
|
118
|
+
if (!r)
|
|
119
|
+
return;
|
|
120
|
+
const e = {};
|
|
121
|
+
for (const n in t)
|
|
122
|
+
e[`{${n}}`] = String(t[n]);
|
|
123
|
+
return r.split(/(\{[a-zA-Z0-9_.-]+\}+)/g).map((n) => e[n] ? e[n] : n).join("");
|
|
124
|
+
}
|
|
125
|
+
function ii(r) {
|
|
126
|
+
return typeof r == "object" && r !== null && "name" in r && "value" in r && !("in" in r);
|
|
127
|
+
}
|
|
128
|
+
function Mr(r) {
|
|
129
|
+
return typeof r == "object" && r !== null && "in" in r && ["header", "query", "path", "cookie"].includes(r.in);
|
|
130
|
+
}
|
|
131
|
+
const ai = /^image\/(png|jpeg|gif|bmp|webp|svg\+xml)|application\/pdf$/;
|
|
132
|
+
function ns(r) {
|
|
133
|
+
return r.startsWith("$file(") && r.endsWith(")") ? r.substring(7, r.length - 2) : r;
|
|
134
|
+
}
|
|
135
|
+
const Ut = async (r, t, e, n, a) => {
|
|
136
|
+
const c = Y.dirname(n), f = Y.resolve(c, ns(e));
|
|
137
|
+
r.append(t, await a.options.requestFileLoader.getFileBody(f));
|
|
138
|
+
}, os = (r, t, e, n, a, c) => {
|
|
139
|
+
Object.entries(e).forEach(([f, l]) => {
|
|
140
|
+
const h = c ? `${c}[${f}]` : f;
|
|
141
|
+
typeof l == "string" && l.startsWith("$file(") && l.endsWith(")") ? r.push(Ut(t, h, l, n, a)) : Array.isArray(l) ? l.forEach((d) => {
|
|
142
|
+
typeof d == "string" && d.startsWith("$file(") && d.endsWith(")") ? r.push(Ut(t, h, d, n, a)) : t.append(h, d.toString());
|
|
143
|
+
}) : typeof l == "object" && l !== null ? os(r, t, l, n, a, h) : (typeof l == "string" || typeof l == "number" || typeof l == "boolean") && t.append(h, l.toString());
|
|
144
|
+
});
|
|
145
|
+
}, ci = async (r, t, e, n) => {
|
|
146
|
+
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
147
|
+
const a = [];
|
|
148
|
+
os(a, t, r, e, n), await Promise.all(a);
|
|
149
|
+
}
|
|
150
|
+
}, fi = async (r, t) => {
|
|
151
|
+
if (typeof r == "string" && r.startsWith("$file(") && r.endsWith(")")) {
|
|
152
|
+
const e = Y.resolve(Y.dirname(t.options.filePath), ns(r));
|
|
153
|
+
return t.options.requestFileLoader.getFileBody(e);
|
|
154
|
+
} else
|
|
155
|
+
return r;
|
|
156
|
+
};
|
|
157
|
+
async function ui(r, t) {
|
|
158
|
+
if (!r)
|
|
159
|
+
return {
|
|
160
|
+
payload: void 0,
|
|
161
|
+
contentType: void 0,
|
|
162
|
+
encoding: void 0,
|
|
163
|
+
replacements: void 0
|
|
164
|
+
};
|
|
165
|
+
const { payload: e, contentType: n } = r;
|
|
166
|
+
if (n === "multipart/form-data") {
|
|
167
|
+
const a = new FormData(), c = Y.resolve(t.options.filePath);
|
|
168
|
+
return await ci(e, a, c, t), {
|
|
169
|
+
...r,
|
|
170
|
+
payload: a
|
|
171
|
+
};
|
|
172
|
+
} else {
|
|
173
|
+
if (n === "application/octet-stream" || typeof n == "string" && ai.test(n))
|
|
174
|
+
return {
|
|
175
|
+
...r,
|
|
176
|
+
payload: await fi(e, t),
|
|
177
|
+
contentType: "application/octet-stream"
|
|
178
|
+
};
|
|
179
|
+
if (n === "application/x-www-form-urlencoded" && typeof e == "string")
|
|
180
|
+
return {
|
|
181
|
+
...r,
|
|
182
|
+
payload: Object.fromEntries(new URLSearchParams(e).entries()),
|
|
183
|
+
contentType: "application/x-www-form-urlencoded"
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return r;
|
|
187
|
+
}
|
|
188
|
+
function li(r) {
|
|
189
|
+
try {
|
|
190
|
+
return _o(r);
|
|
191
|
+
} catch {
|
|
192
|
+
throw new Error(`Runtime expression is not valid: ${r}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function pi(r, t) {
|
|
196
|
+
const e = [
|
|
197
|
+
{
|
|
198
|
+
pattern: /\$response\.body#\/([\w/]+)/g,
|
|
199
|
+
ctxFunction: (a, c) => Le(t.$response?.body, c, a)
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
pattern: /\$request\.body#\/([\w/]+)/g,
|
|
203
|
+
ctxFunction: (a, c) => Le(t.$request?.body, c, a)
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
pattern: /\$outputs\.([\w-]+)#\/([\w/]+)/g,
|
|
207
|
+
ctxFunction: (a, c, f) => Le(t.$outputs?.[c], f, a)
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
pattern: /\$workflows\.([\w-]+)\.outputs\.([\w-]+)#\/([\w/]+)/g,
|
|
211
|
+
ctxFunction: (a, c, f, l) => Le(t.$workflows?.[c]?.outputs?.[f], l, a)
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
pattern: /\$steps\.([\w-]+)\.outputs\.([\w-]+)#\/([\w/]+)/g,
|
|
215
|
+
ctxFunction: (a, c, f, l) => Le(t.$steps?.[c]?.outputs?.[f], l, a)
|
|
216
|
+
}
|
|
217
|
+
];
|
|
218
|
+
let n = r;
|
|
219
|
+
for (const { pattern: a, ctxFunction: c } of e)
|
|
220
|
+
n = n.replaceAll(a, c);
|
|
221
|
+
return n;
|
|
222
|
+
}
|
|
223
|
+
function Le(r, t, e) {
|
|
224
|
+
if (r)
|
|
225
|
+
try {
|
|
226
|
+
const n = Ee.get(r, `/${t}`);
|
|
227
|
+
return typeof n == "string" || Array.isArray(n) || typeof n == "object" ? JSON.stringify(n) : n !== void 0 ? n : e;
|
|
228
|
+
} catch {
|
|
229
|
+
return e;
|
|
230
|
+
}
|
|
231
|
+
return e;
|
|
232
|
+
}
|
|
233
|
+
function oe({ payload: r, context: t, contentType: e, logger: n }) {
|
|
234
|
+
if (e?.includes("application/octet-stream"))
|
|
235
|
+
return Wt(r, t, n);
|
|
236
|
+
if (e?.includes("multipart/form-data")) {
|
|
237
|
+
if (r instanceof FormData) {
|
|
238
|
+
const a = new FormData();
|
|
239
|
+
for (const [c, f] of r.entries())
|
|
240
|
+
if (f instanceof File)
|
|
241
|
+
a.append(c, f);
|
|
242
|
+
else {
|
|
243
|
+
const l = oe({
|
|
244
|
+
payload: f,
|
|
245
|
+
context: t,
|
|
246
|
+
logger: n
|
|
247
|
+
});
|
|
248
|
+
a.append(c, l);
|
|
249
|
+
}
|
|
250
|
+
return a;
|
|
251
|
+
}
|
|
252
|
+
return Wt(r, t, n);
|
|
253
|
+
}
|
|
254
|
+
return typeof r == "string" ? vi(r) ? Se(r, t, n) : wi(r, t, n) : cr(r) ? Object.entries(r).reduce((a, [c, f]) => (a[c] = oe({ payload: f, context: t, logger: n }), a), {}) : Array.isArray(r) ? r.map((a) => oe({ payload: a, context: t, logger: n })) : r;
|
|
255
|
+
}
|
|
256
|
+
function Se(r, t, e) {
|
|
257
|
+
return typeof r == "string" ? di(r, t, e) : cr(r) ? Object.entries(r).reduce((n, [a, c]) => (n[a] = c && Se(c, t, e), n), {}) : Array.isArray(r) ? r.map((n) => Se(n, t, e)) : r;
|
|
258
|
+
}
|
|
259
|
+
function di(r, t, e) {
|
|
260
|
+
if (/^\$faker\.[a-zA-Z0-9._-]+(\([^\\)]*\))?$/.test(r))
|
|
261
|
+
return ze({ pointer: r.slice(1), ctx: t, logger: e });
|
|
262
|
+
if (r.includes("$faker.")) {
|
|
263
|
+
const c = /\$faker\.[a-zA-Z0-9._-]+(\([^\\)]*\))?/g;
|
|
264
|
+
r = r.replace(c, (f) => ze({ pointer: f.slice(1), ctx: t, logger: e })).replace(/{(.*?)}/g, "$1");
|
|
265
|
+
}
|
|
266
|
+
if (!r.includes("$") && !/[=<>]/.test(r))
|
|
267
|
+
return r;
|
|
268
|
+
li(r);
|
|
269
|
+
const n = gi(r, t), a = mi(t);
|
|
270
|
+
try {
|
|
271
|
+
return new Function(...Object.keys(a), `return ${n};`)(...Object.values(a));
|
|
272
|
+
} catch {
|
|
273
|
+
throw new Error(`Error in resolving runtime expression '${r}'.
|
|
274
|
+
This could be because the expression references a value from a previous failed step, or is trying to reference a variable that hasn't been set.`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function hi(r) {
|
|
278
|
+
return r.replace(/\$([a-zA-Z0-9._-]+)/g, (t, e) => `$${e.replace(/-/g, "_")}`);
|
|
279
|
+
}
|
|
280
|
+
function gi(r, t) {
|
|
281
|
+
const e = pi(r, t), a = hi(e).replace(/{(.*?)}/g, "$1"), c = yi(a), f = /\.header\.([a-zA-Z0-9._-]+)/g;
|
|
282
|
+
return c.replace(f, (h, d) => `.header.${d.toLowerCase()}`);
|
|
283
|
+
}
|
|
284
|
+
function mi(r) {
|
|
285
|
+
const t = {};
|
|
286
|
+
for (const [e, n] of Object.entries(r)) {
|
|
287
|
+
const a = e.replace(/-/g, "_");
|
|
288
|
+
t[a] = is(n);
|
|
289
|
+
}
|
|
290
|
+
return t;
|
|
291
|
+
}
|
|
292
|
+
function is(r) {
|
|
293
|
+
return Array.isArray(r) ? r : typeof r == "object" && r !== null ? $i(r) : r;
|
|
294
|
+
}
|
|
295
|
+
function $i(r) {
|
|
296
|
+
return Object.keys(r).reduce((t, e) => {
|
|
297
|
+
const n = e.replace(/-/g, "_");
|
|
298
|
+
return t[n] = is(r[e]), t;
|
|
299
|
+
}, {});
|
|
300
|
+
}
|
|
301
|
+
function yi(r) {
|
|
302
|
+
return r.replace(/\.(\d+)/g, (t, e, n, a) => {
|
|
303
|
+
const c = a[n - 1];
|
|
304
|
+
return /\d/.test(c) ? t : `[${e}]`;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
function wi(r, t, e) {
|
|
308
|
+
const n = /\{(?:[^{}]|\{[^{}]*\})*\}|\$[^\s{}]+(?:\([^()]*\))*/g;
|
|
309
|
+
return r.replace(n, (a) => {
|
|
310
|
+
const c = a.trim(), f = Se(c, t, e);
|
|
311
|
+
return f !== void 0 ? f : a;
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
function vi(r) {
|
|
315
|
+
return /^\$[^\s{}]+(\([^)]*\))?$|^\{[^{}]*\}$/.test(r.trim());
|
|
316
|
+
}
|
|
317
|
+
function ki({ payload: r, replacements: t, expressionContext: e, logger: n }) {
|
|
318
|
+
for (const a of t) {
|
|
319
|
+
const { target: c, value: f } = a;
|
|
320
|
+
if (typeof c != "string")
|
|
321
|
+
throw new Error(`Invalid JSON Pointer: ${c}`);
|
|
322
|
+
try {
|
|
323
|
+
const l = Ee.get(r, c), h = oe({
|
|
324
|
+
payload: f,
|
|
325
|
+
context: e,
|
|
326
|
+
logger: n
|
|
327
|
+
});
|
|
328
|
+
l !== void 0 && Ee.set(r, c, h);
|
|
329
|
+
} catch {
|
|
330
|
+
throw new Error(`Invalid JSON Pointer: ${c}`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const Ei = ["parameters", "failureActions", "successActions"];
|
|
335
|
+
function Si(r, t) {
|
|
336
|
+
const { reference: e, value: n } = r;
|
|
337
|
+
if (!Ei.some((c) => e.includes(`$components.${c}`)))
|
|
338
|
+
throw new Error("Invalid reference: available components are $components.parameters, $components.failureActions, or $components.successActions");
|
|
339
|
+
const a = fe({ value: e, ctx: t, logger: t.options.logger });
|
|
340
|
+
return "value" in a && n ? {
|
|
341
|
+
...a,
|
|
342
|
+
value: n
|
|
343
|
+
} : a;
|
|
344
|
+
}
|
|
345
|
+
function We(r, t) {
|
|
346
|
+
return "reference" in r ? Si(r, t) : r;
|
|
347
|
+
}
|
|
348
|
+
function Ci(r, t) {
|
|
349
|
+
const e = r?.requestBody?.content || {}, [n, a] = Object.entries(e)[0] || [], c = a?.example || ts(a?.examples) || as(a?.schema, t), f = bi(r);
|
|
350
|
+
return {
|
|
351
|
+
parameters: Ai([
|
|
352
|
+
...zt(r.pathParameters, t),
|
|
353
|
+
...zt(r.parameters, t)
|
|
354
|
+
]).filter(({ value: h }) => h),
|
|
355
|
+
contentTypeParameters: [
|
|
356
|
+
...n ? [{ name: "content-type", in: "header", value: n }] : [],
|
|
357
|
+
...f ? [{ name: "accept", in: "header", value: f }] : []
|
|
358
|
+
],
|
|
359
|
+
requestBody: c,
|
|
360
|
+
contentType: n
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
function bi(r) {
|
|
364
|
+
return r?.responses ? Array.from(new Set(Object.values(r.responses).flatMap((t) => cr(t) && "content" in t ? Object.keys(t.content || {}) : []))).join(", ") : void 0;
|
|
365
|
+
}
|
|
366
|
+
function zt(r, t) {
|
|
367
|
+
return (r || []).filter((e) => e?.required === !0).map((e) => {
|
|
368
|
+
if (Mr(e))
|
|
369
|
+
return {
|
|
370
|
+
name: e.name,
|
|
371
|
+
in: e.in,
|
|
372
|
+
value: Ii(e, t)
|
|
373
|
+
};
|
|
374
|
+
}).filter((e) => e !== void 0);
|
|
375
|
+
}
|
|
376
|
+
function Ai(r) {
|
|
377
|
+
const t = {};
|
|
378
|
+
for (const e of r)
|
|
379
|
+
Mr(e) && (t[(e.name + ":" + e.in).toLowerCase()] = e);
|
|
380
|
+
return Object.values(t);
|
|
381
|
+
}
|
|
382
|
+
function Ri(r, t) {
|
|
383
|
+
let e, n;
|
|
384
|
+
if (r.includes("$sourceDescriptions.")) {
|
|
385
|
+
const [, h, d] = r.split(".");
|
|
386
|
+
e = h, n = d;
|
|
387
|
+
} else r.includes(".") ? [e, n] = r.split(".") : (n = r, e = Object.keys(t)[0]);
|
|
388
|
+
const a = Object.keys(t);
|
|
389
|
+
if (!t[e])
|
|
390
|
+
throw new Error(`Unknown description name ${U(e)} at ${U(r)}. Available descriptions: ${a.join(", ")}.`);
|
|
391
|
+
const c = t[e], f = c?.components?.securitySchemes, l = c.servers;
|
|
392
|
+
for (const [h, d] of Object.entries(t[e].paths)) {
|
|
393
|
+
if (!d)
|
|
394
|
+
return;
|
|
395
|
+
for (const [g, k] of Object.entries(d))
|
|
396
|
+
if (k.operationId === n)
|
|
397
|
+
return {
|
|
398
|
+
servers: d.servers || l,
|
|
399
|
+
...k,
|
|
400
|
+
pathParameters: k.parameters || [],
|
|
401
|
+
path: h,
|
|
402
|
+
method: g,
|
|
403
|
+
descriptionName: e,
|
|
404
|
+
securitySchemes: f
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
throw new Error(`Unknown operationId ${U(n)} at ${U(r)}.`);
|
|
408
|
+
}
|
|
409
|
+
function Oi(r, t) {
|
|
410
|
+
const { $sourceDescriptions: e, sourceDescriptions: n } = t, [a, c] = r.split("#");
|
|
411
|
+
if (!n)
|
|
412
|
+
throw new Error("Missing described sourceDescriptions");
|
|
413
|
+
const f = n.find((T) => {
|
|
414
|
+
if (["openapi", "arazzo"].includes(T.type)) {
|
|
415
|
+
if (a.includes("$sourceDescriptions.")) {
|
|
416
|
+
const [, N] = a.split(".");
|
|
417
|
+
return T.name === N;
|
|
418
|
+
}
|
|
419
|
+
return "url" in T && T.url === a;
|
|
420
|
+
}
|
|
421
|
+
return !1;
|
|
422
|
+
})?.name;
|
|
423
|
+
if (!f)
|
|
424
|
+
throw new Error(`Unknown operationPath ${U(r)}. API description ${U(a)} is not listed in 'sourceDescriptions' workflow section.`);
|
|
425
|
+
const l = e[f] || {}, h = l?.components?.securitySchemes, [d, g, k] = Ee.parse(c);
|
|
426
|
+
if (d !== "paths")
|
|
427
|
+
throw new Error(`Invalid fragment identifier: ${c} at operationPath ${U(r)}.`);
|
|
428
|
+
const { servers: y } = l, C = Ee.get(l, c) || {}, j = Ee.get(l, Ee.compile(["paths", g])) || {};
|
|
429
|
+
return {
|
|
430
|
+
servers: j.servers || y,
|
|
431
|
+
// use servers from path level if exists
|
|
432
|
+
...C,
|
|
433
|
+
// operation level servers override path level or global servers
|
|
434
|
+
pathParameters: j.parameters || [],
|
|
435
|
+
path: g,
|
|
436
|
+
method: k,
|
|
437
|
+
descriptionName: f,
|
|
438
|
+
securitySchemes: h
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
function Ti(r, t) {
|
|
442
|
+
if (!r.operationId && !r.operationPath)
|
|
443
|
+
return;
|
|
444
|
+
const { $sourceDescriptions: e, sourceDescriptions: n } = t, { operationId: a, operationPath: c } = r;
|
|
445
|
+
return a ? Ri(a, e) : c ? Oi(c, { $sourceDescriptions: e, sourceDescriptions: n }) : void 0;
|
|
446
|
+
}
|
|
447
|
+
function Pi({ statusCode: r, contentType: t, descriptionResponses: e }) {
|
|
448
|
+
return e ? (e[r] || e.default)?.content?.[t]?.schema : void 0;
|
|
449
|
+
}
|
|
450
|
+
function Fi(r, t) {
|
|
451
|
+
if (!t)
|
|
452
|
+
return;
|
|
453
|
+
const n = t.requestBody?.content;
|
|
454
|
+
return n && n[r]?.schema || void 0;
|
|
455
|
+
}
|
|
456
|
+
const _i = {
|
|
457
|
+
title: "[REPLACE WITH API title]",
|
|
458
|
+
version: "[REPLACE WITH API version]"
|
|
459
|
+
};
|
|
460
|
+
function as(r, t) {
|
|
461
|
+
if (r)
|
|
462
|
+
try {
|
|
463
|
+
return Io(r, { skipReadOnly: !0, skipNonRequired: !1, quiet: !0 });
|
|
464
|
+
} catch (e) {
|
|
465
|
+
t.error(rr(" Error while generating test data from JSON Schema ") + `
|
|
466
|
+
` + e);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
function Ii(r, t) {
|
|
471
|
+
if (r?.example)
|
|
472
|
+
return r.example;
|
|
473
|
+
if (r?.examples)
|
|
474
|
+
return ts(r.examples);
|
|
475
|
+
if (r?.schema)
|
|
476
|
+
return as(r.schema, t);
|
|
477
|
+
}
|
|
478
|
+
function Di(r) {
|
|
479
|
+
return r == null ? !0 : r.constructor.name === "FormData" || r instanceof Blob && r.size > 0 ? !1 : typeof r == "object" ? Object.keys(r).length === 0 : typeof r == "string" || Array.isArray(r) ? r.length === 0 : !1;
|
|
480
|
+
}
|
|
481
|
+
function Ni(r) {
|
|
482
|
+
return !Do && process.env.NODE_ENV === "test" ? "<test>ms" : `${Math.ceil(performance.now() - r)}ms`;
|
|
483
|
+
}
|
|
484
|
+
function Vr(r) {
|
|
485
|
+
const t = r.length;
|
|
486
|
+
let e = 0, n = 0, a = 0, c = 0, f = 0, l = 0, h = 0;
|
|
487
|
+
const d = /* @__PURE__ */ new Set();
|
|
488
|
+
let g = 0;
|
|
489
|
+
const k = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set();
|
|
490
|
+
for (const C of r) {
|
|
491
|
+
const j = cs(C.executedSteps);
|
|
492
|
+
let T = !1;
|
|
493
|
+
for (const N of j) {
|
|
494
|
+
if (c++, N.retriesLeft && N.retriesLeft !== 0)
|
|
495
|
+
continue;
|
|
496
|
+
a++;
|
|
497
|
+
let P = !1;
|
|
498
|
+
for (const L of N.checks)
|
|
499
|
+
if (n++, !L.passed)
|
|
500
|
+
switch (L.severity) {
|
|
501
|
+
case "warn":
|
|
502
|
+
f++, d.add(C.workflowId), y.add(C.workflowId + ":" + N.stepId);
|
|
503
|
+
break;
|
|
504
|
+
case "off":
|
|
505
|
+
l++, k.add(C.workflowId + ":" + N.stepId);
|
|
506
|
+
break;
|
|
507
|
+
default:
|
|
508
|
+
e++, P = !0;
|
|
509
|
+
}
|
|
510
|
+
P && (g++, T = !0);
|
|
511
|
+
}
|
|
512
|
+
T && h++;
|
|
513
|
+
}
|
|
514
|
+
return {
|
|
515
|
+
workflows: {
|
|
516
|
+
passed: t - h,
|
|
517
|
+
failed: h,
|
|
518
|
+
warnings: d.size,
|
|
519
|
+
skipped: 0,
|
|
520
|
+
total: t
|
|
521
|
+
},
|
|
522
|
+
steps: {
|
|
523
|
+
passed: a - g,
|
|
524
|
+
failed: g,
|
|
525
|
+
warnings: y.size,
|
|
526
|
+
skipped: k.size,
|
|
527
|
+
total: a
|
|
528
|
+
},
|
|
529
|
+
checks: {
|
|
530
|
+
passed: n - e,
|
|
531
|
+
failed: e,
|
|
532
|
+
warnings: f,
|
|
533
|
+
skipped: l,
|
|
534
|
+
total: n
|
|
535
|
+
},
|
|
536
|
+
totalRequests: c
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function cs(r) {
|
|
540
|
+
return r.flatMap((t) => "executedSteps" in t ? cs(t.executedSteps) : [t]);
|
|
541
|
+
}
|
|
542
|
+
function Li({ startedAt: r, workflows: t, options: e }) {
|
|
543
|
+
const { logger: n } = e, a = Y.basename(e?.file || ""), c = ar(e?.workflow) || [], f = ar(e?.skip) || [];
|
|
544
|
+
let l = c && c.length ? t.filter(({ workflowId: g }) => c.includes(g)) : t;
|
|
545
|
+
l = f && f.length ? l.filter(({ workflowId: g }) => !f.includes(g)) : l;
|
|
546
|
+
const h = Vr(l), d = Ni(r);
|
|
547
|
+
n.printNewLine(), n.output(No`
|
|
548
|
+
${fr(X(`Summary for ${Re(a)}`, 2))}
|
|
549
|
+
${X("", 2)}
|
|
550
|
+
${X(ji("Workflows:", h.workflows), 2)}
|
|
551
|
+
${X(Bt("Steps:", h.steps), 2)}
|
|
552
|
+
${X(Bt("Checks:", h.checks), 2)}
|
|
553
|
+
${X(Zt(`Time: ${d}`), 2)}
|
|
554
|
+
`), n.printNewLine(), n.printNewLine();
|
|
555
|
+
}
|
|
556
|
+
function ji(r, t) {
|
|
557
|
+
return ur(r) + (t.passed ? ` ${Yt(t.passed + " passed")},` : "") + (t.failed ? ` ${U(t.failed + " failed")},` : "") + ` ${t.total} total`;
|
|
558
|
+
}
|
|
559
|
+
function Bt(r, t) {
|
|
560
|
+
return ur(r) + (t.passed ? ` ${Yt(t.passed + " passed")},` : "") + (t.failed ? ` ${U(t.failed + " failed")},` : "") + (t.warnings ? ` ${fr(t.warnings + " warnings")},` : "") + (t.skipped ? ` ${we(t.skipped + " ignored")},` : "") + ` ${t.total} total`;
|
|
561
|
+
}
|
|
562
|
+
const xt = {
|
|
563
|
+
SUCCESS_CRITERIA_CHECK: "error",
|
|
564
|
+
STATUS_CODE_CHECK: "error",
|
|
565
|
+
SCHEMA_CHECK: "error",
|
|
566
|
+
CONTENT_TYPE_CHECK: "error",
|
|
567
|
+
GLOBAL_TIMEOUT_ERROR: "error",
|
|
568
|
+
MAX_STEPS_REACHED_ERROR: "error",
|
|
569
|
+
NETWORK_ERROR: "error",
|
|
570
|
+
UNEXPECTED_ERROR: "error"
|
|
571
|
+
};
|
|
572
|
+
function Wi(r) {
|
|
573
|
+
if (!r)
|
|
574
|
+
return xt;
|
|
575
|
+
const t = Kr(r);
|
|
576
|
+
if (Object.keys(t).length === 0)
|
|
577
|
+
throw new Error(`Failed to parse severity configuration, please check the format ${r}`);
|
|
578
|
+
return {
|
|
579
|
+
...xt,
|
|
580
|
+
...t,
|
|
581
|
+
UNEXPECTED_ERROR: "error",
|
|
582
|
+
NETWORK_ERROR: "error"
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function fs(r) {
|
|
586
|
+
return r.flatMap((t) => "executedSteps" in t ? fs(t.executedSteps) : [t]);
|
|
587
|
+
}
|
|
588
|
+
function qi(r, t) {
|
|
589
|
+
t.output(`${Ze}
|
|
590
|
+
${X(U("Failed tests info:"), 2)}
|
|
591
|
+
`);
|
|
592
|
+
for (const e of r) {
|
|
593
|
+
const n = fs(e.executedSteps);
|
|
594
|
+
if (n.some((c) => c.checks.some((f) => !f.passed) && (!c.retriesLeft || c.retriesLeft === 0))) {
|
|
595
|
+
t.output(`${Ze}
|
|
596
|
+
${X(we("Workflow name:"), 2)} ${Lo(e.workflowId)}${Ze}
|
|
597
|
+
`);
|
|
598
|
+
for (const c of n) {
|
|
599
|
+
const f = c.checks.filter((l) => !l.passed);
|
|
600
|
+
if (f.length && !(c.retriesLeft && c.retriesLeft !== 0)) {
|
|
601
|
+
t.printNewLine(), t.output(X(`${Re("stepId - ")}`, 4) + (c?.stepId ? U(c.stepId) : U(c?.operationId || c?.operationPath || "")));
|
|
602
|
+
for (const l in f) {
|
|
603
|
+
const { name: h, message: d, severity: g } = f[l], y = [
|
|
604
|
+
V.UNEXPECTED_ERROR,
|
|
605
|
+
V.GLOBAL_TIMEOUT_ERROR,
|
|
606
|
+
V.MAX_STEPS_REACHED_ERROR
|
|
607
|
+
].includes(h) ? X(`Reason: ${d}`, 4) : X(`${jo(d)}${Ze}
|
|
608
|
+
`, 6);
|
|
609
|
+
t.printNewLine(), g === "error" ? t.output(X(`${U("✗")} ${we(h.toLowerCase())}`, 4)) : g === "off" ? t.output(X(`${we("○")} ${we(h.toLowerCase())} ${we("(skipped)")}`, 4)) : t.output(X(`${fr("⚠")} ${we(h.toLowerCase())}`, 4)), t.printNewLine(), t.output(`${y}`);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
function Lr({ headerParams: r, path: t, method: e, host: n, body: a, statusCode: c, responseTime: f, responseSize: l }) {
|
|
617
|
+
const h = {
|
|
618
|
+
path: t,
|
|
619
|
+
method: e,
|
|
620
|
+
host: n
|
|
621
|
+
};
|
|
622
|
+
return r && Object.keys(r).length > 0 && (h.headerParams = r), a && (a instanceof FormData || a instanceof File || a instanceof ArrayBuffer || Object.keys(a).length > 0) && (h.body = a), c && (h.statusCode = c), f && (h.responseTime = f), l !== void 0 && (h.responseSize = l), h;
|
|
623
|
+
}
|
|
624
|
+
function Wr(r, t = /* @__PURE__ */ new WeakMap()) {
|
|
625
|
+
if (!Array.isArray(r) && !cr(r))
|
|
626
|
+
return r;
|
|
627
|
+
if (t.has(r))
|
|
628
|
+
return t.get(r);
|
|
629
|
+
if (r instanceof ArrayBuffer || r instanceof File || r instanceof Blob || r instanceof FormData || r instanceof Date || r instanceof RegExp || r instanceof Map || r instanceof Set || r instanceof URL || r instanceof Error)
|
|
630
|
+
return r;
|
|
631
|
+
if (Array.isArray(r)) {
|
|
632
|
+
const n = [];
|
|
633
|
+
t.set(r, n);
|
|
634
|
+
for (let a = 0; a < r.length; a++)
|
|
635
|
+
n[a] = Wr(r[a], t);
|
|
636
|
+
return n;
|
|
637
|
+
}
|
|
638
|
+
const e = {};
|
|
639
|
+
t.set(r, e);
|
|
640
|
+
for (const n in r)
|
|
641
|
+
Object.prototype.hasOwnProperty.call(r, n) && (e[n] = Wr(r[n], t));
|
|
642
|
+
return e;
|
|
643
|
+
}
|
|
644
|
+
const Ui = [
|
|
645
|
+
"token",
|
|
646
|
+
"access_token",
|
|
647
|
+
"id_token",
|
|
648
|
+
"password",
|
|
649
|
+
"client_secret"
|
|
650
|
+
];
|
|
651
|
+
function zi(r, t) {
|
|
652
|
+
const e = (f, l) => f.replace(l, "*".repeat(8));
|
|
653
|
+
if (typeof r == "string") {
|
|
654
|
+
let f = r;
|
|
655
|
+
return t.forEach((l) => {
|
|
656
|
+
f = f.split(l).join("*".repeat(8));
|
|
657
|
+
}), f;
|
|
658
|
+
}
|
|
659
|
+
const n = Wr(r), a = (f) => {
|
|
660
|
+
let l = f;
|
|
661
|
+
for (const h of t)
|
|
662
|
+
l.includes(h) && (l = e(l, h));
|
|
663
|
+
return l;
|
|
664
|
+
}, c = (f) => {
|
|
665
|
+
for (const l in f)
|
|
666
|
+
typeof f[l] == "string" ? f[l] = a(f[l]) : typeof f[l] == "object" && f[l] !== null && !(f[l] instanceof File) && !(f[l] instanceof ArrayBuffer) && !(f[l] instanceof Blob) && !(f[l] instanceof FormData) && !(f[l] instanceof Date) && !(f[l] instanceof RegExp) && !(f[l] instanceof Map) && !(f[l] instanceof Set) && !(f[l] instanceof URL) && !(f[l] instanceof Error) && c(f[l]);
|
|
667
|
+
};
|
|
668
|
+
return c(n), n;
|
|
669
|
+
}
|
|
670
|
+
function Mt(r, t = Ui) {
|
|
671
|
+
const e = [];
|
|
672
|
+
if (!r || typeof r != "object")
|
|
673
|
+
return e;
|
|
674
|
+
const n = (a) => {
|
|
675
|
+
if (!(!a || typeof a != "object")) {
|
|
676
|
+
if (Array.isArray(a)) {
|
|
677
|
+
for (const c of a)
|
|
678
|
+
n(c);
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
for (const c in a) {
|
|
682
|
+
const f = a[c];
|
|
683
|
+
if (t.some((l) => l.toLowerCase() === c.toLowerCase()) && typeof f == "string" && f.trim() && e.push(f), typeof f == "string" && f.trim())
|
|
684
|
+
for (const l of t) {
|
|
685
|
+
const h = f.match(new RegExp(`${l}=([^;\\s]+)`, "i")), [, d] = h || [];
|
|
686
|
+
d && e.push(d);
|
|
687
|
+
}
|
|
688
|
+
f && typeof f == "object" && n(f);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
return n(r), e;
|
|
693
|
+
}
|
|
694
|
+
function ge({ value: r, noSecretsMasking: t, secretsSet: e }) {
|
|
695
|
+
return t ? r : zi(r, e);
|
|
696
|
+
}
|
|
697
|
+
function Bi(r) {
|
|
698
|
+
const t = r.replace("Digest ", "").split(",").map((a) => a.trim());
|
|
699
|
+
return Object.fromEntries(["realm", "nonce", "opaque", "qop", "algorithm", "cnonce", "nc"].map((a) => [
|
|
700
|
+
a,
|
|
701
|
+
t.find((c) => c.startsWith(`${a}=`))?.split("=")[1]?.replace(/"/g, "")
|
|
702
|
+
]));
|
|
703
|
+
}
|
|
704
|
+
const us = "MD5", ls = "00000001";
|
|
705
|
+
function xi({ username: r, password: t, nonce: e, realm: n, cnonce: a, algorithm: c = us, qop: f, nc: l = ls, opaque: h, uri: d, method: g, bodyContent: k = "" }) {
|
|
706
|
+
const y = {
|
|
707
|
+
username: r,
|
|
708
|
+
password: t,
|
|
709
|
+
realm: n,
|
|
710
|
+
nonce: e,
|
|
711
|
+
qop: f,
|
|
712
|
+
opaque: h,
|
|
713
|
+
uri: d,
|
|
714
|
+
method: g
|
|
715
|
+
}, C = Object.entries(y).filter(([N, P]) => !P).map(([N]) => N);
|
|
716
|
+
if (C.length > 0)
|
|
717
|
+
throw new Error(`Missing required digest auth parameters: ${C.join(", ")}`);
|
|
718
|
+
const j = Mi({
|
|
719
|
+
...y,
|
|
720
|
+
cnonce: a,
|
|
721
|
+
algorithm: c,
|
|
722
|
+
nc: l,
|
|
723
|
+
bodyContent: k
|
|
724
|
+
}), T = [
|
|
725
|
+
`username="${r}"`,
|
|
726
|
+
`realm="${n}"`,
|
|
727
|
+
`nonce="${e}"`,
|
|
728
|
+
`uri="${d}"`,
|
|
729
|
+
`qop=${f}`,
|
|
730
|
+
`nc=${l}`,
|
|
731
|
+
`cnonce="${a}"`,
|
|
732
|
+
`response="${j}"`,
|
|
733
|
+
`algorithm=${c}`
|
|
734
|
+
];
|
|
735
|
+
return h && T.push(`opaque="${h}"`), `Digest ${T.join(", ")}`;
|
|
736
|
+
}
|
|
737
|
+
function Mi(r) {
|
|
738
|
+
const { username: t, password: e, realm: n, nonce: a, cnonce: c, algorithm: f = us, qop: l, nc: h = ls, uri: d, method: g, bodyContent: k } = r, y = f.endsWith("-sess") ? me(f)(me(f)(`${t}:${n}:${e}`) + `:${a}:${c}`) : me(f)(`${t}:${n}:${e}`), C = l.includes("auth-int") ? me(f)(`${g}:${d}:${me(f)(k)}`) : me(f)(`${g}:${d}`);
|
|
739
|
+
return me(f)(`${y}:${a}:${h}:${c}:${l}:${C}`);
|
|
740
|
+
}
|
|
741
|
+
function me(r) {
|
|
742
|
+
switch (r.replace("-sess", "").toUpperCase()) {
|
|
743
|
+
case "SHA-256":
|
|
744
|
+
return (e) => Dt(qo(e));
|
|
745
|
+
default:
|
|
746
|
+
return (e) => Dt(Wo(e));
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
function Vi(r) {
|
|
750
|
+
return [
|
|
751
|
+
"application/octet-stream",
|
|
752
|
+
"application/pdf",
|
|
753
|
+
"image/",
|
|
754
|
+
"audio/",
|
|
755
|
+
"video/",
|
|
756
|
+
"application/zip",
|
|
757
|
+
"application/x-zip-compressed",
|
|
758
|
+
"application/gzip",
|
|
759
|
+
"application/x-gzip",
|
|
760
|
+
"application/x-bzip2",
|
|
761
|
+
"application/x-tar",
|
|
762
|
+
"application/x-rar-compressed",
|
|
763
|
+
"application/x-7z-compressed",
|
|
764
|
+
"application/vnd.openxmlformats-officedocument",
|
|
765
|
+
"application/vnd.ms-excel",
|
|
766
|
+
"application/vnd.ms-powerpoint",
|
|
767
|
+
"application/msword",
|
|
768
|
+
"application/x-shockwave-flash",
|
|
769
|
+
"application/x-font-",
|
|
770
|
+
"font/",
|
|
771
|
+
"application/x-font-ttf"
|
|
772
|
+
].some((e) => r.startsWith(e));
|
|
773
|
+
}
|
|
774
|
+
function je(r) {
|
|
775
|
+
return /^application\/([a-z.-]+\+)?json$/.test(r);
|
|
776
|
+
}
|
|
777
|
+
function Ki(r) {
|
|
778
|
+
return /^application\/([a-z.-]+\+)?xml$/.test(r);
|
|
779
|
+
}
|
|
780
|
+
function Hi(r) {
|
|
781
|
+
return r.endsWith("/") ? r.slice(0, -1) : r;
|
|
782
|
+
}
|
|
783
|
+
class Ji {
|
|
784
|
+
constructor(t) {
|
|
785
|
+
this.initVerboseLogs = ({ headerParams: e, host: n, path: a, method: c, body: f }) => {
|
|
786
|
+
this.verboseLogs = Lr({
|
|
787
|
+
headerParams: e,
|
|
788
|
+
host: n,
|
|
789
|
+
path: a,
|
|
790
|
+
method: c,
|
|
791
|
+
body: f instanceof FormData || f instanceof File ? f : JSON.stringify(f)
|
|
792
|
+
});
|
|
793
|
+
}, this.getVerboseLogs = () => this.verboseLogs, this.updateVerboseLogs = (e) => {
|
|
794
|
+
if (!this.verboseLogs)
|
|
795
|
+
throw new Error("Verbose logs not initialized");
|
|
796
|
+
this.verboseLogs = Lr({
|
|
797
|
+
...this.verboseLogs,
|
|
798
|
+
...e
|
|
799
|
+
});
|
|
800
|
+
}, this.initVerboseResponseLogs = ({ headerParams: e, host: n, path: a, method: c, body: f, statusCode: l, responseTime: h, responseSize: d }) => {
|
|
801
|
+
this.verboseResponseLogs = Lr({
|
|
802
|
+
headerParams: e,
|
|
803
|
+
host: n,
|
|
804
|
+
path: a,
|
|
805
|
+
method: c,
|
|
806
|
+
body: f,
|
|
807
|
+
statusCode: l,
|
|
808
|
+
responseTime: h,
|
|
809
|
+
responseSize: d
|
|
810
|
+
});
|
|
811
|
+
}, this.getVerboseResponseLogs = () => this.verboseResponseLogs, this.fetchResult = async ({ ctx: e, step: n, requestData: a, workflowId: c }) => {
|
|
812
|
+
const { serverUrl: f, path: l, method: h, parameters: d, requestBody: g, openapiOperation: k } = a;
|
|
813
|
+
if (!f?.url)
|
|
814
|
+
throw e.options.logger.error(rr(" No server url provided ")), new Error("No server url provided");
|
|
815
|
+
const y = {}, C = new URLSearchParams(), j = {}, T = {};
|
|
816
|
+
for (const R of d)
|
|
817
|
+
switch (R.in) {
|
|
818
|
+
case "header":
|
|
819
|
+
y[R.name.toLowerCase()] = String(R.value);
|
|
820
|
+
break;
|
|
821
|
+
case "query":
|
|
822
|
+
C.set(R.name, String(R.value));
|
|
823
|
+
break;
|
|
824
|
+
case "path":
|
|
825
|
+
j[R.name] = String(R.value);
|
|
826
|
+
break;
|
|
827
|
+
case "cookie":
|
|
828
|
+
T[R.name] = String(R.value);
|
|
829
|
+
break;
|
|
830
|
+
}
|
|
831
|
+
typeof g == "object" && !y["content-type"] && (y["content-type"] = "application/json"), Object.keys(T).length && (y.cookie = Object.entries(T).map(([R, Z]) => `${R}=${Z}`).join("; "));
|
|
832
|
+
const P = `${qt(l, j) || ""}${C.toString() ? "?" + C.toString() : ""}`, L = qt(f.url, j) || "", D = `${Hi(L)}${P}`;
|
|
833
|
+
D.startsWith("/") && e.options.logger.error(rr(` Wrong url: ${Zt(D)} `) + ` Did you forget to provide a correct "serverUrl"?
|
|
834
|
+
`);
|
|
835
|
+
const b = y["content-type"] || "";
|
|
836
|
+
g && !b && e.options.logger.error(rr(" Incorrect request ") + ` Please provide a correct "content-type" header or specify the "content-type" field in the test case itself.
|
|
837
|
+
`);
|
|
838
|
+
let A;
|
|
839
|
+
if (b === "application/x-www-form-urlencoded")
|
|
840
|
+
A = new URLSearchParams(g).toString();
|
|
841
|
+
else if (je(b || ""))
|
|
842
|
+
A = JSON.stringify(g);
|
|
843
|
+
else if (Ki(b))
|
|
844
|
+
A = g;
|
|
845
|
+
else if (b.includes("multipart/form-data"))
|
|
846
|
+
A = g, delete y["content-type"];
|
|
847
|
+
else if (b === "application/octet-stream") {
|
|
848
|
+
if (A = g, g instanceof File) {
|
|
849
|
+
const R = g.name;
|
|
850
|
+
y["content-disposition"] = `attachment; filename=${R}`;
|
|
851
|
+
}
|
|
852
|
+
} else
|
|
853
|
+
A = g;
|
|
854
|
+
const K = ge({
|
|
855
|
+
value: y,
|
|
856
|
+
noSecretsMasking: e.noSecretsMasking,
|
|
857
|
+
secretsSet: e.secretsSet
|
|
858
|
+
});
|
|
859
|
+
let _;
|
|
860
|
+
if (A instanceof FormData) {
|
|
861
|
+
const R = new FormData();
|
|
862
|
+
for (const [Z, le] of A.entries())
|
|
863
|
+
if (le instanceof File)
|
|
864
|
+
R.append(Z, le);
|
|
865
|
+
else {
|
|
866
|
+
const _e = ge({
|
|
867
|
+
value: le,
|
|
868
|
+
noSecretsMasking: e.noSecretsMasking,
|
|
869
|
+
secretsSet: e.secretsSet
|
|
870
|
+
});
|
|
871
|
+
R.append(Z, _e);
|
|
872
|
+
}
|
|
873
|
+
_ = R;
|
|
874
|
+
} else je(b) && A ? _ = ge({
|
|
875
|
+
value: JSON.parse(A),
|
|
876
|
+
noSecretsMasking: e.noSecretsMasking,
|
|
877
|
+
secretsSet: e.secretsSet
|
|
878
|
+
}) : _ = A;
|
|
879
|
+
const W = ge({
|
|
880
|
+
value: P,
|
|
881
|
+
noSecretsMasking: e.noSecretsMasking,
|
|
882
|
+
secretsSet: e.secretsSet
|
|
883
|
+
});
|
|
884
|
+
this.initVerboseLogs({
|
|
885
|
+
headerParams: K,
|
|
886
|
+
host: L,
|
|
887
|
+
method: h.toUpperCase(),
|
|
888
|
+
path: W || "",
|
|
889
|
+
body: _
|
|
890
|
+
});
|
|
891
|
+
const z = e.options.fetch, x = performance.now();
|
|
892
|
+
let I, B, H;
|
|
893
|
+
const ee = {
|
|
894
|
+
method: h.toUpperCase(),
|
|
895
|
+
headers: y,
|
|
896
|
+
...!Di(g) && {
|
|
897
|
+
body: A
|
|
898
|
+
},
|
|
899
|
+
redirect: "follow",
|
|
900
|
+
signal: AbortSignal.timeout(e.options.maxFetchTimeout),
|
|
901
|
+
// Required for application/octet-stream content type requests
|
|
902
|
+
...y["content-type"] === "application/octet-stream" && {
|
|
903
|
+
duplex: "half"
|
|
904
|
+
}
|
|
905
|
+
}, ne = [
|
|
906
|
+
...e.workflows.find((R) => R.workflowId === c)?.["x-security"] || [],
|
|
907
|
+
...n["x-security"] || []
|
|
908
|
+
].reverse().find((R) => {
|
|
909
|
+
const Z = R.schemeName ? k?.securitySchemes?.[R.schemeName] : R.scheme;
|
|
910
|
+
return Z?.type === "http" && Z?.scheme === "digest";
|
|
911
|
+
});
|
|
912
|
+
if (ne) {
|
|
913
|
+
const R = await z(D, ee), Z = await R.text(), le = R.headers.get("www-authenticate");
|
|
914
|
+
if (R.status !== 401)
|
|
915
|
+
throw this.initVerboseResponseLogs({
|
|
916
|
+
body: Z,
|
|
917
|
+
method: h,
|
|
918
|
+
host: f.url,
|
|
919
|
+
path: P || "",
|
|
920
|
+
statusCode: R.status,
|
|
921
|
+
responseTime: 0,
|
|
922
|
+
responseSize: void 0
|
|
923
|
+
}), new es(`Digest auth failed, expected 401 status code, but received ${R.status} in the first response`);
|
|
924
|
+
if (!le)
|
|
925
|
+
throw this.initVerboseResponseLogs({
|
|
926
|
+
body: Z,
|
|
927
|
+
method: h,
|
|
928
|
+
host: f.url,
|
|
929
|
+
path: P || "",
|
|
930
|
+
statusCode: R.status,
|
|
931
|
+
responseTime: 0,
|
|
932
|
+
responseSize: void 0
|
|
933
|
+
}), new rs("Digest auth failed, no www-authenticate header received in the first response");
|
|
934
|
+
const { realm: _e, nonce: hr, opaque: gr, qop: mr, algorithm: $r, cnonce: yr, nc: wr } = Bi(le), { username: vr, password: kr } = ne.values, Er = new URL(D).pathname + new URL(D).search, Sr = xi({
|
|
935
|
+
username: vr,
|
|
936
|
+
password: kr,
|
|
937
|
+
realm: _e,
|
|
938
|
+
nonce: hr,
|
|
939
|
+
opaque: gr,
|
|
940
|
+
qop: mr,
|
|
941
|
+
algorithm: $r,
|
|
942
|
+
cnonce: yr,
|
|
943
|
+
nc: wr,
|
|
944
|
+
uri: Er,
|
|
945
|
+
method: h.toUpperCase(),
|
|
946
|
+
bodyContent: JSON.stringify(A) || ""
|
|
947
|
+
}), Ie = {
|
|
948
|
+
...y,
|
|
949
|
+
authorization: Sr
|
|
950
|
+
}, be = e.$workflows[c].steps[n.stepId]?.request;
|
|
951
|
+
be && (be.header = Ie), this.updateVerboseLogs({
|
|
952
|
+
headerParams: ge({
|
|
953
|
+
value: Ie,
|
|
954
|
+
noSecretsMasking: e.noSecretsMasking,
|
|
955
|
+
secretsSet: e.secretsSet
|
|
956
|
+
})
|
|
957
|
+
}), I = await z(D, {
|
|
958
|
+
...ee,
|
|
959
|
+
headers: Ie
|
|
960
|
+
}), H = Math.ceil(performance.now() - x);
|
|
961
|
+
} else
|
|
962
|
+
I = await z(D, ee), H = Math.ceil(performance.now() - x);
|
|
963
|
+
if (!I)
|
|
964
|
+
throw new Error("Failed to fetch, no result received");
|
|
965
|
+
const [re] = I.headers.get("content-type")?.split(";") || [
|
|
966
|
+
"application/json"
|
|
967
|
+
];
|
|
968
|
+
Vi(re) ? B = await I.arrayBuffer() : B = await I.text();
|
|
969
|
+
const ue = B ? B instanceof ArrayBuffer ? B : je(re) ? JSON.parse(B) : B : {}, pr = Pi({
|
|
970
|
+
statusCode: I.status,
|
|
971
|
+
contentType: re,
|
|
972
|
+
descriptionResponses: k?.responses
|
|
973
|
+
});
|
|
974
|
+
Be(e, pr, ue);
|
|
975
|
+
const dr = Mt(ue);
|
|
976
|
+
for (const R of dr)
|
|
977
|
+
e.secretsSet.add(R);
|
|
978
|
+
const Me = je(re) ? ge({
|
|
979
|
+
value: ue,
|
|
980
|
+
noSecretsMasking: e.noSecretsMasking,
|
|
981
|
+
secretsSet: e.secretsSet
|
|
982
|
+
}) : ue, Ve = Object.fromEntries(I.headers?.entries() || []), Ke = Mt(Ve);
|
|
983
|
+
for (const R of Ke)
|
|
984
|
+
e.secretsSet.add(R);
|
|
985
|
+
let ie;
|
|
986
|
+
const Fe = I.headers.get("content-length");
|
|
987
|
+
return Fe && !isNaN(+Fe) ? ie = +Fe : B instanceof ArrayBuffer ? ie = B.byteLength : typeof B == "string" ? ie = new TextEncoder().encode(B).length : ie = void 0, this.initVerboseResponseLogs({
|
|
988
|
+
body: je(re) ? JSON.stringify(Me) : Me,
|
|
989
|
+
method: h,
|
|
990
|
+
host: f.url,
|
|
991
|
+
path: P || "",
|
|
992
|
+
statusCode: I.status,
|
|
993
|
+
responseTime: H,
|
|
994
|
+
headerParams: ge({
|
|
995
|
+
value: Ve,
|
|
996
|
+
noSecretsMasking: e.noSecretsMasking,
|
|
997
|
+
secretsSet: e.secretsSet
|
|
998
|
+
}),
|
|
999
|
+
responseSize: ie
|
|
1000
|
+
}), {
|
|
1001
|
+
body: ue,
|
|
1002
|
+
statusCode: I.status,
|
|
1003
|
+
time: H,
|
|
1004
|
+
header: Object.fromEntries(I.headers?.entries() || []),
|
|
1005
|
+
contentType: re,
|
|
1006
|
+
requestUrl: D,
|
|
1007
|
+
responseSize: ie
|
|
1008
|
+
};
|
|
1009
|
+
}, this.fetch = t.fetch || fetch;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
function Xi() {
|
|
1013
|
+
return {
|
|
1014
|
+
address: {
|
|
1015
|
+
city: () => J.address.city(),
|
|
1016
|
+
country: () => J.address.country(),
|
|
1017
|
+
zipCode: () => J.address.zipCode(),
|
|
1018
|
+
street: () => J.address.street()
|
|
1019
|
+
},
|
|
1020
|
+
date: {
|
|
1021
|
+
past: () => J.date.past(),
|
|
1022
|
+
future: () => J.date.future()
|
|
1023
|
+
},
|
|
1024
|
+
number: {
|
|
1025
|
+
integer: ({ min: a, max: c } = {}) => J.datatype.number({ min: a, max: c, precision: 1 }),
|
|
1026
|
+
float: (a) => J.datatype.float(a)
|
|
1027
|
+
},
|
|
1028
|
+
string: {
|
|
1029
|
+
email: ({ provider: a, domain: c = "com" } = {}) => J.internet.email(void 0, void 0, `${a}.${c}`),
|
|
1030
|
+
userName: () => J.internet.userName(),
|
|
1031
|
+
firstName: () => J.name.firstName(),
|
|
1032
|
+
lastName: () => J.name.lastName(),
|
|
1033
|
+
fullName: () => J.name.fullName(),
|
|
1034
|
+
uuid: () => J.datatype.uuid(),
|
|
1035
|
+
string: ({ length: a } = {}) => J.datatype.string(a)
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
function Kr(r) {
|
|
1040
|
+
return r ? Array.isArray(r) ? r.reduce((t, e) => {
|
|
1041
|
+
const n = Vt(e);
|
|
1042
|
+
return { ...t, ...n };
|
|
1043
|
+
}, {}) : Vt(r) : {};
|
|
1044
|
+
}
|
|
1045
|
+
function Vt(r) {
|
|
1046
|
+
try {
|
|
1047
|
+
const t = JSON.parse(r);
|
|
1048
|
+
if (typeof t == "object" && t !== null)
|
|
1049
|
+
return t;
|
|
1050
|
+
} catch {
|
|
1051
|
+
}
|
|
1052
|
+
if (typeof r == "string") {
|
|
1053
|
+
if (r.includes(","))
|
|
1054
|
+
return r.split(",").reduce((t, e) => {
|
|
1055
|
+
const [n, a] = e.split("=");
|
|
1056
|
+
return n && a && (t[n.trim()] = a.trim()), t;
|
|
1057
|
+
}, {});
|
|
1058
|
+
if (r.includes("=")) {
|
|
1059
|
+
const [t, e] = r.split("=");
|
|
1060
|
+
return { [t.trim()]: e.trim() };
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
return {};
|
|
1064
|
+
}
|
|
1065
|
+
function Kt(r, t) {
|
|
1066
|
+
if (!t || Object.keys(t).length === 0)
|
|
1067
|
+
return {};
|
|
1068
|
+
const e = new Uo({
|
|
1069
|
+
useDefaults: !0,
|
|
1070
|
+
removeAdditional: "all",
|
|
1071
|
+
coerceTypes: !0,
|
|
1072
|
+
strictTypes: !1
|
|
1073
|
+
});
|
|
1074
|
+
e.addFormat("password", !0), e.addFormat("int32", !0), e.addFormat("int64", !0), e.addFormat("float", !0), e.addFormat("double", !0);
|
|
1075
|
+
const n = e.compile(t), a = { ...r };
|
|
1076
|
+
return n(a), a;
|
|
1077
|
+
}
|
|
1078
|
+
function Qi(r, t) {
|
|
1079
|
+
return /\.(yaml|yml|json)$/i.test(r) && !!t.arazzo;
|
|
1080
|
+
}
|
|
1081
|
+
async function ps(r) {
|
|
1082
|
+
const { filePath: t, base: e, externalRefResolver: n, collectSpecData: a, version: c, skipLint: f = !1 } = r;
|
|
1083
|
+
let l = [];
|
|
1084
|
+
const h = Y.basename(t);
|
|
1085
|
+
if (!h)
|
|
1086
|
+
throw new Error("Invalid file name");
|
|
1087
|
+
const d = await zo({
|
|
1088
|
+
extends: ["recommended-strict"],
|
|
1089
|
+
arazzo1Rules: {
|
|
1090
|
+
"no-criteria-xpath": "error",
|
|
1091
|
+
"respect-supported-versions": "warn",
|
|
1092
|
+
"no-x-security-scheme-name-without-openapi": "error",
|
|
1093
|
+
"x-security-scheme-required-values": "error",
|
|
1094
|
+
"no-x-security-scheme-name-in-workflow": "error"
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
if (!f && (l = await Bo({
|
|
1098
|
+
ref: t,
|
|
1099
|
+
config: d,
|
|
1100
|
+
externalRefResolver: n
|
|
1101
|
+
}), l.length)) {
|
|
1102
|
+
const y = xo(l);
|
|
1103
|
+
Mo(l, {
|
|
1104
|
+
totals: y,
|
|
1105
|
+
version: c
|
|
1106
|
+
}), Vo(y, r.logger);
|
|
1107
|
+
}
|
|
1108
|
+
const g = await Gt({
|
|
1109
|
+
base: e,
|
|
1110
|
+
ref: t,
|
|
1111
|
+
config: d,
|
|
1112
|
+
dereference: !0,
|
|
1113
|
+
externalRefResolver: n
|
|
1114
|
+
});
|
|
1115
|
+
if (!g)
|
|
1116
|
+
throw new Error(`Could not find source description file '${h}'.`);
|
|
1117
|
+
if (!Qi(h, g.bundle.parsed))
|
|
1118
|
+
throw new Error(`No test files found. File ${h} does not follows naming pattern "*.[yaml | yml | json]" or have not valid "Arazzo" description.`);
|
|
1119
|
+
if (a?.(g.bundle.parsed || {}), l.filter((y) => y.severity === "error").length)
|
|
1120
|
+
throw new Error(`${U("Found errors in Arazzo description")} ${ur(h)}`);
|
|
1121
|
+
return g.bundle.parsed || {};
|
|
1122
|
+
}
|
|
1123
|
+
function Gi(r, t) {
|
|
1124
|
+
let e = r;
|
|
1125
|
+
for (const n of t)
|
|
1126
|
+
if (e && e[n] !== void 0)
|
|
1127
|
+
e = e[n];
|
|
1128
|
+
else
|
|
1129
|
+
return;
|
|
1130
|
+
return e;
|
|
1131
|
+
}
|
|
1132
|
+
function Zi(r) {
|
|
1133
|
+
const t = {};
|
|
1134
|
+
for (const e of r)
|
|
1135
|
+
t[e.stepId] = {};
|
|
1136
|
+
return t;
|
|
1137
|
+
}
|
|
1138
|
+
function Yi({ workflows: r, inputs: t, env: e = {} }) {
|
|
1139
|
+
const n = {};
|
|
1140
|
+
for (const a of r) {
|
|
1141
|
+
const c = a.inputs, f = ds({ inputs: t, workflowInputSchema: c, env: e });
|
|
1142
|
+
n[a.workflowId] = {
|
|
1143
|
+
steps: Zi(a.steps || []),
|
|
1144
|
+
inputs: c ? f : void 0,
|
|
1145
|
+
outputs: a.outputs
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
return n;
|
|
1149
|
+
}
|
|
1150
|
+
function ds({ inputs: r, workflowInputSchema: t, env: e }) {
|
|
1151
|
+
let n = {}, a = {};
|
|
1152
|
+
return t && (n = Kt(r, t)), t?.properties?.env && (a = Kt(e || {}, t.properties.env)), Object.keys(a).length > 0 ? { ...n, env: a } : n;
|
|
1153
|
+
}
|
|
1154
|
+
const ea = Xi();
|
|
1155
|
+
async function hs(r, t, e) {
|
|
1156
|
+
const n = r?.sourceDescriptions, a = {};
|
|
1157
|
+
n && await Promise.all(n.map(async (f) => {
|
|
1158
|
+
if (f.type === "openapi") {
|
|
1159
|
+
const l = await Zo({
|
|
1160
|
+
descriptionPath: f.url,
|
|
1161
|
+
config: t.config,
|
|
1162
|
+
base: t.filePath,
|
|
1163
|
+
externalRefResolver: t?.externalRefResolver
|
|
1164
|
+
}), { paths: h, servers: d, info: g, security: k, components: y } = l;
|
|
1165
|
+
a[f.name] = {
|
|
1166
|
+
paths: h,
|
|
1167
|
+
servers: d,
|
|
1168
|
+
info: g,
|
|
1169
|
+
security: k,
|
|
1170
|
+
components: y
|
|
1171
|
+
};
|
|
1172
|
+
} else if (f.type === "arazzo") {
|
|
1173
|
+
const { url: l, name: h } = f, d = Y.resolve(Y.dirname(t.filePath), l), g = await ps({
|
|
1174
|
+
filePath: d,
|
|
1175
|
+
version: t?.version,
|
|
1176
|
+
logger: t.logger,
|
|
1177
|
+
externalRefResolver: t?.externalRefResolver,
|
|
1178
|
+
skipLint: t?.skipLint
|
|
1179
|
+
});
|
|
1180
|
+
a[h] = g;
|
|
1181
|
+
}
|
|
1182
|
+
}));
|
|
1183
|
+
for (const f of r.workflows || [])
|
|
1184
|
+
for (const l of f.steps)
|
|
1185
|
+
l.checks = [];
|
|
1186
|
+
const c = {
|
|
1187
|
+
$response: void 0,
|
|
1188
|
+
$request: void 0,
|
|
1189
|
+
$inputs: { env: {} },
|
|
1190
|
+
$faker: ea,
|
|
1191
|
+
$sourceDescriptions: a,
|
|
1192
|
+
$workflows: Yi({
|
|
1193
|
+
workflows: r.workflows || [],
|
|
1194
|
+
inputs: Kr(t?.input),
|
|
1195
|
+
env: t.envVariables || {}
|
|
1196
|
+
}),
|
|
1197
|
+
$steps: {},
|
|
1198
|
+
$components: r.components || {},
|
|
1199
|
+
$outputs: {},
|
|
1200
|
+
executedSteps: [],
|
|
1201
|
+
workflows: r.workflows || [],
|
|
1202
|
+
options: t,
|
|
1203
|
+
testDescription: r,
|
|
1204
|
+
info: r.info || _i,
|
|
1205
|
+
arazzo: r.arazzo || "",
|
|
1206
|
+
sourceDescriptions: r.sourceDescriptions || [],
|
|
1207
|
+
noSecretsMasking: t.noSecretsMasking || !1,
|
|
1208
|
+
secretsSet: /* @__PURE__ */ new Set(),
|
|
1209
|
+
severity: Wi(t.severity),
|
|
1210
|
+
apiClient: e
|
|
1211
|
+
};
|
|
1212
|
+
for (const f of r.workflows || [])
|
|
1213
|
+
f.inputs && Be(c, f.inputs, c.$workflows[f.workflowId].inputs);
|
|
1214
|
+
return c;
|
|
1215
|
+
}
|
|
1216
|
+
function Be(r, t, e, n = []) {
|
|
1217
|
+
if (!t || !e)
|
|
1218
|
+
return;
|
|
1219
|
+
const a = Gi(e, n);
|
|
1220
|
+
t.format === "password" && a && r.secretsSet.add(a), t.properties && Object.entries(t.properties).forEach(([c, f]) => {
|
|
1221
|
+
const l = [...n, c];
|
|
1222
|
+
Be(r, f, e, l);
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
function ra({ workflows: r, workflowsToRun: t, workflowsToSkip: e, logger: n }) {
|
|
1226
|
+
let a = [];
|
|
1227
|
+
return t && t.length ? a = sa(r, t, n) : e && e.length ? a = ta(r, e, n) : a = r, a;
|
|
1228
|
+
}
|
|
1229
|
+
function ta(r, t, e) {
|
|
1230
|
+
const n = r.filter((a) => !t.includes(a.workflowId));
|
|
1231
|
+
return n.length ? (e.output(`${fr(`Following workflows are skipped: ${t.join(", ")}`)}`), e.printNewLine(), n) : (e.output(`${U("All workflows are skipped")}`), e.printNewLine(), []);
|
|
1232
|
+
}
|
|
1233
|
+
function sa(r, t, e) {
|
|
1234
|
+
const n = na(r, t);
|
|
1235
|
+
if (!n.length)
|
|
1236
|
+
throw new Error(`Following workflows don't exist: ${t.join(", ")}`);
|
|
1237
|
+
if (n.length === t.length)
|
|
1238
|
+
return n;
|
|
1239
|
+
{
|
|
1240
|
+
const a = t.filter((c) => !r.find((f) => f.workflowId === c));
|
|
1241
|
+
return e.output(`Following workflows don't exist: ${a.join(", ")}`), n;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
function na(r, t) {
|
|
1245
|
+
return r.filter((e) => t.includes(e.workflowId));
|
|
1246
|
+
}
|
|
1247
|
+
function gs(r) {
|
|
1248
|
+
return r.type === "regex";
|
|
1249
|
+
}
|
|
1250
|
+
function ms(r) {
|
|
1251
|
+
const t = r?.type;
|
|
1252
|
+
return t === "jsonpath" || typeof t == "object" && t?.type === "jsonpath";
|
|
1253
|
+
}
|
|
1254
|
+
const Ht = [
|
|
1255
|
+
"$url",
|
|
1256
|
+
"$method",
|
|
1257
|
+
"$statusCode",
|
|
1258
|
+
"$request",
|
|
1259
|
+
"$response",
|
|
1260
|
+
"$inputs",
|
|
1261
|
+
"$outputs",
|
|
1262
|
+
"$steps",
|
|
1263
|
+
"$workflows",
|
|
1264
|
+
"$sourceDescriptions",
|
|
1265
|
+
"$components"
|
|
1266
|
+
];
|
|
1267
|
+
function oa(r) {
|
|
1268
|
+
r.forEach((t) => {
|
|
1269
|
+
const { condition: e } = t;
|
|
1270
|
+
if (gs(t)) {
|
|
1271
|
+
const { context: n } = t, a = /\$[a-zA-Z_]\w*/g, c = n.match(a);
|
|
1272
|
+
if (!c)
|
|
1273
|
+
throw new Error(`"${n}" does not contain any valid context.`);
|
|
1274
|
+
if (c.filter((l) => !Ht.includes(l)).length)
|
|
1275
|
+
throw new Error(`Success criteria context "${n}" is not allowed.`);
|
|
1276
|
+
} else if (ms(t)) {
|
|
1277
|
+
if (!t.context)
|
|
1278
|
+
throw new Error("jsonpath success criteria context is required.");
|
|
1279
|
+
if (!t.condition)
|
|
1280
|
+
throw new Error("jsonpath success criteria condition is required.");
|
|
1281
|
+
} else {
|
|
1282
|
+
const n = /\$[a-zA-Z_]\w*/g, a = e.match(n);
|
|
1283
|
+
if (!a)
|
|
1284
|
+
return;
|
|
1285
|
+
if (a.filter((f) => !Ht.includes(f)).length)
|
|
1286
|
+
throw new Error(`Success criteria condition ${e} is not allowed.`);
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
function lr({ ctx: r, workflowId: t, step: e }) {
|
|
1291
|
+
if (!e || !t)
|
|
1292
|
+
return {
|
|
1293
|
+
$statusCode: void 0,
|
|
1294
|
+
$method: "",
|
|
1295
|
+
$response: void 0,
|
|
1296
|
+
$url: "",
|
|
1297
|
+
$request: void 0,
|
|
1298
|
+
$outputs: r.$outputs,
|
|
1299
|
+
$steps: r.$steps,
|
|
1300
|
+
$workflows: r.$workflows,
|
|
1301
|
+
$inputs: r.$inputs,
|
|
1302
|
+
$sourceDescriptions: r.$sourceDescriptions,
|
|
1303
|
+
$components: r.$components,
|
|
1304
|
+
$faker: r.$faker
|
|
1305
|
+
};
|
|
1306
|
+
const n = r.$workflows[t].steps[e.stepId].request, a = n?.path, c = n?.query, f = n?.body || {}, l = n?.header, h = n?.method, d = e.response?.statusCode, g = e.response?.header || {}, k = e.response?.body || {};
|
|
1307
|
+
return {
|
|
1308
|
+
$statusCode: d,
|
|
1309
|
+
$method: h,
|
|
1310
|
+
$response: {
|
|
1311
|
+
header: g,
|
|
1312
|
+
body: k,
|
|
1313
|
+
path: a,
|
|
1314
|
+
query: c
|
|
1315
|
+
},
|
|
1316
|
+
$url: n && n.url,
|
|
1317
|
+
$request: {
|
|
1318
|
+
header: l,
|
|
1319
|
+
body: f,
|
|
1320
|
+
path: a,
|
|
1321
|
+
query: c
|
|
1322
|
+
},
|
|
1323
|
+
$outputs: r.$outputs,
|
|
1324
|
+
$steps: r.$steps,
|
|
1325
|
+
$workflows: r.$workflows,
|
|
1326
|
+
$inputs: r.$inputs,
|
|
1327
|
+
$sourceDescriptions: r.$sourceDescriptions,
|
|
1328
|
+
$components: r.$components,
|
|
1329
|
+
$faker: r.$faker
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
function ia(r, t) {
|
|
1333
|
+
function e() {
|
|
1334
|
+
this.constructor = r;
|
|
1335
|
+
}
|
|
1336
|
+
e.prototype = t.prototype, r.prototype = new e();
|
|
1337
|
+
}
|
|
1338
|
+
function Oe(r, t, e, n) {
|
|
1339
|
+
var a = Error.call(this, r);
|
|
1340
|
+
return Object.setPrototypeOf && Object.setPrototypeOf(a, Oe.prototype), a.expected = t, a.found = e, a.location = n, a.name = "SyntaxError", a;
|
|
1341
|
+
}
|
|
1342
|
+
ia(Oe, Error);
|
|
1343
|
+
function jr(r, t, e) {
|
|
1344
|
+
return e = e || " ", r.length > t ? r : (t -= r.length, e += e.repeat(t), r + e.slice(0, t));
|
|
1345
|
+
}
|
|
1346
|
+
Oe.prototype.format = function(r) {
|
|
1347
|
+
var t = "Error: " + this.message;
|
|
1348
|
+
if (this.location) {
|
|
1349
|
+
var e = null, n;
|
|
1350
|
+
for (n = 0; n < r.length; n++)
|
|
1351
|
+
if (r[n].source === this.location.source) {
|
|
1352
|
+
e = r[n].text.split(/\r\n|\n|\r/g);
|
|
1353
|
+
break;
|
|
1354
|
+
}
|
|
1355
|
+
var a = this.location.start, c = this.location.source && typeof this.location.source.offset == "function" ? this.location.source.offset(a) : a, f = this.location.source + ":" + c.line + ":" + c.column;
|
|
1356
|
+
if (e) {
|
|
1357
|
+
var l = this.location.end, h = jr("", c.line.toString().length, " "), d = e[a.line - 1], g = a.line === l.line ? l.column : d.length + 1, k = g - a.column || 1;
|
|
1358
|
+
t += `
|
|
1359
|
+
--> ` + f + `
|
|
1360
|
+
` + h + ` |
|
|
1361
|
+
` + c.line + " | " + d + `
|
|
1362
|
+
` + h + " | " + jr("", a.column - 1, " ") + jr("", k, "^");
|
|
1363
|
+
} else
|
|
1364
|
+
t += `
|
|
1365
|
+
at ` + f;
|
|
1366
|
+
}
|
|
1367
|
+
return t;
|
|
1368
|
+
};
|
|
1369
|
+
Oe.buildMessage = function(r, t) {
|
|
1370
|
+
var e = {
|
|
1371
|
+
literal: function(d) {
|
|
1372
|
+
return '"' + a(d.text) + '"';
|
|
1373
|
+
},
|
|
1374
|
+
class: function(d) {
|
|
1375
|
+
var g = d.parts.map(function(k) {
|
|
1376
|
+
return Array.isArray(k) ? c(k[0]) + "-" + c(k[1]) : c(k);
|
|
1377
|
+
});
|
|
1378
|
+
return "[" + (d.inverted ? "^" : "") + g.join("") + "]";
|
|
1379
|
+
},
|
|
1380
|
+
any: function() {
|
|
1381
|
+
return "any character";
|
|
1382
|
+
},
|
|
1383
|
+
end: function() {
|
|
1384
|
+
return "end of input";
|
|
1385
|
+
},
|
|
1386
|
+
other: function(d) {
|
|
1387
|
+
return d.description;
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1390
|
+
function n(d) {
|
|
1391
|
+
return d.charCodeAt(0).toString(16).toUpperCase();
|
|
1392
|
+
}
|
|
1393
|
+
function a(d) {
|
|
1394
|
+
return d.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(g) {
|
|
1395
|
+
return "\\x0" + n(g);
|
|
1396
|
+
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(g) {
|
|
1397
|
+
return "\\x" + n(g);
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
function c(d) {
|
|
1401
|
+
return d.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(g) {
|
|
1402
|
+
return "\\x0" + n(g);
|
|
1403
|
+
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(g) {
|
|
1404
|
+
return "\\x" + n(g);
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
function f(d) {
|
|
1408
|
+
return e[d.type](d);
|
|
1409
|
+
}
|
|
1410
|
+
function l(d) {
|
|
1411
|
+
var g = d.map(f), k, y;
|
|
1412
|
+
if (g.sort(), g.length > 0) {
|
|
1413
|
+
for (k = 1, y = 1; k < g.length; k++)
|
|
1414
|
+
g[k - 1] !== g[k] && (g[y] = g[k], y++);
|
|
1415
|
+
g.length = y;
|
|
1416
|
+
}
|
|
1417
|
+
switch (g.length) {
|
|
1418
|
+
case 1:
|
|
1419
|
+
return g[0];
|
|
1420
|
+
case 2:
|
|
1421
|
+
return g[0] + " or " + g[1];
|
|
1422
|
+
default:
|
|
1423
|
+
return g.slice(0, -1).join(", ") + ", or " + g[g.length - 1];
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
function h(d) {
|
|
1427
|
+
return d ? '"' + a(d) + '"' : "end of input";
|
|
1428
|
+
}
|
|
1429
|
+
return "Expected " + l(r) + " but " + h(t) + " found.";
|
|
1430
|
+
};
|
|
1431
|
+
function aa(r, t) {
|
|
1432
|
+
t = t !== void 0 ? t : {};
|
|
1433
|
+
var e = {}, n = t.grammarSource, a = { jsonpath_query: Rr }, c = Rr, f = "$", l = ".", h = "..", d = "[", g = ",", k = "]", y = "*", C = ":", j = "?", T = '"', N = "'", P = "0", L = "-", D = "||", b = "\\", A = "u", K = "&&", _ = "d", W = "(", z = ")", x = "!", I = "==", B = "!=", H = "<=", ee = ">=", he = "-0", ne = "true", re = "false", ue = "null", pr = "@", dr = "e", Me = /^[\t-\n\r ]/, Ve = /^[A-Z_a-z\x80-\uD7FF\uE000-\uFFFF]/, Ke = /^[\uD800-\uDBFF]/, ie = /^[\uDC00-\uDFFF]/, Fe = /^[0-9]/, R = /^[1-9]/, Z = /^[ -!#-&(-[\]-\uD7FF\uE000-\uFFFF]/, le = /^[\/\\bfnrt]/, _e = /^[A-CE-F]/i, hr = /^[0-7]/, gr = /^[8-9]/, mr = /^[A-B]/i, $r = /^[C-F]/i, yr = /^[A-F]/i, wr = /^[<>]/, vr = /^[0-9_a-z]/, kr = /^[+\-]/, Er = /^[a-z]/, Sr = F("$", !1), Ie = M([[" ", `
|
|
1434
|
+
`], "\r", " "], !1, !1), be = F(".", !1), Ds = F("..", !1), Cr = F("[", !1), He = F(",", !1), br = F("]", !1), Ns = F("*", !1), Ls = M([["A", "Z"], "_", ["a", "z"], ["", ""], ["", ""]], !1, !1), Jr = M([["\uD800", "\uDBFF"]], !1, !1), Xr = M([["\uDC00", "\uDFFF"]], !1, !1), Qr = F(":", !1), js = F("?", !1), Ws = M([["0", "9"]], !1, !1), Je = F('"', !1), Xe = F("'", !1), qs = F("0", !1), Us = F("-", !1), zs = M([["1", "9"]], !1, !1), Gr = F("||", !1), Bs = M([[" ", "!"], ["#", "&"], ["(", "["], ["]", ""], ["", ""]], !1, !1), Zr = F("\\", !1), xs = M(["/", "\\", "b", "f", "n", "r", "t"], !1, !1), Yr = F("u", !1), et = F("&&", !1), Ms = M([["A", "C"], ["E", "F"]], !1, !0), Ar = F("D", !0), Vs = M([["0", "7"]], !1, !1), Ks = M([["8", "9"]], !1, !1), Hs = M([["A", "B"]], !1, !0), Js = M([["C", "F"]], !1, !0), rt = F("(", !1), tt = F(")", !1), Xs = M([["A", "F"]], !1, !0), Qs = F("!", !1), Gs = F("==", !1), Zs = F("!=", !1), Ys = F("<=", !1), en = F(">=", !1), rn = M(["<", ">"], !1, !1), tn = F("-0", !1), sn = F("true", !1), nn = F("false", !1), on = F("null", !1), an = F("@", !1), cn = M([["0", "9"], "_", ["a", "z"]], !1, !1), fn = F("e", !0), un = M(["+", "-"], !1, !1), ln = M([["a", "z"]], !1, !1), pn = function(s) {
|
|
1435
|
+
return {
|
|
1436
|
+
type: "JsonPathQuery",
|
|
1437
|
+
segments: s
|
|
1438
|
+
};
|
|
1439
|
+
}, st = function(s) {
|
|
1440
|
+
return s;
|
|
1441
|
+
}, dn = function(s) {
|
|
1442
|
+
return s;
|
|
1443
|
+
}, hn = function(s) {
|
|
1444
|
+
return { type: "ChildSegment", node: s };
|
|
1445
|
+
}, gn = function(s) {
|
|
1446
|
+
return { type: "DescendantSegment", node: s };
|
|
1447
|
+
}, nt = function(s, o) {
|
|
1448
|
+
return o;
|
|
1449
|
+
}, mn = function(s, o) {
|
|
1450
|
+
return [s, ...o];
|
|
1451
|
+
}, $n = function(s) {
|
|
1452
|
+
return {
|
|
1453
|
+
type: "BracketedSelection",
|
|
1454
|
+
selectors: s
|
|
1455
|
+
};
|
|
1456
|
+
}, yn = function() {
|
|
1457
|
+
return { type: "WildcardSelector" };
|
|
1458
|
+
}, wn = function(s) {
|
|
1459
|
+
return { type: "MemberNameShorthand", value: s };
|
|
1460
|
+
}, vn = function(s) {
|
|
1461
|
+
return { type: "NameSelector", value: s };
|
|
1462
|
+
}, kn = function(s, o, u) {
|
|
1463
|
+
return u;
|
|
1464
|
+
}, En = function(s, o, u) {
|
|
1465
|
+
return { start: s, end: o, step: u };
|
|
1466
|
+
}, Sn = function(s) {
|
|
1467
|
+
return {
|
|
1468
|
+
type: "SliceSelector",
|
|
1469
|
+
start: s.start === "" ? null : Number.parseInt(s.start.trim(), 10),
|
|
1470
|
+
end: s.end === "" ? null : Number.parseInt(s.end.trim(), 10),
|
|
1471
|
+
step: s.step === "" || s.step === null ? null : Number.parseInt(s.step.trim(), 10)
|
|
1472
|
+
};
|
|
1473
|
+
}, Cn = function(s) {
|
|
1474
|
+
return { type: "IndexSelector", value: Number.parseInt(s, 10) };
|
|
1475
|
+
}, bn = function(s) {
|
|
1476
|
+
return { type: "FilterSelector", value: s };
|
|
1477
|
+
}, An = function(s) {
|
|
1478
|
+
return s;
|
|
1479
|
+
}, Rn = function(s) {
|
|
1480
|
+
return s;
|
|
1481
|
+
}, On = function(s) {
|
|
1482
|
+
return s.join("");
|
|
1483
|
+
}, Tn = function() {
|
|
1484
|
+
return '"';
|
|
1485
|
+
}, Pn = function(s) {
|
|
1486
|
+
switch (s) {
|
|
1487
|
+
case "b":
|
|
1488
|
+
return "\b";
|
|
1489
|
+
case "f":
|
|
1490
|
+
return "\f";
|
|
1491
|
+
case "n":
|
|
1492
|
+
return `
|
|
1493
|
+
`;
|
|
1494
|
+
case "r":
|
|
1495
|
+
return "\r";
|
|
1496
|
+
case "t":
|
|
1497
|
+
return " ";
|
|
1498
|
+
case "/":
|
|
1499
|
+
return "/";
|
|
1500
|
+
case "\\":
|
|
1501
|
+
return "\\";
|
|
1502
|
+
default:
|
|
1503
|
+
return s.slice(1);
|
|
1504
|
+
}
|
|
1505
|
+
}, Fn = function() {
|
|
1506
|
+
return "'";
|
|
1507
|
+
}, _n = function(s) {
|
|
1508
|
+
switch (s) {
|
|
1509
|
+
case "b":
|
|
1510
|
+
return "\b";
|
|
1511
|
+
case "f":
|
|
1512
|
+
return "\f";
|
|
1513
|
+
case "n":
|
|
1514
|
+
return `
|
|
1515
|
+
`;
|
|
1516
|
+
case "r":
|
|
1517
|
+
return "\r";
|
|
1518
|
+
case "t":
|
|
1519
|
+
return " ";
|
|
1520
|
+
case "/":
|
|
1521
|
+
return "/";
|
|
1522
|
+
case "\\":
|
|
1523
|
+
return "\\";
|
|
1524
|
+
default:
|
|
1525
|
+
return s.slice(1);
|
|
1526
|
+
}
|
|
1527
|
+
}, ot = function(s, o) {
|
|
1528
|
+
return o;
|
|
1529
|
+
}, In = function(s, o) {
|
|
1530
|
+
return o.length === 0 ? s : {
|
|
1531
|
+
type: "LogicalOrExpr",
|
|
1532
|
+
left: s,
|
|
1533
|
+
right: o.length === 1 ? o[0] : o.slice(1).reduce((u, p) => ({
|
|
1534
|
+
type: "LogicalOrExpr",
|
|
1535
|
+
left: u,
|
|
1536
|
+
right: p
|
|
1537
|
+
}), o[0])
|
|
1538
|
+
};
|
|
1539
|
+
}, it = function(s, o) {
|
|
1540
|
+
return o;
|
|
1541
|
+
}, Dn = function(s, o) {
|
|
1542
|
+
return [s, ...o];
|
|
1543
|
+
}, Nn = function(s) {
|
|
1544
|
+
return s.length === 1 ? s[0] : {
|
|
1545
|
+
type: "LogicalAndExpr",
|
|
1546
|
+
left: s[0],
|
|
1547
|
+
right: s.length === 2 ? s[1] : s.slice(2).reduce((o, u) => ({
|
|
1548
|
+
type: "LogicalOrExpr",
|
|
1549
|
+
left: o,
|
|
1550
|
+
right: u
|
|
1551
|
+
}), s[1])
|
|
1552
|
+
};
|
|
1553
|
+
}, Ln = function() {
|
|
1554
|
+
return String.fromCharCode(Number.parseInt(so(), 16));
|
|
1555
|
+
}, jn = function(s, o) {
|
|
1556
|
+
return String.fromCharCode(Number.parseInt(s, 16)) + String.fromCharCode(Number.parseInt(o, 16));
|
|
1557
|
+
}, Wn = function(s) {
|
|
1558
|
+
return s;
|
|
1559
|
+
}, qn = function(s, o) {
|
|
1560
|
+
return s !== null ? {
|
|
1561
|
+
type: "LogicalNotExpr",
|
|
1562
|
+
expression: o
|
|
1563
|
+
} : o;
|
|
1564
|
+
}, Un = function(s, o, u) {
|
|
1565
|
+
return {
|
|
1566
|
+
type: "ComparisonExpr",
|
|
1567
|
+
left: s,
|
|
1568
|
+
op: o,
|
|
1569
|
+
right: u
|
|
1570
|
+
};
|
|
1571
|
+
}, zn = function(s, o) {
|
|
1572
|
+
return s !== null ? {
|
|
1573
|
+
type: "LogicalNotExpr",
|
|
1574
|
+
expression: {
|
|
1575
|
+
type: "TestExpr",
|
|
1576
|
+
expression: o
|
|
1577
|
+
}
|
|
1578
|
+
} : {
|
|
1579
|
+
type: "TestExpr",
|
|
1580
|
+
expression: o
|
|
1581
|
+
};
|
|
1582
|
+
}, Bn = function(s) {
|
|
1583
|
+
return { type: "FilterQuery", value: s };
|
|
1584
|
+
}, at = function(s, o, u) {
|
|
1585
|
+
return u;
|
|
1586
|
+
}, xn = function(s, o, u) {
|
|
1587
|
+
return [o, ...u];
|
|
1588
|
+
}, Mn = function(s, o) {
|
|
1589
|
+
return {
|
|
1590
|
+
type: "FunctionExpr",
|
|
1591
|
+
name: s,
|
|
1592
|
+
arguments: o
|
|
1593
|
+
};
|
|
1594
|
+
}, Vn = function(s) {
|
|
1595
|
+
return { type: "Literal", value: s };
|
|
1596
|
+
}, Kn = function(s) {
|
|
1597
|
+
return { type: "RelQuery", segments: s };
|
|
1598
|
+
}, Hn = function(s) {
|
|
1599
|
+
return Number(s);
|
|
1600
|
+
}, Jn = function() {
|
|
1601
|
+
return !0;
|
|
1602
|
+
}, Xn = function() {
|
|
1603
|
+
return !1;
|
|
1604
|
+
}, Qn = function() {
|
|
1605
|
+
return null;
|
|
1606
|
+
}, Gn = function(s) {
|
|
1607
|
+
return { type: "RelSingularQuery", segments: s };
|
|
1608
|
+
}, Zn = function(s) {
|
|
1609
|
+
return { type: "AbsSingularQuery", segments: s };
|
|
1610
|
+
}, ct = function(s) {
|
|
1611
|
+
return {
|
|
1612
|
+
type: "SingularQuerySegment",
|
|
1613
|
+
node: s
|
|
1614
|
+
};
|
|
1615
|
+
}, Yn = function(s) {
|
|
1616
|
+
return s;
|
|
1617
|
+
}, eo = function(s) {
|
|
1618
|
+
return s;
|
|
1619
|
+
}, ro = function(s) {
|
|
1620
|
+
return s;
|
|
1621
|
+
}, to = function(s) {
|
|
1622
|
+
return { type: "IndexSelector", selector: s };
|
|
1623
|
+
}, i = t.peg$currPos | 0, E = i, Ae = [{ line: 1, column: 1 }], te = i, Qe = t.peg$maxFailExpected || [], v = t.peg$silentFails | 0, De;
|
|
1624
|
+
if (t.startRule) {
|
|
1625
|
+
if (!(t.startRule in a))
|
|
1626
|
+
throw new Error(`Can't start parsing from rule "` + t.startRule + '".');
|
|
1627
|
+
c = a[t.startRule];
|
|
1628
|
+
}
|
|
1629
|
+
function so() {
|
|
1630
|
+
return r.substring(E, i);
|
|
1631
|
+
}
|
|
1632
|
+
function F(s, o) {
|
|
1633
|
+
return { type: "literal", text: s, ignoreCase: o };
|
|
1634
|
+
}
|
|
1635
|
+
function M(s, o, u) {
|
|
1636
|
+
return { type: "class", parts: s, inverted: o, ignoreCase: u };
|
|
1637
|
+
}
|
|
1638
|
+
function no() {
|
|
1639
|
+
return { type: "end" };
|
|
1640
|
+
}
|
|
1641
|
+
function ft(s) {
|
|
1642
|
+
var o = Ae[s], u;
|
|
1643
|
+
if (o)
|
|
1644
|
+
return o;
|
|
1645
|
+
if (s >= Ae.length)
|
|
1646
|
+
u = Ae.length - 1;
|
|
1647
|
+
else
|
|
1648
|
+
for (u = s; !Ae[--u]; )
|
|
1649
|
+
;
|
|
1650
|
+
for (o = Ae[u], o = {
|
|
1651
|
+
line: o.line,
|
|
1652
|
+
column: o.column
|
|
1653
|
+
}; u < s; )
|
|
1654
|
+
r.charCodeAt(u) === 10 ? (o.line++, o.column = 1) : o.column++, u++;
|
|
1655
|
+
return Ae[s] = o, o;
|
|
1656
|
+
}
|
|
1657
|
+
function ut(s, o, u) {
|
|
1658
|
+
var p = ft(s), m = ft(o), $ = {
|
|
1659
|
+
source: n,
|
|
1660
|
+
start: {
|
|
1661
|
+
offset: s,
|
|
1662
|
+
line: p.line,
|
|
1663
|
+
column: p.column
|
|
1664
|
+
},
|
|
1665
|
+
end: {
|
|
1666
|
+
offset: o,
|
|
1667
|
+
line: m.line,
|
|
1668
|
+
column: m.column
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
return $;
|
|
1672
|
+
}
|
|
1673
|
+
function w(s) {
|
|
1674
|
+
i < te || (i > te && (te = i, Qe = []), Qe.push(s));
|
|
1675
|
+
}
|
|
1676
|
+
function oo(s, o, u) {
|
|
1677
|
+
return new Oe(Oe.buildMessage(s, o), s, o, u);
|
|
1678
|
+
}
|
|
1679
|
+
function Rr() {
|
|
1680
|
+
var s, o, u;
|
|
1681
|
+
return s = i, o = lt(), o !== e ? (u = pt(), E = s, s = pn(u)) : (i = s, s = e), s;
|
|
1682
|
+
}
|
|
1683
|
+
function lt() {
|
|
1684
|
+
var s;
|
|
1685
|
+
return r.charCodeAt(i) === 36 ? (s = f, i++) : (s = e, v === 0 && w(Sr)), s;
|
|
1686
|
+
}
|
|
1687
|
+
function pt() {
|
|
1688
|
+
var s, o, u;
|
|
1689
|
+
for (s = [], o = i, O(), u = dt(), u !== e ? (E = o, o = st(u)) : (i = o, o = e); o !== e; )
|
|
1690
|
+
s.push(o), o = i, O(), u = dt(), u !== e ? (E = o, o = st(u)) : (i = o, o = e);
|
|
1691
|
+
return s;
|
|
1692
|
+
}
|
|
1693
|
+
function O() {
|
|
1694
|
+
var s, o;
|
|
1695
|
+
for (s = [], o = ht(); o !== e; )
|
|
1696
|
+
s.push(o), o = ht();
|
|
1697
|
+
return s;
|
|
1698
|
+
}
|
|
1699
|
+
function dt() {
|
|
1700
|
+
var s;
|
|
1701
|
+
return s = io(), s === e && (s = ao()), s;
|
|
1702
|
+
}
|
|
1703
|
+
function ht() {
|
|
1704
|
+
var s;
|
|
1705
|
+
return s = r.charAt(i), Me.test(s) ? i++ : (s = e, v === 0 && w(Ie)), s;
|
|
1706
|
+
}
|
|
1707
|
+
function io() {
|
|
1708
|
+
var s, o, u, p;
|
|
1709
|
+
return s = i, o = gt(), o === e && (o = i, r.charCodeAt(i) === 46 ? (u = l, i++) : (u = e, v === 0 && w(be)), u !== e ? (p = Or(), p === e && (p = Tr()), p !== e ? (E = o, o = dn(p)) : (i = o, o = e)) : (i = o, o = e)), o !== e && (E = s, o = hn(o)), s = o, s;
|
|
1710
|
+
}
|
|
1711
|
+
function ao() {
|
|
1712
|
+
var s, o, u;
|
|
1713
|
+
return s = i, r.substr(i, 2) === h ? (o = h, i += 2) : (o = e, v === 0 && w(Ds)), o !== e ? (u = gt(), u === e && (u = Or(), u === e && (u = Tr())), u !== e ? (E = s, s = gn(u)) : (i = s, s = e)) : (i = s, s = e), s;
|
|
1714
|
+
}
|
|
1715
|
+
function gt() {
|
|
1716
|
+
var s, o, u, p, m, $, S, q;
|
|
1717
|
+
if (s = i, r.charCodeAt(i) === 91 ? (o = d, i++) : (o = e, v === 0 && w(Cr)), o !== e) {
|
|
1718
|
+
if (u = i, O(), p = Pr(), p !== e) {
|
|
1719
|
+
for (m = [], $ = i, O(), r.charCodeAt(i) === 44 ? (S = g, i++) : (S = e, v === 0 && w(He)), S !== e ? (O(), q = Pr(), q !== e ? (E = $, $ = nt(p, q)) : (i = $, $ = e)) : (i = $, $ = e); $ !== e; )
|
|
1720
|
+
m.push($), $ = i, O(), r.charCodeAt(i) === 44 ? (S = g, i++) : (S = e, v === 0 && w(He)), S !== e ? (O(), q = Pr(), q !== e ? (E = $, $ = nt(p, q)) : (i = $, $ = e)) : (i = $, $ = e);
|
|
1721
|
+
E = u, u = mn(p, m);
|
|
1722
|
+
} else
|
|
1723
|
+
i = u, u = e;
|
|
1724
|
+
u !== e ? (O(), r.charCodeAt(i) === 93 ? (p = k, i++) : (p = e, v === 0 && w(br)), p !== e ? (E = s, s = $n(u)) : (i = s, s = e)) : (i = s, s = e);
|
|
1725
|
+
} else
|
|
1726
|
+
i = s, s = e;
|
|
1727
|
+
return s;
|
|
1728
|
+
}
|
|
1729
|
+
function Or() {
|
|
1730
|
+
var s, o;
|
|
1731
|
+
return s = i, r.charCodeAt(i) === 42 ? (o = y, i++) : (o = e, v === 0 && w(Ns)), o !== e && (E = s, o = yn()), s = o, s;
|
|
1732
|
+
}
|
|
1733
|
+
function Tr() {
|
|
1734
|
+
var s, o, u, p, m, $;
|
|
1735
|
+
if (s = i, o = i, u = i, p = mt(), p !== e) {
|
|
1736
|
+
for (m = [], $ = $t(); $ !== e; )
|
|
1737
|
+
m.push($), $ = $t();
|
|
1738
|
+
p = [p, m], u = p;
|
|
1739
|
+
} else
|
|
1740
|
+
i = u, u = e;
|
|
1741
|
+
return u !== e ? o = r.substring(o, i) : o = u, o !== e && (E = s, o = wn(o)), s = o, s;
|
|
1742
|
+
}
|
|
1743
|
+
function Pr() {
|
|
1744
|
+
var s;
|
|
1745
|
+
return s = yt(), s === e && (s = Or(), s === e && (s = co(), s === e && (s = wt(), s === e && (s = fo())))), s;
|
|
1746
|
+
}
|
|
1747
|
+
function mt() {
|
|
1748
|
+
var s, o, u;
|
|
1749
|
+
return s = r.charAt(i), Ve.test(s) ? i++ : (s = e, v === 0 && w(Ls)), s === e && (s = i, o = r.charAt(i), Ke.test(o) ? i++ : (o = e, v === 0 && w(Jr)), o !== e ? (u = r.charAt(i), ie.test(u) ? i++ : (u = e, v === 0 && w(Xr)), u !== e ? (o = [o, u], s = o) : (i = s, s = e)) : (i = s, s = e)), s;
|
|
1750
|
+
}
|
|
1751
|
+
function $t() {
|
|
1752
|
+
var s;
|
|
1753
|
+
return s = mt(), s === e && (s = ae()), s;
|
|
1754
|
+
}
|
|
1755
|
+
function yt() {
|
|
1756
|
+
var s, o;
|
|
1757
|
+
return s = i, o = vt(), o !== e && (E = s, o = vn(o)), s = o, s;
|
|
1758
|
+
}
|
|
1759
|
+
function co() {
|
|
1760
|
+
var s, o, u, p, m, $, S, q, G;
|
|
1761
|
+
return s = i, o = i, u = i, p = i, m = Ne(), m !== e ? ($ = O(), m = [m, $], p = m) : (i = p, p = e), p === e && (p = null), u = r.substring(u, i), r.charCodeAt(i) === 58 ? (p = C, i++) : (p = e, v === 0 && w(Qr)), p !== e ? (m = O(), $ = i, S = i, q = Ne(), q !== e ? (G = O(), q = [q, G], S = q) : (i = S, S = e), S === e && (S = null), $ = r.substring($, i), S = i, r.charCodeAt(i) === 58 ? (q = C, i++) : (q = e, v === 0 && w(Qr)), q !== e ? (G = i, O(), Ne(), G = r.substring(G, i), E = S, S = kn(u, $, G)) : (i = S, S = e), S === e && (S = null), E = o, o = En(u, $, S)) : (i = o, o = e), o !== e && (E = s, o = Sn(o)), s = o, s;
|
|
1762
|
+
}
|
|
1763
|
+
function wt() {
|
|
1764
|
+
var s, o, u;
|
|
1765
|
+
return s = i, o = i, u = Ne(), u !== e ? o = r.substring(o, i) : o = u, o !== e && (E = s, o = Cn(o)), s = o, s;
|
|
1766
|
+
}
|
|
1767
|
+
function fo() {
|
|
1768
|
+
var s, o, u;
|
|
1769
|
+
return s = i, r.charCodeAt(i) === 63 ? (o = j, i++) : (o = e, v === 0 && w(js)), o !== e ? (O(), u = Fr(), u !== e ? (E = s, s = bn(u)) : (i = s, s = e)) : (i = s, s = e), s;
|
|
1770
|
+
}
|
|
1771
|
+
function ae() {
|
|
1772
|
+
var s;
|
|
1773
|
+
return s = r.charAt(i), Fe.test(s) ? i++ : (s = e, v === 0 && w(Ws)), s;
|
|
1774
|
+
}
|
|
1775
|
+
function vt() {
|
|
1776
|
+
var s, o, u, p, m;
|
|
1777
|
+
if (s = i, o = i, r.charCodeAt(i) === 34 ? (u = T, i++) : (u = e, v === 0 && w(Je)), u !== e) {
|
|
1778
|
+
for (p = [], m = kt(); m !== e; )
|
|
1779
|
+
p.push(m), m = kt();
|
|
1780
|
+
r.charCodeAt(i) === 34 ? (m = T, i++) : (m = e, v === 0 && w(Je)), m !== e ? (E = o, o = An(p)) : (i = o, o = e);
|
|
1781
|
+
} else
|
|
1782
|
+
i = o, o = e;
|
|
1783
|
+
if (o === e)
|
|
1784
|
+
if (o = i, r.charCodeAt(i) === 39 ? (u = N, i++) : (u = e, v === 0 && w(Xe)), u !== e) {
|
|
1785
|
+
for (p = [], m = Et(); m !== e; )
|
|
1786
|
+
p.push(m), m = Et();
|
|
1787
|
+
r.charCodeAt(i) === 39 ? (m = N, i++) : (m = e, v === 0 && w(Xe)), m !== e ? (E = o, o = Rn(p)) : (i = o, o = e);
|
|
1788
|
+
} else
|
|
1789
|
+
i = o, o = e;
|
|
1790
|
+
return o !== e && (E = s, o = On(o)), s = o, s;
|
|
1791
|
+
}
|
|
1792
|
+
function Ne() {
|
|
1793
|
+
var s, o, u, p, m;
|
|
1794
|
+
if (r.charCodeAt(i) === 48 ? (s = P, i++) : (s = e, v === 0 && w(qs)), s === e)
|
|
1795
|
+
if (s = i, r.charCodeAt(i) === 45 ? (o = L, i++) : (o = e, v === 0 && w(Us)), o === e && (o = null), u = uo(), u !== e) {
|
|
1796
|
+
for (p = [], m = ae(); m !== e; )
|
|
1797
|
+
p.push(m), m = ae();
|
|
1798
|
+
o = [o, u, p], s = o;
|
|
1799
|
+
} else
|
|
1800
|
+
i = s, s = e;
|
|
1801
|
+
return s;
|
|
1802
|
+
}
|
|
1803
|
+
function kt() {
|
|
1804
|
+
var s, o, u;
|
|
1805
|
+
return s = i, o = St(), o !== e ? s = r.substring(s, i) : s = o, s === e && (r.charCodeAt(i) === 39 ? (s = N, i++) : (s = e, v === 0 && w(Xe)), s === e && (s = i, o = Ge(), o !== e ? (r.charCodeAt(i) === 34 ? (u = T, i++) : (u = e, v === 0 && w(Je)), u !== e ? (E = s, s = Tn()) : (i = s, s = e)) : (i = s, s = e), s === e && (s = i, o = Ge(), o !== e ? (u = Ct(), u !== e ? (E = s, s = Pn(u)) : (i = s, s = e)) : (i = s, s = e)))), s;
|
|
1806
|
+
}
|
|
1807
|
+
function Et() {
|
|
1808
|
+
var s, o, u;
|
|
1809
|
+
return s = i, o = St(), o !== e ? s = r.substring(s, i) : s = o, s === e && (r.charCodeAt(i) === 34 ? (s = T, i++) : (s = e, v === 0 && w(Je)), s === e && (s = i, o = Ge(), o !== e ? (r.charCodeAt(i) === 39 ? (u = N, i++) : (u = e, v === 0 && w(Xe)), u !== e ? (E = s, s = Fn()) : (i = s, s = e)) : (i = s, s = e), s === e && (s = i, o = Ge(), o !== e ? (u = Ct(), u !== e ? (E = s, s = _n(u)) : (i = s, s = e)) : (i = s, s = e)))), s;
|
|
1810
|
+
}
|
|
1811
|
+
function uo() {
|
|
1812
|
+
var s;
|
|
1813
|
+
return s = r.charAt(i), R.test(s) ? i++ : (s = e, v === 0 && w(zs)), s;
|
|
1814
|
+
}
|
|
1815
|
+
function Fr() {
|
|
1816
|
+
var s, o, u, p, m, $;
|
|
1817
|
+
if (s = i, o = _r(), o !== e) {
|
|
1818
|
+
for (u = [], p = i, O(), r.substr(i, 2) === D ? (m = D, i += 2) : (m = e, v === 0 && w(Gr)), m !== e ? (O(), $ = _r(), $ !== e ? (E = p, p = ot(o, $)) : (i = p, p = e)) : (i = p, p = e); p !== e; )
|
|
1819
|
+
u.push(p), p = i, O(), r.substr(i, 2) === D ? (m = D, i += 2) : (m = e, v === 0 && w(Gr)), m !== e ? (O(), $ = _r(), $ !== e ? (E = p, p = ot(o, $)) : (i = p, p = e)) : (i = p, p = e);
|
|
1820
|
+
E = s, s = In(o, u);
|
|
1821
|
+
} else
|
|
1822
|
+
i = s, s = e;
|
|
1823
|
+
return s;
|
|
1824
|
+
}
|
|
1825
|
+
function St() {
|
|
1826
|
+
var s, o, u;
|
|
1827
|
+
return s = r.charAt(i), Z.test(s) ? i++ : (s = e, v === 0 && w(Bs)), s === e && (s = i, o = r.charAt(i), Ke.test(o) ? i++ : (o = e, v === 0 && w(Jr)), o !== e ? (u = r.charAt(i), ie.test(u) ? i++ : (u = e, v === 0 && w(Xr)), u !== e ? (o = [o, u], s = o) : (i = s, s = e)) : (i = s, s = e)), s;
|
|
1828
|
+
}
|
|
1829
|
+
function Ge() {
|
|
1830
|
+
var s;
|
|
1831
|
+
return r.charCodeAt(i) === 92 ? (s = b, i++) : (s = e, v === 0 && w(Zr)), s;
|
|
1832
|
+
}
|
|
1833
|
+
function Ct() {
|
|
1834
|
+
var s, o, u;
|
|
1835
|
+
return s = r.charAt(i), le.test(s) ? i++ : (s = e, v === 0 && w(xs)), s === e && (s = i, r.charCodeAt(i) === 117 ? (o = A, i++) : (o = e, v === 0 && w(Yr)), o !== e ? (u = lo(), u !== e ? (o = [o, u], s = o) : (i = s, s = e)) : (i = s, s = e)), s;
|
|
1836
|
+
}
|
|
1837
|
+
function _r() {
|
|
1838
|
+
var s, o, u, p, m, $, S;
|
|
1839
|
+
if (s = i, o = i, u = Ir(), u !== e) {
|
|
1840
|
+
for (p = [], m = i, O(), r.substr(i, 2) === K ? ($ = K, i += 2) : ($ = e, v === 0 && w(et)), $ !== e ? (O(), S = Ir(), S !== e ? (E = m, m = it(u, S)) : (i = m, m = e)) : (i = m, m = e); m !== e; )
|
|
1841
|
+
p.push(m), m = i, O(), r.substr(i, 2) === K ? ($ = K, i += 2) : ($ = e, v === 0 && w(et)), $ !== e ? (O(), S = Ir(), S !== e ? (E = m, m = it(u, S)) : (i = m, m = e)) : (i = m, m = e);
|
|
1842
|
+
E = o, o = Dn(u, p);
|
|
1843
|
+
} else
|
|
1844
|
+
i = o, o = e;
|
|
1845
|
+
return o !== e && (E = s, o = Nn(o)), s = o, s;
|
|
1846
|
+
}
|
|
1847
|
+
function lo() {
|
|
1848
|
+
var s, o, u, p, m, $, S;
|
|
1849
|
+
return s = i, o = i, u = po(), u !== e && (E = o, u = Ln()), o = u, o === e && (o = i, u = i, p = ho(), p !== e ? u = r.substring(u, i) : u = p, u !== e ? (r.charCodeAt(i) === 92 ? (p = b, i++) : (p = e, v === 0 && w(Zr)), p !== e ? (r.charCodeAt(i) === 117 ? (m = A, i++) : (m = e, v === 0 && w(Yr)), m !== e ? ($ = i, S = go(), S !== e ? $ = r.substring($, i) : $ = S, $ !== e ? (E = o, o = jn(u, $)) : (i = o, o = e)) : (i = o, o = e)) : (i = o, o = e)) : (i = o, o = e)), o !== e && (E = s, o = Wn(o)), s = o, s;
|
|
1850
|
+
}
|
|
1851
|
+
function Ir() {
|
|
1852
|
+
var s;
|
|
1853
|
+
return s = mo(), s === e && (s = $o(), s === e && (s = yo())), s;
|
|
1854
|
+
}
|
|
1855
|
+
function po() {
|
|
1856
|
+
var s, o, u, p, m, $;
|
|
1857
|
+
if (s = i, o = ae(), o === e && (o = r.charAt(i), _e.test(o) ? i++ : (o = e, v === 0 && w(Ms))), o !== e) {
|
|
1858
|
+
for (u = i, p = [], m = pe(); m !== e; )
|
|
1859
|
+
p.push(m), p.length >= 3 ? m = e : m = pe();
|
|
1860
|
+
p.length < 3 ? (i = u, u = e) : u = p, u !== e ? (o = [o, u], s = o) : (i = s, s = e);
|
|
1861
|
+
} else
|
|
1862
|
+
i = s, s = e;
|
|
1863
|
+
if (s === e)
|
|
1864
|
+
if (s = i, o = r.charAt(i), o.toLowerCase() === _ ? i++ : (o = e, v === 0 && w(Ar)), o !== e)
|
|
1865
|
+
if (u = r.charAt(i), hr.test(u) ? i++ : (u = e, v === 0 && w(Vs)), u !== e) {
|
|
1866
|
+
for (p = i, m = [], $ = pe(); $ !== e; )
|
|
1867
|
+
m.push($), m.length >= 2 ? $ = e : $ = pe();
|
|
1868
|
+
m.length < 2 ? (i = p, p = e) : p = m, p !== e ? (o = [o, u, p], s = o) : (i = s, s = e);
|
|
1869
|
+
} else
|
|
1870
|
+
i = s, s = e;
|
|
1871
|
+
else
|
|
1872
|
+
i = s, s = e;
|
|
1873
|
+
return s;
|
|
1874
|
+
}
|
|
1875
|
+
function ho() {
|
|
1876
|
+
var s, o, u, p, m, $;
|
|
1877
|
+
if (s = i, o = r.charAt(i), o.toLowerCase() === _ ? i++ : (o = e, v === 0 && w(Ar)), o !== e)
|
|
1878
|
+
if (u = r.charAt(i), gr.test(u) ? i++ : (u = e, v === 0 && w(Ks)), u === e && (u = r.charAt(i), mr.test(u) ? i++ : (u = e, v === 0 && w(Hs))), u !== e) {
|
|
1879
|
+
for (p = i, m = [], $ = pe(); $ !== e; )
|
|
1880
|
+
m.push($), m.length >= 2 ? $ = e : $ = pe();
|
|
1881
|
+
m.length < 2 ? (i = p, p = e) : p = m, p !== e ? (o = [o, u, p], s = o) : (i = s, s = e);
|
|
1882
|
+
} else
|
|
1883
|
+
i = s, s = e;
|
|
1884
|
+
else
|
|
1885
|
+
i = s, s = e;
|
|
1886
|
+
return s;
|
|
1887
|
+
}
|
|
1888
|
+
function go() {
|
|
1889
|
+
var s, o, u, p, m, $;
|
|
1890
|
+
if (s = i, o = r.charAt(i), o.toLowerCase() === _ ? i++ : (o = e, v === 0 && w(Ar)), o !== e)
|
|
1891
|
+
if (u = r.charAt(i), $r.test(u) ? i++ : (u = e, v === 0 && w(Js)), u !== e) {
|
|
1892
|
+
for (p = i, m = [], $ = pe(); $ !== e; )
|
|
1893
|
+
m.push($), m.length >= 2 ? $ = e : $ = pe();
|
|
1894
|
+
m.length < 2 ? (i = p, p = e) : p = m, p !== e ? (o = [o, u, p], s = o) : (i = s, s = e);
|
|
1895
|
+
} else
|
|
1896
|
+
i = s, s = e;
|
|
1897
|
+
else
|
|
1898
|
+
i = s, s = e;
|
|
1899
|
+
return s;
|
|
1900
|
+
}
|
|
1901
|
+
function mo() {
|
|
1902
|
+
var s, o, u, p, m, $;
|
|
1903
|
+
return s = i, o = i, u = bt(), u !== e ? (p = O(), u = [u, p], o = u) : (i = o, o = e), o === e && (o = null), r.charCodeAt(i) === 40 ? (u = W, i++) : (u = e, v === 0 && w(rt)), u !== e ? (p = O(), m = Fr(), m !== e ? (O(), r.charCodeAt(i) === 41 ? ($ = z, i++) : ($ = e, v === 0 && w(tt)), $ !== e ? (E = s, s = qn(o, m)) : (i = s, s = e)) : (i = s, s = e)) : (i = s, s = e), s;
|
|
1904
|
+
}
|
|
1905
|
+
function $o() {
|
|
1906
|
+
var s, o, u, p;
|
|
1907
|
+
return s = i, o = At(), o !== e ? (O(), u = wo(), u !== e ? (O(), p = At(), p !== e ? (E = s, s = Un(o, u, p)) : (i = s, s = e)) : (i = s, s = e)) : (i = s, s = e), s;
|
|
1908
|
+
}
|
|
1909
|
+
function yo() {
|
|
1910
|
+
var s, o, u, p;
|
|
1911
|
+
return s = i, o = i, u = bt(), u !== e ? (p = O(), u = [u, p], o = u) : (i = o, o = e), o === e && (o = null), u = Rt(), u === e && (u = Dr()), u !== e ? (E = s, s = zn(o, u)) : (i = s, s = e), s;
|
|
1912
|
+
}
|
|
1913
|
+
function pe() {
|
|
1914
|
+
var s;
|
|
1915
|
+
return s = ae(), s === e && (s = r.charAt(i), yr.test(s) ? i++ : (s = e, v === 0 && w(Xs))), s;
|
|
1916
|
+
}
|
|
1917
|
+
function bt() {
|
|
1918
|
+
var s;
|
|
1919
|
+
return r.charCodeAt(i) === 33 ? (s = x, i++) : (s = e, v === 0 && w(Qs)), s;
|
|
1920
|
+
}
|
|
1921
|
+
function At() {
|
|
1922
|
+
var s;
|
|
1923
|
+
return s = Ot(), s === e && (s = vo(), s === e && (s = Dr())), s;
|
|
1924
|
+
}
|
|
1925
|
+
function wo() {
|
|
1926
|
+
var s;
|
|
1927
|
+
return r.substr(i, 2) === I ? (s = I, i += 2) : (s = e, v === 0 && w(Gs)), s === e && (r.substr(i, 2) === B ? (s = B, i += 2) : (s = e, v === 0 && w(Zs)), s === e && (r.substr(i, 2) === H ? (s = H, i += 2) : (s = e, v === 0 && w(Ys)), s === e && (r.substr(i, 2) === ee ? (s = ee, i += 2) : (s = e, v === 0 && w(en)), s === e && (s = r.charAt(i), wr.test(s) ? i++ : (s = e, v === 0 && w(rn)))))), s;
|
|
1928
|
+
}
|
|
1929
|
+
function Rt() {
|
|
1930
|
+
var s, o;
|
|
1931
|
+
return s = i, o = ko(), o === e && (o = Rr()), o !== e && (E = s, o = Bn(o)), s = o, s;
|
|
1932
|
+
}
|
|
1933
|
+
function Dr() {
|
|
1934
|
+
var s, o, u, p, m, $, S, q, G;
|
|
1935
|
+
if (s = i, o = Eo(), o !== e)
|
|
1936
|
+
if (r.charCodeAt(i) === 40 ? (u = W, i++) : (u = e, v === 0 && w(rt)), u !== e) {
|
|
1937
|
+
if (O(), p = i, m = Nr(), m !== e) {
|
|
1938
|
+
for ($ = [], S = i, O(), r.charCodeAt(i) === 44 ? (q = g, i++) : (q = e, v === 0 && w(He)), q !== e ? (O(), G = Nr(), G !== e ? (E = S, S = at(o, m, G)) : (i = S, S = e)) : (i = S, S = e); S !== e; )
|
|
1939
|
+
$.push(S), S = i, O(), r.charCodeAt(i) === 44 ? (q = g, i++) : (q = e, v === 0 && w(He)), q !== e ? (O(), G = Nr(), G !== e ? (E = S, S = at(o, m, G)) : (i = S, S = e)) : (i = S, S = e);
|
|
1940
|
+
E = p, p = xn(o, m, $);
|
|
1941
|
+
} else
|
|
1942
|
+
i = p, p = e;
|
|
1943
|
+
p === e && (p = null), m = O(), r.charCodeAt(i) === 41 ? ($ = z, i++) : ($ = e, v === 0 && w(tt)), $ !== e ? (E = s, s = Mn(o, p)) : (i = s, s = e);
|
|
1944
|
+
} else
|
|
1945
|
+
i = s, s = e;
|
|
1946
|
+
else
|
|
1947
|
+
i = s, s = e;
|
|
1948
|
+
return s;
|
|
1949
|
+
}
|
|
1950
|
+
function Ot() {
|
|
1951
|
+
var s, o;
|
|
1952
|
+
return s = i, o = So(), o === e && (o = vt(), o === e && (o = Co(), o === e && (o = bo(), o === e && (o = Ao())))), o !== e && (E = s, o = Vn(o)), s = o, s;
|
|
1953
|
+
}
|
|
1954
|
+
function vo() {
|
|
1955
|
+
var s;
|
|
1956
|
+
return s = Ro(), s === e && (s = Oo()), s;
|
|
1957
|
+
}
|
|
1958
|
+
function ko() {
|
|
1959
|
+
var s, o, u;
|
|
1960
|
+
return s = i, o = Tt(), o !== e ? (u = pt(), u !== e ? (E = s, s = Kn(u)) : (i = s, s = e)) : (i = s, s = e), s;
|
|
1961
|
+
}
|
|
1962
|
+
function Eo() {
|
|
1963
|
+
var s, o, u, p, m;
|
|
1964
|
+
if (s = i, o = i, u = Fo(), u !== e) {
|
|
1965
|
+
for (p = [], m = Pt(); m !== e; )
|
|
1966
|
+
p.push(m), m = Pt();
|
|
1967
|
+
u = [u, p], o = u;
|
|
1968
|
+
} else
|
|
1969
|
+
i = o, o = e;
|
|
1970
|
+
return o !== e ? s = r.substring(s, i) : s = o, s;
|
|
1971
|
+
}
|
|
1972
|
+
function Nr() {
|
|
1973
|
+
var s;
|
|
1974
|
+
return s = Ot(), s === e && (s = Rt(), s === e && (s = Dr(), s === e && (s = Fr()))), s;
|
|
1975
|
+
}
|
|
1976
|
+
function So() {
|
|
1977
|
+
var s, o, u, p, m, $;
|
|
1978
|
+
return s = i, o = i, u = i, p = Ne(), p === e && (r.substr(i, 2) === he ? (p = he, i += 2) : (p = e, v === 0 && w(tn))), p !== e ? (m = To(), m === e && (m = null), $ = Po(), $ === e && ($ = null), p = [p, m, $], u = p) : (i = u, u = e), u !== e ? o = r.substring(o, i) : o = u, o !== e && (E = s, o = Hn(o)), s = o, s;
|
|
1979
|
+
}
|
|
1980
|
+
function Co() {
|
|
1981
|
+
var s, o;
|
|
1982
|
+
return s = i, r.substr(i, 4) === ne ? (o = ne, i += 4) : (o = e, v === 0 && w(sn)), o !== e && (E = s, o = Jn()), s = o, s;
|
|
1983
|
+
}
|
|
1984
|
+
function bo() {
|
|
1985
|
+
var s, o;
|
|
1986
|
+
return s = i, r.substr(i, 5) === re ? (o = re, i += 5) : (o = e, v === 0 && w(nn)), o !== e && (E = s, o = Xn()), s = o, s;
|
|
1987
|
+
}
|
|
1988
|
+
function Ao() {
|
|
1989
|
+
var s, o;
|
|
1990
|
+
return s = i, r.substr(i, 4) === ue ? (o = ue, i += 4) : (o = e, v === 0 && w(on)), o !== e && (E = s, o = Qn()), s = o, s;
|
|
1991
|
+
}
|
|
1992
|
+
function Ro() {
|
|
1993
|
+
var s, o, u;
|
|
1994
|
+
return s = i, o = Tt(), o !== e ? (u = Ft(), E = s, s = Gn(u)) : (i = s, s = e), s;
|
|
1995
|
+
}
|
|
1996
|
+
function Oo() {
|
|
1997
|
+
var s, o, u;
|
|
1998
|
+
return s = i, o = lt(), o !== e ? (u = Ft(), E = s, s = Zn(u)) : (i = s, s = e), s;
|
|
1999
|
+
}
|
|
2000
|
+
function Tt() {
|
|
2001
|
+
var s;
|
|
2002
|
+
return r.charCodeAt(i) === 64 ? (s = pr, i++) : (s = e, v === 0 && w(an)), s;
|
|
2003
|
+
}
|
|
2004
|
+
function Pt() {
|
|
2005
|
+
var s;
|
|
2006
|
+
return s = r.charAt(i), vr.test(s) ? i++ : (s = e, v === 0 && w(cn)), s;
|
|
2007
|
+
}
|
|
2008
|
+
function To() {
|
|
2009
|
+
var s, o, u, p;
|
|
2010
|
+
if (s = i, r.charCodeAt(i) === 46 ? (o = l, i++) : (o = e, v === 0 && w(be)), o !== e) {
|
|
2011
|
+
if (u = [], p = ae(), p !== e)
|
|
2012
|
+
for (; p !== e; )
|
|
2013
|
+
u.push(p), p = ae();
|
|
2014
|
+
else
|
|
2015
|
+
u = e;
|
|
2016
|
+
u !== e ? (o = [o, u], s = o) : (i = s, s = e);
|
|
2017
|
+
} else
|
|
2018
|
+
i = s, s = e;
|
|
2019
|
+
return s;
|
|
2020
|
+
}
|
|
2021
|
+
function Po() {
|
|
2022
|
+
var s, o, u, p, m;
|
|
2023
|
+
if (s = i, o = r.charAt(i), o.toLowerCase() === dr ? i++ : (o = e, v === 0 && w(fn)), o !== e) {
|
|
2024
|
+
if (u = r.charAt(i), kr.test(u) ? i++ : (u = e, v === 0 && w(un)), u === e && (u = null), p = [], m = ae(), m !== e)
|
|
2025
|
+
for (; m !== e; )
|
|
2026
|
+
p.push(m), m = ae();
|
|
2027
|
+
else
|
|
2028
|
+
p = e;
|
|
2029
|
+
p !== e ? (o = [o, u, p], s = o) : (i = s, s = e);
|
|
2030
|
+
} else
|
|
2031
|
+
i = s, s = e;
|
|
2032
|
+
return s;
|
|
2033
|
+
}
|
|
2034
|
+
function Ft() {
|
|
2035
|
+
var s, o, u, p;
|
|
2036
|
+
for (s = i, o = [], u = i, O(), p = _t(), p === e && (p = It()), p !== e ? (E = u, u = ct(p)) : (i = u, u = e); u !== e; )
|
|
2037
|
+
o.push(u), u = i, O(), p = _t(), p === e && (p = It()), p !== e ? (E = u, u = ct(p)) : (i = u, u = e);
|
|
2038
|
+
return E = s, o = Yn(o), s = o, s;
|
|
2039
|
+
}
|
|
2040
|
+
function Fo() {
|
|
2041
|
+
var s;
|
|
2042
|
+
return s = r.charAt(i), Er.test(s) ? i++ : (s = e, v === 0 && w(ln)), s;
|
|
2043
|
+
}
|
|
2044
|
+
function _t() {
|
|
2045
|
+
var s, o, u, p;
|
|
2046
|
+
return s = i, r.charCodeAt(i) === 91 ? (o = d, i++) : (o = e, v === 0 && w(Cr)), o !== e ? (u = yt(), u !== e ? (r.charCodeAt(i) === 93 ? (p = k, i++) : (p = e, v === 0 && w(br)), p !== e ? (E = s, s = eo(u)) : (i = s, s = e)) : (i = s, s = e)) : (i = s, s = e), s === e && (s = i, r.charCodeAt(i) === 46 ? (o = l, i++) : (o = e, v === 0 && w(be)), o !== e ? (u = Tr(), u !== e ? (E = s, s = ro(u)) : (i = s, s = e)) : (i = s, s = e)), s;
|
|
2047
|
+
}
|
|
2048
|
+
function It() {
|
|
2049
|
+
var s, o, u, p;
|
|
2050
|
+
return s = i, r.charCodeAt(i) === 91 ? (o = d, i++) : (o = e, v === 0 && w(Cr)), o !== e ? (u = wt(), u !== e ? (r.charCodeAt(i) === 93 ? (p = k, i++) : (p = e, v === 0 && w(br)), p !== e ? (E = s, s = to(u)) : (i = s, s = e)) : (i = s, s = e)) : (i = s, s = e), s;
|
|
2051
|
+
}
|
|
2052
|
+
if (De = c(), t.peg$library)
|
|
2053
|
+
return (
|
|
2054
|
+
/** @type {any} */
|
|
2055
|
+
{
|
|
2056
|
+
peg$result: De,
|
|
2057
|
+
peg$currPos: i,
|
|
2058
|
+
peg$FAILED: e,
|
|
2059
|
+
peg$maxFailExpected: Qe,
|
|
2060
|
+
peg$maxFailPos: te
|
|
2061
|
+
}
|
|
2062
|
+
);
|
|
2063
|
+
if (De !== e && i === r.length)
|
|
2064
|
+
return De;
|
|
2065
|
+
throw De !== e && i < r.length && w(no()), oo(Qe, te < r.length ? r.charAt(te) : null, te < r.length ? ut(te, te + 1) : ut(te, te));
|
|
2066
|
+
}
|
|
2067
|
+
function ca(r) {
|
|
2068
|
+
return aa(r);
|
|
2069
|
+
}
|
|
2070
|
+
class fa {
|
|
2071
|
+
head = null;
|
|
2072
|
+
tail = null;
|
|
2073
|
+
size = 0;
|
|
2074
|
+
push(t) {
|
|
2075
|
+
const e = { value: t, next: null };
|
|
2076
|
+
this.tail !== null && (this.tail.next = e), this.tail = e, this.head === null && (this.head = e), this.size++;
|
|
2077
|
+
}
|
|
2078
|
+
pop() {
|
|
2079
|
+
if (this.head === null)
|
|
2080
|
+
return;
|
|
2081
|
+
const t = this.head.value;
|
|
2082
|
+
return this.head = this.head.next, this.head === null && (this.tail = null), this.size--, t;
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
function xe(r) {
|
|
2086
|
+
if (typeof r != "object" || r === null)
|
|
2087
|
+
return !1;
|
|
2088
|
+
const t = Object.getPrototypeOf(r);
|
|
2089
|
+
return t === null || t === Object.prototype;
|
|
2090
|
+
}
|
|
2091
|
+
const tr = (r) => Array.isArray(r.value), nr = (r) => xe(r.value), $s = /* @__PURE__ */ new WeakSet(), Q = (r) => typeof r == "object" && r !== null && $s.has(r), ua = (r) => {
|
|
2092
|
+
switch (typeof r) {
|
|
2093
|
+
case "string":
|
|
2094
|
+
case "number":
|
|
2095
|
+
case "boolean":
|
|
2096
|
+
return !0;
|
|
2097
|
+
case "object":
|
|
2098
|
+
return r === null || xe(r) || ys(r);
|
|
2099
|
+
default:
|
|
2100
|
+
return !1;
|
|
2101
|
+
}
|
|
2102
|
+
}, ys = (r) => Array.isArray(r) && !Q(r), ws = () => {
|
|
2103
|
+
const r = [];
|
|
2104
|
+
return $s.add(r), r;
|
|
2105
|
+
}, Pe = Symbol("Nothing"), la = {
|
|
2106
|
+
declaration: function(t, e) {
|
|
2107
|
+
return Q(e) ? e.length : 0;
|
|
2108
|
+
},
|
|
2109
|
+
definition: {
|
|
2110
|
+
parameters: ["NodesType"],
|
|
2111
|
+
returnType: "ValueType"
|
|
2112
|
+
}
|
|
2113
|
+
};
|
|
2114
|
+
function pa(r) {
|
|
2115
|
+
let t = 0;
|
|
2116
|
+
for (let e = 0; e < r.length; e++) {
|
|
2117
|
+
const n = r.charCodeAt(e);
|
|
2118
|
+
(n >= 0 && n <= 55295 || n >= 57344 && n <= 1114111) && t++;
|
|
2119
|
+
}
|
|
2120
|
+
return t;
|
|
2121
|
+
}
|
|
2122
|
+
const da = {
|
|
2123
|
+
declaration: function(t, e) {
|
|
2124
|
+
return typeof e == "string" ? pa(e) : Array.isArray(e) ? e.length : xe(e) ? Object.keys(e).length : Pe;
|
|
2125
|
+
},
|
|
2126
|
+
definition: {
|
|
2127
|
+
parameters: ["ValueType"],
|
|
2128
|
+
returnType: "ValueType"
|
|
2129
|
+
}
|
|
2130
|
+
};
|
|
2131
|
+
function vs(r) {
|
|
2132
|
+
return r === 92;
|
|
2133
|
+
}
|
|
2134
|
+
function ha(r, t) {
|
|
2135
|
+
let e = !1, n = t;
|
|
2136
|
+
for (; n < r.length; ) {
|
|
2137
|
+
const a = r.charCodeAt(n);
|
|
2138
|
+
if (n++, vs(a)) {
|
|
2139
|
+
e = !0;
|
|
2140
|
+
continue;
|
|
2141
|
+
}
|
|
2142
|
+
if (a === 93) {
|
|
2143
|
+
if (!e)
|
|
2144
|
+
break;
|
|
2145
|
+
e = !1;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
return n;
|
|
2149
|
+
}
|
|
2150
|
+
function ga(r) {
|
|
2151
|
+
let t = r;
|
|
2152
|
+
for (let e = 0; e < r.length; e++) {
|
|
2153
|
+
const n = r.charCodeAt(e);
|
|
2154
|
+
vs(n) ? e++ : n === 91 ? e = ha(r, e) : n === 46 && (t = `${r.slice(0, e)}[^
|
|
2155
|
+
\r]${r.slice(e + 1)}`);
|
|
2156
|
+
}
|
|
2157
|
+
return t;
|
|
2158
|
+
}
|
|
2159
|
+
function ks({ cache: r }, t) {
|
|
2160
|
+
const e = r.get("regexps") ?? {};
|
|
2161
|
+
if (r.has("regexps") || r.set("regexps", e), Object.hasOwn(e, t))
|
|
2162
|
+
return e[t];
|
|
2163
|
+
try {
|
|
2164
|
+
const n = RegExp(ga(t), "u");
|
|
2165
|
+
return e[t] = n, n;
|
|
2166
|
+
} catch {
|
|
2167
|
+
return e[t] = null, null;
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
const ma = {
|
|
2171
|
+
declaration: function(t, e, n) {
|
|
2172
|
+
return typeof e != "string" || typeof n != "string" ? !1 : ks(t, `^${n}$`)?.test(e) === !0;
|
|
2173
|
+
},
|
|
2174
|
+
definition: {
|
|
2175
|
+
parameters: ["ValueType", "ValueType"],
|
|
2176
|
+
returnType: "LogicalType"
|
|
2177
|
+
}
|
|
2178
|
+
}, $a = {
|
|
2179
|
+
declaration: function(t, e, n) {
|
|
2180
|
+
return typeof e != "string" || typeof n != "string" ? !1 : ks(t, n)?.test(e) === !0;
|
|
2181
|
+
},
|
|
2182
|
+
definition: {
|
|
2183
|
+
parameters: ["ValueType", "ValueType"],
|
|
2184
|
+
returnType: "LogicalType"
|
|
2185
|
+
}
|
|
2186
|
+
}, ya = {
|
|
2187
|
+
declaration: function(t, e) {
|
|
2188
|
+
return e.length === 1 ? e[0] : Pe;
|
|
2189
|
+
},
|
|
2190
|
+
definition: {
|
|
2191
|
+
parameters: ["NodesType"],
|
|
2192
|
+
returnType: "ValueType"
|
|
2193
|
+
}
|
|
2194
|
+
}, qr = [];
|
|
2195
|
+
function se(r, t) {
|
|
2196
|
+
return r === qr ? qr : typeof t == "number" ? [...r, t] : [...r, Ea(t)];
|
|
2197
|
+
}
|
|
2198
|
+
function wa(r) {
|
|
2199
|
+
return r ? [] : qr;
|
|
2200
|
+
}
|
|
2201
|
+
const va = (
|
|
2202
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: we need control characters to escape Unicode characters
|
|
2203
|
+
/[\u0000-\u001f'\\]/g
|
|
2204
|
+
);
|
|
2205
|
+
function ka(r) {
|
|
2206
|
+
const t = r.charCodeAt(0);
|
|
2207
|
+
switch (t) {
|
|
2208
|
+
case 8:
|
|
2209
|
+
return "\\b";
|
|
2210
|
+
case 12:
|
|
2211
|
+
return "\\f";
|
|
2212
|
+
case 10:
|
|
2213
|
+
return "\\n";
|
|
2214
|
+
case 13:
|
|
2215
|
+
return "\\r";
|
|
2216
|
+
case 9:
|
|
2217
|
+
return "\\t";
|
|
2218
|
+
case 39:
|
|
2219
|
+
return "\\'";
|
|
2220
|
+
case 92:
|
|
2221
|
+
return "\\\\";
|
|
2222
|
+
default:
|
|
2223
|
+
return `\\u${t.toString(16).padStart(4, "0")}`;
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
function Ea(r) {
|
|
2227
|
+
return r.replace(va, ka);
|
|
2228
|
+
}
|
|
2229
|
+
function Ce(r) {
|
|
2230
|
+
throw new TypeError(
|
|
2231
|
+
// biome-ignore lint/complexity/useLiteralKeys: type exhaustiveness
|
|
2232
|
+
`Unexpected node type: ${r.type}`
|
|
2233
|
+
);
|
|
2234
|
+
}
|
|
2235
|
+
function de(r) {
|
|
2236
|
+
throw new TypeError(`Unexpected comparison operator: ${r}`);
|
|
2237
|
+
}
|
|
2238
|
+
function Es(r, t) {
|
|
2239
|
+
throw new Error(t);
|
|
2240
|
+
}
|
|
2241
|
+
function sr(r) {
|
|
2242
|
+
switch (typeof r) {
|
|
2243
|
+
case "object":
|
|
2244
|
+
if (r === null)
|
|
2245
|
+
return "null";
|
|
2246
|
+
if (Q(r))
|
|
2247
|
+
return "NodeList";
|
|
2248
|
+
if (ys(r))
|
|
2249
|
+
return "array";
|
|
2250
|
+
if (xe(r))
|
|
2251
|
+
return "object";
|
|
2252
|
+
throw new TypeError(`Unknown type: ${r}`);
|
|
2253
|
+
case "string":
|
|
2254
|
+
return "string";
|
|
2255
|
+
case "number":
|
|
2256
|
+
return "number";
|
|
2257
|
+
case "boolean":
|
|
2258
|
+
return "boolean";
|
|
2259
|
+
default:
|
|
2260
|
+
if (r === Pe)
|
|
2261
|
+
return "Nothing";
|
|
2262
|
+
throw new TypeError(`Unknown type: ${r}`);
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
function Sa(r, t) {
|
|
2266
|
+
if (r.length !== t.length)
|
|
2267
|
+
return !1;
|
|
2268
|
+
for (let e = 0; e < r.length; e++)
|
|
2269
|
+
if (!Te(r[e], t[e]))
|
|
2270
|
+
return !1;
|
|
2271
|
+
return !0;
|
|
2272
|
+
}
|
|
2273
|
+
function Ca(r, t) {
|
|
2274
|
+
const e = Object.keys(r), n = Object.keys(t);
|
|
2275
|
+
if (e.length !== n.length)
|
|
2276
|
+
return !1;
|
|
2277
|
+
for (const a of e)
|
|
2278
|
+
if (!Object.hasOwn(t, a) || !Te(r[a], t[a]))
|
|
2279
|
+
return !1;
|
|
2280
|
+
return !0;
|
|
2281
|
+
}
|
|
2282
|
+
function Te(r, t) {
|
|
2283
|
+
if (sr(r) !== sr(t))
|
|
2284
|
+
return !1;
|
|
2285
|
+
switch (sr(r)) {
|
|
2286
|
+
case "string":
|
|
2287
|
+
case "number":
|
|
2288
|
+
case "boolean":
|
|
2289
|
+
case "null":
|
|
2290
|
+
return r === t;
|
|
2291
|
+
case "object":
|
|
2292
|
+
return Ca(r, t);
|
|
2293
|
+
case "array":
|
|
2294
|
+
case "NodeList":
|
|
2295
|
+
return Sa(r, t);
|
|
2296
|
+
default:
|
|
2297
|
+
return !1;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
function Ss(r, t, e) {
|
|
2301
|
+
switch (e) {
|
|
2302
|
+
case "==":
|
|
2303
|
+
case ">=":
|
|
2304
|
+
// does not offer < comparison
|
|
2305
|
+
case "<=":
|
|
2306
|
+
return !Q(r) && !Q(t) && Te(r, t);
|
|
2307
|
+
case "<":
|
|
2308
|
+
// does not offer < comparison
|
|
2309
|
+
case ">":
|
|
2310
|
+
return !1;
|
|
2311
|
+
case "!=":
|
|
2312
|
+
return !Ss(r, t, "==");
|
|
2313
|
+
default:
|
|
2314
|
+
de(e);
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
function Cs(r, t, e) {
|
|
2318
|
+
switch (e) {
|
|
2319
|
+
case "==":
|
|
2320
|
+
case "<=":
|
|
2321
|
+
// does not offer < comparison
|
|
2322
|
+
case ">=":
|
|
2323
|
+
return Q(r) && (Q(t) && Te(r, t) || t === Pe);
|
|
2324
|
+
case "<":
|
|
2325
|
+
// does not offer < comparison
|
|
2326
|
+
case ">":
|
|
2327
|
+
return !1;
|
|
2328
|
+
case "!=":
|
|
2329
|
+
return !Cs(r, t, "==");
|
|
2330
|
+
default:
|
|
2331
|
+
de(e);
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
function bs(r, t, e) {
|
|
2335
|
+
switch (e) {
|
|
2336
|
+
case "==":
|
|
2337
|
+
case "<=":
|
|
2338
|
+
// does not offer < comparison
|
|
2339
|
+
case ">=":
|
|
2340
|
+
return t === Pe || Q(t) && t.length === 0;
|
|
2341
|
+
case "<":
|
|
2342
|
+
// does not offer < comparison
|
|
2343
|
+
case ">":
|
|
2344
|
+
return !1;
|
|
2345
|
+
case "!=":
|
|
2346
|
+
return !bs(r, t, "==");
|
|
2347
|
+
default:
|
|
2348
|
+
de(e);
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
function ve(r, t, e) {
|
|
2352
|
+
switch (e) {
|
|
2353
|
+
case "==":
|
|
2354
|
+
return r === t;
|
|
2355
|
+
case "<":
|
|
2356
|
+
return typeof t == "number" && r < t;
|
|
2357
|
+
case "!=":
|
|
2358
|
+
return !ve(r, t, "==");
|
|
2359
|
+
case "<=":
|
|
2360
|
+
return ve(r, t, "<") || ve(r, t, "==");
|
|
2361
|
+
case ">":
|
|
2362
|
+
return typeof t == "number" && ve(t, r, "<");
|
|
2363
|
+
case ">=":
|
|
2364
|
+
return typeof t == "number" && ve(t, r, "<") || ve(r, t, "==");
|
|
2365
|
+
default:
|
|
2366
|
+
de(e);
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
function ba(r, t, e) {
|
|
2370
|
+
switch (e) {
|
|
2371
|
+
case "==":
|
|
2372
|
+
case "<=":
|
|
2373
|
+
// does not offer < comparison
|
|
2374
|
+
case ">=":
|
|
2375
|
+
return Te(r, t);
|
|
2376
|
+
case "<":
|
|
2377
|
+
// does not offer < comparison
|
|
2378
|
+
case ">":
|
|
2379
|
+
return !1;
|
|
2380
|
+
case "!=":
|
|
2381
|
+
return !Te(r, t);
|
|
2382
|
+
default:
|
|
2383
|
+
de(e);
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
function As(r, t, e) {
|
|
2387
|
+
switch (e) {
|
|
2388
|
+
case "==":
|
|
2389
|
+
case "<=":
|
|
2390
|
+
// do not offer < comparison
|
|
2391
|
+
case ">=":
|
|
2392
|
+
return r === t;
|
|
2393
|
+
case "<":
|
|
2394
|
+
case ">":
|
|
2395
|
+
return !1;
|
|
2396
|
+
case "!=":
|
|
2397
|
+
return !As(r, t, "==");
|
|
2398
|
+
default:
|
|
2399
|
+
de(e);
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
function $e(r, t, e) {
|
|
2403
|
+
if (typeof r != "string" || typeof t != "string")
|
|
2404
|
+
return !1;
|
|
2405
|
+
switch (e) {
|
|
2406
|
+
case "==":
|
|
2407
|
+
return r === t;
|
|
2408
|
+
case "<": {
|
|
2409
|
+
let n = 0;
|
|
2410
|
+
for (; r.length > n && t.length > n; ) {
|
|
2411
|
+
const a = r.charCodeAt(n), c = t.charCodeAt(n);
|
|
2412
|
+
if (a === c) {
|
|
2413
|
+
n++;
|
|
2414
|
+
continue;
|
|
2415
|
+
}
|
|
2416
|
+
return r.charCodeAt(n) < t.charCodeAt(n);
|
|
2417
|
+
}
|
|
2418
|
+
return r.length < t.length;
|
|
2419
|
+
}
|
|
2420
|
+
default:
|
|
2421
|
+
de(e);
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
function Aa(r, t, e) {
|
|
2425
|
+
switch (e) {
|
|
2426
|
+
case "==":
|
|
2427
|
+
case "<":
|
|
2428
|
+
return $e(r, t, e);
|
|
2429
|
+
case "!=":
|
|
2430
|
+
return !$e(r, t, "==");
|
|
2431
|
+
case "<=":
|
|
2432
|
+
return $e(r, t, "<") || $e(r, t, "==");
|
|
2433
|
+
case ">":
|
|
2434
|
+
return $e(t, r, "<");
|
|
2435
|
+
case ">=":
|
|
2436
|
+
return $e(t, r, "<") || $e(r, t, "==");
|
|
2437
|
+
default:
|
|
2438
|
+
de(e);
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
function Ra(r, t, e) {
|
|
2442
|
+
const n = Q(r) && r.length === 1 ? r[0] : r, a = sr(n), c = Q(t) && t.length === 1 ? t[0] : t;
|
|
2443
|
+
switch (a) {
|
|
2444
|
+
case "string":
|
|
2445
|
+
return Aa(n, c, e);
|
|
2446
|
+
case "number":
|
|
2447
|
+
return ve(n, c, e);
|
|
2448
|
+
case "boolean":
|
|
2449
|
+
case "null":
|
|
2450
|
+
return As(n, c, e);
|
|
2451
|
+
case "object":
|
|
2452
|
+
return ba(n, c, e);
|
|
2453
|
+
case "array":
|
|
2454
|
+
return Ss(n, c, e);
|
|
2455
|
+
case "Nothing":
|
|
2456
|
+
return bs(n, c, e);
|
|
2457
|
+
case "NodeList":
|
|
2458
|
+
return Cs(n, c, e);
|
|
2459
|
+
default:
|
|
2460
|
+
Es(a, "Unknown type");
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
function Rs(r, t, e) {
|
|
2464
|
+
const n = ws();
|
|
2465
|
+
switch (e.value.type) {
|
|
2466
|
+
case "RelQuery":
|
|
2467
|
+
ir(r, t.root, t.value, e.value, (a) => {
|
|
2468
|
+
n.push(a);
|
|
2469
|
+
});
|
|
2470
|
+
break;
|
|
2471
|
+
case "JsonPathQuery":
|
|
2472
|
+
ir(r, t.root, t.root, e.value, (a) => {
|
|
2473
|
+
n.push(a);
|
|
2474
|
+
});
|
|
2475
|
+
break;
|
|
2476
|
+
default:
|
|
2477
|
+
Ce(e.value);
|
|
2478
|
+
}
|
|
2479
|
+
return n;
|
|
2480
|
+
}
|
|
2481
|
+
function Oa(r, t, e) {
|
|
2482
|
+
switch (e.expression.type) {
|
|
2483
|
+
case "FilterQuery":
|
|
2484
|
+
return Rs(r, t, e.expression).length > 0;
|
|
2485
|
+
case "FunctionExpr":
|
|
2486
|
+
return Hr(r, t, e.expression) === !0;
|
|
2487
|
+
default:
|
|
2488
|
+
Ce(e.expression);
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
function ke(r, t, e) {
|
|
2492
|
+
switch (e.type) {
|
|
2493
|
+
case "LogicalNotExpr":
|
|
2494
|
+
return !ke(r, t, e.expression);
|
|
2495
|
+
case "LogicalAndExpr":
|
|
2496
|
+
return ke(r, t, e.left) && ke(r, t, e.right);
|
|
2497
|
+
case "LogicalOrExpr":
|
|
2498
|
+
return ke(r, t, e.left) || ke(r, t, e.right);
|
|
2499
|
+
case "TestExpr":
|
|
2500
|
+
return Oa(r, t, e);
|
|
2501
|
+
case "ComparisonExpr":
|
|
2502
|
+
return Os(r, t, e);
|
|
2503
|
+
default:
|
|
2504
|
+
Ce(e);
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
function Ta(r, t, e) {
|
|
2508
|
+
switch (e.type) {
|
|
2509
|
+
case "FunctionExpr":
|
|
2510
|
+
return Hr(r, t, e);
|
|
2511
|
+
case "FilterQuery":
|
|
2512
|
+
return Rs(r, t, e);
|
|
2513
|
+
case "LogicalNotExpr":
|
|
2514
|
+
case "LogicalAndExpr":
|
|
2515
|
+
case "LogicalOrExpr":
|
|
2516
|
+
case "TestExpr":
|
|
2517
|
+
return ke(r, t, e);
|
|
2518
|
+
case "Literal":
|
|
2519
|
+
return e.value;
|
|
2520
|
+
default:
|
|
2521
|
+
Ce(e);
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
function Pa(r) {
|
|
2525
|
+
return Q(r) ? r.length === 1 ? r[0] : Pe : r;
|
|
2526
|
+
}
|
|
2527
|
+
function Hr(r, t, e) {
|
|
2528
|
+
if (!Fa(r.functions, e.name))
|
|
2529
|
+
return !1;
|
|
2530
|
+
const n = r.functions[e.name];
|
|
2531
|
+
if (n.definition.parameters.length !== e.arguments.length)
|
|
2532
|
+
return !1;
|
|
2533
|
+
const a = [];
|
|
2534
|
+
for (let c = 0; c < e.arguments.length; c++) {
|
|
2535
|
+
const f = Ta(r, t, e.arguments[c]), l = n.definition.parameters[c];
|
|
2536
|
+
switch (l) {
|
|
2537
|
+
case "ValueType":
|
|
2538
|
+
if (!Q(f) && !ua(f))
|
|
2539
|
+
return !1;
|
|
2540
|
+
a.push(Pa(f));
|
|
2541
|
+
break;
|
|
2542
|
+
case "NodesType":
|
|
2543
|
+
if (!Q(f))
|
|
2544
|
+
return !1;
|
|
2545
|
+
a.push(f);
|
|
2546
|
+
break;
|
|
2547
|
+
case "LogicalType":
|
|
2548
|
+
if (typeof f == "boolean")
|
|
2549
|
+
a.push(f);
|
|
2550
|
+
else if (Q(f))
|
|
2551
|
+
a.push(f.length > 0);
|
|
2552
|
+
else
|
|
2553
|
+
return !1;
|
|
2554
|
+
break;
|
|
2555
|
+
default:
|
|
2556
|
+
Es(l, "Unknown function argument type");
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
return n.declaration(
|
|
2560
|
+
r,
|
|
2561
|
+
...a
|
|
2562
|
+
);
|
|
2563
|
+
}
|
|
2564
|
+
function Fa(r, t) {
|
|
2565
|
+
return Object.hasOwn(r, t);
|
|
2566
|
+
}
|
|
2567
|
+
function Jt(r, t, e) {
|
|
2568
|
+
switch (e.type) {
|
|
2569
|
+
case "Literal":
|
|
2570
|
+
return e.value;
|
|
2571
|
+
case "RelSingularQuery":
|
|
2572
|
+
case "AbsSingularQuery": {
|
|
2573
|
+
const n = e.type === "RelSingularQuery" ? t.value : t.root;
|
|
2574
|
+
if (e.segments.length === 0)
|
|
2575
|
+
return n;
|
|
2576
|
+
const a = ws();
|
|
2577
|
+
return ir(r, t.root, n, e, (c) => {
|
|
2578
|
+
a.push(c);
|
|
2579
|
+
}), a;
|
|
2580
|
+
}
|
|
2581
|
+
case "FunctionExpr":
|
|
2582
|
+
return Hr(r, t, e);
|
|
2583
|
+
default:
|
|
2584
|
+
Ce(e);
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
function Os(r, t, e) {
|
|
2588
|
+
const n = Jt(r, t, e.left), a = Jt(r, t, e.right);
|
|
2589
|
+
return Ra(n, a, e.op);
|
|
2590
|
+
}
|
|
2591
|
+
function Ts(r, t, e) {
|
|
2592
|
+
if (e.value.type === "ComparisonExpr") {
|
|
2593
|
+
if (!Os(r, t, e.value))
|
|
2594
|
+
return;
|
|
2595
|
+
} else if (!ke(r, t, e.value))
|
|
2596
|
+
return;
|
|
2597
|
+
r.stack.push({
|
|
2598
|
+
root: t.root,
|
|
2599
|
+
path: t.path,
|
|
2600
|
+
value: t.value,
|
|
2601
|
+
index: t.index + 1
|
|
2602
|
+
});
|
|
2603
|
+
}
|
|
2604
|
+
function _a(r, t) {
|
|
2605
|
+
return r < 0 ? t + r : r;
|
|
2606
|
+
}
|
|
2607
|
+
function Ps(r, t, e) {
|
|
2608
|
+
const n = _a(e.value, t.value.length);
|
|
2609
|
+
n >= 0 && n < t.value.length && r.stack.push({
|
|
2610
|
+
root: t.root,
|
|
2611
|
+
path: se(t.path, n),
|
|
2612
|
+
value: t.value[n],
|
|
2613
|
+
index: t.index + 1
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2616
|
+
function Fs(r, { root: t, path: e, value: n, index: a }, c) {
|
|
2617
|
+
Object.hasOwn(n, c.value) && r.stack.push({
|
|
2618
|
+
root: t,
|
|
2619
|
+
path: se(e, c.value),
|
|
2620
|
+
value: n[c.value],
|
|
2621
|
+
index: a + 1
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
function or(r, t) {
|
|
2625
|
+
return r >= 0 ? r : t + r;
|
|
2626
|
+
}
|
|
2627
|
+
function Ia(r, t, e, n) {
|
|
2628
|
+
const a = or(r, n), c = or(t, n);
|
|
2629
|
+
if (e >= 0) {
|
|
2630
|
+
const h = Math.min(Math.max(a, 0), n), d = Math.min(Math.max(c, 0), n);
|
|
2631
|
+
return [h, d];
|
|
2632
|
+
}
|
|
2633
|
+
const f = Math.min(Math.max(a, -1), n - 1);
|
|
2634
|
+
return [Math.min(Math.max(c, -1), n - 1), f];
|
|
2635
|
+
}
|
|
2636
|
+
function Da(r, { root: t, path: e, value: n, index: a }, c) {
|
|
2637
|
+
const f = c.step ?? 1, l = f >= 0 ? 0 : n.length - 1, h = f >= 0 ? n.length : -n.length - 1, d = c.start === null ? l : or(c.start, n.length), g = c.end === null ? h : or(c.end, n.length), [k, y] = Ia(d, g, f, n.length);
|
|
2638
|
+
if (f > 0) {
|
|
2639
|
+
let C = k;
|
|
2640
|
+
for (; C < y; )
|
|
2641
|
+
r.stack.push({
|
|
2642
|
+
root: t,
|
|
2643
|
+
path: se(e, C),
|
|
2644
|
+
value: n[C],
|
|
2645
|
+
index: a + 1
|
|
2646
|
+
}), C += f;
|
|
2647
|
+
} else if (f < 0) {
|
|
2648
|
+
let C = y;
|
|
2649
|
+
for (; k < C; )
|
|
2650
|
+
r.stack.push({
|
|
2651
|
+
root: t,
|
|
2652
|
+
path: se(e, C),
|
|
2653
|
+
value: n[C],
|
|
2654
|
+
index: a + 1
|
|
2655
|
+
}), C += f;
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
function _s(r, { root: t, path: e, value: n, index: a }) {
|
|
2659
|
+
if (Array.isArray(n))
|
|
2660
|
+
for (let c = 0; c < n.length; c++)
|
|
2661
|
+
r.stack.push({
|
|
2662
|
+
root: t,
|
|
2663
|
+
path: se(e, c),
|
|
2664
|
+
value: n[c],
|
|
2665
|
+
index: a + 1
|
|
2666
|
+
});
|
|
2667
|
+
else if (xe(n))
|
|
2668
|
+
for (const c of Object.keys(n))
|
|
2669
|
+
r.stack.push({
|
|
2670
|
+
root: t,
|
|
2671
|
+
path: se(e, c),
|
|
2672
|
+
value: n[c],
|
|
2673
|
+
index: a + 1
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
function Na(r, t, e) {
|
|
2677
|
+
for (const n of e.selectors)
|
|
2678
|
+
switch (n.type) {
|
|
2679
|
+
case "NameSelector":
|
|
2680
|
+
nr(t) && Fs(r, t, n);
|
|
2681
|
+
break;
|
|
2682
|
+
case "SliceSelector":
|
|
2683
|
+
tr(t) && Da(r, t, n);
|
|
2684
|
+
break;
|
|
2685
|
+
case "IndexSelector": {
|
|
2686
|
+
tr(t) && Ps(r, t, n);
|
|
2687
|
+
break;
|
|
2688
|
+
}
|
|
2689
|
+
case "WildcardSelector":
|
|
2690
|
+
_s(r, t);
|
|
2691
|
+
break;
|
|
2692
|
+
case "FilterSelector": {
|
|
2693
|
+
tr(t) ? La(r, t, n) : nr(t) && ja(r, t, n);
|
|
2694
|
+
break;
|
|
2695
|
+
}
|
|
2696
|
+
default:
|
|
2697
|
+
Ce(n);
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
function La(r, { root: t, path: e, value: n, index: a }, c) {
|
|
2701
|
+
for (let f = 0; f < n.length; f++)
|
|
2702
|
+
Ts(r, {
|
|
2703
|
+
root: t,
|
|
2704
|
+
path: se(e, f),
|
|
2705
|
+
value: n[f],
|
|
2706
|
+
index: a
|
|
2707
|
+
}, c);
|
|
2708
|
+
}
|
|
2709
|
+
function ja(r, { root: t, path: e, value: n, index: a }, c) {
|
|
2710
|
+
for (const f of Object.keys(n))
|
|
2711
|
+
Ts(r, {
|
|
2712
|
+
root: t,
|
|
2713
|
+
path: se(e, f),
|
|
2714
|
+
value: n[f],
|
|
2715
|
+
index: a
|
|
2716
|
+
}, c);
|
|
2717
|
+
}
|
|
2718
|
+
function Wa(r, { root: t, path: e, value: n, index: a }, c) {
|
|
2719
|
+
Object.hasOwn(n, c.value) && r.stack.push({
|
|
2720
|
+
root: t,
|
|
2721
|
+
path: se(e, c.value),
|
|
2722
|
+
value: n[c.value],
|
|
2723
|
+
index: a + 1
|
|
2724
|
+
});
|
|
2725
|
+
}
|
|
2726
|
+
function qa(r, t, e) {
|
|
2727
|
+
switch (e.type) {
|
|
2728
|
+
case "BracketedSelection":
|
|
2729
|
+
return Na(r, t, e);
|
|
2730
|
+
case "WildcardSelector":
|
|
2731
|
+
return _s(r, t);
|
|
2732
|
+
case "MemberNameShorthand":
|
|
2733
|
+
nr(t) && Wa(r, t, e);
|
|
2734
|
+
break;
|
|
2735
|
+
case "NameSelector":
|
|
2736
|
+
nr(t) && Fs(r, t, e);
|
|
2737
|
+
break;
|
|
2738
|
+
case "IndexSelector":
|
|
2739
|
+
tr(t) && Ps(r, t, e);
|
|
2740
|
+
break;
|
|
2741
|
+
default:
|
|
2742
|
+
Ce(e);
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
function ir(r, t, e, n, a) {
|
|
2746
|
+
const c = new fa();
|
|
2747
|
+
c.push({
|
|
2748
|
+
root: t,
|
|
2749
|
+
path: wa(r.capturePaths),
|
|
2750
|
+
value: e,
|
|
2751
|
+
index: 0
|
|
2752
|
+
});
|
|
2753
|
+
const f = {
|
|
2754
|
+
cache: r.cache,
|
|
2755
|
+
capturePaths: !1,
|
|
2756
|
+
functions: r.functions,
|
|
2757
|
+
regexp: r.regexp,
|
|
2758
|
+
stack: c
|
|
2759
|
+
};
|
|
2760
|
+
for (; c.size > 0; ) {
|
|
2761
|
+
const l = c.pop();
|
|
2762
|
+
if (l.index === n.segments.length) {
|
|
2763
|
+
a(l.value, l.path);
|
|
2764
|
+
continue;
|
|
2765
|
+
}
|
|
2766
|
+
const { path: h, value: d, index: g } = l, k = n.segments[g];
|
|
2767
|
+
if (qa(f, l, k.node), k.type === "DescendantSegment") {
|
|
2768
|
+
if (Array.isArray(d))
|
|
2769
|
+
for (let y = 0; y < d.length; y++)
|
|
2770
|
+
c.push({
|
|
2771
|
+
root: t,
|
|
2772
|
+
path: se(h, y),
|
|
2773
|
+
value: d[y],
|
|
2774
|
+
index: g
|
|
2775
|
+
});
|
|
2776
|
+
else if (d !== null && typeof d == "object")
|
|
2777
|
+
for (const y of Object.keys(d))
|
|
2778
|
+
c.push({
|
|
2779
|
+
root: t,
|
|
2780
|
+
path: se(h, y),
|
|
2781
|
+
value: d[y],
|
|
2782
|
+
index: g
|
|
2783
|
+
});
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
function Ua(r, t, e, n) {
|
|
2788
|
+
const a = {
|
|
2789
|
+
cache: /* @__PURE__ */ new Map(),
|
|
2790
|
+
capturePaths: e.capturePaths,
|
|
2791
|
+
functions: {
|
|
2792
|
+
count: la,
|
|
2793
|
+
search: $a,
|
|
2794
|
+
value: ya,
|
|
2795
|
+
match: ma,
|
|
2796
|
+
length: da
|
|
2797
|
+
},
|
|
2798
|
+
regexp: "i-regexp"
|
|
2799
|
+
};
|
|
2800
|
+
ir(a, r, r, ca(t), n);
|
|
2801
|
+
}
|
|
2802
|
+
function Ur(r, t) {
|
|
2803
|
+
const e = [];
|
|
2804
|
+
return Ua(r, t, { capturePaths: !1 }, (n) => {
|
|
2805
|
+
e.push(n);
|
|
2806
|
+
}), e;
|
|
2807
|
+
}
|
|
2808
|
+
function za(r, t) {
|
|
2809
|
+
try {
|
|
2810
|
+
const e = Ba(r, t);
|
|
2811
|
+
return !!new Function(`return ${e};`)();
|
|
2812
|
+
} catch {
|
|
2813
|
+
return !1;
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
function Ba(r, t) {
|
|
2817
|
+
const e = [];
|
|
2818
|
+
let n = 0, a = "";
|
|
2819
|
+
for (; n < r.length; )
|
|
2820
|
+
if (r[n] === "$") {
|
|
2821
|
+
a.length > 0 && (e.push(a), a = "");
|
|
2822
|
+
const c = n, f = xa(r, n);
|
|
2823
|
+
if (f.length > 1) {
|
|
2824
|
+
const l = Ma(f, t);
|
|
2825
|
+
e.push(l);
|
|
2826
|
+
}
|
|
2827
|
+
n = c + f.length;
|
|
2828
|
+
} else
|
|
2829
|
+
a += r[n], n++;
|
|
2830
|
+
return a.length > 0 && e.push(a), e.join("");
|
|
2831
|
+
}
|
|
2832
|
+
function xa(r, t) {
|
|
2833
|
+
let e = "$", n = 0, a = !1, c = "", f = !1, l = 0, h = t + 1;
|
|
2834
|
+
for (; h < r.length; ) {
|
|
2835
|
+
const d = r[h];
|
|
2836
|
+
if ((d === '"' || d === "'") && !a) {
|
|
2837
|
+
a = !0, c = d, e += d, h++;
|
|
2838
|
+
continue;
|
|
2839
|
+
}
|
|
2840
|
+
if (d === c && a) {
|
|
2841
|
+
a = !1, e += d, h++;
|
|
2842
|
+
continue;
|
|
2843
|
+
}
|
|
2844
|
+
if (a) {
|
|
2845
|
+
e += d, h++;
|
|
2846
|
+
continue;
|
|
2847
|
+
}
|
|
2848
|
+
if (d === "[") {
|
|
2849
|
+
n++, h + 1 < r.length && r[h + 1] === "?" && (f = !0, l = n), e += d, h++;
|
|
2850
|
+
continue;
|
|
2851
|
+
}
|
|
2852
|
+
if (d === "]") {
|
|
2853
|
+
n--, f && n < l && (f = !1), e += d, h++;
|
|
2854
|
+
continue;
|
|
2855
|
+
}
|
|
2856
|
+
if (!f && (/\s/.test(d) || /[<>=!&|,)]/.test(d)))
|
|
2857
|
+
break;
|
|
2858
|
+
e += d, h++;
|
|
2859
|
+
}
|
|
2860
|
+
return e;
|
|
2861
|
+
}
|
|
2862
|
+
function Ma(r, t) {
|
|
2863
|
+
if (r.endsWith(".length")) {
|
|
2864
|
+
const a = r.slice(0, -7), c = zr(a), l = Ur(t, c)[0] ?? null;
|
|
2865
|
+
return Array.isArray(l) ? String(l.length) : "0";
|
|
2866
|
+
}
|
|
2867
|
+
if (r.includes("[?(") && r.includes(")]"))
|
|
2868
|
+
return Va(r, t);
|
|
2869
|
+
const e = zr(r), n = Ur(t, e);
|
|
2870
|
+
return JSON.stringify(n[0]);
|
|
2871
|
+
}
|
|
2872
|
+
function Va(r, t) {
|
|
2873
|
+
const e = r.match(/\[\?\((.*)\)\]/);
|
|
2874
|
+
if (!e)
|
|
2875
|
+
return "false";
|
|
2876
|
+
const n = e[1], a = r.substring(0, r.indexOf("[?(")), c = zr(a), f = Ur(t, c), l = Array.isArray(f) ? f.flat() : f;
|
|
2877
|
+
if (!Array.isArray(l))
|
|
2878
|
+
return "false";
|
|
2879
|
+
const h = l.filter((g) => {
|
|
2880
|
+
const k = Ka(n, g);
|
|
2881
|
+
try {
|
|
2882
|
+
return !!new Function("item", `return ${k};`)(g);
|
|
2883
|
+
} catch {
|
|
2884
|
+
return !1;
|
|
2885
|
+
}
|
|
2886
|
+
}), d = r.substring(r.indexOf(")]") + 2);
|
|
2887
|
+
if (d.startsWith(".")) {
|
|
2888
|
+
const g = d.match(/\.([a-zA-Z0-9_-]+)/);
|
|
2889
|
+
if (g) {
|
|
2890
|
+
const k = g[1].replace(/-/g, "_"), y = h.map((C) => C[k]);
|
|
2891
|
+
return JSON.stringify(y);
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
return h.length > 0 ? JSON.stringify(h) : "false";
|
|
2895
|
+
}
|
|
2896
|
+
function Ka(r, t) {
|
|
2897
|
+
let e = r;
|
|
2898
|
+
return e = e.replace(/@\.([a-zA-Z0-9_-]+)\.match\(([^)]+)\)/g, (n, a, c) => {
|
|
2899
|
+
const f = a.replace(/-/g, "_"), l = t[f];
|
|
2900
|
+
if (typeof l != "string")
|
|
2901
|
+
return "false";
|
|
2902
|
+
try {
|
|
2903
|
+
let h = c.replace(/^["']|["']$/g, "");
|
|
2904
|
+
h = h.replace(/^\/|\/$/g, "");
|
|
2905
|
+
const d = new RegExp(h);
|
|
2906
|
+
return String(d.test(l));
|
|
2907
|
+
} catch {
|
|
2908
|
+
return "false";
|
|
2909
|
+
}
|
|
2910
|
+
}), e = e.replace(/@\.([a-zA-Z0-9_-]+)/g, (n, a) => {
|
|
2911
|
+
const c = a.replace(/-/g, "_"), f = t[c];
|
|
2912
|
+
return JSON.stringify(f);
|
|
2913
|
+
}), e;
|
|
2914
|
+
}
|
|
2915
|
+
function zr(r) {
|
|
2916
|
+
return r.replace(/\.([a-zA-Z0-9_-]+)/g, (t, e) => "." + e.replace(/-/g, "_"));
|
|
2917
|
+
}
|
|
2918
|
+
function Is({ workflowId: r, step: t, criteria: e = [], ctx: n }) {
|
|
2919
|
+
oa(e);
|
|
2920
|
+
const a = [];
|
|
2921
|
+
if (!r)
|
|
2922
|
+
return a.push({
|
|
2923
|
+
name: V.SUCCESS_CRITERIA_CHECK,
|
|
2924
|
+
passed: !1,
|
|
2925
|
+
message: `Undefined workflowId for step ${t.stepId}`,
|
|
2926
|
+
severity: n.severity.SUCCESS_CRITERIA_CHECK
|
|
2927
|
+
}), a;
|
|
2928
|
+
const c = lr({
|
|
2929
|
+
ctx: n,
|
|
2930
|
+
workflowId: r,
|
|
2931
|
+
step: t
|
|
2932
|
+
});
|
|
2933
|
+
return e.forEach((f) => {
|
|
2934
|
+
const { condition: l } = f;
|
|
2935
|
+
try {
|
|
2936
|
+
if (gs(f)) {
|
|
2937
|
+
const h = l.match(/^\/(.*)\/([gimsuy]*)$/);
|
|
2938
|
+
let d, g;
|
|
2939
|
+
h ? (d = h[1], g = h[2]) : (d = l, g = "");
|
|
2940
|
+
const { context: k } = f, y = new RegExp(d, g);
|
|
2941
|
+
a.push({
|
|
2942
|
+
name: V.SUCCESS_CRITERIA_CHECK,
|
|
2943
|
+
passed: y.test(Se(k, c, n.options.logger)),
|
|
2944
|
+
message: `Checking regex criteria: ${JSON.stringify(f)}`,
|
|
2945
|
+
severity: n.severity.SUCCESS_CRITERIA_CHECK,
|
|
2946
|
+
condition: l
|
|
2947
|
+
});
|
|
2948
|
+
} else if (ms(f)) {
|
|
2949
|
+
const { context: h } = f, d = Se(h, c, n.options.logger);
|
|
2950
|
+
a.push({
|
|
2951
|
+
name: V.SUCCESS_CRITERIA_CHECK,
|
|
2952
|
+
passed: za(l, d),
|
|
2953
|
+
message: `Checking jsonpath criteria: ${l}`,
|
|
2954
|
+
severity: n.severity.SUCCESS_CRITERIA_CHECK,
|
|
2955
|
+
condition: l
|
|
2956
|
+
});
|
|
2957
|
+
} else
|
|
2958
|
+
a.push({
|
|
2959
|
+
name: V.SUCCESS_CRITERIA_CHECK,
|
|
2960
|
+
passed: Se(l, c, n.options.logger),
|
|
2961
|
+
message: `Checking simple criteria: ${JSON.stringify(f)}`,
|
|
2962
|
+
severity: n.severity.SUCCESS_CRITERIA_CHECK,
|
|
2963
|
+
condition: l
|
|
2964
|
+
});
|
|
2965
|
+
} catch (h) {
|
|
2966
|
+
a.push({
|
|
2967
|
+
name: V.SUCCESS_CRITERIA_CHECK,
|
|
2968
|
+
passed: !1,
|
|
2969
|
+
message: `Failed to pass ${JSON.stringify(f)}: ${h.message}`,
|
|
2970
|
+
severity: n.severity.SUCCESS_CRITERIA_CHECK,
|
|
2971
|
+
condition: f.condition
|
|
2972
|
+
});
|
|
2973
|
+
}
|
|
2974
|
+
}), a;
|
|
2975
|
+
}
|
|
2976
|
+
async function Ha({ ctx: r, workflowId: t, step: e, requestData: n }) {
|
|
2977
|
+
e.checks = [];
|
|
2978
|
+
const a = {
|
|
2979
|
+
successCriteriaCheck: !0,
|
|
2980
|
+
schemaCheck: !0,
|
|
2981
|
+
networkCheck: !0,
|
|
2982
|
+
unexpectedErrorCheck: !0,
|
|
2983
|
+
statusCodeCheck: !0
|
|
2984
|
+
};
|
|
2985
|
+
try {
|
|
2986
|
+
e.response = await r.apiClient.fetchResult({ ctx: r, step: e, requestData: n, workflowId: t });
|
|
2987
|
+
} catch (h) {
|
|
2988
|
+
return h instanceof rs ? (e.checks.push({
|
|
2989
|
+
name: V.UNEXPECTED_ERROR,
|
|
2990
|
+
passed: !1,
|
|
2991
|
+
message: h.message,
|
|
2992
|
+
severity: r.severity.UNEXPECTED_ERROR
|
|
2993
|
+
}), a.unexpectedErrorCheck = !1, a) : h instanceof es ? (e.checks.push({
|
|
2994
|
+
name: V.STATUS_CODE_CHECK,
|
|
2995
|
+
passed: !1,
|
|
2996
|
+
message: h.message,
|
|
2997
|
+
severity: r.severity.STATUS_CODE_CHECK
|
|
2998
|
+
}), a.statusCodeCheck = !1, a) : (e.checks.push({
|
|
2999
|
+
name: V.NETWORK_ERROR,
|
|
3000
|
+
passed: !1,
|
|
3001
|
+
message: h.message,
|
|
3002
|
+
severity: r.severity.NETWORK_ERROR
|
|
3003
|
+
}), a.networkCheck = !1, a);
|
|
3004
|
+
}
|
|
3005
|
+
const c = r.$workflows[t].steps[e.stepId].request;
|
|
3006
|
+
if (e.request = c, e.verboseLog = r.apiClient.getVerboseResponseLogs(), e.successCriteria) {
|
|
3007
|
+
const h = Is({
|
|
3008
|
+
workflowId: t,
|
|
3009
|
+
step: e,
|
|
3010
|
+
criteria: e.successCriteria,
|
|
3011
|
+
ctx: {
|
|
3012
|
+
...r,
|
|
3013
|
+
$request: c,
|
|
3014
|
+
$response: e.response,
|
|
3015
|
+
$inputs: r.$workflows[t].inputs
|
|
3016
|
+
}
|
|
3017
|
+
});
|
|
3018
|
+
a.successCriteriaCheck = h.every((d) => d.passed || ["off", "warn"].includes(d.severity)), e.checks.push(...h);
|
|
3019
|
+
}
|
|
3020
|
+
const f = Ko({
|
|
3021
|
+
stepCallCtx: {
|
|
3022
|
+
$response: e.response,
|
|
3023
|
+
$inputs: r.$workflows[t].inputs
|
|
3024
|
+
},
|
|
3025
|
+
descriptionOperation: n.openapiOperation,
|
|
3026
|
+
ctx: r
|
|
3027
|
+
});
|
|
3028
|
+
f.length && (a.schemaCheck = f.every((h) => h.passed || ["off", "warn"].includes(h.severity)), e.checks.push(...f));
|
|
3029
|
+
const l = {};
|
|
3030
|
+
if (e.outputs) {
|
|
3031
|
+
const h = lr({
|
|
3032
|
+
ctx: {
|
|
3033
|
+
...r,
|
|
3034
|
+
$response: e.response,
|
|
3035
|
+
$inputs: r.$workflows[t].inputs
|
|
3036
|
+
},
|
|
3037
|
+
workflowId: t,
|
|
3038
|
+
step: e
|
|
3039
|
+
});
|
|
3040
|
+
for (const d of Object.keys(e.outputs))
|
|
3041
|
+
l[d] = oe({
|
|
3042
|
+
payload: e.outputs[d],
|
|
3043
|
+
context: h,
|
|
3044
|
+
logger: r.options.logger
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
3047
|
+
return r.$steps[e.stepId] = {
|
|
3048
|
+
outputs: { ...r.$steps[e.stepId].outputs, ...l }
|
|
3049
|
+
}, r.$workflows[t].steps[e.stepId] = {
|
|
3050
|
+
outputs: { ...r.$steps[e.stepId].outputs, ...l },
|
|
3051
|
+
request: c,
|
|
3052
|
+
response: e.response
|
|
3053
|
+
}, a;
|
|
3054
|
+
}
|
|
3055
|
+
function Ja(r = 0) {
|
|
3056
|
+
return new Promise((t) => setTimeout(t, r * 1e3));
|
|
3057
|
+
}
|
|
3058
|
+
function Xa({ ctx: r, descriptionName: t, openapiOperation: e, xOperation: n }) {
|
|
3059
|
+
if (!t && n?.url)
|
|
3060
|
+
return { url: n?.url };
|
|
3061
|
+
if (r.options?.server && t) {
|
|
3062
|
+
const c = Kr(r.options.server);
|
|
3063
|
+
if (c[t])
|
|
3064
|
+
return { url: c[t] };
|
|
3065
|
+
}
|
|
3066
|
+
const a = r.sourceDescriptions?.find((c) => c.name === t);
|
|
3067
|
+
if (a && a.type === "openapi" && a["x-serverUrl"]) {
|
|
3068
|
+
if (a["x-serverUrl"].startsWith("http"))
|
|
3069
|
+
return {
|
|
3070
|
+
url: a["x-serverUrl"]
|
|
3071
|
+
};
|
|
3072
|
+
const c = a["x-serverUrl"].startsWith("$servers.") ? a["x-serverUrl"].split(".")[1] : void 0;
|
|
3073
|
+
if (!c)
|
|
3074
|
+
return;
|
|
3075
|
+
const f = fe({
|
|
3076
|
+
value: `$sourceDescriptions.${t}.servers.${c}`,
|
|
3077
|
+
ctx: r,
|
|
3078
|
+
logger: r.options.logger
|
|
3079
|
+
});
|
|
3080
|
+
return Ye(f);
|
|
3081
|
+
}
|
|
3082
|
+
if (e?.servers?.[0]) {
|
|
3083
|
+
const c = r.sourceDescriptions?.find((l) => l.name === e.sourceDescriptionName);
|
|
3084
|
+
let f;
|
|
3085
|
+
return r.sourceDescriptions?.length === 1 && r.sourceDescriptions[0] ? f = "x-serverUrl" in r.sourceDescriptions[0] ? r.sourceDescriptions[0]["x-serverUrl"] : void 0 : c && (f = "x-serverUrl" in c ? c["x-serverUrl"] : void 0), f ? { url: f } : Ye(e.servers[0]);
|
|
3086
|
+
}
|
|
3087
|
+
if (!t && r?.sourceDescriptions && r.sourceDescriptions.length === 1) {
|
|
3088
|
+
const c = r.sourceDescriptions[0];
|
|
3089
|
+
return "x-serverUrl" in c && c["x-serverUrl"] ? { url: c["x-serverUrl"] } : Ye(r.$sourceDescriptions[c.name]?.servers[0]) || void 0;
|
|
3090
|
+
}
|
|
3091
|
+
if (!(!t || !r.$sourceDescriptions || !r.$sourceDescriptions[t] || !r.$sourceDescriptions[t]?.servers?.length))
|
|
3092
|
+
return Ye(r.$sourceDescriptions[t].servers?.[0]);
|
|
3093
|
+
}
|
|
3094
|
+
function Ye(r) {
|
|
3095
|
+
if (r)
|
|
3096
|
+
return {
|
|
3097
|
+
url: r.url,
|
|
3098
|
+
parameters: Object.entries(r.variables || {}).map(([t, e]) => ({
|
|
3099
|
+
in: "path",
|
|
3100
|
+
name: t,
|
|
3101
|
+
value: e.default
|
|
3102
|
+
})).filter(({ value: t }) => !!t)
|
|
3103
|
+
};
|
|
3104
|
+
}
|
|
3105
|
+
function Qa(r, t) {
|
|
3106
|
+
if (Ya(r))
|
|
3107
|
+
return {
|
|
3108
|
+
in: r.scheme.in,
|
|
3109
|
+
name: r.scheme.name,
|
|
3110
|
+
value: r.values.apiKey
|
|
3111
|
+
};
|
|
3112
|
+
if (ec(r)) {
|
|
3113
|
+
const { username: e, password: n } = r.values, a = btoa(`${e}:${n}`);
|
|
3114
|
+
return t.secretsSet.add(a), er(`Basic ${a}`);
|
|
3115
|
+
}
|
|
3116
|
+
if (rc(r)) {
|
|
3117
|
+
const { token: e } = r.values;
|
|
3118
|
+
return t.secretsSet.add(e), er(`Bearer ${e}`);
|
|
3119
|
+
}
|
|
3120
|
+
if (Za(r)) {
|
|
3121
|
+
const { accessToken: e } = r.values;
|
|
3122
|
+
return t.secretsSet.add(e), er(`Bearer ${e}`);
|
|
3123
|
+
}
|
|
3124
|
+
if (Ga(r)) {
|
|
3125
|
+
const { accessToken: e } = r.values;
|
|
3126
|
+
return t.secretsSet.add(e), er(`Bearer ${e}`);
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
function er(r, t) {
|
|
3130
|
+
return {
|
|
3131
|
+
in: "header",
|
|
3132
|
+
name: "Authorization",
|
|
3133
|
+
value: r
|
|
3134
|
+
};
|
|
3135
|
+
}
|
|
3136
|
+
function Ga(r) {
|
|
3137
|
+
return r.scheme.type === "oauth2";
|
|
3138
|
+
}
|
|
3139
|
+
function Za(r) {
|
|
3140
|
+
return r.scheme.type === "openIdConnect";
|
|
3141
|
+
}
|
|
3142
|
+
function Ya(r) {
|
|
3143
|
+
return r.scheme.type === "apiKey";
|
|
3144
|
+
}
|
|
3145
|
+
function ec(r) {
|
|
3146
|
+
return r.scheme.type === "http" && r.scheme.scheme === "basic";
|
|
3147
|
+
}
|
|
3148
|
+
function rc(r) {
|
|
3149
|
+
return r.scheme.type === "http" && r.scheme.scheme === "bearer";
|
|
3150
|
+
}
|
|
3151
|
+
const tc = {
|
|
3152
|
+
apiKey: ["apiKey"],
|
|
3153
|
+
basic: ["username", "password"],
|
|
3154
|
+
digest: ["username", "password"],
|
|
3155
|
+
bearer: ["token"],
|
|
3156
|
+
oauth2: ["accessToken"],
|
|
3157
|
+
openIdConnect: ["accessToken"],
|
|
3158
|
+
mutualTLS: []
|
|
3159
|
+
};
|
|
3160
|
+
function sc({ scheme: r, values: t }) {
|
|
3161
|
+
const e = r.type === "http" ? r.scheme : r.type, n = tc[e];
|
|
3162
|
+
if (!n)
|
|
3163
|
+
throw new Error(`Unsupported security scheme type: ${e}`);
|
|
3164
|
+
for (const a of n)
|
|
3165
|
+
if (!t?.[a])
|
|
3166
|
+
throw new Error(`Missing required value \`${a}\` for ${e} security scheme`);
|
|
3167
|
+
return { scheme: r, values: t };
|
|
3168
|
+
}
|
|
3169
|
+
function nc({ ctx: r, runtimeContext: t, step: e, operation: n, workflowLevelXSecurityParameters: a }) {
|
|
3170
|
+
const c = e["x-security"], l = [...a || [], ...c || []], h = [];
|
|
3171
|
+
for (const d of l) {
|
|
3172
|
+
const g = "schemeName" in d ? n?.securitySchemes?.[d.schemeName] : d.scheme;
|
|
3173
|
+
if ("schemeName" in d && !g)
|
|
3174
|
+
throw new Error(`Security scheme "${d.schemeName}" not found`);
|
|
3175
|
+
if (!g)
|
|
3176
|
+
continue;
|
|
3177
|
+
const k = Object.fromEntries(Object.entries(d?.values ?? {}).map(([j, T]) => {
|
|
3178
|
+
const N = oe({
|
|
3179
|
+
payload: T,
|
|
3180
|
+
context: t,
|
|
3181
|
+
logger: r.options.logger
|
|
3182
|
+
});
|
|
3183
|
+
return d.values && (d.values[j] = N), [j, N];
|
|
3184
|
+
})), y = sc({ scheme: g, values: k }), C = Qa(y, r);
|
|
3185
|
+
C && h.push(C);
|
|
3186
|
+
}
|
|
3187
|
+
return h;
|
|
3188
|
+
}
|
|
3189
|
+
async function oc(r, t, e) {
|
|
3190
|
+
const { stepId: n, operationId: a, operationPath: c, "x-operation": f } = t, l = r.workflows.find((x) => x.workflowId === e), h = l && l.parameters || [], d = f ? void 0 : Ti({
|
|
3191
|
+
operationId: a,
|
|
3192
|
+
operationPath: c
|
|
3193
|
+
}, r);
|
|
3194
|
+
let g = "", k;
|
|
3195
|
+
const y = Xa({
|
|
3196
|
+
ctx: r,
|
|
3197
|
+
descriptionName: d?.descriptionName,
|
|
3198
|
+
openapiOperation: d,
|
|
3199
|
+
xOperation: f
|
|
3200
|
+
});
|
|
3201
|
+
if (f)
|
|
3202
|
+
k = f.method;
|
|
3203
|
+
else if (d)
|
|
3204
|
+
g = d?.path, k = d?.method;
|
|
3205
|
+
else
|
|
3206
|
+
throw new Error("No operation found");
|
|
3207
|
+
if (!y && !g.includes("http"))
|
|
3208
|
+
throw new Error("No servers found in API description");
|
|
3209
|
+
if (!k)
|
|
3210
|
+
throw new Error('"method" is required to make a request');
|
|
3211
|
+
const C = d && Ci(d, r.options.logger), {
|
|
3212
|
+
payload: j,
|
|
3213
|
+
// encoding: stepRequestBodyEncoding,
|
|
3214
|
+
contentType: T,
|
|
3215
|
+
replacements: N
|
|
3216
|
+
} = await ui(t.requestBody, r), P = j || C?.requestBody, L = T || C?.contentType, D = Xt(
|
|
3217
|
+
// order is important here, the last one wins
|
|
3218
|
+
typeof P == "object" ? [{ in: "header", name: "content-type", value: "application/json" }] : [],
|
|
3219
|
+
y?.parameters || [],
|
|
3220
|
+
C?.contentTypeParameters || [],
|
|
3221
|
+
// if step.parameters is defined, we do not auto-populate parameters from the openapi operation
|
|
3222
|
+
t.parameters ? [] : C?.parameters || [],
|
|
3223
|
+
Qt(h, r),
|
|
3224
|
+
T ? [{ in: "header", name: "content-type", value: T }] : [],
|
|
3225
|
+
Qt(t.parameters || [], r)
|
|
3226
|
+
);
|
|
3227
|
+
r.$steps[n] || (r.$steps[n] = {}), r.$workflows[e].steps[n] || (r.$workflows[e].steps[n] = {}), k?.toLowerCase() === "x-query" && (k = "query"), r.$workflows[e].steps[n].request = {
|
|
3228
|
+
body: P,
|
|
3229
|
+
header: ye(D, "header"),
|
|
3230
|
+
path: ye(D, "path"),
|
|
3231
|
+
query: ye(D, "query"),
|
|
3232
|
+
url: y?.url && g ? `${y?.url}${g}` : y?.url,
|
|
3233
|
+
method: k
|
|
3234
|
+
};
|
|
3235
|
+
const b = {
|
|
3236
|
+
...r,
|
|
3237
|
+
$inputs: {
|
|
3238
|
+
...r.$inputs || {},
|
|
3239
|
+
...r.$workflows[e]?.inputs || {}
|
|
3240
|
+
}
|
|
3241
|
+
}, A = lr({
|
|
3242
|
+
ctx: b,
|
|
3243
|
+
workflowId: e,
|
|
3244
|
+
step: t
|
|
3245
|
+
}), K = l?.["x-security"] || [], _ = nc({
|
|
3246
|
+
ctx: b,
|
|
3247
|
+
runtimeContext: A,
|
|
3248
|
+
step: t,
|
|
3249
|
+
operation: d,
|
|
3250
|
+
workflowLevelXSecurityParameters: K
|
|
3251
|
+
}), W = Xt(D, _).map((x) => ({
|
|
3252
|
+
...x,
|
|
3253
|
+
value: oe({
|
|
3254
|
+
payload: x.value,
|
|
3255
|
+
context: A,
|
|
3256
|
+
logger: r.options.logger
|
|
3257
|
+
})
|
|
3258
|
+
}));
|
|
3259
|
+
for (const x of d?.parameters || []) {
|
|
3260
|
+
const { schema: I, name: B } = x;
|
|
3261
|
+
Be(r, I, ye(D, x.in), [B]);
|
|
3262
|
+
}
|
|
3263
|
+
const z = oe({
|
|
3264
|
+
payload: P,
|
|
3265
|
+
context: A,
|
|
3266
|
+
contentType: L,
|
|
3267
|
+
logger: r.options.logger
|
|
3268
|
+
});
|
|
3269
|
+
if (N && typeof z == "object" && ki({
|
|
3270
|
+
payload: z,
|
|
3271
|
+
replacements: N,
|
|
3272
|
+
expressionContext: A,
|
|
3273
|
+
logger: r.options.logger
|
|
3274
|
+
}), L && d?.requestBody) {
|
|
3275
|
+
const x = Fi(L, d);
|
|
3276
|
+
typeof P == "object" && Be(r, x, P);
|
|
3277
|
+
}
|
|
3278
|
+
return r.$workflows[e].steps[n].request = {
|
|
3279
|
+
body: z,
|
|
3280
|
+
header: ye(W, "header"),
|
|
3281
|
+
path: ye(W, "path"),
|
|
3282
|
+
query: ye(W, "query"),
|
|
3283
|
+
url: y?.url && g ? `${y?.url}${g}` : y?.url,
|
|
3284
|
+
method: k
|
|
3285
|
+
}, {
|
|
3286
|
+
serverUrl: y,
|
|
3287
|
+
path: g,
|
|
3288
|
+
method: k,
|
|
3289
|
+
parameters: ic(W),
|
|
3290
|
+
requestBody: z,
|
|
3291
|
+
openapiOperation: d
|
|
3292
|
+
};
|
|
3293
|
+
}
|
|
3294
|
+
function Xt(...r) {
|
|
3295
|
+
const e = r.flat().filter((n) => "name" in n).reduce((n, a) => {
|
|
3296
|
+
const c = `${a.name}:${a.in}`;
|
|
3297
|
+
return n[c] = a, n;
|
|
3298
|
+
}, {});
|
|
3299
|
+
return Object.values(e);
|
|
3300
|
+
}
|
|
3301
|
+
function ye(r, t) {
|
|
3302
|
+
return r.reduce((e, n) => (n.in === t && "name" in n && (e[n.in === "header" ? n.name.toLowerCase() : n.name] = n.value), e), {});
|
|
3303
|
+
}
|
|
3304
|
+
function Qt(r, t) {
|
|
3305
|
+
return r.map((e) => {
|
|
3306
|
+
const n = We(e, t);
|
|
3307
|
+
if (Mr(n))
|
|
3308
|
+
return n;
|
|
3309
|
+
}).filter((e) => e !== void 0);
|
|
3310
|
+
}
|
|
3311
|
+
function ic(r) {
|
|
3312
|
+
const t = [];
|
|
3313
|
+
for (const e of r)
|
|
3314
|
+
if (e.in === "header" && e.name.toLowerCase() === "cookie") {
|
|
3315
|
+
const n = String(e.value).split(";").map((a) => {
|
|
3316
|
+
const [c, f] = a.split("=");
|
|
3317
|
+
return { name: c, value: f, in: "cookie" };
|
|
3318
|
+
});
|
|
3319
|
+
t.push(...n);
|
|
3320
|
+
} else
|
|
3321
|
+
t.push(e);
|
|
3322
|
+
return t;
|
|
3323
|
+
}
|
|
3324
|
+
class ce {
|
|
3325
|
+
constructor(t) {
|
|
3326
|
+
this.startTime = Date.now(), this.timeout = t;
|
|
3327
|
+
}
|
|
3328
|
+
static getInstance(t) {
|
|
3329
|
+
return ce.instance || (ce.instance = new ce(t)), ce.instance;
|
|
3330
|
+
}
|
|
3331
|
+
static reset() {
|
|
3332
|
+
ce.instance = void 0;
|
|
3333
|
+
}
|
|
3334
|
+
isTimedOut() {
|
|
3335
|
+
return Date.now() - this.startTime > this.timeout;
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
async function Br({ step: r, ctx: t, workflowId: e, retriesLeft: n, executedStepsCount: a }) {
|
|
3339
|
+
r = { ...r }, r.retriesLeft = n;
|
|
3340
|
+
const c = t.workflows.find((b) => b.workflowId === e), { stepId: f, onFailure: l, onSuccess: h, workflowId: d, parameters: g } = r, k = (l || c?.failureActions || []).map((b) => We(b, t)), y = (h || c?.successActions || []).map((b) => We(b, t)), C = g?.map((b) => We(b, t));
|
|
3341
|
+
if (d) {
|
|
3342
|
+
const b = t.workflows.find((W) => W.workflowId === d) || fe({ value: d, ctx: t, logger: t.options.logger });
|
|
3343
|
+
if (!b) {
|
|
3344
|
+
const W = {
|
|
3345
|
+
name: V.UNEXPECTED_ERROR,
|
|
3346
|
+
message: `Workflow ${U(d)} not found.`,
|
|
3347
|
+
passed: !1,
|
|
3348
|
+
severity: t.severity.UNEXPECTED_ERROR
|
|
3349
|
+
};
|
|
3350
|
+
r.checks.push(W);
|
|
3351
|
+
return;
|
|
3352
|
+
}
|
|
3353
|
+
const A = await xr(d, b, t, t.options.config);
|
|
3354
|
+
if (C && C.length) {
|
|
3355
|
+
const W = C.filter(ii).reduce((z, x) => {
|
|
3356
|
+
const I = {
|
|
3357
|
+
...t,
|
|
3358
|
+
$inputs: {
|
|
3359
|
+
...t.$inputs || {},
|
|
3360
|
+
...e ? t.$workflows[e]?.inputs || {} : {}
|
|
3361
|
+
}
|
|
3362
|
+
};
|
|
3363
|
+
return z[x.name] = fe({
|
|
3364
|
+
value: x.value,
|
|
3365
|
+
ctx: I,
|
|
3366
|
+
logger: t.options.logger
|
|
3367
|
+
}), z;
|
|
3368
|
+
}, {});
|
|
3369
|
+
A.$workflows[b.workflowId].inputs = {
|
|
3370
|
+
...A.$workflows[b.workflowId].inputs,
|
|
3371
|
+
...W
|
|
3372
|
+
};
|
|
3373
|
+
}
|
|
3374
|
+
Ho(f, t.options.logger);
|
|
3375
|
+
const K = await Ue({
|
|
3376
|
+
workflowInput: b,
|
|
3377
|
+
ctx: A,
|
|
3378
|
+
skipLineSeparator: !0,
|
|
3379
|
+
parentStepId: f,
|
|
3380
|
+
invocationContext: `Child workflow of step ${f}`,
|
|
3381
|
+
executedStepsCount: a
|
|
3382
|
+
});
|
|
3383
|
+
t.executedSteps.push(K);
|
|
3384
|
+
const _ = {};
|
|
3385
|
+
if (r?.outputs) {
|
|
3386
|
+
try {
|
|
3387
|
+
for (const [W, z] of Object.entries(r.outputs))
|
|
3388
|
+
_[W] = oe({
|
|
3389
|
+
payload: z,
|
|
3390
|
+
context: {
|
|
3391
|
+
$outputs: A.$outputs?.[b.workflowId] || {}
|
|
3392
|
+
},
|
|
3393
|
+
logger: t.options.logger
|
|
3394
|
+
});
|
|
3395
|
+
} catch (W) {
|
|
3396
|
+
const z = {
|
|
3397
|
+
name: V.UNEXPECTED_ERROR,
|
|
3398
|
+
message: W.message,
|
|
3399
|
+
passed: !1,
|
|
3400
|
+
severity: t.severity.UNEXPECTED_ERROR
|
|
3401
|
+
};
|
|
3402
|
+
r.checks.push(z);
|
|
3403
|
+
}
|
|
3404
|
+
t.$steps[f] = {
|
|
3405
|
+
outputs: _
|
|
3406
|
+
}, c?.workflowId && (t.$workflows[c.workflowId].steps[f] = {
|
|
3407
|
+
outputs: _,
|
|
3408
|
+
request: void 0,
|
|
3409
|
+
response: void 0
|
|
3410
|
+
});
|
|
3411
|
+
}
|
|
3412
|
+
return { shouldEnd: !1 };
|
|
3413
|
+
}
|
|
3414
|
+
if (t.executedSteps.push(r), a.value++, a.value > t.options.maxSteps)
|
|
3415
|
+
return r.checks.push({
|
|
3416
|
+
name: V.MAX_STEPS_REACHED_ERROR,
|
|
3417
|
+
message: `Max steps (${t.options.maxSteps}) reached`,
|
|
3418
|
+
passed: !1,
|
|
3419
|
+
severity: t.severity.MAX_STEPS_REACHED_ERROR
|
|
3420
|
+
}), { shouldEnd: !0 };
|
|
3421
|
+
if (t.options.executionTimeout && ce.getInstance(t.options.executionTimeout).isTimedOut())
|
|
3422
|
+
return r.checks.push({
|
|
3423
|
+
name: V.GLOBAL_TIMEOUT_ERROR,
|
|
3424
|
+
message: "Global Respect timer reached",
|
|
3425
|
+
passed: !1,
|
|
3426
|
+
severity: t.severity.GLOBAL_TIMEOUT_ERROR
|
|
3427
|
+
}), { shouldEnd: !0 };
|
|
3428
|
+
if (C && C.length) {
|
|
3429
|
+
const b = C.find((A) => !("in" in We(A, t)));
|
|
3430
|
+
if (b)
|
|
3431
|
+
throw new Error(`Parameter "in" is required for ${f} step parameter ${b.name}`);
|
|
3432
|
+
}
|
|
3433
|
+
let j = !1, T;
|
|
3434
|
+
try {
|
|
3435
|
+
if (!e)
|
|
3436
|
+
throw new Error("Workflow name is required to run a step");
|
|
3437
|
+
T = await oc(t, r, e);
|
|
3438
|
+
const b = await Ha({
|
|
3439
|
+
ctx: t,
|
|
3440
|
+
workflowId: e,
|
|
3441
|
+
step: r,
|
|
3442
|
+
requestData: T
|
|
3443
|
+
});
|
|
3444
|
+
j = Object.values(b).every((A) => A);
|
|
3445
|
+
} catch (b) {
|
|
3446
|
+
r.verboseLog = t.apiClient.getVerboseResponseLogs();
|
|
3447
|
+
const A = {
|
|
3448
|
+
name: V.UNEXPECTED_ERROR,
|
|
3449
|
+
message: b.message,
|
|
3450
|
+
passed: !1,
|
|
3451
|
+
severity: t.severity.UNEXPECTED_ERROR
|
|
3452
|
+
};
|
|
3453
|
+
r.checks.push(A);
|
|
3454
|
+
}
|
|
3455
|
+
const N = t.options.verbose ? t.apiClient.getVerboseLogs() : void 0, P = t.options.verbose ? t.apiClient.getVerboseResponseLogs() : void 0, L = T?.path || T?.serverUrl?.url;
|
|
3456
|
+
if (L ? Jo({
|
|
3457
|
+
testNameToDisplay: `${T?.method.toUpperCase()} ${Nt(L)}${r.stepId ? ` ${Re("- step")} ${Nt(ur(r.stepId))}` : ""}`,
|
|
3458
|
+
checks: r.checks,
|
|
3459
|
+
verboseLogs: N,
|
|
3460
|
+
verboseResponseLogs: P,
|
|
3461
|
+
logger: t.options.logger
|
|
3462
|
+
}) : Xo(r, t.options.logger), !j) {
|
|
3463
|
+
const b = await D(k, "failure", a);
|
|
3464
|
+
if (b?.retriesLeft && b.retriesLeft > 0)
|
|
3465
|
+
return b.stepResult;
|
|
3466
|
+
if (b?.shouldEnd)
|
|
3467
|
+
return { shouldEnd: !0 };
|
|
3468
|
+
}
|
|
3469
|
+
if (y.length && j && (await D(y, "success", a))?.shouldEnd)
|
|
3470
|
+
return { shouldEnd: !0 };
|
|
3471
|
+
async function D(b = [], A, K) {
|
|
3472
|
+
for (const _ of b) {
|
|
3473
|
+
const { type: W, criteria: z } = _;
|
|
3474
|
+
if (_.workflowId && _.stepId)
|
|
3475
|
+
throw new Error(`Cannot use both workflowId: ${_.workflowId} and stepId: ${_.stepId} in ${_.type} action`);
|
|
3476
|
+
if (Is({
|
|
3477
|
+
workflowId: e,
|
|
3478
|
+
step: r,
|
|
3479
|
+
criteria: z,
|
|
3480
|
+
ctx: t
|
|
3481
|
+
}).every((I) => I.passed)) {
|
|
3482
|
+
const I = _.workflowId ? fe({ value: _.workflowId, ctx: t, logger: t.options.logger }) : void 0, B = _.workflowId ? await xr(_.workflowId, I, t, t.options.config) : { ...t, executedSteps: [] }, H = _.stepId ? _.stepId : void 0;
|
|
3483
|
+
if (W === "retry") {
|
|
3484
|
+
const { retryAfter: ee, retryLimit: he = 0 } = _;
|
|
3485
|
+
if (n = n ?? he, r.retriesLeft = n, n === 0)
|
|
3486
|
+
return { retriesLeft: 0, shouldEnd: !1 };
|
|
3487
|
+
if (ee && await Ja(ee), (I || H) && Lt({
|
|
3488
|
+
stepId: f,
|
|
3489
|
+
actionName: _.name,
|
|
3490
|
+
kind: A,
|
|
3491
|
+
logger: t.options.logger
|
|
3492
|
+
}), I) {
|
|
3493
|
+
const ne = await Ue({
|
|
3494
|
+
workflowInput: I,
|
|
3495
|
+
ctx: B,
|
|
3496
|
+
skipLineSeparator: !0,
|
|
3497
|
+
invocationContext: `Retry action for step ${f}`,
|
|
3498
|
+
executedStepsCount: K
|
|
3499
|
+
});
|
|
3500
|
+
t.executedSteps.push(ne);
|
|
3501
|
+
} else if (H) {
|
|
3502
|
+
const ne = c?.steps.find((re) => re.stepId === H);
|
|
3503
|
+
if (!ne)
|
|
3504
|
+
throw new Error(`Step ${H} not found in workflow ${e}`);
|
|
3505
|
+
await Br({
|
|
3506
|
+
step: ne,
|
|
3507
|
+
ctx: B,
|
|
3508
|
+
workflowId: e,
|
|
3509
|
+
executedStepsCount: K
|
|
3510
|
+
});
|
|
3511
|
+
}
|
|
3512
|
+
return t.options.logger.output(`
|
|
3513
|
+
Retrying step ${Re(f)} (${he - n + 1}/${he})
|
|
3514
|
+
`), {
|
|
3515
|
+
stepResult: await Br({
|
|
3516
|
+
step: r,
|
|
3517
|
+
ctx: t,
|
|
3518
|
+
workflowId: e,
|
|
3519
|
+
retriesLeft: n - 1,
|
|
3520
|
+
executedStepsCount: K
|
|
3521
|
+
}),
|
|
3522
|
+
retriesLeft: n
|
|
3523
|
+
};
|
|
3524
|
+
} else {
|
|
3525
|
+
if (W === "end")
|
|
3526
|
+
return { shouldEnd: !0 };
|
|
3527
|
+
if (W === "goto") {
|
|
3528
|
+
if (!I && !H)
|
|
3529
|
+
throw new Error("Either workflowId or stepId must be provided in goto action");
|
|
3530
|
+
(I || H) && Lt({
|
|
3531
|
+
stepId: f,
|
|
3532
|
+
actionName: _.name,
|
|
3533
|
+
kind: A,
|
|
3534
|
+
logger: t.options.logger
|
|
3535
|
+
});
|
|
3536
|
+
const ee = await Ue({
|
|
3537
|
+
workflowInput: I || c,
|
|
3538
|
+
ctx: B,
|
|
3539
|
+
fromStepId: H,
|
|
3540
|
+
skipLineSeparator: !0,
|
|
3541
|
+
invocationContext: `Goto from step ${f}`,
|
|
3542
|
+
executedStepsCount: K
|
|
3543
|
+
});
|
|
3544
|
+
return t.executedSteps.push(ee), { shouldEnd: !0 };
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
break;
|
|
3548
|
+
}
|
|
3549
|
+
}
|
|
3550
|
+
if (A === "failure")
|
|
3551
|
+
return { shouldEnd: !0 };
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
function ar(r) {
|
|
3555
|
+
if (r) {
|
|
3556
|
+
if (typeof r == "string")
|
|
3557
|
+
return r.includes(",") ? r.split(",").map((t) => t.trim()) : [r];
|
|
3558
|
+
if (Array.isArray(r)) {
|
|
3559
|
+
const t = [];
|
|
3560
|
+
for (const e of r)
|
|
3561
|
+
e.includes(",") ? t.push(...e.split(",").map((n) => n.trim())) : t.push(e);
|
|
3562
|
+
return t;
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
}
|
|
3566
|
+
async function ac({ options: r, collectSpecData: t, executedStepsCount: e }) {
|
|
3567
|
+
const n = {
|
|
3568
|
+
...r,
|
|
3569
|
+
filePath: r.file,
|
|
3570
|
+
metadata: { ...r }
|
|
3571
|
+
}, a = await ps({
|
|
3572
|
+
filePath: r.file,
|
|
3573
|
+
collectSpecData: t,
|
|
3574
|
+
version: r?.version,
|
|
3575
|
+
logger: r.logger,
|
|
3576
|
+
externalRefResolver: r?.externalRefResolver,
|
|
3577
|
+
skipLint: r?.skipLint
|
|
3578
|
+
});
|
|
3579
|
+
return await cc({
|
|
3580
|
+
testDescription: a,
|
|
3581
|
+
options: n,
|
|
3582
|
+
executedStepsCount: e
|
|
3583
|
+
});
|
|
3584
|
+
}
|
|
3585
|
+
async function cc({ testDescription: r, options: t, executedStepsCount: e }) {
|
|
3586
|
+
const n = new Ji({
|
|
3587
|
+
fetch: t.fetch
|
|
3588
|
+
}), a = await hs(r, t, n), c = ar(t.workflow), f = ar(t.skip), l = ra({
|
|
3589
|
+
workflows: a.workflows,
|
|
3590
|
+
workflowsToRun: c,
|
|
3591
|
+
workflowsToSkip: f,
|
|
3592
|
+
logger: a.options.logger
|
|
3593
|
+
}), h = [];
|
|
3594
|
+
for (const d of l) {
|
|
3595
|
+
a.executedSteps = [], d.dependsOn?.length && await fc({ workflow: d, ctx: a, config: t.config, executedStepsCount: e });
|
|
3596
|
+
const g = await Ue({
|
|
3597
|
+
workflowInput: d.workflowId,
|
|
3598
|
+
ctx: a,
|
|
3599
|
+
executedStepsCount: e
|
|
3600
|
+
});
|
|
3601
|
+
h.push(g);
|
|
3602
|
+
}
|
|
3603
|
+
return { ctx: a, executedWorkflows: h };
|
|
3604
|
+
}
|
|
3605
|
+
async function Ue({ workflowInput: r, ctx: t, fromStepId: e, skipLineSeparator: n, parentStepId: a, invocationContext: c, executedStepsCount: f }) {
|
|
3606
|
+
const { logger: l } = t.options, h = performance.now(), d = Y.basename(t.options.filePath), g = typeof r == "string" ? t.workflows.find((P) => P.workflowId === r) : r;
|
|
3607
|
+
if (!g)
|
|
3608
|
+
throw new Error(`
|
|
3609
|
+
${Re("Workflow")} ${r} ${Re("not found")}
|
|
3610
|
+
`);
|
|
3611
|
+
const k = g.inputs;
|
|
3612
|
+
if (k) {
|
|
3613
|
+
const P = t.$workflows[g.workflowId].inputs;
|
|
3614
|
+
t.$workflows[g.workflowId].inputs = ds({
|
|
3615
|
+
inputs: P,
|
|
3616
|
+
workflowInputSchema: k,
|
|
3617
|
+
env: t.options.envVariables
|
|
3618
|
+
});
|
|
3619
|
+
}
|
|
3620
|
+
const y = g.workflowId;
|
|
3621
|
+
e || Go({
|
|
3622
|
+
fileName: d,
|
|
3623
|
+
workflowName: y,
|
|
3624
|
+
skipLineSeparator: n,
|
|
3625
|
+
logger: l
|
|
3626
|
+
});
|
|
3627
|
+
const C = e ? g.steps.findIndex((P) => P.stepId === e) : 0, j = g.steps.slice(C);
|
|
3628
|
+
t.$steps = {};
|
|
3629
|
+
for (const P of j)
|
|
3630
|
+
try {
|
|
3631
|
+
if ((await Br({
|
|
3632
|
+
step: P,
|
|
3633
|
+
ctx: t,
|
|
3634
|
+
workflowId: y,
|
|
3635
|
+
executedStepsCount: f
|
|
3636
|
+
}))?.shouldEnd)
|
|
3637
|
+
break;
|
|
3638
|
+
} catch (L) {
|
|
3639
|
+
const D = {
|
|
3640
|
+
name: V.UNEXPECTED_ERROR,
|
|
3641
|
+
message: L.message,
|
|
3642
|
+
passed: !1,
|
|
3643
|
+
severity: t.severity.UNEXPECTED_ERROR
|
|
3644
|
+
};
|
|
3645
|
+
P.checks.push(D), t.executedSteps.push(P);
|
|
3646
|
+
}
|
|
3647
|
+
const T = g.steps.some((P) => P.checks?.some((L) => !L.passed && L.name == V.GLOBAL_TIMEOUT_ERROR));
|
|
3648
|
+
if (g.outputs && y && !T) {
|
|
3649
|
+
t.$outputs || (t.$outputs = {}), t.$outputs[y] || (t.$outputs[y] = {});
|
|
3650
|
+
const P = lr({
|
|
3651
|
+
ctx: {
|
|
3652
|
+
...t,
|
|
3653
|
+
$inputs: {
|
|
3654
|
+
...t.$inputs || {},
|
|
3655
|
+
...t.$workflows[y]?.inputs || {}
|
|
3656
|
+
}
|
|
3657
|
+
},
|
|
3658
|
+
workflowId: y
|
|
3659
|
+
}), L = {};
|
|
3660
|
+
for (const D of Object.keys(g.outputs))
|
|
3661
|
+
try {
|
|
3662
|
+
L[D] = oe({
|
|
3663
|
+
payload: g.outputs[D],
|
|
3664
|
+
context: P,
|
|
3665
|
+
logger: t.options.logger
|
|
3666
|
+
});
|
|
3667
|
+
} catch (b) {
|
|
3668
|
+
throw new Error(`Failed to resolve output "${D}" in workflow "${y}": ${b.message}`);
|
|
3669
|
+
}
|
|
3670
|
+
t.$outputs[y] = L, t.$workflows[y].outputs = L;
|
|
3671
|
+
}
|
|
3672
|
+
g.time = Math.ceil(performance.now() - h), l.printNewLine();
|
|
3673
|
+
const N = performance.now();
|
|
3674
|
+
return {
|
|
3675
|
+
type: "workflow",
|
|
3676
|
+
invocationContext: c,
|
|
3677
|
+
workflowId: y,
|
|
3678
|
+
stepId: a,
|
|
3679
|
+
startTime: h,
|
|
3680
|
+
endTime: N,
|
|
3681
|
+
totalTimeMs: pc(t.executedSteps),
|
|
3682
|
+
executedSteps: t.executedSteps,
|
|
3683
|
+
ctx: t,
|
|
3684
|
+
globalTimeoutError: T
|
|
3685
|
+
};
|
|
3686
|
+
}
|
|
3687
|
+
async function fc({ workflow: r, ctx: t, config: e, executedStepsCount: n }) {
|
|
3688
|
+
if (!r.dependsOn?.length)
|
|
3689
|
+
return;
|
|
3690
|
+
const a = await Promise.all(r.dependsOn.map(async (l) => {
|
|
3691
|
+
const h = fe({
|
|
3692
|
+
value: l,
|
|
3693
|
+
ctx: t,
|
|
3694
|
+
logger: t.options.logger
|
|
3695
|
+
}), d = await xr(l, h, t, e);
|
|
3696
|
+
return Qo(r.workflowId, t.options.logger), Ue({
|
|
3697
|
+
workflowInput: h,
|
|
3698
|
+
ctx: d,
|
|
3699
|
+
skipLineSeparator: !0,
|
|
3700
|
+
executedStepsCount: n
|
|
3701
|
+
});
|
|
3702
|
+
}));
|
|
3703
|
+
if (Vr(a).steps.failed > 0)
|
|
3704
|
+
throw new Error("Dependent workflows has failed steps");
|
|
3705
|
+
}
|
|
3706
|
+
async function xr(r, t, e, n) {
|
|
3707
|
+
const a = r && r.startsWith("$sourceDescriptions.") && r.split(".")[1], c = a && e.$sourceDescriptions[a];
|
|
3708
|
+
return c ? await hs(c, {
|
|
3709
|
+
...e.options,
|
|
3710
|
+
filePath: uc(a, e.sourceDescriptions, e.options),
|
|
3711
|
+
workflow: [t.workflowId],
|
|
3712
|
+
skip: void 0,
|
|
3713
|
+
config: n
|
|
3714
|
+
}, e.apiClient) : {
|
|
3715
|
+
...e,
|
|
3716
|
+
executedSteps: []
|
|
3717
|
+
};
|
|
3718
|
+
}
|
|
3719
|
+
function uc(r, t, e) {
|
|
3720
|
+
const n = t && t.find(({ name: a }) => a === r);
|
|
3721
|
+
if (n) {
|
|
3722
|
+
if (n.type === "openapi")
|
|
3723
|
+
return n.url;
|
|
3724
|
+
if (n.type === "arazzo")
|
|
3725
|
+
return Y.resolve(Y.dirname(e.filePath), n.url);
|
|
3726
|
+
throw new Error(`Unknown source description type ${n.type}`);
|
|
3727
|
+
} else return "";
|
|
3728
|
+
}
|
|
3729
|
+
function lc(r) {
|
|
3730
|
+
return "type" in r && r.type === "workflow";
|
|
3731
|
+
}
|
|
3732
|
+
function pc(r) {
|
|
3733
|
+
let t = 0;
|
|
3734
|
+
for (const e of r)
|
|
3735
|
+
lc(e) ? t += e.totalTimeMs : t += e.response?.time || 0;
|
|
3736
|
+
return t;
|
|
3737
|
+
}
|
|
3738
|
+
async function gc(r) {
|
|
3739
|
+
const t = { value: 0 }, { files: e, executionTimeout: n, collectSpecData: a } = r;
|
|
3740
|
+
n && (ce.reset(), ce.getInstance(n));
|
|
3741
|
+
const c = [], f = [];
|
|
3742
|
+
for (const l of e) {
|
|
3743
|
+
const h = await dc({
|
|
3744
|
+
options: { ...r, file: l },
|
|
3745
|
+
startedAt: performance.now(),
|
|
3746
|
+
collectSpecData: a,
|
|
3747
|
+
executedStepsCount: t
|
|
3748
|
+
});
|
|
3749
|
+
c.push(h.hasProblems), f.push(h);
|
|
3750
|
+
}
|
|
3751
|
+
return f;
|
|
3752
|
+
}
|
|
3753
|
+
async function dc({ options: r, startedAt: t, executedStepsCount: e, collectSpecData: n }) {
|
|
3754
|
+
const a = await ac({ options: r, collectSpecData: n, executedStepsCount: e }), { executedWorkflows: c, ctx: f } = a, l = Vr(c), h = l.workflows.failed > 0, d = l.workflows.warnings > 0, g = c.some((k) => k.globalTimeoutError);
|
|
3755
|
+
return (l.steps.failed > 0 || l.steps.warnings > 0 || l.steps.skipped > 0) && qi(c, r.logger), Li({ startedAt: t, workflows: c, options: r }), {
|
|
3756
|
+
hasProblems: h,
|
|
3757
|
+
hasWarnings: d,
|
|
3758
|
+
file: r.file,
|
|
3759
|
+
executedWorkflows: c,
|
|
3760
|
+
options: r,
|
|
3761
|
+
ctx: f,
|
|
3762
|
+
totalTimeMs: performance.now() - t,
|
|
3763
|
+
totalRequests: l.totalRequests,
|
|
3764
|
+
globalTimeoutError: g,
|
|
3765
|
+
...f.noSecretsMasking && { secretValues: Array.from(f.secretsSet) || [] }
|
|
3766
|
+
};
|
|
3767
|
+
}
|
|
3768
|
+
export {
|
|
3769
|
+
Ze as RESET_ESCAPE_CODE,
|
|
3770
|
+
Vr as calculateTotals,
|
|
3771
|
+
ge as conditionallyMaskSecrets,
|
|
3772
|
+
zi as maskSecrets,
|
|
3773
|
+
_o as parseRuntimeExpression,
|
|
3774
|
+
gc as run
|
|
3775
|
+
};
|