@redocly/replay 0.31.0-next.4 → 0.31.0-next.5

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.
Files changed (31) hide show
  1. package/dist/{replay-AiChatProvider-DmFb_KEh.js → replay-AiChatProvider-DF95dPI4.js} +6 -6
  2. package/dist/{replay-AiChatSqliteDBStorage-DPCC1JxA.js → replay-AiChatSqliteDBStorage-DFai0iTB.js} +1 -1
  3. package/dist/{replay-AiPanel-Duce6bPI.js → replay-AiPanel-DWJrryHB.js} +26 -31
  4. package/dist/{replay-FileWatcher-CuDTvKR_.js → replay-FileWatcher-DhpdT_VS.js} +2 -2
  5. package/dist/{replay-SemanticSearchService-UD-ISya0.js → replay-SemanticSearchService-C9AkUyVE.js} +1 -1
  6. package/dist/{replay-SqliteDBStorage-yz16M_Mv.js → replay-SqliteDBStorage-DT9_LMLs.js} +1 -1
  7. package/dist/{replay-TauriFileSystemAdapter-D6ELx87H.js → replay-TauriFileSystemAdapter-C16TSOZg.js} +1 -1
  8. package/dist/{replay-TauriRootStorage-BBtrm1uU.js → replay-TauriRootStorage-BNacv6Qu.js} +2 -2
  9. package/dist/{replay-agent-loop-X-3QP3_I.js → replay-agent-loop-Om_DXb5S.js} +3 -3
  10. package/dist/{replay-ai-chat-mappers-Cn5M5bfQ.js → replay-ai-chat-mappers-T6Rn74yZ.js} +1 -1
  11. package/dist/{replay-create-model-I01u52en.js → replay-create-model-CWTiZi7t.js} +16108 -17055
  12. package/dist/{replay-db-_AqPojpS.js → replay-db-DGrxiWzT.js} +1 -1
  13. package/dist/{replay-external-resolver-B9jDVIjA.js → replay-external-resolver-1QWjOOVR.js} +2 -2
  14. package/dist/{replay-index-vq6dCDYU.js → replay-index-BZZ4OP90.js} +1 -1
  15. package/dist/replay-index-CEqxKoBH.js +4 -0
  16. package/dist/{replay-index-NeiVLZKP.js → replay-index-CTTaOYRK.js} +1 -1
  17. package/dist/{replay-index-Bd6nBD-g.js → replay-index-CiOV_Ucc.js} +23401 -22849
  18. package/dist/{replay-index-5x470UiG.js → replay-index-DF2XA7Wl.js} +1 -1
  19. package/dist/replay-index-DVf85Dg1.js +917 -0
  20. package/dist/{replay-lint-Bag9E2VE.js → replay-lint-B6TsU9Uq.js} +6569 -5787
  21. package/dist/{replay-lint-graphql-Dy_zzWSu.js → replay-lint-graphql-CmPzfY7b.js} +2 -2
  22. package/dist/{replay-periodic-revalidation-ZF9THDF0.js → replay-periodic-revalidation-B77h_-F6.js} +1 -1
  23. package/dist/{replay-resolve-C-3GwDKX.js → replay-resolve-9K6-oXdr.js} +886 -866
  24. package/dist/{replay-respect-run-CGAeb4ct.js → replay-respect-run-Cpt4Fgtq.js} +123 -123
  25. package/dist/{replay-tauri-path-JPWbAoK0.js → replay-tauri-path-wnkmhbG_.js} +2 -2
  26. package/dist/{replay-useAiChatQueries-B8RKvZ6W.js → replay-useAiChatQueries-CTLNVgPv.js} +83 -81
  27. package/dist/{replay-validate-key-BA81wxhp.js → replay-validate-key-C5YTZaNy.js} +2 -2
  28. package/dist/replay.js +1 -1
  29. package/package.json +6 -6
  30. package/dist/replay-index-BW65Uxno.js +0 -4
  31. package/dist/replay-index-CryjpI5N.js +0 -576
