@kumori/kdsl 0.0.7 → 0.0.8

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.
Files changed (2) hide show
  1. package/out/main.cjs +22 -22
  2. package/package.json +2 -2
package/out/main.cjs CHANGED
@@ -215,7 +215,25 @@ For example, "docker.io/alpine:3"`,{node:f});continue}}}}var Oce=[qr],b$=()=>Oce
215
215
  library
216
216
 
217
217
  func Open(path string, args? struct open[]) string
218
- `;var X$=`package builtin
218
+ `;var X$=`package kumori
219
+
220
+ library
221
+
222
+ alias builtin struct {
223
+ id Ref
224
+ srv Links
225
+ config struct open[]
226
+ resource struct open[Resource]
227
+ }
228
+
229
+ alias Ref struct {
230
+ name string
231
+ kind "service" | "component"
232
+ domain string
233
+ module string
234
+ version string
235
+ }
236
+ `;var eM=`package builtin
219
237
 
220
238
  import "kumori"
221
239
 
@@ -241,25 +259,7 @@ builtin HTTPInbound {
241
259
  serverdomain: kumori.Domain
242
260
  clientcertca?: kumori.CA
243
261
  }
244
- }`;var eM=`package kumori
245
-
246
- library
247
-
248
- alias builtin struct {
249
- id Ref
250
- srv Links
251
- config struct open[]
252
- resource struct open[Resource]
253
- }
254
-
255
- alias Ref struct {
256
- name string
257
- kind "service" | "component"
258
- domain string
259
- module string
260
- version string
261
- }
262
- `;var tM=`package builtin
262
+ }`;var tM=`package builtin
263
263
 
264
264
  import "kumori"
265
265
 
@@ -550,7 +550,7 @@ func JSON(v any) string
550
550
 
551
551
  func Concat(v []string) string
552
552
 
553
- func Join(v []string, sep string) string`;var Gi=[],fM=Gi,xs=(t,e)=>({src:t,data:e});Gi.push(xs("/io/lib.kumori",Z$));Gi.push(xs("/kumori/builtin/httpinbound.h.kumori",X$));Gi.push(xs("/kumori/builtin.kumori",eM));Gi.push(xs("/kumori/builtin/tcpinbound.h.kumori",tM));Gi.push(xs("/kumori/component.kumori",rM));Gi.push(xs("/kumori/deployment.kumori",nM));Gi.push(xs("/kumori/resource.kumori",iM));Gi.push(xs("/kumori/service.kumori",sM));Gi.push(xs("/kumori/shared.kumori",oM));Gi.push(xs("/kumori/sized.kumori",aM));Gi.push(xs("/sized.kumori",cM));Gi.push(xs("/std.kumori",uM));Gi.push(xs("/strconv/lib.kumori",lM));var n_=fM.map(t=>kI(t.src,t.data)),Oue=new Map;for(let t of n_){let e=ee.dirname(t.uri).fsPath.split("/").filter(i=>i!==""),r=Oue,n="";for(let i of e){n=`${n}/${i}`;let s=r.get(i);if(s===void 0&&(s={type:"Dir",contents:new Map},r.set(i,s)),s.type==="File")throw new Error("fs collision on "+n);r=s.contents}r.set(ee.basename(t.uri),{type:"File",data:t.data})}async function J4(t,e,r,n=ye.CancellationToken.None){await dM(t,e,r,n)}async function dM(t,e,r,n=ye.CancellationToken.None){await it(n);let i=await t.readDirectory(e);if(r.Dir){let o=await r.Dir(e,i);if(o!=null&&o.break)return o;if(o!=null&&o.skipDir)return}let s=[];for(let o of i)if(await it(n),o.isDirectory)s.push(o.uri);else if(o.isFile&&r.File){let a=await r.File(o.uri);if(a!=null&&a.break)return a}for(let o of s){await it(n);let a=await dM(t,o,r);if(a!=null&&a.break)return a}}var xr="kumori.mod.json";async function pM(t,e,r=ye.CancellationToken.None){let n=[],i=await Iue(t,De.parse(e.uri),r);for(let s of i){let o=await kr(t,s);N.isOk(o)&&n.push(o.value)}return n}async function Iue(t,e,r=ye.CancellationToken.None){let n=[];return await J4(t,e,{Dir:async i=>{if(e.fsPath===i.fsPath)return;let s=ee.dirname(i);if((await t.readDirectory(s)).map(a=>a.uri).map(ee.basename).includes(xr))return{skipDir:!0}},File:i=>{ee.basename(i)===xr&&n.push(ee.dirname(i))}},r),n}async function wl(t,e){if((await t.readDirectory(e)).map(s=>ee.basename(s.uri)).includes(xr))return Ut(ee.joinPath(e,xr));let i=ee.dirname(e);return e.fsPath===i.fsPath?ot:wl(t,i)}var i_=k.object({target:k.string(),version:k.string()}),mM=i_.extend({headers:k.optional(i_)}),Due=mM.extend({alias:k.optional(k.string())}),Lue=k.object({spec:k.literal("kumori/module/v1"),module:k.string(),kumori:k.string(),version:k.string(),headers:k.optional(i_),cacheLocation:k.optional(k.string().default(".kumori/mod")),requires:k.array(Due),indirect:k.array(mM).optional()}),hM=k.discriminatedUnion("spec",[Lue]);async function Gs(t,e,r=ye.CancellationToken.None){try{await it(r)}catch(o){return oe("error reading module: operation cancelled")}let n=e;if(n.scheme!=="file")return oe(`unexpected URI scheme '${n.scheme}': ${n.toString()}`);ee.basename(n)!==xr&&(n=ee.joinPath(n,xr));let i;try{i=JSON.parse(await t.readFile(n))}catch(o){return oe(`error reading file ${n.fsPath}: ${o}`)}let s=await hM.safeParseAsync(i);return s.success?Le({Root:ee.dirname(n),Manifest:s.data}):oe(`error parsing file ${n.fsPath}: ${JSON.stringify(s.error.format())}`)}function ig(t){return t instanceof De||(t=t.Root),ee.joinPath(t,"vendor")}function Q4(t){if(!(t instanceof De)){let e=t.Manifest,r=t.Root;if(e&&e.cacheLocation){let n=e.cacheLocation;return n.startsWith(".")?ee.joinPath(r,n):n.startsWith("/")?De.parse(n):ee.joinPath(r,n)}t=r}return ee.joinPath(t,".kumori/mod")}var fg=require("fs/promises");var s_=require("crypto"),gM=require("fs"),yM=require("fs/promises"),o_=ke(require("path"),1),vM=require("stream/promises");async function $p(t){let e=[];async function r(i){let s=await(0,yM.readdir)(i,{withFileTypes:!0});for(let o of s){let a=o_.default.join(i,o.name),c=o_.default.relative(i,a).replace(/\\/g,"/");if(o.isDirectory())await r(a);else if(o.isFile()){let u=(0,s_.createHash)("sha256"),f=(0,gM.createReadStream)(a);await(0,vM.pipeline)(f,u),e.push({relativePath:c,hash:u.digest("hex")})}}}await r(t),e.sort((i,s)=>i.relativePath.localeCompare(s.relativePath));let n=(0,s_.createHash)("sha256");for(let i of e)n.update(`${i.relativePath} ${i.hash}
553
+ func Join(v []string, sep string) string`;var Gi=[],fM=Gi,xs=(t,e)=>({src:t,data:e});Gi.push(xs("/io/lib.kumori",Z$));Gi.push(xs("/kumori/builtin.kumori",X$));Gi.push(xs("/kumori/builtin/httpinbound.h.kumori",eM));Gi.push(xs("/kumori/builtin/tcpinbound.h.kumori",tM));Gi.push(xs("/kumori/component.kumori",rM));Gi.push(xs("/kumori/deployment.kumori",nM));Gi.push(xs("/kumori/resource.kumori",iM));Gi.push(xs("/kumori/service.kumori",sM));Gi.push(xs("/kumori/shared.kumori",oM));Gi.push(xs("/kumori/sized.kumori",aM));Gi.push(xs("/sized.kumori",cM));Gi.push(xs("/std.kumori",uM));Gi.push(xs("/strconv/lib.kumori",lM));var n_=fM.map(t=>kI(t.src,t.data)),Oue=new Map;for(let t of n_){let e=ee.dirname(t.uri).fsPath.split("/").filter(i=>i!==""),r=Oue,n="";for(let i of e){n=`${n}/${i}`;let s=r.get(i);if(s===void 0&&(s={type:"Dir",contents:new Map},r.set(i,s)),s.type==="File")throw new Error("fs collision on "+n);r=s.contents}r.set(ee.basename(t.uri),{type:"File",data:t.data})}async function J4(t,e,r,n=ye.CancellationToken.None){await dM(t,e,r,n)}async function dM(t,e,r,n=ye.CancellationToken.None){await it(n);let i=await t.readDirectory(e);if(r.Dir){let o=await r.Dir(e,i);if(o!=null&&o.break)return o;if(o!=null&&o.skipDir)return}let s=[];for(let o of i)if(await it(n),o.isDirectory)s.push(o.uri);else if(o.isFile&&r.File){let a=await r.File(o.uri);if(a!=null&&a.break)return a}for(let o of s){await it(n);let a=await dM(t,o,r);if(a!=null&&a.break)return a}}var xr="kumori.mod.json";async function pM(t,e,r=ye.CancellationToken.None){let n=[],i=await Iue(t,De.parse(e.uri),r);for(let s of i){let o=await kr(t,s);N.isOk(o)&&n.push(o.value)}return n}async function Iue(t,e,r=ye.CancellationToken.None){let n=[];return await J4(t,e,{Dir:async i=>{if(e.fsPath===i.fsPath)return;let s=ee.dirname(i);if((await t.readDirectory(s)).map(a=>a.uri).map(ee.basename).includes(xr))return{skipDir:!0}},File:i=>{ee.basename(i)===xr&&n.push(ee.dirname(i))}},r),n}async function wl(t,e){if((await t.readDirectory(e)).map(s=>ee.basename(s.uri)).includes(xr))return Ut(ee.joinPath(e,xr));let i=ee.dirname(e);return e.fsPath===i.fsPath?ot:wl(t,i)}var i_=k.object({target:k.string(),version:k.string()}),mM=i_.extend({headers:k.optional(i_)}),Due=mM.extend({alias:k.optional(k.string())}),Lue=k.object({spec:k.literal("kumori/module/v1"),module:k.string(),kumori:k.string(),version:k.string(),headers:k.optional(i_),cacheLocation:k.optional(k.string().default(".kumori/mod")),requires:k.array(Due),indirect:k.array(mM).optional()}),hM=k.discriminatedUnion("spec",[Lue]);async function Gs(t,e,r=ye.CancellationToken.None){try{await it(r)}catch(o){return oe("error reading module: operation cancelled")}let n=e;if(n.scheme!=="file")return oe(`unexpected URI scheme '${n.scheme}': ${n.toString()}`);ee.basename(n)!==xr&&(n=ee.joinPath(n,xr));let i;try{i=JSON.parse(await t.readFile(n))}catch(o){return oe(`error reading file ${n.fsPath}: ${o}`)}let s=await hM.safeParseAsync(i);return s.success?Le({Root:ee.dirname(n),Manifest:s.data}):oe(`error parsing file ${n.fsPath}: ${JSON.stringify(s.error.format())}`)}function ig(t){return t instanceof De||(t=t.Root),ee.joinPath(t,"vendor")}function Q4(t){if(!(t instanceof De)){let e=t.Manifest,r=t.Root;if(e&&e.cacheLocation){let n=e.cacheLocation;return n.startsWith(".")?ee.joinPath(r,n):n.startsWith("/")?De.parse(n):ee.joinPath(r,n)}t=r}return ee.joinPath(t,".kumori/mod")}var fg=require("fs/promises");var s_=require("crypto"),gM=require("fs"),yM=require("fs/promises"),o_=ke(require("path"),1),vM=require("stream/promises");async function $p(t){let e=[];async function r(i){let s=await(0,yM.readdir)(i,{withFileTypes:!0});for(let o of s){let a=o_.default.join(i,o.name),c=o_.default.relative(i,a).replace(/\\/g,"/");if(o.isDirectory())await r(a);else if(o.isFile()){let u=(0,s_.createHash)("sha256"),f=(0,gM.createReadStream)(a);await(0,vM.pipeline)(f,u),e.push({relativePath:c,hash:u.digest("hex")})}}}await r(t),e.sort((i,s)=>i.relativePath.localeCompare(s.relativePath));let n=(0,s_.createHash)("sha256");for(let i of e)n.update(`${i.relativePath} ${i.hash}
554
554
  `);return`h1:${n.digest("hex")}`}var wM=ke(TM(),1);var ea=class{get[Symbol.toStringTag](){return"URLSearchParams"}constructor(e){this.isEncoded=!1,this.params=[],typeof e=="string"?a_(e,e[0]==="?"?1:0,e.length,this,[38],61,[],{encode:!0}):Array.isArray(e)?e.forEach(r=>{this.append(r[0],r[1])}):typeof e=="object"&&Object.keys(e).forEach(r=>{this.append(r,e[r])})}*entries(){for(let e=0;e<this.params.length;e+=1)yield[mo(this.params[e][0]),mo(this.params[e][1])]}append(e,r){this.params.push([Y4(e),Y4(r)])}delete(e){this.params=this.params.filter(([r])=>mo(r)!==e)}forEach(e){this.params.forEach(([r,n])=>{e(mo(n),mo(r),this)})}get(e){let r=this.params.find(([n])=>mo(n)===e);return r?mo(r[1]):null}getAll(e){return this.params.filter(([r])=>mo(r)===e).map(r=>r[1])}has(e){return this.get(e)!==null}*keys(){for(let e=0;e<this.params.length;e+=1)yield mo(this.params[e][0])}set(e,r){let n=this.params.findIndex(([i])=>mo(i)===e);if(n===-1){this.append(e,r);return}this.delete(e),this.params.splice(n,0,[Y4(e),Y4(r)])}sort(){this.params=this.params.sort((e,r)=>e[0].localeCompare(r[0]))}toString(){return this.params.map(([e,r])=>`${e}=${r}`).join("&")}*values(){for(let e=0;e<this.params.length;e+=1)yield mo(this.params[e][1])}[Symbol.iterator](){return this.entries()}get size(){return this.params.length}};function a_(t,e,r,n,i,s,o,{encode:a}={encode:!1}){let c=e,u=c,f=0,l=0,p=a?n.append.bind(n):(d,h)=>n.params.push([d,h]);for(;c<=r;c+=1){let d=t.charCodeAt(c);if(d===s&&f===0)f=c,l=c+1;else if(i.indexOf(d)!==-1)c>u&&p(t.slice(u,f||c),t.slice(l||c,c)),u=c+1,f=0,l=0;else if(o.indexOf(d)!==-1)break}return c!==u&&p(t.slice(u,f||c),t.slice(l||c,c)),c}function mo(t){if(t.indexOf("%")!==-1)try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}else return t}function Y4(t){let e=""+t,r="";for(let n=0;n<e.length;n++)e.charCodeAt(n)===32?r+="+":r+=encodeURIComponent(e[n]);return r}var kM=[47,35,63];function nle(t){return t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||t===45||t===43}var Bc=class{constructor(t){this.parse(t)}get protocol(){return this._protocol}get username(){return this._username}get password(){return this._password}get hostname(){return this._hostname}get host(){return this._host}get port(){return this._port}get pathname(){return this._pathname}get search(){return this._search||this._extractParams(),this._search}get searchParams(){return this.isQueryParsed||this._extractSearchParams(),this._query}get parameters(){return this.isQueryParsed||this._extractSearchParams(),this._parameters}hasParameterString(){return this.parameterStartIndex>0}get hash(){return!this._search&&!this._hash&&this._extractParams(),this._hash}get href(){return this._href}toString(){return this.href}toJSON(){return this.href}get domainInfo(){return this._domainInfo||(this._domainInfo=(0,wM.parse)(this.hostname,{extractHostname:!1})),this._domainInfo}get hostIsIp(){return this.domainInfo.isIp}get domain(){return this.domainInfo.hostname||this.hostname}get generalDomain(){return this.domainInfo.domain||this.hostname}get path(){return this.pathname||"/"}get scheme(){return this.protocol.slice(0,-1)}isValidHost(){return this.hostIsIp||this.generalDomain!==null}extractKeyValues(){if(this.parsedParameters)return this.parsedParameters;if(this.parsedParameters=new ea,this.queryStartIndex===0&&this.parameterStartIndex===0)return this.parsedParameters;let t=this.parameterStartIndex||this.queryStartIndex,e=this.href.length-1,r=t;return this.href.charCodeAt(r)===59&&(r=this._extractParamTuples(r+1,e,this.parsedParameters,[59],61,[63,35])),this.href.charCodeAt(r)===63&&(r=this._extractParamTuples(r+1,e,this.parsedParameters,[38,59],61,[35])),this.parsedParameters}_extractHostname(t,e){let r=0,n=!1,i=t,s=!1,o=!1;if(this._href.charCodeAt(i)===91){for(s=!0;i<=e;i+=1)if(this._href.charCodeAt(i)===93){let u=this._href.charCodeAt(i+1);if(u===58)r=i+1,i+=1,n=!0;else if(u===47)i+=1,n=!0;else if(i!==e)throw new TypeError("expected `:` or `/` after IPv6 address");break}}if(!s)for(;i<=e;i+=1){let c=this._href.charCodeAt(i);if(c===58){r=i,n=!0;break}else if(c===64)return this._username=this._href.slice(t,i),this._password="",this._extractHostname(i+1,e);if(kM.indexOf(c)!==-1){n=!0;break}else{if(c<=32)throw new TypeError(`Invalid character '${this.href[i]}' in hostname`);c>=65&&c<=90&&(o=!0)}}let a=n?i:i+1;if(o&&(this._href=`${this._href.slice(0,t)}${this._href.slice(t,a).toLowerCase()}${this._href.slice(a)}`),this._hostname=this._href.slice(t,a),r>0){i+=1;let c=i,u=!1;for(;i<=e;i+=1){let f=this._href.charCodeAt(i);if(kM.indexOf(f)!==-1){this._port=this._href.slice(c,i);break}else{if(f===64)return this._username=this._href.slice(t,r||i),this._password=this._href.slice(r+1,i),this._extractHostname(i+1,e);(f<48||f>57)&&(u=!0)}}if(this._port||(this._port=this.href.slice(c,i)),u)throw new TypeError("Invalid URL: port contains non numeric character");if(this._port.length>=5&&+this._port>65535)throw new TypeError("Invalid URL: invalid port number")}return this._host=this._href.slice(t,n?i:i+1),this.origin=`${this._protocol}//${this._host}`,n?i:i+1}_extractParams(){if(this.queryStartIndex>0){let t=this.queryStartIndex,e=this.href.length-1;if(this.href.charCodeAt(t)===63){let r=!1;for(;t<=e;t+=1)if(this.href.charCodeAt(t)===35){r=!0;break}this._search=this.href.slice(this.queryStartIndex,r?t:e+1),this._search.length===1&&(this._search="")}this.href.charCodeAt(t)===35&&(this._hash=this.href.slice(t,e+1))}}_extractSearchParams(){if(this.isQueryParsed=!0,this.queryStartIndex===0&&this.parameterStartIndex===0)return;let t=this.parameterStartIndex||this.queryStartIndex,e=this.href.length-1,r=t;if(this.href.charCodeAt(r)===59&&(r=this._extractParamTuples(r+1,e,this._parameters,[59],61,[63,35])),this.href.charCodeAt(r)===63){let n=r;r=this._extractParamTuples(r+1,e,this._query,[38],61,[35]),this._search=this.href.slice(n,r),this._search.length===1&&(this._search="")}this.href.charCodeAt(r)===35&&(this._hash=this.href.slice(r,e+1))}_extractParamTuples(t,e,r,n,i,s){return a_(this.href,t,e,r,n,i,s)}parse(t){if(typeof t!="string"||t.length===0)throw new TypeError(`${t} is not a valid URL`);this._protocol="",this._hostname="",this._host="",this._port="",this._pathname="",this._username="",this._password="",this._search="",this._hash="",this.parameterStartIndex=0,this.queryStartIndex=0,this.isQueryParsed=!1,this._parameters=new ea,this._query=new ea,this._domainInfo=null,this.parsedParameters=null;let e=0,r=t.length-1;for(;t.charCodeAt(e)<=32;)e+=1;for(;t.charCodeAt(r)<=32;)r-=1;this._href=t.slice(e,r+1),r=this._href.length-1;let n=!1;for(;e<=r;e+=1){let i=this._href.charCodeAt(e);if(i===58){this._protocol=this._href.slice(0,e+1),n&&(this._protocol=this._protocol.toLowerCase(),this._href=`${this._protocol}${this._href.slice(e+1)}`);break}else if(nle(i))i>=65&&i<=90&&(n=!0);else throw new TypeError("Invalid URL protocol")}if(e>=r)throw new TypeError("No protocol");for(this.slashes="",e+=1;e<r&&this._href.charCodeAt(e)===47;e+=1)this.slashes+="/";if(this.slashes.length>=2?e=this._extractHostname(e,r):(this._host="",this._hostname="",this.origin="null"),e>=r)this._href.charCodeAt(r)!==47&&(this._href+="/"),this._pathname="/";else{let i=e;for(;e<=r;e+=1){let s=this._href.charCodeAt(e);if(s===59&&!this.parameterStartIndex)this.parameterStartIndex=e;else if(s===63||s===35){this.queryStartIndex=e;break}}this._pathname=this.href.slice(i,this.queryStartIndex!==0?this.queryStartIndex:r+1)||"/"}}};var og=class extends ea{constructor(e,r){super(),this.url=e,this.params=r.params}append(e,r){super.append(e,r),this.url.search=this.toString()}delete(e){super.delete(e),this.url.search=this.toString()}set(e,r){super.set(e,r),this.url.search=this.toString()}sort(){super.sort(),this.url.search=this.toString()}};function Hc(t,e){let r={hash:e.hash!==void 0?e.hash:t.hash,host:e.host!==void 0?e.host:t.host,hostname:e.hostname!==void 0?e.hostname:t.hostname,password:e.password!==void 0?e.password:t.password,pathname:e.pathname!==void 0?e.pathname:t.pathname,port:e.port!==void 0?e.port:t.port,protocol:e.protocol!==void 0?e.protocol:t.protocol,search:e.search!==void 0?e.search:t.search,username:e.username!==void 0?e.username:t.username};(e.hostname||e.port)&&((r.protocol==="https:"&&r.port==="443"||r.protocol==="http:"&&r.port==="80")&&(r.port=""),r.host=`${r.hostname}${r.port?":":""}${r.port}`);let n=r.username?r.password?`${r.username}:${r.password}@`:`${r.username}@`:r.password?`:${r.password}@`:"";return new Bc(`${r.protocol}${t.slashes}${n}${r.host}${r.pathname}${r.search}${r.hash}`)}var Bp=class{get[Symbol.toStringTag](){return"URL"}constructor(t){this.url=new Bc(t)}get protocol(){return this.url.protocol}set protocol(t){let e=this.url.protocol,r=t.endsWith(":")?"":":",n=`${t}${r}${this.href.slice(e.length)}`;this.url=new Bc(n)}get username(){return this.url.username}set username(t){this.url=Hc(this,{username:t||""})}get password(){return this.url.password}set password(t){this.url=Hc(this,{password:t||""})}get hostname(){return this.url.hostname}set hostname(t){this.url=Hc(this,{hostname:t||""})}get host(){return this.url.host}set host(t){this.url=Hc(this,{host:t})}get origin(){return this.url.origin}get port(){return this.url.port}set port(t){this.url=Hc(this,{port:t||""})}get pathname(){return this.url.pathname}set pathname(t){let e=t.charCodeAt(0)===47?t:`/${t}`;this.url=Hc(this,{pathname:e})}get search(){return this.url.search}set search(t){let e=t.charCodeAt(0)===63?t.slice(1):t;this.url=Hc(this,{search:e.length>0?`?${e}`:""})}get searchParams(){return new og(this,this.url.searchParams)}get parameters(){return this.url.parameters}hasParameterString(){return this.url.hasParameterString()}get hash(){return this.url.hash}set hash(t){let e=t.charCodeAt(0)===35?t.slice(1):t;this.url=Hc(this,{hash:e.length>0?`#${e}`:""})}get href(){return this.url.href}set href(t){this.url=new Bc(t)}toString(){return this.href}toJSON(){return this.href}get domainInfo(){return this.url.domainInfo}get hostIsIp(){return this.url.hostIsIp}get domain(){return this.url.domain}get generalDomain(){return this.url.generalDomain}get path(){return this.url.path}get scheme(){return this.url.scheme}get slashes(){return this.url.slashes}isValidHost(){return this.url.isValidHost()}extractKeyValues(){return this.url.extractKeyValues()}};var Ba=class extends Bp{};var Ha=ke(require("fs"),1),cg=ke(require("path"),1),D_=ke(require("os"),1),RV=ke(I_(),1);var AV={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://kumori.systems/kdsl/registry-index.schema.json",title:"KDSL Registry Module Index",description:"Defines the structure of the index.json file hosted in a registry repository.",type:"object",required:["modules"],properties:{modules:{type:"array",minItems:1,uniqueItems:!0,description:"List of modules available in this registry index",items:{type:"object",required:["name","version","repository","checksum"],properties:{name:{type:"string",pattern:"^[a-zA-Z0-9._-]+$",description:"Name of the module"},version:{type:"string",description:"Semantic version of the module"},description:{type:"string",description:"Optional human-readable module description"},location:{type:"string",format:"uri",description:"Location (URL) where the module resides"},checksum:{type:"string",pattern:"^[a-fA-F0-9]{64}$",description:"SHA-256 checksum of the module package"},icon:{type:"string",format:"uri",description:"Optional URL to an icon for this module"}},additionalProperties:!1}}},additionalProperties:!1};var go=class{constructor(){this.registries=[];this.defaultName="kumori.systems";let e=cg.default.join(D_.default.homedir(),".config","kdsl");try{Ha.default.existsSync(e)||Ha.default.mkdirSync(e,{recursive:!0})}catch(r){throw new Error(`Failed to create config directory: ${r}`)}this.filePath=cg.default.join(e,"registries.json"),this.load()}initialize(){this.registries=[{selector:this.defaultName,indexUrl:"https://github.com/jrovira-kumori"}],this.save()}load(){if(Ha.default.existsSync(this.filePath))try{let e=Ha.default.readFileSync(this.filePath,"utf-8"),r=JSON.parse(e);if(!Array.isArray(r.registries))throw new Error("Malformed registry file: 'registries' is not an array");this.registries=r.registries}catch(e){console.warn(`Failed to load registries: ${e}. Reinitializing.`),this.initialize()}else this.initialize()}save(){let e=`${this.filePath}.tmp`;try{Ha.default.writeFileSync(e,JSON.stringify({registries:this.registries},null,2),{encoding:"utf-8"}),Ha.default.renameSync(e,this.filePath)}catch(r){throw new Error(`Failed to save registries: ${r}`)}}list(){return this.registries}async add(e){if(!e.selector||typeof e.selector!="string")throw new Error("Registry must have a valid 'selector'");if(this.registries.some(c=>c.selector===e.selector))throw new Error(`Registry with selector '${e.selector}' already exists`);let r=cg.default.join(D_.default.homedir(),".config","kdsl",".cache",e.selector),n=cg.default.join(r,"index.json");Ha.default.mkdirSync(r,{recursive:!0});let i=`${e.indexUrl}/index.json`,s=await fetch(i);if(!s.ok)throw new Error(`Failed to download index from ${i}: ${s.statusText}`);let o=await s.json();if(!this.validateIndexSchema(o))throw new Error(`Index schema validation failed for ${i}`);Ha.default.writeFileSync(n,JSON.stringify(o,null,2),{encoding:"utf-8"}),this.registries.push(e),this.save()}remove(e){if(e===this.defaultName)throw new Error(`Cannot remove default registry '${this.defaultName}'`);let r=this.registries.length;if(this.registries=this.registries.filter(n=>n.selector!==e),this.registries.length===r)throw new Error(`Registry '${e}' not found`);this.save()}validateIndexSchema(e){let n=new RV.default({validateSchema:!1,allErrors:!0}).compile(AV);return n(e)?!0:(console.warn("Index schema valiVdation errors:",n.errors),!1)}};var ug=ke(require("path"),1),$_=ke(require("os"),1),lg=ke(require("fs"),1),L_;(r=>(r.toString=n=>{let i=`${n.Scheme}://${n.Location}`;return ue.isSome(n.Major)&&(i=`${i}#${n.Major.value}`),ue.isSome(n.Version)&&(i=`${i}@${n.Version.value}`),i},r.toURL=n=>new Ba(`${n.Scheme}://${n.Location}`)))(L_||(L_={}));function Js(t){var u;let e=[t],r="git";if(e=e.pop().split("://"),e.length>2)return ot;e.length===2&&(r=e.shift());let n=ot;if(e=e.pop().split("@"),e.length>2)return ot;e.length===2&&(n=Ut(e.pop()));let i=ot;if(e=e.pop().split("#"),e.length>2)return ot;e.length===2&&(i=Ut(e.pop()));let s=e.pop(),c=new go().list().find(f=>s.startsWith(f.selector));if(c!==void 0){let f=ug.default.join($_.default.homedir(),".config","kdsl",".cache",c.selector),l=ug.default.join(f,"index.json");if(!lg.default.existsSync(l))return console.warn(`Index not found in cache: ${l}`),ot;let p=lg.default.readFileSync(l,{encoding:"utf-8"}),h=JSON.parse(p).modules.find(T=>c.selector+"/"+T.name==s);if(h===void 0)return console.warn(`Module not found in registry index: ${s} (registry: ${c.selector})`),ot;if(ue.isSome(n)&&h.version!==n.value)return console.warn(`Module version not found in registry index: ${s} (requested: ${n.value}, available: ${h.version})`),ot;let g=s.substring(h.location.length),b=((u=h.location.split("://")[1])!=null?u:h.location).replace(/\/+$/,""),_=g.startsWith("/")?g:`/${g}`;s=`${b}${_}`}return Ut({Location:s,Scheme:r,Major:i,Version:n,toString(){return L_.toString(this)}})}function PV(t){let n=new go().list().find(i=>t.startsWith(i.selector));if(n!==void 0){let i=ug.default.join($_.default.homedir(),".config","kdsl",".cache",n.selector),s=ug.default.join(i,"index.json");if(!lg.default.existsSync(s))return console.warn(`Index not found in cache: ${s}`),ot;let o=lg.default.readFileSync(s,{encoding:"utf-8"}),c=JSON.parse(o).modules.find(u=>n.selector+"/"+u.name==t);return c===void 0?(console.warn(`Module not found in registry index: ${t} (registry: ${n.selector})`),ot):Ut(c.checksum)}return ot}var Mfe=k.object({indirect:k.optional(k.boolean()),sum:k.string()}),Ffe=k.object({spec:k.literal("kumori/sumdb/v1"),content:k.record(Mfe)}),za;(c=>(c.Type=k.discriminatedUnion("spec",[Ffe]),c.Parse=c.Type.safeParseAsync,c.Retrieve=Vfe,c.Register=jfe,c.New=()=>({spec:"kumori/sumdb/v1",content:{}}),c.Open=Ufe,c.Read=qfe,c.Write=IV))(za||(za={}));var NV=(t,e)=>{let r=`${t}@v${e}`,n=Js(r);return N.isOk(n)?n.value.toString():r};function Vfe(t,e,r){var n;switch(t.spec){case"kumori/sumdb/v1":return ue.fromNullable((n=t.content[NV(e,r)])==null?void 0:n.sum)}}async function jfe(t,e,r,n,i){switch(t.spec){case"kumori/sumdb/v1":{let s=await $p(e.fsPath);t.content[NV(n,i)]={sum:s};break}}return IV(r.Locations.Checksum(),t)}var M_=t=>ee.joinPath(t.Root,"kumori.sum.json");async function Ufe(t){let e;try{e=(await(0,fg.readFile)(t.fsPath)).toString("utf-8")}catch(r){return Le(za.New())}return N.mapErr(await OV(e),r=>`error parsing sumdb '${t.fsPath}': ${r}`)}async function qfe(t){let e;try{e=(await(0,fg.readFile)(t.fsPath)).toString("utf-8")}catch(r){return oe(`unable to open sumdb: error reading file '${t.fsPath}'`)}return N.mapErr(await OV(e),r=>`error parsing sumdb '${t.fsPath}': ${r}`)}async function OV(t){let e;try{e=JSON.parse(t)}catch(n){return oe("invalid json data")}let r=await za.Parse(e);if(!r.success){let n,i=Bfe(r.error);return i.length===0?n="<unknown error>":n=`
555
555
  `+i.join(`
556
556
  `),oe(n)}return Le(r.data)}async function IV(t,e){let r;try{r=JSON.stringify(e,void 0,4)}catch(n){return oe("unable to serialize sumdb")}try{await(0,fg.writeFile)(t.fsPath,r)}catch(n){return oe(`error writing to sumdb: error writing file '${t.fsPath}': `+n)}return Le(void 0)}function Bfe(t){return DV("",t.format()).map(([r,n])=>r===""?n:`- [${r}]: ${n}`)}function DV(t,e){let r=[];"_errors"in e&&Array.isArray(e._errors)&&e._errors.every(n=>typeof n=="string")&&(r=r.concat(e._errors.map(n=>[t,n])));for(let[n,i]of Object.entries(e))n!=="_errors"&&(typeof i!="object"||i===null||(r=r.concat(DV(`${t}.${n}`,i))));return r}async function kr(t,e){let r=await wl(t,e);if(N.isErr(r))return oe(`not a module: unable to find ${xr}`);let n=await Gs(t,r.value);if(N.isErr(n))return n;let i=n.value;return Le({Current:i,Root:i,Locations:{Cache:Fs(()=>Q4(i)),Vendor:Fs(()=>ig(i)),Checksum:Fs(()=>M_(i))}})}(e=>{async function t(r,n,i){let s=await e(n,i);if(N.isErr(s))return oe(`move context: ${i.fsPath}: no module in location`);if(s.value.Current.Root.fsPath===r.Current.Root.fsPath)return oe(`move context: ${i.fsPath}: module not moved`);let o=s.value.Current;return Le(Y(C({},r),{Current:o,Locations:Y(C({},r.Locations),{Vendor:Fs(()=>ig(o)),Checksum:Fs(()=>M_(o))})}))}e.Move=t})(kr||(kr={}));var LV=ke(require("assert"),1),$V=require("path");async function yv(t,e,r=ye.CancellationToken.None){let n=t.svcs.workspace.FileSystemProvider,i=await kr(n,e.Root);return(0,LV.default)(N.isOk(i)),await MV(Y(C({},t),{mod:i.value}),r),Array.from(t.cache.values()).filter(ue.isSome).map(s=>s.value)}async function MV(t,e=ye.CancellationToken.None){let r=t.mod.Current;if(r.Manifest.headers!==void 0){let n=r.Manifest.headers;await it(e),await F_(t,n.target,n.version,e)}for(let n of r.Manifest.requires)if(await it(e),await F_(t,n.target,n.version,e),n.headers!==void 0){let i=n.headers;await it(e),await F_(t,i.target,i.version,e)}}async function F_(t,e,r,n=ye.CancellationToken.None){let i=t.svcs.workspace.FileSystemProvider,s=Ln(e,r);if(t.cache.get(s)!==void 0)return;t.cache.set(s,ot);let a=await Hfe(t,e,r);if(N.isErr(a))return;let c=await kr.Move(t.mod,i,a.value);N.isErr(c)||(t.cache.set(s,Le(c.value.Current)),t=Y(C({},t),{mod:c.value}),await MV(t,n))}async function Hfe(t,e,r){let n=t.svcs.workspace.FileSystemProvider,i=Ln(e,r);if((0,$V.isAbsolute)(e)){let a=De.file(e),c=await N.tryCatchAsync(async()=>await n.readDirectory(a));if(N.isOk(c))return Ut(a)}let s=ee.joinPath(t.mod.Locations.Vendor(),i),o=await N.tryCatchAsync(async()=>await n.readDirectory(s));return N.isOk(o)?Ut(s):(s=ee.joinPath(t.mod.Locations.Cache(),i),o=await N.tryCatchAsync(async()=>await n.readDirectory(s)),N.isOk(o)?Ut(s):ot)}async function Hp(t,e,r=ye.CancellationToken.None){await it(r);let n=[],i=t.ServiceRegistry.all.flatMap(a=>a.LanguageMetaData.fileExtensions),s=ig(e).fsPath,o=Q4(e).fsPath;return await J4(t.workspace.FileSystemProvider,e,{Dir:a=>({skipDir:[s,o].includes(a.fsPath)}),File:a=>{let c=ee.extname(a);i.includes(c)&&n.push(a)}},r),n}var vv=class{constructor(e){this.svcs=e;this.initialBuildOptions={};this.folders=[];this.mutex=new Mu;this._ready=new qn}get ready(){return this._ready.promise}get workspaceFolders(){return this.folders}initialize(e){var r;this.folders=(r=e.workspaceFolders)!=null?r:this.folders}initialized(e){return this.mutex.write(r=>this.initializeWorkspace(this.folders,r))}async initializeWorkspace(e,r=ye.CancellationToken.None){e=e.map(zfe);let n=this.svcs.workspace.LangiumDocuments,i=u=>{n.hasDocument(u.uri)||n.addDocument(u)};this.loadStdlib(i);let s=this.svcs.references.KumoriModules.ResolverCtx(),o=this.svcs.workspace.FileSystemProvider,a=(await Promise.all(e.map(async u=>{let f=await pM(o,u,r),l=(await Promise.all(f.map(d=>Gs(o,d.Current.Root)))).filter(N.isOk).map(d=>d.value);return(await Promise.all(l.map(d=>yv(s,d,r)))).flat().concat(l)}))).flat();await Promise.all(a.map(async u=>{let f=await Hp(this.svcs,u.Root),l=Y(C({},u),{Docs:f});await this.svcs.references.KumoriModules.registerModule(l),await this.loadModule(l,i)})),this._ready.resolve(),await it(r);let c=this.svcs.workspace.LangiumDocuments.all.toArray();await this.svcs.workspace.DocumentBuilder.build(c,this.initialBuildOptions,r)}loadStdlib(e){let r=this.svcs.workspace.LangiumDocumentFactory;for(let n of n_)e(r.fromString(n.data,n.uri))}async loadModule(e,r){let n=this.svcs.workspace.LangiumDocumentFactory;for(let i of e.Docs)r(await n.fromUri(i))}};function zfe(t){let e=qy(De.parse(t.uri));return Y(C({},t),{uri:e.toString()})}var FV=ke(Ui(),1);var xv=class extends lp{constructor(r){super(r);this.svcs=r}registerFileWatcher(r){let n=nt(r.ServiceRegistry.all).flatMap(o=>o.LanguageMetaData.fileExtensions).map(o=>o.startsWith(".")?o.substring(1):o).distinct().toArray(),i={watchers:[]};n.length>0&&i.watchers.push({globPattern:n.length===1?`**/*.${n[0]}`:`**/*.{${n.join(",")}}`}),n.includes("kumori")&&i.watchers.push({globPattern:`**/${xr}`});let s=r.lsp.Connection;s==null||s.client.register(FV.DidChangeWatchedFilesNotification.type,i)}fireDocumentUpdate(r,n){(async()=>{let i=this.svcs.references.KumoriModules,s=[...r,...n].filter(c=>ee.basename(c)===xr);if(s.length){let c=i.ResolverCtx(),u=this.svcs.workspace.FileSystemProvider,f=(await Promise.all(s.map(async l=>{let p=await Gs(u,l);return N.isErr(p)?[]:(await yv(c,p.value)).concat(p.value)}))).flat();await Promise.all(f.map(async l=>{let p=await Hp(this.svcs,l.Root),d=Y(C({},l),{Docs:p});await i.registerModule(d)}))}for(let c of s)i.invalidateModule(c);let o=r.filter(c=>ee.basename(c)!==xr),a=n.filter(c=>ee.basename(c)!==xr);super.fireDocumentUpdate(o,a)})()}};var Wfe={workspace:{WorkspaceManager:t=>new vv(t),IndexManager:t=>new jy(t),DocumentBuilder:t=>new Fy(t)},references:{KumoriModules:t=>new By(t)},lsp:{DocumentUpdateHandler:t=>new xv(t)}},Kfe={references:{ScopeComputation:t=>new zy(t),ScopeProvider:t=>new Wy(t),Linker:t=>new Uy(t),KumoriPackages:t=>new Hy(t)},validation:{KumoriValidations:t=>Y$(t),KumoriTypeSystem:t=>new H4(t),DocumentValidator:t=>new Vy(t)},lsp:{SemanticTokenProvider:t=>new Gy(t)}};function Ji(t){let e=Fu(_I(t),SI,Wfe),r=Fu(xI({shared:e}),EI,Kfe);return e.ServiceRegistry.register(r),Q$(r),t.connection||e.workspace.ConfigurationProvider.initialized({}),{shared:e,Kumori:r}}var V_=ke(require("fs"),1),j_=class{constructor(){this.encoding="utf-8"}readFile(e){return V_.promises.readFile(e.fsPath,this.encoding)}async readDirectory(e){return(await V_.promises.readdir(e.fsPath,{withFileTypes:!0})).map(n=>({dirent:n,isFile:n.isFile(),isDirectory:n.isDirectory(),uri:ee.joinPath(e,n.name)}))}},wn={fileSystemProvider:()=>new j_};var VV=k.object({name:k.string(),artifact:k.union([r_,K4,G4]),resilience:k.number().nonnegative().optional(),config:k.object({}).catchall(k.any()).optional(),resource:k.object({}).catchall(ja).optional(),meta:k.object({}).catchall(k.any()).optional()});var jV={m:.001,k:1e3,M:1e6,G:1e9,T:1e12,P:1e15,E:1e18,Ki:2**10,Mi:2**20,Gi:2**30,Ti:2**40,Pi:2**50,Ei:2**60},UV=(t,e)=>{let r=jV[t.unit],n=jV[e];return{size:t.size*(r/n),unit:e}};function ta(t){if(t.$type===Fx){let e=Vx.parse(t);return{volume:{size:e.value.size,unit:e.value.unit,kind:"storage"}}}if(t.$type===jx)return{volume:Ux.parse(t).value};if(t.$type===Gx)return{volume:Jx.parse(t).value};if(t.$type===qx){let e=Bx.parse(t);return{volume:{size:e.value.size,unit:e.value.unit,kind:"storage",type:"volatile"}}}if(t.$type===Hx){let e=zx.parse(t);return{volume:{size:e.value.size,unit:e.value.unit,kind:"storage",type:"persistent"}}}if(t.$type===Wx){let e=Kx.parse(t);return{volume:{size:e.value.size,unit:e.value.unit,kind:"storage",type:"nonreplicated"}}}if(t.$type===eg)return{ca:Qx.parse(t).value};if(t.$type===tg)return{certificate:Yx.parse(t).value};if(t.$type===Op)return{secret:Zx.parse(t).value};if(t.$type===rg)return{domain:Xx.parse(t).value};if(t.$type===ng)return{port:e_.parse(t).value};throw new Error(`unknown resource type '${t.$type}'`)}var qV=require("path");function BV(t){return typeof t=="string"?N.orElse(N.map(W4(t),e=>{var r,n;return{tag:e.tag,hub:{name:e.hub,secret:typeof t=="string"?"":(n=(r=t.hub)==null?void 0:r.secret)!=null?n:""}}}),e=>{throw new Error(e)}):t}function Nl(t,e){if(!e)return[];let r=Fe.getDocument(e).uri,n=t.getModule(r);if(N.isErr(n))return[];let i=N.tryCatch(()=>new URL(`file://${n.value.Manifest.module}`));if(N.isErr(i))return[];let s=[];return i.value.hostname.length&&s.push(o=>o.domain=i.value.hostname),i.value.pathname.length&&s.push(o=>{o.module=i.value.pathname.replace(/^\//,""),o.name=(0,qV.basename)(o.module)}),s}function HV(t,e){let r={version:[0,0,0],kind:"service",domain:"unknown",module:"unknown",name:"unknown"},n=t.svcs.shared.references.KumoriModules,i=Nl(n,t.nodes.get(e));for(let s of i)s(r);return{spec:[1,0],ref:r,description:{builtin:!1,connector:{},config:{resilience:0,scale:{},parameter:{},resource:{}},role:{component:{name:"component",meta:{},artifact:U_(t,e)}}}}}function U_(t,e){var u,f,l,p,d,h,g,v,b,_,x;let r={version:[0,0,0],kind:"component",domain:"unknown",module:"unknown",name:"unknown"},n=t.svcs.shared.references.KumoriModules,i=Nl(n,t.nodes.get(e));for(let T of i)T(r);function s(T,R=!1){return Object.fromEntries(Object.entries(T!=null?T:{}).map(([V,$])=>{var z,W;return[V,{name:V,init:R,entrypoint:$.entrypoint,image:BV($.image),cmd:$.cmd,size:{memory:Y(C({},$.size.memory),{kind:"ram"}),cpu:Y(C({},$.size.cpu),{kind:"cpu"}),mincpu:$.size.mincpu?$.size.mincpu.size:$.size.cpu.size},mapping:{filesystem:Object.fromEntries(Object.entries((z=$.fs)!=null?z:{}).map(([D,P])=>[D,Gfe(D,P)])),env:Object.fromEntries(Object.entries((W=$.env)!=null?W:{}).map(([D,P])=>{let M=D,j=typeof P=="string"||typeof P=="number"||typeof P=="boolean"?{value:String(P)}:P;return[M,j]}))}}]}))}let o=Object.fromEntries(((u=e.init)!=null?u:[]).map((T,R)=>[`INIT_${R}`,T])),a=s(e.code),c=s(o,!0);return{spec:[1,0],ref:r,description:{builtin:!1,config:{resilience:0,scale:{hsize:(f=e.scale)!=null?f:1},parameter:e.config,resource:Object.fromEntries(Object.entries((l=e.resource)!=null?l:{}).map(([T,R])=>[T,ta(R)]))},size:{bandwidth:Y(C({},e.size.bandwidth),{kind:"bandwidth"}),minbandwidth:Math.ceil(UV((p=e.size.minbandwidth)!=null?p:e.size.bandwidth,e.size.bandwidth.unit).size),mincpu:Y(C({},e.size.mincpu),{kind:"cpu"})},profile:{threadability:"*",iopsintensive:!1},srv:{client:Object.fromEntries(Object.entries((h=(d=e.srv)==null?void 0:d.client)!=null?h:{}).map(([T,R])=>[T,{protocol:R,inherited:!1}])),server:Object.fromEntries(Object.entries((v=(g=e.srv)==null?void 0:g.server)!=null?v:{}).map(([T,R])=>{let V;return typeof R=="string"?V={port:80,portnum:1,inherited:!1,protocol:R}:V=Y(C({},R),{portnum:1,inherited:!1}),[T,V]})),duplex:Object.fromEntries(Object.entries((_=(b=e.srv)==null?void 0:b.duplex)!=null?_:{}).map(([T,R])=>{let V;return typeof R=="string"?V={port:80,portnum:1,inherited:!1,protocol:R}:V=Y(C({},R),{portnum:1,inherited:!1}),[T,V]}))},code:C(C({},c),a),probe:Object.fromEntries(Object.entries((x=e.probe)!=null?x:{}).map(([T,R])=>[T,R]))}}}function Gfe(t,e){var r,n,i,s;if(typeof e=="string")return{path:t,data:{value:e},format:"text"};if(typeof e=="object"){if("volume"in e)return{path:t,volume:e.volume};if("data"in e)return{path:t,data:{value:e.data},format:(r=e.format)!=null?r:"text",mode:(n=e.mode)!=null?n:420};let a=["secret","port","domain","certificate","ca"].find(c=>c in e);if(a){let c=a;return{path:t,data:{[c]:e[c]},format:(i=e.format)!=null?i:"text",mode:(s=e.mode)!=null?s:420}}}throw new Error(`Unknown key '${t}': ${JSON.stringify(e)}`)}function Jfe(t){var r,n,i;let e=Ci(t.id.version);return{spec:[1,0],ref:{version:[e.major,e.minor,e.patch],kind:t.id.kind,domain:t.id.domain,module:t.id.module,name:t.id.name},description:{builtin:!0,srv:{client:Object.fromEntries(Object.entries((r=t.srv.client)!=null?r:{}).map(([s])=>[s,{protocol:"http",inherited:!1}])),server:Object.fromEntries(Object.entries((n=t.srv.server)!=null?n:{}).map(([s,o])=>{let a;return typeof o=="string"?a={port:80,portnum:1,inherited:!1,protocol:o}:a=Y(C({},o),{inherited:!1}),[s,a]})),duplex:Object.fromEntries(Object.entries((i=t.srv.duplex)!=null?i:{}).map(([s,o])=>{let a;return typeof o=="string"?a={port:80,portnum:1,inherited:!1,protocol:o}:a=Y(C({},o),{inherited:!1}),[s,a]}))},config:{resilience:0,scale:{},parameter:t.config,resource:Object.fromEntries(Object.entries(t.resource).map(([s,o])=>[s,ta(o)]))},connector:{},role:{}}}}function zV(t,e){var r,n;return{name:Ol(t),up:zp(t),meta:{},config:{resilience:0,scale:{},parameter:(r=e.config)!=null?r:{},resource:Object.fromEntries(Object.entries((n=e.resource)!=null?n:{}).map(([i,s])=>[i,ta(s)]))},artifact:Jfe(e)}}function _v(t,e,r,n){let i=t.svcs.shared.references.KumoriModules,s=Nl(i,t.nodes.get(e));for(let o of s)o(r);return n&&(r.kind="service"),r}function q_(t,e){return t.some(r=>JSON.stringify(r)===JSON.stringify(e))}function B_(t,e){return{role:t,channel:e}}function bv(t,e,r){return{meta:t,links:[{role:e,channel:r}]}}function WV(t,e,r){var i,s,o,a;let n={version:[0,0,0],kind:"component",domain:"unknown",module:"unknown",name:"unknown"};if(r.$type===Dp){r=r;let c=[],u=[];if("from"in r.value&&Array.isArray(r.value.from)&&"to"in r.value&&Array.isArray(r.value.to))for(let f of r.value.from){u.push(B_(f.target,f.channel));for(let l of r.value.to){let p=e.role[l.target=="self"?f.target:l.target],d=Wa(p.artifact)||l.target=="self";_v(t,p,n,d);let h=(i=r.value.meta)!=null?i:[{auto:{channel:l.target!=="self"?l.target+"."+l.channel:l.channel,compRef:n,roleName:l.target=="self"?f.target:l.target},user:{}}],g=bv(h,l.target,l.channel);q_(c,g)||c.push(g)}}else if("from"in r.value&&!Array.isArray(r.value.from)&&!Array.isArray(r.value.to)){let f=r.value.from,l=r.value.to;u.push(B_(f.target,f.channel));let p=e.role[l.target=="self"?f.target:l.target],d=Wa(p.artifact)||l.target=="self";_v(t,p,n,d);let h=(s=r.value.meta)!=null?s:[{auto:{channel:l.target!=="self"?l.target+"."+l.channel:l.channel,compRef:n,roleName:l.target=="self"?f.target:l.target},user:{}}],g=bv(h,l.target,l.channel);q_(c,g)||c.push(g)}return{kind:"lb",clients:u,servers:c}}if(r.$type===Lp){r=r;let c=[],u=[];if("from"in r.value&&Array.isArray(r.value.from)&&"to"in r.value&&Array.isArray(r.value.to))for(let f of r.value.from){u.push(B_(f.target,f.channel));for(let l of r.value.to){let p=e.role[l.target=="self"?f.target:l.target],d=Wa(p.artifact);_v(t,p,n,d);let h=(o=r.value.meta)!=null?o:[{auto:{channel:l.target!=="self"?l.target+"."+l.channel:l.channel,compRef:n,roleName:l.target=="self"?f.target:l.target},user:{}}],g=bv(h,l.target,l.channel);q_(c,g)||c.push(g)}}else if("target"in r.value&&"channel"in r.value){let f=e.role[r.value.target],l=Wa(f.artifact);_v(t,f,n,l);let p=(a=r.value.meta)!=null?a:[{auto:{channel:r.value.channel,compRef:n,roleName:r.value.target},user:{}}];c.push(bv(p,r.value.target,r.value.channel))}return{kind:"full",clients:u,servers:c}}throw new Error(`unknown connection type '${r.$type}'`)}function H_(t,e){var o,a,c,u,f,l,p,d,h,g,v;let r={version:[0,0,0],kind:"service",domain:"unknown",module:"unknown",name:"unknown"},n=t.svcs.shared.references.KumoriModules,i=Nl(n,t.nodes.get(e));for(let b of i)b(r);let s={spec:[1,0],ref:r,description:{builtin:!1,config:{resilience:0,scale:{detail:Object.fromEntries(Object.entries((o=e.role)!=null?o:{}).filter(([,b])=>Gc(b.artifact)).map(([b,_])=>{var x;return Gc(_.artifact)?[b,{hsize:(x=_.artifact.scale)!=null?x:1}]:[b,{hsize:1}]}))},parameter:(a=e==null?void 0:e.config)!=null?a:{},resource:Object.fromEntries(Object.entries((c=e.resource)!=null?c:{}).map(([b,_])=>[b,ta(_)]))},role:{},connector:Object.fromEntries(Object.entries((u=e.connect)!=null?u:{}).map(([b,_])=>[b,WV(t,e,_)])),srv:{client:Object.fromEntries(Object.entries((l=(f=e.srv)==null?void 0:f.client)!=null?l:{}).map(([b,_])=>[b,{protocol:_,inherited:!1}])),server:Object.fromEntries(Object.entries((d=(p=e.srv)==null?void 0:p.server)!=null?d:{}).map(([b,_])=>{let x;return typeof _=="string"?x={port:80,inherited:!1,protocol:_}:x=Y(C({},_),{inherited:!1}),[b,x]})),duplex:Object.fromEntries(Object.entries((g=(h=e.srv)==null?void 0:h.duplex)!=null?g:{}).map(([b,_])=>{let x;return typeof _=="string"?x={port:80,inherited:!1,protocol:_}:x=Y(C({},_),{inherited:!1}),[b,x]}))}}};return s.description.role=Object.fromEntries(Object.entries((v=e.role)!=null?v:{}).map(([b,_])=>[b,Yfe(t,b,_,s)]).filter(([,b])=>ue.isSome(b)).map(([b,_])=>[b,_.value])),s}function Qfe(t,e){var r,n,i,s,o,a,c;return{name:Ol(t),up:zp(t),meta:{},config:{resilience:0,scale:(i=(r=e.config)==null?void 0:r.scale)!=null?i:{hsize:(n=e.config)==null?void 0:n.scale},parameter:(o=(s=e.config)==null?void 0:s.parameter)!=null?o:{},resource:Object.fromEntries(Object.entries((c=(a=e.config)==null?void 0:a.resource)!=null?c:{}).map(([u,f])=>[u,ta(f)]))},artifact:H_(t,e)}}function Yfe(t,e,r,n){var o,a,c,u,f,l,p,d,h,g,v,b,_,x,T,R,V,$;if(Gc(r.artifact))return Ut({name:e,meta:r.meta,config:{resilience:0,scale:r.artifact.scale?{hsize:r.artifact.scale}:{hsize:1},parameter:(o=r.artifact.config)!=null?o:{},resource:{}},artifact:U_(t,r.artifact)});let i=r.artifact;t=KV(t,e),GV(t,Wa(i)?Qfe(t,i):zV(t,i)),(c=(a=n.description).srv)!=null||(a.srv={}),(f=(u=n.description.srv).server)!=null||(u.server={}),(p=(l=n.description.srv).client)!=null||(l.client={});for(let[,K]of Object.entries((d=n.description.connector)!=null?d:{})){for(let z of K.clients){if(z.role!==e)continue;let W=C({},z),D=`${z.role}.${z.channel}`,P=((g=(h=i==null?void 0:i.srv)==null?void 0:h.client)!=null?g:{})[z.channel];n.description.srv.server[D]={inherited:!0,protocol:z.channel=="inbound"?"http":P},z.role="self",z.channel=D,(b=(v=t.root).links)!=null||(v.links=[]),t.root.links.push({meta:{},s_d:Ol(t),s_c:W.channel,t_d:zp(t),t_c:D})}for(let z of K.servers)for(let W of z.links)if(W.role===e){let D=`${W.role}.${W.channel}`,P=((x=(_=i==null?void 0:i.srv)==null?void 0:_.server)!=null?x:{})[W.channel];P===void 0&&(P=((R=(T=i==null?void 0:i.srv)==null?void 0:T.duplex)!=null?R:{})[W.channel]),n.description.srv.client[D]={inherited:!0,protocol:typeof P=="string"?P:P.protocol,port:typeof P=="object"?P.port:void 0},($=(V=t.root).links)!=null||(V.links=[]),t.root.links.push({meta:{},s_d:zp(t),s_c:D,t_d:Ol(t),t_c:W.channel}),W.role="self",W.channel=D}}return ot}var Ol=t=>t.path.join("."),zp=t=>t.path.slice(0,-1).join("."),KV=(t,e)=>Y(C({},t),{path:[...t.path,e]}),GV=(t,e)=>t.root.deployments[Ol(t)]=e;function JV(t,e,r){var s,o,a;let n={top:r.name,deployments:{},links:[]},i={svcs:t,path:[r.name],root:n,nodes:e};return n.deployments[r.name]={name:r.name,meta:r.meta,config:{parameter:(s=r.config)!=null?s:{},resource:Object.fromEntries(Object.entries((o=r.resource)!=null?o:{}).map(([c,u])=>[c,ta(u)])),resilience:(a=r.resilience)!=null?a:0,scale:{detail:(()=>{var c;return Object.fromEntries(Object.entries(Wa(r.artifact)?(c=r.artifact.role)!=null?c:{}:{}).filter(([,u])=>Gc(u.artifact)).map(([u,f])=>{var l;return Gc(f.artifact)?[u,{hsize:(l=f.artifact.scale)!=null?l:1}]:[u,{hsize:1}]}))})()}},artifact:(()=>{if(Gc(r.artifact))return HV(i,r.artifact);if(Wa(r.artifact))return H_(i,r.artifact);throw QV(r.artifact)?new Error("not implemented: handle builtin"):new Error("unknown artifact")})()},n}function Gc(t){return"size"in t}function Wa(t){return!(Gc(t)||QV(t))}function QV(t){return"id"in t}function YV(t,e,r){var u,f;let n=e.validation.KumoriTypeSystem,[{Value:i},s]=n.Eval(e.validation.KumoriValidations.ctx(),r);if(s.length!==0){for(let l of s){let p=l.node,d=Fe.getDocument(p),h=((u=p.$cstNode)==null?void 0:u.range.start)||{line:0,character:0};t.error(`${d.uri.fsPath}:${h.line}:${h.character}: type error: ${l.message}`)}process.exit(1)}let o=new Map,a=Qo({svcs:e,nodes:o},i);if(N.isErr(a)){for(let l of a.err){let p=l.node,d=Fe.getDocument(p),h=((f=p.$cstNode)==null?void 0:f.range.start)||{line:0,character:0};t.error(`${d.uri.fsPath}:${h.line}:${h.character}: json conversion error: ${l.message}`)}process.exit(1)}let c=VV.safeParse(a.value);if(!c.success){for(let l of c.error.issues)t.error(`${l.code}: ${l.path}: invalid deployment: ${l.message}`);process.exit(1)}return JSON.stringify(JV(e,o,a.value),null,2)}function Sv(t,e=new On){if(t.Manifest.headers!==void 0){let[r,n]=[t.Manifest.headers.target,t.Manifest.headers.version],i=Ln(r,n);e.add(i,{target:r,version:n})}for(let r of t.Manifest.requires){let[n,i]=[r.target,r.version],s={target:n,version:i},o=Ln(n,i);if(e.add(o,s),r.headers!==void 0){let[a,c]=[r.headers.target,r.headers.version],u=Ln(a,c);s.interface={target:a,version:c},e.add(u,s.interface)}}return e}var Kb=ke(require("assert"),1);var ZV=require("path");async function dg(t,e,r){let n=Ln(e,r),i=Js(n);if(ue.isSome(i)&&(e=i.value.Location),(0,ZV.isAbsolute)(e)){let a=De.file(e),c=await Gs(t.FS,a);return N.isOk(c)?c:ot}let s=ee.joinPath(t.Locations.Vendor(),n),o=await Gs(t.FS,s);return N.isOk(o)||(s=ee.joinPath(t.Locations.Cache(),n),o=await Gs(t.FS,s),N.isOk(o))?o:ot}function ra(t,e){if(N.isErr(e)){for(let r of e.err)t.error(r);process.exit(1)}return e.value}var Gb=ke(require("path"),1);var Wb=ke(Ui(),1);var jv=ke(fj(),1),$v=ke(J_(),1),MU=require("child_process"),_q=ke(Y_(),1),Qp=ke(Y_(),1),Wq=require("events"),Fv=Object.defineProperty,kde=Object.defineProperties,wde=Object.getOwnPropertyDescriptor,Ade=Object.getOwnPropertyDescriptors,yb=Object.getOwnPropertyNames,dj=Object.getOwnPropertySymbols,zj=Object.prototype.hasOwnProperty,Rde=Object.prototype.propertyIsEnumerable,pj=(t,e,r)=>e in t?Fv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ys=(t,e)=>{for(var r in e||(e={}))zj.call(e,r)&&pj(t,r,e[r]);if(dj)for(var r of dj(e))Rde.call(e,r)&&pj(t,r,e[r]);return t},hg=(t,e)=>kde(t,Ade(e)),xe=(t,e)=>function(){return t&&(e=(0,t[yb(t)[0]])(t=0)),e},Pde=(t,e)=>function(){return e||(0,t[yb(t)[0]])((e={exports:{}}).exports,e),e.exports},ln=(t,e)=>{for(var r in e)Fv(t,r,{get:e[r],enumerable:!0})},Nde=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of yb(e))!zj.call(t,i)&&i!==r&&Fv(t,i,{get:()=>e[i],enumerable:!(n=wde(e,i))||n.enumerable});return t},Zr=t=>Nde(Fv({},"__esModule",{value:!0}),t),mg=(t,e,r)=>new Promise((n,i)=>{var s=c=>{try{a(r.next(c))}catch(u){i(u)}},o=c=>{try{a(r.throw(c))}catch(u){i(u)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,o);a((r=r.apply(t,e)).next())});function Ode(...t){let e=new String(t);return Vv.set(e,t),e}function Dv(t){return t instanceof String&&Vv.has(t)}function mj(t){return Vv.get(t)||[]}var Vv,xg=xe({"src/lib/args/pathspec.ts"(){"use strict";Vv=new WeakMap}}),Ga,Yc=xe({"src/lib/errors/git-error.ts"(){"use strict";Ga=class extends Error{constructor(t,e){super(e),this.task=t,Object.setPrototypeOf(this,new.target.prototype)}}}}),_g,Zp=xe({"src/lib/errors/git-response-error.ts"(){"use strict";Yc(),_g=class extends Ga{constructor(t,e){super(void 0,e||String(t)),this.git=t}}}}),Wj,Kj=xe({"src/lib/errors/task-configuration-error.ts"(){"use strict";Yc(),Wj=class extends Ga{constructor(t){super(void 0,t)}}}});function Gj(t){return typeof t=="function"?t:Ml}function Jj(t){return typeof t=="function"&&t!==Ml}function Qj(t,e){let r=t.indexOf(e);return r<=0?[t,""]:[t.substr(0,r),t.substr(r+1)]}function Yj(t,e=0){return Zj(t)&&t.length>e?t[e]:void 0}function $l(t,e=0){if(Zj(t)&&t.length>e)return t[t.length-1-e]}function Zj(t){return!!(t&&typeof t.length=="number")}function bg(t="",e=!0,r=`
@@ -684,7 +684,7 @@ If the module is not located in the current directory, you can provide a custom
684
684
  kdsl mod update -v 1.0.0 -p ./my-module
685
685
  `.trim();function V1e(t){return async e=>{await j1e(t,process.cwd(),e)}}var j1e=async(t,e,r)=>{var f,l,p;let n=wn.fileSystemProvider(),i=(f=r.path)!=null?f:e;Rg.default.isAbsolute(i)||(i=Rg.default.join(e,i));let s=await wl(n,De.file(i));ue.isSome(s)&&s.value.fsPath===i&&(t.error(`error: module ${i} already exists`),process.exit(1));let o=await n.readFile(De.file(Rg.default.join(i,xr))),a=JSON.parse(o),c={spec:"kumori/module/v1",kumori:"0.0.1",version:(l=r.version)!=null?l:a.version,module:a.module,cacheLocation:(p=r.cacheLocation)!=null?p:a.cacheLocation,requires:[]},u=Rg.default.join(i,xr);await(0,n8.mkdir)(i,{recursive:!0}),await(0,n8.writeFile)(u,JSON.stringify(c,null,4)),t.info(`updated ${xr}: module ${c.module}`)};var DB={Register:U1e};function U1e(t,e){let r=t.command("mod").summary(q1e).description(B1e).helpCommand(!1).helpOption(!1);return xB.Register(r,e),fB.Register(r,e),CB.Register(r,e),NB.Register(r,e),OB.Register(r),IB.Register(r,e),r}var q1e="module maintenance",B1e=`
686
686
  Provides access to operations on modules.
687
- `.trim();var LB={name:"@kumori/kdsl",version:"0.0.7",private:!1,files:["bin","out"],type:"module",description:"Kumori DSL command line interface",bin:{kdsl:"bin/cli.js"},scripts:{build:"npm run fix && tsc -b tsconfig.json && node esbuild.mjs --minify",test:"vitest run",clean:"rm -rf dist/ out/ tsconfig.tsbuildinfo",prepublishOnly:"npm run build",lint:"eslint .",prettier:"prettier src/ test/ --write",fix:"npm run lint && npm run prettier"},dependencies:{"@commander-js/extra-typings":"^13.1.0","@kumori/kdsl-lsp":"file:../lsp",ajv:"^6.12.6",chalk:"~5.3.0",commander:"~13.1.0",zod:"^3.24.2"},license:"EUPL",keywords:["cli","tool","automation","kumori","dsl"],gitHead:"89bea74c68de5f90f37ccc0e64b340408c90b76d",devDependencies:{"@eslint/js":"^9.35.0",eslint:"^9.35.0",globals:"^16.4.0",jiti:"^2.5.1",prettier:"3.6.2","typescript-eslint":"^8.44.0"}};var z1e="<unknown>",$B,W1e=($B=LB.version)!=null?$B:z1e,MB=W1e;var FB={Register:K1e};function K1e(t,e){return t.command("add").argument("<selector>","Name selector for matching dependencies").argument("<version>","Version of the registry specification. It is a git tag.").argument("<url>","URL that contains the registry index for resolving modules").summary(G1e).description(J1e).action(Q1e(e))}var G1e=`
687
+ `.trim();var LB={name:"@kumori/kdsl",version:"0.0.8",private:!1,files:["bin","out"],type:"module",description:"Kumori DSL command line interface",bin:{kdsl:"bin/cli.js"},scripts:{build:"npm run fix && tsc -b tsconfig.json && node esbuild.mjs --minify",test:"vitest run",clean:"rm -rf dist/ out/ tsconfig.tsbuildinfo",prepublishOnly:"npm run build",lint:"eslint .",prettier:"prettier src/ test/ --write",fix:"npm run lint && npm run prettier"},dependencies:{"@commander-js/extra-typings":"^13.1.0","@kumori/kdsl-lsp":"0.0.1-alpha.8",ajv:"^6.12.6",chalk:"~5.3.0",commander:"~13.1.0",zod:"^3.24.2"},license:"EUPL",keywords:["cli","tool","automation","kumori","dsl"],gitHead:"89bea74c68de5f90f37ccc0e64b340408c90b76d",devDependencies:{"@eslint/js":"^9.35.0",eslint:"^9.35.0",globals:"^16.4.0",jiti:"^2.5.1",prettier:"3.6.2","typescript-eslint":"^8.44.0"}};var z1e="<unknown>",$B,W1e=($B=LB.version)!=null?$B:z1e,MB=W1e;var FB={Register:K1e};function K1e(t,e){return t.command("add").argument("<selector>","Name selector for matching dependencies").argument("<version>","Version of the registry specification. It is a git tag.").argument("<url>","URL that contains the registry index for resolving modules").summary(G1e).description(J1e).action(Q1e(e))}var G1e=`
688
688
  add a new registry
689
689
  `.trim(),J1e=`
690
690
  Add a registry to the resolver configuration. The selector argument is used to match artifacts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumori/kdsl",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "private": false,
5
5
  "files": [
6
6
  "bin",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@commander-js/extra-typings": "^13.1.0",
25
- "@kumori/kdsl-lsp": "file:../lsp",
25
+ "@kumori/kdsl-lsp": "0.0.1-alpha.8",
26
26
  "ajv": "^6.12.6",
27
27
  "chalk": "~5.3.0",
28
28
  "commander": "~13.1.0",