@powerduck/tree 0.7.4 → 0.7.7

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/README.md CHANGED
@@ -554,3 +554,59 @@ npm run typecheck # Type check with tsc
554
554
  ## License
555
555
 
556
556
  MIT
557
+
558
+
559
+ ## Quality and interaction updates
560
+
561
+ The tree inherits `powerduck-react` color tokens without overwriting the host's
562
+ palette. Standalone instances can use `theme="light"` or `theme="dark"`; inherited
563
+ `data-theme` also supplies matching fallback colors. Menus carry the same tokens
564
+ when portalled outside the tree. Search controls, row selection, focus rings,
565
+ buttons, and hover states use the shared palette and radius tokens. Scrollbar
566
+ thumbs appear on hover or keyboard interaction, with visible touch affordances.
567
+
568
+ Keyboard navigation uses a single row tab stop. Up/Down, Home/End, and Left/Right
569
+ navigate visible rows and branches. Typing a label prefix finds a visible row.
570
+ Enter or Space activates the row. Shift+F10 opens the row's context menu; menu
571
+ arrows skip disabled actions, and Escape closes the menu and returns focus.
572
+ Context-menu separators now appear above their actions rather than replacing them.
573
+
574
+ For more than 500 visible rows, fixed-height trees automatically render a window
575
+ around the viewport. Set `virtualized={false}` to opt out or `virtualized={true}`
576
+ to enable it for smaller trees. Document variants and custom `renderNode` content
577
+ retain full rendering because their heights may vary. Give the tree a bounded
578
+ parent height or `maxHeight` to benefit from windowing. Row sizing follows `size`;
579
+ custom variable-height rows should disable windowing. Imperative node location
580
+ reveals ancestors, clears search, and scrolls after the new rows are committed.
581
+
582
+ Core traversal, transformation, and nested-tag assembly avoid recursive stack
583
+ growth. Object-reference cycles terminate safely; transforming malformed graphs
584
+ omits cyclic edges. IDs must still be unique, and caller-owned inputs should be
585
+ treated as immutable. Pass a new tree reference when changing data. Expansion
586
+ callbacks are notifications for local state, not a controlled expansion prop.
587
+
588
+ Schema generation accepts `maxNodes` (default 10,000; bounded to 1–100,000).
589
+ `maxDepth` defaults to 8 and is bounded to 0–128; non-finite limits use the default.
590
+ Generation warns when the node budget is exhausted or an object cycle is found.
591
+ Literal dots, brackets, and backslashes in schema path segments are escaped in
592
+ node IDs; use `metadata.jsonPath` or `findSchemaNodeByPath` for exact lookup.
593
+ Nested documentation tag groups are limited to 128 levels and 10,000 generated
594
+ groups with a warning.
595
+
596
+ JSON Patch reorder notifications are emitted only for source arrays whose
597
+ metadata paths match the rendered sibling order. Object-property paths and
598
+ sorted/filtered views do not receive misleading array move patches. Dragging
599
+ rechecks group and drop constraints before committing a move. Native drag and
600
+ drop is a desktop interaction; touch reordering is not implemented.
601
+
602
+ ### Local verification
603
+
604
+ ```sh
605
+ npm run check # Source language, package and preview types, tests, build
606
+ npm run preview # Interactive examples at http://127.0.0.1:4174
607
+ npm run benchmark # Build and compare the old/new sorting comparator
608
+ ```
609
+
610
+ The benchmark reports medians from seven runs over a deterministic shuffled input.
611
+ It measures sorting, traversal, and filtering only, not end-to-end browser latency.
612
+ See [QUALITY.md](./QUALITY.md) for findings, evidence, and remaining limitations.
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,a={};function s(e){return[...e].sort((e,t)=>{const n=e.order??Number.MAX_SAFE_INTEGER,o=t.order??Number.MAX_SAFE_INTEGER;if(n!==o)return n-o;return e.name.localeCompare(t.name,"en-US",{numeric:!0,sensitivity:"base"})||e.id.localeCompare(t.id)})}((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})(a,{buildDocTree:()=>z,buildOpenApiTree:()=>y,buildSchemaTree:()=>v,findSchemaNodeByPath:()=>N,formatSchemaType:()=>C}),module.exports=(e=a,((e,a,s,i)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let c of o(a))r.call(e,c)||c===s||t(e,c,{get:()=>a[c],enumerable:!(i=n(a,c))||i.enumerable});return e})(t({},"__esModule",{value:!0}),e));var i=["get","put","post","delete","options","head","patch","trace"],c={showInternal:!1,showComponents:!0,showWebhooks:!0,defaultExpandDepth:2};function d(e){return"object"!=typeof e||null===e||Array.isArray(e)?null:e}function p(e){return"string"==typeof e&&e.trim().length>0?e.trim():void 0}function u(e){return"boolean"==typeof e?e:void 0}function m(e){return Array.isArray(e)?e:void 0}function f(e,t){return!t&&(!0===u(e["x-scalar-ignore"])||!0===u(e["x-internal"]))}function h(e){return"number"==typeof(t=e["x-order"])&&Number.isFinite(t)?t:void 0;var t}function l(e){return p(e["x-displayName"])}function g(e,t,n,o){const r=new Map;for(const t of e)r.set(t.name,t);const a=new Map;for(const t of e){if(!t.parent){a.set(t.name,null);continue}if(!r.has(t.parent)){o.push(`Tag "${t.name}" references unknown parent "${t.parent}", treating as root.`),a.set(t.name,null);continue}const e=[t.name];let n=t.parent,s=!1;for(;n;){if(e.includes(n)){s=!0,o.push(`Circular tag reference detected: ${e.join(" -> ")} -> ${n}. Breaking cycle.`);break}e.push(n),n=r.get(n)?.parent}a.set(t.name,s?null:t.parent)}const i=new Map;for(const e of t){if(f(e.raw,n.showInternal))continue;const t=e.tags.length>0?e.tags:["Other"];for(const n of t){const t=i.get(n)??[];t.push(e),i.set(n,t)}}const c=new Map;for(const t of e){const e=a.get(t.name)??null??"__root__",n=c.get(e)??[];n.push(t),c.set(e,n)}const d=e=>s((c.get(e)??[]).map(e=>{const t=(e=>{const t=(i.get(e.name)??[]).map(t=>({id:`op:${e.name}:${t.id}`,name:t.name,order:h(t.raw),metadata:{method:t.method,path:t.path,operationId:t.operationId,deprecated:t.deprecated,summary:t.summary,pointer:t.pointer,source:"oas32-parent",kind:"operation"}}));return{id:`tag:${e.name}`,name:e.displayName,order:e.order,children:s(t),metadata:{source:"oas32-parent",kind:"tag"}}})(e),n=d(e.name);return n.length>0&&(t.children=s([...t.children??[],...n])),t})),p=d("__root__"),u=i.get("Other")??[];if(u.length>0){const e=u.map(e=>({id:`op:Other:${e.id}`,name:e.name,order:h(e.raw),metadata:{method:e.method,path:e.path,operationId:e.operationId,deprecated:e.deprecated,summary:e.summary,pointer:e.pointer,source:"fallback",kind:"operation"}}));p.push({id:"tag:Other",name:"Other",order:Number.MAX_SAFE_INTEGER,children:s(e),metadata:{source:"fallback",kind:"tag"}})}return s(p)}function y(e,t={}){const n={...c,...t},o=[],r=d(e);if(!r)return{root:{id:"root",name:"OpenAPI",children:[],metadata:{kind:"root"}},warnings:["Document is null or not an object."]};const a=function(e){const t=d(e.paths);if(!t)return[];const n=[];for(const[e,o]of Object.entries(t)){const t=d(o);if(t)for(const o of i){const r=t[o];if(null==r)continue;const a=d(r);if(!a)continue;const s=p(a.operationId),i=p(a.summary),c=m(a.tags)?.filter(e=>"string"==typeof e).map(e=>e.trim()).filter(e=>e.length>0)??[],f=i??s??`${o.toUpperCase()} ${e}`,h=s??`${o}:${e}`,l=`/paths/${encodeURIComponent(e)}/${o}`;n.push({id:h,path:e,method:o,name:f,summary:i,operationId:s,deprecated:!0===u(a.deprecated),tags:c,pointer:l,raw:a})}}return n}(r),y=function(e){const t=m(e.tags);if(!t)return[];const n=[];for(const e of t){const t=d(e),o=p(t?.name);o&&t&&n.push({name:o,displayName:l(t)??o,description:p(t.description),parent:p(t.parent),order:h(t),raw:t})}return n}(r);let $;if(function(e){return e.some(e=>void 0!==e.parent)}(y))$=g(y,a,n,o);else{const e=function(e){const t=m(e["x-tagGroups"]);if(!t)return[];const n=(e,t)=>{const o=d(e),r=p(o?.name),a=m(o?.tags)?.filter(e=>"string"==typeof e).map(e=>e.trim()).filter(e=>e.length>0)??[];if(!r)return null;const s=m(o?.groups)?.map((e,t)=>n(e,t)).filter(e=>null!==e)??[];return{name:r,tags:a,groups:s.length>0?s:void 0,order:h(o??{})??t}};return t.map((e,t)=>n(e,t)).filter(e=>null!==e)}(r);$=e.length>0?function(e,t,n,o){const r=new Map;for(const e of t)r.set(e.name,e.displayName);const a=new Map;for(const e of n)if(!f(e.raw,o.showInternal))for(const t of e.tags){const n=a.get(t)??[];n.push(e),a.set(t,n)}const i=e=>(a.get(e)??[]).map(t=>({id:`op:${e}:${t.id}`,name:t.name,order:h(t.raw),metadata:{method:t.method,path:t.path,operationId:t.operationId,deprecated:t.deprecated,summary:t.summary,pointer:t.pointer,source:"tag-group",kind:"operation"}})),c=e=>({id:`tag:${e}`,name:r.get(e)??e,children:s(i(e)),metadata:{source:"tag-group",kind:"tag"}}),d=e=>{const t=[];for(const n of e.tags){const e=a.get(n);e?.length&&t.push(c(n))}for(const n of e.groups??[])t.push(d(n));return{id:`tag-group:${e.name}`,name:e.name,order:e.order,children:s(t),metadata:{source:"tag-group",kind:"tag-group"}}};return s(e.map(d))}(e,y,a,n):function(e,t,n){const o=new Map,r=new Map;for(let t=0;t<e.length;t+=1){const n=e[t];r.set(n.name,n.order??t)}for(const e of t){if(f(e.raw,n.showInternal))continue;const t=e.tags.length>0?e.tags:["Other"];for(const n of t){const t=o.get(n)??[];t.push(e),o.set(n,t)}}const a=new Map;for(const t of e)a.set(t.name,t.displayName);const i=[];for(const[e,t]of o){const n=t.map(t=>({id:`op:${e}:${t.id}`,name:t.name,order:h(t.raw),metadata:{method:t.method,path:t.path,operationId:t.operationId,deprecated:t.deprecated,summary:t.summary,pointer:t.pointer,source:"tag",kind:"operation"}}));i.push({id:`tag:${e}`,name:a.get(e)??e,order:"Other"===e?Number.MAX_SAFE_INTEGER:r.get(e),children:s(n),metadata:{source:"tag",kind:"tag"}})}return s(i)}(y,a,n)}const k=function(e,t){if(!t.showWebhooks)return;const n=d(e.webhooks);if(!n)return;const o=[];for(const[e,r]of Object.entries(n)){const n=d(r);if(n)for(const r of i){const a=d(n[r]);if(!a||f(a,t.showInternal))continue;const s=p(a.operationId),i=p(a.summary),c=i??s??`${r.toUpperCase()} ${e}`;o.push({id:`webhook:${e}:${r}`,name:c,order:h(a),metadata:{method:r,path:e,operationId:s,deprecated:!0===u(a.deprecated),summary:i,pointer:`/webhooks/${encodeURIComponent(e)}/${r}`,source:"tag",kind:"webhook"}})}}return 0!==o.length?{id:"section:webhooks",name:"Webhooks",order:Number.MAX_SAFE_INTEGER-2,children:s(o),metadata:{source:"section",kind:"section",section:"webhooks"}}:void 0}(r,n),w=function(e,t){if(!t.showComponents)return;const n=d(e.components),o=d(n?.schemas);if(!o)return;const r=[];for(const[e,n]of Object.entries(o)){const o=d(n);o&&!f(o,t.showInternal)&&r.push({id:`schema:${e}`,name:e,order:h(o),metadata:{pointer:`/components/schemas/${encodeURIComponent(e)}`,source:"tag",kind:"schema"}})}return 0!==r.length?{id:"section:components",name:"Components",order:Number.MAX_SAFE_INTEGER-1,children:s(r),metadata:{source:"section",kind:"section",section:"components"}}:void 0}(r,n);return{root:{id:"root",name:"OpenAPI",children:s([{id:"section:apis",name:"APIs",children:$,metadata:{kind:"section",source:"section",section:"apis"},order:0},...k?[k]:[],...w?[w]:[]]),metadata:{kind:"root"}},warnings:o}}var $={openapi:0,info:1,servers:2,paths:3,webhooks:4,components:5,security:6,tags:7,externalDocs:8,jsonSchemaDialect:9},k={maxDepth:8,showDeprecated:!0,expandCombinators:!0,showArrayItems:!0},w=new Set(["string","number","integer","boolean","null"]);function b(e){return"object"!=typeof e||null===e||Array.isArray(e)?null:e}function I(e){return"string"==typeof e&&e.trim().length>0?e.trim():void 0}function A(e){return"boolean"==typeof e?e:void 0}function O(e){return Array.isArray(e)?e:void 0}function j(e){return e?Array.isArray(e)?e.join(" | "):e:"any"}function _(e,t,n,o,r,a){const i=function(e){const t=e.type;return"string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)?t:void 0}(t),c=I(t.format),d=I(t.description),p=!0===A(t.deprecated),u=function(e){if(!e)return"unknown";switch(Array.isArray(e)?e[0]:e){case"object":return"object";case"array":return"array";case"string":return"string";case"number":return"number";case"integer":return"integer";case"boolean":return"boolean";case"null":return"null";default:return"unknown"}}(i),m={jsonPath:n,type:i,format:c,required:a,deprecated:p,description:d,kind:u},f=I(t.$ref);if(f){if(r.refStack.has(f))return r.warnings.push(`Circular $ref detected at ${n.join(".")}: ${f}. Breaking recursion.`),{id:n.join(".")||"root",name:e,metadata:{...m,kind:"ref",isLeaf:!0}};r.refStack.add(f)}let h,l=function(e){return!!e&&(Array.isArray(e)?e.every(e=>w.has(e)):w.has(e))}(i);if(o>=r.options.maxDepth)return f&&r.refStack.delete(f),{id:n.join(".")||"root",name:e,metadata:{...m,isLeaf:!0}};const g=b(t.properties);if(g){const e=O(t.required)??[],a=new Set(e.filter(e=>"string"==typeof e)),i=[];for(const[e,t]of Object.entries(g)){const s=b(t);s&&((r.options.showDeprecated||!0!==A(s.deprecated))&&i.push(_(e,s,[...n,"properties",e],o+1,r,a.has(e))))}h=[...h??[],...s(i)],l=!1}if(r.options.showArrayItems&&"array"===i){const e=b(t.items);if(e){h=[...h??[],_("items",e,[...n,"items"],o+1,r,!1)],l=!1}else m.hasItems=!1}if(r.options.expandCombinators){const e=[{key:"allOf",kind:"allOf"},{key:"anyOf",kind:"anyOf"},{key:"oneOf",kind:"oneOf"}];for(const{key:a,kind:i}of e){const e=O(t[a]);if(!e?.length)continue;const c=e.map((e,t)=>{const s=b(e);return s?_(`[${t}]`,s,[...n,a,String(t)],o+1,r,!1):{id:`${n.join(".")}.${a}[${t}]`,name:`[${t}]`,metadata:{jsonPath:[...n,a,String(t)],kind:"unknown",isLeaf:!0}}});h=[...h??[],{id:`${n.join(".")}.${a}`,name:a,children:s(c),metadata:{jsonPath:[...n,a],kind:i}}],l=!1}}const y=O(t.enum);return y?.length&&!h?.length&&(m.kind="enum",l=!0),f&&r.refStack.delete(f),{id:n.join(".")||"root",name:e,order:$[e],metadata:{...m,isLeaf:l},children:h}}function v(e,t={}){const n={...k,...t},o=[],r=b(e);if(!r)return{root:{id:"root",name:"Schema",metadata:{jsonPath:[],kind:"root",isLeaf:!0}},warnings:["Schema is null or not an object."]};return{root:_("root",r,[],0,{options:n,warnings:o,refStack:new Set},!0),warnings:o}}function N(e,t){if(0===t.length)return e;const n=t.join("."),o=[e];for(;o.length>0;){const e=o.shift();if(!e)continue;const t=e.metadata?.jsonPath?.join(".");if(t===n)return e;for(const t of e.children??[])o.push(t)}}function C(e){return"enum"===e.kind?"enum":"ref"===e.kind?"$ref":e.format?`${j(e.type)} (${e.format})`:j(e.type)}var E=["get","put","post","delete","options","head","patch","trace"],M={showInternal:!1,showComponents:!1,showWebhooks:!0,expandOperationDetails:!1};function S(e){return"object"!=typeof e||null===e||Array.isArray(e)?null:e}function R(e){return"string"==typeof e&&e.trim().length>0?e.trim():void 0}function x(e){return"boolean"==typeof e?e:void 0}function T(e){return Array.isArray(e)?e:void 0}function U(e,t){return!t&&(!0===x(e["x-scalar-ignore"])||!0===x(e["x-internal"]))}function P(e){const t=e["x-order"];return"number"==typeof t&&Number.isFinite(t)?t:void 0}function D(e){return R(e["x-displayName"])}function G(e,t){const n=[],o=T(e.parameters);if(o?.length){const e=function(e,t){const n=[];for(const o of e){const e=S(o);if(!e)continue;const r=R(e.name),a=R(e.in);if(!r||!a)continue;const s=`${a}:${r}`;n.push({id:`${t}/parameters/${encodeURIComponent(s)}`,name:r,metadata:{paramIn:a,required:!0===x(e.required),description:R(e.description),pointer:`${t}/parameters`,kind:"parameter"}})}return s(n)}(o,t);e.length>0&&n.push({id:`${t}/parameters`,name:"Parameters",children:e,metadata:{pointer:`${t}/parameters`,kind:"parameters"}})}const r=S(e.requestBody);if(r){const e=S(r.content),o=[];if(e)for(const[n]of Object.entries(e))o.push({id:`${t}/requestBody/content/${encodeURIComponent(n)}`,name:n,metadata:{contentType:n,pointer:`${t}/requestBody/content/${encodeURIComponent(n)}`,kind:"content"}});n.push({id:`${t}/requestBody`,name:"Request Body",metadata:{description:R(r.description),required:!0===x(r.required),pointer:`${t}/requestBody`,kind:"request-body"},children:o.length>0?o:void 0})}const a=S(e.responses);if(a){const e=function(e,t){const n=[];for(const[o,r]of Object.entries(e)){const e=S(r);if(!e)continue;const a=R(e.description),s=S(e.content),i=[];if(s)for(const[e]of Object.entries(s))i.push({id:`${t}/responses/${encodeURIComponent(o)}/content/${encodeURIComponent(e)}`,name:e,metadata:{contentType:e,pointer:`${t}/responses/${encodeURIComponent(o)}/content/${encodeURIComponent(e)}`,kind:"content"}});n.push({id:`${t}/responses/${encodeURIComponent(o)}`,name:o,metadata:{statusCode:o,description:a,pointer:`${t}/responses/${encodeURIComponent(o)}`,kind:"response"},children:i.length>0?i:void 0})}return s(n)}(a,t);e.length>0&&n.push({id:`${t}/responses`,name:"Responses",children:e,metadata:{pointer:`${t}/responses`,kind:"responses"}})}return n}function q(e,t,n,o){const r=t.expandOperationDetails?G(e.raw,e.pointer):void 0;return{id:`op:${o}:${e.id}`,name:e.name,order:P(e.raw),metadata:{method:e.method,path:e.path,operationId:e.operationId,deprecated:e.deprecated,summary:e.summary,description:e.description,pointer:e.pointer,source:n,kind:"operation"},children:r&&r.length>0?r:void 0}}function F(e,t,n,o){const r=new Map;for(const t of e)r.set(t.name,t);const a=new Map;for(const t of e){if(!t.parent){a.set(t.name,null);continue}if(!r.has(t.parent)){o.push(`Tag "${t.name}" references unknown parent "${t.parent}", treating as root.`),a.set(t.name,null);continue}const e=[t.name];let n=t.parent,s=!1;for(;n;){if(e.includes(n)){s=!0,o.push(`Circular tag reference detected: ${e.join(" -> ")} -> ${n}. Breaking cycle.`);break}e.push(n),n=r.get(n)?.parent}a.set(t.name,s?null:t.parent)}const i=new Map;for(const e of t){if(U(e.raw,n.showInternal))continue;const t=e.tags.length>0?e.tags:["Other"];for(const n of t){const t=i.get(n)??[];t.push(e),i.set(n,t)}}const c=new Map;for(const t of e){const e=a.get(t.name)??null??"__root__",n=c.get(e)??[];n.push(t),c.set(e,n)}const d=e=>s((c.get(e)??[]).map(e=>{const t=(e=>{const t=(i.get(e.name)??[]).map(t=>q(t,n,"oas32-parent",e.name));return{id:`tag:${e.name}`,name:e.displayName,order:e.order,children:s(t),metadata:{description:e.description,source:"oas32-parent",kind:"tag"}}})(e),o=d(e.name);return o.length>0&&(t.children=s([...t.children??[],...o])),t})),p=d("__root__"),u=i.get("Other")??[];if(u.length>0){const e=u.map(e=>q(e,n,"fallback","Other"));p.push({id:"tag:Other",name:"Other",order:Number.MAX_SAFE_INTEGER,children:s(e),metadata:{source:"fallback",kind:"tag"}})}return s(p)}function B(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const e=S(n);if(!e||"string"!=typeof e.name)continue;const o={name:e.name};Array.isArray(e.tags)&&(o.tags=e.tags.filter(e=>"string"==typeof e)),Array.isArray(e.groups)&&(o.groups=B(e.groups)),t.push(o)}return t}function X(e,t,n,o,r,a=0){const i=[];if(e.tags)for(const a of e.tags){const e=t.get(a);if(!e||0===e.length)continue;const c=e.map(e=>q(e,r,"tag-group",a));i.push({id:`tag:${a}`,name:n.get(a)??a,order:o.get(a),children:s(c),metadata:{source:"tag-group",kind:"tag"}})}if(e.groups)for(const s of e.groups)i.push(X(s,t,n,o,r,a+1));return{id:`tag-group:${e.name}`,name:e.name,order:1e3*a,children:s(i),metadata:{source:"tag-group",kind:"tag-group"}}}function L(e,t,n,o){const r=new Map,a=new Map,i=new Map;for(let e=0;e<t.length;e+=1)a.set(t[e].name,e),i.set(t[e].name,t[e].displayName);for(const e of n){if(U(e.raw,o.showInternal))continue;const t=e.tags.length>0?e.tags:["Other"];for(const n of t){const t=r.get(n)??[];t.push(e),r.set(n,t)}}const c=B(e["x-tagGroups"]).map(e=>X(e,r,i,a,o)),d=r.get("Other");if(d&&d.length>0){const e=d.map(e=>q(e,o,"fallback","Other"));c.push({id:"tag:Other",name:"Other",order:Number.MAX_SAFE_INTEGER,children:s(e),metadata:{source:"fallback",kind:"tag"}})}return s(c)}function W(e){return e.map(e=>{const t=e.children?W(e.children):void 0,n="operation"===e.metadata?.kind?1:0,o=t?.reduce((e,t)=>e+(t.metadata?.operationCount??0),0)??0;return{...e,children:t,metadata:{...e.metadata,operationCount:n+o}}})}function z(e,t={}){const n={...M,...t},o=[],r=S(e);if(!r)return{root:{id:"root",name:"API Documentation",children:[],metadata:{kind:"root"}},warnings:["Document is null or not an object."]};const a=function(e){const t=S(e.paths);if(!t)return[];const n=[];for(const[e,o]of Object.entries(t)){const t=S(o);if(t)for(const o of E){const r=S(t[o]);if(!r)continue;const a=R(r.operationId),s=R(r.summary),i=R(r.description),c=T(r.tags)?.filter(e=>"string"==typeof e).map(e=>e.trim()).filter(e=>e.length>0)??[],d=s??a??`${o.toUpperCase()} ${e}`,p=a??`${o}:${e}`,u=`/paths/${encodeURIComponent(e)}/${o}`;n.push({id:p,path:e,method:o,name:d,summary:s,description:i,operationId:a,deprecated:!0===x(r.deprecated),tags:c,pointer:u,raw:r})}}return n}(r),i=function(e){const t=T(e.tags);if(!t)return[];const n=[];for(const e of t){const t=S(e),o=R(t?.name);o&&t&&n.push({name:o,displayName:D(t)??o,description:R(t.description),parent:R(t.parent),order:P(t)})}return n}(r);let c;c=function(e){return e.some(e=>void 0!==e.parent)}(i)?F(i,a,n,o):function(e){return Array.isArray(e["x-tagGroups"])&&e["x-tagGroups"].length>0}(r)?L(r,i,a,n):function(e,t,n){const o=new Map,r=new Map;for(let t=0;t<e.length;t+=1)r.set(e[t].name,t);for(const e of t){if(U(e.raw,n.showInternal))continue;const t=e.tags.length>0?e.tags:["Other"];for(const n of t){const t=o.get(n)??[];t.push(e),o.set(n,t)}}const a=new Map;for(const t of e)a.set(t.name,t.displayName);const i=[];for(const[e,t]of o){const o=t.map(t=>q(t,n,"tag",e));i.push({id:`tag:${e}`,name:a.get(e)??e,order:"Other"===e?Number.MAX_SAFE_INTEGER:r.get(e),children:s(o),metadata:{source:"tag",kind:"tag"}})}return s(i)}(i,a,n);const d=function(e,t){if(!t.showComponents)return;const n=S(e.components),o=S(n?.schemas);if(!o)return;const r=[];for(const[e,n]of Object.entries(o)){const o=S(n);o&&!U(o,t.showInternal)&&r.push({id:`schema:${e}`,name:e,order:P(o),metadata:{description:R(o.description),pointer:`/components/schemas/${encodeURIComponent(e)}`,source:"tag",kind:"schema"}})}return 0!==r.length?{id:"section:components",name:"Components",order:Number.MAX_SAFE_INTEGER-1,children:s(r),metadata:{source:"tag",kind:"component"}}:void 0}(r,n);return{root:{id:"root",name:"API Documentation",children:s(W([...c,...d?[d]:[]])),metadata:{kind:"root"}},warnings:o}}
1
+ "use strict";var F=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var ce=Object.prototype.hasOwnProperty;var ue=(e,t)=>{for(var o in t)F(e,o,{get:t[o],enumerable:!0})},pe=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of de(t))!ce.call(e,n)&&n!==o&&F(e,n,{get:()=>t[n],enumerable:!(r=ae(t,n))||r.enumerable});return e};var me=e=>pe(F({},"__esModule",{value:!0}),e);var Xe={};ue(Xe,{buildDocTree:()=>ie,buildOpenApiTree:()=>z,buildSchemaTree:()=>ee,findSchemaNodeByPath:()=>ne,formatSchemaType:()=>te});module.exports=me(Xe);function*fe(e,t=1/0){let o=new Set,r=[];for(let n=e.length-1;n>=0;n--)r.push({node:e[n],depth:1});for(;r.length;){let n=r.pop();if(o.has(n.node)||n.depth>t)continue;o.add(n.node),yield n;let c=n.node.children??[];for(let a=c.length-1;a>=0;a--)r.push({node:c[a],parent:n,depth:n.depth+1})}}var ge=new Intl.Collator("en-US",{numeric:!0,sensitivity:"base"});function g(e){return[...e].sort((t,o)=>{let r=(t.order??Number.MAX_SAFE_INTEGER)-(o.order??Number.MAX_SAFE_INTEGER);return(Number.isNaN(r)?0:r)||ge.compare(t.name,o.name)||t.id.localeCompare(o.id)})}function W(e){return Array.from(fe(e),({node:t,depth:o})=>({node:t,depth:o}))}function J(e,t,o){let r=new Map;for(let d of e)r.has(d.name)?o.push(`Duplicate tag "${d.name}" was ignored.`):r.set(d.name,d);let n=new Map;for(let d of r.values())d.parent&&!r.has(d.parent)&&o.push(`Tag "${d.name}" references unknown parent "${d.parent}", treating as root.`),n.set(d.name,d.parent&&r.has(d.parent)?d.parent:null);let c=new Set;for(let d of r.keys()){let u=new Set,s=d;for(;s!==null&&!c.has(s);){if(u.has(s)){o.push(`Circular tag reference detected at "${s}". Breaking cycle.`),n.set(s,null);break}u.add(s),s=n.get(s)??null}for(let p of u)c.add(p)}let a=new Map(Array.from(r,([d,u])=>[d,t(u)])),i=[];for(let[d,u]of a){let s=n.get(d);if(s==null)i.push(u);else{let p=a.get(s);(p.children??(p.children=[])).push(u)}}for(let d of a.values())d.children&&(d.children=g(d.children));return g(i)}var v=["get","put","post","delete","options","head","patch","trace"],le={showInternal:!1,showComponents:!0,showWebhooks:!0,defaultExpandDepth:2};function N(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function w(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function he(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function B(e){return typeof e=="boolean"?e:void 0}function $(e){return Array.isArray(e)?e:void 0}function M(e,t){return t?!1:B(e["x-scalar-ignore"])===!0||B(e["x-internal"])===!0}function A(e){return he(e["x-order"])}function Te(e){return w(e["x-displayName"])}function Ne(e){let t=N(e.paths);if(!t)return[];let o=[];for(let[r,n]of Object.entries(t)){let c=N(n);if(c)for(let a of v){let i=c[a];if(i==null)continue;let d=N(i);if(!d)continue;let u=w(d.operationId),s=w(d.summary),p=$(d.tags)?.filter(O=>typeof O=="string").map(O=>O.trim()).filter(O=>O.length>0)??[],f=s??u??`${a.toUpperCase()} ${r}`,m=u??`${a}:${r}`,T=`/paths/${encodeURIComponent(r)}/${a}`;o.push({id:m,path:r,method:a,name:f,summary:s,operationId:u,deprecated:B(d.deprecated)===!0,tags:p,pointer:T,raw:d})}}return o}function ye(e){let t=$(e.tags);if(!t)return[];let o=[];for(let r of t){let n=N(r),c=w(n?.name);!c||!n||o.push({name:c,displayName:Te(n)??c,description:w(n.description),parent:w(n.parent),order:A(n),raw:n})}return o}function Oe(e){return e.some(t=>t.parent!==void 0)}function be(e,t,o,r){let n=new Map;for(let s of t){if(M(s.raw,o.showInternal))continue;let p=s.tags.length>0?s.tags:["Other"];for(let f of p){let m=n.get(f)??[];m.push(s),n.set(f,m)}}let c=s=>{let f=(n.get(s.name)??[]).map(m=>({id:`op:${s.name}:${m.id}`,name:m.name,order:A(m.raw),metadata:{method:m.method,path:m.path,operationId:m.operationId,deprecated:m.deprecated,summary:m.summary,pointer:m.pointer,source:"oas32-parent",kind:"operation"}}));return{id:`tag:${s.name}`,name:s.displayName,order:s.order,children:g(f),metadata:{source:"oas32-parent",kind:"tag"}}},a=new Set(e.map(s=>s.name)),i=[...e];for(let s of n.keys())s!=="Other"&&!a.has(s)&&i.push({name:s,displayName:s,raw:{}});let d=J(i,c,r),u=n.get("Other")??[];if(u.length>0&&!e.some(s=>s.name==="Other")){let s=u.map(p=>({id:`op:Other:${p.id}`,name:p.name,order:A(p.raw),metadata:{method:p.method,path:p.path,operationId:p.operationId,deprecated:p.deprecated,summary:p.summary,pointer:p.pointer,source:"fallback",kind:"operation"}}));d.push({id:"tag:Other",name:"Other",order:Number.MAX_SAFE_INTEGER,children:g(s),metadata:{source:"fallback",kind:"tag"}})}return g(d)}function we(e){let t=$(e["x-tagGroups"]);if(!t)return[];let o=(r,n)=>{let c=N(r),a=w(c?.name),i=$(c?.tags)?.filter(u=>typeof u=="string").map(u=>u.trim()).filter(u=>u.length>0)??[];if(!a)return null;let d=$(c?.groups)?.map((u,s)=>o(u,s)).filter(u=>u!==null)??[];return{name:a,tags:i,groups:d.length>0?d:void 0,order:A(c??{})??n}};return t.map((r,n)=>o(r,n)).filter(r=>r!==null)}function ke(e,t,o,r){let n=new Map;for(let u of t)n.set(u.name,u.displayName);let c=new Map;for(let u of o)if(!M(u.raw,r.showInternal))for(let s of u.tags){let p=c.get(s)??[];p.push(u),c.set(s,p)}let a=u=>(c.get(u)??[]).map(p=>({id:`op:${u}:${p.id}`,name:p.name,order:A(p.raw),metadata:{method:p.method,path:p.path,operationId:p.operationId,deprecated:p.deprecated,summary:p.summary,pointer:p.pointer,source:"tag-group",kind:"operation"}})),i=u=>({id:`tag:${u}`,name:n.get(u)??u,children:g(a(u)),metadata:{source:"tag-group",kind:"tag"}}),d=u=>{let s=[];for(let p of u.tags)c.get(p)?.length&&s.push(i(p));for(let p of u.groups??[])s.push(d(p));return{id:`tag-group:${u.name}`,name:u.name,order:u.order,children:g(s),metadata:{source:"tag-group",kind:"tag-group"}}};return g(e.map(d))}function De(e,t,o){let r=new Map,n=new Map;for(let i=0;i<e.length;i+=1){let d=e[i];n.set(d.name,d.order??i)}for(let i of t){if(M(i.raw,o.showInternal))continue;let d=i.tags.length>0?i.tags:["Other"];for(let u of d){let s=r.get(u)??[];s.push(i),r.set(u,s)}}let c=new Map;for(let i of e)c.set(i.name,i.displayName);let a=[];for(let[i,d]of r){let u=d.map(s=>({id:`op:${i}:${s.id}`,name:s.name,order:A(s.raw),metadata:{method:s.method,path:s.path,operationId:s.operationId,deprecated:s.deprecated,summary:s.summary,pointer:s.pointer,source:"tag",kind:"operation"}}));a.push({id:`tag:${i}`,name:c.get(i)??i,order:i==="Other"?Number.MAX_SAFE_INTEGER:n.get(i),children:g(u),metadata:{source:"tag",kind:"tag"}})}return g(a)}function Ae(e,t){if(!t.showComponents)return;let o=N(e.components),r=N(o?.schemas);if(!r)return;let n=[];for(let[c,a]of Object.entries(r)){let i=N(a);!i||M(i,t.showInternal)||n.push({id:`schema:${c}`,name:c,order:A(i),metadata:{pointer:`/components/schemas/${encodeURIComponent(c)}`,source:"tag",kind:"schema"}})}if(n.length!==0)return{id:"section:components",name:"Components",order:Number.MAX_SAFE_INTEGER-1,children:g(n),metadata:{source:"section",kind:"section",section:"components"}}}function Re(e,t){if(!t.showWebhooks)return;let o=N(e.webhooks);if(!o)return;let r=[];for(let[n,c]of Object.entries(o)){let a=N(c);if(a)for(let i of v){let d=a[i],u=N(d);if(!u||M(u,t.showInternal))continue;let s=w(u.operationId),p=w(u.summary),f=p??s??`${i.toUpperCase()} ${n}`;r.push({id:`webhook:${n}:${i}`,name:f,order:A(u),metadata:{method:i,path:n,operationId:s,deprecated:B(u.deprecated)===!0,summary:p,pointer:`/webhooks/${encodeURIComponent(n)}/${i}`,source:"tag",kind:"webhook"}})}}if(r.length!==0)return{id:"section:webhooks",name:"Webhooks",order:Number.MAX_SAFE_INTEGER-2,children:g(r),metadata:{source:"section",kind:"section",section:"webhooks"}}}function z(e,t={}){let o={...le,...t},r=[],n=N(e);if(!n)return{root:{id:"root",name:"OpenAPI",children:[],metadata:{kind:"root"}},warnings:["Document is null or not an object."]};let c=Ne(n),a=ye(n),i;if(Oe(a))i=be(a,c,o,r);else{let f=we(n);f.length>0?i=ke(f,a,c,o):i=De(a,c,o)}let d=Re(n,o),u=Ae(n,o),p=[{id:"section:apis",name:"APIs",children:i,metadata:{kind:"section",source:"section",section:"apis"},order:0},...d?[d]:[],...u?[u]:[]];return{root:{id:"root",name:"OpenAPI",children:g(p),metadata:{kind:"root"}},warnings:r}}var V={openapi:0,info:1,servers:2,paths:3,webhooks:4,components:5,security:6,tags:7,externalDocs:8,jsonSchemaDialect:9},U={maxDepth:8,maxNodes:1e4,showDeprecated:!0,expandCombinators:!0,showArrayItems:!0},Y=new Set(["string","number","integer","boolean","null"]);function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function j(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function Q(e){return typeof e=="boolean"?e:void 0}function L(e){return Array.isArray(e)?e:void 0}function Se(e){let t=e.type;if(typeof t=="string"||Array.isArray(t)&&t.every(o=>typeof o=="string"))return t}function Ie(e){return e?Array.isArray(e)?e.every(t=>Y.has(t)):Y.has(e):!1}function xe(e){if(!e)return"unknown";switch(Array.isArray(e)?e[0]:e){case"object":return"object";case"array":return"array";case"string":return"string";case"number":return"number";case"integer":return"integer";case"boolean":return"boolean";case"null":return"null";default:return"unknown"}}function Z(e){return e?Array.isArray(e)?e.join(" | "):e:"any"}function S(e){return e.map(t=>t.replace(/[\\.\[\]]/g,o=>`\\${o}`)).join(".")||"root"}function P(e,t,o,r,n,c){n.remaining--;let a=Se(t),i=j(t.format),d=j(t.description),u=Q(t.deprecated)===!0,s=xe(a),p={jsonPath:o,type:a,format:i,required:c,deprecated:u,description:d,kind:s},f=j(t.$ref);if(f){if(n.refStack.has(f))return n.warnings.push(`Circular $ref detected at ${o.join(".")}: ${f}. Breaking recursion.`),{id:S(o),name:e,metadata:{...p,kind:"ref",isLeaf:!0}};n.refStack.add(f)}let m,T=Ie(a),O=n.activeSchemas.has(t);if(O&&n.warnings.push(`Circular schema object detected at ${S(o)}.`),O||r>=n.options.maxDepth||n.remaining<=0)return f&&n.refStack.delete(f),{id:S(o),name:e,metadata:{...p,isLeaf:!0}};n.activeSchemas.add(t);let k=C(t.properties);if(k){let R=L(t.required)??[],y=new Set(R.filter(b=>typeof b=="string")),q=[];for(let[b,I]of Object.entries(k)){if(n.remaining<=0)break;let x=C(I);x&&(!n.options.showDeprecated&&Q(x.deprecated)===!0||q.push(P(b,x,[...o,"properties",b],r+1,n,y.has(b))))}m=[...m??[],...g(q)],T=!1}if(n.remaining>0&&n.options.showArrayItems&&a==="array"){let R=C(t.items);if(R){let y=P("items",R,[...o,"items"],r+1,n,!1);m=[...m??[],y],T=!1}else p.hasItems=!1}if(n.options.expandCombinators){let R=[{key:"allOf",kind:"allOf"},{key:"anyOf",kind:"anyOf"},{key:"oneOf",kind:"oneOf"}];for(let{key:y,kind:q}of R){if(n.remaining<=0)break;let b=L(t[y]);if(!b?.length)continue;n.remaining--;let I=[];for(let D=0;D<b.length&&n.remaining>0;D++){let se=b[D],H=C(se);if(!H){n.remaining--,I.push({id:S([...o,y,String(D)]),name:`[${D}]`,metadata:{jsonPath:[...o,y,String(D)],kind:"unknown",isLeaf:!0}});continue}I.push(P(`[${D}]`,H,[...o,y,String(D)],r+1,n,!1))}let x={id:S([...o,y]),name:y,children:g(I),metadata:{jsonPath:[...o,y],kind:q}};m=[...m??[],x],T=!1}}return L(t.enum)?.length&&!m?.length&&(p.kind="enum",T=!0),f&&n.refStack.delete(f),n.activeSchemas.delete(t),{id:S(o),name:e,order:Object.prototype.hasOwnProperty.call(V,e)?V[e]:void 0,metadata:{...p,isLeaf:T},children:m}}function ee(e,t={}){let o={...U,...t};o.maxDepth=Number.isFinite(o.maxDepth)?Math.min(128,Math.max(0,Math.trunc(o.maxDepth))):U.maxDepth,o.maxNodes=Number.isFinite(o.maxNodes)?Math.min(1e5,Math.max(1,Math.trunc(o.maxNodes))):U.maxNodes;let r=[],n=C(e);if(!n)return{root:{id:"root",name:"Schema",metadata:{jsonPath:[],kind:"root",isLeaf:!0}},warnings:["Schema is null or not an object."]};let c={options:o,warnings:r,refStack:new Set,activeSchemas:new Set,remaining:o.maxNodes},a=P("root",n,[],0,c,!0);return c.remaining<=0&&r.push(`Schema node limit (${o.maxNodes}) reached; remaining branches were omitted.`),{root:a,warnings:r}}function ne(e,t){if(t.length===0)return e;let o=JSON.stringify(t),r=[e],n=new Set;for(let c=0;c<r.length;c++){let a=r[c];if(!a||n.has(a))continue;if(n.add(a),JSON.stringify(a.metadata?.jsonPath)===o)return a;for(let d of a.children??[])r.push(d)}}function te(e){return e.kind==="enum"?"enum":e.kind==="ref"?"$ref":e.format?`${Z(e.type)} (${e.format})`:Z(e.type)}var $e=["get","put","post","delete","options","head","patch","trace"],Me={showInternal:!1,showComponents:!1,showWebhooks:!0,expandOperationDetails:!1};function l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function h(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function E(e){return typeof e=="boolean"?e:void 0}function K(e){return Array.isArray(e)?e:void 0}function _(e,t){return t?!1:E(e["x-scalar-ignore"])===!0||E(e["x-internal"])===!0}function X(e){let t=e["x-order"];return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Ce(e){return h(e["x-displayName"])}function Ee(e,t){let o=[];for(let r of e){let n=l(r);if(!n)continue;let c=h(n.name),a=h(n.in);if(!c||!a)continue;let i=`${a}:${c}`;o.push({id:`${t}/parameters/${encodeURIComponent(i)}`,name:c,metadata:{paramIn:a,required:E(n.required)===!0,description:h(n.description),pointer:`${t}/parameters`,kind:"parameter"}})}return g(o)}function Ge(e,t){let o=[];for(let[r,n]of Object.entries(e)){let c=l(n);if(!c)continue;let a=h(c.description),i=l(c.content),d=[];if(i)for(let[u]of Object.entries(i))d.push({id:`${t}/responses/${encodeURIComponent(r)}/content/${encodeURIComponent(u)}`,name:u,metadata:{contentType:u,pointer:`${t}/responses/${encodeURIComponent(r)}/content/${encodeURIComponent(u)}`,kind:"content"}});o.push({id:`${t}/responses/${encodeURIComponent(r)}`,name:r,metadata:{statusCode:r,description:a,pointer:`${t}/responses/${encodeURIComponent(r)}`,kind:"response"},children:d.length>0?d:void 0})}return g(o)}function qe(e,t){let o=[],r=K(e.parameters);if(r?.length){let a=Ee(r,t);a.length>0&&o.push({id:`${t}/parameters`,name:"Parameters",children:a,metadata:{pointer:`${t}/parameters`,kind:"parameters"}})}let n=l(e.requestBody);if(n){let a=l(n.content),i=[];if(a)for(let[d]of Object.entries(a))i.push({id:`${t}/requestBody/content/${encodeURIComponent(d)}`,name:d,metadata:{contentType:d,pointer:`${t}/requestBody/content/${encodeURIComponent(d)}`,kind:"content"}});o.push({id:`${t}/requestBody`,name:"Request Body",metadata:{description:h(n.description),required:E(n.required)===!0,pointer:`${t}/requestBody`,kind:"request-body"},children:i.length>0?i:void 0})}let c=l(e.responses);if(c){let a=Ge(c,t);a.length>0&&o.push({id:`${t}/responses`,name:"Responses",children:a,metadata:{pointer:`${t}/responses`,kind:"responses"}})}return o}function Je(e){let t=l(e.paths);if(!t)return[];let o=[];for(let[r,n]of Object.entries(t)){let c=l(n);if(c)for(let a of $e){let i=c[a],d=l(i);if(!d)continue;let u=h(d.operationId),s=h(d.summary),p=h(d.description),f=K(d.tags)?.filter(k=>typeof k=="string").map(k=>k.trim()).filter(k=>k.length>0)??[],m=s??u??`${a.toUpperCase()} ${r}`,T=u??`${a}:${r}`,O=`/paths/${encodeURIComponent(r)}/${a}`;o.push({id:T,path:r,method:a,name:m,summary:s,description:p,operationId:u,deprecated:E(d.deprecated)===!0,tags:f,pointer:O,raw:d})}}return o}function Be(e){let t=K(e.tags);if(!t)return[];let o=[];for(let r of t){let n=l(r),c=h(n?.name);!c||!n||o.push({name:c,displayName:Ce(n)??c,description:h(n.description),parent:h(n.parent),order:X(n)})}return o}function Pe(e){return e.some(t=>t.parent!==void 0)}function G(e,t,o,r){let n=t.expandOperationDetails?qe(e.raw,e.pointer):void 0;return{id:`op:${r}:${e.id}`,name:e.name,order:X(e.raw),metadata:{method:e.method,path:e.path,operationId:e.operationId,deprecated:e.deprecated,summary:e.summary,description:e.description,pointer:e.pointer,source:o,kind:"operation"},children:n&&n.length>0?n:void 0}}function _e(e,t,o,r){let n=new Map;for(let s of t){if(_(s.raw,o.showInternal))continue;let p=s.tags.length>0?s.tags:["Other"];for(let f of p){let m=n.get(f)??[];m.push(s),n.set(f,m)}}let c=s=>{let f=(n.get(s.name)??[]).map(m=>G(m,o,"oas32-parent",s.name));return{id:`tag:${s.name}`,name:s.displayName,order:s.order,children:g(f),metadata:{description:s.description,source:"oas32-parent",kind:"tag"}}},a=new Set(e.map(s=>s.name)),i=[...e];for(let s of n.keys())s!=="Other"&&!a.has(s)&&i.push({name:s,displayName:s});let d=J(i,c,r),u=n.get("Other")??[];if(u.length>0&&!e.some(s=>s.name==="Other")){let s=u.map(p=>G(p,o,"fallback","Other"));d.push({id:"tag:Other",name:"Other",order:Number.MAX_SAFE_INTEGER,children:g(s),metadata:{source:"fallback",kind:"tag"}})}return g(d)}function Fe(e,t,o){let r=new Map,n=new Map;for(let i=0;i<e.length;i+=1)n.set(e[i].name,i);for(let i of t){if(_(i.raw,o.showInternal))continue;let d=i.tags.length>0?i.tags:["Other"];for(let u of d){let s=r.get(u)??[];s.push(i),r.set(u,s)}}let c=new Map;for(let i of e)c.set(i.name,i.displayName);let a=[];for(let[i,d]of r){let u=d.map(s=>G(s,o,"tag",i));a.push({id:`tag:${i}`,name:c.get(i)??i,order:i==="Other"?Number.MAX_SAFE_INTEGER:n.get(i),children:g(u),metadata:{source:"tag",kind:"tag"}})}return g(a)}function Ue(e){return Array.isArray(e["x-tagGroups"])&&e["x-tagGroups"].length>0}function re(e,t,o=0,r={active:new Set,remaining:1e4,warned:!1}){if(!Array.isArray(e))return[];if(o>=128||r.active.has(e))return t.push("Nested tag groups were truncated at a cycle or the 128-level limit."),[];r.active.add(e);let n=[];for(let c of e){if(r.remaining<=0){r.warned||t.push("Tag group limit (10,000) reached; remaining groups were omitted."),r.warned=!0;break}let a=l(c);if(!a||typeof a.name!="string")continue;r.remaining--;let i={name:a.name};Array.isArray(a.tags)&&(i.tags=a.tags.filter(d=>typeof d=="string")),Array.isArray(a.groups)&&(i.groups=re(a.groups,t,o+1,r)),n.push(i)}return r.active.delete(e),n}function oe(e,t,o,r,n,c=0){let a=[];if(e.tags)for(let i of e.tags){let d=t.get(i);if(!d||d.length===0)continue;let u=d.map(s=>G(s,n,"tag-group",i));a.push({id:`tag:${i}`,name:o.get(i)??i,order:r.get(i),children:g(u),metadata:{source:"tag-group",kind:"tag"}})}if(e.groups)for(let i of e.groups)a.push(oe(i,t,o,r,n,c+1));return{id:`tag-group:${e.name}`,name:e.name,order:c*1e3,children:g(a),metadata:{source:"tag-group",kind:"tag-group"}}}function je(e,t,o,r,n){let c=new Map,a=new Map,i=new Map;for(let p=0;p<t.length;p+=1)a.set(t[p].name,p),i.set(t[p].name,t[p].displayName);for(let p of o){if(_(p.raw,r.showInternal))continue;let f=p.tags.length>0?p.tags:["Other"];for(let m of f){let T=c.get(m)??[];T.push(p),c.set(m,T)}}let u=re(e["x-tagGroups"],n).map(p=>oe(p,c,i,a,r)),s=c.get("Other");if(s&&s.length>0){let p=s.map(f=>G(f,r,"fallback","Other"));u.push({id:"tag:Other",name:"Other",order:Number.MAX_SAFE_INTEGER,children:g(p),metadata:{source:"fallback",kind:"tag"}})}return g(u)}function Le(e,t){if(!t.showComponents)return;let o=l(e.components),r=l(o?.schemas);if(!r)return;let n=[];for(let[c,a]of Object.entries(r)){let i=l(a);!i||_(i,t.showInternal)||n.push({id:`schema:${c}`,name:c,order:X(i),metadata:{description:h(i.description),pointer:`/components/schemas/${encodeURIComponent(c)}`,source:"tag",kind:"schema"}})}if(n.length!==0)return{id:"section:components",name:"Components",order:Number.MAX_SAFE_INTEGER-1,children:g(n),metadata:{source:"tag",kind:"component"}}}function Ke(e){let t=new Map,o=W(e);for(let r=o.length-1;r>=0;r--){let n=o[r].node,c=n.children?.map(i=>t.get(i)).filter(Boolean),a=(n.metadata?.kind==="operation"?1:0)+(c?.reduce((i,d)=>i+(d.metadata?.operationCount??0),0)??0);t.set(n,{...n,children:c,metadata:{...n.metadata,operationCount:a}})}return e.map(r=>t.get(r))}function ie(e,t={}){let o={...Me,...t},r=[],n=l(e);if(!n)return{root:{id:"root",name:"API Documentation",children:[],metadata:{kind:"root"}},warnings:["Document is null or not an object."]};let c=Je(n),a=Be(n),i;Pe(a)?i=_e(a,c,o,r):Ue(n)?i=je(n,a,c,o,r):i=Fe(a,c,o);let d=Le(n,o),u=Ke([...i,...d?[d]:[]]);return{root:{id:"root",name:"API Documentation",children:g(u),metadata:{kind:"root"}},warnings:r}}0&&(module.exports={buildDocTree,buildOpenApiTree,buildSchemaTree,findSchemaNodeByPath,formatSchemaType});
@@ -1,5 +1,5 @@
1
1
  import { Oas32Document } from '@powerduck/openapi-parser';
2
- import { T as TreeNode } from '../types-DVz8c2Yd.cjs';
2
+ import { T as TreeNode } from '../types-CH939NGV.cjs';
3
3
 
4
4
  /** Metadata attached to OpenAPI tree nodes. */
5
5
  interface OpenApiNodeMetadata {
@@ -79,6 +79,8 @@ type SchemaTreeNode = TreeNode<SchemaNodeMetadata>;
79
79
  interface SchemaTreeOptions {
80
80
  /** Maximum recursion depth. Default 8. Prevents infinite loops on circular schemas. */
81
81
  maxDepth?: number;
82
+ /** Maximum generated nodes, including combinator groups. Default 10,000. */
83
+ maxNodes?: number;
82
84
  /** Include deprecated properties. Default true. */
83
85
  showDeprecated?: boolean;
84
86
  /** Expand allOf/anyOf/oneOf branches. Default true. */
@@ -1,5 +1,5 @@
1
1
  import { Oas32Document } from '@powerduck/openapi-parser';
2
- import { T as TreeNode } from '../types-DVz8c2Yd.js';
2
+ import { T as TreeNode } from '../types-CH939NGV.js';
3
3
 
4
4
  /** Metadata attached to OpenAPI tree nodes. */
5
5
  interface OpenApiNodeMetadata {
@@ -79,6 +79,8 @@ type SchemaTreeNode = TreeNode<SchemaNodeMetadata>;
79
79
  interface SchemaTreeOptions {
80
80
  /** Maximum recursion depth. Default 8. Prevents infinite loops on circular schemas. */
81
81
  maxDepth?: number;
82
+ /** Maximum generated nodes, including combinator groups. Default 10,000. */
83
+ maxNodes?: number;
82
84
  /** Include deprecated properties. Default true. */
83
85
  showDeprecated?: boolean;
84
86
  /** Expand allOf/anyOf/oneOf branches. Default true. */
@@ -1 +1 @@
1
- import{buildDocTree as o,buildOpenApiTree as r,buildSchemaTree as m,findSchemaNodeByPath as p,formatSchemaType as t}from"../chunk-WY6V7DT2.js";import"../chunk-5KF7QUTD.js";export{o as buildDocTree,r as buildOpenApiTree,m as buildSchemaTree,p as findSchemaNodeByPath,t as formatSchemaType};
1
+ import{a,b,c,d,e}from"../chunk-UK2AZ4W7.js";import"../chunk-AHHDXXHL.js";export{e as buildDocTree,a as buildOpenApiTree,b as buildSchemaTree,c as findSchemaNodeByPath,d as formatSchemaType};
@@ -0,0 +1 @@
1
+ function w(r){return r!=null}function*c(r,e=1/0){let n=new Set,t=[];for(let o=r.length-1;o>=0;o--)t.push({node:r[o],depth:1});for(;t.length;){let o=t.pop();if(n.has(o.node)||o.depth>e)continue;n.add(o.node),yield o;let d=o.node.children??[];for(let u=d.length-1;u>=0;u--)t.push({node:d[u],parent:o,depth:o.depth+1})}}function f(r,e){for(let{node:n}of c(r))if(n.id===e)return n}function x(r,e,n=[]){for(let t of c(r)){if(t.node.id!==e)continue;let o=[],d=t;for(;d;)o.push(d.node),d=d.parent;o.reverse();let u=[...n,...o];return{nodes:u,target:t.node,parent:u[u.length-2],ancestorIds:u.slice(0,-1).map(i=>i.id)}}return null}function E(r){let e=[];for(let{node:n}of c(r))n.children?.length||e.push(n);return e}function I(r){let e=0;for(let n of c(r))e++;return e}function v(r){let e=0;for(let n of c(r))e=Math.max(e,n.depth);return e}var g=new Intl.Collator("en-US",{numeric:!0,sensitivity:"base"});function N(r){return[...r].sort((e,n)=>{let t=(e.order??Number.MAX_SAFE_INTEGER)-(n.order??Number.MAX_SAFE_INTEGER);return(Number.isNaN(t)?0:t)||g.compare(e.name,n.name)||e.id.localeCompare(n.id)})}function h(r,e,n=()=>!0){let t=new Set,o=new Map,d=[{source:r,output:[],index:0}];for(;d.length;){let u=d[d.length-1];if(u.index<u.source.length){let s=u.source[u.index++];if(t.has(s))continue;if(o.has(s)){let l=o.get(s);l&&u.output.push(l)}else if(s.children?.length&&n(s))t.add(s),d.push({source:s.children,output:[],index:0,owner:s});else{let l=e(s);o.set(s,l),l&&u.output.push(l)}continue}d.pop();let i=u.source.length===u.output.length&&u.source.every((s,l)=>s===u.output[l])?u.source:u.output;if(!u.owner)return i;let T=u.owner,p=e(i===T.children?T:{...T,children:i});t.delete(T),o.set(T,p),p&&d[d.length-1].output.push(p)}return r}function C(r){return N(h(r,e=>e.children?.length?{...e,children:N(e.children)}:e))}function M(r,e){let n=e.query.trim().toLowerCase();return n?h(r,t=>t.name.toLowerCase().includes(n)||t.id.toLowerCase().includes(n)||(e.keepAncestors??!0)&&t.children?.length?t:null):r}function y(r,e={}){let n=[];for(let{node:t,depth:o}of c(r,e.maxDepth??1/0))o<=(e.maxDepth??1/0)&&(!(e.onlyWithChildren??!0)||t.children?.length)&&n.push(t.id);return n}function A(r){return y(r)}function F(r){return Array.from(c(r),({node:e,depth:n})=>({node:e,depth:n}))}function a(r,e,n){return h(r,t=>t.id===e?n(t):t,t=>t.id!==e)}function b(r,e){return h(r,n=>n.id===e?null:n,n=>n.id!==e)}function R(r,e,n){return a(r,e,t=>({...t,children:[...t.children??[],n]}))}function m(r,e){return Math.max(0,Math.min(Number.isNaN(r)?0:Math.trunc(r),e))}function O(r,e,n){let t=x(r,e);if(!t)return null;let o=t.parent?.children??r,d=o.indexOf(t.target),u=m(n,o.length-1),i={nodes:r,moved:t.target,parentId:t.parent?.id??null,fromIndex:d,toIndex:u};if(u===d)return i;let T=[...o];return T.splice(d,1),T.splice(u,0,t.target),{...i,nodes:t.parent?a(r,t.parent.id,p=>({...p,children:T})):T}}function S(r,e,n,t){let o=f(r,e);if(!o||n!==null&&(!f(r,n)||f([o],n)))return null;let d=b(r,e),u=i=>{let T=[...i];return T.splice(m(t??T.length,T.length),0,o),T};return n===null?u(d):a(d,n,i=>({...i,children:u(i.children??[])}))}export{w as a,f as b,x as c,E as d,I as e,v as f,N as g,C as h,M as i,y as j,A as k,F as l,a as m,b as n,R as o,O as p,S as q};
@@ -0,0 +1 @@
1
+ import{g as f,l as X}from"./chunk-AHHDXXHL.js";function E(e,t,a){let o=new Map;for(let d of e)o.has(d.name)?a.push(`Duplicate tag "${d.name}" was ignored.`):o.set(d.name,d);let n=new Map;for(let d of o.values())d.parent&&!o.has(d.parent)&&a.push(`Tag "${d.name}" references unknown parent "${d.parent}", treating as root.`),n.set(d.name,d.parent&&o.has(d.parent)?d.parent:null);let c=new Set;for(let d of o.keys()){let p=new Set,s=d;for(;s!==null&&!c.has(s);){if(p.has(s)){a.push(`Circular tag reference detected at "${s}". Breaking cycle.`),n.set(s,null);break}p.add(s),s=n.get(s)??null}for(let u of p)c.add(u)}let i=new Map(Array.from(o,([d,p])=>[d,t(p)])),r=[];for(let[d,p]of i){let s=n.get(d);if(s==null)r.push(p);else{let u=i.get(s);(u.children??(u.children=[])).push(p)}}for(let d of i.values())d.children&&(d.children=f(d.children));return f(r)}var W=["get","put","post","delete","options","head","patch","trace"],ne={showInternal:!1,showComponents:!0,showWebhooks:!0,defaultExpandDepth:2};function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function w(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function te(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function B(e){return typeof e=="boolean"?e:void 0}function M(e){return Array.isArray(e)?e:void 0}function C(e,t){return t?!1:B(e["x-scalar-ignore"])===!0||B(e["x-internal"])===!0}function A(e){return te(e["x-order"])}function re(e){return w(e["x-displayName"])}function oe(e){let t=O(e.paths);if(!t)return[];let a=[];for(let[o,n]of Object.entries(t)){let c=O(n);if(c)for(let i of W){let r=c[i];if(r==null)continue;let d=O(r);if(!d)continue;let p=w(d.operationId),s=w(d.summary),u=M(d.tags)?.filter(y=>typeof y=="string").map(y=>y.trim()).filter(y=>y.length>0)??[],g=s??p??`${i.toUpperCase()} ${o}`,m=p??`${i}:${o}`,T=`/paths/${encodeURIComponent(o)}/${i}`;a.push({id:m,path:o,method:i,name:g,summary:s,operationId:p,deprecated:B(d.deprecated)===!0,tags:u,pointer:T,raw:d})}}return a}function ae(e){let t=M(e.tags);if(!t)return[];let a=[];for(let o of t){let n=O(o),c=w(n?.name);!c||!n||a.push({name:c,displayName:re(n)??c,description:w(n.description),parent:w(n.parent),order:A(n),raw:n})}return a}function se(e){return e.some(t=>t.parent!==void 0)}function ie(e,t,a,o){let n=new Map;for(let s of t){if(C(s.raw,a.showInternal))continue;let u=s.tags.length>0?s.tags:["Other"];for(let g of u){let m=n.get(g)??[];m.push(s),n.set(g,m)}}let c=s=>{let g=(n.get(s.name)??[]).map(m=>({id:`op:${s.name}:${m.id}`,name:m.name,order:A(m.raw),metadata:{method:m.method,path:m.path,operationId:m.operationId,deprecated:m.deprecated,summary:m.summary,pointer:m.pointer,source:"oas32-parent",kind:"operation"}}));return{id:`tag:${s.name}`,name:s.displayName,order:s.order,children:f(g),metadata:{source:"oas32-parent",kind:"tag"}}},i=new Set(e.map(s=>s.name)),r=[...e];for(let s of n.keys())s!=="Other"&&!i.has(s)&&r.push({name:s,displayName:s,raw:{}});let d=E(r,c,o),p=n.get("Other")??[];if(p.length>0&&!e.some(s=>s.name==="Other")){let s=p.map(u=>({id:`op:Other:${u.id}`,name:u.name,order:A(u.raw),metadata:{method:u.method,path:u.path,operationId:u.operationId,deprecated:u.deprecated,summary:u.summary,pointer:u.pointer,source:"fallback",kind:"operation"}}));d.push({id:"tag:Other",name:"Other",order:Number.MAX_SAFE_INTEGER,children:f(s),metadata:{source:"fallback",kind:"tag"}})}return f(d)}function de(e){let t=M(e["x-tagGroups"]);if(!t)return[];let a=(o,n)=>{let c=O(o),i=w(c?.name),r=M(c?.tags)?.filter(p=>typeof p=="string").map(p=>p.trim()).filter(p=>p.length>0)??[];if(!i)return null;let d=M(c?.groups)?.map((p,s)=>a(p,s)).filter(p=>p!==null)??[];return{name:i,tags:r,groups:d.length>0?d:void 0,order:A(c??{})??n}};return t.map((o,n)=>a(o,n)).filter(o=>o!==null)}function ce(e,t,a,o){let n=new Map;for(let p of t)n.set(p.name,p.displayName);let c=new Map;for(let p of a)if(!C(p.raw,o.showInternal))for(let s of p.tags){let u=c.get(s)??[];u.push(p),c.set(s,u)}let i=p=>(c.get(p)??[]).map(u=>({id:`op:${p}:${u.id}`,name:u.name,order:A(u.raw),metadata:{method:u.method,path:u.path,operationId:u.operationId,deprecated:u.deprecated,summary:u.summary,pointer:u.pointer,source:"tag-group",kind:"operation"}})),r=p=>({id:`tag:${p}`,name:n.get(p)??p,children:f(i(p)),metadata:{source:"tag-group",kind:"tag"}}),d=p=>{let s=[];for(let u of p.tags)c.get(u)?.length&&s.push(r(u));for(let u of p.groups??[])s.push(d(u));return{id:`tag-group:${p.name}`,name:p.name,order:p.order,children:f(s),metadata:{source:"tag-group",kind:"tag-group"}}};return f(e.map(d))}function pe(e,t,a){let o=new Map,n=new Map;for(let r=0;r<e.length;r+=1){let d=e[r];n.set(d.name,d.order??r)}for(let r of t){if(C(r.raw,a.showInternal))continue;let d=r.tags.length>0?r.tags:["Other"];for(let p of d){let s=o.get(p)??[];s.push(r),o.set(p,s)}}let c=new Map;for(let r of e)c.set(r.name,r.displayName);let i=[];for(let[r,d]of o){let p=d.map(s=>({id:`op:${r}:${s.id}`,name:s.name,order:A(s.raw),metadata:{method:s.method,path:s.path,operationId:s.operationId,deprecated:s.deprecated,summary:s.summary,pointer:s.pointer,source:"tag",kind:"operation"}}));i.push({id:`tag:${r}`,name:c.get(r)??r,order:r==="Other"?Number.MAX_SAFE_INTEGER:n.get(r),children:f(p),metadata:{source:"tag",kind:"tag"}})}return f(i)}function ue(e,t){if(!t.showComponents)return;let a=O(e.components),o=O(a?.schemas);if(!o)return;let n=[];for(let[c,i]of Object.entries(o)){let r=O(i);!r||C(r,t.showInternal)||n.push({id:`schema:${c}`,name:c,order:A(r),metadata:{pointer:`/components/schemas/${encodeURIComponent(c)}`,source:"tag",kind:"schema"}})}if(n.length!==0)return{id:"section:components",name:"Components",order:Number.MAX_SAFE_INTEGER-1,children:f(n),metadata:{source:"section",kind:"section",section:"components"}}}function me(e,t){if(!t.showWebhooks)return;let a=O(e.webhooks);if(!a)return;let o=[];for(let[n,c]of Object.entries(a)){let i=O(c);if(i)for(let r of W){let d=i[r],p=O(d);if(!p||C(p,t.showInternal))continue;let s=w(p.operationId),u=w(p.summary),g=u??s??`${r.toUpperCase()} ${n}`;o.push({id:`webhook:${n}:${r}`,name:g,order:A(p),metadata:{method:r,path:n,operationId:s,deprecated:B(p.deprecated)===!0,summary:u,pointer:`/webhooks/${encodeURIComponent(n)}/${r}`,source:"tag",kind:"webhook"}})}}if(o.length!==0)return{id:"section:webhooks",name:"Webhooks",order:Number.MAX_SAFE_INTEGER-2,children:f(o),metadata:{source:"section",kind:"section",section:"webhooks"}}}function ge(e,t={}){let a={...ne,...t},o=[],n=O(e);if(!n)return{root:{id:"root",name:"OpenAPI",children:[],metadata:{kind:"root"}},warnings:["Document is null or not an object."]};let c=oe(n),i=ae(n),r;if(se(i))r=ie(i,c,a,o);else{let g=de(n);g.length>0?r=ce(g,i,c,a):r=pe(i,c,a)}let d=me(n,a),p=ue(n,a),u=[{id:"section:apis",name:"APIs",children:r,metadata:{kind:"section",source:"section",section:"apis"},order:0},...d?[d]:[],...p?[p]:[]];return{root:{id:"root",name:"OpenAPI",children:f(u),metadata:{kind:"root"}},warnings:o}}var z={openapi:0,info:1,servers:2,paths:3,webhooks:4,components:5,security:6,tags:7,externalDocs:8,jsonSchemaDialect:9},U={maxDepth:8,maxNodes:1e4,showDeprecated:!0,expandCombinators:!0,showArrayItems:!0},V=new Set(["string","number","integer","boolean","null"]);function x(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function F(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function Y(e){return typeof e=="boolean"?e:void 0}function j(e){return Array.isArray(e)?e:void 0}function fe(e){let t=e.type;if(typeof t=="string"||Array.isArray(t)&&t.every(a=>typeof a=="string"))return t}function le(e){return e?Array.isArray(e)?e.every(t=>V.has(t)):V.has(e):!1}function he(e){if(!e)return"unknown";switch(Array.isArray(e)?e[0]:e){case"object":return"object";case"array":return"array";case"string":return"string";case"number":return"number";case"integer":return"integer";case"boolean":return"boolean";case"null":return"null";default:return"unknown"}}function Q(e){return e?Array.isArray(e)?e.join(" | "):e:"any"}function S(e){return e.map(t=>t.replace(/[\\.\[\]]/g,a=>`\\${a}`)).join(".")||"root"}function P(e,t,a,o,n,c){n.remaining--;let i=fe(t),r=F(t.format),d=F(t.description),p=Y(t.deprecated)===!0,s=he(i),u={jsonPath:a,type:i,format:r,required:c,deprecated:p,description:d,kind:s},g=F(t.$ref);if(g){if(n.refStack.has(g))return n.warnings.push(`Circular $ref detected at ${a.join(".")}: ${g}. Breaking recursion.`),{id:S(a),name:e,metadata:{...u,kind:"ref",isLeaf:!0}};n.refStack.add(g)}let m,T=le(i),y=n.activeSchemas.has(t);if(y&&n.warnings.push(`Circular schema object detected at ${S(a)}.`),y||o>=n.options.maxDepth||n.remaining<=0)return g&&n.refStack.delete(g),{id:S(a),name:e,metadata:{...u,isLeaf:!0}};n.activeSchemas.add(t);let k=x(t.properties);if(k){let R=j(t.required)??[],N=new Set(R.filter(b=>typeof b=="string")),J=[];for(let[b,$]of Object.entries(k)){if(n.remaining<=0)break;let I=x($);I&&(!n.options.showDeprecated&&Y(I.deprecated)===!0||J.push(P(b,I,[...a,"properties",b],o+1,n,N.has(b))))}m=[...m??[],...f(J)],T=!1}if(n.remaining>0&&n.options.showArrayItems&&i==="array"){let R=x(t.items);if(R){let N=P("items",R,[...a,"items"],o+1,n,!1);m=[...m??[],N],T=!1}else u.hasItems=!1}if(n.options.expandCombinators){let R=[{key:"allOf",kind:"allOf"},{key:"anyOf",kind:"anyOf"},{key:"oneOf",kind:"oneOf"}];for(let{key:N,kind:J}of R){if(n.remaining<=0)break;let b=j(t[N]);if(!b?.length)continue;n.remaining--;let $=[];for(let D=0;D<b.length&&n.remaining>0;D++){let ee=b[D],H=x(ee);if(!H){n.remaining--,$.push({id:S([...a,N,String(D)]),name:`[${D}]`,metadata:{jsonPath:[...a,N,String(D)],kind:"unknown",isLeaf:!0}});continue}$.push(P(`[${D}]`,H,[...a,N,String(D)],o+1,n,!1))}let I={id:S([...a,N]),name:N,children:f($),metadata:{jsonPath:[...a,N],kind:J}};m=[...m??[],I],T=!1}}return j(t.enum)?.length&&!m?.length&&(u.kind="enum",T=!0),g&&n.refStack.delete(g),n.activeSchemas.delete(t),{id:S(a),name:e,order:Object.prototype.hasOwnProperty.call(z,e)?z[e]:void 0,metadata:{...u,isLeaf:T},children:m}}function Te(e,t={}){let a={...U,...t};a.maxDepth=Number.isFinite(a.maxDepth)?Math.min(128,Math.max(0,Math.trunc(a.maxDepth))):U.maxDepth,a.maxNodes=Number.isFinite(a.maxNodes)?Math.min(1e5,Math.max(1,Math.trunc(a.maxNodes))):U.maxNodes;let o=[],n=x(e);if(!n)return{root:{id:"root",name:"Schema",metadata:{jsonPath:[],kind:"root",isLeaf:!0}},warnings:["Schema is null or not an object."]};let c={options:a,warnings:o,refStack:new Set,activeSchemas:new Set,remaining:a.maxNodes},i=P("root",n,[],0,c,!0);return c.remaining<=0&&o.push(`Schema node limit (${a.maxNodes}) reached; remaining branches were omitted.`),{root:i,warnings:o}}function Oe(e,t){if(t.length===0)return e;let a=JSON.stringify(t),o=[e],n=new Set;for(let c=0;c<o.length;c++){let i=o[c];if(!i||n.has(i))continue;if(n.add(i),JSON.stringify(i.metadata?.jsonPath)===a)return i;for(let d of i.children??[])o.push(d)}}function Ne(e){return e.kind==="enum"?"enum":e.kind==="ref"?"$ref":e.format?`${Q(e.type)} (${e.format})`:Q(e.type)}var ye=["get","put","post","delete","options","head","patch","trace"],be={showInternal:!1,showComponents:!1,showWebhooks:!0,expandOperationDetails:!1};function l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function h(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function G(e){return typeof e=="boolean"?e:void 0}function L(e){return Array.isArray(e)?e:void 0}function _(e,t){return t?!1:G(e["x-scalar-ignore"])===!0||G(e["x-internal"])===!0}function K(e){let t=e["x-order"];return typeof t=="number"&&Number.isFinite(t)?t:void 0}function we(e){return h(e["x-displayName"])}function ke(e,t){let a=[];for(let o of e){let n=l(o);if(!n)continue;let c=h(n.name),i=h(n.in);if(!c||!i)continue;let r=`${i}:${c}`;a.push({id:`${t}/parameters/${encodeURIComponent(r)}`,name:c,metadata:{paramIn:i,required:G(n.required)===!0,description:h(n.description),pointer:`${t}/parameters`,kind:"parameter"}})}return f(a)}function De(e,t){let a=[];for(let[o,n]of Object.entries(e)){let c=l(n);if(!c)continue;let i=h(c.description),r=l(c.content),d=[];if(r)for(let[p]of Object.entries(r))d.push({id:`${t}/responses/${encodeURIComponent(o)}/content/${encodeURIComponent(p)}`,name:p,metadata:{contentType:p,pointer:`${t}/responses/${encodeURIComponent(o)}/content/${encodeURIComponent(p)}`,kind:"content"}});a.push({id:`${t}/responses/${encodeURIComponent(o)}`,name:o,metadata:{statusCode:o,description:i,pointer:`${t}/responses/${encodeURIComponent(o)}`,kind:"response"},children:d.length>0?d:void 0})}return f(a)}function Ae(e,t){let a=[],o=L(e.parameters);if(o?.length){let i=ke(o,t);i.length>0&&a.push({id:`${t}/parameters`,name:"Parameters",children:i,metadata:{pointer:`${t}/parameters`,kind:"parameters"}})}let n=l(e.requestBody);if(n){let i=l(n.content),r=[];if(i)for(let[d]of Object.entries(i))r.push({id:`${t}/requestBody/content/${encodeURIComponent(d)}`,name:d,metadata:{contentType:d,pointer:`${t}/requestBody/content/${encodeURIComponent(d)}`,kind:"content"}});a.push({id:`${t}/requestBody`,name:"Request Body",metadata:{description:h(n.description),required:G(n.required)===!0,pointer:`${t}/requestBody`,kind:"request-body"},children:r.length>0?r:void 0})}let c=l(e.responses);if(c){let i=De(c,t);i.length>0&&a.push({id:`${t}/responses`,name:"Responses",children:i,metadata:{pointer:`${t}/responses`,kind:"responses"}})}return a}function Re(e){let t=l(e.paths);if(!t)return[];let a=[];for(let[o,n]of Object.entries(t)){let c=l(n);if(c)for(let i of ye){let r=c[i],d=l(r);if(!d)continue;let p=h(d.operationId),s=h(d.summary),u=h(d.description),g=L(d.tags)?.filter(k=>typeof k=="string").map(k=>k.trim()).filter(k=>k.length>0)??[],m=s??p??`${i.toUpperCase()} ${o}`,T=p??`${i}:${o}`,y=`/paths/${encodeURIComponent(o)}/${i}`;a.push({id:T,path:o,method:i,name:m,summary:s,description:u,operationId:p,deprecated:G(d.deprecated)===!0,tags:g,pointer:y,raw:d})}}return a}function Se(e){let t=L(e.tags);if(!t)return[];let a=[];for(let o of t){let n=l(o),c=h(n?.name);!c||!n||a.push({name:c,displayName:we(n)??c,description:h(n.description),parent:h(n.parent),order:K(n)})}return a}function $e(e){return e.some(t=>t.parent!==void 0)}function q(e,t,a,o){let n=t.expandOperationDetails?Ae(e.raw,e.pointer):void 0;return{id:`op:${o}:${e.id}`,name:e.name,order:K(e.raw),metadata:{method:e.method,path:e.path,operationId:e.operationId,deprecated:e.deprecated,summary:e.summary,description:e.description,pointer:e.pointer,source:a,kind:"operation"},children:n&&n.length>0?n:void 0}}function Ie(e,t,a,o){let n=new Map;for(let s of t){if(_(s.raw,a.showInternal))continue;let u=s.tags.length>0?s.tags:["Other"];for(let g of u){let m=n.get(g)??[];m.push(s),n.set(g,m)}}let c=s=>{let g=(n.get(s.name)??[]).map(m=>q(m,a,"oas32-parent",s.name));return{id:`tag:${s.name}`,name:s.displayName,order:s.order,children:f(g),metadata:{description:s.description,source:"oas32-parent",kind:"tag"}}},i=new Set(e.map(s=>s.name)),r=[...e];for(let s of n.keys())s!=="Other"&&!i.has(s)&&r.push({name:s,displayName:s});let d=E(r,c,o),p=n.get("Other")??[];if(p.length>0&&!e.some(s=>s.name==="Other")){let s=p.map(u=>q(u,a,"fallback","Other"));d.push({id:"tag:Other",name:"Other",order:Number.MAX_SAFE_INTEGER,children:f(s),metadata:{source:"fallback",kind:"tag"}})}return f(d)}function Me(e,t,a){let o=new Map,n=new Map;for(let r=0;r<e.length;r+=1)n.set(e[r].name,r);for(let r of t){if(_(r.raw,a.showInternal))continue;let d=r.tags.length>0?r.tags:["Other"];for(let p of d){let s=o.get(p)??[];s.push(r),o.set(p,s)}}let c=new Map;for(let r of e)c.set(r.name,r.displayName);let i=[];for(let[r,d]of o){let p=d.map(s=>q(s,a,"tag",r));i.push({id:`tag:${r}`,name:c.get(r)??r,order:r==="Other"?Number.MAX_SAFE_INTEGER:n.get(r),children:f(p),metadata:{source:"tag",kind:"tag"}})}return f(i)}function Ce(e){return Array.isArray(e["x-tagGroups"])&&e["x-tagGroups"].length>0}function Z(e,t,a=0,o={active:new Set,remaining:1e4,warned:!1}){if(!Array.isArray(e))return[];if(a>=128||o.active.has(e))return t.push("Nested tag groups were truncated at a cycle or the 128-level limit."),[];o.active.add(e);let n=[];for(let c of e){if(o.remaining<=0){o.warned||t.push("Tag group limit (10,000) reached; remaining groups were omitted."),o.warned=!0;break}let i=l(c);if(!i||typeof i.name!="string")continue;o.remaining--;let r={name:i.name};Array.isArray(i.tags)&&(r.tags=i.tags.filter(d=>typeof d=="string")),Array.isArray(i.groups)&&(r.groups=Z(i.groups,t,a+1,o)),n.push(r)}return o.active.delete(e),n}function v(e,t,a,o,n,c=0){let i=[];if(e.tags)for(let r of e.tags){let d=t.get(r);if(!d||d.length===0)continue;let p=d.map(s=>q(s,n,"tag-group",r));i.push({id:`tag:${r}`,name:a.get(r)??r,order:o.get(r),children:f(p),metadata:{source:"tag-group",kind:"tag"}})}if(e.groups)for(let r of e.groups)i.push(v(r,t,a,o,n,c+1));return{id:`tag-group:${e.name}`,name:e.name,order:c*1e3,children:f(i),metadata:{source:"tag-group",kind:"tag-group"}}}function xe(e,t,a,o,n){let c=new Map,i=new Map,r=new Map;for(let u=0;u<t.length;u+=1)i.set(t[u].name,u),r.set(t[u].name,t[u].displayName);for(let u of a){if(_(u.raw,o.showInternal))continue;let g=u.tags.length>0?u.tags:["Other"];for(let m of g){let T=c.get(m)??[];T.push(u),c.set(m,T)}}let p=Z(e["x-tagGroups"],n).map(u=>v(u,c,r,i,o)),s=c.get("Other");if(s&&s.length>0){let u=s.map(g=>q(g,o,"fallback","Other"));p.push({id:"tag:Other",name:"Other",order:Number.MAX_SAFE_INTEGER,children:f(u),metadata:{source:"fallback",kind:"tag"}})}return f(p)}function Ge(e,t){if(!t.showComponents)return;let a=l(e.components),o=l(a?.schemas);if(!o)return;let n=[];for(let[c,i]of Object.entries(o)){let r=l(i);!r||_(r,t.showInternal)||n.push({id:`schema:${c}`,name:c,order:K(r),metadata:{description:h(r.description),pointer:`/components/schemas/${encodeURIComponent(c)}`,source:"tag",kind:"schema"}})}if(n.length!==0)return{id:"section:components",name:"Components",order:Number.MAX_SAFE_INTEGER-1,children:f(n),metadata:{source:"tag",kind:"component"}}}function qe(e){let t=new Map,a=X(e);for(let o=a.length-1;o>=0;o--){let n=a[o].node,c=n.children?.map(r=>t.get(r)).filter(Boolean),i=(n.metadata?.kind==="operation"?1:0)+(c?.reduce((r,d)=>r+(d.metadata?.operationCount??0),0)??0);t.set(n,{...n,children:c,metadata:{...n.metadata,operationCount:i}})}return e.map(o=>t.get(o))}function Je(e,t={}){let a={...be,...t},o=[],n=l(e);if(!n)return{root:{id:"root",name:"API Documentation",children:[],metadata:{kind:"root"}},warnings:["Document is null or not an object."]};let c=Re(n),i=Se(n),r;$e(i)?r=Ie(i,c,a,o):Ce(n)?r=xe(n,i,c,a,o):r=Me(i,c,a);let d=Ge(n,a),p=qe([...r,...d?[d]:[]]);return{root:{id:"root",name:"API Documentation",children:f(p),metadata:{kind:"root"}},warnings:o}}export{ge as a,Te as b,Oe as c,Ne as d,Je as e};
@@ -1 +1 @@
1
- "use strict";var n,e=Object.defineProperty,r=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i={};function c(n){return null!=n}function l(n,e){for(const r of n){if(r.id===e)return r;if(r.children?.length){const n=l(r.children,e);if(n)return n}}}function d(n,e,r=[]){for(const t of n){const n=[...r,t];if(t.id===e)return{nodes:n,target:t,parent:r[r.length-1],ancestorIds:r.map(n=>n.id)};if(t.children?.length){const r=d(t.children,e,n);if(r)return r}}return null}function f(n){const e=[],r=n=>{if(n.children?.length)for(const e of n.children)r(e);else e.push(n)};for(const e of n)r(e);return e}function s(n){let e=0;const r=n=>{e+=1;for(const e of n.children??[])r(e)};for(const e of n)r(e);return e}function u(n){let e=0;const r=(n,t)=>{e=Math.max(e,t);for(const e of n.children??[])r(e,t+1)};for(const e of n)r(e,1);return e}function h(n){return[...n].sort((n,e)=>{const r=n.order??Number.MAX_SAFE_INTEGER,t=e.order??Number.MAX_SAFE_INTEGER;if(r!==t)return r-t;return n.name.localeCompare(e.name,"en-US",{numeric:!0,sensitivity:"base"})||n.id.localeCompare(e.id)})}function a(n){return h(n).map(n=>n.children?.length?{...n,children:a(n.children)}:n)}function p(n,e){const r=e.query.trim().toLowerCase();if(!r)return n;const t=e.keepAncestors??!0,o=n=>{const e=(n.children??[]).map(o).filter(c),i=(n=>n.name.toLowerCase().includes(r)||n.id.toLowerCase().includes(r))(n);return(i||e.length)&&(t||i)?e.length===(n.children?.length??0)?n:{...n,children:e}:null};return n.map(o).filter(c)}function m(n,e={}){const r=e.maxDepth??1/0,t=e.onlyWithChildren??!0,o=[],i=(n,e)=>{if(e>r)return;const c=(n.children?.length??0)>0;t&&!c||o.push(n.id);for(const r of n.children??[])i(r,e+1)};for(const e of n)i(e,1);return o}function g(n){const e=[],r=n=>{const t=n.children;if(t&&0!==t.length){e.push(n.id);for(const n of t)r(n)}};for(const e of n)r(e);return e}function x(n){const e=[],r=(n,t)=>{e.push({node:n,depth:t});for(const e of n.children??[])r(e,t+1)};for(const e of n)r(e,1);return e}function I(n,e,r){let t=!1;const o=n.map(n=>{if(n.id===e)return t=!0,r(n);if(n.children?.length){const o=I(n.children,e,r);if(o!==n.children)return t=!0,{...n,children:o}}return n});return t?o:n}function N(n,e){const r=[];let t=!1;for(const o of n)if(o.id!==e){if(o.children?.length){const n=N(o.children,e);if(n!==o.children){t=!0,r.push({...o,children:n});continue}}r.push(o)}else t=!0;return t?r:n}function b(n,e,r){let t=!1;const o=n.map(n=>{if(n.id===e)return t=!0,{...n,children:[...n.children??[],r]};if(n.children?.length){const o=b(n.children,e,r);if(o!==n.children)return t=!0,{...n,children:o}}return n});return t?o:n}function y(n,e,r){const t=(n,r)=>{const o=n.findIndex(n=>n.id===e);if(-1!==o)return{array:n,index:o,parentId:r};for(const e of n)if(e.children?.length){const n=t(e.children,e.id);if(n)return n}return null},o=t(n,null);if(!o)return null;const{array:i,index:c,parentId:l}=o,d=Math.max(0,Math.min(r,i.length-1));if(d===c)return{nodes:n,moved:i[c],parentId:l,fromIndex:c,toIndex:c};const f=[...i],[s]=f.splice(c,1);f.splice(d,0,s);const u=n=>null===l?f:n.map(n=>n.id===l?{...n,children:f}:n.children?.length?{...n,children:u(n.children)}:n);return{nodes:u(n),moved:s,parentId:l,fromIndex:c,toIndex:d}}function M(n,e,r,t){let o=null;if(null!==r){const t=d(n,e);if(t&&t.ancestorIds.includes(r))return null}const i=n=>{const r=[];let t=!1;for(const c of n)if(c.id!==e){if(c.children?.length){const n=i(c.children);if(n!==c.children){t=!0,r.push({...c,children:n});continue}}r.push(c)}else o=c,t=!0;return t?r:n},c=i(n);if(!o)return null;if(null===r){const n=t??c.length,e=[...c];return e.splice(Math.max(0,Math.min(n,e.length)),0,o),e}let l=!1;const f=n=>n.map(n=>{if(n.id===r){l=!0;const e=[...n.children??[]],r=t??e.length;return e.splice(Math.max(0,Math.min(r,e.length)),0,o),{...n,children:e}}return n.children?.length?{...n,children:f(n.children)}:n}),s=f(c);return l?s:null}((n,r)=>{for(var t in r)e(n,t,{get:r[t],enumerable:!0})})(i,{countNodes:()=>s,filterTree:()=>p,findNode:()=>l,findPath:()=>d,flattenTree:()=>x,getBranchIds:()=>g,getExpandableIds:()=>m,getLeaves:()=>f,getMaxDepth:()=>u,insertChild:()=>b,isTreeNode:()=>c,moveNode:()=>M,removeNode:()=>N,reorderNode:()=>y,sortNodes:()=>h,sortTree:()=>a,updateNode:()=>I}),module.exports=(n=i,((n,i,c,l)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let d of t(i))o.call(n,d)||d===c||e(n,d,{get:()=>i[d],enumerable:!(l=r(i,d))||l.enumerable});return n})(e({},"__esModule",{value:!0}),n));
1
+ "use strict";var m=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var k=(r,e)=>{for(var n in e)m(r,n,{get:e[n],enumerable:!0})},G=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _(e))!D.call(r,o)&&o!==n&&m(r,o,{get:()=>e[o],enumerable:!(t=S(e,o))||t.enumerable});return r};var q=r=>G(m({},"__esModule",{value:!0}),r);var P={};k(P,{countNodes:()=>w,filterTree:()=>C,findNode:()=>h,findPath:()=>x,flattenTree:()=>R,getBranchIds:()=>M,getExpandableIds:()=>g,getLeaves:()=>E,getMaxDepth:()=>I,insertChild:()=>A,isTreeNode:()=>b,moveNode:()=>L,removeNode:()=>y,reorderNode:()=>O,sortNodes:()=>f,sortTree:()=>v,updateNode:()=>a});module.exports=q(P);function b(r){return r!=null}function*c(r,e=1/0){let n=new Set,t=[];for(let o=r.length-1;o>=0;o--)t.push({node:r[o],depth:1});for(;t.length;){let o=t.pop();if(n.has(o.node)||o.depth>e)continue;n.add(o.node),yield o;let u=o.node.children??[];for(let d=u.length-1;d>=0;d--)t.push({node:u[d],parent:o,depth:o.depth+1})}}function h(r,e){for(let{node:n}of c(r))if(n.id===e)return n}function x(r,e,n=[]){for(let t of c(r)){if(t.node.id!==e)continue;let o=[],u=t;for(;u;)o.push(u.node),u=u.parent;o.reverse();let d=[...n,...o];return{nodes:d,target:t.node,parent:d[d.length-2],ancestorIds:d.slice(0,-1).map(T=>T.id)}}return null}function E(r){let e=[];for(let{node:n}of c(r))n.children?.length||e.push(n);return e}function w(r){let e=0;for(let n of c(r))e++;return e}function I(r){let e=0;for(let n of c(r))e=Math.max(e,n.depth);return e}var B=new Intl.Collator("en-US",{numeric:!0,sensitivity:"base"});function f(r){return[...r].sort((e,n)=>{let t=(e.order??Number.MAX_SAFE_INTEGER)-(n.order??Number.MAX_SAFE_INTEGER);return(Number.isNaN(t)?0:t)||B.compare(e.name,n.name)||e.id.localeCompare(n.id)})}function N(r,e,n=()=>!0){let t=new Set,o=new Map,u=[{source:r,output:[],index:0}];for(;u.length;){let d=u[u.length-1];if(d.index<d.source.length){let s=d.source[d.index++];if(t.has(s))continue;if(o.has(s)){let l=o.get(s);l&&d.output.push(l)}else if(s.children?.length&&n(s))t.add(s),u.push({source:s.children,output:[],index:0,owner:s});else{let l=e(s);o.set(s,l),l&&d.output.push(l)}continue}u.pop();let T=d.source.length===d.output.length&&d.source.every((s,l)=>s===d.output[l])?d.source:d.output;if(!d.owner)return T;let i=d.owner,p=e(T===i.children?i:{...i,children:T});t.delete(i),o.set(i,p),p&&u[u.length-1].output.push(p)}return r}function v(r){return f(N(r,e=>e.children?.length?{...e,children:f(e.children)}:e))}function C(r,e){let n=e.query.trim().toLowerCase();return n?N(r,t=>t.name.toLowerCase().includes(n)||t.id.toLowerCase().includes(n)||(e.keepAncestors??!0)&&t.children?.length?t:null):r}function g(r,e={}){let n=[];for(let{node:t,depth:o}of c(r,e.maxDepth??1/0))o<=(e.maxDepth??1/0)&&(!(e.onlyWithChildren??!0)||t.children?.length)&&n.push(t.id);return n}function M(r){return g(r)}function R(r){return Array.from(c(r),({node:e,depth:n})=>({node:e,depth:n}))}function a(r,e,n){return N(r,t=>t.id===e?n(t):t,t=>t.id!==e)}function y(r,e){return N(r,n=>n.id===e?null:n,n=>n.id!==e)}function A(r,e,n){return a(r,e,t=>({...t,children:[...t.children??[],n]}))}function F(r,e){return Math.max(0,Math.min(Number.isNaN(r)?0:Math.trunc(r),e))}function O(r,e,n){let t=x(r,e);if(!t)return null;let o=t.parent?.children??r,u=o.indexOf(t.target),d=F(n,o.length-1),T={nodes:r,moved:t.target,parentId:t.parent?.id??null,fromIndex:u,toIndex:d};if(d===u)return T;let i=[...o];return i.splice(u,1),i.splice(d,0,t.target),{...T,nodes:t.parent?a(r,t.parent.id,p=>({...p,children:i})):i}}function L(r,e,n,t){let o=h(r,e);if(!o||n!==null&&(!h(r,n)||h([o],n)))return null;let u=y(r,e),d=T=>{let i=[...T];return i.splice(F(t??i.length,i.length),0,o),i};return n===null?d(u):a(u,n,T=>({...T,children:d(T.children??[])}))}0&&(module.exports={countNodes,filterTree,findNode,findPath,flattenTree,getBranchIds,getExpandableIds,getLeaves,getMaxDepth,insertChild,isTreeNode,moveNode,removeNode,reorderNode,sortNodes,sortTree,updateNode});
@@ -1,107 +1,32 @@
1
- import { T as TreeNode, F as FilterTreeOptions, a as TreePath, E as ExpandOptions } from '../types-DVz8c2Yd.cjs';
1
+ import { T as TreeNode, F as FilterTreeOptions, a as TreePath, E as ExpandOptions } from '../types-CH939NGV.cjs';
2
2
 
3
- declare function isTreeNode<TMetadata>(value: TreeNode<TMetadata> | null | undefined): value is TreeNode<TMetadata>;
4
- /**
5
- * Finds a node by id in a tree. Returns undefined if not found.
6
- */
7
- declare function findNode<TMetadata>(nodes: TreeNode<TMetadata>[], id: string): TreeNode<TMetadata> | undefined;
8
- /**
9
- * Finds the full path from root to the node with the given id.
10
- * Returns null if the node is not found.
11
- */
12
- declare function findPath<TMetadata>(nodes: TreeNode<TMetadata>[], id: string, ancestors?: TreeNode<TMetadata>[]): TreePath<TMetadata> | null;
13
- /**
14
- * Returns all leaf nodes (nodes with no children).
15
- */
16
- declare function getLeaves<TMetadata>(nodes: TreeNode<TMetadata>[]): TreeNode<TMetadata>[];
17
- /**
18
- * Returns the total number of nodes in the tree.
19
- */
20
- declare function countNodes<TMetadata>(nodes: TreeNode<TMetadata>[]): number;
21
- /**
22
- * Returns the maximum depth of the tree. Root-level nodes are depth 1.
23
- */
24
- declare function getMaxDepth<TMetadata>(nodes: TreeNode<TMetadata>[]): number;
25
- /**
26
- * Sorts nodes by order (ascending), then by name (locale-aware, numeric).
27
- * Nodes without an order value sort after those with one.
28
- *
29
- * Returns a new array; does not mutate the input.
30
- */
31
- declare function sortNodes<TMetadata>(nodes: TreeNode<TMetadata>[]): TreeNode<TMetadata>[];
32
- /**
33
- * Recursively sorts all nodes in the tree by order, then name.
34
- * Returns a new tree; does not mutate the input.
35
- */
36
- declare function sortTree<TMetadata>(nodes: TreeNode<TMetadata>[]): TreeNode<TMetadata>[];
37
- /**
38
- * Filters a tree by query. Matching nodes and (optionally) their ancestors
39
- * are retained. Returns a new tree; does not mutate the input.
40
- *
41
- * When no query is provided, the original nodes are returned unchanged.
42
- */
43
- declare function filterTree<TMetadata>(nodes: TreeNode<TMetadata>[], options: FilterTreeOptions): TreeNode<TMetadata>[];
44
- /**
45
- * Returns the IDs of all nodes that should be expanded based on options.
46
- *
47
- * @param nodes - The root nodes.
48
- * @param options - maxDepth (default Infinity), onlyWithChildren (default true).
49
- */
50
- declare function getExpandableIds<TMetadata>(nodes: TreeNode<TMetadata>[], options?: ExpandOptions): string[];
51
- /**
52
- * Returns the IDs of all branch nodes (nodes with at least one child).
53
- */
54
- declare function getBranchIds<TMetadata>(nodes: TreeNode<TMetadata>[]): string[];
55
- /**
56
- * Flattens a tree into a list of nodes with their depth.
57
- * Parent nodes appear before their children (pre-order traversal).
58
- */
59
- declare function flattenTree<TMetadata>(nodes: TreeNode<TMetadata>[]): Array<{
60
- node: TreeNode<TMetadata>;
3
+ declare function isTreeNode<T>(value: TreeNode<T> | null | undefined): value is TreeNode<T>;
4
+ declare function findNode<T>(nodes: TreeNode<T>[], id: string): TreeNode<T> | undefined;
5
+ declare function findPath<T>(nodes: TreeNode<T>[], id: string, ancestors?: TreeNode<T>[]): TreePath<T> | null;
6
+ declare function getLeaves<T>(nodes: TreeNode<T>[]): TreeNode<T>[];
7
+ declare function countNodes<T>(nodes: TreeNode<T>[]): number;
8
+ declare function getMaxDepth<T>(nodes: TreeNode<T>[]): number;
9
+ declare function sortNodes<T>(nodes: TreeNode<T>[]): TreeNode<T>[];
10
+ declare function sortTree<T>(nodes: TreeNode<T>[]): TreeNode<T>[];
11
+ declare function filterTree<T>(nodes: TreeNode<T>[], options: FilterTreeOptions): TreeNode<T>[];
12
+ declare function getExpandableIds<T>(nodes: TreeNode<T>[], options?: ExpandOptions): string[];
13
+ declare function getBranchIds<T>(nodes: TreeNode<T>[]): string[];
14
+ declare function flattenTree<T>(nodes: TreeNode<T>[]): Array<{
15
+ node: TreeNode<T>;
61
16
  depth: number;
62
17
  }>;
63
- /**
64
- * Returns a new tree with the node at the given id replaced.
65
- * If the id is not found, the original tree is returned unchanged.
66
- */
67
- declare function updateNode<TMetadata>(nodes: TreeNode<TMetadata>[], id: string, updater: (node: TreeNode<TMetadata>) => TreeNode<TMetadata>): TreeNode<TMetadata>[];
68
- /**
69
- * Returns a new tree with the node at the given id removed.
70
- * If the id is not found, the original tree is returned unchanged.
71
- */
72
- declare function removeNode<TMetadata>(nodes: TreeNode<TMetadata>[], id: string): TreeNode<TMetadata>[];
73
- /**
74
- * Returns a new tree with a child inserted at the given parent id.
75
- * If the parent id is not found, the original tree is returned unchanged.
76
- */
77
- declare function insertChild<TMetadata>(nodes: TreeNode<TMetadata>[], parentId: string, child: TreeNode<TMetadata>): TreeNode<TMetadata>[];
78
- /**
79
- * Result of a reorder operation.
80
- */
81
- interface ReorderResult<TMetadata> {
82
- /** The reordered tree. */
83
- nodes: TreeNode<TMetadata>[];
84
- /** The moved node. */
85
- moved: TreeNode<TMetadata>;
86
- /** ID of the parent containing the moved node, or null for root. */
18
+ declare function updateNode<T>(nodes: TreeNode<T>[], id: string, updater: (node: TreeNode<T>) => TreeNode<T>): TreeNode<T>[];
19
+ declare function removeNode<T>(nodes: TreeNode<T>[], id: string): TreeNode<T>[];
20
+ declare function insertChild<T>(nodes: TreeNode<T>[], parentId: string, child: TreeNode<T>): TreeNode<T>[];
21
+ interface ReorderResult<T> {
22
+ nodes: TreeNode<T>[];
23
+ moved: TreeNode<T>;
87
24
  parentId: string | null;
88
- /** Original index within the parent's children. */
89
25
  fromIndex: number;
90
- /** New index within the parent's children. */
91
26
  toIndex: number;
92
27
  }
93
- /**
94
- * Moves a node to a new position within the same parent.
95
- *
96
- * Returns the reordered tree and metadata about the move. If the node id
97
- * is not found, returns null.
98
- */
99
- declare function reorderNode<TMetadata>(nodes: TreeNode<TMetadata>[], nodeId: string, toIndex: number): ReorderResult<TMetadata> | null;
100
- /**
101
- * Moves a node to a different parent.
102
- *
103
- * Returns the new tree, or null if either the source or target is not found.
104
- */
105
- declare function moveNode<TMetadata>(nodes: TreeNode<TMetadata>[], nodeId: string, targetParentId: string | null, targetIndex?: number): TreeNode<TMetadata>[] | null;
28
+ declare function reorderNode<T>(nodes: TreeNode<T>[], nodeId: string, toIndex: number): ReorderResult<T> | null;
29
+ /** Move indices refer to the destination children after removal of the source. */
30
+ declare function moveNode<T>(nodes: TreeNode<T>[], nodeId: string, targetParentId: string | null, targetIndex?: number): TreeNode<T>[] | null;
106
31
 
107
32
  export { ExpandOptions, FilterTreeOptions, type ReorderResult, TreeNode, TreePath, countNodes, filterTree, findNode, findPath, flattenTree, getBranchIds, getExpandableIds, getLeaves, getMaxDepth, insertChild, isTreeNode, moveNode, removeNode, reorderNode, sortNodes, sortTree, updateNode };
@@ -1,107 +1,32 @@
1
- import { T as TreeNode, F as FilterTreeOptions, a as TreePath, E as ExpandOptions } from '../types-DVz8c2Yd.js';
1
+ import { T as TreeNode, F as FilterTreeOptions, a as TreePath, E as ExpandOptions } from '../types-CH939NGV.js';
2
2
 
3
- declare function isTreeNode<TMetadata>(value: TreeNode<TMetadata> | null | undefined): value is TreeNode<TMetadata>;
4
- /**
5
- * Finds a node by id in a tree. Returns undefined if not found.
6
- */
7
- declare function findNode<TMetadata>(nodes: TreeNode<TMetadata>[], id: string): TreeNode<TMetadata> | undefined;
8
- /**
9
- * Finds the full path from root to the node with the given id.
10
- * Returns null if the node is not found.
11
- */
12
- declare function findPath<TMetadata>(nodes: TreeNode<TMetadata>[], id: string, ancestors?: TreeNode<TMetadata>[]): TreePath<TMetadata> | null;
13
- /**
14
- * Returns all leaf nodes (nodes with no children).
15
- */
16
- declare function getLeaves<TMetadata>(nodes: TreeNode<TMetadata>[]): TreeNode<TMetadata>[];
17
- /**
18
- * Returns the total number of nodes in the tree.
19
- */
20
- declare function countNodes<TMetadata>(nodes: TreeNode<TMetadata>[]): number;
21
- /**
22
- * Returns the maximum depth of the tree. Root-level nodes are depth 1.
23
- */
24
- declare function getMaxDepth<TMetadata>(nodes: TreeNode<TMetadata>[]): number;
25
- /**
26
- * Sorts nodes by order (ascending), then by name (locale-aware, numeric).
27
- * Nodes without an order value sort after those with one.
28
- *
29
- * Returns a new array; does not mutate the input.
30
- */
31
- declare function sortNodes<TMetadata>(nodes: TreeNode<TMetadata>[]): TreeNode<TMetadata>[];
32
- /**
33
- * Recursively sorts all nodes in the tree by order, then name.
34
- * Returns a new tree; does not mutate the input.
35
- */
36
- declare function sortTree<TMetadata>(nodes: TreeNode<TMetadata>[]): TreeNode<TMetadata>[];
37
- /**
38
- * Filters a tree by query. Matching nodes and (optionally) their ancestors
39
- * are retained. Returns a new tree; does not mutate the input.
40
- *
41
- * When no query is provided, the original nodes are returned unchanged.
42
- */
43
- declare function filterTree<TMetadata>(nodes: TreeNode<TMetadata>[], options: FilterTreeOptions): TreeNode<TMetadata>[];
44
- /**
45
- * Returns the IDs of all nodes that should be expanded based on options.
46
- *
47
- * @param nodes - The root nodes.
48
- * @param options - maxDepth (default Infinity), onlyWithChildren (default true).
49
- */
50
- declare function getExpandableIds<TMetadata>(nodes: TreeNode<TMetadata>[], options?: ExpandOptions): string[];
51
- /**
52
- * Returns the IDs of all branch nodes (nodes with at least one child).
53
- */
54
- declare function getBranchIds<TMetadata>(nodes: TreeNode<TMetadata>[]): string[];
55
- /**
56
- * Flattens a tree into a list of nodes with their depth.
57
- * Parent nodes appear before their children (pre-order traversal).
58
- */
59
- declare function flattenTree<TMetadata>(nodes: TreeNode<TMetadata>[]): Array<{
60
- node: TreeNode<TMetadata>;
3
+ declare function isTreeNode<T>(value: TreeNode<T> | null | undefined): value is TreeNode<T>;
4
+ declare function findNode<T>(nodes: TreeNode<T>[], id: string): TreeNode<T> | undefined;
5
+ declare function findPath<T>(nodes: TreeNode<T>[], id: string, ancestors?: TreeNode<T>[]): TreePath<T> | null;
6
+ declare function getLeaves<T>(nodes: TreeNode<T>[]): TreeNode<T>[];
7
+ declare function countNodes<T>(nodes: TreeNode<T>[]): number;
8
+ declare function getMaxDepth<T>(nodes: TreeNode<T>[]): number;
9
+ declare function sortNodes<T>(nodes: TreeNode<T>[]): TreeNode<T>[];
10
+ declare function sortTree<T>(nodes: TreeNode<T>[]): TreeNode<T>[];
11
+ declare function filterTree<T>(nodes: TreeNode<T>[], options: FilterTreeOptions): TreeNode<T>[];
12
+ declare function getExpandableIds<T>(nodes: TreeNode<T>[], options?: ExpandOptions): string[];
13
+ declare function getBranchIds<T>(nodes: TreeNode<T>[]): string[];
14
+ declare function flattenTree<T>(nodes: TreeNode<T>[]): Array<{
15
+ node: TreeNode<T>;
61
16
  depth: number;
62
17
  }>;
63
- /**
64
- * Returns a new tree with the node at the given id replaced.
65
- * If the id is not found, the original tree is returned unchanged.
66
- */
67
- declare function updateNode<TMetadata>(nodes: TreeNode<TMetadata>[], id: string, updater: (node: TreeNode<TMetadata>) => TreeNode<TMetadata>): TreeNode<TMetadata>[];
68
- /**
69
- * Returns a new tree with the node at the given id removed.
70
- * If the id is not found, the original tree is returned unchanged.
71
- */
72
- declare function removeNode<TMetadata>(nodes: TreeNode<TMetadata>[], id: string): TreeNode<TMetadata>[];
73
- /**
74
- * Returns a new tree with a child inserted at the given parent id.
75
- * If the parent id is not found, the original tree is returned unchanged.
76
- */
77
- declare function insertChild<TMetadata>(nodes: TreeNode<TMetadata>[], parentId: string, child: TreeNode<TMetadata>): TreeNode<TMetadata>[];
78
- /**
79
- * Result of a reorder operation.
80
- */
81
- interface ReorderResult<TMetadata> {
82
- /** The reordered tree. */
83
- nodes: TreeNode<TMetadata>[];
84
- /** The moved node. */
85
- moved: TreeNode<TMetadata>;
86
- /** ID of the parent containing the moved node, or null for root. */
18
+ declare function updateNode<T>(nodes: TreeNode<T>[], id: string, updater: (node: TreeNode<T>) => TreeNode<T>): TreeNode<T>[];
19
+ declare function removeNode<T>(nodes: TreeNode<T>[], id: string): TreeNode<T>[];
20
+ declare function insertChild<T>(nodes: TreeNode<T>[], parentId: string, child: TreeNode<T>): TreeNode<T>[];
21
+ interface ReorderResult<T> {
22
+ nodes: TreeNode<T>[];
23
+ moved: TreeNode<T>;
87
24
  parentId: string | null;
88
- /** Original index within the parent's children. */
89
25
  fromIndex: number;
90
- /** New index within the parent's children. */
91
26
  toIndex: number;
92
27
  }
93
- /**
94
- * Moves a node to a new position within the same parent.
95
- *
96
- * Returns the reordered tree and metadata about the move. If the node id
97
- * is not found, returns null.
98
- */
99
- declare function reorderNode<TMetadata>(nodes: TreeNode<TMetadata>[], nodeId: string, toIndex: number): ReorderResult<TMetadata> | null;
100
- /**
101
- * Moves a node to a different parent.
102
- *
103
- * Returns the new tree, or null if either the source or target is not found.
104
- */
105
- declare function moveNode<TMetadata>(nodes: TreeNode<TMetadata>[], nodeId: string, targetParentId: string | null, targetIndex?: number): TreeNode<TMetadata>[] | null;
28
+ declare function reorderNode<T>(nodes: TreeNode<T>[], nodeId: string, toIndex: number): ReorderResult<T> | null;
29
+ /** Move indices refer to the destination children after removal of the source. */
30
+ declare function moveNode<T>(nodes: TreeNode<T>[], nodeId: string, targetParentId: string | null, targetIndex?: number): TreeNode<T>[] | null;
106
31
 
107
32
  export { ExpandOptions, FilterTreeOptions, type ReorderResult, TreeNode, TreePath, countNodes, filterTree, findNode, findPath, flattenTree, getBranchIds, getExpandableIds, getLeaves, getMaxDepth, insertChild, isTreeNode, moveNode, removeNode, reorderNode, sortNodes, sortTree, updateNode };
@@ -1 +1 @@
1
- import"../chunk-NHPRTISE.js";import{countNodes as o,filterTree as r,findNode as m,findPath as p,flattenTree as t,getBranchIds as c,getExpandableIds as h,getLeaves as i,getMaxDepth as j,insertChild as k,isTreeNode as n,moveNode as s,removeNode as u,reorderNode as T,sortNodes as e,sortTree as f,updateNode as x}from"../chunk-5KF7QUTD.js";export{o as countNodes,r as filterTree,m as findNode,p as findPath,t as flattenTree,c as getBranchIds,h as getExpandableIds,i as getLeaves,j as getMaxDepth,k as insertChild,n as isTreeNode,s as moveNode,u as removeNode,T as reorderNode,e as sortNodes,f as sortTree,x as updateNode};
1
+ import"../chunk-NHPRTISE.js";import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"../chunk-AHHDXXHL.js";export{e as countNodes,i as filterTree,b as findNode,c as findPath,l as flattenTree,k as getBranchIds,j as getExpandableIds,d as getLeaves,f as getMaxDepth,o as insertChild,a as isTreeNode,q as moveNode,n as removeNode,p as reorderNode,g as sortNodes,h as sortTree,m as updateNode};