likec4 1.29.0 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/__app__/src/main.js +52 -34
- package/__app__/src/style.css +1 -1
- package/dist/cli/index.mjs +681 -677
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/shared/{likec4.CN01ZZwj.mjs → likec4.bAyyEO3Z.mjs} +36 -36
- package/dist/shared/{likec4.DallBlZf.d.mts → likec4.tyGQtUCS.d.mts} +190 -24
- package/dist/shared/{likec4.BHE-zBYQ.mjs → likec4.wnruN9MH.mjs} +1362 -1355
- package/dist/vite-plugin/index.d.mts +1 -1
- package/dist/vite-plugin/index.mjs +1 -1
- package/package.json +22 -21
- package/react/index.mjs +19 -19
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProjectId, DiagramView, NonEmptyArray } from '@likec4/core';
|
|
2
2
|
export { AbstractRelation, AutoLayoutDirection, BBox, Color, ComputedDeploymentView, ComputedDynamicView, ComputedEdge, ComputedElementView, ComputedLikeC4ModelData, ComputedNode, ComputedView, DeployedInstance, DeploymentElement, DeploymentNode, DeploymentNodeKind, DeploymentRelation, DeploymentView, DiagramEdge, DiagramNode, DiagramView, DynamicView, EdgeId, Element, ElementKind, ElementView, Fqn, HexColorLiteral, LayoutedLikeC4ModelData, LikeC4View, NodeId, ParsedLikeC4ModelData, Point, RelationExpr, RelationId, StepEdgeId, Tag, ThemeColor, ViewId, XYPoint } from '@likec4/core';
|
|
3
3
|
import { LikeC4Model } from '@likec4/core/model';
|
|
4
4
|
export { AnyAux, Aux, LikeC4DeploymentModel, LikeC4Model, LikeC4ViewModel } from '@likec4/core/model';
|
|
5
|
-
import { W as WorkspaceFolder, a as LikeC4Services, G as GraphvizLayouter, L as LikeC4LanguageServices, b as LikeC4Views, R as Range } from './shared/likec4.
|
|
5
|
+
import { W as WorkspaceFolder, a as LikeC4Services, G as GraphvizLayouter, L as LikeC4LanguageServices, b as LikeC4Views, R as Range } from './shared/likec4.tyGQtUCS.mjs';
|
|
6
6
|
import 'type-fest';
|
|
7
7
|
import '/home/runner/work/likec4/likec4/node_modules/.pnpm/@types+picomatch@4.0.0/node_modules/@types/picomatch/posix.d.ts';
|
|
8
8
|
import '@likec4/core/types';
|
|
@@ -102,7 +102,7 @@ declare class LikeC4 {
|
|
|
102
102
|
* Diagram is a computed view, layouted using Graphviz
|
|
103
103
|
* Used in React components
|
|
104
104
|
*/
|
|
105
|
-
diagrams(): Promise<DiagramView[]>;
|
|
105
|
+
diagrams(projectId?: ProjectId | undefined): Promise<DiagramView[]>;
|
|
106
106
|
/**
|
|
107
107
|
* Builds LikeC4Model from all documents
|
|
108
108
|
* Only computes view predicates {@link ComputedView} - i.e. no layout
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"@likec4/core";export{LikeC4DeploymentModel,LikeC4Model,LikeC4ViewModel}from"@likec4/core/model";export{L as LikeC4}from"./shared/likec4.
|
|
1
|
+
import"@likec4/core";export{LikeC4DeploymentModel,LikeC4Model,LikeC4ViewModel}from"@likec4/core/model";export{L as LikeC4}from"./shared/likec4.wnruN9MH.mjs";import"node:fs";import"node:path";import"node:url";import"tty";import"node:util";import"util";import"path";import"os";import"crypto";import"net";import"url";import"fs";import"child_process";import"@likec4/core/types";import"events";import"buffer";import"@hpcc-js/wasm-graphviz";import"@likec4/core/compute-view";import"@likec4/core/utils";import"node:process";
|
|
2
2
|
import"boxen";import"node:child_process";import"node:events";import"node:fs/promises";import"node:stream/promises";import"node:os";import"fs/promises";
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import{relative as Z}from"node:path";import{f as ee,g as x,T as te,N as U,i as ne,n as _,j as S,u as m,l as ie,C as re,a as oe,b as D,c as
|
|
2
|
-
lement"in t&&"text"in t}function fe(t){try{return x(t).uri.toString()}catch{return}}function ge(t){var e,i;const{astNode:n,property:r,index:
|
|
3
|
-
return d&&v(d,T(n))}else return}}}function T(t){var e,i,n,r;return t.$cstNode?(i=(e=x(t))===null||e===void 0?void 0:e.uri)===null||i===void 0?void 0:i.toString():t.$textRegion?t.$textRegion.documentURI||((r=(n=new te(t,
|
|
4
|
-
void 0?i:t.offset+t.length,length:(n=t.length)!==null&&n!==void 0?n:t.end-t.offset};return t.range&&(r.range=t.range),e??(e=t.fileURI),e&&(r.fileURI=e),r}function A(t,e){var i,n;if(t){if(!e)return t&&v(t)}else return e&&v(e);const r=(i=t.end)!==null&&i!==void 0?i:t.offset+t.length,
|
|
5
|
-
line===t.range.start.line&&e.range.start.character<t.range.start.character?e.range.start:t.range.start,end:e.range.end.line>t.range.end.line||e.range.end.line===t.range.end.line&&e.range.end.character>t.range.end.character?e.range.end:t.range.end}),t.fileURI||e.fileURI){const
|
|
1
|
+
import{relative as Z}from"node:path";import{f as ee,g as x,T as te,N as U,i as ne,n as _,j as S,u as m,l as ie,C as re,a as oe,b as D,c as se,t as ae,d as P,m as de,p as ce,e as O,L as le}from"./likec4.wnruN9MH.mjs";function pe(t){var e,i;if(t){if("astNode"in t)return ge(t);if(Array.isArray(t))return t.reduce(A,void 0);{const n=t,r=ue(n)?fe((i=(e=n?.root)===null||e===void 0?void 0:e.astNode)!==null&&i!==void 0?i:n?.astNode):void 0;return v(n,r)}}else return}function ue(t){return typeof t<"u"&&"e\
|
|
2
|
+
lement"in t&&"text"in t}function fe(t){try{return x(t).uri.toString()}catch{return}}function ge(t){var e,i;const{astNode:n,property:r,index:s}=t??{},o=(e=n?.$cstNode)!==null&&e!==void 0?e:n?.$textRegion;if(!(n===void 0||o===void 0)){if(r===void 0)return v(o,T(n));{const a=d=>s!==void 0&&s>-1&&Array.isArray(n[r])?s<d.length?d[s]:void 0:d.reduce(A,void 0);if(!((i=o.assignments)===null||i===void 0)&&i[r]){const d=a(o.assignments[r]);return d&&v(d,T(n))}else if(n.$cstNode){const d=a(ee(n.$cstNode,r));
|
|
3
|
+
return d&&v(d,T(n))}else return}}}function T(t){var e,i,n,r;return t.$cstNode?(i=(e=x(t))===null||e===void 0?void 0:e.uri)===null||i===void 0?void 0:i.toString():t.$textRegion?t.$textRegion.documentURI||((r=(n=new te(t,s=>s.$container?[s.$container]:[]).find(s=>{var o;return(o=s.$textRegion)===null||o===void 0?void 0:o.documentURI}))===null||n===void 0?void 0:n.$textRegion)===null||r===void 0?void 0:r.documentURI):void 0}function v(t,e){var i,n;const r={offset:t.offset,end:(i=t.end)!==null&&i!==
|
|
4
|
+
void 0?i:t.offset+t.length,length:(n=t.length)!==null&&n!==void 0?n:t.end-t.offset};return t.range&&(r.range=t.range),e??(e=t.fileURI),e&&(r.fileURI=e),r}function A(t,e){var i,n;if(t){if(!e)return t&&v(t)}else return e&&v(e);const r=(i=t.end)!==null&&i!==void 0?i:t.offset+t.length,s=(n=e.end)!==null&&n!==void 0?n:e.offset+e.length,o=Math.min(t.offset,e.offset),a=Math.max(r,s),d=a-o,c={offset:o,end:a,length:d};if(t.range&&e.range&&(c.range={start:e.range.start.line<t.range.start.line||e.range.start.
|
|
5
|
+
line===t.range.start.line&&e.range.start.character<t.range.start.character?e.range.start:t.range.start,end:e.range.end.line>t.range.end.line||e.range.end.line===t.range.end.line&&e.range.end.character>t.range.end.character?e.range.end:t.range.end}),t.fileURI||e.fileURI){const u=t.fileURI,f=e.fileURI,p=u&&f&&u!==f?`<unmergable text regions of ${u}, ${f}>`:u??f;c.fileURI=p}return c}class he{constructor(e){this.defaultIndentation=" ",this.pendingIndent=!0,this.currentIndents=[],this.recentNonImmediateIndents=
|
|
6
6
|
[],this.traceData=[],this.lines=[[]],this.length=0,typeof e=="string"?this.defaultIndentation=e:typeof e=="number"&&(this.defaultIndentation="".padStart(e))}get content(){return this.lines.map(e=>e.join("")).join("")}get contentLength(){return this.length}get currentLineNumber(){return this.lines.length-1}get currentLineContent(){return this.lines[this.currentLineNumber].join("")}get currentPosition(){return{offset:this.contentLength,line:this.currentLineNumber,character:this.currentLineContent.
|
|
7
7
|
length}}append(e,i){if(e.length>0){const n=i&&this.currentPosition;this.lines[this.currentLineNumber].push(e),this.length+=e.length,n&&this.indentPendingTraceRegions(n)}}indentPendingTraceRegions(e){for(let i=this.traceData.length-1;i>=0;i--){const n=this.traceData[i];n.targetStart&&n.targetStart.offset===e.offset&&(n.targetStart=this.currentPosition)}}increaseIndent(e){this.currentIndents.push(e),e.indentImmediately||this.recentNonImmediateIndents.push(e)}decreaseIndent(){this.currentIndents.pop()}get relevantIndents(){
|
|
8
|
-
return this.currentIndents.filter(e=>!this.recentNonImmediateIndents.includes(e))}resetCurrentLine(){this.length-=this.lines[this.currentLineNumber].join("").length,this.lines[this.currentLineNumber]=[],this.pendingIndent=!0,this.recentNonImmediateIndents.length=0}addNewLine(){this.lines.push([]),this.pendingIndent=!0,this.recentNonImmediateIndents.length=0}pushTraceRegion(e){const i=me(e,this.currentPosition,n=>{var r,
|
|
9
|
-
r.children)===null||
|
|
10
|
-
var
|
|
11
|
-
complete&&n.complete(i.currentPosition);const r=n.children&&n.children.length===1?n.children[0]:void 0,
|
|
12
|
-
length===0):!1}function we(t,e){t&&(W(e,!1),e.append(t))}function W(t,e){var i;if(t.pendingIndent){let n="";for(const r of t.relevantIndents.filter(
|
|
8
|
+
return this.currentIndents.filter(e=>!this.recentNonImmediateIndents.includes(e))}resetCurrentLine(){this.length-=this.lines[this.currentLineNumber].join("").length,this.lines[this.currentLineNumber]=[],this.pendingIndent=!0,this.recentNonImmediateIndents.length=0}addNewLine(){this.lines.push([]),this.pendingIndent=!0,this.recentNonImmediateIndents.length=0}pushTraceRegion(e){const i=me(e,this.currentPosition,n=>{var r,s;return(s=(r=this.traceData[this.traceData.length-1])===null||r===void 0?void 0:
|
|
9
|
+
r.children)===null||s===void 0?void 0:s.push(n)});return this.traceData.push(i),i}popTraceRegion(e){const i=this.traceData.pop();return this.assertTrue(i===e,"Trace region mismatch!"),i}getParentTraceSourceFileURI(){var e;for(let i=this.traceData.length-1;i>-1;i--){const n=(e=this.traceData[i].sourceRegion)===null||e===void 0?void 0:e.fileURI;if(n)return n}}assertTrue(e,i){if(!e)throw new Error(i)}}function me(t,e,i){const n={sourceRegion:t,targetRegion:void 0,children:[],targetStart:e,complete:r=>{
|
|
10
|
+
var s,o;return n.targetRegion={offset:n.targetStart.offset,end:r.offset,length:r.offset-n.targetStart.offset,range:{start:{line:n.targetStart.line,character:n.targetStart.character},end:{line:r.line,character:r.character}}},delete n.targetStart,((s=n.children)===null||s===void 0?void 0:s.length)===0&&delete n.children,!((o=n.targetRegion)===null||o===void 0)&&o.length&&i(n),delete n.complete,n}};return n}function Ie(t,e){const i=new he(e),n=i.pushTraceRegion(void 0);J(t,i),i.popTraceRegion(n),n.
|
|
11
|
+
complete&&n.complete(i.currentPosition);const r=n.children&&n.children.length===1?n.children[0]:void 0,s=r?.targetRegion,o=n.targetRegion;return s&&r.sourceRegion&&s.offset===o.offset&&s.length===o.length?{text:i.content,trace:r}:{text:i.content,trace:n}}function J(t,e){typeof t=="string"?we(t,e):t instanceof E?Ne(t,e):t instanceof g?G(t,e):t instanceof $&&ve(t,e)}function V(t,e){return typeof t=="string"?t.length!==0:t instanceof g?t.contents.some(i=>V(i,e)):t instanceof $?!(t.ifNotEmpty&&e.currentLineContent.
|
|
12
|
+
length===0):!1}function we(t,e){t&&(W(e,!1),e.append(t))}function W(t,e){var i;if(t.pendingIndent){let n="";for(const r of t.relevantIndents.filter(s=>s.indentEmptyLines||!e))n+=(i=r.indentation)!==null&&i!==void 0?i:t.defaultIndentation;t.append(n,!0),t.pendingIndent=!1}}function G(t,e){let i;const n=pe(t.tracedSource);n&&(i=e.pushTraceRegion(n));for(const r of t.contents)J(r,e);if(i){e.popTraceRegion(i);const r=e.getParentTraceSourceFileURI();r&&n?.fileURI===r&&delete n.fileURI,i.complete&&i.complete(
|
|
13
13
|
e.currentPosition)}}function Ne(t,e){var i;if(V(t,e)){t.indentImmediately&&!e.pendingIndent&&e.append((i=t.indentation)!==null&&i!==void 0?i:e.defaultIndentation,!0);try{e.increaseIndent(t),G(t,e)}finally{e.decreaseIndent()}}}function ve(t,e){t.ifNotEmpty&&!ye(e.currentLineContent)?e.resetCurrentLine():(W(e,!0),e.append(t.lineDelimiter),e.addNewLine())}function ye(t){return t.trimStart()!==""}Object.freeze("__\xABSKIP^NEW^LINE^IF^EMPTY\xBB__");const ke=/\S|$/;function Le(t){const e=t.filter(n=>n.
|
|
14
|
-
length>0).map(n=>n.search(ke)),i=e.length===0?0:Math.min(...e);return Math.max(0,i)}function w(t,...e){const i
|
|
15
|
-
length-1].trim().length===0};{let r=i?e.slice(1):e;r=n?r.slice(0,r.length-1):r,r=r.filter(o=>o.length!==0);const
|
|
16
|
-
(
|
|
17
|
-
1]=="string"&&(C(t[r-2])||L(t[r-2]))?i.node.appendNewLineIfNotEmpty():i.node.appendNewLine()}:(()=>{var
|
|
14
|
+
length>0).map(n=>n.search(ke)),i=e.length===0?0:Math.min(...e);return Math.max(0,i)}function w(t,...e){const i=je(t),n=Se(t,e,i);return Te(n)}function $e(t,e,i){return(n,...r)=>Ee(t,e,i)(w(n,...r))}function je(t){const e=t.join("_").split(U),i=e.length>1&&e[0].trim().length===0,n=i&&e.length>1&&e[e.length-1].trim().length===0;if(e.length===1||e.length!==0&&e[0].trim().length!==0||e.length===2&&e[1].trim().length===0)return{indentation:0,omitFirstLine:i,omitLastLine:n,trimLastLine:e.length!==1&&e[e.
|
|
15
|
+
length-1].trim().length===0};{let r=i?e.slice(1):e;r=n?r.slice(0,r.length-1):r,r=r.filter(o=>o.length!==0);const s=Le(r);return{indentation:s,omitFirstLine:i,omitLastLine:n&&(e[e.length-1].length<s||!e[e.length-1].startsWith(r[0].substring(0,s)))}}}function Se(t,e,{indentation:i,omitFirstLine:n,omitLastLine:r,trimLastLine:s}){const o=[];t.forEach((c,u)=>{o.push(...c.split(U).map((f,p)=>p===0||f.length<i?f:f.substring(i)).reduce(u===0?(f,p,h)=>h===0?n?[]:[p]:h===1&&f.length===0?[p]:f.concat(R,p):
|
|
16
|
+
(f,p,h)=>h===0?[p]:f.concat(R,p),[]).filter(f=>!(typeof f=="string"&&f.length===0)).concat(L(e[u])?e[u]:e[u]!==void 0?{content:String(e[u])}:u<e.length?F:[]))});const a=o.length,d=a!==0?o[a-1]:void 0;return(r||s)&&typeof d=="string"&&d.trim().length===0?n&&a!==1&&o[a-2]===R?o.slice(0,a-2):o.slice(0,a-1):o}const R={isNewLine:!0},F={isUndefinedSegment:!0},z=t=>t===R,C=t=>t===F,Re=t=>t.content!==void 0;function Te(t){return t.reduce((i,n,r)=>C(n)?i:z(n)?{node:r!==0&&(C(t[r-1])||L(t[r-1]))||r>1&&typeof t[r-
|
|
17
|
+
1]=="string"&&(C(t[r-2])||L(t[r-2]))?i.node.appendNewLineIfNotEmpty():i.node.appendNewLine()}:(()=>{var s;const o=(r===0||z(t[r-1]))&&typeof n=="string"&&n.length!==0?"".padStart(n.length-n.trimStart().length):"",a=Re(n)?n.content:n;let d;return{node:i.indented?i.node:o.length!==0?i.node.indent({indentation:o,indentImmediately:!1,indentedChildren:c=>d=c.append(a)}):i.node.append(a),indented:d??((s=i.indented)===null||s===void 0?void 0:s.append(a))}})(),{node:new g}).node}const Ce=typeof process>
|
|
18
18
|
"u"?`
|
|
19
19
|
`:process.platform==="win32"?`\r
|
|
20
20
|
`:`
|
|
21
|
-
`;function L(t){return t instanceof g||t instanceof E||t instanceof
|
|
21
|
+
`;function L(t){return t instanceof g||t instanceof E||t instanceof $}function y(t,e){return L(t)?Ie(t,e).text:String(t)}class g{constructor(...e){this.contents=[],this.append(...e)}isEmpty(){return this.contents.length===0}trace(e,i,n){if(ne(e)){if(this.tracedSource={astNode:e,property:i,index:n},this.tracedSource.property===void 0&&this.tracedSource.index!==void 0&&this.tracedSource.index>-1)throw new Error("Generation support: 'property' argument must not be 'undefined' if a non-negative valu\
|
|
22
22
|
e is assigned to 'index' in 'CompositeGeneratorNode.trace(...)'.")}else this.tracedSource=e;return this}append(...e){for(const i of e)typeof i=="function"?i(this):i&&this.contents.push(i);return this}appendIf(e,...i){return e?this.append(...i):this}appendNewLine(){return this.append(l)}appendNewLineIf(e){return e?this.append(l):this}appendNewLineIfNotEmpty(){return this.append(Me)}appendNewLineIfNotEmptyIf(e){return e?this.appendNewLineIfNotEmpty():this}appendTemplate(e,...i){return this.append(
|
|
23
|
-
w(e,...i))}appendTemplateIf(e){return e?(i,...n)=>this.appendTemplate(i,...n):()=>this}indent(e){const{indentedChildren:i,indentation:n,indentEmptyLines:r,indentImmediately:
|
|
24
|
-
i():i,n,r):()=>this}appendTracedTemplate(e,i,n){return(r,...
|
|
25
|
-
padStart(e)),this.indentImmediately=i,this.indentEmptyLines=n}}class
|
|
26
|
-
if(r&&!r(h
|
|
27
|
-
switch(t.direction){case"TB":return"down";case"BT":return"up";case"LR":return"right";case"RL":return"left"}},Pe=({shape:t})=>{switch(t){case"queue":case"cylinder":case"rectangle":case"person":return t;case"storage":return"stored_data";case"mobile":case"browser":return"rectangle"}};function Y(t){const{nodes:e,edges:i}=t,n=new Map,r=(o,
|
|
28
|
-
el: ",
|
|
29
|
-
t.slice(1),Ae=t=>t.split(".").map(Oe).join(""),Je=t=>Ae(t.parent?t.id.slice(t.parent.length+1):t.id),Ve=({shape:t})=>{switch(t){case"queue":case"cylinder":return["[(",")]"];case"person":return["[fa:fa-user ","]"];case"storage":return["([","])"];case"mobile":case"browser":case"rectangle":return["[","]"]}};function q(t){const{nodes:e,edges:i}=t,n=new Map,r=(o,
|
|
30
|
-
`,"\\n"),
|
|
31
|
-
`,"\\n")+'" .-':"-","> ",n.get(o.target));return y(new g().appendIf(t.title!==null&&t.title.length>0,"---",l,`title: ${JSON.stringify(t.title)}`,l,"---",l).append("graph ",t.autoLayout.direction,l).indent({indentedChildren:o=>{o.append(I(e.filter(
|
|
32
|
-
groups??e.match(/^likec4:(?<module>.+)\/(?<projectId>.+)$/)?.groups??{};return!i||!n?null:(i.endsWith(".js")&&(i=i.slice(0,-3)),i===t?n:null)},virtualId:e=>S("likec4:plugin",e,t)+".js"}}function M(t,e){return{id:`likec4:${t}`,virtualId:`likec4:plugin/${t}.js`,async load({likec4:i,logger:n,projects:r,assetsDir:
|
|
23
|
+
w(e,...i))}appendTemplateIf(e){return e?(i,...n)=>this.appendTemplate(i,...n):()=>this}indent(e){const{indentedChildren:i,indentation:n,indentEmptyLines:r,indentImmediately:s}=Array.isArray(e)||typeof e=="function"?{indentedChildren:e}:typeof e=="object"?e:{},o=new E(n,s,r);return this.contents.push(o),Array.isArray(i)?o.append(...i):i&&o.append(i),this}appendTraced(e,i,n){return r=>this.append(new g().trace(e,i,n).append(r))}appendTracedIf(e,i,n,r){return e?this.appendTraced(typeof i=="function"?
|
|
24
|
+
i():i,n,r):()=>this}appendTracedTemplate(e,i,n){return(r,...s)=>this.append($e(e,i,n)(r,...s))}appendTracedTemplateIf(e,i,n,r){return e?this.appendTracedTemplate(typeof i=="function"?i():i,n,r):()=>this}}function Ee(t,e,i){return n=>n instanceof g&&n.tracedSource===void 0?n.trace(t,e,i):new g().trace(t,e,i).append(n)}class E extends g{constructor(e,i=!0,n=!1){super(),this.indentImmediately=!0,this.indentEmptyLines=!1,typeof e=="string"?this.indentation=e:typeof e=="number"&&(this.indentation="".
|
|
25
|
+
padStart(e)),this.indentImmediately=i,this.indentEmptyLines=n}}class ${constructor(e,i=!1){this.ifNotEmpty=!1,this.lineDelimiter=e??Ce,this.ifNotEmpty=i}}const l=new $,Me=new $(void 0,!0),B=t=>t===void 0||typeof t=="string"||L(t)?t:String(t);function I(t,e=B,i={}){const n=typeof e=="function"?e:B,{filter:r,prefix:s,suffix:o,separator:a,appendNewLineIfNotEmpty:d,skipNewLineAfterLastItem:c}=typeof e=="object"?e:i,u=typeof s=="function"?s:()=>s,f=typeof o=="function"?o:()=>o;return be(t,(p,h,j,N)=>{
|
|
26
|
+
if(r&&!r(h,j,N))return p;const b=n(h,j,N);return b===void 0?p:(p??(p=new g)).append(u(h,j,N)).append(b).append(f(h,j,N)).appendIf(!N,a).appendNewLineIfNotEmptyIf(!p.isEmpty()&&!!d&&(!N||!c))})}function be(t,e,i){const n=t[Symbol.iterator]();let r=n.next(),s=0,o=i;for(;!r.done;){const a=n.next();o=e(o,r.value,s,!!a.done),r=a,s++}return o}const xe=t=>t.charAt(0).toLocaleUpperCase()+t.slice(1),Ue=t=>t.split(".").map(xe).join(""),_e=t=>Ue(t.parent?t.id.slice(t.parent.length+1):t.id),De=({autoLayout:t})=>{
|
|
27
|
+
switch(t.direction){case"TB":return"down";case"BT":return"up";case"LR":return"right";case"RL":return"left"}},Pe=({shape:t})=>{switch(t){case"queue":case"cylinder":case"rectangle":case"person":return t;case"storage":return"stored_data";case"mobile":case"browser":return"rectangle"}};function Y(t){const{nodes:e,edges:i}=t,n=new Map,r=(o,a)=>{const d=_e(o),c=(a?a+".":"")+d;n.set(o.id,c);const u=JSON.stringify(o.title),f=Pe(o);return new g().append(d,": {",l).indent({indentedChildren:p=>p.append("lab\
|
|
28
|
+
el: ",u,l).appendIf(f!=="rectangle","shape: ",f,l).appendIf(o.children.length>0,l,I(e.filter(h=>h.parent===o.id),h=>r(h,c))),indentation:2}).append("}",l)},s=o=>new g().append(n.get(o.source)," -> ",n.get(o.target)).append(a=>o.label&&a.append(": ",JSON.stringify(o.label)));return y(new g().append("direction: ",De(t),l,l).append(I(e.filter(o=>_(o.parent)),o=>r(o),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,l,I(i,o=>s(o),{appendNewLineIfNotEmpty:!0})))}const Oe=t=>t.charAt(0).toLocaleUpperCase()+
|
|
29
|
+
t.slice(1),Ae=t=>t.split(".").map(Oe).join(""),Je=t=>Ae(t.parent?t.id.slice(t.parent.length+1):t.id),Ve=({shape:t})=>{switch(t){case"queue":case"cylinder":return["[(",")]"];case"person":return["[fa:fa-user ","]"];case"storage":return["([","])"];case"mobile":case"browser":case"rectangle":return["[","]"]}};function q(t){const{nodes:e,edges:i}=t,n=new Map,r=(o,a)=>{const d=Je(o),c=(a?a+".":"")+d;n.set(o.id,c);const u=o.title.replaceAll(`
|
|
30
|
+
`,"\\n"),f=Ve(o),p=new g;return o.children.length>0?p.append("subgraph ",c,"[",JSON.stringify(o.title),"]",l).indent({indentedChildren:[I(e.filter(h=>h.parent===o.id),h=>r(h,c),{appendNewLineIfNotEmpty:!0})],indentation:2}).append("end",l):p.append(c,f[0],u,f[1]),p},s=o=>new g().append(n.get(o.source)," -.",o.label?' "'+o.label.replaceAll(`
|
|
31
|
+
`,"\\n")+'" .-':"-","> ",n.get(o.target));return y(new g().appendIf(t.title!==null&&t.title.length>0,"---",l,`title: ${JSON.stringify(t.title)}`,l,"---",l).append("graph ",t.autoLayout.direction,l).indent({indentedChildren:o=>{o.append(I(e.filter(a=>_(a.parent)),a=>r(a),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,I(i,a=>s(a),{appendNewLineIfNotEmpty:!0}))},indentation:2}))}function k(t){return{matches:e=>{let{module:i,projectId:n}=e.match(/^likec4:plugin\/(?<projectId>.+)\/(?<module>.+)$/)?.
|
|
32
|
+
groups??e.match(/^likec4:(?<module>.+)\/(?<projectId>.+)$/)?.groups??{};return!i||!n?null:(i.endsWith(".js")&&(i=i.slice(0,-3)),i===t?n:null)},virtualId:e=>S("likec4:plugin",e,t)+".js"}}function M(t,e){return{id:`likec4:${t}`,virtualId:`likec4:plugin/${t}.js`,async load({likec4:i,logger:n,projects:r,assetsDir:s}){n.info(m.dim(`generating likec4:${t}`));const o=r.map(({id:a})=>{const d=S(`likec4:${t}`,a);return` case ${JSON.stringify(a)}: return await import(${JSON.stringify(d)})`});return`
|
|
33
33
|
export async function ${e}(projectId) {
|
|
34
34
|
switch (projectId) {
|
|
35
35
|
${o.join(`
|
|
@@ -86,8 +86,8 @@ export async function ${e}(projectId) {
|
|
|
86
86
|
default: {
|
|
87
87
|
throw new Error('Unknown viewId: ' + viewId)
|
|
88
88
|
}
|
|
89
|
-
`}}).append(l," }",l,"}",l,l),y(e)}const Be={...k("dot"),async load({likec4:t,projectId:e,logger:i}){i.info(m.dim(`generating likec4:dot/${e}`));const n=await t.views.viewsAsGraphvizOut(),r=ie(n,({id:
|
|
90
|
-
padStart(2,"0");return r.imports.push(`import ${c} from 'likec4/icons/${
|
|
89
|
+
`}}).append(l," }",l,"}",l,l),y(e)}const Be={...k("dot"),async load({likec4:t,projectId:e,logger:i}){i.info(m.dim(`generating likec4:dot/${e}`));const n=await t.views.viewsAsGraphvizOut(e),r=ie(n,({id:s,svg:o,dot:a})=>[s,{dot:a,svg:o}]);return ze(r)}},Ye=M("dot","loadDotSources");function qe(t){const e=re(t.flatMap(r=>r.nodes.map(s=>s.icon)),D(ae),D(r=>se(r)&&!(r.toLowerCase().startsWith("http:")||r.toLowerCase().startsWith("https:"))),oe()).sort(),{imports:i,cases:n}=e.reduce((r,s,o)=>{
|
|
90
|
+
const a=s.startsWith("file:"),d="Icon"+o.toString().padStart(2,"0");if(a)return r.imports.push(`import ${d} from '${s}?inline'`),r.cases.push(` '${s}': () => jsx('img', { src: ${d} })`),r;const[c,u]=s.split(":");return r.imports.push(`import ${d} from 'likec4/icons/${c}/${u}'`),r.cases.push(` '${c}:${u}': ${d}`),r},{imports:[],cases:[]});return`
|
|
91
91
|
import { jsx } from 'react/jsx-runtime'
|
|
92
92
|
${i.join(`
|
|
93
93
|
`)}
|
|
@@ -117,8 +117,8 @@ if (import.meta.hot) {
|
|
|
117
117
|
}
|
|
118
118
|
})
|
|
119
119
|
}
|
|
120
|
-
`}const He={...k("icons"),async load({likec4:t,projectId:e,logger:i}){i.info(m.dim(`generating likec4:icons/${e}`));const n=await t.views.computedViews(e);return qe(n)}},Ke={id:"likec4:icons",virtualId:"likec4:plugin/icons.
|
|
121
|
-
c)}`),
|
|
120
|
+
`}const He={...k("icons"),async load({likec4:t,projectId:e,logger:i}){i.info(m.dim(`generating likec4:icons/${e}`));const n=await t.views.computedViews(e);return qe(n)}},Ke={id:"likec4:icons",virtualId:"likec4:plugin/icons.jsx",async load({likec4:t,projects:e,logger:i}){i.info(m.dim("generating likec4:icons"));const{imports:n,cases:r}=e.reduce((s,{id:o},a)=>{const d="Icons"+a.toString().padStart(2,"0"),c=S("likec4:icons",o);return s.imports.push(`import { IconRenderer as ${d} } from ${JSON.stringify(
|
|
121
|
+
c)}`),s.cases.push(` case ${JSON.stringify(o)}: return ${d}`),s},{imports:[],cases:[]});return`
|
|
122
122
|
${n.join(`
|
|
123
123
|
`)}
|
|
124
124
|
|
|
@@ -179,7 +179,7 @@ if (import.meta.hot) {
|
|
|
179
179
|
`,tt={...k("model"),async load({likec4:t,projectId:e,logger:i,assetsDir:n}){i.info(m.dim(`generating likec4:model/${e}`));const r=await t.layoutedModel(e);return et(r)}},nt={id:"likec4:model",virtualId:"likec4:plugin/model.js",async load({likec4:t,logger:e,projects:i,assetsDir:n}){return e.info(m.dim("generating likec4:model")),`
|
|
180
180
|
export async function loadModel(projectId) {
|
|
181
181
|
switch (projectId) {
|
|
182
|
-
${i.map(({id:r})=>{const
|
|
182
|
+
${i.map(({id:r})=>{const s=S("likec4:model",r);return` case ${JSON.stringify(r)}: return await import(${JSON.stringify(s)})`}).join(`
|
|
183
183
|
`)}
|
|
184
184
|
default: throw new Error('Unknown projectId: ' + projectId)
|
|
185
185
|
}
|
|
@@ -210,7 +210,7 @@ export {
|
|
|
210
210
|
useLikeC4View,
|
|
211
211
|
useLikeC4Views
|
|
212
212
|
}
|
|
213
|
-
`,ot={...k("react"),async load({projectId:t,logger:e}){return e.info(m.dim(`generating likec4:react/${t}`)),H(t)}},
|
|
213
|
+
`,ot={...k("react"),async load({projectId:t,logger:e}){return e.info(m.dim(`generating likec4:react/${t}`)),H(t)}},st={id:"likec4:react",virtualId:"likec4:plugin/react.js",async load({logger:t,projects:e}){const i=O(e);return t.info(m.dim("generating likec4:react for")+" "+i.id),H(i.id)}},at=t=>`
|
|
214
214
|
export { IconRenderer } from 'likec4:icons/${t}'
|
|
215
215
|
export {
|
|
216
216
|
$likec4data,
|
|
@@ -220,8 +220,8 @@ export {
|
|
|
220
220
|
useLikeC4View
|
|
221
221
|
} from 'likec4:model/${t}'
|
|
222
222
|
export const projectId = ${JSON.stringify(t)}
|
|
223
|
-
`,dt={id:"likec4:single-project",virtualId:"likec4:plugin/single-project.js",async load({likec4:t,logger:e,projects:i,assetsDir:n}){const r=O(i);return e.info(m.dim("generating likec4:single-project for")+" "+r.id),
|
|
224
|
-
if(i=o.root,n=o.logger,t===!0){const
|
|
225
|
-
virtualId(d)}for(const
|
|
226
|
-
ct(
|
|
227
|
-
`+c.message.slice(0,500),stack:"",plugin:"vite-plugin-likec4",loc:{file:Z(i,c.sourceFsPath),line:c.range.start.line+1,column:c.range.start.character+1}}});return}for(const
|
|
223
|
+
`,dt={id:"likec4:single-project",virtualId:"likec4:plugin/single-project.js",async load({likec4:t,logger:e,projects:i,assetsDir:n}){const r=O(i);return e.info(m.dim("generating likec4:single-project for")+" "+r.id),at(r.id)}},K=[tt,He,Ge,Be,Qe],X=[...K,ot],Q=[rt,nt,dt,st,Fe,Ye,Ze,Ke],ct=t=>{const e=t.toLowerCase();return e.endsWith(".c4")||e.endsWith(".likec4")||e.endsWith(".like-c4")};function lt({useOverviewGraph:t=!1,...e}){let i,n,r,s;return{name:"vite-plugin-likec4",async configResolved(o){
|
|
224
|
+
if(i=o.root,n=o.logger,t===!0){const a=o.resolve.alias.find(d=>d.find==="likec4/previews")?.replacement;a?(s=a,n.info(m.dim("likec4/previews alias")+" "+m.dim(s))):n.warn("likec4/previews alias not found")}e.languageServices?r=e.languageServices:r=(await le.fromWorkspace(e.workspace??o.root,{logger:n,graphviz:e.graphviz??"wasm",printErrors:e.printErrors??!0,throwIfInvalid:e.throwIfInvalid??!1})).languageServices,s=r.workspaceUri.fsPath},resolveId(o){for(const a of X){const d=a.matches(o);if(d)return a.
|
|
225
|
+
virtualId(d)}for(const a of Q)if(a.id===o)return a.virtualId;return null},async load(o){for(const a of X){const d=a.matches(o);if(d)return await a.load({logger:n,likec4:r,projectId:d,assetsDir:s,useOverviewGraph:t})}for(const a of Q)if(a.virtualId===o){const d=await r.projects();return await a.load({logger:n,likec4:r,projects:d,assetsDir:s,useOverviewGraph:t})}return null},configureServer(o){const a=r.projects().map(({folder:c})=>c.fsPath);for(const c of a)n.info(`${m.dim("watch")} ${c}`);const d=c=>u=>{
|
|
226
|
+
ct(u)&&r.notifyUpdate({[c]:u})};o.watcher.add(a).on("add",d("changed")).on("change",d("changed")).on("unlink",d("removed")),r.builder.onModelParsed(async()=>{const[c]=r.getErrors();if(c){o.ws.send({type:"error",err:{name:"LikeC4ValidationError",message:`Validation failed
|
|
227
|
+
`+c.message.slice(0,500),stack:"",plugin:"vite-plugin-likec4",loc:{file:Z(i,c.sourceFsPath),line:c.range.start.line+1,column:c.range.start.character+1}}});return}for(const u of r.projects())for(const f of K){const p=o.moduleGraph.getModuleById(f.virtualId(u.id));if(p&&p.importers.size>0){n.info(`${m.green("reload")} ${m.dim(p.id??p.url)}`);try{await o.reloadModule(p)}catch(h){n.error(h)}}}})}}}export{g as C,lt as L,l as N,Y as a,w as e,q as g,I as j,y as t};
|
|
@@ -17773,7 +17773,7 @@ declare namespace util {
|
|
|
17773
17773
|
export { };
|
|
17774
17774
|
}
|
|
17775
17775
|
declare namespace objectUtil {
|
|
17776
|
-
export type MergeShapes<U, V> = {
|
|
17776
|
+
export type MergeShapes<U, V> = keyof U & keyof V extends never ? U & V : {
|
|
17777
17777
|
[k in Exclude<keyof U, keyof V>]: U[k];
|
|
17778
17778
|
} & V;
|
|
17779
17779
|
type optionalKeys<T extends object> = {
|
|
@@ -17800,7 +17800,7 @@ declare namespace objectUtil {
|
|
|
17800
17800
|
[k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
|
|
17801
17801
|
}>;
|
|
17802
17802
|
export const mergeShapes: <U, T>(first: U, second: T) => T & U;
|
|
17803
|
-
export type extendShape<A extends object, B extends object> = {
|
|
17803
|
+
export type extendShape<A extends object, B extends object> = keyof A & keyof B extends never ? A & B : {
|
|
17804
17804
|
[K in keyof A as K extends keyof B ? never : K]: A[K];
|
|
17805
17805
|
} & {
|
|
17806
17806
|
[K in keyof B]: B[K];
|
|
@@ -19047,6 +19047,10 @@ declare const ResultSchema: ZodObject<{
|
|
|
19047
19047
|
*/
|
|
19048
19048
|
_meta: ZodOptional<ZodObject<{}, "passthrough", ZodTypeAny, objectOutputType<{}, ZodTypeAny, "passthrough">, objectInputType<{}, ZodTypeAny, "passthrough">>>;
|
|
19049
19049
|
}, ZodTypeAny, "passthrough">>;
|
|
19050
|
+
/**
|
|
19051
|
+
* A uniquely identifying ID for a request in JSON-RPC.
|
|
19052
|
+
*/
|
|
19053
|
+
declare const RequestIdSchema: ZodUnion<[ZodString, ZodNumber]>;
|
|
19050
19054
|
declare const JSONRPCMessageSchema: ZodUnion<[ZodObject<objectUtil.extendShape<{
|
|
19051
19055
|
jsonrpc: ZodLiteral<"2.0">;
|
|
19052
19056
|
id: ZodUnion<[ZodString, ZodNumber]>;
|
|
@@ -34827,6 +34831,7 @@ type Infer<Schema extends ZodTypeAny> = Flatten<TypeOf<Schema>>;
|
|
|
34827
34831
|
type Request = Infer<typeof RequestSchema>;
|
|
34828
34832
|
type Notification = Infer<typeof NotificationSchema>;
|
|
34829
34833
|
type Result = Infer<typeof ResultSchema>;
|
|
34834
|
+
type RequestId = Infer<typeof RequestIdSchema>;
|
|
34830
34835
|
type JSONRPCMessage = Infer<typeof JSONRPCMessageSchema>;
|
|
34831
34836
|
type Implementation = Infer<typeof ImplementationSchema>;
|
|
34832
34837
|
type ClientCapabilities = Infer<typeof ClientCapabilitiesSchema>;
|
|
@@ -34845,6 +34850,54 @@ type ServerRequest = Infer<typeof ServerRequestSchema>;
|
|
|
34845
34850
|
type ServerNotification = Infer<typeof ServerNotificationSchema>;
|
|
34846
34851
|
type ServerResult = Infer<typeof ServerResultSchema>;
|
|
34847
34852
|
|
|
34853
|
+
/**
|
|
34854
|
+
* Information about a validated access token, provided to request handlers.
|
|
34855
|
+
*/
|
|
34856
|
+
interface AuthInfo {
|
|
34857
|
+
/**
|
|
34858
|
+
* The access token.
|
|
34859
|
+
*/
|
|
34860
|
+
token: string;
|
|
34861
|
+
/**
|
|
34862
|
+
* The client ID associated with this token.
|
|
34863
|
+
*/
|
|
34864
|
+
clientId: string;
|
|
34865
|
+
/**
|
|
34866
|
+
* Scopes associated with this token.
|
|
34867
|
+
*/
|
|
34868
|
+
scopes: string[];
|
|
34869
|
+
/**
|
|
34870
|
+
* When the token expires (in seconds since epoch).
|
|
34871
|
+
*/
|
|
34872
|
+
expiresAt?: number;
|
|
34873
|
+
/**
|
|
34874
|
+
* Additional data associated with the token.
|
|
34875
|
+
* This field should be used for any additional data that needs to be attached to the auth info.
|
|
34876
|
+
*/
|
|
34877
|
+
extra?: Record<string, unknown>;
|
|
34878
|
+
}
|
|
34879
|
+
|
|
34880
|
+
/**
|
|
34881
|
+
* Options for sending a JSON-RPC message.
|
|
34882
|
+
*/
|
|
34883
|
+
type TransportSendOptions = {
|
|
34884
|
+
/**
|
|
34885
|
+
* If present, `relatedRequestId` is used to indicate to the transport which incoming request to associate this outgoing message with.
|
|
34886
|
+
*/
|
|
34887
|
+
relatedRequestId?: RequestId;
|
|
34888
|
+
/**
|
|
34889
|
+
* The resumption token used to continue long-running requests that were interrupted.
|
|
34890
|
+
*
|
|
34891
|
+
* This allows clients to reconnect and continue from where they left off, if supported by the transport.
|
|
34892
|
+
*/
|
|
34893
|
+
resumptionToken?: string;
|
|
34894
|
+
/**
|
|
34895
|
+
* A callback that is invoked when the resumption token changes, if supported by the transport.
|
|
34896
|
+
*
|
|
34897
|
+
* This allows clients to persist the latest token for potential reconnection.
|
|
34898
|
+
*/
|
|
34899
|
+
onresumptiontoken?: (token: string) => void;
|
|
34900
|
+
};
|
|
34848
34901
|
/**
|
|
34849
34902
|
* Describes the minimal contract for a MCP transport that a client or server can communicate over.
|
|
34850
34903
|
*/
|
|
@@ -34859,8 +34912,10 @@ interface Transport {
|
|
|
34859
34912
|
start(): Promise<void>;
|
|
34860
34913
|
/**
|
|
34861
34914
|
* Sends a JSON-RPC message (request or response).
|
|
34915
|
+
*
|
|
34916
|
+
* If present, `relatedRequestId` is used to indicate to the transport which incoming request to associate this outgoing message with.
|
|
34862
34917
|
*/
|
|
34863
|
-
send(message: JSONRPCMessage): Promise<void>;
|
|
34918
|
+
send(message: JSONRPCMessage, options?: TransportSendOptions): Promise<void>;
|
|
34864
34919
|
/**
|
|
34865
34920
|
* Closes the connection.
|
|
34866
34921
|
*/
|
|
@@ -34879,8 +34934,13 @@ interface Transport {
|
|
|
34879
34934
|
onerror?: (error: Error) => void;
|
|
34880
34935
|
/**
|
|
34881
34936
|
* Callback for when a message (request or response) is received over the connection.
|
|
34937
|
+
*
|
|
34938
|
+
* Includes the authInfo if the transport is authenticated.
|
|
34939
|
+
*
|
|
34882
34940
|
*/
|
|
34883
|
-
onmessage?: (message: JSONRPCMessage
|
|
34941
|
+
onmessage?: (message: JSONRPCMessage, extra?: {
|
|
34942
|
+
authInfo?: AuthInfo;
|
|
34943
|
+
}) => void;
|
|
34884
34944
|
/**
|
|
34885
34945
|
* The session ID generated for this connection.
|
|
34886
34946
|
*/
|
|
@@ -34934,19 +34994,44 @@ type RequestOptions = {
|
|
|
34934
34994
|
* If not specified, there is no maximum total timeout.
|
|
34935
34995
|
*/
|
|
34936
34996
|
maxTotalTimeout?: number;
|
|
34997
|
+
} & TransportSendOptions;
|
|
34998
|
+
/**
|
|
34999
|
+
* Options that can be given per notification.
|
|
35000
|
+
*/
|
|
35001
|
+
type NotificationOptions = {
|
|
35002
|
+
/**
|
|
35003
|
+
* May be used to indicate to the transport which incoming request to associate this outgoing notification with.
|
|
35004
|
+
*/
|
|
35005
|
+
relatedRequestId?: RequestId;
|
|
34937
35006
|
};
|
|
34938
35007
|
/**
|
|
34939
35008
|
* Extra data given to request handlers.
|
|
34940
35009
|
*/
|
|
34941
|
-
type RequestHandlerExtra = {
|
|
35010
|
+
type RequestHandlerExtra<SendRequestT extends Request, SendNotificationT extends Notification> = {
|
|
34942
35011
|
/**
|
|
34943
35012
|
* An abort signal used to communicate if the request was cancelled from the sender's side.
|
|
34944
35013
|
*/
|
|
34945
35014
|
signal: AbortSignal;
|
|
35015
|
+
/**
|
|
35016
|
+
* Information about a validated access token, provided to request handlers.
|
|
35017
|
+
*/
|
|
35018
|
+
authInfo?: AuthInfo;
|
|
34946
35019
|
/**
|
|
34947
35020
|
* The session ID from the transport, if available.
|
|
34948
35021
|
*/
|
|
34949
35022
|
sessionId?: string;
|
|
35023
|
+
/**
|
|
35024
|
+
* Sends a notification that relates to the current request being handled.
|
|
35025
|
+
*
|
|
35026
|
+
* This is used by certain transports to correctly associate related messages.
|
|
35027
|
+
*/
|
|
35028
|
+
sendNotification: (notification: SendNotificationT) => Promise<void>;
|
|
35029
|
+
/**
|
|
35030
|
+
* Sends a request that relates to the current request being handled.
|
|
35031
|
+
*
|
|
35032
|
+
* This is used by certain transports to correctly associate related messages.
|
|
35033
|
+
*/
|
|
35034
|
+
sendRequest: <U extends ZodType<object>>(request: SendRequestT, resultSchema: U, options?: RequestOptions) => Promise<TypeOf<U>>;
|
|
34950
35035
|
};
|
|
34951
35036
|
/**
|
|
34952
35037
|
* Implements MCP protocol framing on top of a pluggable transport, including
|
|
@@ -35030,7 +35115,7 @@ declare abstract class Protocol<SendRequestT extends Request, SendNotificationT
|
|
|
35030
35115
|
/**
|
|
35031
35116
|
* Emits a notification, which is a one-way message that does not expect a response.
|
|
35032
35117
|
*/
|
|
35033
|
-
notification(notification: SendNotificationT): Promise<void>;
|
|
35118
|
+
notification(notification: SendNotificationT, options?: NotificationOptions): Promise<void>;
|
|
35034
35119
|
/**
|
|
35035
35120
|
* Registers a handler to invoke when this protocol object receives a request with the given method.
|
|
35036
35121
|
*
|
|
@@ -35038,7 +35123,7 @@ declare abstract class Protocol<SendRequestT extends Request, SendNotificationT
|
|
|
35038
35123
|
*/
|
|
35039
35124
|
setRequestHandler<T extends ZodObject<{
|
|
35040
35125
|
method: ZodLiteral<string>;
|
|
35041
|
-
}>>(requestSchema: T, handler: (request: TypeOf<T>, extra: RequestHandlerExtra) => SendResultT | Promise<SendResultT>): void;
|
|
35126
|
+
}>>(requestSchema: T, handler: (request: TypeOf<T>, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
|
|
35042
35127
|
/**
|
|
35043
35128
|
* Removes the request handler for the given method.
|
|
35044
35129
|
*/
|
|
@@ -35257,51 +35342,68 @@ declare class McpServer {
|
|
|
35257
35342
|
/**
|
|
35258
35343
|
* Registers a resource `name` at a fixed URI, which will use the given callback to respond to read requests.
|
|
35259
35344
|
*/
|
|
35260
|
-
resource(name: string, uri: string, readCallback: ReadResourceCallback):
|
|
35345
|
+
resource(name: string, uri: string, readCallback: ReadResourceCallback): RegisteredResource;
|
|
35261
35346
|
/**
|
|
35262
35347
|
* Registers a resource `name` at a fixed URI with metadata, which will use the given callback to respond to read requests.
|
|
35263
35348
|
*/
|
|
35264
|
-
resource(name: string, uri: string, metadata: ResourceMetadata, readCallback: ReadResourceCallback):
|
|
35349
|
+
resource(name: string, uri: string, metadata: ResourceMetadata, readCallback: ReadResourceCallback): RegisteredResource;
|
|
35265
35350
|
/**
|
|
35266
35351
|
* Registers a resource `name` with a template pattern, which will use the given callback to respond to read requests.
|
|
35267
35352
|
*/
|
|
35268
|
-
resource(name: string, template: ResourceTemplate, readCallback: ReadResourceTemplateCallback):
|
|
35353
|
+
resource(name: string, template: ResourceTemplate, readCallback: ReadResourceTemplateCallback): RegisteredResourceTemplate;
|
|
35269
35354
|
/**
|
|
35270
35355
|
* Registers a resource `name` with a template pattern and metadata, which will use the given callback to respond to read requests.
|
|
35271
35356
|
*/
|
|
35272
|
-
resource(name: string, template: ResourceTemplate, metadata: ResourceMetadata, readCallback: ReadResourceTemplateCallback):
|
|
35357
|
+
resource(name: string, template: ResourceTemplate, metadata: ResourceMetadata, readCallback: ReadResourceTemplateCallback): RegisteredResourceTemplate;
|
|
35273
35358
|
/**
|
|
35274
35359
|
* Registers a zero-argument tool `name`, which will run the given function when the client calls it.
|
|
35275
35360
|
*/
|
|
35276
|
-
tool(name: string, cb: ToolCallback):
|
|
35361
|
+
tool(name: string, cb: ToolCallback): RegisteredTool;
|
|
35277
35362
|
/**
|
|
35278
35363
|
* Registers a zero-argument tool `name` (with a description) which will run the given function when the client calls it.
|
|
35279
35364
|
*/
|
|
35280
|
-
tool(name: string, description: string, cb: ToolCallback):
|
|
35365
|
+
tool(name: string, description: string, cb: ToolCallback): RegisteredTool;
|
|
35281
35366
|
/**
|
|
35282
35367
|
* Registers a tool `name` accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments.
|
|
35283
35368
|
*/
|
|
35284
|
-
tool<Args extends ZodRawShape>(name: string, paramsSchema: Args, cb: ToolCallback<Args>):
|
|
35369
|
+
tool<Args extends ZodRawShape>(name: string, paramsSchema: Args, cb: ToolCallback<Args>): RegisteredTool;
|
|
35285
35370
|
/**
|
|
35286
35371
|
* Registers a tool `name` (with a description) accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments.
|
|
35287
35372
|
*/
|
|
35288
|
-
tool<Args extends ZodRawShape>(name: string, description: string, paramsSchema: Args, cb: ToolCallback<Args>):
|
|
35373
|
+
tool<Args extends ZodRawShape>(name: string, description: string, paramsSchema: Args, cb: ToolCallback<Args>): RegisteredTool;
|
|
35289
35374
|
/**
|
|
35290
35375
|
* Registers a zero-argument prompt `name`, which will run the given function when the client calls it.
|
|
35291
35376
|
*/
|
|
35292
|
-
prompt(name: string, cb: PromptCallback):
|
|
35377
|
+
prompt(name: string, cb: PromptCallback): RegisteredPrompt;
|
|
35293
35378
|
/**
|
|
35294
35379
|
* Registers a zero-argument prompt `name` (with a description) which will run the given function when the client calls it.
|
|
35295
35380
|
*/
|
|
35296
|
-
prompt(name: string, description: string, cb: PromptCallback):
|
|
35381
|
+
prompt(name: string, description: string, cb: PromptCallback): RegisteredPrompt;
|
|
35297
35382
|
/**
|
|
35298
35383
|
* Registers a prompt `name` accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments.
|
|
35299
35384
|
*/
|
|
35300
|
-
prompt<Args extends PromptArgsRawShape>(name: string, argsSchema: Args, cb: PromptCallback<Args>):
|
|
35385
|
+
prompt<Args extends PromptArgsRawShape>(name: string, argsSchema: Args, cb: PromptCallback<Args>): RegisteredPrompt;
|
|
35301
35386
|
/**
|
|
35302
35387
|
* Registers a prompt `name` (with a description) accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments.
|
|
35303
35388
|
*/
|
|
35304
|
-
prompt<Args extends PromptArgsRawShape>(name: string, description: string, argsSchema: Args, cb: PromptCallback<Args>):
|
|
35389
|
+
prompt<Args extends PromptArgsRawShape>(name: string, description: string, argsSchema: Args, cb: PromptCallback<Args>): RegisteredPrompt;
|
|
35390
|
+
/**
|
|
35391
|
+
* Checks if the server is connected to a transport.
|
|
35392
|
+
* @returns True if the server is connected
|
|
35393
|
+
*/
|
|
35394
|
+
isConnected(): boolean;
|
|
35395
|
+
/**
|
|
35396
|
+
* Sends a resource list changed event to the client, if connected.
|
|
35397
|
+
*/
|
|
35398
|
+
sendResourceListChanged(): void;
|
|
35399
|
+
/**
|
|
35400
|
+
* Sends a tool list changed event to the client, if connected.
|
|
35401
|
+
*/
|
|
35402
|
+
sendToolListChanged(): void;
|
|
35403
|
+
/**
|
|
35404
|
+
* Sends a prompt list changed event to the client, if connected.
|
|
35405
|
+
*/
|
|
35406
|
+
sendPromptListChanged(): void;
|
|
35305
35407
|
}
|
|
35306
35408
|
/**
|
|
35307
35409
|
* A callback to complete one variable within a resource template's URI template.
|
|
@@ -35344,7 +35446,23 @@ declare class ResourceTemplate {
|
|
|
35344
35446
|
*
|
|
35345
35447
|
* Parameters will include tool arguments, if applicable, as well as other request handler context.
|
|
35346
35448
|
*/
|
|
35347
|
-
type ToolCallback<Args extends undefined | ZodRawShape = undefined> = Args extends ZodRawShape ? (args: objectOutputType<Args, ZodTypeAny>, extra: RequestHandlerExtra) => CallToolResult | Promise<CallToolResult> : (extra: RequestHandlerExtra) => CallToolResult | Promise<CallToolResult>;
|
|
35449
|
+
type ToolCallback<Args extends undefined | ZodRawShape = undefined> = Args extends ZodRawShape ? (args: objectOutputType<Args, ZodTypeAny>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => CallToolResult | Promise<CallToolResult> : (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => CallToolResult | Promise<CallToolResult>;
|
|
35450
|
+
type RegisteredTool = {
|
|
35451
|
+
description?: string;
|
|
35452
|
+
inputSchema?: AnyZodObject;
|
|
35453
|
+
callback: ToolCallback<undefined | ZodRawShape>;
|
|
35454
|
+
enabled: boolean;
|
|
35455
|
+
enable(): void;
|
|
35456
|
+
disable(): void;
|
|
35457
|
+
update<Args extends ZodRawShape>(updates: {
|
|
35458
|
+
name?: string | null;
|
|
35459
|
+
description?: string;
|
|
35460
|
+
paramsSchema?: Args;
|
|
35461
|
+
callback?: ToolCallback<Args>;
|
|
35462
|
+
enabled?: boolean;
|
|
35463
|
+
}): void;
|
|
35464
|
+
remove(): void;
|
|
35465
|
+
};
|
|
35348
35466
|
/**
|
|
35349
35467
|
* Additional, optional information for annotating a resource.
|
|
35350
35468
|
*/
|
|
@@ -35352,19 +35470,67 @@ type ResourceMetadata = Omit<Resource, "uri" | "name">;
|
|
|
35352
35470
|
/**
|
|
35353
35471
|
* Callback to list all resources matching a given template.
|
|
35354
35472
|
*/
|
|
35355
|
-
type ListResourcesCallback = (extra: RequestHandlerExtra) => ListResourcesResult | Promise<ListResourcesResult>;
|
|
35473
|
+
type ListResourcesCallback = (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => ListResourcesResult | Promise<ListResourcesResult>;
|
|
35356
35474
|
/**
|
|
35357
35475
|
* Callback to read a resource at a given URI.
|
|
35358
35476
|
*/
|
|
35359
|
-
type ReadResourceCallback = (uri: URL, extra: RequestHandlerExtra) => ReadResourceResult | Promise<ReadResourceResult>;
|
|
35477
|
+
type ReadResourceCallback = (uri: URL, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => ReadResourceResult | Promise<ReadResourceResult>;
|
|
35478
|
+
type RegisteredResource = {
|
|
35479
|
+
name: string;
|
|
35480
|
+
metadata?: ResourceMetadata;
|
|
35481
|
+
readCallback: ReadResourceCallback;
|
|
35482
|
+
enabled: boolean;
|
|
35483
|
+
enable(): void;
|
|
35484
|
+
disable(): void;
|
|
35485
|
+
update(updates: {
|
|
35486
|
+
name?: string;
|
|
35487
|
+
uri?: string | null;
|
|
35488
|
+
metadata?: ResourceMetadata;
|
|
35489
|
+
callback?: ReadResourceCallback;
|
|
35490
|
+
enabled?: boolean;
|
|
35491
|
+
}): void;
|
|
35492
|
+
remove(): void;
|
|
35493
|
+
};
|
|
35360
35494
|
/**
|
|
35361
35495
|
* Callback to read a resource at a given URI, following a filled-in URI template.
|
|
35362
35496
|
*/
|
|
35363
|
-
type ReadResourceTemplateCallback = (uri: URL, variables: Variables, extra: RequestHandlerExtra) => ReadResourceResult | Promise<ReadResourceResult>;
|
|
35497
|
+
type ReadResourceTemplateCallback = (uri: URL, variables: Variables, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => ReadResourceResult | Promise<ReadResourceResult>;
|
|
35498
|
+
type RegisteredResourceTemplate = {
|
|
35499
|
+
resourceTemplate: ResourceTemplate;
|
|
35500
|
+
metadata?: ResourceMetadata;
|
|
35501
|
+
readCallback: ReadResourceTemplateCallback;
|
|
35502
|
+
enabled: boolean;
|
|
35503
|
+
enable(): void;
|
|
35504
|
+
disable(): void;
|
|
35505
|
+
update(updates: {
|
|
35506
|
+
name?: string | null;
|
|
35507
|
+
template?: ResourceTemplate;
|
|
35508
|
+
metadata?: ResourceMetadata;
|
|
35509
|
+
callback?: ReadResourceTemplateCallback;
|
|
35510
|
+
enabled?: boolean;
|
|
35511
|
+
}): void;
|
|
35512
|
+
remove(): void;
|
|
35513
|
+
};
|
|
35364
35514
|
type PromptArgsRawShape = {
|
|
35365
35515
|
[k: string]: ZodType<string, ZodTypeDef, string> | ZodOptional<ZodType<string, ZodTypeDef, string>>;
|
|
35366
35516
|
};
|
|
35367
|
-
type PromptCallback<Args extends undefined | PromptArgsRawShape = undefined> = Args extends PromptArgsRawShape ? (args: objectOutputType<Args, ZodTypeAny>, extra: RequestHandlerExtra) => GetPromptResult | Promise<GetPromptResult> : (extra: RequestHandlerExtra) => GetPromptResult | Promise<GetPromptResult>;
|
|
35517
|
+
type PromptCallback<Args extends undefined | PromptArgsRawShape = undefined> = Args extends PromptArgsRawShape ? (args: objectOutputType<Args, ZodTypeAny>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => GetPromptResult | Promise<GetPromptResult> : (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => GetPromptResult | Promise<GetPromptResult>;
|
|
35518
|
+
type RegisteredPrompt = {
|
|
35519
|
+
description?: string;
|
|
35520
|
+
argsSchema?: ZodObject<PromptArgsRawShape>;
|
|
35521
|
+
callback: PromptCallback<undefined | PromptArgsRawShape>;
|
|
35522
|
+
enabled: boolean;
|
|
35523
|
+
enable(): void;
|
|
35524
|
+
disable(): void;
|
|
35525
|
+
update<Args extends PromptArgsRawShape>(updates: {
|
|
35526
|
+
name?: string | null;
|
|
35527
|
+
description?: string;
|
|
35528
|
+
argsSchema?: Args;
|
|
35529
|
+
callback?: PromptCallback<Args>;
|
|
35530
|
+
enabled?: boolean;
|
|
35531
|
+
}): void;
|
|
35532
|
+
remove(): void;
|
|
35533
|
+
};
|
|
35368
35534
|
|
|
35369
35535
|
interface LikeC4MCPServer {
|
|
35370
35536
|
start(port: number): Promise<void>;
|