@@ -0,0 +1,917 @@
1
+ import { a6 as j, a7 as y } from "./replay-index-CiOV_Ucc.js";
2
+ import { a as X, g as F, d as Q, o as Z, A as pe, S as ue, N as ee, n as N, w as I, t as de, b as ye, c as V, l as te, e as P, f as me, p as S, v as ne, k as he, h as ge, j as ve, m as E, q as O, r as se, s as be, u as D, x as M, y as x, H as Ee, z as Se, B as Oe, i as Te } from "./replay-lint-B6TsU9Uq.js";
3
+ import { C as yt, D as mt, E as ht, F as gt, G as vt, I as bt, J as Et, K as St, L as Ot, M as Tt, O as Rt, P as xt, Q as kt, R as wt, T as Nt, U as It, V as Pt, W as Dt, X as _t, Y as Ct, Z as jt, _ as Ft, $ as Vt, a0 as Mt, a1 as $t, a2 as Lt, a3 as zt, a4 as Bt, a5 as qt, a6 as Gt, a7 as Kt, a8 as Ut, a9 as At, aa as Yt, ab as Ht, ac as Wt, ad as Jt, ae as Xt, af as Qt, ag as Zt, ah as en, ai as tn, aj as nn, ak as sn, al as rn, am as on, an, ao as cn, ap as fn, ae as ln, aq as pn } from "./replay-lint-B6TsU9Uq.js";
4
+ import { i as Re, B as T, n as re, a as k, m as oe } from "./replay-resolve-9K6-oXdr.js";
5
+ import { L as dn, R as yn, S as mn, Y as hn, e as gn, g as vn, b as bn, c as En, d as Sn, f as On, h as Tn, j as Rn, p as xn, k as kn, r as wn, l as Nn, s as In, u as Pn } from "./replay-resolve-9K6-oXdr.js";
6
+ function st(e) {
7
+ return (j.extname(e) === ".yaml" || j.extname(e) === ".yml") && !1;
8
+ }
9
+ function rt(e) {
10
+ return y(e) && !X(e);
11
+ }
12
+ async function ot(e) {
13
+ return new Promise((t) => setTimeout(t, e));
14
+ }
15
+ function it(e) {
16
+ return e.charAt(0).toUpperCase() + e.slice(1);
17
+ }
18
+ const _ = "type", $ = ["api-description", "api-operation", "data-schema"];
19
+ function xe(e, t) {
20
+ const { ctx: n } = F("EntityFileDefault", t), { ctx: s, discriminatorResolver: r } = F("EntityFile", e);
21
+ return {
22
+ entityTypes: {
23
+ ...n,
24
+ ...s,
25
+ EntityFileArray: {
26
+ properties: {},
27
+ items: (a) => {
28
+ if (y(a)) {
29
+ const i = a[_];
30
+ if (!i)
31
+ return "Entity";
32
+ const c = r?.(a, i);
33
+ if (c && typeof c == "string")
34
+ return c;
35
+ }
36
+ return "Entity";
37
+ }
38
+ }
39
+ },
40
+ discriminatorResolver: r
41
+ };
42
+ }
43
+ function h(e, t) {
44
+ if (Re(t.parent))
45
+ return;
46
+ const n = t.key.toString(), s = e.counts ??= {};
47
+ s[n] = (s[n] ?? 0) + 1;
48
+ }
49
+ function C(e) {
50
+ for (const r of Object.values(e))
51
+ r.items && (r.total = r.items.size);
52
+ const { xExtensions: t } = e, n = t.counts ?? {}, s = Object.keys(n).sort();
53
+ t.total = s.length, t.counts = Object.fromEntries(s.map((r) => [r, n[r]]));
54
+ }
55
+ const at = (e) => ({
56
+ SpecExtension: {
57
+ enter(t, n) {
58
+ h(e.xExtensions, n);
59
+ }
60
+ },
61
+ XCodeSampleList: {
62
+ enter(t, n) {
63
+ h(e.xExtensions, n);
64
+ }
65
+ },
66
+ ExamplesMap: {
67
+ enter(t, n) {
68
+ n.key.toString() === "x-examples" && h(e.xExtensions, n);
69
+ }
70
+ },
71
+ EnumDescriptions: {
72
+ enter(t, n) {
73
+ h(e.xExtensions, n);
74
+ }
75
+ },
76
+ TagGroups: {
77
+ enter(t, n) {
78
+ h(e.xExtensions, n);
79
+ }
80
+ },
81
+ Logo: {
82
+ enter(t, n) {
83
+ h(e.xExtensions, n);
84
+ }
85
+ },
86
+ XServerList: {
87
+ enter(t, n) {
88
+ h(e.xExtensions, n);
89
+ }
90
+ },
91
+ XUsePkce: {
92
+ enter(t, n) {
93
+ h(e.xExtensions, n);
94
+ }
95
+ },
96
+ Operation: {
97
+ enter(t, n) {
98
+ n.key.toString() === "x-query" && h(e.xExtensions, n);
99
+ }
100
+ },
101
+ ExternalDocs: {
102
+ leave() {
103
+ e.externalDocs.total++;
104
+ }
105
+ },
106
+ ref: {
107
+ enter(t) {
108
+ e.refs.items.add(t.$ref);
109
+ }
110
+ },
111
+ Tag: {
112
+ leave(t) {
113
+ e.tags.items.add(t.name);
114
+ }
115
+ },
116
+ Link: {
117
+ leave(t) {
118
+ e.links.items.add(t.operationId);
119
+ }
120
+ },
121
+ WebhooksMap: {
122
+ enter(t, n) {
123
+ n.key.toString() === "x-webhooks" && h(e.xExtensions, n);
124
+ },
125
+ Operation: {
126
+ leave(t) {
127
+ if (e.webhooks.total++, t.tags)
128
+ for (const n of t.tags)
129
+ e.tags.items.add(n);
130
+ }
131
+ }
132
+ },
133
+ Paths: {
134
+ PathItem: {
135
+ leave() {
136
+ e.pathItems.total++;
137
+ },
138
+ Operation: {
139
+ leave(t) {
140
+ if (e.operations.total++, t.tags)
141
+ for (const n of t.tags)
142
+ e.tags.items.add(n);
143
+ }
144
+ },
145
+ Parameter: {
146
+ leave(t) {
147
+ e.parameters.items.add(t.name);
148
+ }
149
+ }
150
+ }
151
+ },
152
+ NamedSchemas: {
153
+ Schema: {
154
+ leave() {
155
+ e.schemas.total++;
156
+ }
157
+ }
158
+ },
159
+ Root: {
160
+ leave() {
161
+ C(e);
162
+ }
163
+ }
164
+ }), ct = (e) => ({
165
+ SpecExtension: {
166
+ enter(t, n) {
167
+ h(e.xExtensions, n);
168
+ }
169
+ },
170
+ ExternalDocs: {
171
+ leave() {
172
+ e.externalDocs.total++;
173
+ }
174
+ },
175
+ ref: {
176
+ enter(t) {
177
+ e.refs.items.add(t.$ref);
178
+ }
179
+ },
180
+ Tag: {
181
+ leave(t) {
182
+ e.tags.items.add(t.name);
183
+ }
184
+ },
185
+ ChannelMap: {
186
+ Channel: {
187
+ leave() {
188
+ e.channels.total++;
189
+ },
190
+ Operation: {
191
+ leave(t) {
192
+ if (e.operations.total++, t.tags)
193
+ for (const n of t.tags)
194
+ e.tags.items.add(n);
195
+ }
196
+ },
197
+ Parameter: {
198
+ leave(t, { key: n }) {
199
+ e.parameters.items.add(n.toString());
200
+ }
201
+ }
202
+ }
203
+ },
204
+ NamedSchemas: {
205
+ Schema: {
206
+ leave() {
207
+ e.schemas.total++;
208
+ }
209
+ }
210
+ },
211
+ Root: {
212
+ leave() {
213
+ C(e);
214
+ }
215
+ }
216
+ }), ft = (e) => ({
217
+ SpecExtension: {
218
+ enter(t, n) {
219
+ h(e.xExtensions, n);
220
+ }
221
+ },
222
+ ExternalDocs: {
223
+ leave() {
224
+ e.externalDocs.total++;
225
+ }
226
+ },
227
+ ref: {
228
+ enter(t) {
229
+ e.refs.items.add(t.$ref);
230
+ }
231
+ },
232
+ Tag: {
233
+ leave(t) {
234
+ e.tags.items.add(t.name);
235
+ }
236
+ },
237
+ NamedChannels: {
238
+ Channel: {
239
+ leave() {
240
+ e.channels.total++;
241
+ },
242
+ Parameter: {
243
+ leave(t, { key: n }) {
244
+ e.parameters.items.add(n.toString());
245
+ }
246
+ }
247
+ }
248
+ },
249
+ NamedOperations: {
250
+ Operation: {
251
+ leave(t) {
252
+ if (e.operations.total++, t.tags)
253
+ for (const n of t.tags)
254
+ e.tags.items.add(n);
255
+ }
256
+ }
257
+ },
258
+ NamedSchemas: {
259
+ Schema: {
260
+ leave() {
261
+ e.schemas.total++;
262
+ }
263
+ }
264
+ },
265
+ Root: {
266
+ leave() {
267
+ C(e);
268
+ }
269
+ }
270
+ }), ke = /^[a-z0-9]+(?:-[a-z0-9]+)*$/, L = 2, z = 150, we = () => ({
271
+ any(e, { report: t, location: n }) {
272
+ if (y(e) && "key" in e) {
273
+ const s = e.key;
274
+ if (typeof s != "string") {
275
+ t({
276
+ message: "Entity `key` must be a string.",
277
+ location: n.child(["key"])
278
+ });
279
+ return;
280
+ }
281
+ s.length < L && t({
282
+ message: `Entity 'key' must be at least ${L} characters long.`,
283
+ location: n.child(["key"])
284
+ }), s.length > z && t({
285
+ message: `Entity 'key' must not exceed ${z} characters.`,
286
+ location: n.child(["key"])
287
+ }), ke.test(s) || t({
288
+ message: "Entity `key` must contain only lowercase letters, numbers, and hyphens, and cannot start or end with a hyphen.",
289
+ location: n.child(["key"])
290
+ });
291
+ }
292
+ }
293
+ });
294
+ function B(e, t) {
295
+ const s = t.split("-").map((r) => r.charAt(0).toUpperCase() + r.slice(1)).join("") + e;
296
+ return Object.values(Z).includes(s) ? s : e;
297
+ }
298
+ function Ne(e, t) {
299
+ const n = {};
300
+ for (const [s, r] of Object.entries(t))
301
+ if (ie(s, r)) {
302
+ if (r.severity === "off")
303
+ continue;
304
+ n[s] = {
305
+ ..._e(e, s, r)
306
+ };
307
+ } else
308
+ n[s] = r;
309
+ return n;
310
+ }
311
+ function Ie(e) {
312
+ const t = {}, n = {};
313
+ for (const [s, r] of Object.entries(e))
314
+ if (ie(s, r)) {
315
+ const o = r;
316
+ De(o) ? t[s] = o : n[s] = o;
317
+ } else
318
+ n[s] = r;
319
+ return { entityRules: t, apiRules: n };
320
+ }
321
+ function Pe(e, t, n) {
322
+ if (!y(n.parsed) || !y(n.parsed.components))
323
+ return null;
324
+ const s = n.parsed.components, r = "schemas" in s ? s.schemas : void 0;
325
+ if (!r || !(e in r))
326
+ return null;
327
+ const o = r[e];
328
+ try {
329
+ const a = JSON.parse(t);
330
+ if (Q(o, a))
331
+ return o;
332
+ } catch {
333
+ return null;
334
+ }
335
+ return null;
336
+ }
337
+ function ie(e, t) {
338
+ return e.startsWith("rule/") && y(t);
339
+ }
340
+ function De(e) {
341
+ return Object.values(Z).some((t) => e.subject.type === t);
342
+ }
343
+ function _e(e, t, n) {
344
+ const s = B(n.subject.type, e), r = n.where?.map((o) => ({
345
+ ...o,
346
+ subject: {
347
+ ...o.subject,
348
+ type: B(o.subject.type, e)
349
+ }
350
+ }));
351
+ return {
352
+ assertionId: t,
353
+ subject: {
354
+ ...n.subject,
355
+ type: s
356
+ },
357
+ assertions: n.assertions,
358
+ ...r && { where: r },
359
+ ...n.message && { message: n.message },
360
+ ...n.severity && { severity: n.severity }
361
+ };
362
+ }
363
+ async function Ce(e) {
364
+ const { document: t, entitySchema: n, entityDefaultSchema: s, severity: r, externalRefResolver: o = new T(), assertionConfig: a = {} } = e, i = {
365
+ problems: [],
366
+ specVersion: "entity",
367
+ visitorsData: {}
368
+ }, { entityTypes: c, discriminatorResolver: d } = xe(n, s), l = re(c);
369
+ let f = l.Entity;
370
+ if (Array.isArray(t.parsed))
371
+ f = l.EntityFileArray;
372
+ else if (y(t.parsed)) {
373
+ const v = t.parsed[_];
374
+ if (!v)
375
+ f = l.Entity;
376
+ else {
377
+ const b = d?.(t.parsed, v);
378
+ b && typeof b == "string" && l[b] && (f = l[b]);
379
+ }
380
+ }
381
+ const u = pe(a), p = Array.isArray(u) ? u.map((v) => ({
382
+ severity: r || "error",
383
+ ruleId: "entity assertions",
384
+ visitor: v
385
+ })) : [
386
+ {
387
+ severity: r || "error",
388
+ ruleId: "entity assertions",
389
+ visitor: u
390
+ }
391
+ ], m = [
392
+ {
393
+ severity: r || "error",
394
+ ruleId: "entity struct",
395
+ visitor: ue()
396
+ },
397
+ {
398
+ severity: r || "error",
399
+ ruleId: "entity no-unresolved-refs",
400
+ visitor: ee()
401
+ },
402
+ {
403
+ severity: r || "error",
404
+ ruleId: "entity key-valid",
405
+ visitor: we()
406
+ },
407
+ ...p
408
+ ], g = N(m, l), R = await k({
409
+ rootDocument: t,
410
+ rootType: f,
411
+ externalRefResolver: o
412
+ });
413
+ return I({
414
+ document: t,
415
+ rootType: f,
416
+ normalizedVisitors: g,
417
+ resolvedRefMap: R,
418
+ ctx: i
419
+ }), i.problems;
420
+ }
421
+ async function lt(e, t, n) {
422
+ if (!t.rules)
423
+ throw new Error(`Scorecard level "${t.name}" has no rules defined.`);
424
+ const s = new T(), r = oe(JSON.stringify(e, null, 2), "entity"), o = r.parsed[_], a = Ne(o || "unknown", t.rules), { entityRules: i, apiRules: c } = Ie(a), d = await Ce({
425
+ document: r,
426
+ entitySchema: de,
427
+ entityDefaultSchema: ye,
428
+ externalRefResolver: s,
429
+ assertionConfig: i
430
+ });
431
+ if ($.includes(e.type)) {
432
+ if (Object.keys(c).length === 0)
433
+ return d;
434
+ if (!n)
435
+ throw new Error(`Document is required for entity type "${e.type}". Provide the source API document to lint API rules.`);
436
+ if (e.type === "data-schema" && e.metadata?.schema) {
437
+ Object.values(c).forEach((p) => {
438
+ if (y(p) && y(p.subject) && p.subject.type !== "Schema")
439
+ throw new Error(`API rules for "data-schema" entity must target Schema subject, but found "${p.subject.type}".`);
440
+ });
441
+ const f = Pe(e.title, e.metadata.schema, n);
442
+ if (!f)
443
+ throw new Error(`Schema "${e.title}" not found in the document. Ensure the schema exists in components.schemas.`);
444
+ const u = await je({
445
+ schema: f,
446
+ schemaKey: e.title,
447
+ config: await V({
448
+ rules: c
449
+ }),
450
+ specType: e.metadata.specType,
451
+ sourceDocument: n,
452
+ externalRefResolver: s
453
+ });
454
+ return [...d, ...u];
455
+ }
456
+ const l = await te({
457
+ document: n,
458
+ externalRefResolver: s,
459
+ config: await V({
460
+ rules: c
461
+ })
462
+ });
463
+ return [...d, ...l];
464
+ } else if (!X(c))
465
+ throw new Error(`API rules are not supported for entity type "${e.type}". Only ${$.join(", ")} support API rules.`);
466
+ return d;
467
+ }
468
+ async function je(e) {
469
+ const { schema: t, schemaKey: n, config: s, sourceDocument: r, specType: o, externalRefResolver: a = new T(s.resolve) } = e, i = r.parsed, c = i[o], d = i.info, l = oe(JSON.stringify({
470
+ [o]: c,
471
+ info: d,
472
+ components: {
473
+ schemas: {
474
+ [n]: t
475
+ }
476
+ }
477
+ }, null, 2), r?.source.absoluteRef || `schema:${n}`);
478
+ return (await te({
479
+ document: l,
480
+ config: s,
481
+ externalRefResolver: a
482
+ })).filter((u) => u.location.some((p) => p.pointer?.includes(`/components/schemas/${n}`)));
483
+ }
484
+ function Fe(e) {
485
+ const { document: t, types: n, resolvedRefMap: s, ctx: r } = e, o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = (l, { type: f, key: u, location: p }, m) => {
486
+ const g = {
487
+ type: f,
488
+ key: u,
489
+ location: p,
490
+ value: l,
491
+ parent: m ?? null,
492
+ children: []
493
+ };
494
+ m?.children.push(g), o.set(l, g);
495
+ for (const R of a.get(l) ?? [])
496
+ R.resolved = g;
497
+ return g;
498
+ }, d = [
499
+ { severity: "warn", ruleId: "node-tree", visitor: {
500
+ any: {
501
+ enter(l, f) {
502
+ if (!(y(l) || Array.isArray(l)) || o.has(l))
503
+ return;
504
+ const p = o.get(f.rawNode);
505
+ p ? i(l, f).referencedFrom = p : i(l, f, o.get(f.parent));
506
+ },
507
+ // A target the walker reached through a `$ref` before its own place joins it here
508
+ leave(l) {
509
+ const f = o.get(l);
510
+ if (f)
511
+ for (const [u, p] of Object.entries(f.value)) {
512
+ const m = o.get(p);
513
+ !m || m.parent || (m.parent = f, m.key = Array.isArray(f.value) ? Number(u) : u, f.children.push(m));
514
+ }
515
+ }
516
+ },
517
+ ref(l, f, u) {
518
+ if (o.has(l))
519
+ return;
520
+ const p = i(l, f, o.get(f.parent)), m = u.chain?.[0]?.node ?? u.node, g = o.get(m);
521
+ g ? p.resolved = g : a.set(m, [...a.get(m) ?? [], p]);
522
+ }
523
+ } },
524
+ { severity: "error", ruleId: "no-unresolved-refs", visitor: ee() }
525
+ ];
526
+ return I({
527
+ document: t,
528
+ rootType: n.Root,
529
+ normalizedVisitors: N(d, n),
530
+ resolvedRefMap: s,
531
+ ctx: r
532
+ }), o.get(t.parsed);
533
+ }
534
+ function ae(e) {
535
+ return e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean";
536
+ }
537
+ function Ve(e) {
538
+ return Array.isArray(e) && e.every(ae);
539
+ }
540
+ function Me(e) {
541
+ return e.kind === "removed" ? e.base : e.revision;
542
+ }
543
+ function $e(e) {
544
+ const { base: t, revision: n } = P(e);
545
+ if (!t)
546
+ return [{ path: S(e), node: e, kind: "added", revision: G(me(e)) }];
547
+ if (!n)
548
+ return [{ path: S(e), node: e, kind: "removed", base: G(t) }];
549
+ const s = [];
550
+ let r;
551
+ const o = q(t), a = q(n);
552
+ for (const i of Object.keys({ ...o, ...a }))
553
+ Q(o[i], a[i]) || (r ??= S(e), s.push({
554
+ path: r,
555
+ node: e,
556
+ kind: "modified",
557
+ property: i,
558
+ base: K(t, i, o[i]),
559
+ revision: K(n, i, a[i])
560
+ }));
561
+ return s;
562
+ }
563
+ function q(e) {
564
+ const t = {}, n = new Set(e.children.map((s) => s.key));
565
+ if (y(e.value))
566
+ for (const [s, r] of Object.entries(e.value))
567
+ n.has(s) || s === "$ref" && e.resolved || (ae(r) || Ve(r)) && (t[s] = r);
568
+ return t;
569
+ }
570
+ function G(e) {
571
+ return { location: e.location, value: ne(e) };
572
+ }
573
+ function K(e, t, n) {
574
+ return { location: y(e.value) && t in e.value ? e.location.child([t]) : e.location, value: n };
575
+ }
576
+ const Le = 0.5;
577
+ function ze(e, t) {
578
+ const n = [], s = new Set(t), r = [], o = U([...e, ...t], (i) => i.value);
579
+ for (const i of e) {
580
+ const c = Be(i, s, o);
581
+ c ? (s.delete(c), n.push({ base: i, revision: c })) : r.push(i);
582
+ }
583
+ const a = U([...r, ...s], ne);
584
+ for (const i of r) {
585
+ const c = qe(i, s, a);
586
+ c && s.delete(c), n.push({ base: i, revision: c });
587
+ }
588
+ for (const i of s)
589
+ n.push({ revision: i });
590
+ return n;
591
+ }
592
+ function U(e, t) {
593
+ return new Map(e.map((n) => [
594
+ n,
595
+ typeof n.key == "string" ? n.key : w(t(n))
596
+ ]));
597
+ }
598
+ function Be(e, t, n) {
599
+ for (const s of t)
600
+ if (s.type.name === e.type.name && n.get(s) === n.get(e))
601
+ return s;
602
+ }
603
+ function qe(e, t, n) {
604
+ let s, r = 0;
605
+ for (const o of t) {
606
+ if (o.type.name !== e.type.name)
607
+ continue;
608
+ const a = Ge(e, o, n);
609
+ a >= Le && a > r && (s = o, r = a);
610
+ }
611
+ return s;
612
+ }
613
+ function Ge(e, t, n) {
614
+ if (he(e) === "field")
615
+ return e.key === t.key ? 1 : 0;
616
+ const s = n.get(e), r = n.get(t), o = Math.max(s.length, r.length);
617
+ return o === 0 ? 1 : 1 - ge(s, r) / o;
618
+ }
619
+ function w(e) {
620
+ return Array.isArray(e) ? `[${e.map(w).join(",")}]` : y(e) ? `{${Object.keys(e).sort().map((n) => `${JSON.stringify(n)}:${w(e[n])}`).join(",")}}` : JSON.stringify(e) ?? "null";
621
+ }
622
+ function Ke(e, t) {
623
+ const n = [], s = /* @__PURE__ */ new Map();
624
+ function r(o) {
625
+ const a = P(o);
626
+ if (a.base && a.revision) {
627
+ const i = `${a.base.location.absolutePointer}|${a.revision.location.absolutePointer}`, c = s.get(i);
628
+ if (c) {
629
+ c.referencedBy.push(o);
630
+ return;
631
+ }
632
+ s.set(i, o);
633
+ }
634
+ if (n.push(...$e(o)), !(!a.base || !a.revision)) {
635
+ for (const i of ze(a.base.children, a.revision.children)) {
636
+ const c = { ...i, parent: o, referencedBy: [] };
637
+ i.base && i.revision && typeof i.base.key == "string" && i.base.key !== i.revision.key && n.push({
638
+ path: S(c),
639
+ node: c,
640
+ kind: "modified",
641
+ property: "key",
642
+ base: { location: i.base.location, value: i.base.key },
643
+ revision: { location: i.revision.location, value: i.revision.key }
644
+ }), r(c);
645
+ }
646
+ ve(a) && r({
647
+ base: a.base.resolved,
648
+ revision: a.revision.resolved,
649
+ parent: o,
650
+ referencedBy: []
651
+ });
652
+ }
653
+ }
654
+ return r({ base: e, revision: t, parent: null, referencedBy: [] }), n;
655
+ }
656
+ const Ue = ["request", "response"];
657
+ function Ae(e) {
658
+ const t = ce(e.revision ? "revision" : "base", e, /* @__PURE__ */ new Set());
659
+ return Ue.filter((n) => t.includes(n));
660
+ }
661
+ function ce(e, t, n) {
662
+ if (n.has(t))
663
+ return [];
664
+ n.add(t);
665
+ const s = A(P(t)[e]) ?? A(t[e]);
666
+ return s ? [s] : [t.parent, ...t.referencedBy].flatMap((r) => r ? ce(e, r, n) : []);
667
+ }
668
+ function A(e) {
669
+ switch (e.type.name) {
670
+ case "RequestBody":
671
+ case "ParameterList":
672
+ return Y(e, "request");
673
+ case "Responses":
674
+ return Y(e, "response");
675
+ // "readOnly" data only comes from the API and "writeOnly" data only goes to it (OpenAPI,
676
+ // Schema Object), wherever the schema is used.
677
+ case "Schema":
678
+ return E(e, "readOnly") === !0 ? "response" : E(e, "writeOnly") === !0 ? "request" : void 0;
679
+ // AsyncAPI 3: `receive` means another application produces the message, so its payload is
680
+ // judged the way a request body is; `send` means this application produces it. An OpenAPI
681
+ // operation has no `action`, so it says nothing.
682
+ case "Operation":
683
+ return H(E(e, "action"));
684
+ // A reply answers the operation, so it travels back the other way.
685
+ case "OperationReply": {
686
+ const t = H(E(O(e, "Operation"), "action"));
687
+ return t && fe(t);
688
+ }
689
+ default:
690
+ return;
691
+ }
692
+ }
693
+ function Y(e, t) {
694
+ return O(e, "Components") ? void 0 : O(e, "CallbacksMap") ?? O(e, "WebhooksMap") ? fe(t) : t;
695
+ }
696
+ function H(e) {
697
+ if (e === "receive")
698
+ return "request";
699
+ if (e === "send")
700
+ return "response";
701
+ }
702
+ function fe(e) {
703
+ return e === "request" ? "response" : "request";
704
+ }
705
+ const Ye = /* @__PURE__ */ new Set(["enter", "leave", "skip"]);
706
+ function le(e, t, n = []) {
707
+ return Object.entries(e).flatMap(([s, r]) => {
708
+ if (Ye.has(s) || s === "any" && n.length > 0)
709
+ throw new Error(`Diff rule '${t}' uses '${s}' where diff visitors do not have it.`);
710
+ return typeof r != "function" ? le(r, t, [...n, s]) : [{ typePath: s === "any" ? [] : [...n, s], visit: r }];
711
+ });
712
+ }
713
+ function He(e, t) {
714
+ let n = t;
715
+ for (let s = e.length - 1; s >= 0; s--) {
716
+ if (n === void 0 || D(n) !== e[s])
717
+ return !1;
718
+ s > 0 && (n = We(n.parent, [e[s - 1], e[s]]));
719
+ }
720
+ return !0;
721
+ }
722
+ function We(e, t) {
723
+ for (let n = e; n; n = n.parent)
724
+ if (t.includes(D(n)))
725
+ return n;
726
+ }
727
+ function Je(e, t, n) {
728
+ const s = t.flatMap(({ ruleId: r, impact: o, visitor: a }) => le(a, r).map((i) => ({ ruleId: r, impact: o, ...i })));
729
+ return e.map((r) => Xe(r, s, n));
730
+ }
731
+ function Xe(e, t, n) {
732
+ let s;
733
+ const r = () => s ??= Ae(e.node), o = Me(e).location, a = [];
734
+ for (const { ruleId: c, impact: d, typePath: l, visit: f } of t) {
735
+ if (!He(l, e.node))
736
+ continue;
737
+ f(e, { report: (p) => {
738
+ a.push({
739
+ ruleId: c,
740
+ impact: d,
741
+ message: p.message,
742
+ location: p.location ?? o
743
+ });
744
+ }, location: o, getDirections: r, specVersion: n });
745
+ }
746
+ const i = se(a.map((c) => c.impact));
747
+ return { ...e, verdicts: a, impact: i ?? be(e) };
748
+ }
749
+ async function pt(e) {
750
+ const { base: t, revision: n, config: s, externalRefResolver: r = new T(s.resolve) } = e, o = M(t.parsed), a = M(n.parsed), i = x(a);
751
+ if (x(o) !== i)
752
+ throw new Ee(`Cannot compare ${o} with ${a}.`);
753
+ const [c, d] = await Promise.all([
754
+ W(t, o, s, r),
755
+ W(n, a, s, r)
756
+ ]), l = Se(s.getDiffRulesForSpecVersion(i), s, a), f = Je(Ke(c.root, d.root), l, a);
757
+ return {
758
+ files: {
759
+ base: t.source.absoluteRef,
760
+ revision: n.source.absoluteRef
761
+ },
762
+ specVersions: {
763
+ base: o,
764
+ revision: a
765
+ },
766
+ infoVersions: { base: J(t), revision: J(n) },
767
+ summary: Qe(f),
768
+ bump: Ze(f),
769
+ changes: f,
770
+ // The base is not the author's to fix, so its problems only warn.
771
+ problems: [
772
+ ...c.problems.map((u) => ({ ...u, severity: "warn" })),
773
+ ...d.problems
774
+ ]
775
+ };
776
+ }
777
+ async function W(e, t, n, s) {
778
+ const r = n.getRulesForSpecVersion(x(t)), o = re(n.extendTypes(Oe(t), t), n), a = {
779
+ problems: [],
780
+ specVersion: t,
781
+ config: n,
782
+ visitorsData: {}
783
+ }, i = Te(r, n, "decorators", t);
784
+ let c = await k({
785
+ rootDocument: e,
786
+ rootType: o.Root,
787
+ externalRefResolver: s
788
+ });
789
+ return i.length > 0 && (I({
790
+ document: e,
791
+ rootType: o.Root,
792
+ normalizedVisitors: N(i, o),
793
+ resolvedRefMap: c,
794
+ ctx: a
795
+ }), c = await k({
796
+ rootDocument: e,
797
+ rootType: o.Root,
798
+ externalRefResolver: s
799
+ })), {
800
+ root: Fe({ document: e, types: o, resolvedRefMap: c, ctx: a }),
801
+ problems: a.problems.map((d) => n.addProblemToIgnore(d))
802
+ };
803
+ }
804
+ function J({ parsed: e }) {
805
+ const t = y(e) && y(e.info) ? e.info.version : void 0;
806
+ return typeof t == "string" ? t : void 0;
807
+ }
808
+ function Qe(e) {
809
+ const t = { major: 0, minor: 0, patch: 0 };
810
+ for (const n of e)
811
+ t[n.impact]++;
812
+ return t;
813
+ }
814
+ function Ze(e) {
815
+ return se(e.flatMap((t) => t.kind === "modified" && t.property === "version" && D(t.node) === "Info" ? [] : [t.impact]));
816
+ }
817
+ export {
818
+ yt as AbortFlowError,
819
+ mt as Arazzo1Types,
820
+ ht as Arazzo1_1Types,
821
+ gt as AsyncApi2Types,
822
+ vt as AsyncApi3Types,
823
+ T as BaseResolver,
824
+ bt as CONFIG_BUNDLER_VISITOR_ID,
825
+ Et as CONFIG_FILE_NAME,
826
+ St as ConfigTypes,
827
+ Ot as ConfigValidationError,
828
+ Tt as DEFAULT_CONFIG,
829
+ Rt as DEFAULT_PROJECT_PLUGIN_PATHS,
830
+ Ee as HandledError,
831
+ xt as IGNORE_BANNER,
832
+ kt as IGNORE_FILE,
833
+ dn as Location,
834
+ wt as Oas2Types,
835
+ Nt as Oas3Types,
836
+ It as Oas3_1Types,
837
+ Pt as Oas3_2Types,
838
+ Dt as OpenRpcTypes,
839
+ _t as Overlay1Types,
840
+ Ct as PLUGINS_COLLECTOR_VISITOR_ID,
841
+ yn as ResolveError,
842
+ mn as Source,
843
+ ct as StatsAsync2,
844
+ ft as StatsAsync3,
845
+ at as StatsOAS,
846
+ hn as YamlParseError,
847
+ jt as bundle,
848
+ Ft as bundleDocument,
849
+ Vt as bundleFromString,
850
+ it as capitalize,
851
+ Mt as clearPluginsCache,
852
+ V as createConfig,
853
+ $t as createConfigTypes,
854
+ xe as createEntityTypes,
855
+ Q as dequal,
856
+ M as detectSpec,
857
+ pt as diffDocuments,
858
+ Me as displaySide,
859
+ st as doesYamlFileExist,
860
+ gn as escapePointerFragment,
861
+ Lt as findConfig,
862
+ zt as formatProblems,
863
+ Bt as getAstNodeByPointer,
864
+ qt as getCodeframe,
865
+ vn as getDir,
866
+ Gt as getLineColLocation,
867
+ x as getMajorSpecVersion,
868
+ Kt as getPluginCacheVersion,
869
+ Ut as getTotals,
870
+ Oe as getTypes,
871
+ At as impactRank,
872
+ Yt as impacts,
873
+ bn as isAbsoluteUrl,
874
+ En as isBrowser,
875
+ X as isEmptyObject,
876
+ Sn as isGraphqlRef,
877
+ On as isMappingRef,
878
+ Ht as isNotEmptyArray,
879
+ rt as isNotEmptyObject,
880
+ y as isPlainObject,
881
+ Re as isRef,
882
+ Wt as isString,
883
+ Tn as isSupportedExtension,
884
+ Rn as isTruthy,
885
+ Jt as keysOf,
886
+ Xt as lint,
887
+ Qt as lintConfig,
888
+ te as lintDocument,
889
+ Ce as lintEntityFile,
890
+ lt as lintEntityWithScorecardLevel,
891
+ Zt as lintFromString,
892
+ je as lintSchema,
893
+ en as loadConfig,
894
+ tn as loadIgnoreConfig,
895
+ nn as logger,
896
+ oe as makeDocumentFromString,
897
+ sn as mapTypeToComponent,
898
+ rn as nameOf,
899
+ re as normalizeTypes,
900
+ N as normalizeVisitors,
901
+ xn as parsePointer,
902
+ kn as parseYaml,
903
+ ot as pause,
904
+ on as pluralize,
905
+ wn as readFileFromUrl,
906
+ an as regexFromString,
907
+ k as resolveDocument,
908
+ Nn as resolvePath,
909
+ cn as resolvePlugins,
910
+ fn as slash,
911
+ In as stringifyYaml,
912
+ D as typeOf,
913
+ Pn as unescapePointerFragment,
914
+ ln as validate,
915
+ I as walkDocument,
916
+ pn as xmlEscape
917
+ };