@redocly/replay 0.27.0-next.8 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{replay-AiChatProvider-DHIxHTKX.js → replay-AiChatProvider-LQhrLIDL.js} +44 -44
- package/dist/{replay-AiChatProvider-O8HHQobN.js → replay-AiChatProvider-Oms5CFgT.js} +1 -1
- package/dist/{replay-AiChatSqliteDBStorage-DNMrzkJg.js → replay-AiChatSqliteDBStorage-3-p1mthX.js} +1 -1
- package/dist/{replay-AiChatSqliteDBStorage-DjUq9VX3.js → replay-AiChatSqliteDBStorage-GZibdHOQ.js} +1 -1
- package/dist/replay-AiPanel-BvwwBTh1.js +742 -0
- package/dist/{replay-AiPanel-CR815YqV.js → replay-AiPanel-lcDNvgo0.js} +973 -1176
- package/dist/replay-FileWatcher-ClVd_wG0.js +1 -0
- package/dist/replay-FileWatcher-DR-wJLe2.js +343 -0
- package/dist/replay-Observable-D6wKbFwB.js +31 -0
- package/dist/replay-Observable-bjJ6wkRB.js +1 -0
- package/dist/replay-SemanticSearchService-CCqwCRo6.js +1 -0
- package/dist/replay-SemanticSearchService-U1eXQGfF.js +723 -0
- package/dist/{replay-SqliteDBStorage-B3oYWXem.js → replay-SqliteDBStorage-Dn6DoVWW.js} +1 -1
- package/dist/{replay-SqliteDBStorage-CC9kLioX.js → replay-SqliteDBStorage-d_ZK6ScA.js} +1 -1
- package/dist/replay-TauriFileSystemAdapter-CpiUuG3T.js +99 -0
- package/dist/replay-TauriFileSystemAdapter-dwJ0xBYr.js +1 -0
- package/dist/replay-TauriRootStorage-CuVbYMXX.js +605 -0
- package/dist/replay-TauriRootStorage-DhzbAahU.js +1 -0
- package/dist/{replay-agent-loop-CTq5eJ4u.js → replay-agent-loop-BLSu4v_O.js} +1 -1
- package/dist/{replay-agent-loop-CCYOzyHo.js → replay-agent-loop-DgEHdXUt.js} +11 -11
- package/dist/{replay-ai-chat-mappers-C8y5UhCq.js → replay-ai-chat-mappers-BvfcEubB.js} +5 -5
- package/dist/{replay-ai-chat-mappers-B_wovMvG.js → replay-ai-chat-mappers-Dy2kJ7ZG.js} +1 -1
- package/dist/replay-core-BJmXmoC5.js +1 -0
- package/dist/replay-core-B_hiOZZr.js +10 -0
- package/dist/{replay-create-model-C5yvtnXA.js → replay-create-model-DNPFcOIp.js} +579 -578
- package/dist/{replay-create-model-CBCmuEKC.js → replay-create-model-bOIDB-e8.js} +10 -10
- package/dist/{replay-db-CCBQadnT.js → replay-db-BQGv3PGw.js} +1 -1
- package/dist/{replay-db-DfOjLqsq.js → replay-db-CMXZZs9v.js} +1 -1
- package/dist/{replay-external-resolver-BRouROm6.js → replay-external-resolver-mrykFC2h.js} +2 -2
- package/dist/{replay-external-resolver-B6tpqUZt.js → replay-external-resolver-n5OvQMRF.js} +1 -1
- package/dist/replay-index-3lwhSmvi.js +1 -0
- package/dist/{replay-index-BzzBKjHm.js → replay-index-Bc5RHu5L.js} +23771 -25420
- package/dist/replay-index-CFLu-XMV.js +25 -0
- package/dist/{replay-index-Xq6K7XSm.js → replay-index-CHGVyIdG.js} +1 -1
- package/dist/{replay-index-Cpkh9r0X.js → replay-index-CSR_qlua.js} +1 -1
- package/dist/replay-index-CepJ5Z0m.js +6875 -0
- package/dist/{replay-index-Bzttek8l.js → replay-index-CgCGhu4l.js} +6 -6
- package/dist/replay-index-DDjmUXWm.js +1 -0
- package/dist/replay-index-DiSy_1OY.js +21 -0
- package/dist/replay-index-Oct6Dygd.js +1 -0
- package/dist/{replay-index-B_OHqSlS.js → replay-index-QXosJxRc.js} +18 -18
- package/dist/replay-index-jkDlU0Lx.js +32 -0
- package/dist/{replay-lint-gtuMJgII.js → replay-lint-DoHQIATV.js} +122 -122
- package/dist/{replay-lint-DlDmPTBV.js → replay-lint-PWaLESz5.js} +8921 -8880
- package/dist/{replay-lint-graphql-DHOq8lRT.js → replay-lint-graphql-xh8VoAwd.js} +1 -1
- package/dist/{replay-lint-graphql-BQJ00lU4.js → replay-lint-graphql-zO8zunug.js} +1 -1
- package/dist/replay-periodic-revalidation-BoyLQHtg.js +1 -0
- package/dist/replay-periodic-revalidation-Dsp-n7ui.js +21 -0
- package/dist/replay-promise-map-limit-DRDkHc-b.js +1 -0
- package/dist/replay-promise-map-limit-Db_42GvV.js +14 -0
- package/dist/replay-resolve-B0AjmaE9.js +47 -0
- package/dist/{replay-resolve-DsgcWnjC.js → replay-resolve-MVe_8Ube.js} +1364 -1329
- package/dist/{replay-respect-run-7Cwe1_ri.js → replay-respect-run-BJsR4a4m.js} +1 -1
- package/dist/{replay-respect-run-D1zyh-5j.js → replay-respect-run-X4PSO6Fj.js} +3 -3
- package/dist/{replay-tauri-path-BAY3g5sW.js → replay-tauri-path-CkGiQWsb.js} +5 -5
- package/dist/{replay-tauri-path-CaVeI3a-.js → replay-tauri-path-D8FJsoZb.js} +1 -1
- package/dist/replay-useAiChatQueries-BXL-_N2Q.js +215 -0
- package/dist/{replay-useAiChatQueries-CxZNLVje.js → replay-useAiChatQueries-D7sHNAfV.js} +1078 -1022
- package/dist/{replay-validate-key-Cv0mvYDS.js → replay-validate-key-CmzSfORv.js} +1 -1
- package/dist/{replay-validate-key-Di8MCBz7.js → replay-validate-key-CtZEJRP7.js} +2 -2
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +11 -11
- package/package.json +10 -9
- package/dist/replay-AiPanel-CfYBCkrN.js +0 -868
- package/dist/replay-index-C6SJPGDO.js +0 -23
- package/dist/replay-index-CUs62_1f.js +0 -1
- package/dist/replay-index-Dfnqt_IZ.js +0 -6899
- package/dist/replay-resolve-DqFS69S_.js +0 -47
- package/dist/replay-useAiChatQueries-D99tAUpY.js +0 -215
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
import { i as f, aP as W, aQ as X, aN as y } from "./replay-index-Bc5RHu5L.js";
|
|
2
|
+
import { O as z } from "./replay-Observable-D6wKbFwB.js";
|
|
3
|
+
import { p as K } from "./replay-promise-map-limit-Db_42GvV.js";
|
|
4
|
+
function w(t) {
|
|
5
|
+
return t == null ? "" : typeof t == "string" ? t : typeof t == "object" && "raw" in t && typeof t.raw == "string" ? t.raw : String(t);
|
|
6
|
+
}
|
|
7
|
+
function S(t) {
|
|
8
|
+
return t.replace(/\s+/g, " ").trim();
|
|
9
|
+
}
|
|
10
|
+
function b(t) {
|
|
11
|
+
return typeof t == "object" && t !== null && "$ref" in t;
|
|
12
|
+
}
|
|
13
|
+
function D(t) {
|
|
14
|
+
return b(t) ? null : t;
|
|
15
|
+
}
|
|
16
|
+
function q(t) {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.stringify(t);
|
|
19
|
+
} catch {
|
|
20
|
+
return String(t);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function J(t) {
|
|
24
|
+
let e = `${t.name} (${t.in}`;
|
|
25
|
+
return t.required && (e += ", required"), t.type && (e += `, ${t.type}`), t.format && (e += `, format: ${t.format}`), t.enum && (e += `, enum: [${t.enum.join(",")}]`), t.pattern && (e += `, pattern: ${t.pattern}`), e += ")", e;
|
|
26
|
+
}
|
|
27
|
+
function U(t) {
|
|
28
|
+
return t.type ? Array.isArray(t.type) ? t.type.join("|") : t.type : t.oneOf ? "oneOf" : t.anyOf ? "anyOf" : t.allOf ? "allOf" : "object";
|
|
29
|
+
}
|
|
30
|
+
function Y(t) {
|
|
31
|
+
return t === "querystring" ? "query" : t === "query" || t === "header" || t === "path" || t === "cookie" ? t : "query";
|
|
32
|
+
}
|
|
33
|
+
function Z(t) {
|
|
34
|
+
const e = t.schema && !b(t.schema) ? t.schema : null, n = {
|
|
35
|
+
name: t.name,
|
|
36
|
+
in: Y(t.in),
|
|
37
|
+
required: t.required ?? !1
|
|
38
|
+
};
|
|
39
|
+
return e && (n.type = U(e), e.format && (n.format = e.format), e.enum && (n.enum = e.enum.map(String)), e.pattern && (n.pattern = e.pattern), e.example !== void 0 && (n.example = String(e.example))), t.description && (n.description = w(t.description)), t.example !== void 0 && !n.example && (n.example = String(t.example)), n;
|
|
40
|
+
}
|
|
41
|
+
function V(t, e) {
|
|
42
|
+
const n = /* @__PURE__ */ new Set(), o = [], s = (i) => {
|
|
43
|
+
for (const r of i) {
|
|
44
|
+
const c = D(r);
|
|
45
|
+
if (!c || !c.name) continue;
|
|
46
|
+
const a = `${c.in}:${c.name}`;
|
|
47
|
+
n.has(a) || (n.add(a), o.push(Z(c)));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return t.parameters && s(t.parameters), e.parameters && s(e.parameters), o;
|
|
51
|
+
}
|
|
52
|
+
function F(t, e = 2, n = 0) {
|
|
53
|
+
if (n >= e || !t.properties) return [];
|
|
54
|
+
const o = new Set(t.required ?? []);
|
|
55
|
+
return Object.entries(t.properties).map(([s, i]) => ({
|
|
56
|
+
name: s,
|
|
57
|
+
type: U(i),
|
|
58
|
+
required: o.has(s),
|
|
59
|
+
readOnly: i.readOnly
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
function ee(t) {
|
|
63
|
+
const e = t.components?.securitySchemes;
|
|
64
|
+
if (!e) return [];
|
|
65
|
+
const n = [];
|
|
66
|
+
for (const [o, s] of Object.entries(e)) {
|
|
67
|
+
const i = D(s);
|
|
68
|
+
i && n.push(te(o, i));
|
|
69
|
+
}
|
|
70
|
+
return n;
|
|
71
|
+
}
|
|
72
|
+
function te(t, e) {
|
|
73
|
+
const n = {
|
|
74
|
+
schemeName: t,
|
|
75
|
+
type: e.type
|
|
76
|
+
};
|
|
77
|
+
if (e.in && (n.in = e.in), e.name && (n.name = e.name), e.scheme && (n.scheme = e.scheme), e.bearerFormat && (n.bearerFormat = e.bearerFormat), e.flows) {
|
|
78
|
+
const o = Object.keys(e.flows).filter(
|
|
79
|
+
(i) => e.flows[i]
|
|
80
|
+
);
|
|
81
|
+
o.length > 0 && (n.flows = o.join(", "));
|
|
82
|
+
const s = /* @__PURE__ */ new Set();
|
|
83
|
+
for (const i of o) {
|
|
84
|
+
const r = e.flows[i];
|
|
85
|
+
r?.scopes && Object.keys(r.scopes).forEach((c) => s.add(c));
|
|
86
|
+
}
|
|
87
|
+
s.size > 0 && (n.scopes = [...s].join(", "));
|
|
88
|
+
}
|
|
89
|
+
return n;
|
|
90
|
+
}
|
|
91
|
+
function ne(t, e, n) {
|
|
92
|
+
const o = t ?? e;
|
|
93
|
+
if (!o || n.length === 0) return [];
|
|
94
|
+
const s = /* @__PURE__ */ new Set();
|
|
95
|
+
for (const i of o)
|
|
96
|
+
for (const r of Object.keys(i))
|
|
97
|
+
s.add(r);
|
|
98
|
+
return n.filter((i) => s.has(i.schemeName));
|
|
99
|
+
}
|
|
100
|
+
function ie(t) {
|
|
101
|
+
return t.length === 0 ? "" : `Security: ${t.map((n) => {
|
|
102
|
+
let o = `${n.schemeName} (${n.type}`;
|
|
103
|
+
return n.scheme && (o += `, ${n.scheme}`), n.in && n.name && (o += `, ${n.name} in ${n.in}`), o += ")", o;
|
|
104
|
+
}).join("; ")}.`;
|
|
105
|
+
}
|
|
106
|
+
const oe = [
|
|
107
|
+
"get",
|
|
108
|
+
"put",
|
|
109
|
+
"post",
|
|
110
|
+
"delete",
|
|
111
|
+
"options",
|
|
112
|
+
"head",
|
|
113
|
+
"patch",
|
|
114
|
+
"trace"
|
|
115
|
+
], se = ["query", "x-query"];
|
|
116
|
+
function re(t, e) {
|
|
117
|
+
const n = [], o = Object.keys(t.content ?? {});
|
|
118
|
+
if (o.length === 0)
|
|
119
|
+
return { textPart: "", schemaJson: "{}", examples: n };
|
|
120
|
+
const s = o.find((d) => d.includes("json")) ?? o[0], i = t.content?.[s], r = i?.schema && !b(i.schema) ? i.schema : null, a = (r ? F(r) : []).filter((d) => !e.hideReadOnly || !d.readOnly), u = t.required ? "required" : "optional";
|
|
121
|
+
let l = `Request body (${s}, ${u})`;
|
|
122
|
+
if (a.length > 0) {
|
|
123
|
+
const d = a.map(
|
|
124
|
+
(p) => `${p.name}: ${p.type}${p.required ? " required" : ""}${p.readOnly ? " readOnly" : ""}`
|
|
125
|
+
);
|
|
126
|
+
l += `: {${d.join(", ")}}`;
|
|
127
|
+
}
|
|
128
|
+
return i?.example !== void 0 && n.push(q(i.example)), {
|
|
129
|
+
textPart: l,
|
|
130
|
+
schemaJson: JSON.stringify(a),
|
|
131
|
+
examples: n
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function ce(t) {
|
|
135
|
+
const e = [], n = [];
|
|
136
|
+
for (const [o, s] of Object.entries(t)) {
|
|
137
|
+
if (b(s)) continue;
|
|
138
|
+
const i = w(s.description ?? "");
|
|
139
|
+
e.push(`${o} ${i}`.trim());
|
|
140
|
+
const r = { statusCode: o };
|
|
141
|
+
i && (r.description = i);
|
|
142
|
+
const c = s.content;
|
|
143
|
+
if (c) {
|
|
144
|
+
const a = Object.keys(c).find((l) => l.includes("json")) ?? Object.keys(c)[0], u = c[a]?.schema;
|
|
145
|
+
if (u && !b(u)) {
|
|
146
|
+
const l = F(u);
|
|
147
|
+
l.length > 0 && (r.schemaProperties = JSON.stringify(l));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
n.push(r);
|
|
151
|
+
}
|
|
152
|
+
return { textParts: e, summaries: n };
|
|
153
|
+
}
|
|
154
|
+
function R(t) {
|
|
155
|
+
const { apiId: e, apiTitle: n, path: o, method: s, op: i, pathItem: r, globalSchemes: c, apiSecurity: a } = t, u = i.summary ?? "", l = w(i.description ?? ""), d = i.operationId ?? "", p = i.tags ?? [], m = s.toUpperCase(), g = V(i, r), h = ne(i.security, a, c), x = h.length > 0 ? h.map((_) => `api_sec:${e}:${_.schemeName}`) : void 0, I = [n, `${m} ${o}`, u, l];
|
|
156
|
+
d && I.push(`operationId: ${d}`), p.length > 0 && I.push(`Tags: ${p.join(", ")}`), i.deprecated && I.push("DEPRECATED"), g.length > 0 && I.push(`Parameters: ${g.map(J).join(". ")}.`);
|
|
157
|
+
let k;
|
|
158
|
+
const v = [], T = i.requestBody;
|
|
159
|
+
if (T) {
|
|
160
|
+
const _ = D(T);
|
|
161
|
+
if (_) {
|
|
162
|
+
const N = re(_, {
|
|
163
|
+
hideReadOnly: m === "POST" || m === "PUT" || m === "PATCH"
|
|
164
|
+
});
|
|
165
|
+
N.textPart && I.push(N.textPart), k = N.schemaJson, v.push(...N.examples);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const { textParts: B, summaries: A } = ce(
|
|
169
|
+
i.responses ?? {}
|
|
170
|
+
);
|
|
171
|
+
B.length > 0 && I.push(`Responses: ${B.join(", ")}.`);
|
|
172
|
+
const C = ie(h);
|
|
173
|
+
C && I.push(C);
|
|
174
|
+
const E = `api_op:${e}:${o}:${s}:${d || `${o}-${s}`}`, G = {
|
|
175
|
+
type: "api_operation",
|
|
176
|
+
id: E,
|
|
177
|
+
contentHash: "",
|
|
178
|
+
title: u || `${m} ${o}`,
|
|
179
|
+
description: l || void 0,
|
|
180
|
+
apiId: e,
|
|
181
|
+
path: o,
|
|
182
|
+
method: m,
|
|
183
|
+
operationId: d || void 0,
|
|
184
|
+
tags: p.length > 0 ? p : void 0,
|
|
185
|
+
deprecated: i.deprecated || void 0,
|
|
186
|
+
parameterDetails: g.length > 0 ? g : void 0,
|
|
187
|
+
requestBodySchema: k,
|
|
188
|
+
responseSchemas: A.length > 0 ? A : void 0,
|
|
189
|
+
securitySchemeRefs: x,
|
|
190
|
+
examples: v.length > 0 ? v : void 0
|
|
191
|
+
};
|
|
192
|
+
return {
|
|
193
|
+
id: E,
|
|
194
|
+
text: S(I.filter(Boolean).join(" ")),
|
|
195
|
+
payload: G
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function ae(t) {
|
|
199
|
+
const e = t.info?.title ?? "Untitled API", n = w(t.info?.description ?? t.info?.summary ?? ""), o = t.id;
|
|
200
|
+
return {
|
|
201
|
+
id: `api:${o}`,
|
|
202
|
+
text: S([e, n].filter(Boolean).join(" ")),
|
|
203
|
+
payload: {
|
|
204
|
+
type: "api",
|
|
205
|
+
id: `api:${o}`,
|
|
206
|
+
contentHash: "",
|
|
207
|
+
title: e,
|
|
208
|
+
description: n || void 0,
|
|
209
|
+
apiId: o
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function L(t) {
|
|
214
|
+
const e = [];
|
|
215
|
+
for (const n of t) {
|
|
216
|
+
e.push(ae(n));
|
|
217
|
+
const o = n.info?.title ?? "Untitled API", s = n.id, i = ee(n);
|
|
218
|
+
for (const c of i) {
|
|
219
|
+
const a = `api_sec:${s}:${c.schemeName}`, u = [
|
|
220
|
+
`${c.schemeName}: type=${c.type}`,
|
|
221
|
+
c.scheme ? `scheme=${c.scheme}` : "",
|
|
222
|
+
c.in && c.name ? `${c.name} in ${c.in}` : "",
|
|
223
|
+
c.bearerFormat ? `format=${c.bearerFormat}` : "",
|
|
224
|
+
c.flows ? `flows=[${c.flows}]` : "",
|
|
225
|
+
c.scopes ? `scopes=[${c.scopes}]` : ""
|
|
226
|
+
].filter(Boolean).join(" ");
|
|
227
|
+
e.push({
|
|
228
|
+
id: a,
|
|
229
|
+
text: S(`${o} Authentication. ${c.schemeName}. ${u}.`),
|
|
230
|
+
payload: {
|
|
231
|
+
type: "api_security",
|
|
232
|
+
id: a,
|
|
233
|
+
contentHash: "",
|
|
234
|
+
title: `${o} — ${c.schemeName}`,
|
|
235
|
+
apiId: s,
|
|
236
|
+
securityScheme: c
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
const r = n.paths ?? {};
|
|
241
|
+
for (const [c, a] of Object.entries(r)) {
|
|
242
|
+
if (!a || typeof a != "object") continue;
|
|
243
|
+
const u = [
|
|
244
|
+
...oe.filter((d) => d in a),
|
|
245
|
+
...se.filter((d) => d in a)
|
|
246
|
+
];
|
|
247
|
+
for (const d of u) {
|
|
248
|
+
const p = a[d];
|
|
249
|
+
!p || typeof p != "object" || e.push(
|
|
250
|
+
R({
|
|
251
|
+
apiId: s,
|
|
252
|
+
apiTitle: o,
|
|
253
|
+
path: c,
|
|
254
|
+
method: d,
|
|
255
|
+
op: p,
|
|
256
|
+
pathItem: a,
|
|
257
|
+
globalSchemes: i,
|
|
258
|
+
apiSecurity: n.security
|
|
259
|
+
})
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
const l = a.additionalOperations;
|
|
263
|
+
if (l && typeof l == "object")
|
|
264
|
+
for (const [d, p] of Object.entries(l))
|
|
265
|
+
!p || typeof p != "object" || e.push(
|
|
266
|
+
R({
|
|
267
|
+
apiId: s,
|
|
268
|
+
apiTitle: o,
|
|
269
|
+
path: c,
|
|
270
|
+
method: d,
|
|
271
|
+
op: p,
|
|
272
|
+
pathItem: a,
|
|
273
|
+
globalSchemes: i,
|
|
274
|
+
apiSecurity: n.security
|
|
275
|
+
})
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return e;
|
|
280
|
+
}
|
|
281
|
+
function le(t) {
|
|
282
|
+
const e = [], n = [
|
|
283
|
+
{ list: t.queryParameters, loc: "query" },
|
|
284
|
+
{ list: t.headers, loc: "header" },
|
|
285
|
+
{ list: t.cookies, loc: "cookie" },
|
|
286
|
+
{ list: t.pathParameters, loc: "path" }
|
|
287
|
+
];
|
|
288
|
+
for (const { list: o, loc: s } of n)
|
|
289
|
+
for (const i of o)
|
|
290
|
+
if ("key" in i) {
|
|
291
|
+
const r = i;
|
|
292
|
+
e.push({
|
|
293
|
+
name: r.key,
|
|
294
|
+
in: s,
|
|
295
|
+
required: !1
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return e;
|
|
299
|
+
}
|
|
300
|
+
function de(t) {
|
|
301
|
+
const e = t.id, n = t.info?.title ?? "Untitled Collection", o = w(t.info?.description ?? t.info?.summary ?? "");
|
|
302
|
+
return {
|
|
303
|
+
id: `collection:${e}`,
|
|
304
|
+
text: S([n, o].filter(Boolean).join(" ")),
|
|
305
|
+
payload: {
|
|
306
|
+
type: "collection",
|
|
307
|
+
id: `collection:${e}`,
|
|
308
|
+
contentHash: "",
|
|
309
|
+
title: n,
|
|
310
|
+
description: o || void 0,
|
|
311
|
+
collectionId: e
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function ue(t) {
|
|
316
|
+
const { collectionId: e, collectionTitle: n, workflow: o } = t, s = o.workflowId ?? "", i = o.summary ?? s, r = w(o.description ?? ""), c = [n, i, r];
|
|
317
|
+
if (o.inputs && c.push(`Inputs schema: ${q(o.inputs)}`), o.outputs?.length) {
|
|
318
|
+
const a = o.outputs.map((u) => u.key).filter(Boolean);
|
|
319
|
+
a.length && c.push(`Outputs: ${a.join(", ")}`);
|
|
320
|
+
}
|
|
321
|
+
return o.dependsOn?.length && c.push(`Depends on: ${o.dependsOn.join(", ")}`), {
|
|
322
|
+
id: `workflow:${e}:${s}`,
|
|
323
|
+
text: S(c.filter(Boolean).join(" ")),
|
|
324
|
+
payload: {
|
|
325
|
+
type: "workflow",
|
|
326
|
+
id: `workflow:${e}:${s}`,
|
|
327
|
+
contentHash: "",
|
|
328
|
+
title: i,
|
|
329
|
+
description: r || void 0,
|
|
330
|
+
collectionId: e,
|
|
331
|
+
workflowId: s
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function pe(t) {
|
|
336
|
+
const { collectionId: e, collectionTitle: n, workflowId: o, workflowTitle: s, step: i } = t, r = i.stepId ?? "", c = w(i.description ?? ""), a = i.operation, u = i.xOperation, l = [n, s, `step: ${r}`];
|
|
337
|
+
c && l.push(c), a ? (l.push(`${a.method?.toUpperCase()} ${a.path}`), a.apiId && l.push(`API: ${a.apiId}`), a.operationId && l.push(`operationId: ${a.operationId}`)) : u && l.push(`${u.method?.toUpperCase()} ${u.url}`);
|
|
338
|
+
const d = i.parameters ? le(i.parameters) : [];
|
|
339
|
+
d.length > 0 && l.push(`Parameters: ${d.map(J).join(". ")}.`), i.requestBody?.type && l.push(`Request body type: ${i.requestBody.type}`);
|
|
340
|
+
const m = (i.successCriteria ?? []).map((h) => {
|
|
341
|
+
let x = h.condition;
|
|
342
|
+
return h.context && (x += ` context: ${h.context}`), h.type && (x += ` (${h.type})`), x;
|
|
343
|
+
});
|
|
344
|
+
if (m.length > 0 && l.push(`Success criteria: ${m.join("; ")}`), i.outputs?.length) {
|
|
345
|
+
const h = i.outputs.map((x) => `${x.key}=${x.value}`).filter(Boolean);
|
|
346
|
+
h.length && l.push(`Outputs: ${h.join(", ")}`);
|
|
347
|
+
}
|
|
348
|
+
const g = `step:${e}:${o}:${r}`;
|
|
349
|
+
return {
|
|
350
|
+
id: g,
|
|
351
|
+
text: S(l.filter(Boolean).join(" ")),
|
|
352
|
+
payload: {
|
|
353
|
+
type: "step",
|
|
354
|
+
id: g,
|
|
355
|
+
contentHash: "",
|
|
356
|
+
title: r,
|
|
357
|
+
description: c || void 0,
|
|
358
|
+
collectionId: e,
|
|
359
|
+
workflowId: o,
|
|
360
|
+
stepId: r,
|
|
361
|
+
path: a?.path ?? u?.url,
|
|
362
|
+
method: (a?.method ?? u?.method)?.toUpperCase(),
|
|
363
|
+
apiId: a?.apiId,
|
|
364
|
+
operationId: a?.operationId,
|
|
365
|
+
parameterDetails: d.length > 0 ? d : void 0,
|
|
366
|
+
successCriteria: m.length > 0 ? m : void 0,
|
|
367
|
+
requestBodySchema: i.requestBody?.type ? q(i.requestBody) : void 0
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function Q(t) {
|
|
372
|
+
const e = [];
|
|
373
|
+
for (const n of t) {
|
|
374
|
+
const o = n.id, s = n.info?.title ?? "Untitled Collection";
|
|
375
|
+
e.push(de(n));
|
|
376
|
+
for (const i of n.workflows ?? []) {
|
|
377
|
+
e.push(ue({ collectionId: o, collectionTitle: s, workflow: i }));
|
|
378
|
+
const r = i.workflowId ?? "", c = i.summary ?? r;
|
|
379
|
+
for (const a of i.steps ?? [])
|
|
380
|
+
e.push(
|
|
381
|
+
pe({ collectionId: o, collectionTitle: s, workflowId: r, workflowTitle: c, step: a })
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return e;
|
|
386
|
+
}
|
|
387
|
+
function fe(t, e) {
|
|
388
|
+
return [...L(t), ...Q(e)];
|
|
389
|
+
}
|
|
390
|
+
const O = 10, he = 4;
|
|
391
|
+
function H(t) {
|
|
392
|
+
let e = 0;
|
|
393
|
+
for (let n = 0; n < t.length; n++)
|
|
394
|
+
e = (e << 5) - e + t.charCodeAt(n) | 0;
|
|
395
|
+
return e >>> 0;
|
|
396
|
+
}
|
|
397
|
+
function me(t) {
|
|
398
|
+
return W(X(t));
|
|
399
|
+
}
|
|
400
|
+
const ye = {};
|
|
401
|
+
class xe extends z {
|
|
402
|
+
constructor(e) {
|
|
403
|
+
super(), this.collectionName = e;
|
|
404
|
+
}
|
|
405
|
+
collectionName;
|
|
406
|
+
activeIndexJobs = 0;
|
|
407
|
+
getIndexingActivityState() {
|
|
408
|
+
return { inProgress: this.activeIndexJobs > 0 };
|
|
409
|
+
}
|
|
410
|
+
beginIndexJob() {
|
|
411
|
+
this.activeIndexJobs++, this.activeIndexJobs === 1 && this.emit("indexing-activity", { inProgress: !0 });
|
|
412
|
+
}
|
|
413
|
+
endIndexJob() {
|
|
414
|
+
this.activeIndexJobs = Math.max(0, this.activeIndexJobs - 1), this.activeIndexJobs === 0 && this.emit("indexing-activity", { inProgress: !1 });
|
|
415
|
+
}
|
|
416
|
+
async getIdsByPayload(e, n) {
|
|
417
|
+
return f("semantic_search_get_ids_by_payload", {
|
|
418
|
+
collectionName: this.collectionName,
|
|
419
|
+
field: e,
|
|
420
|
+
value: n
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
async getAllIds() {
|
|
424
|
+
return f("semantic_search_get_all_ids", {
|
|
425
|
+
collectionName: this.collectionName
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
async getScopeHashes(e) {
|
|
429
|
+
const n = e.apiIds ?? [], o = e.collectionIds ?? [];
|
|
430
|
+
let s;
|
|
431
|
+
if (n.length === 0 && o.length === 0)
|
|
432
|
+
s = await this.getAllIds();
|
|
433
|
+
else {
|
|
434
|
+
const r = [];
|
|
435
|
+
for (const a of n)
|
|
436
|
+
r.push(this.getIdsByPayload("apiId", a));
|
|
437
|
+
for (const a of o)
|
|
438
|
+
r.push(this.getIdsByPayload("collectionId", a));
|
|
439
|
+
s = (await Promise.all(r)).flat();
|
|
440
|
+
}
|
|
441
|
+
const i = /* @__PURE__ */ new Map();
|
|
442
|
+
for (const r of s)
|
|
443
|
+
i.set(r.id, r.contentHash);
|
|
444
|
+
return i;
|
|
445
|
+
}
|
|
446
|
+
async indexDocuments(e, n) {
|
|
447
|
+
if (e.length === 0 && !n)
|
|
448
|
+
return { added: 0, updated: 0, removed: 0, unchanged: 0 };
|
|
449
|
+
const o = await this.getScopeHashes(n ?? {}), s = [], i = /* @__PURE__ */ new Set();
|
|
450
|
+
let r = 0, c = 0;
|
|
451
|
+
for (const l of e) {
|
|
452
|
+
const d = me(l.text);
|
|
453
|
+
l.payload.contentHash = d, i.add(l.id);
|
|
454
|
+
const p = o.get(l.id);
|
|
455
|
+
p === d ? c++ : (p || r++, s.push(l));
|
|
456
|
+
}
|
|
457
|
+
const a = s.length - r, u = [];
|
|
458
|
+
for (const l of o.keys())
|
|
459
|
+
i.has(l) || u.push(l);
|
|
460
|
+
if (u.length > 0 || s.length > 0) {
|
|
461
|
+
this.beginIndexJob();
|
|
462
|
+
try {
|
|
463
|
+
u.length > 0 && await this.deletePoints(u.map(H)), s.length > 0 && await this.embedAndUpsert(s), await this.flush();
|
|
464
|
+
} finally {
|
|
465
|
+
this.endIndexJob();
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return { added: r, updated: a, removed: u.length, unchanged: c };
|
|
469
|
+
}
|
|
470
|
+
async removeByPayloadFilter(e, n) {
|
|
471
|
+
return f("semantic_search_delete_by_payload", {
|
|
472
|
+
collectionName: this.collectionName,
|
|
473
|
+
field: e,
|
|
474
|
+
value: n
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
async getStoredDocumentCount() {
|
|
478
|
+
try {
|
|
479
|
+
return (await f(
|
|
480
|
+
"plugin:velesdb|list_collections"
|
|
481
|
+
))?.find((o) => o.name === this.collectionName)?.count ?? 0;
|
|
482
|
+
} catch {
|
|
483
|
+
return 0;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
async getDocumentsByIds(e) {
|
|
487
|
+
if (e.length === 0) return /* @__PURE__ */ new Map();
|
|
488
|
+
const n = e.map(H), o = await f(
|
|
489
|
+
"plugin:velesdb|get_points",
|
|
490
|
+
{
|
|
491
|
+
request: {
|
|
492
|
+
collection: this.collectionName,
|
|
493
|
+
ids: n
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
), s = /* @__PURE__ */ new Map();
|
|
497
|
+
for (const i of o ?? [])
|
|
498
|
+
if (i?.payload) {
|
|
499
|
+
const r = i.payload;
|
|
500
|
+
r.id && s.set(r.id, r);
|
|
501
|
+
}
|
|
502
|
+
return s;
|
|
503
|
+
}
|
|
504
|
+
async embedAndUpsert(e) {
|
|
505
|
+
const n = [], o = e.length;
|
|
506
|
+
for (let s = 0; s < o; s += O)
|
|
507
|
+
n.push({
|
|
508
|
+
docs: e.slice(s, s + O),
|
|
509
|
+
index: Math.floor(s / O)
|
|
510
|
+
});
|
|
511
|
+
await K(n, he, async (s) => {
|
|
512
|
+
const i = s.docs.map((r) => ({
|
|
513
|
+
id: r.id,
|
|
514
|
+
text: r.text || r.payload.title,
|
|
515
|
+
payload: r.payload
|
|
516
|
+
}));
|
|
517
|
+
await f("semantic_search_embed_and_upsert", {
|
|
518
|
+
collectionName: this.collectionName,
|
|
519
|
+
documents: i
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
async deletePoints(e) {
|
|
524
|
+
e.length !== 0 && await f("plugin:velesdb|delete_points", {
|
|
525
|
+
request: {
|
|
526
|
+
collection: this.collectionName,
|
|
527
|
+
ids: e
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
async flush() {
|
|
532
|
+
await f("plugin:velesdb|flush", { name: this.collectionName }), await f("semantic_search_write_hnsw_marker", {
|
|
533
|
+
collectionName: this.collectionName
|
|
534
|
+
}).catch(() => {
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
const M = "replay_search", Ie = 384, $ = {
|
|
539
|
+
added: 0,
|
|
540
|
+
updated: 0,
|
|
541
|
+
removed: 0,
|
|
542
|
+
unchanged: 0
|
|
543
|
+
};
|
|
544
|
+
function P(t) {
|
|
545
|
+
return t.added + t.updated > 0;
|
|
546
|
+
}
|
|
547
|
+
class ge extends z {
|
|
548
|
+
initialized = !1;
|
|
549
|
+
projectId = null;
|
|
550
|
+
indexer = null;
|
|
551
|
+
indexQueue = Promise.resolve();
|
|
552
|
+
get collectionName() {
|
|
553
|
+
return this.projectId ? `${M}_${this.projectId}` : M;
|
|
554
|
+
}
|
|
555
|
+
createIndexer() {
|
|
556
|
+
const e = new xe(this.collectionName);
|
|
557
|
+
return e.subscribe("indexing-activity", (n) => {
|
|
558
|
+
this.emit("indexing-activity", n);
|
|
559
|
+
}), e;
|
|
560
|
+
}
|
|
561
|
+
getIndexer() {
|
|
562
|
+
return this.indexer || (this.indexer = this.createIndexer()), this.indexer;
|
|
563
|
+
}
|
|
564
|
+
getIndexingActivityState() {
|
|
565
|
+
return this.getIndexer().getIndexingActivityState();
|
|
566
|
+
}
|
|
567
|
+
async ensureInitialized() {
|
|
568
|
+
this.initialized || await this.init();
|
|
569
|
+
}
|
|
570
|
+
enqueueIndex(e, n) {
|
|
571
|
+
const s = this.indexQueue.then(() => e()).then(async (i) => (n(i) && await this.unloadModel(), i)).catch(async (i) => {
|
|
572
|
+
throw console.error("Semantic index:", i), await this.unloadModel(), i;
|
|
573
|
+
});
|
|
574
|
+
return this.indexQueue = s.catch(() => {
|
|
575
|
+
}), s;
|
|
576
|
+
}
|
|
577
|
+
async unloadModel() {
|
|
578
|
+
try {
|
|
579
|
+
await f("semantic_search_unload_model");
|
|
580
|
+
} catch {
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
setProject(e) {
|
|
584
|
+
this.projectId !== e && (this.projectId = e, this.initialized = !1, this.indexer = this.createIndexer());
|
|
585
|
+
}
|
|
586
|
+
async init() {
|
|
587
|
+
if (y() && !this.initialized) {
|
|
588
|
+
try {
|
|
589
|
+
if ((await f("plugin:velesdb|list_collections"))?.some((n) => n.name === this.collectionName)) {
|
|
590
|
+
this.initialized = !0;
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
} catch {
|
|
594
|
+
}
|
|
595
|
+
await f("plugin:velesdb|create_collection", {
|
|
596
|
+
request: {
|
|
597
|
+
name: this.collectionName,
|
|
598
|
+
dimension: Ie,
|
|
599
|
+
metric: "cosine",
|
|
600
|
+
storage_mode: "full"
|
|
601
|
+
}
|
|
602
|
+
}), this.initialized = !0;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
async indexApis(e) {
|
|
606
|
+
if (!y()) return $;
|
|
607
|
+
const n = this.collectionName, o = this.getIndexer(), s = L(e), i = { apiIds: e.map((r) => r.id) };
|
|
608
|
+
return await this.ensureInitialized(), this.enqueueIndex(async () => this.collectionName !== n ? $ : o.indexDocuments(s, i), P);
|
|
609
|
+
}
|
|
610
|
+
async indexCollections(e) {
|
|
611
|
+
if (!y()) return $;
|
|
612
|
+
const n = this.collectionName, o = this.getIndexer(), s = Q(e), i = { collectionIds: e.map((r) => r.id) };
|
|
613
|
+
return await this.ensureInitialized(), this.enqueueIndex(async () => this.collectionName !== n ? $ : o.indexDocuments(s, i), P);
|
|
614
|
+
}
|
|
615
|
+
async removeApi(e) {
|
|
616
|
+
if (!y()) return;
|
|
617
|
+
const n = this.getIndexer();
|
|
618
|
+
await this.ensureInitialized(), await this.enqueueIndex(
|
|
619
|
+
() => n.removeByPayloadFilter("apiId", e),
|
|
620
|
+
() => !1
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
async removeCollection(e) {
|
|
624
|
+
if (!y()) return;
|
|
625
|
+
const n = this.getIndexer();
|
|
626
|
+
await this.ensureInitialized(), await this.enqueueIndex(
|
|
627
|
+
() => n.removeByPayloadFilter("collectionId", e),
|
|
628
|
+
() => !1
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
async reindex(e) {
|
|
632
|
+
if (!y()) return $;
|
|
633
|
+
const n = this.collectionName, o = this.getIndexer();
|
|
634
|
+
return await this.ensureInitialized(), this.enqueueIndex(async () => {
|
|
635
|
+
if (this.collectionName !== n) return $;
|
|
636
|
+
const { apis: s, collections: i } = e(), r = fe(s, i);
|
|
637
|
+
return o.indexDocuments(r, ye);
|
|
638
|
+
}, P);
|
|
639
|
+
}
|
|
640
|
+
async search(e, n = 10, o) {
|
|
641
|
+
if (!y()) return [];
|
|
642
|
+
try {
|
|
643
|
+
await this.ensureInitialized();
|
|
644
|
+
const s = o && Object.keys(o).length > 0 ? {
|
|
645
|
+
type: o.type,
|
|
646
|
+
apiId: o.apiId,
|
|
647
|
+
collectionId: o.collectionId,
|
|
648
|
+
path: o.path,
|
|
649
|
+
method: o.method,
|
|
650
|
+
operationId: o.operationId,
|
|
651
|
+
workflowId: o.workflowId,
|
|
652
|
+
stepId: o.stepId
|
|
653
|
+
} : void 0, r = ((await f("semantic_search_text", {
|
|
654
|
+
collection: this.collectionName,
|
|
655
|
+
query: e,
|
|
656
|
+
topK: n,
|
|
657
|
+
filters: s
|
|
658
|
+
})).results ?? []).map((c) => ({
|
|
659
|
+
...c.payload,
|
|
660
|
+
score: c.score ?? 0
|
|
661
|
+
}));
|
|
662
|
+
return await this.enrichWithRelatedSecurity(r), r;
|
|
663
|
+
} catch {
|
|
664
|
+
return [];
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
async enrichWithRelatedSecurity(e) {
|
|
668
|
+
const n = e.filter(
|
|
669
|
+
(i) => i.type === "api_operation" && i.securitySchemeRefs?.length
|
|
670
|
+
);
|
|
671
|
+
if (n.length === 0) return;
|
|
672
|
+
const o = [...new Set(n.flatMap((i) => i.securitySchemeRefs ?? []))], s = await this.getIndexer().getDocumentsByIds(o);
|
|
673
|
+
for (const i of n) {
|
|
674
|
+
const r = [];
|
|
675
|
+
for (const c of i.securitySchemeRefs ?? []) {
|
|
676
|
+
const a = s.get(c);
|
|
677
|
+
a?.securityScheme && r.push(a.securityScheme);
|
|
678
|
+
}
|
|
679
|
+
r.length > 0 && (i.relatedSecuritySchemes = r);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
async status() {
|
|
683
|
+
if (!y()) return { indexed: 0, modelLoaded: !1 };
|
|
684
|
+
const e = await this.getIndexer().getStoredDocumentCount();
|
|
685
|
+
let n = !1;
|
|
686
|
+
try {
|
|
687
|
+
n = (await f("semantic_search_model_status")).loaded;
|
|
688
|
+
} catch {
|
|
689
|
+
}
|
|
690
|
+
return { indexed: e, modelLoaded: n };
|
|
691
|
+
}
|
|
692
|
+
async clear() {
|
|
693
|
+
if (!(!y() || !this.initialized))
|
|
694
|
+
try {
|
|
695
|
+
await f("plugin:velesdb|delete_collection", { name: this.collectionName }), this.initialized = !1;
|
|
696
|
+
} catch {
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
async preloadModel() {
|
|
700
|
+
if (y())
|
|
701
|
+
try {
|
|
702
|
+
await f("semantic_search_preload_model");
|
|
703
|
+
} catch {
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
let j = null;
|
|
708
|
+
function be() {
|
|
709
|
+
return j || (j = new ge()), j;
|
|
710
|
+
}
|
|
711
|
+
export {
|
|
712
|
+
ge as S,
|
|
713
|
+
L as a,
|
|
714
|
+
Q as b,
|
|
715
|
+
ae as c,
|
|
716
|
+
R as d,
|
|
717
|
+
fe as e,
|
|
718
|
+
ee as f,
|
|
719
|
+
be as g,
|
|
720
|
+
de as h,
|
|
721
|
+
pe as i,
|
|
722
|
+
ue as j
|
|
723
|
+
};
|