@kitelev/exocortex-cli 17.5.8 → 17.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// @kitelev/exocortex-cli v17.5.
|
|
2
|
+
// @kitelev/exocortex-cli v17.5.9
|
|
3
3
|
// CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
|
|
4
4
|
// License: MIT
|
|
5
5
|
|
|
@@ -241,7 +241,7 @@ aliases:
|
|
|
241
241
|
?instance exo:Asset_label ?label .
|
|
242
242
|
}
|
|
243
243
|
ORDER BY ?instance
|
|
244
|
-
`,o=await this.sparqlService.query(s);return this.buildEnumValues(o)}buildEnumValues(e){let t=[],n=new Set;for(let i of e){let s=this.getBindingValue(i,"instance");if(!s||n.has(s))continue;n.add(s);let o=this.getBindingValue(i,"label")??s,l=`[[${this.fromFullIRI(s)}]]`;t.push({value:l,label:o})}return t}buildRankProperty(e){let t=OR.Namespace.fromPropertyKey(e);return t?`${t.namespace.prefix}__${t.localName}_rank`:null}normalizeClassName(e){return e.replace(/\[\[|\]\]/g,"").trim()}getBindingValue(e,t){let n=e.get(t);if(n!=null)return String(n)}toFullIRI(e){if(e.startsWith("http://")||e.startsWith("https://"))return e;let t=OR.Namespace.fromPropertyKey(e);return t?t.namespace.term(t.localName).value:e}fromFullIRI(e){let t=OR.Namespace.fromTermIRI(e);return t?`${t.namespace.prefix}__${t.localName}`:e}};Pa.EnumValueResolver=PR;Pa.EnumValueResolver=PR=mne([(0,yne.injectable)(),gne("design:paramtypes",[Object,Object])],PR)});var DR=T(Ns=>{"use strict";var bne=Ns&&Ns.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},_ne=Ns&&Ns.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Sne=Ns&&Ns.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(Ns,"__esModule",{value:!0});Ns.GenericAssetCreationService=void 0;var Cj=lt(),Yh=Ts(),wne=Ea(),Ene=mo(),vne=At(),xj=Zl(),Tne=oi(),Ao=zy(),Ane=Mh(),Ine=$b(),FR=class{static{a(this,"GenericAssetCreationService")}constructor(e){this.vault=e,this.clock=(0,Ane.liveClock)(),this.uidGen=(0,Ine.liveUidGenerator)()}withDeterminism(e){return e.clock&&(this.clock=e.clock),e.uidGenerator&&(this.uidGen=e.uidGenerator),this}async createAsset(e,t){let{folderPath:n,path:i,content:s}=this.buildAsset(e,t);return this.vault.getAbstractFileByPath(n)||await this.vault.createFolder(n),await this.vault.create(i,s)}buildAsset(e,t){let n=this.uidGen.next(),i=this.generateFrontmatter(e,t||[],n),s=e.declaredRanges,o=new Map;for(let d of Object.keys(e.propertyValues??{}))o.set((0,xj.canonicalYamlKey)(d),d);let c=wne.MetadataHelpers.buildFileContent(i,e.body,s===void 0?void 0:d=>s.get(o.get(d)??d)),l=e.folderPath||this.getDefaultFolderPath(e),u=`${n}.md`,f=l?`${l}/${u}`:u;return{uid:n,folderPath:l,path:f,frontmatter:i,content:c}}generateFrontmatter(e,t=[],n=this.uidGen.next()){let i={},s=new Map;for(let u of t)s.set(u.name,u.fieldType);i.exo__Asset_uid=n;let o=e.timezone?this.generateTimestampInTimezone(e.timezone):Yh.DateFormatter.toLocalTimestamp(this.clock.now());i.exo__Asset_createdAt=o,i.exo__Asset_updatedAt=o;let c=e.classRefForm==="uuid"&&e.classUid?e.classUid:e.className;i.exo__Instance_class=[this.formatWikilink(c)];let l=e.propertyValues?.exo__Instance_class;if(l!=null){let u=i.exo__Instance_class,f=Array.isArray(l)?l:[l];for(let d of f){if(d==null||String(d).trim()==="")continue;let p=this.formatWikilink(String(d));u.includes(p)||u.push(p)}}if(e.createdBy&&e.createdBy.trim()!==""&&(i.exo__Asset_createdBy=this.formatWikilink(e.createdBy.trim())),e.label&&e.label.trim()!==""){let u=e.label.trim();i.exo__Asset_label=u;let f=[u];if(e.aliases)for(let d of e.aliases)f.includes(d)||f.push(d);i.aliases=f}if(e.parentFile&&e.parentMetadata&&this.inheritParentContext(i,e),e.propertyValues)for(let[u,f]of Object.entries(e.propertyValues)){let d=(0,xj.canonicalYamlKey)(u);if(!(d==="exo__Asset_uid"||d==="exo__Asset_createdAt"||d==="exo__Asset_updatedAt"||d==="exo__Asset_createdBy"||d==="exo__Instance_class"||d==="exo__Asset_label"||d==="aliases")&&f!=null)if(e.shapeRegistry!==void 0)Array.isArray(f)?i[d]=f.map(p=>this.quoteWikilinkValue(String(p))):i[d]=this.formatPropertyValueWithCardinality(d,String(f),e.shapeRegistry);else{let p=s.get(d);i[d]=this.formatValue(f,p)}}return i}inheritParentContext(e,t){let n=t.parentMetadata||{},i=t.parentFile?.basename;if(t.className==="ems__Task"||t.className.startsWith("ems__Task")){let s=n.exo__Instance_class,c=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[c]=i?this.formatWikilink(i):null}if(t.className==="ems__Project"||t.className.startsWith("ems__Project")){let s=n.exo__Instance_class,c=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[c]=i?this.formatWikilink(i):null}if(n.exo__Asset_isDefinedBy){let s=n.exo__Asset_isDefinedBy;e.exo__Asset_isDefinedBy=typeof s=="string"?this.formatWikilink(s):s}}isAreaClass(e,t){if(!e)return!1;let n=Array.isArray(e)?e:[e],i=a(()=>null,"noopResolver");return n.some(s=>{let o=Ene.WikiLinkHelpers.resolveSymbolic(String(s),t??i);return o.includes("Area")||o.includes("ems__Area")})}getDefaultFolderPath(e){if(e.parentFile?.parent?.path)return e.parentFile.parent.path;let t={ems__Task:"tasks",ems__Project:"projects",ems__Area:"areas",ems__Meeting:"meetings",exo__Event:"events",ims__Concept:"concepts"};if(t[e.className])return t[e.className];for(let[n,i]of Object.entries(t))if(e.className.startsWith(n))return i;return"assets"}formatValue(e,t){if(e==null)return null;if(!t)return this.formatInferredValue(e);switch(t){case Ao.PropertyFieldType.Text:return String(e);case Ao.PropertyFieldType.Wikilink:case Ao.PropertyFieldType.Reference:case Ao.PropertyFieldType.StatusSelect:case Ao.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case Ao.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case Ao.PropertyFieldType.Boolean:return this.formatBoolean(e);case Ao.PropertyFieldType.Date:case Ao.PropertyFieldType.DateTime:case Ao.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?Yh.DateFormatter.toLocalTimestamp(e):typeof e=="string"?e.startsWith("[[")||e.startsWith('"[[')?this.formatWikilink(e):e:String(e)}formatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:`"[[${e}]]"`}formatBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"}return typeof e=="number"?e!==0:!!e}formatTimestamp(e){if(e instanceof Date)return Yh.DateFormatter.toLocalTimestamp(e);if(typeof e=="string"){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(e))return e;if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e.replace("Z","");let t=new Date(e);return isNaN(t.getTime())?e:Yh.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return Yh.DateFormatter.toLocalTimestamp(t)}return String(e)}formatPropertyValueWithCardinality(e,t,n){let i=this.quoteWikilinkValue(t);return i.includes("[[")&&this.shouldEmitAsArray(e,n)?[i]:i}quoteWikilinkValue(e){return e.includes("[[")?e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`:e}shouldEmitAsArray(e,t){if(!t)return!1;let n=vne.Namespace.fromPropertyKey(e);if(!n)return!1;let i=n.namespace.term(n.localName).value;return t.get(i)?.cardinality==="Multiple"}generateTimestampInTimezone(e){let t=this.clock.now(),i=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(t),s=a(o=>i.find(c=>c.type===o)?.value||"00","get");return`${s("year")}-${s("month")}-${s("day")}T${s("hour")}:${s("minute")}:${s("second")}`}};Ns.GenericAssetCreationService=FR;Ns.GenericAssetCreationService=FR=bne([(0,Cj.injectable)(),Sne(0,(0,Cj.inject)(Tne.DI_TOKENS.IVaultAdapter)),_ne("design:paramtypes",[Object])],FR)});var Pj=T(ks=>{"use strict";var Rne=ks&&ks.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Cne=ks&&ks.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},xne=ks&&ks.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(ks,"__esModule",{value:!0});ks.ArchiveAssetService=void 0;var Oj=lt(),One=oi(),Pne=eu(),LR=class{static{a(this,"ArchiveAssetService")}constructor(e){this.vault=e,this.frontmatterService=new Pne.FrontmatterService}async archiveAsset(e){let t=await this.vault.read(e),n=this.frontmatterService.updateProperty(t,"exo__Asset_archived","true");n=this.frontmatterService.removeProperty(n,"aliases"),n!==t&&await this.vault.modify(e,n)}};ks.ArchiveAssetService=LR;ks.ArchiveAssetService=LR=Rne([(0,Oj.injectable)(),xne(0,(0,Oj.inject)(One.DI_TOKENS.IVaultAdapter)),Cne("design:paramtypes",[Object])],LR)});var Dj=T(Ms=>{"use strict";var Fne=Ms&&Ms.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Dne=Ms&&Ms.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Lne=Ms&&Ms.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(Ms,"__esModule",{value:!0});Ms.FixMissingLabelService=void 0;var Fj=lt(),Nne=oi(),kne=eu(),NR=class{static{a(this,"FixMissingLabelService")}constructor(e){this.vault=e,this.frontmatterService=new kne.FrontmatterService}async fixMissingLabel(e){let t=await this.vault.read(e);if(this.hasNonEmptyLabel(t))return;let n=this.frontmatterService.updateProperty(t,"exo__Asset_label",e.basename);n!==t&&await this.vault.modify(e,n)}hasNonEmptyLabel(e){let t=this.frontmatterService.parse(e);if(!t.exists)return!1;let n=t.content.match(/^exo__Asset_label:\s*(.*)$/m);if(!n)return!1;let i=n[1].trim();return!(i===""||i==='""'||i==="''")}};Ms.FixMissingLabelService=NR;Ms.FixMissingLabelService=NR=Fne([(0,Fj.injectable)(),Lne(0,(0,Fj.inject)(Nne.DI_TOKENS.IVaultAdapter)),Dne("design:paramtypes",[Object])],NR)});var Lj=T(Da=>{"use strict";var Mne=Da&&Da.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},jne=Da&&Da.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(Da,"__esModule",{value:!0});Da.GraphQueryService=void 0;var $ne=lt(),Xh=De(),Une=He(),Fa=At(),Bne=qv(),js={INSTANCE_CLASS:Fa.Namespace.EXO.term("Instance_class"),ASSET_LABEL:Fa.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:Fa.Namespace.EXO.term("Asset_prototype"),ASSET_ARCHIVED:Fa.Namespace.EXO.term("Asset_archived"),ASSET_IS_ARCHIVED:Fa.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:Fa.Namespace.EMS.term("Effort_parent"),REFERENCES:Fa.Namespace.EXO.term("references"),REFERENCED_BY:Fa.Namespace.EXO.term("referencedBy"),RDF_TYPE:Fa.Namespace.RDF.term("type")},kR=class{static{a(this,"GraphQueryService")}constructor(e,t={},n){this.subscribers=new Set,this.nodeCache=new Map,this.lastCacheUpdate=0,this.tripleStore=e,this.logger=n,this.config={defaultLimit:t.defaultLimit??100,maxLimit:t.maxLimit??1e4,defaultDepth:t.defaultDepth??2,maxDepth:t.maxDepth??10,includeArchivedByDefault:t.includeArchivedByDefault??!1,cacheTTL:t.cacheTTL??3e4}}async loadGraphData(e={}){let t=Date.now(),n=await this.loadNodes(e),i=await this.loadEdges(n,e),s=this.computeStats(n,i),o=Date.now()-t;return o>100&&n.length>0&&this.logger?.debug(`GraphQueryService: loaded ${n.length} nodes in ${o}ms (${(o/n.length).toFixed(2)}ms/node)`),{nodes:n,edges:i,stats:s,lastUpdated:Date.now(),version:1}}async loadNodesIncremental(e={}){let t=Math.min(e.limit??this.config.defaultLimit,this.config.maxLimit),n=e.offset??0,i=await this.loadNodes({...e,limit:t+1,offset:n}),s=i.length>t,o=s?i.slice(0,t):i,c=await this.loadEdges(o,e);return{nodes:o,edges:c,hasMore:s,totalCount:void 0,cursor:s?String(n+t):void 0}}async loadConnectedNodes(e,t={}){let n=Math.min(t.depth??this.config.defaultDepth,this.config.maxDepth),i=Math.min(t.limit??this.config.maxLimit,this.config.maxLimit),s=new Set,o=[{id:e,currentDepth:0}],c=[];for(;o.length>0&&c.length<i;){let u=o.shift();if(!u)break;let{id:f,currentDepth:d}=u;if(s.has(f))continue;s.add(f);let p=await this.getNodeById(f,t);if(p&&(c.push(p),d<n)){let h=await this.getConnectedNodeIds(f);for(let g of h)s.has(g)||o.push({id:g,currentDepth:d+1})}}let l=await this.loadEdges(c,t);return{nodes:c,edges:l,hasMore:o.length>0,totalCount:s.size+o.length}}async getNodeById(e,t={}){let n=this.getCachedNode(e);if(n)return{...n};let i=this.idToIRI(e),s=await this.tripleStore.match(i,void 0,void 0);if(s.length===0)return null;let o=this.triplesToNode(e,s,t);return o&&this.cacheNode(o),o}subscribe(e){return this.subscribers.add(e),{unsubscribe:a(()=>{this.subscribers.delete(e)},"unsubscribe")}}notifyChange(e){for(let t of this.subscribers)try{t(e)}catch(n){this.logger?.error("GraphQueryService: error in subscriber callback",n instanceof Error?n:new Error(String(n)))}this.invalidateCache()}async getStats(){let e=await this.loadNodes({includeArchived:!0}),t=await this.loadEdges(e,{});return this.computeStats(e,t)}clearCache(){this.nodeCache.clear(),this.lastCacheUpdate=0}async loadNodes(e){let t=e.includeArchived??this.config.includeArchivedByDefault,n=e.limit??this.config.maxLimit,i=e.offset??0,s=await this.tripleStore.match(void 0,js.INSTANCE_CLASS,void 0),o=s;if(e.classes&&e.classes.length>0){let h=new Set(e.classes);o=s.filter(g=>{let m=this.getObjectValue(g.object);return m&&h.has(m)})}let c=new Set;for(let h of o)c.add(this.subjectToId(h.subject));let f=Array.from(c).slice(i,i+n).map(h=>this.getNodeById(h,e));return(await Promise.all(f)).filter(h=>!(!h||!t&&h.isArchived))}async loadEdges(e,t){let n=new Set(e.map(o=>o.id)),i=[],s=new Set;for(let o of e){let c=this.idToIRI(o.id),l=await this.tripleStore.match(c,void 0,void 0);for(let u of l){let f=this.tripleToEdge(o.id,u,n);f&&f.id&&!s.has(f.id)&&(!t.edgeTypes||t.edgeTypes.includes(f.type))&&(s.add(f.id),i.push(f))}}return i}async getConnectedNodeIds(e){let t=this.idToIRI(e),n=[],i=await this.tripleStore.match(t,void 0,void 0);for(let o of i){let c=this.objectToId(o.object);c&&n.push(c)}let s=await this.tripleStore.match(void 0,void 0,t);for(let o of s)n.push(this.subjectToId(o.subject));return[...new Set(n)]}triplesToNode(e,t,n){let i={},s,o,c,l,u=!1;for(let p of t){let h=p.predicate.value,g=this.getObjectValue(p.object);if(h===js.INSTANCE_CLASS.value)s=g;else if(h===js.ASSET_LABEL.value)o=g;else if(h===js.ASSET_PROTOTYPE.value)c=this.objectToId(p.object)??g;else if(h===js.EFFORT_PARENT.value)l=this.objectToId(p.object)??g;else if(h===js.ASSET_ARCHIVED.value||h===js.ASSET_IS_ARCHIVED.value)u=u||g==="true"||g==="1";else{let m=this.predicateToPropertyName(h);m&&(i[m]=g)}}if(u&&!(n.includeArchived??this.config.includeArchivedByDefault))return null;let f=this.idToPath(e),d=o??this.pathToTitle(f);return{id:e,path:f,title:d,label:d,assetClass:s,isArchived:u,uri:e.startsWith("http")?e:void 0,prototype:c,parent:l,properties:Object.keys(i).length>0?i:void 0}}tripleToEdge(e,t,n){let i=t.predicate.value,s=this.objectToId(t.object);if(!s||!n.has(s)||s===e)return null;let o=this.predicateToEdgeType(i);if(!o)return null;let c=(0,Bne.createEdgeId)(e,s,o,i),l=this.predicateToLabel(i);return{id:c,source:e,target:s,type:o,predicate:i,label:l}}predicateToEdgeType(e){return e===js.EFFORT_PARENT.value?"hierarchy":e===js.ASSET_PROTOTYPE.value?"prototype":e===js.REFERENCES.value?"forward-link":e===js.REFERENCED_BY.value?"backlink":e.includes("Asset_")||e.includes("Instance_")?null:"semantic"}predicateToLabel(e){let t=e.lastIndexOf("#"),n=e.lastIndexOf("/"),i=Math.max(t,n);return i>=0?e.substring(i+1):e}predicateToPropertyName(e){return this.predicateToLabel(e).replace(/_/g,"__").replace(/#/g,"_")}computeStats(e,t){let n={},i={backlink:0,"forward-link":0,hierarchy:0,prototype:0,semantic:0,reference:0};for(let c of e){let l=c.assetClass??"unknown";n[l]=(n[l]??0)+1}for(let c of t)i[c.type]=(i[c.type]??0)+1;let s=new Map,o=new Map;for(let c of t)o.set(c.source,(o.get(c.source)??0)+1),s.set(c.target,(s.get(c.target)??0)+1);for(let c of e)c.inDegree=s.get(c.id)??0,c.outDegree=o.get(c.id)??0,c.weight=c.inDegree+c.outDegree;return{nodeCount:e.length,edgeCount:t.length,nodesByClass:n,edgesByType:i,computedAt:Date.now()}}idToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?new Xh.IRI(e):new Xh.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof Xh.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof Xh.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof Une.Literal||e instanceof Xh.IRI)return e.value}idToPath(e){if(e.startsWith("obsidian://vault/"))return decodeURIComponent(e.replace("obsidian://vault/",""));if(e.startsWith("http://")||e.startsWith("https://")){let t=e.match(/\/([^/]+\.md)$/);if(t)return t[1]}return e}pathToTitle(e){return(e.split("/").pop()??e).replace(/\.md$/,"")}getCachedNode(e){return Date.now()-this.lastCacheUpdate>this.config.cacheTTL?(this.clearCache(),null):this.nodeCache.get(e)??null}cacheNode(e){this.nodeCache.set(e.id,e),this.lastCacheUpdate===0&&(this.lastCacheUpdate=Date.now())}invalidateCache(){this.clearCache()}};Da.GraphQueryService=kR;Da.GraphQueryService=kR=Mne([(0,$ne.injectable)(),jne("design:paramtypes",[Object,Object,Object])],kR)});var kj=T(La=>{"use strict";var Vne=La&&La.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Gne=La&&La.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(La,"__esModule",{value:!0});La.TypeRegistry=void 0;var qne=lt(),Io=De(),Nj=sr(),Wne=He(),zne=ru(),kt=Wv(),MR=class{static{a(this,"TypeRegistry")}constructor(e=null,t={}){this.nodeTypes=new Map,this.edgeTypes=new Map,this.typeHierarchy=new Map,this.subscribers=new Set,this.discoveryComplete=!1,this.tripleStore=e,this.config={autoDiscoverTypes:t.autoDiscoverTypes??!0,includeBuiltInStyles:t.includeBuiltInStyles??!0,styleResolution:t.styleResolution??{mergeStyles:!0,inheritParentStyles:!0,defaultNodeStyle:kt.DEFAULT_NODE_STYLE,defaultEdgeStyle:kt.DEFAULT_EDGE_STYLE},maxInheritanceDepth:t.maxInheritanceDepth??10},this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerNodeType(e){let n=this.nodeTypes.get(e.uri)?"type-updated":"type-added";this.nodeTypes.set(e.uri,e),e.parentTypes&&e.parentTypes.length>0&&this.typeHierarchy.set(e.uri,e.parentTypes),this.emit({type:n,typeUri:e.uri,definition:e})}registerEdgeType(e){let n=this.edgeTypes.get(e.uri)?"type-updated":"type-added";this.edgeTypes.set(e.uri,e),this.emit({type:n,typeUri:e.uri,definition:e})}unregisterType(e){let t=this.nodeTypes.delete(e),n=this.edgeTypes.delete(e);this.typeHierarchy.delete(e),(t||n)&&this.emit({type:"type-removed",typeUri:e})}getNodeType(e){return this.nodeTypes.get(e)}getEdgeType(e){return this.edgeTypes.get(e)}getAllNodeTypes(){return Array.from(this.nodeTypes.values())}getAllEdgeTypes(){return Array.from(this.edgeTypes.values())}getParentTypes(e,t=this.config.maxInheritanceDepth){let n=[],i=new Set,s=[{uri:e,currentDepth:0}];for(;s.length>0;){let o=s.shift();if(!o)break;let{uri:c,currentDepth:l}=o;if(i.has(c)||(i.add(c),l>=t))continue;let u=this.typeHierarchy.get(c)??[];for(let f of u)i.has(f)||(n.push(f),s.push({uri:f,currentDepth:l+1}))}return n}getChildTypes(e){let t=[];for(let[n,i]of this.typeHierarchy)i.includes(e)&&t.push(n);return t}isSubtypeOf(e,t){return e===t?!0:this.getParentTypes(e).includes(t)}resolveNodeType(e){let t=[],n="unknown",i="custom";if(e.assetClass){let c=this.normalizeTypeUri(e.assetClass);t.push(c),n=c,i="exo:Instance_class"}let s=e.properties?.[kt.RDF_TYPE_PREDICATES.RDF_TYPE];s&&!t.includes(s)&&(t.push(s),n==="unknown"&&(n=s,i="rdf:type"));for(let c of[...t]){let l=this.getParentTypes(c);for(let u of l)t.includes(u)||t.push(u)}let o=this.resolveNodeStyle(t);return{primaryType:n,types:t,resolvedStyle:o,source:i}}resolveEdgeType(e){let t=e.predicate??e.type,n=e.predicate?"rdf:type":"custom",i=this.resolveEdgeStyle(t);return{primaryType:t,resolvedStyle:i,source:n}}resolveNodeStyle(e){let{mergeStyles:t,defaultNodeStyle:n}=this.config.styleResolution,i={...n},s=[];for(let o of e){let c=this.nodeTypes.get(o);c&&s.push(c)}if(s.sort((o,c)=>o.priority-c.priority),t)for(let o of s)i=(0,kt.mergeNodeStyles)(i,o.style);else if(s.length>0){let o=s[s.length-1];i=(0,kt.mergeNodeStyles)(i,o.style)}return i}resolveEdgeStyle(e){let{defaultEdgeStyle:t}=this.config.styleResolution,n={...t},i=this.edgeTypes.get(e);return i&&(n=(0,kt.mergeEdgeStyles)(n,i.style)),n}filterNodes(e,t){return e.filter(n=>{let i=this.resolveNodeType(n);return!(t.includeNodeTypes&&t.includeNodeTypes.length>0&&!t.includeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||t.excludeNodeTypes&&t.excludeNodeTypes.length>0&&t.excludeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||!t.includeDeprecated&&this.nodeTypes.get(i.primaryType)?.deprecated)})}filterEdges(e,t){return e.filter(n=>{let i=n.predicate??n.type;return!(t.includeEdgeTypes&&t.includeEdgeTypes.length>0&&!t.includeEdgeTypes.includes(i)||t.excludeEdgeTypes&&t.excludeEdgeTypes.length>0&&t.excludeEdgeTypes.includes(i))})}groupNodesByType(e,t,n={}){let{groupByNodeType:i=!0,groupByParentType:s=!1,groupLevel:o=0,maxGroups:c=20,customGroupFn:l}=n,u=new Map;for(let p of e){let h=this.resolveNodeType(p),g;if(l?g=l(h.types):s&&h.types.length>o?g=h.types[o]??h.primaryType:i?g=h.primaryType:g="all",!u.has(g)){let _=this.nodeTypes.get(g)?.label??(0,kt.extractLocalName)(g);u.set(g,{nodeIds:new Set,label:_})}let m=u.get(g);m&&m.nodeIds.add(p.id)}let f=Array.from(u.entries()).map(([p,h])=>({id:p,label:h.label,nodeIds:Array.from(h.nodeIds)}));if(f.length>c){f.sort((g,m)=>m.nodeIds.length-g.nodeIds.length);let p=f.slice(0,c-1),h=f.slice(c-1).flatMap(g=>g.nodeIds);p.push({id:"other",label:"Other",nodeIds:h}),f=p}let d=new Map;for(let p of f)for(let h of p.nodeIds)d.set(h,p.id);return f.map((p,h)=>{let g=new Set(p.nodeIds),m=[],b=[];for(let A of t){let E=g.has(A.source),w=g.has(A.target);E&&w?A.id&&m.push(A.id):(E||w)&&A.id&&b.push(A.id)}let S=`hsl(${h*137.5%360}, 70%, 50%)`;return{id:p.id,label:p.label,nodeIds:p.nodeIds,internalEdgeIds:m,externalEdgeIds:b,color:S,stats:{nodeCount:p.nodeIds.length,internalEdgeCount:m.length,externalEdgeCount:b.length}}})}validateTypes(e,t){let n=[],i=[];for(let s of e){let o=this.resolveNodeType(s);if(o.primaryType!=="unknown"){let c=this.nodeTypes.get(o.primaryType);!c&&o.source!=="inferred"&&i.push({code:"UNREGISTERED_NODE_TYPE",message:`Node type "${o.primaryType}" is not registered`,elementId:s.id,suggestion:"Register the type with registerNodeType()"}),c?.deprecated&&i.push({code:"DEPRECATED_NODE_TYPE",message:`Node uses deprecated type "${o.primaryType}"`,elementId:s.id,suggestion:"Migrate to a non-deprecated type"})}else i.push({code:"MISSING_NODE_TYPE",message:"Node has no type information",elementId:s.id,suggestion:"Add exo:Instance_class or rdf:type to the node"})}for(let s of t){let o=s.predicate??s.type,c=this.edgeTypes.get(o);if(c?.domain&&c.domain.length>0){let l=e.find(u=>u.id===s.source);if(l){let u=this.resolveNodeType(l);c.domain.some(d=>u.types.includes(d))||n.push({code:"DOMAIN_VIOLATION",message:"Edge source does not match expected domain",elementId:s.id,expected:c.domain,actual:u.types})}}if(c?.range&&c.range.length>0){let l=e.find(u=>u.id===s.target);if(l){let u=this.resolveNodeType(l);c.range.some(d=>u.types.includes(d))||n.push({code:"RANGE_VIOLATION",message:"Edge target does not match expected range",elementId:s.id,expected:c.range,actual:u.types})}}}return{valid:n.length===0,errors:n,warnings:i}}async discoverTypes(){if(!this.tripleStore||this.discoveryComplete)return;let e=await this.tripleStore.match(void 0,new Io.IRI(kt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let n of e){let i=this.getObjectValue(n.object);if(i&&(0,kt.isClassType)(i)){let s=this.getSubjectValue(n.subject);s&&await this.discoverNodeType(s)}}let t=await this.tripleStore.match(void 0,new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF),void 0);for(let n of t){let i=this.getSubjectValue(n.subject),s=this.getObjectValue(n.object);if(i&&s){let o=this.typeHierarchy.get(i)??[];if(!o.includes(s)){o.push(s),this.typeHierarchy.set(i,o);let c=this.nodeTypes.get(i);c&&(c.parentTypes=o)}}}this.discoveryComplete=!0,this.emit({type:"hierarchy-updated",rootTypes:this.getRootTypes()})}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}clear(){this.nodeTypes.clear(),this.edgeTypes.clear(),this.typeHierarchy.clear(),this.discoveryComplete=!1,this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerBuiltInTypes(){for(let[e,t]of Object.entries(kt.BUILT_IN_NODE_STYLES))this.nodeTypes.set(e,{uri:e,label:(0,kt.extractLocalName)(e),source:"custom",style:(0,kt.mergeNodeStyles)(kt.DEFAULT_NODE_STYLE,t),priority:1});for(let[e,t]of Object.entries(kt.BUILT_IN_EDGE_STYLES))this.edgeTypes.set(e,{uri:e,label:(0,kt.extractLocalName)(e),source:"custom",style:(0,kt.mergeEdgeStyles)(kt.DEFAULT_EDGE_STYLE,t),priority:1})}async discoverNodeType(e){if(this.nodeTypes.has(e)||!this.tripleStore)return;let t=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),n=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_COMMENT),void 0),i=t.length>0?this.getObjectValue(t[0].object)??(0,kt.extractLocalName)(e):(0,kt.extractLocalName)(e),s=n.length>0?this.getObjectValue(n[0].object):void 0,o="rdfs:Class",c=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let f of c)if(this.getObjectValue(f.object)===kt.RDF_TYPE_PREDICATES.OWL_CLASS){o="owl:Class";break}let l=kt.BUILT_IN_NODE_STYLES[e]??kt.BUILT_IN_NODE_STYLES[(0,kt.extractLocalName)(e)],u={uri:e,label:i,description:s,source:o,style:(0,kt.mergeNodeStyles)(kt.DEFAULT_NODE_STYLE,l??{}),priority:1};this.registerNodeType(u)}normalizeTypeUri(e){let t=e.match(/^\[\[(.+?)\]\]$/);return t?t[1]:e}getSubjectValue(e){if(e instanceof Io.IRI)return e.value;if(e instanceof Nj.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof Wne.Literal||e instanceof Io.IRI)return e.value;if(e instanceof Nj.BlankNode)return`_:${e.id}`}getRootTypes(){let e=new Set;for(let n of this.typeHierarchy.values())for(let i of n)e.add(i);let t=[];for(let n of this.nodeTypes.keys()){let i=this.typeHierarchy.get(n);(!i||i.length===0)&&e.has(n)&&t.push(n)}return t}emit(e){for(let t of this.subscribers)try{t(e)}catch(n){zne.LoggingService.error("TypeRegistry: error in subscriber callback",n instanceof Error?n:new Error(String(n)))}}};La.TypeRegistry=MR;La.TypeRegistry=MR=Vne([(0,qne.injectable)(),Gne("design:paramtypes",[Object,Object])],MR)});var Mj=T(E_=>{"use strict";Object.defineProperty(E_,"__esModule",{value:!0});E_.SPARQL_PREFIXES=void 0;E_.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
|
|
244
|
+
`,o=await this.sparqlService.query(s);return this.buildEnumValues(o)}buildEnumValues(e){let t=[],n=new Set;for(let i of e){let s=this.getBindingValue(i,"instance");if(!s||n.has(s))continue;n.add(s);let o=this.getBindingValue(i,"label")??s,l=`[[${this.fromFullIRI(s)}]]`;t.push({value:l,label:o})}return t}buildRankProperty(e){let t=OR.Namespace.fromPropertyKey(e);return t?`${t.namespace.prefix}__${t.localName}_rank`:null}normalizeClassName(e){return e.replace(/\[\[|\]\]/g,"").trim()}getBindingValue(e,t){let n=e.get(t);if(n!=null)return String(n)}toFullIRI(e){if(e.startsWith("http://")||e.startsWith("https://"))return e;let t=OR.Namespace.fromPropertyKey(e);return t?t.namespace.term(t.localName).value:e}fromFullIRI(e){let t=OR.Namespace.fromTermIRI(e);return t?`${t.namespace.prefix}__${t.localName}`:e}};Pa.EnumValueResolver=PR;Pa.EnumValueResolver=PR=mne([(0,yne.injectable)(),gne("design:paramtypes",[Object,Object])],PR)});var DR=T(Ns=>{"use strict";var bne=Ns&&Ns.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},_ne=Ns&&Ns.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Sne=Ns&&Ns.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(Ns,"__esModule",{value:!0});Ns.GenericAssetCreationService=void 0;var Cj=lt(),Yh=Ts(),wne=Ea(),Ene=mo(),vne=At(),xj=Zl(),Tne=oi(),Ao=zy(),Ane=Mh(),Ine=$b(),FR=class{static{a(this,"GenericAssetCreationService")}constructor(e){this.vault=e,this.clock=(0,Ane.liveClock)(),this.uidGen=(0,Ine.liveUidGenerator)()}withDeterminism(e){return e.clock&&(this.clock=e.clock),e.uidGenerator&&(this.uidGen=e.uidGenerator),this}async createAsset(e,t){let{folderPath:n,path:i,content:s}=this.buildAsset(e,t);return this.vault.getAbstractFileByPath(n)||await this.vault.createFolder(n),await this.vault.create(i,s)}buildAsset(e,t){let n=this.uidGen.next(),i=this.generateFrontmatter(e,t||[],n),s=e.declaredRanges,o=new Map;for(let d of Object.keys(e.propertyValues??{}))o.set((0,xj.canonicalYamlKey)(d),d);let c=wne.MetadataHelpers.buildFileContent(i,e.body,s===void 0?void 0:d=>s.get(o.get(d)??d)),l=e.folderPath||this.getDefaultFolderPath(e),u=`${n}.md`,f=l?`${l}/${u}`:u;return{uid:n,folderPath:l,path:f,frontmatter:i,content:c}}generateFrontmatter(e,t=[],n=this.uidGen.next()){let i={},s=new Map;for(let u of t)s.set(u.name,u.fieldType);i.exo__Asset_uid=n;let o=e.timezone?this.generateTimestampInTimezone(e.timezone):Yh.DateFormatter.toLocalTimestamp(this.clock.now());i.exo__Asset_createdAt=o,i.exo__Asset_updatedAt=o;let c=e.classRefForm==="uuid"&&e.classUid?e.classUid:e.className;i.exo__Instance_class=[this.formatWikilink(c)];let l=e.propertyValues?.exo__Instance_class;if(l!=null){let u=i.exo__Instance_class,f=Array.isArray(l)?l:[l];for(let d of f){if(d==null||String(d).trim()==="")continue;let p=this.formatWikilink(String(d));u.includes(p)||u.push(p)}}if(e.createdBy&&e.createdBy.trim()!==""&&(i.exo__Asset_createdBy=this.formatWikilink(e.createdBy.trim())),e.label&&e.label.trim()!==""){let u=e.label.trim();i.exo__Asset_label=u;let f=[u];if(e.aliases)for(let d of e.aliases)f.includes(d)||f.push(d);i.aliases=f}if(e.parentFile&&e.parentMetadata&&this.inheritParentContext(i,e),e.propertyValues)for(let[u,f]of Object.entries(e.propertyValues)){let d=(0,xj.canonicalYamlKey)(u);if(!(d==="exo__Asset_uid"||d==="exo__Asset_createdAt"||d==="exo__Asset_updatedAt"||d==="exo__Asset_createdBy"||d==="exo__Instance_class"||d==="exo__Asset_label"||d==="aliases")&&f!=null)if(e.shapeRegistry!==void 0)Array.isArray(f)?i[d]=f.map(p=>this.quoteWikilinkValue(String(p))):i[d]=this.formatPropertyValueWithCardinality(d,String(f),e.shapeRegistry);else{let p=s.get(d);i[d]=this.formatValue(f,p)}}return i}inheritParentContext(e,t){let n=t.parentMetadata||{},i=t.parentFile?.basename;if(t.className==="ems__Task"||t.className.startsWith("ems__Task")){let s=n.exo__Instance_class,c=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[c]=i?this.formatWikilink(i):null}if(t.className==="ems__Project"||t.className.startsWith("ems__Project")){let s=n.exo__Instance_class,c=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[c]=i?this.formatWikilink(i):null}if(n.exo__Asset_isDefinedBy){let s=n.exo__Asset_isDefinedBy;e.exo__Asset_isDefinedBy=typeof s=="string"?this.formatWikilink(s):s}}isAreaClass(e,t){if(!e)return!1;let n=Array.isArray(e)?e:[e],i=a(()=>null,"noopResolver");return n.some(s=>{let o=Ene.WikiLinkHelpers.resolveSymbolic(String(s),t??i);return o.includes("Area")||o.includes("ems__Area")})}getDefaultFolderPath(e){if(e.parentFile?.parent?.path)return e.parentFile.parent.path;let t={ems__Task:"tasks",ems__Project:"projects",ems__Area:"areas",ems__Meeting:"meetings",exo__Event:"events"};if(t[e.className])return t[e.className];for(let[n,i]of Object.entries(t))if(e.className.startsWith(n))return i;return"assets"}formatValue(e,t){if(e==null)return null;if(!t)return this.formatInferredValue(e);switch(t){case Ao.PropertyFieldType.Text:return String(e);case Ao.PropertyFieldType.Wikilink:case Ao.PropertyFieldType.Reference:case Ao.PropertyFieldType.StatusSelect:case Ao.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case Ao.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case Ao.PropertyFieldType.Boolean:return this.formatBoolean(e);case Ao.PropertyFieldType.Date:case Ao.PropertyFieldType.DateTime:case Ao.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?Yh.DateFormatter.toLocalTimestamp(e):typeof e=="string"?e.startsWith("[[")||e.startsWith('"[[')?this.formatWikilink(e):e:String(e)}formatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:`"[[${e}]]"`}formatBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"}return typeof e=="number"?e!==0:!!e}formatTimestamp(e){if(e instanceof Date)return Yh.DateFormatter.toLocalTimestamp(e);if(typeof e=="string"){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(e))return e;if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e.replace("Z","");let t=new Date(e);return isNaN(t.getTime())?e:Yh.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return Yh.DateFormatter.toLocalTimestamp(t)}return String(e)}formatPropertyValueWithCardinality(e,t,n){let i=this.quoteWikilinkValue(t);return i.includes("[[")&&this.shouldEmitAsArray(e,n)?[i]:i}quoteWikilinkValue(e){return e.includes("[[")?e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`:e}shouldEmitAsArray(e,t){if(!t)return!1;let n=vne.Namespace.fromPropertyKey(e);if(!n)return!1;let i=n.namespace.term(n.localName).value;return t.get(i)?.cardinality==="Multiple"}generateTimestampInTimezone(e){let t=this.clock.now(),i=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(t),s=a(o=>i.find(c=>c.type===o)?.value||"00","get");return`${s("year")}-${s("month")}-${s("day")}T${s("hour")}:${s("minute")}:${s("second")}`}};Ns.GenericAssetCreationService=FR;Ns.GenericAssetCreationService=FR=bne([(0,Cj.injectable)(),Sne(0,(0,Cj.inject)(Tne.DI_TOKENS.IVaultAdapter)),_ne("design:paramtypes",[Object])],FR)});var Pj=T(ks=>{"use strict";var Rne=ks&&ks.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Cne=ks&&ks.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},xne=ks&&ks.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(ks,"__esModule",{value:!0});ks.ArchiveAssetService=void 0;var Oj=lt(),One=oi(),Pne=eu(),LR=class{static{a(this,"ArchiveAssetService")}constructor(e){this.vault=e,this.frontmatterService=new Pne.FrontmatterService}async archiveAsset(e){let t=await this.vault.read(e),n=this.frontmatterService.updateProperty(t,"exo__Asset_archived","true");n=this.frontmatterService.removeProperty(n,"aliases"),n!==t&&await this.vault.modify(e,n)}};ks.ArchiveAssetService=LR;ks.ArchiveAssetService=LR=Rne([(0,Oj.injectable)(),xne(0,(0,Oj.inject)(One.DI_TOKENS.IVaultAdapter)),Cne("design:paramtypes",[Object])],LR)});var Dj=T(Ms=>{"use strict";var Fne=Ms&&Ms.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Dne=Ms&&Ms.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Lne=Ms&&Ms.__param||function(r,e){return function(t,n){e(t,n,r)}};Object.defineProperty(Ms,"__esModule",{value:!0});Ms.FixMissingLabelService=void 0;var Fj=lt(),Nne=oi(),kne=eu(),NR=class{static{a(this,"FixMissingLabelService")}constructor(e){this.vault=e,this.frontmatterService=new kne.FrontmatterService}async fixMissingLabel(e){let t=await this.vault.read(e);if(this.hasNonEmptyLabel(t))return;let n=this.frontmatterService.updateProperty(t,"exo__Asset_label",e.basename);n!==t&&await this.vault.modify(e,n)}hasNonEmptyLabel(e){let t=this.frontmatterService.parse(e);if(!t.exists)return!1;let n=t.content.match(/^exo__Asset_label:\s*(.*)$/m);if(!n)return!1;let i=n[1].trim();return!(i===""||i==='""'||i==="''")}};Ms.FixMissingLabelService=NR;Ms.FixMissingLabelService=NR=Fne([(0,Fj.injectable)(),Lne(0,(0,Fj.inject)(Nne.DI_TOKENS.IVaultAdapter)),Dne("design:paramtypes",[Object])],NR)});var Lj=T(Da=>{"use strict";var Mne=Da&&Da.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},jne=Da&&Da.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(Da,"__esModule",{value:!0});Da.GraphQueryService=void 0;var $ne=lt(),Xh=De(),Une=He(),Fa=At(),Bne=qv(),js={INSTANCE_CLASS:Fa.Namespace.EXO.term("Instance_class"),ASSET_LABEL:Fa.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:Fa.Namespace.EXO.term("Asset_prototype"),ASSET_ARCHIVED:Fa.Namespace.EXO.term("Asset_archived"),ASSET_IS_ARCHIVED:Fa.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:Fa.Namespace.EMS.term("Effort_parent"),REFERENCES:Fa.Namespace.EXO.term("references"),REFERENCED_BY:Fa.Namespace.EXO.term("referencedBy"),RDF_TYPE:Fa.Namespace.RDF.term("type")},kR=class{static{a(this,"GraphQueryService")}constructor(e,t={},n){this.subscribers=new Set,this.nodeCache=new Map,this.lastCacheUpdate=0,this.tripleStore=e,this.logger=n,this.config={defaultLimit:t.defaultLimit??100,maxLimit:t.maxLimit??1e4,defaultDepth:t.defaultDepth??2,maxDepth:t.maxDepth??10,includeArchivedByDefault:t.includeArchivedByDefault??!1,cacheTTL:t.cacheTTL??3e4}}async loadGraphData(e={}){let t=Date.now(),n=await this.loadNodes(e),i=await this.loadEdges(n,e),s=this.computeStats(n,i),o=Date.now()-t;return o>100&&n.length>0&&this.logger?.debug(`GraphQueryService: loaded ${n.length} nodes in ${o}ms (${(o/n.length).toFixed(2)}ms/node)`),{nodes:n,edges:i,stats:s,lastUpdated:Date.now(),version:1}}async loadNodesIncremental(e={}){let t=Math.min(e.limit??this.config.defaultLimit,this.config.maxLimit),n=e.offset??0,i=await this.loadNodes({...e,limit:t+1,offset:n}),s=i.length>t,o=s?i.slice(0,t):i,c=await this.loadEdges(o,e);return{nodes:o,edges:c,hasMore:s,totalCount:void 0,cursor:s?String(n+t):void 0}}async loadConnectedNodes(e,t={}){let n=Math.min(t.depth??this.config.defaultDepth,this.config.maxDepth),i=Math.min(t.limit??this.config.maxLimit,this.config.maxLimit),s=new Set,o=[{id:e,currentDepth:0}],c=[];for(;o.length>0&&c.length<i;){let u=o.shift();if(!u)break;let{id:f,currentDepth:d}=u;if(s.has(f))continue;s.add(f);let p=await this.getNodeById(f,t);if(p&&(c.push(p),d<n)){let h=await this.getConnectedNodeIds(f);for(let g of h)s.has(g)||o.push({id:g,currentDepth:d+1})}}let l=await this.loadEdges(c,t);return{nodes:c,edges:l,hasMore:o.length>0,totalCount:s.size+o.length}}async getNodeById(e,t={}){let n=this.getCachedNode(e);if(n)return{...n};let i=this.idToIRI(e),s=await this.tripleStore.match(i,void 0,void 0);if(s.length===0)return null;let o=this.triplesToNode(e,s,t);return o&&this.cacheNode(o),o}subscribe(e){return this.subscribers.add(e),{unsubscribe:a(()=>{this.subscribers.delete(e)},"unsubscribe")}}notifyChange(e){for(let t of this.subscribers)try{t(e)}catch(n){this.logger?.error("GraphQueryService: error in subscriber callback",n instanceof Error?n:new Error(String(n)))}this.invalidateCache()}async getStats(){let e=await this.loadNodes({includeArchived:!0}),t=await this.loadEdges(e,{});return this.computeStats(e,t)}clearCache(){this.nodeCache.clear(),this.lastCacheUpdate=0}async loadNodes(e){let t=e.includeArchived??this.config.includeArchivedByDefault,n=e.limit??this.config.maxLimit,i=e.offset??0,s=await this.tripleStore.match(void 0,js.INSTANCE_CLASS,void 0),o=s;if(e.classes&&e.classes.length>0){let h=new Set(e.classes);o=s.filter(g=>{let m=this.getObjectValue(g.object);return m&&h.has(m)})}let c=new Set;for(let h of o)c.add(this.subjectToId(h.subject));let f=Array.from(c).slice(i,i+n).map(h=>this.getNodeById(h,e));return(await Promise.all(f)).filter(h=>!(!h||!t&&h.isArchived))}async loadEdges(e,t){let n=new Set(e.map(o=>o.id)),i=[],s=new Set;for(let o of e){let c=this.idToIRI(o.id),l=await this.tripleStore.match(c,void 0,void 0);for(let u of l){let f=this.tripleToEdge(o.id,u,n);f&&f.id&&!s.has(f.id)&&(!t.edgeTypes||t.edgeTypes.includes(f.type))&&(s.add(f.id),i.push(f))}}return i}async getConnectedNodeIds(e){let t=this.idToIRI(e),n=[],i=await this.tripleStore.match(t,void 0,void 0);for(let o of i){let c=this.objectToId(o.object);c&&n.push(c)}let s=await this.tripleStore.match(void 0,void 0,t);for(let o of s)n.push(this.subjectToId(o.subject));return[...new Set(n)]}triplesToNode(e,t,n){let i={},s,o,c,l,u=!1;for(let p of t){let h=p.predicate.value,g=this.getObjectValue(p.object);if(h===js.INSTANCE_CLASS.value)s=g;else if(h===js.ASSET_LABEL.value)o=g;else if(h===js.ASSET_PROTOTYPE.value)c=this.objectToId(p.object)??g;else if(h===js.EFFORT_PARENT.value)l=this.objectToId(p.object)??g;else if(h===js.ASSET_ARCHIVED.value||h===js.ASSET_IS_ARCHIVED.value)u=u||g==="true"||g==="1";else{let m=this.predicateToPropertyName(h);m&&(i[m]=g)}}if(u&&!(n.includeArchived??this.config.includeArchivedByDefault))return null;let f=this.idToPath(e),d=o??this.pathToTitle(f);return{id:e,path:f,title:d,label:d,assetClass:s,isArchived:u,uri:e.startsWith("http")?e:void 0,prototype:c,parent:l,properties:Object.keys(i).length>0?i:void 0}}tripleToEdge(e,t,n){let i=t.predicate.value,s=this.objectToId(t.object);if(!s||!n.has(s)||s===e)return null;let o=this.predicateToEdgeType(i);if(!o)return null;let c=(0,Bne.createEdgeId)(e,s,o,i),l=this.predicateToLabel(i);return{id:c,source:e,target:s,type:o,predicate:i,label:l}}predicateToEdgeType(e){return e===js.EFFORT_PARENT.value?"hierarchy":e===js.ASSET_PROTOTYPE.value?"prototype":e===js.REFERENCES.value?"forward-link":e===js.REFERENCED_BY.value?"backlink":e.includes("Asset_")||e.includes("Instance_")?null:"semantic"}predicateToLabel(e){let t=e.lastIndexOf("#"),n=e.lastIndexOf("/"),i=Math.max(t,n);return i>=0?e.substring(i+1):e}predicateToPropertyName(e){return this.predicateToLabel(e).replace(/_/g,"__").replace(/#/g,"_")}computeStats(e,t){let n={},i={backlink:0,"forward-link":0,hierarchy:0,prototype:0,semantic:0,reference:0};for(let c of e){let l=c.assetClass??"unknown";n[l]=(n[l]??0)+1}for(let c of t)i[c.type]=(i[c.type]??0)+1;let s=new Map,o=new Map;for(let c of t)o.set(c.source,(o.get(c.source)??0)+1),s.set(c.target,(s.get(c.target)??0)+1);for(let c of e)c.inDegree=s.get(c.id)??0,c.outDegree=o.get(c.id)??0,c.weight=c.inDegree+c.outDegree;return{nodeCount:e.length,edgeCount:t.length,nodesByClass:n,edgesByType:i,computedAt:Date.now()}}idToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?new Xh.IRI(e):new Xh.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof Xh.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof Xh.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof Une.Literal||e instanceof Xh.IRI)return e.value}idToPath(e){if(e.startsWith("obsidian://vault/"))return decodeURIComponent(e.replace("obsidian://vault/",""));if(e.startsWith("http://")||e.startsWith("https://")){let t=e.match(/\/([^/]+\.md)$/);if(t)return t[1]}return e}pathToTitle(e){return(e.split("/").pop()??e).replace(/\.md$/,"")}getCachedNode(e){return Date.now()-this.lastCacheUpdate>this.config.cacheTTL?(this.clearCache(),null):this.nodeCache.get(e)??null}cacheNode(e){this.nodeCache.set(e.id,e),this.lastCacheUpdate===0&&(this.lastCacheUpdate=Date.now())}invalidateCache(){this.clearCache()}};Da.GraphQueryService=kR;Da.GraphQueryService=kR=Mne([(0,$ne.injectable)(),jne("design:paramtypes",[Object,Object,Object])],kR)});var kj=T(La=>{"use strict";var Vne=La&&La.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Gne=La&&La.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(La,"__esModule",{value:!0});La.TypeRegistry=void 0;var qne=lt(),Io=De(),Nj=sr(),Wne=He(),zne=ru(),kt=Wv(),MR=class{static{a(this,"TypeRegistry")}constructor(e=null,t={}){this.nodeTypes=new Map,this.edgeTypes=new Map,this.typeHierarchy=new Map,this.subscribers=new Set,this.discoveryComplete=!1,this.tripleStore=e,this.config={autoDiscoverTypes:t.autoDiscoverTypes??!0,includeBuiltInStyles:t.includeBuiltInStyles??!0,styleResolution:t.styleResolution??{mergeStyles:!0,inheritParentStyles:!0,defaultNodeStyle:kt.DEFAULT_NODE_STYLE,defaultEdgeStyle:kt.DEFAULT_EDGE_STYLE},maxInheritanceDepth:t.maxInheritanceDepth??10},this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerNodeType(e){let n=this.nodeTypes.get(e.uri)?"type-updated":"type-added";this.nodeTypes.set(e.uri,e),e.parentTypes&&e.parentTypes.length>0&&this.typeHierarchy.set(e.uri,e.parentTypes),this.emit({type:n,typeUri:e.uri,definition:e})}registerEdgeType(e){let n=this.edgeTypes.get(e.uri)?"type-updated":"type-added";this.edgeTypes.set(e.uri,e),this.emit({type:n,typeUri:e.uri,definition:e})}unregisterType(e){let t=this.nodeTypes.delete(e),n=this.edgeTypes.delete(e);this.typeHierarchy.delete(e),(t||n)&&this.emit({type:"type-removed",typeUri:e})}getNodeType(e){return this.nodeTypes.get(e)}getEdgeType(e){return this.edgeTypes.get(e)}getAllNodeTypes(){return Array.from(this.nodeTypes.values())}getAllEdgeTypes(){return Array.from(this.edgeTypes.values())}getParentTypes(e,t=this.config.maxInheritanceDepth){let n=[],i=new Set,s=[{uri:e,currentDepth:0}];for(;s.length>0;){let o=s.shift();if(!o)break;let{uri:c,currentDepth:l}=o;if(i.has(c)||(i.add(c),l>=t))continue;let u=this.typeHierarchy.get(c)??[];for(let f of u)i.has(f)||(n.push(f),s.push({uri:f,currentDepth:l+1}))}return n}getChildTypes(e){let t=[];for(let[n,i]of this.typeHierarchy)i.includes(e)&&t.push(n);return t}isSubtypeOf(e,t){return e===t?!0:this.getParentTypes(e).includes(t)}resolveNodeType(e){let t=[],n="unknown",i="custom";if(e.assetClass){let c=this.normalizeTypeUri(e.assetClass);t.push(c),n=c,i="exo:Instance_class"}let s=e.properties?.[kt.RDF_TYPE_PREDICATES.RDF_TYPE];s&&!t.includes(s)&&(t.push(s),n==="unknown"&&(n=s,i="rdf:type"));for(let c of[...t]){let l=this.getParentTypes(c);for(let u of l)t.includes(u)||t.push(u)}let o=this.resolveNodeStyle(t);return{primaryType:n,types:t,resolvedStyle:o,source:i}}resolveEdgeType(e){let t=e.predicate??e.type,n=e.predicate?"rdf:type":"custom",i=this.resolveEdgeStyle(t);return{primaryType:t,resolvedStyle:i,source:n}}resolveNodeStyle(e){let{mergeStyles:t,defaultNodeStyle:n}=this.config.styleResolution,i={...n},s=[];for(let o of e){let c=this.nodeTypes.get(o);c&&s.push(c)}if(s.sort((o,c)=>o.priority-c.priority),t)for(let o of s)i=(0,kt.mergeNodeStyles)(i,o.style);else if(s.length>0){let o=s[s.length-1];i=(0,kt.mergeNodeStyles)(i,o.style)}return i}resolveEdgeStyle(e){let{defaultEdgeStyle:t}=this.config.styleResolution,n={...t},i=this.edgeTypes.get(e);return i&&(n=(0,kt.mergeEdgeStyles)(n,i.style)),n}filterNodes(e,t){return e.filter(n=>{let i=this.resolveNodeType(n);return!(t.includeNodeTypes&&t.includeNodeTypes.length>0&&!t.includeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||t.excludeNodeTypes&&t.excludeNodeTypes.length>0&&t.excludeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||!t.includeDeprecated&&this.nodeTypes.get(i.primaryType)?.deprecated)})}filterEdges(e,t){return e.filter(n=>{let i=n.predicate??n.type;return!(t.includeEdgeTypes&&t.includeEdgeTypes.length>0&&!t.includeEdgeTypes.includes(i)||t.excludeEdgeTypes&&t.excludeEdgeTypes.length>0&&t.excludeEdgeTypes.includes(i))})}groupNodesByType(e,t,n={}){let{groupByNodeType:i=!0,groupByParentType:s=!1,groupLevel:o=0,maxGroups:c=20,customGroupFn:l}=n,u=new Map;for(let p of e){let h=this.resolveNodeType(p),g;if(l?g=l(h.types):s&&h.types.length>o?g=h.types[o]??h.primaryType:i?g=h.primaryType:g="all",!u.has(g)){let _=this.nodeTypes.get(g)?.label??(0,kt.extractLocalName)(g);u.set(g,{nodeIds:new Set,label:_})}let m=u.get(g);m&&m.nodeIds.add(p.id)}let f=Array.from(u.entries()).map(([p,h])=>({id:p,label:h.label,nodeIds:Array.from(h.nodeIds)}));if(f.length>c){f.sort((g,m)=>m.nodeIds.length-g.nodeIds.length);let p=f.slice(0,c-1),h=f.slice(c-1).flatMap(g=>g.nodeIds);p.push({id:"other",label:"Other",nodeIds:h}),f=p}let d=new Map;for(let p of f)for(let h of p.nodeIds)d.set(h,p.id);return f.map((p,h)=>{let g=new Set(p.nodeIds),m=[],b=[];for(let A of t){let E=g.has(A.source),w=g.has(A.target);E&&w?A.id&&m.push(A.id):(E||w)&&A.id&&b.push(A.id)}let S=`hsl(${h*137.5%360}, 70%, 50%)`;return{id:p.id,label:p.label,nodeIds:p.nodeIds,internalEdgeIds:m,externalEdgeIds:b,color:S,stats:{nodeCount:p.nodeIds.length,internalEdgeCount:m.length,externalEdgeCount:b.length}}})}validateTypes(e,t){let n=[],i=[];for(let s of e){let o=this.resolveNodeType(s);if(o.primaryType!=="unknown"){let c=this.nodeTypes.get(o.primaryType);!c&&o.source!=="inferred"&&i.push({code:"UNREGISTERED_NODE_TYPE",message:`Node type "${o.primaryType}" is not registered`,elementId:s.id,suggestion:"Register the type with registerNodeType()"}),c?.deprecated&&i.push({code:"DEPRECATED_NODE_TYPE",message:`Node uses deprecated type "${o.primaryType}"`,elementId:s.id,suggestion:"Migrate to a non-deprecated type"})}else i.push({code:"MISSING_NODE_TYPE",message:"Node has no type information",elementId:s.id,suggestion:"Add exo:Instance_class or rdf:type to the node"})}for(let s of t){let o=s.predicate??s.type,c=this.edgeTypes.get(o);if(c?.domain&&c.domain.length>0){let l=e.find(u=>u.id===s.source);if(l){let u=this.resolveNodeType(l);c.domain.some(d=>u.types.includes(d))||n.push({code:"DOMAIN_VIOLATION",message:"Edge source does not match expected domain",elementId:s.id,expected:c.domain,actual:u.types})}}if(c?.range&&c.range.length>0){let l=e.find(u=>u.id===s.target);if(l){let u=this.resolveNodeType(l);c.range.some(d=>u.types.includes(d))||n.push({code:"RANGE_VIOLATION",message:"Edge target does not match expected range",elementId:s.id,expected:c.range,actual:u.types})}}}return{valid:n.length===0,errors:n,warnings:i}}async discoverTypes(){if(!this.tripleStore||this.discoveryComplete)return;let e=await this.tripleStore.match(void 0,new Io.IRI(kt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let n of e){let i=this.getObjectValue(n.object);if(i&&(0,kt.isClassType)(i)){let s=this.getSubjectValue(n.subject);s&&await this.discoverNodeType(s)}}let t=await this.tripleStore.match(void 0,new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF),void 0);for(let n of t){let i=this.getSubjectValue(n.subject),s=this.getObjectValue(n.object);if(i&&s){let o=this.typeHierarchy.get(i)??[];if(!o.includes(s)){o.push(s),this.typeHierarchy.set(i,o);let c=this.nodeTypes.get(i);c&&(c.parentTypes=o)}}}this.discoveryComplete=!0,this.emit({type:"hierarchy-updated",rootTypes:this.getRootTypes()})}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}clear(){this.nodeTypes.clear(),this.edgeTypes.clear(),this.typeHierarchy.clear(),this.discoveryComplete=!1,this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerBuiltInTypes(){for(let[e,t]of Object.entries(kt.BUILT_IN_NODE_STYLES))this.nodeTypes.set(e,{uri:e,label:(0,kt.extractLocalName)(e),source:"custom",style:(0,kt.mergeNodeStyles)(kt.DEFAULT_NODE_STYLE,t),priority:1});for(let[e,t]of Object.entries(kt.BUILT_IN_EDGE_STYLES))this.edgeTypes.set(e,{uri:e,label:(0,kt.extractLocalName)(e),source:"custom",style:(0,kt.mergeEdgeStyles)(kt.DEFAULT_EDGE_STYLE,t),priority:1})}async discoverNodeType(e){if(this.nodeTypes.has(e)||!this.tripleStore)return;let t=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),n=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDFS_COMMENT),void 0),i=t.length>0?this.getObjectValue(t[0].object)??(0,kt.extractLocalName)(e):(0,kt.extractLocalName)(e),s=n.length>0?this.getObjectValue(n[0].object):void 0,o="rdfs:Class",c=await this.tripleStore.match(new Io.IRI(e),new Io.IRI(kt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let f of c)if(this.getObjectValue(f.object)===kt.RDF_TYPE_PREDICATES.OWL_CLASS){o="owl:Class";break}let l=kt.BUILT_IN_NODE_STYLES[e]??kt.BUILT_IN_NODE_STYLES[(0,kt.extractLocalName)(e)],u={uri:e,label:i,description:s,source:o,style:(0,kt.mergeNodeStyles)(kt.DEFAULT_NODE_STYLE,l??{}),priority:1};this.registerNodeType(u)}normalizeTypeUri(e){let t=e.match(/^\[\[(.+?)\]\]$/);return t?t[1]:e}getSubjectValue(e){if(e instanceof Io.IRI)return e.value;if(e instanceof Nj.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof Wne.Literal||e instanceof Io.IRI)return e.value;if(e instanceof Nj.BlankNode)return`_:${e.id}`}getRootTypes(){let e=new Set;for(let n of this.typeHierarchy.values())for(let i of n)e.add(i);let t=[];for(let n of this.nodeTypes.keys()){let i=this.typeHierarchy.get(n);(!i||i.length===0)&&e.has(n)&&t.push(n)}return t}emit(e){for(let t of this.subscribers)try{t(e)}catch(n){zne.LoggingService.error("TypeRegistry: error in subscriber callback",n instanceof Error?n:new Error(String(n)))}}};La.TypeRegistry=MR;La.TypeRegistry=MR=Vne([(0,qne.injectable)(),Gne("design:paramtypes",[Object,Object])],MR)});var Mj=T(E_=>{"use strict";Object.defineProperty(E_,"__esModule",{value:!0});E_.SPARQL_PREFIXES=void 0;E_.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
|
|
245
245
|
PREFIX ems: <https://exocortex.my/ontology/ems#>
|
|
246
246
|
PREFIX ims: <https://exocortex.my/ontology/ims#>
|
|
247
247
|
PREFIX gtd: <https://exocortex.my/ontology/gtd#>
|
|
@@ -708,7 +708,7 @@ Next steps:
|
|
|
708
708
|
`).map(n=>n.trim()).filter(n=>n.length>0),t=e[e.length-1];if(t!==void 0)try{return JSON.parse(t)}catch{return}}a(jEe,"parseLastJsonLine");function uq(r,e){return e.filter(t=>{let n=r[t];return typeof n!="string"||n.trim().length===0})}a(uq,"missingStringFields");var dv=class{constructor(e){this.deps=e}static{a(this,"McpServer")}async handle(e){if(typeof e!="object"||e===null||Array.isArray(e))return{jsonrpc:"2.0",id:null,error:{code:lq,message:"Invalid request: expected a JSON-RPC object"}};let t=e.id,n=t===void 0;if(typeof e.method!="string")return n?null:{jsonrpc:"2.0",id:t??null,error:{code:lq,message:"Invalid request: missing method"}};if(n)return null;let i=t??null;switch(e.method){case"initialize":return{jsonrpc:"2.0",id:i,result:{protocolVersion:kEe,capabilities:{tools:{}},serverInfo:{name:"exocortex",version:this.deps.version}}};case"ping":return{jsonrpc:"2.0",id:i,result:{}};case"tools/list":return{jsonrpc:"2.0",id:i,result:{tools:cq}};case"tools/call":return{jsonrpc:"2.0",id:i,result:await this.callTool(e.params??{})};default:return{jsonrpc:"2.0",id:i,error:{code:MEe,message:`Method not found: ${e.method}`}}}}async callTool(e){let t=e.name,n=e.arguments??{},i;if(t==="create_asset"){let c=uq(n,["vault","class","label"]);if(c.length>0)return Dp(`create_asset: missing required argument(s): ${c.join(", ")}`,!0);let l=sq(n);if(l!==null)return Dp(`create_asset: ${l}`,!0);i=oq(n)}else if(t==="create_effort"){let c=uq(n,["vault","command","target"]);if(c.length>0)return Dp(`create_effort: missing required argument(s): ${c.join(", ")}`,!0);i=aq(n)}else return Dp(`Unknown tool: ${String(t)}`,!0);let s=await this.deps.runCli(i);if(s.exitCode!==0){let c=s.stderr.trim()||s.stdout.trim()||"(no diagnostic output)";return Dp(`exocortex-cli exited ${s.exitCode}
|
|
709
709
|
${c}`,!0)}let o=jEe(s.stdout);return Dp(o===void 0?s.stdout.trim():JSON.stringify(o))}};var pq=require("child_process");var $Ee=32*1024*1024;function hq(r){return e=>new Promise(t=>{(0,pq.execFile)(process.execPath,[r,...e],{maxBuffer:$Ee},(n,i,s)=>{let o=0;if(n){let c=n.code;o=typeof c=="number"?c:1}t({stdout:i,stderr:s,exitCode:o})})})}a(hq,"createSelfCliRunner");async function UEe(r,e,t){let n=(0,mq.createInterface)({input:e,crlfDelay:1/0});for await(let i of n){let s=i.trim();if(s.length===0)continue;let o;try{o=JSON.parse(s)}catch{t(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:fq,message:"Parse error: invalid JSON"}})+`
|
|
710
710
|
`);continue}let c;try{c=await r.handle(o)}catch(l){c={jsonrpc:"2.0",id:typeof o?.id=="string"||typeof o?.id=="number"?o.id:null,error:{code:dq,message:`Internal error: ${l instanceof Error?l.message:String(l)}`}}}c!==null&&t(JSON.stringify(c)+`
|
|
711
|
-
`)}}a(UEe,"runStdioServer");function gq(r){return new pe("mcp").description("Run an MCP (Model Context Protocol) stdio server exposing create_asset / create_effort tools backed by this CLI").option("--entry <path>","Path to the CLI entry script the tools invoke (defaults to this process's script)").action(async e=>{let t=e.entry??process.argv[1],n=new dv({runCli:hq(t),version:r??"unknown"});await UEe(n,process.stdin,i=>process.stdout.write(i))})}a(gq,"mcpCommand");function pv(r){let e=new pe;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(r??"17.5.
|
|
711
|
+
`)}}a(UEe,"runStdioServer");function gq(r){return new pe("mcp").description("Run an MCP (Model Context Protocol) stdio server exposing create_asset / create_effort tools backed by this CLI").option("--entry <path>","Path to the CLI entry script the tools invoke (defaults to this process's script)").action(async e=>{let t=e.entry??process.argv[1],n=new dv({runCli:hq(t),version:r??"unknown"});await UEe(n,process.stdin,i=>process.stdout.write(i))})}a(gq,"mcpCommand");function pv(r){let e=new pe;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(r??"17.5.9"),e.addCommand($V()),e.addCommand(YV()),e.addCommand(S7()),e.addCommand(T7()),e.addCommand(W7()),e.addCommand(A7()),e.addCommand(O7()),e.addCommand(P7()),e.addCommand(Z7()),e.addCommand(iV()),e.addCommand(vV()),e.addCommand(CV()),e.addCommand(FV()),e.addCommand(DV()),e.addCommand(NV()),e.addCommand(kV()),e.addCommand(bG()),e.addCommand(wG()),e.addCommand(HG()),e.addCommand(YG()),e.addCommand(JG()),e.addCommand(ZG()),e.addCommand(rq()),e.addCommand(kG()),e.addCommand(qG()),e.addCommand(nq()),e.addCommand(gq(r??"17.5.9")),e}a(pv,"createProgram");pv().parse();0&&(module.exports={createProgram});
|
|
712
712
|
/*! Bundled license information:
|
|
713
713
|
|
|
714
714
|
reflect-metadata/Reflect.js:
|