@redocly/openapi-docs 3.25.0-next.4 → 3.25.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/{redocly-openapi-docs.min.AiChatProvider-BtZYXzQL.js → redocly-openapi-docs.min.AiChatProvider-6YPcWs0H.js} +8 -8
- package/dist/{redocly-openapi-docs.min.AiChatSqliteDBStorage-CMWIhurV.js → redocly-openapi-docs.min.AiChatSqliteDBStorage-B83b3g85.js} +1 -1
- package/dist/{redocly-openapi-docs.min.AiPanel-CzVBo_SJ.js → redocly-openapi-docs.min.AiPanel-C2qfX9uL.js} +120 -120
- package/dist/redocly-openapi-docs.min.FileWatcher-BqldveuP.js +1 -0
- package/dist/redocly-openapi-docs.min.SemanticSearchService-WMOhwmFs.js +1 -0
- package/dist/{redocly-openapi-docs.min.SqliteDBStorage-DicEB6xf.js → redocly-openapi-docs.min.SqliteDBStorage-C1P1898p.js} +1 -1
- package/dist/redocly-openapi-docs.min.TauriFileSystemAdapter-dQrMcpdl.js +1 -0
- package/dist/redocly-openapi-docs.min.TauriRootStorage-Xs8U5nWO.js +1 -0
- package/dist/{redocly-openapi-docs.min.ai-chat-mappers-BfCwakK5.js → redocly-openapi-docs.min.ai-chat-mappers-CJR-cboS.js} +1 -1
- package/dist/{redocly-openapi-docs.min.external-resolver-DftxHgbt.js → redocly-openapi-docs.min.external-resolver-B_BGsIqk.js} +1 -1
- package/dist/redocly-openapi-docs.min.index-A1jwxgMY.js +7843 -0
- package/dist/redocly-openapi-docs.min.index-CzgAKyvP.js +1 -0
- package/dist/redocly-openapi-docs.min.index-DYtjK7I1.js +1 -0
- package/dist/redocly-openapi-docs.min.index-zM-C-d58.js +1 -0
- package/dist/redocly-openapi-docs.min.js +1 -1
- package/dist/{redocly-openapi-docs.min.lint-jyJiMT1p.js → redocly-openapi-docs.min.lint-CFL7cUUQ.js} +2 -2
- package/dist/{redocly-openapi-docs.min.lint-graphql-BLIlXit9.js → redocly-openapi-docs.min.lint-graphql-UDOPvcZk.js} +1 -1
- package/dist/redocly-openapi-docs.min.periodic-revalidation-DkSoAMSp.js +1 -0
- package/dist/{redocly-openapi-docs.min.respect-run-CTD2qNkS.js → redocly-openapi-docs.min.respect-run-BGASIC7w.js} +1 -1
- package/dist/{redocly-openapi-docs.min.standalone-CS00-kVE.js → redocly-openapi-docs.min.standalone-DlNPBIhk.js} +1228 -1148
- package/dist/redocly-openapi-docs.min.tauri-path-B2ySzLGM.js +1 -0
- package/dist/{redocly-openapi-docs.min.useAiChatQueries-BH1oro3k.js → redocly-openapi-docs.min.useAiChatQueries-DvhVIF-L.js} +103 -103
- package/lib/components/PropertyDetails/FieldDetail.js +3 -3
- package/lib/components/Replay/Replay.js +1 -1
- package/lib/components/Security/styled.js +3 -3
- package/lib/components/Tabs/Tabs.js +1 -1
- package/lib/components/TagItem/Breadcrumbs.js +2 -2
- package/lib/components/TagItem/OperationNavigationItems.js +1 -1
- package/lib/components/common/Fields/fields-layout.js +1 -1
- package/lib/components/common/Fields/fields.js +2 -2
- package/lib/components/common/styled.js +1 -1
- package/package.json +14 -5
- package/dist/redocly-openapi-docs.min.FileWatcher-DjTW24VD.js +0 -1
- package/dist/redocly-openapi-docs.min.SemanticSearchService-BdbJAsUF.js +0 -1
- package/dist/redocly-openapi-docs.min.TauriFileSystemAdapter-Bzf6nZVE.js +0 -1
- package/dist/redocly-openapi-docs.min.TauriRootStorage-Cg1lmYY7.js +0 -1
- package/dist/redocly-openapi-docs.min.index-BXAn8eur.js +0 -7837
- package/dist/redocly-openapi-docs.min.index-BnxwvVhR.js +0 -1
- package/dist/redocly-openapi-docs.min.index-CHKNddXa.js +0 -1
- package/dist/redocly-openapi-docs.min.index-U6ORLz-U.js +0 -1
- package/dist/redocly-openapi-docs.min.periodic-revalidation-Dsp-n7ui.js +0 -1
- package/dist/redocly-openapi-docs.min.tauri-path-Dw7ZXd_2.js +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{jsx as r,jsxs as a}from"react/jsx-runtime";import{memo as p}from"react";import{useAtomValue as m}from"jotai";import{JsonViewer as
|
|
1
|
+
import{jsx as r,jsxs as a}from"react/jsx-runtime";import{memo as p}from"react";import{useAtomValue as m}from"jotai";import{JsonViewer as x}from"@redocly/theme/components/JsonViewer/JsonViewer";import{FieldLabel as f,DefaultValue as c,FieldValueLabel as u,ExpandableExample as b}from"../common/index.js";import{globalOptionsAtom as g}from"../../jotai/store.js";import{styled as n}from"../../styled-components.js";function h({value:e,label:s,raw:i,type:l="other"}){const{jsonSamplesExpandLevel:t}=m(g);if(e===void 0)return null;const d=!i&&typeof e=="object"&&e!==null,o=i?String(e):JSON.stringify(e);return a(j,{children:[a(f,{children:[" ",s," "]}),l==="default"?r(c,{children:o}):l==="example"?d?r(V,{data:e,expandLevel:t,controls:!1}):r(b,{value:o}):r(u,{children:o})]})}const D=p(h),j=n.div`
|
|
2
2
|
margin-top: var(--spacing-xxs);
|
|
3
3
|
display: flex;
|
|
4
4
|
align-items: baseline;
|
|
5
5
|
gap: var(--spacing-xxs);
|
|
6
6
|
flex-wrap: wrap;
|
|
7
|
-
`,V=n(
|
|
7
|
+
`,V=n(x)`
|
|
8
8
|
flex-basis: 100%;
|
|
9
9
|
min-width: 0;
|
|
10
10
|
border: 1px solid var(--border-color-secondary);
|
|
11
|
-
border-radius: var(--border-radius);
|
|
11
|
+
border-radius: var(--border-radius-xl);
|
|
12
12
|
overflow: hidden;
|
|
13
13
|
`;export{D as FieldDetail};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as K,jsx as o,jsxs as W}from"react/jsx-runtime";import{lazy as w,memo as Q,Suspense as X,useCallback as d,useMemo as
|
|
1
|
+
import{Fragment as K,jsx as o,jsxs as W}from"react/jsx-runtime";import{lazy as w,memo as Q,Suspense as X,useCallback as d,useMemo as R,useRef as Y,useState as Z}from"react";import{useAtom as g,useAtomValue as y}from"jotai";import $ from"deepmerge";import{ReplayGate as ee}from"@redocly/theme/components/ReplayGate/ReplayGate";import{ReplayTopBarActions as te}from"@redocly/theme/components/ReplayTopBarActions/ReplayTopBarActions";const oe=w(async()=>import("@redocly/replay").then(e=>({default:e.ReplayOverlay})));import{Button as re}from"@redocly/theme/components/Button/Button";import{useFocusTrap as ne,useModalScrollLock as ae}from"@redocly/theme/core/openapi";import{RocketIcon as se}from"@redocly/theme/icons/RocketIcon/RocketIcon";import{CircleDashIcon as ie}from"@redocly/theme/icons/CircleDashIcon/CircleDashIcon";import{Portal as le}from"@redocly/theme/components/Portal/Portal";import{useConfigureReplay as me}from"@redocly/theme/ext/use-configure-replay";import{globalOptionsAtom as pe,globalStoreAtom as ce}from"../../jotai/store.js";import{allOperationsAtom as fe,replayStateAtom as ue}from"../../jotai/replay.js";import{allOperations as de,getDefaultOperationStore as ye}from"../../jotai/operation.js";import{LOADING_STATE as r}from"../../constants.js";import{environmentAtom as he,userClaimsAtom as Oe}from"../../jotai/app.js";import{convertOperationToReplayValueForRedoc as Ie}from"./utils.js";import{useTranslate as Re,useTelemetry as ge}from"../../hooks/index.js";import{JsonPointer as Ae}from"../../utils/index.js";import{getDefaultCollectorUrl as Te}from"../../utils/telemetry.js";import{createTryItOpenEvent as ve,createTryItSentEvent as Se}from"../../events/index.js";import{joinWithSeparator as be}from"../../services/history/helpers.js";import{HTTPSnippet as De}from"../../services/code-samples/httpsnippet/index.js";function Ce({operation:e,corsProxyUrl:A,fullOpenApi:T}){const v=Re(),_=ge(),S=Y(null),h=y(pe),{oAuth2RedirectURI:b,routingBasePath:i}=h,D=y(fe),{parser:l,options:{events:a}}=y(ce),m=y(Oe),[p,C]=Z(!1),[c,O]=g(ue),[f,L]=g(de),[[,V],E]=g(he),k=R(()=>({userClaims:m,info:l?.definition.info,operation:{name:e.name,path:e.path,operationId:e.operationId||"",href:e.href,method:e.httpVerb},servers:e.servers}),[m,l?.definition.info,e.name,e.path,e.operationId,e.href,e.httpVerb,e.servers]),{config:u,refresh:N}=me(k,p),P=d(()=>N(),[N]),q=d(t=>{if(!t)return;const s=D.find(I=>I.operationId===t);return be(i,s?.href)},[D,i]),j=R(()=>Ie(m,u,h,f),[m,u,h,f]),F=R(()=>({corsProxyUrl:A,selectedEnvironment:V,apiId:l?.definition.info?.["x-metadata"]?.apiId,oAuth2RedirectURI:b,disableCollectionsTab:!0,storageKey:i,telemetry:{tracerName:"try-it",collectorUrl:Te()},HTTPSnippet:De,convertOperationToReplayValue:j,dynamicReplayValues:u,getOperationUrl:q,onRequestReset:P}),[A,V,l?.definition.info,b,i,j,u,q,P]);ne(S),ae(p);const U=d(({operations:t,environment:s,environments:I})=>{const z=t.reduce((x,n)=>{n.requestValues.body=n.requestValues.body instanceof URLSearchParams?Object.fromEntries(n.requestValues.body.entries()):n.requestValues.body;const{path:H,method:J}=n.apiPath,B=Ae.compile(["paths",H,J]);return x[B]=$(ye(B),n),x},{});L({...f,...z}),E({environment:s,environments:I})},[f,L,E]),G=()=>{if(p){C(!1),c===r.LOADING&&O(r.NOT_LOADED);return}if(_.sendTryItOpenedMessage([{id:"tryItButton",object:"button",uri:"urn:redocly:redoc:ui:button:tryItButton"}]),a?.tryItOpen&&e){const t=ve({operation:e});a.tryItOpen(t)}C(!0),c===r.NOT_LOADED&&O(r.LOADING)},M=d(t=>{if(a?.tryItSent&&e){const s=Se({operation:e,isSuccess:t});a.tryItSent(s)}},[a,e]);return T?W(K,{children:[o(re,{onClick:G,variant:"primary",iconPosition:"left",icon:c===r.LOADING?o(ie,{}):o(se,{}),children:c===r.LOADING?v("openapi.loading","Loading..."):v("openapi.tryIt","Try it")}),p&&o(X,{children:o(le,{mountId:"api-content",children:o("div",{ref:S,children:o(oe,{ReplayGate:ee,ReplayTopBarActions:te,activeOperationId:e.operationId||e.pointer,api:T,onRequestChange:U,onClose:G,onLoad:()=>O(r.LOADED),settings:F,onRequestSent:M})})})})]}):null}const Ze=Q(Ce);export{Ze as Replay};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import{styled as r}from"../../styled-components.js";const a=r.div`
|
|
2
|
-
border-radius: var(--border-radius);
|
|
2
|
+
border-radius: var(--tag-border-radius);
|
|
3
3
|
padding: 0 var(--spacing-xxs);
|
|
4
4
|
font-family: var(--font-family-monospaced);
|
|
5
5
|
font-size: var(--font-size-sm);
|
|
6
6
|
line-height: var(--line-height-sm);
|
|
7
7
|
color: var(--text-color-primary);
|
|
8
8
|
background-color: var(--tag-bg-color);
|
|
9
|
-
`,
|
|
9
|
+
`,t=r.a`
|
|
10
10
|
color: var(--link-color-primary);
|
|
11
11
|
text-decoration: none;
|
|
12
12
|
word-wrap: break-word;
|
|
13
|
-
`;export{
|
|
13
|
+
`;export{t as StyledLink,a as Tag};
|
|
@@ -12,7 +12,7 @@ import{jsx as e}from"react/jsx-runtime";import{css as t}from"styled-components";
|
|
|
12
12
|
padding: 0 var(--spacing-sm);
|
|
13
13
|
background-color: transparent;
|
|
14
14
|
height: 24px;
|
|
15
|
-
border-radius: var(--border-radius);
|
|
15
|
+
border-radius: var(--border-radius-md);
|
|
16
16
|
font-family: var(--font-family-base);
|
|
17
17
|
font-size: var(--font-size-base);
|
|
18
18
|
font-weight: var(--font-weight-regular);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Fragment as p,jsx as n,jsxs as h}from"react/jsx-runtime";import w,{useRef as x,useState as
|
|
1
|
+
import{Fragment as p,jsx as n,jsxs as h}from"react/jsx-runtime";import w,{useRef as x,useState as b,useMemo as L,useCallback as B,useLayoutEffect as k}from"react";import{Dropdown as E}from"@redocly/theme/components/Dropdown/Dropdown";import{DropdownMenu as M}from"@redocly/theme/components/Dropdown/DropdownMenu";import{DropdownMenuItem as C}from"@redocly/theme/components/Dropdown/DropdownMenuItem";import{Tooltip as T}from"@redocly/theme/components/Tooltip/Tooltip";import{trimText as y}from"@redocly/theme/core/openapi";import{styled as s}from"../../styled-components.js";import{calculateMaxLength as D}from"../../utils/calculateMaxLength.js";const R=25,_=3,u=({breadcrumb:e,onClick:t,maxLength:r})=>{const o=e.name.length>r,i=y(e.name,r);return n(T,{tip:e.name,placement:"bottom",disabled:!o,children:n(v,{onClick:()=>t(e.href),children:i})})},z=({breadcrumbs:e,onClick:t,maxLength:r})=>{const o=e[0],i=e[e.length-1],d=e.slice(1,-1);return h(p,{children:[n(u,{breadcrumb:o,onClick:t,maxLength:r}),n(g,{children:"/"}),n(E,{trigger:n(O,{children:"..."}),closeOnClick:!0,alignment:"end",children:n(M,{children:d.map(a=>n(C,{onAction:()=>t(a.href),children:a.name},a.href))})}),n(g,{children:"/"}),n(u,{breadcrumb:i,onClick:t,maxLength:r})]})},F=({breadcrumbs:e,onClick:t,maxLength:r})=>n(p,{children:e.map((o,i)=>h(w.Fragment,{children:[n(u,{breadcrumb:o,onClick:t,maxLength:r}),i!==e.length-1&&n(g,{children:"/"})]},o.href))});function q({breadcrumbs:e,onClick:t}){const r=x(null),o=x(null),[i,d]=b(R),a=e.length>_,f=L(()=>a?[e[0],e[e.length-1]]:e,[e,a]),m=B(()=>{if(!r.current?.parentElement||!o.current)return;const c=r.current.parentElement.clientWidth,l=D(f,c,a,o.current);d(l)},[f,a]);return k(()=>{m();const c=new ResizeObserver(m),l=r.current?.parentElement;return l&&c.observe(l),()=>{c.disconnect()}},[m]),e.length?h(p,{children:[n(j,{ref:o,"aria-hidden":"true"}),n(A,{ref:r,"data-component-name":"TagItem/Breadcrumbs",children:a?n(z,{breadcrumbs:e,onClick:t,maxLength:i}):n(F,{breadcrumbs:e,onClick:t,maxLength:i})})]}):null}const j=s.span`
|
|
2
2
|
position: absolute;
|
|
3
3
|
visibility: hidden;
|
|
4
4
|
white-space: nowrap;
|
|
@@ -17,7 +17,7 @@ import{Fragment as p,jsx as n,jsxs as h}from"react/jsx-runtime";import w,{useRef
|
|
|
17
17
|
margin: 0;
|
|
18
18
|
font-size: var(--font-size-sm);
|
|
19
19
|
color: var(--breadcrumbs-text-color);
|
|
20
|
-
border-radius: var(--border-radius);
|
|
20
|
+
border-radius: var(--breadcrumbs-border-radius);
|
|
21
21
|
cursor: pointer;
|
|
22
22
|
padding: 1px calc(var(--spacing-xxs) / 2);
|
|
23
23
|
line-height: var(--line-height-sm);
|
|
@@ -5,7 +5,7 @@ import{Fragment as x,jsx as r,jsxs as s}from"react/jsx-runtime";import{memo as y
|
|
|
5
5
|
color: var(--text-color-primary);
|
|
6
6
|
margin: var(--spacing-sm) 0 var(--spacing-xxs) 0;
|
|
7
7
|
`,A=o(B)`
|
|
8
|
-
border-radius: var(--border-radius);
|
|
8
|
+
border-radius: var(--border-radius-lg);
|
|
9
9
|
background: var(--bg-color);
|
|
10
10
|
justify-content: space-between;
|
|
11
11
|
width: 100%;
|
|
@@ -159,7 +159,7 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
|
|
|
159
159
|
padding: var(--schema-nested-offset);
|
|
160
160
|
`,v=a.table`
|
|
161
161
|
border-collapse: separate;
|
|
162
|
-
border-radius: var(--border-radius);
|
|
162
|
+
border-radius: var(--panel-border-radius);
|
|
163
163
|
width: 100%;
|
|
164
164
|
font-size: var(--font-size-base);
|
|
165
165
|
display: block;
|
|
@@ -28,7 +28,7 @@ import{Button as t}from"@redocly/theme/components/Button/Button";import{styled a
|
|
|
28
28
|
font-family: var(--font-family-monospaced);
|
|
29
29
|
font-size: var(--font-size-sm);
|
|
30
30
|
line-height: var(--line-height-sm);
|
|
31
|
-
border-radius: var(--border-radius);
|
|
31
|
+
border-radius: var(--tag-border-radius);
|
|
32
32
|
color: var(--text-color-secondary);
|
|
33
33
|
display: inline-flex;
|
|
34
34
|
word-break: var(--code-word-break);
|
|
@@ -38,7 +38,7 @@ import{Button as t}from"@redocly/theme/components/Button/Button";import{styled a
|
|
|
38
38
|
border: 1px solid var(--border-color-secondary);
|
|
39
39
|
`,a=r(e)`
|
|
40
40
|
background-color: var(--schema-inline-bg-color);
|
|
41
|
-
border-radius: var(--border-radius);
|
|
41
|
+
border-radius: var(--tag-border-radius);
|
|
42
42
|
border: var(--schema-inline-border);
|
|
43
43
|
padding: 0 var(--spacing-unit);
|
|
44
44
|
width: fit-content;
|
|
@@ -30,7 +30,7 @@ import{Tag as o}from"@redocly/theme/components/Tag/Tag";import{styled as r}from"
|
|
|
30
30
|
margin-top: var(--spacing-xs);
|
|
31
31
|
`,d=r.span`
|
|
32
32
|
padding: 0 var(--spacing-xs);
|
|
33
|
-
border-radius: var(--border-radius);
|
|
33
|
+
border-radius: var(--tag-border-radius);
|
|
34
34
|
border: 1px solid var(--border-color-secondary);
|
|
35
35
|
background-color: var(--bg-color);
|
|
36
36
|
font-size: var(--font-size-sm);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.25.0-next.
|
|
3
|
+
"version": "3.25.0-next.6",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"url-template": "^2.0.8",
|
|
40
40
|
"util": "~0.12.5",
|
|
41
41
|
"web-vitals": "3.3.1",
|
|
42
|
-
"@redocly/config": "0.
|
|
43
|
-
"@redocly/redoc-opentelemetry": "0.2.
|
|
44
|
-
"@redocly/replay": "0.28.0-next.
|
|
42
|
+
"@redocly/config": "0.54.0",
|
|
43
|
+
"@redocly/redoc-opentelemetry": "0.2.4",
|
|
44
|
+
"@redocly/replay": "0.28.0-next.6"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@shikijs/transformers": "3.21.0",
|
|
@@ -71,7 +71,16 @@
|
|
|
71
71
|
"url": "~0.11.0",
|
|
72
72
|
"vite": "7.3.6",
|
|
73
73
|
"vitest": "4.1.10",
|
|
74
|
-
"@redocly/theme": "0.69.0-next.
|
|
74
|
+
"@redocly/theme": "0.69.0-next.6"
|
|
75
|
+
},
|
|
76
|
+
"nx": {
|
|
77
|
+
"targets": {
|
|
78
|
+
"vitest:test": {
|
|
79
|
+
"dependsOn": [
|
|
80
|
+
"build"
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
75
84
|
},
|
|
76
85
|
"scripts": {
|
|
77
86
|
"start": "pnpm run copy-highlight-hook && vite",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z as v,B as y,P as m,C as f,E as x,F}from"./redocly-openapi-docs.min.index-BXAn8eur.js";import{g as E}from"./redocly-openapi-docs.min.SemanticSearchService-BdbJAsUF.js";var w;(function(r){r.WINDOW_RESIZED="tauri://resize",r.WINDOW_MOVED="tauri://move",r.WINDOW_CLOSE_REQUESTED="tauri://close-requested",r.WINDOW_DESTROYED="tauri://destroyed",r.WINDOW_FOCUS="tauri://focus",r.WINDOW_BLUR="tauri://blur",r.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",r.WINDOW_THEME_CHANGED="tauri://theme-changed",r.WINDOW_CREATED="tauri://window-created",r.WEBVIEW_CREATED="tauri://webview-created",r.DRAG_ENTER="tauri://drag-enter",r.DRAG_OVER="tauri://drag-over",r.DRAG_DROP="tauri://drag-drop",r.DRAG_LEAVE="tauri://drag-leave"})(w||(w={}));async function _(r,t){await v("plugin:event|unlisten",{event:r,eventId:t})}async function C(r,t,i){var e;const a=(e=void 0)!==null&&e!==void 0?e:{kind:"Any"};return v("plugin:event|listen",{event:r,target:a,handler:y(t)}).then(s=>async()=>_(r,s))}const c="replay-environments.yaml";class A{constructor(t,i,e,a){this.storage=t,this.state=i,this.projectDir=e,this.aiEnabled=a}storage;state;projectDir;aiEnabled;watchPath=null;unlistenEvent=null;get tauriStorage(){return this.storage}indexApis(t){!this.aiEnabled||t.length===0||E().indexApis(t).catch(i=>console.error("Semantic index (apis):",i))}indexCollections(t){!this.aiEnabled||t.length===0||E().indexCollections(t).catch(i=>console.error("Semantic index (collections):",i))}removeApis(t){if(!this.aiEnabled||t.length===0)return;const i=E();Promise.all(t.map(e=>i.removeApi(e))).catch(e=>console.error("Semantic remove (apis):",e))}removeCollections(t){if(!this.aiEnabled||t.length===0)return;const i=E();Promise.all(t.map(e=>i.removeCollection(e))).catch(e=>console.error("Semantic remove (collections):",e))}async start(){if(this.watchPath){console.warn("Watcher already started for:",this.watchPath);return}try{this.unlistenEvent=await C("fs-watch-event",async t=>{const i=t.payload;try{await this.handleEvent(i)}catch(e){console.error("Error handling file change:",e)}}),await v("fs_watch",{path:this.projectDir,options:{recursive:!0,delayMs:500}}),this.watchPath=this.projectDir}catch(t){throw console.error("Failed to start file watcher:",t),this.unlistenEvent&&(this.unlistenEvent(),this.unlistenEvent=null),t}}async stop(){if(this.watchPath)try{await v("fs_unwatch",{path:this.watchPath})}catch(t){console.error("Error stopping file watcher:",t)}finally{this.unlistenEvent&&(this.unlistenEvent(),this.unlistenEvent=null),this.watchPath=null}}async handleEvent(t){const{changeType:i,paths:e,pathTypes:a,type:s}=t;if(await this.isProjectFolderRemoved(e,i)){await this.handleProjectFolderRemoval();return}const o=this.filterSpecFiles(e,a);if(o.paths.length===0)return;const n=await this.toFileEntries(o.paths,o.pathTypes);switch(i){case"changed":(s.includes("Data")||s.includes("Name"))&&await this.handleModify(n);break;case"added":await this.handleCreate(n);break;case"deleted":await this.handleDelete(n);break;case"renamed":await this.handleRename(n);break;default:console.log("Unhandled change type:",i)}}filterSpecFiles(t,i){const e=[],a=[];for(let s=0;s<t.length;s++){const o=t[s],n=o.split(".").pop()?.toLowerCase();n&&["yaml","yml","json"].includes(n)&&(e.push(o),a.push(i[s]||"unknown"))}return{paths:e,pathTypes:a}}async toFileEntries(t,i){return Promise.all(t.map(async(e,a)=>({relative_path:await m.relative(this.projectDir,e),absolute_path:e,type:i[a]||"unknown"})))}hasEnvironmentsFileChange(t){return!this.storage.isWatchExcluded(c)&&t.some(i=>i.relative_path===c)}withoutEnvironmentsFile(t){return t.filter(i=>i.relative_path!==c)}consolidateFileEntries(t){const i=[],e=new Set;for(const a of t)e.has(a.relative_path)||(e.add(a.relative_path),this.storage.isWatchExcluded(a.relative_path)||i.push(a));return i}async handleModify(t){const i=this.hasEnvironmentsFileChange(t),e=this.withoutEnvironmentsFile(t),{newApiFiles:a,existingApiFiles:s}=this.categorizeApisFromFiles(e),{newCollectionFiles:o,existingCollectionFiles:n}=this.categorizeCollectionsFromFiles(e),d=await this.findApisToReload(t),h=await this.findCollectionsToReload(t),p=[...a,...o];p.length>0&&await this.handleCreate(p),i&&await this.reloadEnvironments();const u=this.consolidateFileEntries([...s,...d]),g=this.consolidateFileEntries([...n,...h]);await this.reloadApis(u),await this.reloadCollections(g)}async handleCreate(t){this.hasEnvironmentsFileChange(t)&&await this.reloadEnvironments();const i=this.withoutEnvironmentsFile(t),e=i.filter(h=>h.type==="api"),a=i.filter(h=>h.type==="collection"),{newApiFiles:s,existingApiFiles:o}=this.categorizeApisFromFiles(e),{newCollectionFiles:n,existingCollectionFiles:d}=this.categorizeCollectionsFromFiles(a);if(s.length>0||n.length>0){s.forEach(l=>this.storage.addPersistExcludedId(l.relative_path)),n.forEach(l=>this.storage.addPersistExcludedId(l.relative_path));const h=s.length>0?await this.tauriStorage.loadAndParseApis(s,void 0,!0):[],p=n.length>0?await this.tauriStorage.loadAndParseCollections(n,void 0):[],u=h.filter(l=>l!==null),g=p.filter(l=>l!==null);this.state.apis.merge(u),this.state.collections.merge(g),this.indexApis(u),this.indexCollections(g),setTimeout(()=>{s.forEach(l=>this.storage.removePersistExcludedId(l.relative_path)),n.forEach(l=>this.storage.removePersistExcludedId(l.relative_path))},500)}o.length>0&&await this.reloadApis(o),d.length>0&&await this.reloadCollections(d)}categorizeApisFromFiles(t){const i=new Set,e=[],a=[];for(const s of t)i.has(s.relative_path)||(i.add(s.relative_path),this.state.apis.get({noproxy:!0}).some(o=>o.id===s.relative_path)?a.push(s):s.type==="api"&&e.push(s));return{newApiFiles:e,existingApiFiles:a}}categorizeCollectionsFromFiles(t){const i=new Set,e=[],a=[];for(const s of t)i.has(s.relative_path)||(i.add(s.relative_path),this.state.collections.get({noproxy:!0}).some(o=>o.id===s.relative_path)?a.push(s):s.type==="collection"&&e.push(s));return{newCollectionFiles:e,existingCollectionFiles:a}}async handleDelete(t){this.hasEnvironmentsFileChange(t)&&await this.reloadEnvironments();const i=[],e=[];for(const a of this.withoutEnvironmentsFile(t)){this.storage.addPersistExcludedId(a.relative_path);const s=this.state.apis.get({noproxy:!0}).findIndex(n=>n.id===a.relative_path);s>=0&&(this.state.apis[s].set(f),this.tauriStorage.deleteApiFromCache(a.relative_path),i.push(a.relative_path));const o=this.state.collections.get({noproxy:!0}).findIndex(n=>n.id===a.relative_path);o>=0&&(this.state.collections[o].set(f),e.push(a.relative_path)),setTimeout(()=>{this.storage.removePersistExcludedId(a.relative_path)},500)}this.removeApis(i),this.removeCollections(e)}async handleRename(t){if(t.length>=2){const[i,e]=t;await this.handleDelete([i]),await this.handleCreate([e])}else await this.handleCreate(t)}async isProjectFolderRemoved(t,i){if(t.length===0)return!1;if(i==="deleted"||i==="renamed"){for(const e of t)if(e===this.projectDir)return!0}return t.filter(e=>!e.startsWith(this.projectDir+"/")&&e!==this.projectDir).length>0&&i==="renamed"}async handleProjectFolderRemoval(){const t=this.state.apis.get({noproxy:!0}),i=t.map(s=>s.id);t.forEach(s=>{this.storage.addPersistExcludedId(s.id),this.tauriStorage.deleteApiFromCache(s.id)}),this.state.apis.set([]);const e=this.state.collections.get({noproxy:!0}),a=e.map(s=>s.id);e.forEach(s=>{this.storage.addPersistExcludedId(s.id)}),this.state.collections.set([]),setTimeout(()=>{t.forEach(s=>this.storage.removePersistExcludedId(s.id)),e.forEach(s=>this.storage.removePersistExcludedId(s.id))},500),this.removeApis(i),this.removeCollections(a),await this.stop()}async findApisToReload(t){const i=[];return await Promise.all(this.state.apis.map(async e=>{const a=e.fileDependencies?.get({noproxy:!0})??new Set,s=e.get({noproxy:!0}).id,o=t.find(n=>a.has(n.absolute_path));if(!this.storage.isWatchExcluded(s)&&o){const n=await m.join(this.projectDir,s);i.push({relative_path:s,absolute_path:n,type:"api"})}})),i}async findCollectionsToReload(t){const i=[];return await Promise.all(this.state.collections.map(async e=>{const a=e.fileDependencies?.get({noproxy:!0})??new Set,s=e.get({noproxy:!0}).id,o=t.find(n=>a.has(n.absolute_path));if(!this.storage.isWatchExcluded(s)&&o){const n=await m.join(this.projectDir,s);i.push({relative_path:s,absolute_path:n,type:"collection"})}})),i}async reloadEnvironments(){const t=await this.tauriStorage.readEnviroments();this.storage.addPersistExcludedId(c),this.state.environments.set(t.length>0?t:x(F)),this.state.configFileError.set(this.storage.getEnvironmentsConfigError()),setTimeout(()=>{this.storage.removePersistExcludedId(c)},500)}async reloadApis(t){if(t.length===0)return;const i=await this.tauriStorage.loadAndParseApis(t,void 0,!0),e=[];await Promise.all(i.map(async(a,s)=>{if(!a){await this.handleDelete([t[s]]);return}const o=this.state.apis.get({noproxy:!0}).findIndex(n=>n.id===a.id);o>=0?(this.storage.addPersistExcludedId(a.id),this.state.apis[o].set(a),e.push(a),setTimeout(()=>this.storage.removePersistExcludedId(a.id),500)):console.warn("API not found in state after reload:",a.id)})),e.length>0&&this.indexApis(e)}async reloadCollections(t){if(t.length===0)return;const i=await this.tauriStorage.loadAndParseCollections(t,void 0),e=[];await Promise.all(i.map(async(a,s)=>{if(!a){await this.handleDelete([t[s]]);return}const o=this.state.collections.get({noproxy:!0}).findIndex(n=>n.id===a.id);o>=0?(this.storage.addPersistExcludedId(a.id),this.state.collections[o].set(a),e.push(a),setTimeout(()=>this.storage.removePersistExcludedId(a.id),500)):console.warn("Collection not found in state after reload:",a.id)})),e.length>0&&this.indexCollections(e)}}export{A as FileWatcher};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z as h,aP as te,aQ as ne,aR as y}from"./redocly-openapi-docs.min.index-BXAn8eur.js";import{O as H}from"./redocly-openapi-docs.min.Observable-D6wKbFwB.js";import{p as ie}from"./redocly-openapi-docs.min.promise-map-limit-Db_42GvV.js";function x(t){return t==null?"":typeof t=="string"?t:typeof t=="object"&&"raw"in t&&typeof t.raw=="string"?t.raw:String(t)}function w(t){return t.replace(/\s+/g," ").trim()}function b(t){return typeof t=="object"&&t!==null&&"$ref"in t}function _(t){return b(t)?null:t}function N(t){try{return JSON.stringify(t)}catch{return String(t)}}function U(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 M(t){return t.type?Array.isArray(t.type)?t.type.join("|"):t.type:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":"object"}function oe(t){return t==="querystring"?"query":t==="query"||t==="header"||t==="path"||t==="cookie"?t:"query"}function se(t){const e=t.schema&&!b(t.schema)?t.schema:null,n={name:t.name,in:oe(t.in),required:t.required??!1};return e&&(n.type=M(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=x(t.description)),t.example!==void 0&&!n.example&&(n.example=String(t.example)),n}function ae(t,e){const n=new Set,o=[],s=i=>{for(const a of i){const r=_(a);if(!r||!r.name)continue;const c=`${r.in}:${r.name}`;n.has(c)||(n.add(c),o.push(se(r)))}};return t.parameters&&s(t.parameters),e.parameters&&s(e.parameters),o}function F(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:M(i),required:o.has(s),readOnly:i.readOnly}))}function E(t){const e=t.components?.securitySchemes;if(!e)return[];const n=[];for(const[o,s]of Object.entries(e)){const i=_(s);i&&n.push(re(o,i))}return n}function re(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 a=e.flows[i];a?.scopes&&Object.keys(a.scopes).forEach(r=>s.add(r))}s.size>0&&(n.scopes=[...s].join(", "))}return n}function ce(t,e,n){const o=t??e;if(!o||n.length===0)return[];const s=new Set;for(const i of o)for(const a of Object.keys(i))s.add(a);return n.filter(i=>s.has(i.schemeName))}function le(t){return t.length===0?"":`Security: ${t.map(e=>{let n=`${e.schemeName} (${e.type}`;return e.scheme&&(n+=`, ${e.scheme}`),e.in&&e.name&&(n+=`, ${e.name} in ${e.in}`),n+=")",n}).join("; ")}.`}const de=["get","put","post","delete","options","head","patch","trace"],ue=["query","x-query"];function pe(t,e){const n=[],o=Object.keys(t.content??{});if(o.length===0)return{textPart:"",schemaJson:"{}",examples:n};const s=o.find(l=>l.includes("json"))??o[0],i=t.content?.[s],a=i?.schema&&!b(i.schema)?i.schema:null,r=(a?F(a):[]).filter(l=>!e.hideReadOnly||!l.readOnly),c=t.required?"required":"optional";let d=`Request body (${s}, ${c})`;if(r.length>0){const l=r.map(u=>`${u.name}: ${u.type}${u.required?" required":""}${u.readOnly?" readOnly":""}`);d+=`: {${l.join(", ")}}`}return i?.example!==void 0&&n.push(N(i.example)),{textPart:d,schemaJson:JSON.stringify(r),examples:n}}function he(t){const e=[],n=[];for(const[o,s]of Object.entries(t)){if(b(s))continue;const i=x(s.description??"");e.push(`${o} ${i}`.trim());const a={statusCode:o};i&&(a.description=i);const r=s.content;if(r){const c=Object.keys(r).find(l=>l.includes("json"))??Object.keys(r)[0],d=r[c]?.schema;if(d&&!b(d)){const l=F(d);l.length>0&&(a.schemaProperties=JSON.stringify(l))}}n.push(a)}return{textParts:e,summaries:n}}function q(t){const{apiId:e,apiTitle:n,path:o,method:s,op:i,pathItem:a,globalSchemes:r,apiSecurity:c}=t,d=i.summary??"",l=x(i.description??""),u=i.operationId??"",p=i.tags??[],g=s.toUpperCase(),m=ae(i,a),f=ce(i.security,c,r),Z=f.length>0?f.map(v=>`api_sec:${e}:${v.schemeName}`):void 0,I=[n,`${g} ${o}`,d,l];u&&I.push(`operationId: ${u}`),p.length>0&&I.push(`Tags: ${p.join(", ")}`),i.deprecated&&I.push("DEPRECATED"),m.length>0&&I.push(`Parameters: ${m.map(U).join(". ")}.`);let z;const S=[],J=i.requestBody;if(J){const v=_(J);if(v){const j=pe(v,{hideReadOnly:g==="POST"||g==="PUT"||g==="PATCH"});j.textPart&&I.push(j.textPart),z=j.schemaJson,S.push(...j.examples)}}const{textParts:C,summaries:T}=he(i.responses??{});C.length>0&&I.push(`Responses: ${C.join(", ")}.`);const D=le(f);D&&I.push(D);const R=`api_op:${e}:${o}:${s}:${u||`${o}-${s}`}`,ee={type:"api_operation",id:R,contentHash:"",title:d||`${g} ${o}`,description:l||void 0,apiId:e,path:o,method:g,operationId:u||void 0,tags:p.length>0?p:void 0,deprecated:i.deprecated||void 0,parameterDetails:m.length>0?m:void 0,requestBodySchema:z,responseSchemas:T.length>0?T:void 0,securitySchemeRefs:Z,examples:S.length>0?S:void 0};return{id:R,text:w(I.filter(Boolean).join(" ")),payload:ee}}function Q(t){const e=t.info?.title??"Untitled API",n=x(t.info?.description??t.info?.summary??""),o=t.id;return{id:`api:${o}`,text:w([e,n].filter(Boolean).join(" ")),payload:{type:"api",id:`api:${o}`,contentHash:"",title:e,description:n||void 0,apiId:o}}}function O(t){const e=[];for(const n of t){e.push(Q(n));const o=n.info?.title??"Untitled API",s=n.id,i=E(n);for(const r of i){const c=`api_sec:${s}:${r.schemeName}`,d=[`${r.schemeName}: type=${r.type}`,r.scheme?`scheme=${r.scheme}`:"",r.in&&r.name?`${r.name} in ${r.in}`:"",r.bearerFormat?`format=${r.bearerFormat}`:"",r.flows?`flows=[${r.flows}]`:"",r.scopes?`scopes=[${r.scopes}]`:""].filter(Boolean).join(" ");e.push({id:c,text:w(`${o} Authentication. ${r.schemeName}. ${d}.`),payload:{type:"api_security",id:c,contentHash:"",title:`${o} \u2014 ${r.schemeName}`,apiId:s,securityScheme:r}})}const a=n.paths??{};for(const[r,c]of Object.entries(a)){if(!c||typeof c!="object")continue;const d=[...de.filter(u=>u in c),...ue.filter(u=>u in c)];for(const u of d){const p=c[u];!p||typeof p!="object"||e.push(q({apiId:s,apiTitle:o,path:r,method:u,op:p,pathItem:c,globalSchemes:i,apiSecurity:n.security}))}const l=c.additionalOperations;if(l&&typeof l=="object")for(const[u,p]of Object.entries(l))!p||typeof p!="object"||e.push(q({apiId:s,apiTitle:o,path:r,method:u,op:p,pathItem:c,globalSchemes:i,apiSecurity:n.security}))}}return e}function me(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 a=i;e.push({name:a.key,in:s,required:!1})}return e}function L(t){const e=t.id,n=t.info?.title??"Untitled Collection",o=x(t.info?.description??t.info?.summary??"");return{id:`collection:${e}`,text:w([n,o].filter(Boolean).join(" ")),payload:{type:"collection",id:`collection:${e}`,contentHash:"",title:n,description:o||void 0,collectionId:e}}}function W(t){const{collectionId:e,collectionTitle:n,workflow:o}=t,s=o.workflowId??"",i=o.summary??s,a=x(o.description??""),r=[n,i,a];if(o.inputs&&r.push(`Inputs schema: ${N(o.inputs)}`),o.outputs?.length){const c=o.outputs.map(d=>d.key).filter(Boolean);c.length&&r.push(`Outputs: ${c.join(", ")}`)}return o.dependsOn?.length&&r.push(`Depends on: ${o.dependsOn.join(", ")}`),{id:`workflow:${e}:${s}`,text:w(r.filter(Boolean).join(" ")),payload:{type:"workflow",id:`workflow:${e}:${s}`,contentHash:"",title:i,description:a||void 0,collectionId:e,workflowId:s}}}function K(t){const{collectionId:e,collectionTitle:n,workflowId:o,workflowTitle:s,step:i}=t,a=i.stepId??"",r=x(i.description??""),c=i.operation,d=i.xOperation,l=[n,s,`step: ${a}`];r&&l.push(r),c?(l.push(`${c.method?.toUpperCase()} ${c.path}`),c.apiId&&l.push(`API: ${c.apiId}`),c.operationId&&l.push(`operationId: ${c.operationId}`)):d&&l.push(`${d.method?.toUpperCase()} ${d.url}`);const u=i.parameters?me(i.parameters):[];u.length>0&&l.push(`Parameters: ${u.map(U).join(". ")}.`),i.requestBody?.type&&l.push(`Request body type: ${i.requestBody.type}`);const p=(i.successCriteria??[]).map(m=>{let f=m.condition;return m.context&&(f+=` context: ${m.context}`),m.type&&(f+=` (${m.type})`),f});if(p.length>0&&l.push(`Success criteria: ${p.join("; ")}`),i.outputs?.length){const m=i.outputs.map(f=>`${f.key}=${f.value}`).filter(Boolean);m.length&&l.push(`Outputs: ${m.join(", ")}`)}const g=`step:${e}:${o}:${a}`;return{id:g,text:w(l.filter(Boolean).join(" ")),payload:{type:"step",id:g,contentHash:"",title:a,description:r||void 0,collectionId:e,workflowId:o,stepId:a,path:c?.path??d?.url,method:(c?.method??d?.method)?.toUpperCase(),apiId:c?.apiId,operationId:c?.operationId,parameterDetails:u.length>0?u:void 0,successCriteria:p.length>0?p:void 0,requestBodySchema:i.requestBody?.type?N(i.requestBody):void 0}}}function P(t){const e=[];for(const n of t){const o=n.id,s=n.info?.title??"Untitled Collection";e.push(L(n));for(const i of n.workflows??[]){e.push(W({collectionId:o,collectionTitle:s,workflow:i}));const a=i.workflowId??"",r=i.summary??a;for(const c of i.steps??[])e.push(K({collectionId:o,collectionTitle:s,workflowId:a,workflowTitle:r,step:c}))}}return e}function G(t,e){return[...O(t),...P(e)]}const k=10,fe=4;function V(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e>>>0}function ye(t){return te(ne(t))}const ge={};class Ie extends H{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 h("semantic_search_get_ids_by_payload",{collectionName:this.collectionName,field:e,value:n})}async getAllIds(){return h("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 a=[];for(const r of n)a.push(this.getIdsByPayload("apiId",r));for(const r of o)a.push(this.getIdsByPayload("collectionId",r));s=(await Promise.all(a)).flat()}const i=new Map;for(const a of s)i.set(a.id,a.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 a=0,r=0;for(const l of e){const u=ye(l.text);l.payload.contentHash=u,i.add(l.id);const p=o.get(l.id);p===u?r++:(p||a++,s.push(l))}const c=s.length-a,d=[];for(const l of o.keys())i.has(l)||d.push(l);if(d.length>0||s.length>0){this.beginIndexJob();try{d.length>0&&await this.deletePoints(d.map(V)),s.length>0&&await this.embedAndUpsert(s),await this.flush()}finally{this.endIndexJob()}}return{added:a,updated:c,removed:d.length,unchanged:r}}async removeByPayloadFilter(e,n){return h("semantic_search_delete_by_payload",{collectionName:this.collectionName,field:e,value:n})}async getStoredDocumentCount(){try{return(await h("plugin:velesdb|list_collections"))?.find(e=>e.name===this.collectionName)?.count??0}catch{return 0}}async getDocumentsByIds(e){if(e.length===0)return new Map;const n=e.map(V),o=await h("plugin:velesdb|get_points",{request:{collection:this.collectionName,ids:n}}),s=new Map;for(const i of o??[])if(i?.payload){const a=i.payload;a.id&&s.set(a.id,a)}return s}async embedAndUpsert(e){const n=[],o=e.length;for(let s=0;s<o;s+=k)n.push({docs:e.slice(s,s+k),index:Math.floor(s/k)});await ie(n,fe,async s=>{const i=s.docs.map(a=>({id:a.id,text:a.text||a.payload.title,payload:a.payload}));await h("semantic_search_embed_and_upsert",{collectionName:this.collectionName,documents:i})})}async deletePoints(e){e.length!==0&&await h("plugin:velesdb|delete_points",{request:{collection:this.collectionName,ids:e}})}async flush(){await h("plugin:velesdb|flush",{name:this.collectionName}),await h("semantic_search_write_hnsw_marker",{collectionName:this.collectionName}).catch(()=>{})}}const X="replay_search",xe=384,$={added:0,updated:0,removed:0,unchanged:0};function B(t){return t.added+t.updated>0}class Y extends H{initialized=!1;projectId=null;indexer=null;indexQueue=Promise.resolve();get collectionName(){return this.projectId?`${X}_${this.projectId}`:X}createIndexer(){const e=new Ie(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 o=this.indexQueue.then(()=>e()).then(async s=>(n(s)&&await this.unloadModel(),s)).catch(async s=>{throw console.error("Semantic index:",s),await this.unloadModel(),s});return this.indexQueue=o.catch(()=>{}),o}async unloadModel(){try{await h("semantic_search_unload_model")}catch{}}setProject(e){this.projectId!==e&&(this.projectId=e,this.initialized=!1,this.indexer=this.createIndexer())}async init(){if(y()&&!this.initialized){try{if((await h("plugin:velesdb|list_collections"))?.some(e=>e.name===this.collectionName)){this.initialized=!0;return}}catch{}await h("plugin:velesdb|create_collection",{request:{name:this.collectionName,dimension:xe,metric:"cosine",storage_mode:"full"}}),this.initialized=!0}}async indexApis(e){if(!y())return $;const n=this.collectionName,o=this.getIndexer(),s=O(e),i={apiIds:e.map(a=>a.id)};return await this.ensureInitialized(),this.enqueueIndex(async()=>this.collectionName!==n?$:o.indexDocuments(s,i),B)}async indexCollections(e){if(!y())return $;const n=this.collectionName,o=this.getIndexer(),s=P(e),i={collectionIds:e.map(a=>a.id)};return await this.ensureInitialized(),this.enqueueIndex(async()=>this.collectionName!==n?$:o.indexDocuments(s,i),B)}async removeApi(e){if(!y())return;const n=this.getIndexer();await this.ensureInitialized(),await this.enqueueIndex(()=>n.removeByPayloadFilter("apiId",e),()=>!1)}async removeCollection(e){if(!y())return;const n=this.getIndexer();await this.ensureInitialized(),await this.enqueueIndex(()=>n.removeByPayloadFilter("collectionId",e),()=>!1)}async reindex(e){if(!y())return $;const n=this.collectionName,o=this.getIndexer();return await this.ensureInitialized(),this.enqueueIndex(async()=>{if(this.collectionName!==n)return $;const{apis:s,collections:i}=e(),a=G(s,i);return o.indexDocuments(a,ge)},B)}async search(e,n=10,o){if(!y())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,i=((await h("semantic_search_text",{collection:this.collectionName,query:e,topK:n,filters:s})).results??[]).map(a=>({...a.payload,score:a.score??0}));return await this.enrichWithRelatedSecurity(i),i}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 a=[];for(const r of i.securitySchemeRefs??[]){const c=s.get(r);c?.securityScheme&&a.push(c.securityScheme)}a.length>0&&(i.relatedSecuritySchemes=a)}}async status(){if(!y())return{indexed:0,modelLoaded:!1};const e=await this.getIndexer().getStoredDocumentCount();let n=!1;try{n=(await h("semantic_search_model_status")).loaded}catch{}return{indexed:e,modelLoaded:n}}async clear(){if(!(!y()||!this.initialized))try{await h("plugin:velesdb|delete_collection",{name:this.collectionName}),this.initialized=!1}catch{}}async preloadModel(){if(y())try{await h("semantic_search_preload_model")}catch{}}}let A=null;function we(){return A||(A=new Y),A}export{Y as S,O as a,P as b,Q as c,q as d,G as e,E as f,we as g,L as h,K as i,W as j};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aS as c,aT as l,aU as n,P as o,aV as h,aW as u,aX as d,aY as w,aZ as y,a_ as m}from"./redocly-openapi-docs.min.index-BXAn8eur.js";import{O as f}from"./redocly-openapi-docs.min.Observable-D6wKbFwB.js";const E=new Set(["node_modules"]);class g extends f{constructor(e){super(),this.baseDir=e,this.initializeDirectory(e)}baseDir;writeExcludedKeys=new Set;writeEndTimers=new Map;async initializeDirectory(e){await c(e,{recursive:!0})}setWriteExcludedKeys(e){this.writeExcludedKeys=e}async ls(e){const t=await this.getFullPath(e);return this.getDirEntryFilesRecursively(t)}async getDirEntryFilesRecursively(e){try{const t=[],i=await l(e);for(const s of i)if(s.isDirectory){if(E.has(s.name))continue;const a=await n(e,s.name),r=await this.getDirEntryFilesRecursively(a);t.push(...r)}else{const a=await n(e,s.name),r=await o.relative(this.baseDir,a);t.push(r)}return t}catch(t){return t.includes("forbidden path")||console.error(t),[]}}async get(e){const t=await this.getFullPath(e);try{return await h(t)}catch(i){return!i.includes("No such file or directory")&&!i.includes("forbidden path")&&console.error(i),null}}async has(e){const t=await this.getFullPath(e);return await u(t)}async set(e,t){if(!this.writeExcludedKeys.has(e)){this.emit("write-start",e);try{const i=await this.getFullPath(e),s=m(),a=i.split(s).slice(0,-1).join(s);await c(a,{recursive:!0}),await d(i,t)}finally{const i=this.writeEndTimers.get(e);i&&clearTimeout(i);const s=setTimeout(()=>{this.emit("write-end",e),this.writeEndTimers.delete(e)},1e3);this.writeEndTimers.set(e,s)}}}async remove(e){if(!this.writeExcludedKeys.has(e)){this.emit("write-start",e);try{const t=await this.getFullPath(e);await w(t)}catch(t){!t.includes("No such file or directory")&&!t.includes("forbidden path")&&console.error(t)}finally{const t=this.writeEndTimers.get(e);t&&clearTimeout(t);const i=setTimeout(()=>{this.emit("write-end",e),this.writeEndTimers.delete(e)},1e3);this.writeEndTimers.set(e,i)}}}async rename(e,t){const i=await this.getFullPath(e),s=await this.getFullPath(t);await y(i,s)}async getFullPath(e){return await n(this.baseDir,e??"")}}export{g as TauriFileSystemAdapter};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{G as ht,S as N,H as ut,J as O,K as B,L as ft,c as F,z as pt,M as dt,N as mt,P as vt}from"./redocly-openapi-docs.min.index-BXAn8eur.js";import{p as G}from"./redocly-openapi-docs.min.promise-map-limit-Db_42GvV.js";import{TauriFileSystemAdapter as H}from"./redocly-openapi-docs.min.TauriFileSystemAdapter-Bzf6nZVE.js";import{d as wt,w as k}from"./redocly-openapi-docs.min.standalone-CS00-kVE.js";var R={exports:{}},X;function yt(){return X||(X=1,(function(n){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function c(s,o,l){this.fn=s,this.context=o,this.once=l||!1}function a(s,o,l,y,g){if(typeof l!="function")throw new TypeError("The listener must be a function");var m=new c(l,y||s,g),w=e?e+o:o;return s._events[w]?s._events[w].fn?s._events[w]=[s._events[w],m]:s._events[w].push(m):(s._events[w]=m,s._eventsCount++),s}function f(s,o){--s._eventsCount===0?s._events=new i:delete s._events[o]}function h(){this._events=new i,this._eventsCount=0}h.prototype.eventNames=function(){var s=[],o,l;if(this._eventsCount===0)return s;for(l in o=this._events)t.call(o,l)&&s.push(e?l.slice(1):l);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(o)):s},h.prototype.listeners=function(s){var o=e?e+s:s,l=this._events[o];if(!l)return[];if(l.fn)return[l.fn];for(var y=0,g=l.length,m=new Array(g);y<g;y++)m[y]=l[y].fn;return m},h.prototype.listenerCount=function(s){var o=e?e+s:s,l=this._events[o];return l?l.fn?1:l.length:0},h.prototype.emit=function(s,o,l,y,g,m){var w=e?e+s:s;if(!this._events[w])return!1;var u=this._events[w],S=arguments.length,P,v;if(u.fn){switch(u.once&&this.removeListener(s,u.fn,void 0,!0),S){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,o),!0;case 3:return u.fn.call(u.context,o,l),!0;case 4:return u.fn.call(u.context,o,l,y),!0;case 5:return u.fn.call(u.context,o,l,y,g),!0;case 6:return u.fn.call(u.context,o,l,y,g,m),!0}for(v=1,P=new Array(S-1);v<S;v++)P[v-1]=arguments[v];u.fn.apply(u.context,P)}else{var lt=u.length,I;for(v=0;v<lt;v++)switch(u[v].once&&this.removeListener(s,u[v].fn,void 0,!0),S){case 1:u[v].fn.call(u[v].context);break;case 2:u[v].fn.call(u[v].context,o);break;case 3:u[v].fn.call(u[v].context,o,l);break;case 4:u[v].fn.call(u[v].context,o,l,y);break;default:if(!P)for(I=1,P=new Array(S-1);I<S;I++)P[I-1]=arguments[I];u[v].fn.apply(u[v].context,P)}}return!0},h.prototype.on=function(s,o,l){return a(this,s,o,l,!1)},h.prototype.once=function(s,o,l){return a(this,s,o,l,!0)},h.prototype.removeListener=function(s,o,l,y){var g=e?e+s:s;if(!this._events[g])return this;if(!o)return f(this,g),this;var m=this._events[g];if(m.fn)m.fn===o&&(!y||m.once)&&(!l||m.context===l)&&f(this,g);else{for(var w=0,u=[],S=m.length;w<S;w++)(m[w].fn!==o||y&&!m[w].once||l&&m[w].context!==l)&&u.push(m[w]);u.length?this._events[g]=u.length===1?u[0]:u:f(this,g)}return this},h.prototype.removeAllListeners=function(s){var o;return s?(o=e?e+s:s,this._events[o]&&f(this,o)):(this._events=new i,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=e,h.EventEmitter=h,n.exports=h})(R)),R.exports}var gt=yt();const bt=wt(gt);class Z extends Error{constructor(t){super(t),this.name="TimeoutError"}}let Et=class extends Error{constructor(n){super(),this.name="AbortError",this.message=n}};const tt=n=>globalThis.DOMException===void 0?new Et(n):new DOMException(n),et=n=>{const t=n.reason===void 0?tt("This operation was aborted."):n.reason;return t instanceof Error?t:tt(t)};function St(n,t,e,i){let c;const a=new Promise((f,h)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t===Number.POSITIVE_INFINITY){f(n);return}if(i={customTimers:{setTimeout,clearTimeout},...i},i.signal){const{signal:s}=i;s.aborted&&h(et(s)),s.addEventListener("abort",()=>{h(et(s))})}c=i.customTimers.setTimeout.call(void 0,()=>{const s=`Promise timed out after ${t} milliseconds`,o=e instanceof Error?e:new Z(s);typeof n.cancel=="function"&&n.cancel(),h(o)},t),(async()=>{try{f(await n)}catch(s){h(s)}finally{i.customTimers.clearTimeout.call(void 0,c)}})()});return a.clear=()=>{clearTimeout(c),c=void 0},a}function _t(n,t,e){let i=0,c=n.length;for(;c>0;){const a=Math.trunc(c/2);let f=i+a;e(n[f],t)<=0?(i=++f,c-=a+1):c=a}return i}var x=function(n,t,e,i){if(e==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?i:e==="a"?i.call(n):i?i.value:t.get(n)},C;class Ct{constructor(){C.set(this,[])}enqueue(t,e){e={priority:0,...e};const i={priority:e.priority,run:t};if(this.size&&x(this,C,"f")[this.size-1].priority>=e.priority){x(this,C,"f").push(i);return}const c=_t(x(this,C,"f"),i,(a,f)=>f.priority-a.priority);x(this,C,"f").splice(c,0,i)}dequeue(){return x(this,C,"f").shift()?.run}filter(t){return x(this,C,"f").filter(e=>e.priority===t.priority).map(e=>e.run)}get size(){return x(this,C,"f").length}}C=new WeakMap;var p=function(n,t,e,i,c){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!c:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?c.call(n,e):c?c.value=e:t.set(n,e),e},r=function(n,t,e,i){if(e==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?i:e==="a"?i.call(n):i?i.value:t.get(n)},d,L,M,T,D,W,$,_,z,b,q,E,j,A,K,it,st,rt,nt,at,Y,Q,J,U,ot,V;class ct extends Error{}class Tt extends bt{constructor(t){var e,i,c,a;if(super(),d.add(this),L.set(this,void 0),M.set(this,void 0),T.set(this,0),D.set(this,void 0),W.set(this,void 0),$.set(this,0),_.set(this,void 0),z.set(this,void 0),b.set(this,void 0),q.set(this,void 0),E.set(this,0),j.set(this,void 0),A.set(this,void 0),K.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Ct,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(i=(e=t.intervalCap)===null||e===void 0?void 0:e.toString())!==null&&i!==void 0?i:""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(c=t.interval)===null||c===void 0?void 0:c.toString())!==null&&a!==void 0?a:""}\` (${typeof t.interval})`);p(this,L,t.carryoverConcurrencyCount,"f"),p(this,M,t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,"f"),p(this,D,t.intervalCap,"f"),p(this,W,t.interval,"f"),p(this,b,new t.queueClass,"f"),p(this,q,t.queueClass,"f"),this.concurrency=t.concurrency,this.timeout=t.timeout,p(this,K,t.throwOnTimeout===!0,"f"),p(this,A,t.autoStart===!1,"f")}get concurrency(){return r(this,j,"f")}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);p(this,j,t,"f"),r(this,d,"m",U).call(this)}async add(t,e={}){return e={timeout:this.timeout,throwOnTimeout:r(this,K,"f"),...e},new Promise((i,c)=>{r(this,b,"f").enqueue(async()=>{var a,f,h;p(this,E,(f=r(this,E,"f"),f++,f),"f"),p(this,T,(h=r(this,T,"f"),h++,h),"f");try{if(!((a=e.signal)===null||a===void 0)&&a.aborted)throw new ct("The task was aborted.");let s=t({signal:e.signal});e.timeout&&(s=St(Promise.resolve(s),e.timeout)),e.signal&&(s=Promise.race([s,r(this,d,"m",ot).call(this,e.signal)]));const o=await s;i(o),this.emit("completed",o)}catch(s){if(s instanceof Z&&!e.throwOnTimeout){i();return}c(s),this.emit("error",s)}finally{r(this,d,"m",rt).call(this)}},e),this.emit("add"),r(this,d,"m",Y).call(this)})}async addAll(t,e){return Promise.all(t.map(async i=>this.add(i,e)))}start(){return r(this,A,"f")?(p(this,A,!1,"f"),r(this,d,"m",U).call(this),this):this}pause(){p(this,A,!0,"f")}clear(){p(this,b,new(r(this,q,"f")),"f")}async onEmpty(){r(this,b,"f").size!==0&&await r(this,d,"m",V).call(this,"empty")}async onSizeLessThan(t){r(this,b,"f").size<t||await r(this,d,"m",V).call(this,"next",()=>r(this,b,"f").size<t)}async onIdle(){r(this,E,"f")===0&&r(this,b,"f").size===0||await r(this,d,"m",V).call(this,"idle")}get size(){return r(this,b,"f").size}sizeBy(t){return r(this,b,"f").filter(t).length}get pending(){return r(this,E,"f")}get isPaused(){return r(this,A,"f")}}L=new WeakMap,M=new WeakMap,T=new WeakMap,D=new WeakMap,W=new WeakMap,$=new WeakMap,_=new WeakMap,z=new WeakMap,b=new WeakMap,q=new WeakMap,E=new WeakMap,j=new WeakMap,A=new WeakMap,K=new WeakMap,d=new WeakSet,it=function(){return r(this,M,"f")||r(this,T,"f")<r(this,D,"f")},st=function(){return r(this,E,"f")<r(this,j,"f")},rt=function(){var n;p(this,E,(n=r(this,E,"f"),n--,n),"f"),r(this,d,"m",Y).call(this),this.emit("next")},nt=function(){r(this,d,"m",J).call(this),r(this,d,"m",Q).call(this),p(this,z,void 0,"f")},at=function(){const n=Date.now();if(r(this,_,"f")===void 0){const t=r(this,$,"f")-n;if(t<0)p(this,T,r(this,L,"f")?r(this,E,"f"):0,"f");else return r(this,z,"f")===void 0&&p(this,z,setTimeout(()=>{r(this,d,"m",nt).call(this)},t),"f"),!0}return!1},Y=function(){if(r(this,b,"f").size===0)return r(this,_,"f")&&clearInterval(r(this,_,"f")),p(this,_,void 0,"f"),this.emit("empty"),r(this,E,"f")===0&&this.emit("idle"),!1;if(!r(this,A,"f")){const n=!r(this,d,"a",at);if(r(this,d,"a",it)&&r(this,d,"a",st)){const t=r(this,b,"f").dequeue();return t?(this.emit("active"),t(),n&&r(this,d,"m",Q).call(this),!0):!1}}return!1},Q=function(){r(this,M,"f")||r(this,_,"f")!==void 0||(p(this,_,setInterval(()=>{r(this,d,"m",J).call(this)},r(this,W,"f")),"f"),p(this,$,Date.now()+r(this,W,"f"),"f"))},J=function(){r(this,T,"f")===0&&r(this,E,"f")===0&&r(this,_,"f")&&(clearInterval(r(this,_,"f")),p(this,_,void 0,"f")),p(this,T,r(this,L,"f")?r(this,E,"f"):0,"f"),r(this,d,"m",U).call(this)},U=function(){for(;r(this,d,"m",Y).call(this););},ot=async function(n){return new Promise((t,e)=>{n.addEventListener("abort",()=>{e(new ct("The task was aborted."))},{once:!0})})},V=async function(n,t){return new Promise(e=>{const i=()=>{t&&!t()||(this.off(n,i),e())};this.on(n,i)})};class At{constructor(t){this.apisStorage=t}apisStorage;data=new Map;loading=new Set;pQueue=new Tt({concurrency:20});async get(t){return this.data.has(t)?this.data.get(t)??null:(await this.loadAndParse(t),this.data.get(t)??null)}async load(t,e=!1){this.data.has(t)&&!e||await this.loadAndParse(t,e)}async loadAndParse(t,e=!1){if(this.loading.has(t)){await this.pQueue.add(()=>this.get(t));return}e&&this.data.delete(t),this.loading.add(t),await this.pQueue.add(async()=>{const i=ht(t)?N.WEB:N.FS,c=i===N.WEB?t:await this.apisStorage.getAbsolutePath(t);try{const{definition:a,fileDependencies:f}=await ut(c);if(!a){this.data.set(t,null),await O(t);return}const h=this.apisStorage.parse({uri:t,type:i,content:a});this.data.set(t,{...h,fileDependencies:f}),await O(t)}catch(a){if(this.data.set(t,null),a instanceof Error&&(a.message.includes("Unsupported specification")||a.message.includes("File not found"))){await O(t);return}console.info("Error loading api "+t,a),await B(t,a);return}}),this.loading.delete(t)}get size(){return this.data.size}delete(t){this.data.delete(t)}getAll(){return Array.from(this.data.values()).filter(t=>t!==null)}clear(){this.data.clear(),this.loading.clear()}}class Pt extends ft{apiLoader;constructor(t,e,i){const c=new H(t.systemFilesDir),a=new H(t.userFilesDir);super(c,a,t,!0,!1,e,i),this.apiLoader=new At(this.apisStorage),this.setupWriteListeners(a)}setupWriteListeners(t){t.on("write-start",e=>{this.addWatchExcludedId(e)}),t.on("write-end",e=>{this.removeWatchExcludedId(e)})}async read(){const t=this.telemetry?.startSpan("com.redocly.storage.read",[F("storageOperation","read","storage")],void 0),e=this.telemetry?.startSpan("com.redocly.storage.loadUserState",[F("storageOperation","loadUserState","storage")],t?.parentCtx),[i,c,a]=await Promise.all([this.activeEnvironmentIdStorage.read(),this.tabsStateStorage.read(),this.environmentsStorage.read()]);e?.setAttribute("status","completed"),e?.setAttribute("environmentCount",a.length),e?.setStatus(k.OK),e?.end();const{apiFiles:f,collectionFiles:h}=await this.detectProjectFiles(t);await this.loadAndParseApis(f,t);const s=(await this.loadAndParseCollections(h,t)).filter(l=>l!==null);this.collectionsStorage.setItemIds(s.map(l=>l.id));const o=this.apiLoader.getAll();return this.apisStorage.setItemIds(o.map(l=>l.id)),t?.setAttribute("status","completed"),t?.setStatus(k.OK),t?.end(),{project:this.project,activeEnvironmentId:i,tabsState:c,environments:a,apis:o,collections:s,configFileError:this.getEnvironmentsConfigError()}}async detectProjectFiles(t){const e=this.telemetry?.startSpan("com.redocly.storage.detectFiles",[F("storageOperation","detectFiles","storage")],t?.parentCtx),{api_files:i,collection_files:c}=await pt("fs_scan",{dir:this.project.userFilesDir});return e?.setAttribute("status","completed"),e?.setAttribute("filesCount",i.length+c.length),e?.setAttribute("apiFilesCount",i.length),e?.setAttribute("collectionFilesCount",c.length),e?.setStatus(k.OK),e?.end(),{apiFiles:i,collectionFiles:c}}readEnviroments(){return this.environmentsStorage.read()}deleteApiFromCache(t){this.apiLoader.delete(t)}async loadAndParseApis(t,e,i=!1){const c=this.telemetry?.startSpan("com.redocly.storage.parseApis",[{...F("storageOperation","parseApis","storage"),apisCount:t.length}],e?.parentCtx),a=await G(t,20,async f=>{try{return await this.apiLoader.load(f.relative_path,i),this.apiLoader.get(f.relative_path)}catch(h){return console.info(`Error parsing YAML/JSON file ${f.absolute_path}:`,h),await B(f.relative_path,h),null}});return c?.setAttribute("status","completed"),c?.setAttribute("parsedApisCount",this.apiLoader.size),c?.setStatus(k.OK),c?.end(),a}async loadAndParseCollections(t,e){const i=this.telemetry?.startSpan("com.redocly.storage.parseCollections",[{...F("storageOperation","parseCollections","storage"),collectionsCount:t.length}],e?.parentCtx),c=await G(t,20,async a=>{try{const f=await this.userFilesStorage.get(a.relative_path);if(!f)return null;const h=dt.load(f);if(typeof h!="object"||h===null||typeof h.arazzo!="string")return await O(a.relative_path),null;const s=[];await Promise.all(h.sourceDescriptions?.map(async y=>{const g=y.type,m=y.url,w=!g||g==="openapi",u=await mt({projectPath:this.project.userFilesDir,apiUrl:m,collectionId:a.relative_path});if(w){const S=await this.apiLoader.get(u);S&&s.push(S)}}));const o=await vt.join(this.project.userFilesDir,a.relative_path),l=await this.collectionsStorage.parse({uri:a.relative_path,type:N.FS,content:h,fileDependencies:new Set([o])},s);return await O(a.relative_path),l}catch(f){return console.info(`Error parsing Arazzo file ${a.relative_path}:`,f),await B(a.relative_path,f),null}});return i?.setAttribute("status","completed"),i?.setAttribute("parsedCollectionsCount",c.length),i?.setStatus(k.OK),i?.end(),c}}export{Pt as TauriRootStorage};
|