@redocly/replay 0.29.0 → 0.30.0-next.1
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-BZVskloQ.js → replay-AiChatProvider-BY1M1rCj.js} +6 -6
- package/dist/{replay-AiChatProvider-BRnZ3wFV.js → replay-AiChatProvider-DBLnNCF8.js} +1 -1
- package/dist/{replay-AiChatSqliteDBStorage-D-OSPwkJ.js → replay-AiChatSqliteDBStorage-B978zufl.js} +1 -1
- package/dist/{replay-AiChatSqliteDBStorage-Ditvzorg.js → replay-AiChatSqliteDBStorage-BW2-RW_n.js} +1 -1
- package/dist/{replay-AiPanel-CoeevBXl.js → replay-AiPanel-8K1Nn8fs.js} +1 -1
- package/dist/{replay-AiPanel-CxcQiAtp.js → replay-AiPanel-Cc1hhJJ-.js} +4 -4
- package/dist/{replay-FileWatcher-CT1GjrWt.js → replay-FileWatcher-DpvlfPhp.js} +1 -1
- package/dist/{replay-FileWatcher-BFxdt7pW.js → replay-FileWatcher-mQb0WIRZ.js} +2 -2
- package/dist/replay-SemanticSearchService-D4-a07SY.js +1 -0
- package/dist/{replay-SemanticSearchService-CAmU7U_y.js → replay-SemanticSearchService-Q083tFCJ.js} +7 -10
- package/dist/{replay-SqliteDBStorage-B7cctBN4.js → replay-SqliteDBStorage-BdEDqBaQ.js} +1 -1
- package/dist/{replay-SqliteDBStorage-GDF8VnpW.js → replay-SqliteDBStorage-CGB2CnXm.js} +1 -1
- package/dist/{replay-TauriFileSystemAdapter-CQ68d1Rb.js → replay-TauriFileSystemAdapter-BlpeI6I1.js} +1 -1
- package/dist/{replay-TauriFileSystemAdapter-Bedrv_1E.js → replay-TauriFileSystemAdapter-DrnMzlvI.js} +1 -1
- package/dist/{replay-TauriRootStorage-DWs71c6J.js → replay-TauriRootStorage-CY9J7SvB.js} +3 -3
- package/dist/{replay-TauriRootStorage-BDHfRxBb.js → replay-TauriRootStorage-PRPSPxCM.js} +1 -1
- package/dist/{replay-agent-loop-B9Ku1GMV.js → replay-agent-loop-DOsYsIM_.js} +1 -1
- package/dist/{replay-agent-loop-DZFx7mbI.js → replay-agent-loop-DUaYektB.js} +5 -5
- package/dist/{replay-ai-chat-mappers-DVWjxhhO.js → replay-ai-chat-mappers-BS6gpCNe.js} +1 -1
- package/dist/{replay-ai-chat-mappers-Dm3VfVbf.js → replay-ai-chat-mappers-DawVbG8E.js} +1 -1
- package/dist/{replay-create-model-EqVbPv70.js → replay-create-model-CS4PGJpF.js} +3 -3
- package/dist/{replay-create-model-jiStWNur.js → replay-create-model-D9OW8YQ7.js} +3 -3
- package/dist/{replay-db-Cfh97P75.js → replay-db-BPQqGDf6.js} +1 -1
- package/dist/{replay-db-G0nB5gsK.js → replay-db-YMhgrG6n.js} +1 -1
- package/dist/{replay-external-resolver-CZt2-zxn.js → replay-external-resolver-BuY7tjwA.js} +1 -1
- package/dist/{replay-external-resolver-C4lPwG0y.js → replay-external-resolver-C8RUKQAF.js} +2 -2
- package/dist/{replay-index-RAwADWgR.js → replay-index-B1ISf2Pd.js} +1 -1
- package/dist/{replay-index-B8FrKhrK.js → replay-index-BEVJgOvG.js} +1 -1
- package/dist/{replay-index-CydD_1AG.js → replay-index-BYt60V1u.js} +1 -1
- package/dist/{replay-index-B0ZnzCe0.js → replay-index-BrETb_LJ.js} +19943 -19695
- package/dist/{replay-index-DHpZ_Le1.js → replay-index-CR-63S4F.js} +1116 -1110
- package/dist/{replay-index-C63_26_M.js → replay-index-CUoi3zH7.js} +1 -1
- package/dist/{replay-index-NXYTGvpg.js → replay-index-D01cQRy8.js} +5 -5
- package/dist/{replay-index-CZdITmUC.js → replay-index-DajpN2Kv.js} +1 -1
- package/dist/replay-index-Dc7Zy4VK.js +4 -0
- package/dist/{replay-index-0tBOBdqi.js → replay-index-DuaHxlY6.js} +1 -1
- package/dist/{replay-index-BsW8ar_B.js → replay-index-UCGdLDWp.js} +1 -1
- package/dist/{replay-index-CoTPFQOh.js → replay-index-j2-k1BLA.js} +1 -1
- package/dist/{replay-lint-4jQiEXbI.js → replay-lint-BHA72Tm6.js} +3 -3
- package/dist/{replay-lint-r3bg254e.js → replay-lint-C1ehvXFt.js} +3 -3
- package/dist/{replay-lint-graphql-D2aLmlID.js → replay-lint-graphql-ClVK-Q9m.js} +2 -2
- package/dist/{replay-lint-graphql-AKeELyXP.js → replay-lint-graphql-Dujr-fEy.js} +1 -1
- package/dist/{replay-periodic-revalidation-BgBN4Mbs.js → replay-periodic-revalidation-CQucebne.js} +1 -1
- package/dist/{replay-periodic-revalidation-BRgz4X4a.js → replay-periodic-revalidation-DWUDnmI5.js} +1 -1
- package/dist/replay-promise-map-limit-DDfN3Ygo.js +1 -0
- package/dist/replay-promise-map-limit-DglaAlWc.js +18 -0
- package/dist/{replay-resolve-VJqotAvd.js → replay-resolve-DQkGMS79.js} +1 -1
- package/dist/{replay-resolve-DAJqvo5v.js → replay-resolve-lOnMmrS0.js} +1 -1
- package/dist/{replay-respect-run-DSgF-V0V.js → replay-respect-run-CFRoqQim.js} +3 -3
- package/dist/{replay-respect-run-DH5fR2k2.js → replay-respect-run-VZCFofle.js} +1 -1
- package/dist/{replay-tauri-path-BIdG-8R5.js → replay-tauri-path-DYdSowVf.js} +1 -1
- package/dist/{replay-tauri-path-BuBah8TT.js → replay-tauri-path-DZEIwFxv.js} +2 -2
- package/dist/{replay-useAiChatQueries-BB_Ztjxo.js → replay-useAiChatQueries-Ad3LDWfS.js} +12 -12
- package/dist/{replay-useAiChatQueries-D1isJXlL.js → replay-useAiChatQueries-C7kgDcqd.js} +454 -459
- package/dist/{replay-validate-key-BeE2055s.js → replay-validate-key-BewHEjjp.js} +1 -1
- package/dist/{replay-validate-key-BksJSjZL.js → replay-validate-key-Ck5j2ty0.js} +2 -2
- package/dist/replay.cjs +1 -1
- package/dist/replay.d.ts +9 -0
- package/dist/replay.js +1 -1
- package/package.json +2 -3
- package/dist/replay-SemanticSearchService-DTzvCAEY.js +0 -1
- package/dist/replay-index-B-s3dkqs.js +0 -4
- package/dist/replay-promise-map-limit-DRDkHc-b.js +0 -1
- package/dist/replay-promise-map-limit-Db_42GvV.js +0 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./replay-create-model-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./replay-create-model-D9OW8YQ7.js"),n=require("./replay-index-CR-63S4F.js"),l=require("./replay-defaults-DVvOnvnR.js");async function s(t,a,o,i){try{const e=r.createModel({provider:t,modelId:o,apiKey:a});return await r.generateText({model:e,prompt:l.VALIDATION_PROMPT,maxOutputTokens:n.MAX_OUTPUT_TOKENS_FOR_VALIDATION,abortSignal:i?.abortSignal}),{valid:!0}}catch(e){if(e instanceof Error&&e.name==="AbortError")throw e;return{valid:!1,error:e instanceof Error&&e.message.length>0?e.message:"Validation failed. Please try again."}}}exports.validateApiKey=s;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as i, g as n } from "./replay-create-model-
|
|
2
|
-
import { M as s } from "./replay-index-
|
|
1
|
+
import { c as i, g as n } from "./replay-create-model-CS4PGJpF.js";
|
|
2
|
+
import { M as s } from "./replay-index-BrETb_LJ.js";
|
|
3
3
|
import { V as l } from "./replay-defaults-CzR6jw9a.js";
|
|
4
4
|
async function g(a, e, t, o) {
|
|
5
5
|
try {
|
package/dist/replay.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./replay-index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./replay-index-CR-63S4F.js"),t=require("./replay-oauth2-redirect-handler-BfZRvm6l.js");exports.AI_PROVIDERS=e.AI_PROVIDERS;exports.AiPanelContext=e.AiPanelContext;exports.EmbeddedReplay=e.EmbeddedReplay;exports.Modal=e.Modal;exports.REUNITE_AI_PROVIDER=e.REUNITE_AI_PROVIDER;exports.Replay=e.Replay;exports.ReplayOverlay=e.ReplayOverlay;Object.defineProperty(exports,"SpanStatusCode",{enumerable:!0,get:()=>e.SpanStatusCode});exports.TelemetryClient=e.TelemetryClient;exports.applyThemeToDOM=e.applyThemeToDOM;exports.createResource=e.createResource;exports.getCurrentTheme=e.getCurrentTheme;exports.loadAgentLoop=e.loadAgentLoop;exports.makeProviderRecord=e.makeProviderRecord;exports.resolveTheme=e.resolveTheme;exports.useAiPanel=e.useAiPanel;exports.useTelemetry=e.useTelemetry;exports.useTelemetryClient=e.useTelemetryClient;exports.validateApiKey=e.validateApiKey;exports.OAuth2Error=t.OAuth2Error;exports.handleOAuth2Redirect=t.handleOAuth2Redirect;
|
package/dist/replay.d.ts
CHANGED
|
@@ -164,6 +164,14 @@ declare type EndpointModel = {
|
|
|
164
164
|
accessToken: string;
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
+
declare type FormFieldEncoding = {
|
|
168
|
+
style?: string;
|
|
169
|
+
explode?: boolean;
|
|
170
|
+
allowReserved?: boolean;
|
|
171
|
+
contentType?: string;
|
|
172
|
+
headers?: Record<string, string>;
|
|
173
|
+
};
|
|
174
|
+
|
|
167
175
|
export declare function getCurrentTheme(): ResolvedTheme;
|
|
168
176
|
|
|
169
177
|
declare type GetOperationURLFunction = (operationId?: string) => string | undefined;
|
|
@@ -238,6 +246,7 @@ declare type MediaType = {
|
|
|
238
246
|
name: string;
|
|
239
247
|
example: string;
|
|
240
248
|
}[];
|
|
249
|
+
encoding?: Record<string, FormFieldEncoding>;
|
|
241
250
|
};
|
|
242
251
|
|
|
243
252
|
declare type MediaTypes = {
|
package/dist/replay.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as s, ax as r, bQ as t, bR as l, R as o, bS as b, bT as R, N as d, bU as m, bV as p, O as n, bW as y, bX as A, bY as T, bZ as i, aw as u, av as O, b_ as h, b$ as E } from "./replay-index-
|
|
1
|
+
import { A as s, ax as r, bQ as t, bR as l, R as o, bS as b, bT as R, N as d, bU as m, bV as p, O as n, bW as y, bX as A, bY as T, bZ as i, aw as u, av as O, b_ as h, b$ as E } from "./replay-index-BrETb_LJ.js";
|
|
2
2
|
import { O as C, h as I } from "./replay-oauth2-redirect-handler-Bq6bpZMm.js";
|
|
3
3
|
export {
|
|
4
4
|
s as AI_PROVIDERS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/replay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0-next.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/replay.cjs",
|
|
6
6
|
"module": "./dist/replay.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@redocly/theme": "0.
|
|
19
|
+
"@redocly/theme": "0.71.0-next.0",
|
|
20
20
|
"@tanstack/react-query": "5.62.3",
|
|
21
21
|
"react": "^19.2.7",
|
|
22
22
|
"react-dom": "^19.2.7",
|
|
@@ -67,7 +67,6 @@
|
|
|
67
67
|
"@types/json-pointer": "1.0.34",
|
|
68
68
|
"@types/marked": "4.3.2",
|
|
69
69
|
"@types/node": "24.1.0",
|
|
70
|
-
"@types/path-browserify": "^1.0.3",
|
|
71
70
|
"@types/react": "^19.2.7",
|
|
72
71
|
"@types/react-dom": "^19.2.3",
|
|
73
72
|
"@uiw/codemirror-theme-material": "^4.21.20",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const d=require("./replay-index-DHpZ_Le1.js"),H=require("./replay-Observable-bjJ6wkRB.js"),Z=require("./replay-promise-map-limit-DRDkHc-b.js");function g(t){return t==null?"":typeof t=="string"?t:typeof t=="object"&&"raw"in t&&typeof t.raw=="string"?t.raw:String(t)}function $(t){return t.replace(/\s+/g," ").trim()}function S(t){return typeof t=="object"&&t!==null&&"$ref"in t}function P(t){return S(t)?null:t}function q(t){try{return JSON.stringify(t)}catch{return String(t)}}function z(t){let e=`${t.name} (${t.in}`;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}function J(t){return t.type?Array.isArray(t.type)?t.type.join("|"):t.type:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":"object"}function V(t){return t==="querystring"?"query":t==="query"||t==="header"||t==="path"||t==="cookie"?t:"query"}function ee(t){const e=t.schema&&!S(t.schema)?t.schema:null,n={name:t.name,in:V(t.in),required:t.required??!1};return e&&(n.type=J(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=g(t.description)),t.example!==void 0&&!n.example&&(n.example=String(t.example)),n}function te(t,e){const n=new Set,o=[],s=i=>{for(const r of i){const c=P(r);if(!c||!c.name)continue;const a=`${c.in}:${c.name}`;n.has(a)||(n.add(a),o.push(ee(c)))}};return t.parameters&&s(t.parameters),e.parameters&&s(e.parameters),o}function U(t,e=2,n=0){if(n>=e||!t.properties)return[];const o=new Set(t.required??[]);return Object.entries(t.properties).map(([s,i])=>({name:s,type:J(i),required:o.has(s),readOnly:i.readOnly}))}function F(t){const e=t.components?.securitySchemes;if(!e)return[];const n=[];for(const[o,s]of Object.entries(e)){const i=P(s);i&&n.push(ne(o,i))}return n}function ne(t,e){const n={schemeName:t,type:e.type};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){const o=Object.keys(e.flows).filter(i=>e.flows[i]);o.length>0&&(n.flows=o.join(", "));const s=new Set;for(const i of o){const r=e.flows[i];r?.scopes&&Object.keys(r.scopes).forEach(c=>s.add(c))}s.size>0&&(n.scopes=[...s].join(", "))}return n}function ie(t,e,n){const o=t??e;if(!o||n.length===0)return[];const s=new Set;for(const i of o)for(const r of Object.keys(i))s.add(r);return n.filter(i=>s.has(i.schemeName))}function oe(t){return t.length===0?"":`Security: ${t.map(n=>{let o=`${n.schemeName} (${n.type}`;return n.scheme&&(o+=`, ${n.scheme}`),n.in&&n.name&&(o+=`, ${n.name} in ${n.in}`),o+=")",o}).join("; ")}.`}const se=["get","put","post","delete","options","head","patch","trace"],re=["query","x-query"];function ce(t,e){const n=[],o=Object.keys(t.content??{});if(o.length===0)return{textPart:"",schemaJson:"{}",examples:n};const s=o.find(u=>u.includes("json"))??o[0],i=t.content?.[s],r=i?.schema&&!S(i.schema)?i.schema:null,a=(r?U(r):[]).filter(u=>!e.hideReadOnly||!u.readOnly),p=t.required?"required":"optional";let l=`Request body (${s}, ${p})`;if(a.length>0){const u=a.map(f=>`${f.name}: ${f.type}${f.required?" required":""}${f.readOnly?" readOnly":""}`);l+=`: {${u.join(", ")}}`}return i?.example!==void 0&&n.push(q(i.example)),{textPart:l,schemaJson:JSON.stringify(a),examples:n}}function ae(t){const e=[],n=[];for(const[o,s]of Object.entries(t)){if(S(s))continue;const i=g(s.description??"");e.push(`${o} ${i}`.trim());const r={statusCode:o};i&&(r.description=i);const c=s.content;if(c){const a=Object.keys(c).find(l=>l.includes("json"))??Object.keys(c)[0],p=c[a]?.schema;if(p&&!S(p)){const l=U(p);l.length>0&&(r.schemaProperties=JSON.stringify(l))}}n.push(r)}return{textParts:e,summaries:n}}function D(t){const{apiId:e,apiTitle:n,path:o,method:s,op:i,pathItem:r,globalSchemes:c,apiSecurity:a}=t,p=i.summary??"",l=g(i.description??""),u=i.operationId??"",f=i.tags??[],m=s.toUpperCase(),I=te(i,r),h=ie(i.security,a,c),y=h.length>0?h.map(v=>`api_sec:${e}:${v.schemeName}`):void 0,x=[n,`${m} ${o}`,p,l];u&&x.push(`operationId: ${u}`),f.length>0&&x.push(`Tags: ${f.join(", ")}`),i.deprecated&&x.push("DEPRECATED"),I.length>0&&x.push(`Parameters: ${I.map(z).join(". ")}.`);let T;const _=[],j=i.requestBody;if(j){const v=P(j);if(v){const b=ce(v,{hideReadOnly:m==="POST"||m==="PUT"||m==="PATCH"});b.textPart&&x.push(b.textPart),T=b.schemaJson,_.push(...b.examples)}}const{textParts:A,summaries:B}=ae(i.responses??{});A.length>0&&x.push(`Responses: ${A.join(", ")}.`);const C=oe(h);C&&x.push(C);const E=`api_op:${e}:${o}:${s}:${u||`${o}-${s}`}`,Y={type:"api_operation",id:E,contentHash:"",title:p||`${m} ${o}`,description:l||void 0,apiId:e,path:o,method:m,operationId:u||void 0,tags:f.length>0?f:void 0,deprecated:i.deprecated||void 0,parameterDetails:I.length>0?I:void 0,requestBodySchema:T,responseSchemas:B.length>0?B:void 0,securitySchemeRefs:y,examples:_.length>0?_:void 0};return{id:E,text:$(x.filter(Boolean).join(" ")),payload:Y}}function L(t){const e=t.info?.title??"Untitled API",n=g(t.info?.description??t.info?.summary??""),o=t.id;return{id:`api:${o}`,text:$([e,n].filter(Boolean).join(" ")),payload:{type:"api",id:`api:${o}`,contentHash:"",title:e,description:n||void 0,apiId:o}}}function G(t){const e=[];for(const n of t){e.push(L(n));const o=n.info?.title??"Untitled API",s=n.id,i=F(n);for(const c of i){const a=`api_sec:${s}:${c.schemeName}`,p=[`${c.schemeName}: type=${c.type}`,c.scheme?`scheme=${c.scheme}`:"",c.in&&c.name?`${c.name} in ${c.in}`:"",c.bearerFormat?`format=${c.bearerFormat}`:"",c.flows?`flows=[${c.flows}]`:"",c.scopes?`scopes=[${c.scopes}]`:""].filter(Boolean).join(" ");e.push({id:a,text:$(`${o} Authentication. ${c.schemeName}. ${p}.`),payload:{type:"api_security",id:a,contentHash:"",title:`${o} — ${c.schemeName}`,apiId:s,securityScheme:c}})}const r=n.paths??{};for(const[c,a]of Object.entries(r)){if(!a||typeof a!="object")continue;const p=[...se.filter(u=>u in a),...re.filter(u=>u in a)];for(const u of p){const f=a[u];!f||typeof f!="object"||e.push(D({apiId:s,apiTitle:o,path:c,method:u,op:f,pathItem:a,globalSchemes:i,apiSecurity:n.security}))}const l=a.additionalOperations;if(l&&typeof l=="object")for(const[u,f]of Object.entries(l))!f||typeof f!="object"||e.push(D({apiId:s,apiTitle:o,path:c,method:u,op:f,pathItem:a,globalSchemes:i,apiSecurity:n.security}))}}return e}function le(t){const e=[],n=[{list:t.queryParameters,loc:"query"},{list:t.headers,loc:"header"},{list:t.cookies,loc:"cookie"},{list:t.pathParameters,loc:"path"}];for(const{list:o,loc:s}of n)for(const i of o)if("key"in i){const r=i;e.push({name:r.key,in:s,required:!1})}return e}function W(t){const e=t.id,n=t.info?.title??"Untitled Collection",o=g(t.info?.description??t.info?.summary??"");return{id:`collection:${e}`,text:$([n,o].filter(Boolean).join(" ")),payload:{type:"collection",id:`collection:${e}`,contentHash:"",title:n,description:o||void 0,collectionId:e}}}function Q(t){const{collectionId:e,collectionTitle:n,workflow:o}=t,s=o.workflowId??"",i=o.summary??s,r=g(o.description??""),c=[n,i,r];if(o.inputs&&c.push(`Inputs schema: ${q(o.inputs)}`),o.outputs?.length){const a=o.outputs.map(p=>p.key).filter(Boolean);a.length&&c.push(`Outputs: ${a.join(", ")}`)}return o.dependsOn?.length&&c.push(`Depends on: ${o.dependsOn.join(", ")}`),{id:`workflow:${e}:${s}`,text:$(c.filter(Boolean).join(" ")),payload:{type:"workflow",id:`workflow:${e}:${s}`,contentHash:"",title:i,description:r||void 0,collectionId:e,workflowId:s}}}function X(t){const{collectionId:e,collectionTitle:n,workflowId:o,workflowTitle:s,step:i}=t,r=i.stepId??"",c=g(i.description??""),a=i.operation,p=i.xOperation,l=[n,s,`step: ${r}`];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}`)):p&&l.push(`${p.method?.toUpperCase()} ${p.url}`);const u=i.parameters?le(i.parameters):[];u.length>0&&l.push(`Parameters: ${u.map(z).join(". ")}.`),i.requestBody?.type&&l.push(`Request body type: ${i.requestBody.type}`);const m=(i.successCriteria??[]).map(h=>{let y=h.condition;return h.context&&(y+=` context: ${h.context}`),h.type&&(y+=` (${h.type})`),y});if(m.length>0&&l.push(`Success criteria: ${m.join("; ")}`),i.outputs?.length){const h=i.outputs.map(y=>`${y.key}=${y.value}`).filter(Boolean);h.length&&l.push(`Outputs: ${h.join(", ")}`)}const I=`step:${e}:${o}:${r}`;return{id:I,text:$(l.filter(Boolean).join(" ")),payload:{type:"step",id:I,contentHash:"",title:r,description:c||void 0,collectionId:e,workflowId:o,stepId:r,path:a?.path??p?.url,method:(a?.method??p?.method)?.toUpperCase(),apiId:a?.apiId,operationId:a?.operationId,parameterDetails:u.length>0?u:void 0,successCriteria:m.length>0?m:void 0,requestBodySchema:i.requestBody?.type?q(i.requestBody):void 0}}}function K(t){const e=[];for(const n of t){const o=n.id,s=n.info?.title??"Untitled Collection";e.push(W(n));for(const i of n.workflows??[]){e.push(Q({collectionId:o,collectionTitle:s,workflow:i}));const r=i.workflowId??"",c=i.summary??r;for(const a of i.steps??[])e.push(X({collectionId:o,collectionTitle:s,workflowId:r,workflowTitle:c,step:a}))}}return e}function de(t,e){return[...G(t),...K(e)]}const N=10,ue=4;function R(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e>>>0}function pe(t){return d.bytesToHex(d.md5(t))}const fe={};class he extends H.Observable{constructor(e){super(),this.collectionName=e}collectionName;activeIndexJobs=0;getIndexingActivityState(){return{inProgress:this.activeIndexJobs>0}}beginIndexJob(){this.activeIndexJobs++,this.activeIndexJobs===1&&this.emit("indexing-activity",{inProgress:!0})}endIndexJob(){this.activeIndexJobs=Math.max(0,this.activeIndexJobs-1),this.activeIndexJobs===0&&this.emit("indexing-activity",{inProgress:!1})}async getIdsByPayload(e,n){return d.invoke$1("semantic_search_get_ids_by_payload",{collectionName:this.collectionName,field:e,value:n})}async getAllIds(){return d.invoke$1("semantic_search_get_all_ids",{collectionName:this.collectionName})}async getScopeHashes(e){const n=e.apiIds??[],o=e.collectionIds??[];let s;if(n.length===0&&o.length===0)s=await this.getAllIds();else{const r=[];for(const a of n)r.push(this.getIdsByPayload("apiId",a));for(const a of o)r.push(this.getIdsByPayload("collectionId",a));s=(await Promise.all(r)).flat()}const i=new Map;for(const r of s)i.set(r.id,r.contentHash);return i}async indexDocuments(e,n){if(e.length===0&&!n)return{added:0,updated:0,removed:0,unchanged:0};const o=await this.getScopeHashes(n??{}),s=[],i=new Set;let r=0,c=0;for(const l of e){const u=pe(l.text);l.payload.contentHash=u,i.add(l.id);const f=o.get(l.id);f===u?c++:(f||r++,s.push(l))}const a=s.length-r,p=[];for(const l of o.keys())i.has(l)||p.push(l);if(p.length>0||s.length>0){this.beginIndexJob();try{p.length>0&&await this.deletePoints(p.map(R)),s.length>0&&await this.embedAndUpsert(s),await this.flush()}finally{this.endIndexJob()}}return{added:r,updated:a,removed:p.length,unchanged:c}}async removeByPayloadFilter(e,n){return d.invoke$1("semantic_search_delete_by_payload",{collectionName:this.collectionName,field:e,value:n})}async getStoredDocumentCount(){try{return(await d.invoke$1("plugin:velesdb|list_collections"))?.find(o=>o.name===this.collectionName)?.count??0}catch{return 0}}async getDocumentsByIds(e){if(e.length===0)return new Map;const n=e.map(R),o=await d.invoke$1("plugin:velesdb|get_points",{request:{collection:this.collectionName,ids:n}}),s=new Map;for(const i of o??[])if(i?.payload){const r=i.payload;r.id&&s.set(r.id,r)}return s}async embedAndUpsert(e){const n=[],o=e.length;for(let s=0;s<o;s+=N)n.push({docs:e.slice(s,s+N),index:Math.floor(s/N)});await Z.promiseMapLimit(n,ue,async s=>{const i=s.docs.map(r=>({id:r.id,text:r.text||r.payload.title,payload:r.payload}));await d.invoke$1("semantic_search_embed_and_upsert",{collectionName:this.collectionName,documents:i})})}async deletePoints(e){e.length!==0&&await d.invoke$1("plugin:velesdb|delete_points",{request:{collection:this.collectionName,ids:e}})}async flush(){await d.invoke$1("plugin:velesdb|flush",{name:this.collectionName}),await d.invoke$1("semantic_search_write_hnsw_marker",{collectionName:this.collectionName}).catch(()=>{})}}const M="replay_search",me=384,w={added:0,updated:0,removed:0,unchanged:0};function k(t){return t.added+t.updated>0}class ye extends H.Observable{initialized=!1;projectId=null;indexer=null;indexQueue=Promise.resolve();get collectionName(){return this.projectId?`${M}_${this.projectId}`:M}createIndexer(){const e=new he(this.collectionName);return e.subscribe("indexing-activity",n=>{this.emit("indexing-activity",n)}),e}getIndexer(){return this.indexer||(this.indexer=this.createIndexer()),this.indexer}getIndexingActivityState(){return this.getIndexer().getIndexingActivityState()}async ensureInitialized(){this.initialized||await this.init()}enqueueIndex(e,n){const s=this.indexQueue.then(()=>e()).then(async i=>(n(i)&&await this.unloadModel(),i)).catch(async i=>{throw console.error("Semantic index:",i),await this.unloadModel(),i});return this.indexQueue=s.catch(()=>{}),s}async unloadModel(){try{await d.invoke$1("semantic_search_unload_model")}catch{}}setProject(e){this.projectId!==e&&(this.projectId=e,this.initialized=!1,this.indexer=this.createIndexer())}async init(){if(d.isTauriApp()&&!this.initialized){try{if((await d.invoke$1("plugin:velesdb|list_collections"))?.some(n=>n.name===this.collectionName)){this.initialized=!0;return}}catch{}await d.invoke$1("plugin:velesdb|create_collection",{request:{name:this.collectionName,dimension:me,metric:"cosine",storage_mode:"full"}}),this.initialized=!0}}async indexApis(e){if(!d.isTauriApp())return w;const n=this.collectionName,o=this.getIndexer(),s=G(e),i={apiIds:e.map(r=>r.id)};return await this.ensureInitialized(),this.enqueueIndex(async()=>this.collectionName!==n?w:o.indexDocuments(s,i),k)}async indexCollections(e){if(!d.isTauriApp())return w;const n=this.collectionName,o=this.getIndexer(),s=K(e),i={collectionIds:e.map(r=>r.id)};return await this.ensureInitialized(),this.enqueueIndex(async()=>this.collectionName!==n?w:o.indexDocuments(s,i),k)}async removeApi(e){if(!d.isTauriApp())return;const n=this.getIndexer();await this.ensureInitialized(),await this.enqueueIndex(()=>n.removeByPayloadFilter("apiId",e),()=>!1)}async removeCollection(e){if(!d.isTauriApp())return;const n=this.getIndexer();await this.ensureInitialized(),await this.enqueueIndex(()=>n.removeByPayloadFilter("collectionId",e),()=>!1)}async reindex(e){if(!d.isTauriApp())return w;const n=this.collectionName,o=this.getIndexer();return await this.ensureInitialized(),this.enqueueIndex(async()=>{if(this.collectionName!==n)return w;const{apis:s,collections:i}=e(),r=de(s,i);return o.indexDocuments(r,fe)},k)}async search(e,n=10,o){if(!d.isTauriApp())return[];try{await this.ensureInitialized();const s=o&&Object.keys(o).length>0?{type:o.type,apiId:o.apiId,collectionId:o.collectionId,path:o.path,method:o.method,operationId:o.operationId,workflowId:o.workflowId,stepId:o.stepId}:void 0,r=((await d.invoke$1("semantic_search_text",{collection:this.collectionName,query:e,topK:n,filters:s})).results??[]).map(c=>({...c.payload,score:c.score??0}));return await this.enrichWithRelatedSecurity(r),r}catch{return[]}}async enrichWithRelatedSecurity(e){const n=e.filter(i=>i.type==="api_operation"&&i.securitySchemeRefs?.length);if(n.length===0)return;const o=[...new Set(n.flatMap(i=>i.securitySchemeRefs??[]))],s=await this.getIndexer().getDocumentsByIds(o);for(const i of n){const r=[];for(const c of i.securitySchemeRefs??[]){const a=s.get(c);a?.securityScheme&&r.push(a.securityScheme)}r.length>0&&(i.relatedSecuritySchemes=r)}}async status(){if(!d.isTauriApp())return{indexed:0,modelLoaded:!1};const e=await this.getIndexer().getStoredDocumentCount();let n=!1;try{n=(await d.invoke$1("semantic_search_model_status")).loaded}catch{}return{indexed:e,modelLoaded:n}}async clear(){if(!(!d.isTauriApp()||!this.initialized))try{await d.invoke$1("plugin:velesdb|delete_collection",{name:this.collectionName}),this.initialized=!1}catch{}}async preloadModel(){if(d.isTauriApp())try{await d.invoke$1("semantic_search_preload_model")}catch{}}}let O=null;function xe(){return O||(O=new ye),O}exports.extractApiDocument=L;exports.extractCollectionDocument=W;exports.extractGlobalSecuritySchemes=F;exports.extractOperationDocument=D;exports.extractStepDocument=X;exports.extractWorkflowDocument=Q;exports.getSemanticSearchService=xe;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";async function m(t,s,c){const i=[],e=[];for(const r of t){const n=Promise.resolve().then(()=>c(r,t));if(i.push(n),s<=t.length){const o=n.then(()=>e.splice(e.indexOf(o),1));e.push(o),e.length>=s&&await Promise.race(e)}}return Promise.all(i)}exports.promiseMapLimit=m;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
async function r(t, n, c) {
|
|
2
|
-
const s = [], e = [];
|
|
3
|
-
for (const p of t) {
|
|
4
|
-
const i = Promise.resolve().then(() => c(p, t));
|
|
5
|
-
if (s.push(i), n <= t.length) {
|
|
6
|
-
const o = i.then(() => e.splice(e.indexOf(o), 1));
|
|
7
|
-
e.push(o), e.length >= n && await Promise.race(e);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return Promise.all(s);
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
r as p
|
|
14
|
-
};
|