@kanonak-protocol/sdk 3.48.0 → 3.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/chunk-2WQR7OHH.js +116 -0
  3. package/dist/chunk-64TVBQFR.js +1 -0
  4. package/dist/chunk-DC774EQL.js +1 -0
  5. package/dist/chunk-GQQAXZDK.js +1 -0
  6. package/dist/chunk-H2LEQLVD.js +1 -0
  7. package/dist/{chunk-EIOMVL5H.js → chunk-IIODYDKS.js} +1 -1
  8. package/dist/chunk-IO5RBK3J.js +1 -0
  9. package/dist/{chunk-NIJV5UYW.js → chunk-KDJYZ2YM.js} +1 -1
  10. package/dist/chunk-N224PFBI.js +1 -0
  11. package/dist/chunk-PPORQS4M.js +59 -0
  12. package/dist/chunk-Q4DKP5DO.js +1 -0
  13. package/dist/chunk-XWKCX5ZS.js +2 -0
  14. package/dist/index.d.ts +4 -4
  15. package/dist/index.js +13 -13
  16. package/dist/look/LookRenderer.d.ts +10 -2
  17. package/dist/look/displayValue.d.ts +27 -0
  18. package/dist/look/index.d.ts +1 -0
  19. package/dist/parsing/KanonakObjectParser.d.ts +6 -0
  20. package/dist/parsing/index.js +1 -1
  21. package/dist/reasoning/KanonakVocabulary.d.ts +35 -8
  22. package/dist/reasoning/index.d.ts +1 -1
  23. package/dist/reasoning/index.js +1 -1
  24. package/dist/resolution/TypeDirectedResolver.d.ts +36 -0
  25. package/dist/resolution/index.d.ts +2 -0
  26. package/dist/resolution/index.js +1 -1
  27. package/dist/search/SearchIndex.d.ts +51 -0
  28. package/dist/search/index.d.ts +2 -0
  29. package/dist/search/index.js +6 -0
  30. package/dist/server/index.js +1 -1
  31. package/dist/transformations/index.js +1 -1
  32. package/dist/uri-helpers/index.js +1 -1
  33. package/dist/validation/index.d.ts +1 -1
  34. package/dist/validation/index.js +1 -1
  35. package/dist/validation/rules/repository/DisplayLensScopeRule.d.ts +27 -0
  36. package/dist/validation/rules/repository/index.d.ts +1 -0
  37. package/package.json +9 -2
  38. package/dist/chunk-2JQMUZWN.js +0 -1
  39. package/dist/chunk-4TJZIM7A.js +0 -1
  40. package/dist/chunk-FJ35VIV6.js +0 -1
  41. package/dist/chunk-FMYLEPMC.js +0 -1
  42. package/dist/chunk-HEMBMX7T.js +0 -1
  43. package/dist/chunk-IOJMTW4T.js +0 -1
  44. package/dist/chunk-KPLFNUIL.js +0 -116
  45. package/dist/chunk-RCI34BYO.js +0 -2
  46. package/dist/chunk-SKTXJV4T.js +0 -54
@@ -0,0 +1,36 @@
1
+ import type { Kanonak } from '../kanonaks/Kanonak.js';
2
+ import { SubjectKanonak } from '../kanonaks/SubjectKanonak.js';
3
+ import { KanonakUri } from './KanonakUri.js';
4
+ import { type EntityUri } from '../uri-helpers/index.js';
5
+ export type PropertyKind = 'object' | 'datatype' | 'other';
6
+ export interface PropertyDescriptor {
7
+ /** The property's canonical URI. */
8
+ uri: KanonakUri;
9
+ /** The property's rdfs.label, if declared. */
10
+ label: string | undefined;
11
+ /** ObjectProperty / DatatypeProperty / other, classified by URI. */
12
+ kind: PropertyKind;
13
+ /** The property's declared range, if any. */
14
+ range: KanonakUri | undefined;
15
+ }
16
+ /** Build a subject's canonical URI from its namespace + name. */
17
+ export declare function subjectUri(subject: SubjectKanonak): KanonakUri | undefined;
18
+ /**
19
+ * Every property in scope for a class — those whose `domain` is the
20
+ * class, an ancestor, or rdfs.Resource. Scans the catalog once. Powers
21
+ * completion and single-hop path-step validation.
22
+ */
23
+ export declare function propertiesInScope(catalog: Kanonak[], classUri: EntityUri): PropertyDescriptor[];
24
+ export interface StepResolution {
25
+ ok: boolean;
26
+ descriptor?: PropertyDescriptor;
27
+ message?: string;
28
+ }
29
+ /**
30
+ * Validate a single property step against a context class: is
31
+ * `propertyUri` a property in scope for `classUri`? Returns the
32
+ * descriptor on success, or a diagnostic message on failure.
33
+ */
34
+ export declare function resolvePropertyStep(catalog: Kanonak[], classUri: EntityUri, propertyUri: EntityUri): StepResolution;
35
+ /** The type URIs declared on an instance — the completion context. */
36
+ export declare function contextTypesOf(instance: SubjectKanonak): KanonakUri[];
@@ -8,6 +8,8 @@ export { KanonakUrlResolver } from './KanonakUrlResolver.js';
8
8
  export type { UrlAddress, PublisherUrlAddress, PackageUrlAddress, ResourceUrlAddress, VersionSpec, UrlForm, } from './KanonakUrlResolver.js';
9
9
  export type { ResourceResolutionResult } from './ResourceResolutionResult.js';
10
10
  export { TypeResolver } from './TypeResolver.js';
11
+ export { propertiesInScope, resolvePropertyStep, contextTypesOf, subjectUri, } from './TypeDirectedResolver.js';
12
+ export type { PropertyDescriptor, PropertyKind, StepResolution } from './TypeDirectedResolver.js';
11
13
  export { ResourceTypeClassifier } from './ResourceTypeClassifier.js';
12
14
  export { findInstancesByType } from './InstanceSearch.js';
13
15
  export type { InstanceSearchResult } from './InstanceSearch.js';
@@ -1 +1 @@
1
- import{a as l,b as m,c as n,d as o,e as q}from"../chunk-4TJZIM7A.js";import{a as p}from"../chunk-NIGFQYVA.js";import{a,b,c,d,e,f,g,h}from"../chunk-FQHALFRR.js";import{b as j,c as k}from"../chunk-HEMBMX7T.js";import{a as i}from"../chunk-FUUTGGJS.js";export{i as KanonakUri,m as KanonakUriBuilder,p as KanonakUrlResolver,j as ResourceResolver,l as ResourceTypeClassifier,k as TypeResolver,a as compareVersions,d as createVersion,q as findInstancesByType,o as formatKanonakAddress,c as formatVersion,f as isCompatibleVersion,g as isMajorCompatible,n as parseKanonakAddress,e as parseVersionString,h as pickHighestDocument,b as versionsEqual};
1
+ import{a as m,b as u}from"../chunk-DC774EQL.js";import{a as p}from"../chunk-NIGFQYVA.js";import{a as l,b as n,c as o,d as q,e as r,f as s,g as t}from"../chunk-N224PFBI.js";import"../chunk-Q4DKP5DO.js";import{a,b,c,d,e,f,g,h}from"../chunk-FQHALFRR.js";import{b as j,c as k}from"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import{a as i}from"../chunk-FUUTGGJS.js";export{i as KanonakUri,m as KanonakUriBuilder,p as KanonakUrlResolver,j as ResourceResolver,l as ResourceTypeClassifier,k as TypeResolver,a as compareVersions,t as contextTypesOf,d as createVersion,u as findInstancesByType,o as formatKanonakAddress,c as formatVersion,f as isCompatibleVersion,g as isMajorCompatible,n as parseKanonakAddress,e as parseVersionString,h as pickHighestDocument,r as propertiesInScope,s as resolvePropertyStep,q as subjectUri,b as versionsEqual};
@@ -0,0 +1,51 @@
1
+ import type { Kanonak } from '../kanonaks/index.js';
2
+ import { SubjectKanonak } from '../kanonaks/index.js';
3
+ export interface SearchHit {
4
+ /** The matched resource. */
5
+ subject: SubjectKanonak;
6
+ /** Cosine similarity (normalized embeddings), higher is more similar. */
7
+ score: number;
8
+ }
9
+ export interface BuildOptions {
10
+ /**
11
+ * Directory to persist/reuse the embedding cache. When set, an unchanged
12
+ * catalog reuses cached vectors instead of re-embedding. Defaults to
13
+ * `~/.kanonak/search` when `cache` is true.
14
+ */
15
+ cacheDir?: string;
16
+ }
17
+ export interface BuildResult {
18
+ /** Number of resources indexed. */
19
+ size: number;
20
+ /** Whether vectors were loaded from cache (true) or freshly embedded. */
21
+ cached: boolean;
22
+ }
23
+ /**
24
+ * The natural-language document indexed for a resource: its display label,
25
+ * its type's label ("a City", "a Framework"), and its summary — all via the
26
+ * object model, so search reads what a human reads, not raw YAML.
27
+ */
28
+ export declare function embedTextFor(catalog: Kanonak[], subject: SubjectKanonak): string;
29
+ export declare class SearchIndex {
30
+ private entries;
31
+ /** Number of indexed resources. */
32
+ get size(): number;
33
+ /**
34
+ * Embed every resource in the catalog (highest version per canonical URI),
35
+ * building the in-memory vector index. Loads the embedding runtime + model
36
+ * on first call. With `cacheDir`, unchanged catalogs reuse persisted
37
+ * vectors instead of re-embedding.
38
+ */
39
+ build(catalog: Kanonak[], opts?: BuildOptions): Promise<BuildResult>;
40
+ /**
41
+ * Rank indexed resources by similarity to `text`, descending.
42
+ *
43
+ * `scope` filters to resources whose namespace starts with the given
44
+ * prefix (e.g. `publisher/package@` for a package-scoped search, or
45
+ * `publisher/` for a publisher-scoped search). Omit to search everything.
46
+ */
47
+ query(text: string, opts?: {
48
+ scope?: string;
49
+ limit?: number;
50
+ }): Promise<SearchHit[]>;
51
+ }
@@ -0,0 +1,2 @@
1
+ export { SearchIndex, embedTextFor } from './SearchIndex.js';
2
+ export type { SearchHit, BuildOptions, BuildResult } from './SearchIndex.js';
@@ -0,0 +1,6 @@
1
+ import{a as d}from"../chunk-2WQR7OHH.js";import"../chunk-3NEUHF7E.js";import"../chunk-DC774EQL.js";import"../chunk-NIGFQYVA.js";import"../chunk-H2LEQLVD.js";import{d as c,g as x}from"../chunk-N224PFBI.js";import{a as h,f as j}from"../chunk-Q4DKP5DO.js";import{a as k}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{c as v}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{homedir as F}from"os";import{join as y}from"path";import{existsSync as E,mkdirSync as B,readFileSync as C,writeFileSync as O}from"fs";import{createHash as P}from"crypto";var p="Xenova/all-MiniLM-L6-v2",f=null;async function S(){return f||(f=(async()=>{let n;try{n=await import("@huggingface/transformers")}catch(i){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
2
+ Install it with:
3
+ npm install @huggingface/transformers
4
+ (underlying import error: ${i.message})`)}let{pipeline:t,env:r}=n;r.cacheDir=y(F(),".kanonak","models");let e=await t("feature-extraction",p);return async i=>(await e(i,{pooling:"mean",normalize:!0})).tolist()})()),f}function z(n,t){let r=0;for(let e=0;e<n.length;e++)r+=n[e]*t[e];return r}function D(n,t){return t?n.version?t.version?k(n.version,t.version)>0:!0:!1:!0}function K(n,t){let r=d(n,t),e=[r.label],i=x(t);if(i.length>0){let s=j(n,i[0]),o=s?d(n,s).label:i[0].name;o&&e.push(`\u2014 a ${o}.`)}return r.summary&&e.push(r.summary),e.join(" ")}function U(n){let t=new Map;for(let r of n){if(!(r instanceof v))continue;let e=c(r);if(!e)continue;let i=h(e),s=t.get(i);(!s||D(e,c(s)))&&t.set(i,r)}return[...t.values()].sort((r,e)=>{let i=c(r)?h(c(r)):r.name,s=c(e)?h(c(e)):e.name;return i.localeCompare(s)})}var b=class{entries=[];get size(){return this.entries.length}async build(t,r={}){let e=U(t);if(e.length===0)return this.entries=[],{size:0,cached:!1};let i=e.map(u=>K(t,u)),s=r.cacheDir,o;if(s){let u=P("sha256").update(p+`
5
+ `+i.join(`
6
+ `)).digest("hex").slice(0,32);o=y(s,`index-${u}.json`);let m=H(o);if(m&&m.model===p&&m.vectors.length===e.length)return this.entries=e.map((g,w)=>({subject:g,namespace:g.namespace||"",vector:m.vectors[w]})),{size:this.entries.length,cached:!0}}let l=await(await S())(i);return this.entries=e.map((u,m)=>({subject:u,namespace:u.namespace||"",vector:l[m]})),o&&M(o,{model:p,vectors:l}),{size:this.entries.length,cached:!1}}async query(t,r){if(this.entries.length===0)return[];let e=await S(),[i]=await e([t]),s=r?.scope;return this.entries.filter(a=>!s||a.namespace.startsWith(s)).map(a=>({subject:a.subject,score:z(i,a.vector)})).sort((a,l)=>l.score-a.score).slice(0,r?.limit??20)}};function H(n){try{return E(n)?JSON.parse(C(n,"utf-8")):null}catch{return null}}function M(n,t){try{B(y(n,".."),{recursive:!0}),O(n,JSON.stringify(t))}catch{}}export{b as SearchIndex,K as embedTextFor};
@@ -1,3 +1,3 @@
1
- import{b as O}from"../chunk-KPLFNUIL.js";import"../chunk-3NEUHF7E.js";import{a as P,d as _,f as F,g as N}from"../chunk-MOFATNEC.js";import{a as V,d as K}from"../chunk-VHUJSHH7.js";import{a as L}from"../chunk-NIGFQYVA.js";import{f as D}from"../chunk-FMYLEPMC.js";import{c as C}from"../chunk-W6T7MOKY.js";import{a as M}from"../chunk-7CUTGGH3.js";import{a as x,e as R}from"../chunk-FQHALFRR.js";import"../chunk-HEMBMX7T.js";import"../chunk-FUUTGGJS.js";import{readFileSync as B}from"fs";async function A(n,e={}){let a=new M,r=new V(a),c=[];for(let o of N(n)){let h;try{h=B(o,"utf-8")}catch{continue}let u;try{u=a.parse(h).metadata?.namespace_}catch{continue}if(!u?.version)continue;let v=u.version,w=`${v.major}.${v.minor}.${v.patch}`;await r.saveDocumentAsync(a.parse(h),`${u.publisher}/${u.package_}@${w}`),c.push({publisher:u.publisher,package_:u.package_,verStr:w,source:h})}let g=[...new Set(c.map(o=>o.publisher))].sort(),m=e.publisher;if(m){if(!g.includes(m))throw new Error(`Publisher "${m}" not found in workspace. Available: ${g.join(", ")||"(none)"}`)}else if(g.length===1)m=g[0];else throw g.length===0?new Error(`No Kanonak packages found under ${n}`):new Error(`Workspace has multiple publishers (${g.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let d=new Set,b=new Map;for(let o of c)o.publisher===m&&(d.add(`${o.publisher}/${o.package_}@${o.verStr}`),b.set(`${o.package_}@${o.verStr}`,o.source));let $=e.repository??new F(r,new P(_(),!0,a),new K(e.httpCache?{getFromCache:e.httpCache.getFromCache,onFetch:e.httpCache.onFetch}:void 0)),i=await new D(a).parseKanonaks($),s=new O(i),t=new Map,l=new Map,k=new Map,y=new Set;for(let o of i){if(!(o instanceof C))continue;let h=o.namespace||"";if(!d.has(h))continue;t.set(`${h}/${o.name}`,o);let u=h.split("/")[1]??"",[v,w]=u.split("@");if(!v||!w)continue;let j=R(w);j&&(y.has(u)||(y.add(u),l.has(v)||l.set(v,[]),l.get(v).push({verStr:w,version:j})),o.name===v&&k.set(u,o))}for(let o of l.values())o.sort((h,u)=>x(u.version,h.version));return{publisher:m,availablePublishers:g,catalog:i,lookRenderer:s,localNamespaces:d,rawByNsKey:b,bySubject:t,pkgVersions:l,pkgSelfByVer:k}}var p={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".md":"text/markdown; charset=utf-8",".kan.yml":"application/yaml; charset=utf-8",".txt":"text/plain; charset=utf-8",".json":"application/json; charset=utf-8"},f=(n,e,a,r)=>({status:n,headers:{"Content-Type":e,...r||{}},body:a}),S=n=>f(404,p[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${n}</p>`),I=n=>({status:301,headers:{Location:n},body:""});function E(n,e,a){let r=n.pkgVersions.get(e);if(!r||r.length===0)return null;switch(a.kind){case"any":return r[0].verStr;case"major-pin":return r.find(c=>c.version.major===a.major)?.verStr??null;case"minor-pin":return r.find(c=>c.version.major===a.major&&c.version.minor===a.minor)?.verStr??null;case"exact":return r.find(c=>c.version.major===a.major&&c.version.minor===a.minor&&c.version.patch===a.patch)?.verStr??null;default:return null}}function T(n,e,a=""){let{lookRenderer:r,publisher:c}=n;if(e==="/.well-known/kanonak.json")return f(200,p[".json"],JSON.stringify({version:1,auth:"none"},null,2));if(e==="/index.txt"){let s=[...n.localNamespaces].map(t=>t.split("/")[1].replace("@","/")).sort();return f(200,p[".txt"],s.join(`
1
+ import{c as O}from"../chunk-2WQR7OHH.js";import"../chunk-3NEUHF7E.js";import{a as P,d as _,f as F,g as N}from"../chunk-MOFATNEC.js";import{a as V,d as K}from"../chunk-VHUJSHH7.js";import{a as L}from"../chunk-NIGFQYVA.js";import{c as D}from"../chunk-IO5RBK3J.js";import"../chunk-H2LEQLVD.js";import{a as M}from"../chunk-7CUTGGH3.js";import"../chunk-Q4DKP5DO.js";import{a as x,e as R}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{c as C}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{readFileSync as B}from"fs";async function A(n,e={}){let a=new M,r=new V(a),c=[];for(let o of N(n)){let h;try{h=B(o,"utf-8")}catch{continue}let u;try{u=a.parse(h).metadata?.namespace_}catch{continue}if(!u?.version)continue;let v=u.version,w=`${v.major}.${v.minor}.${v.patch}`;await r.saveDocumentAsync(a.parse(h),`${u.publisher}/${u.package_}@${w}`),c.push({publisher:u.publisher,package_:u.package_,verStr:w,source:h})}let g=[...new Set(c.map(o=>o.publisher))].sort(),m=e.publisher;if(m){if(!g.includes(m))throw new Error(`Publisher "${m}" not found in workspace. Available: ${g.join(", ")||"(none)"}`)}else if(g.length===1)m=g[0];else throw g.length===0?new Error(`No Kanonak packages found under ${n}`):new Error(`Workspace has multiple publishers (${g.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let d=new Set,b=new Map;for(let o of c)o.publisher===m&&(d.add(`${o.publisher}/${o.package_}@${o.verStr}`),b.set(`${o.package_}@${o.verStr}`,o.source));let $=e.repository??new F(r,new P(_(),!0,a),new K(e.httpCache?{getFromCache:e.httpCache.getFromCache,onFetch:e.httpCache.onFetch}:void 0)),i=await new D(a).parseKanonaks($),s=new O(i),t=new Map,l=new Map,k=new Map,y=new Set;for(let o of i){if(!(o instanceof C))continue;let h=o.namespace||"";if(!d.has(h))continue;t.set(`${h}/${o.name}`,o);let u=h.split("/")[1]??"",[v,w]=u.split("@");if(!v||!w)continue;let j=R(w);j&&(y.has(u)||(y.add(u),l.has(v)||l.set(v,[]),l.get(v).push({verStr:w,version:j})),o.name===v&&k.set(u,o))}for(let o of l.values())o.sort((h,u)=>x(u.version,h.version));return{publisher:m,availablePublishers:g,catalog:i,lookRenderer:s,localNamespaces:d,rawByNsKey:b,bySubject:t,pkgVersions:l,pkgSelfByVer:k}}var p={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".md":"text/markdown; charset=utf-8",".kan.yml":"application/yaml; charset=utf-8",".txt":"text/plain; charset=utf-8",".json":"application/json; charset=utf-8"},f=(n,e,a,r)=>({status:n,headers:{"Content-Type":e,...r||{}},body:a}),S=n=>f(404,p[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${n}</p>`),I=n=>({status:301,headers:{Location:n},body:""});function E(n,e,a){let r=n.pkgVersions.get(e);if(!r||r.length===0)return null;switch(a.kind){case"any":return r[0].verStr;case"major-pin":return r.find(c=>c.version.major===a.major)?.verStr??null;case"minor-pin":return r.find(c=>c.version.major===a.major&&c.version.minor===a.minor)?.verStr??null;case"exact":return r.find(c=>c.version.major===a.major&&c.version.minor===a.minor&&c.version.patch===a.patch)?.verStr??null;default:return null}}function T(n,e,a=""){let{lookRenderer:r,publisher:c}=n;if(e==="/.well-known/kanonak.json")return f(200,p[".json"],JSON.stringify({version:1,auth:"none"},null,2));if(e==="/index.txt"){let s=[...n.localNamespaces].map(t=>t.split("/")[1].replace("@","/")).sort();return f(200,p[".txt"],s.join(`
2
2
  `)+`
3
3
  `)}if(e==="/"||e==="/index.html"||e==="/index.css"){let s=r.findPublisherRootView(c),t=[...n.pkgVersions.keys()].sort(),l=s??(t.length?n.pkgSelfByVer.get(`${t[0]}@${n.pkgVersions.get(t[0])[0].verStr}`):void 0);if(e==="/index.css")return f(200,p[".css"],s?r.renderStylesheet(s):r.renderPublisherIndexStylesheet(l));if(s)return f(200,p[".html"],r.renderDocument(s,{rootIndex:!0}));let k=t.map(y=>({label:y,href:`/${y}`}));return f(200,p[".html"],r.renderPublisherIndex(c,k,l))}let g=".html",m=!1,d=e;for(let s of[".kan.yml",".css",".svg",".md",".html"])if(e.endsWith(s)){g=s,m=!0,d=e.slice(0,-s.length);break}let b=!m&&/application\/yaml|text\/yaml/i.test(a),$=d.endsWith("/");$&&d!=="/"&&(d=d.slice(0,-1));let i=L.parse(d,c);if(!i)return S(e);if(i.kind==="package"){let s=E(n,i.package_,i.versionSpec);if(!s)return S(e);if(g===".kan.yml"||b){let k=n.rawByNsKey.get(`${i.package_}@${s}`);return k!==void 0?f(200,p[".kan.yml"],k):S(e)}let t=n.pkgSelfByVer.get(`${i.package_}@${s}`);if(!t)return S(e);if(g===".css")return f(200,p[".css"],r.renderStylesheet(t));if(!$)return I(d+"/");let l=i.versionSpec.kind==="any";if(l&&!r.hasDeclaredView(t)){let k=(n.pkgVersions.get(i.package_)||[]).map(y=>y.verStr);return f(200,p[".html"],r.renderPackageVersionList(i.package_,k,t))}return f(200,p[".html"],r.renderDocument(t,l?{bareOverview:!0}:void 0))}if(i.kind==="resource"){let s=E(n,i.package_,i.versionSpec);if(!s)return S(e);let t=n.bySubject.get(`${c}/${i.package_}@${s}/${i.name}`);if(!t)return S(e);switch(g){case".css":return f(200,p[".css"],r.renderStylesheet(t));case".svg":return f(200,p[".svg"],r.renderSvg(t));case".md":{let l=r.renderRawMarkdown(t);return l===void 0?S(e):f(200,p[".md"],l)}default:return f(200,p[".html"],r.renderDocument(t))}}return S(e)}export{A as loadServerModel,T as route};
@@ -1,4 +1,4 @@
1
- import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-KPLFNUIL.js";import{a as Ne}from"../chunk-EIOMVL5H.js";import"../chunk-3NEUHF7E.js";import"../chunk-NIJV5UYW.js";import"../chunk-NIGFQYVA.js";import{a as Oe}from"../chunk-FJ35VIV6.js";import{a as C,c as Ce,f as Ue}from"../chunk-FMYLEPMC.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import{a as Re}from"../chunk-7CUTGGH3.js";import{e as Le}from"../chunk-FQHALFRR.js";import"../chunk-HEMBMX7T.js";import"../chunk-FUUTGGJS.js";var yt="kanonak.org",kt="document-ast",m=t=>({publisher:yt,package_:kt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ie(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=ht(e.metadata,n),a=St(e.children),u=["---",...r,"---","",a].join(`
1
+ import{b as X,c as ye}from"../chunk-2WQR7OHH.js";import{a as Ne}from"../chunk-IIODYDKS.js";import"../chunk-3NEUHF7E.js";import"../chunk-KDJYZ2YM.js";import"../chunk-NIGFQYVA.js";import{c as Ue}from"../chunk-IO5RBK3J.js";import{a as C,c as Ce}from"../chunk-H2LEQLVD.js";import{a as Re}from"../chunk-7CUTGGH3.js";import{b as E,c as F,d as f,f as M,l as Oe}from"../chunk-Q4DKP5DO.js";import{e as Le}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";var yt="kanonak.org",kt="document-ast",m=t=>({publisher:yt,package_:kt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ie(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=ht(e.metadata,n),a=St(e.children),u=["---",...r,"---","",a].join(`
2
2
  `);return n?.trailingNewline&&(u.endsWith(`
3
3
  `)||(u+=`
4
4
  `)),u}};function ht(t,e){if(!t)return[];let n=new Map;for(let c of t.entries)n.set(ue(c.key),c);let r=new Map;if(e?.metadataRenames)for(let[c,l]of e.metadataRenames)r.set(ue(c),l);let i=(e?.metadataKeys??t.entries.map(c=>c.key)).map(ue),u=[];for(let c of i){let l=n.get(c);if(!l)continue;let p=r.get(c),y=ue(p??c),h=Me(l.value,l.escapeHint);h!==void 0&&u.push(`${y}: ${h}`)}return u}function ue(t){let e=t.lastIndexOf(".");return e===-1?t:t.substring(e+1)||t}function Me(t,e){switch(t.kind){case"StringScalar":return bt(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Me(r,e);a!==void 0&&n.push(a)}return n.join(", ")}case"StructuredMap":return;default:return}}function bt(t,e){return!e||Ie(e,k.ESC_RAW)?t:Ie(e,k.ESC_YAML_SAFE)?wt(t):t}function wt(t){return t.includes(`
@@ -1 +1 @@
1
- import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l}from"../chunk-2JQMUZWN.js";import{a}from"../chunk-FJ35VIV6.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{a as SingleDocumentRepository,g as findSubjectByUri,f as findSubjectsByType,h as getDatatypeValue,k as getEmbeddedValue,l as getListValues,j as getReferenceUri,i as getStringValue,e as hasType,d as toCanonicalUrl,b as uriKey,c as uriMatches};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l}from"../chunk-Q4DKP5DO.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{l as SingleDocumentRepository,f as findSubjectByUri,e as findSubjectsByType,g as getDatatypeValue,j as getEmbeddedValue,k as getListValues,i as getReferenceUri,h as getStringValue,d as hasType,c as toCanonicalUrl,a as uriKey,b as uriMatches};
@@ -8,4 +8,4 @@ export { KanonakObjectValidator } from './KanonakObjectValidator.js';
8
8
  export type { IDocumentValidationRule } from './rules/document/IDocumentValidationRule.js';
9
9
  export type { IRepositoryValidationRule } from './rules/repository/IRepositoryValidationRule.js';
10
10
  export { NamespacePrefixRule, ResourceNamingRule, PropertyTypeSpecificityRule, SubjectKanonakTypeRequiredRule } from './rules/document/index.js';
11
- export { ImportExistenceRule, UnresolvedReferenceRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, InstancePropertyReferenceRule, DefinitionPropertyReferenceRule, XsdImportRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyImportRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyValueTypeRule, ClassDefinitionRule, EmbeddedKanonakTypeRule, MarkdownLinkRule } from './rules/repository/index.js';
11
+ export { ImportExistenceRule, UnresolvedReferenceRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, InstancePropertyReferenceRule, DefinitionPropertyReferenceRule, XsdImportRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyImportRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyValueTypeRule, ClassDefinitionRule, EmbeddedKanonakTypeRule, MarkdownLinkRule, DisplayLensScopeRule } from './rules/repository/index.js';
@@ -1 +1 @@
1
- import{A,B,C,D,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-SKTXJV4T.js";import"../chunk-FJ35VIV6.js";import"../chunk-FMYLEPMC.js";import"../chunk-W6T7MOKY.js";import"../chunk-7CUTGGH3.js";import"../chunk-FQHALFRR.js";import"../chunk-HEMBMX7T.js";import"../chunk-FUUTGGJS.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,m as ClassHierarchyCycleRule,t as DefinitionPropertyReferenceRule,j as EmbeddedKanonakTypeRule,k as ImportExistenceRule,s as InstancePropertyReferenceRule,D as KanonakObjectValidator,C as MarkdownLinkRule,r as NamespaceImportCycleRule,f as NamespacePrefixRule,x as ObjectPropertyImportRule,y as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,z as PropertyDomainRule,n as PropertyHierarchyCycleRule,w as PropertyRangeReferenceRule,o as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,A as PropertyValueTypeRule,g as ResourceNamingRule,p as SubClassOfReferenceRule,q as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,l as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity,u as XsdImportRule};
1
+ import{A,B,C,D,E,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-PPORQS4M.js";import"../chunk-IO5RBK3J.js";import"../chunk-H2LEQLVD.js";import"../chunk-7CUTGGH3.js";import"../chunk-N224PFBI.js";import"../chunk-Q4DKP5DO.js";import"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,m as ClassHierarchyCycleRule,t as DefinitionPropertyReferenceRule,D as DisplayLensScopeRule,j as EmbeddedKanonakTypeRule,k as ImportExistenceRule,s as InstancePropertyReferenceRule,E as KanonakObjectValidator,C as MarkdownLinkRule,r as NamespaceImportCycleRule,f as NamespacePrefixRule,x as ObjectPropertyImportRule,y as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,z as PropertyDomainRule,n as PropertyHierarchyCycleRule,w as PropertyRangeReferenceRule,o as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,A as PropertyValueTypeRule,g as ResourceNamingRule,p as SubClassOfReferenceRule,q as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,l as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity,u as XsdImportRule};
@@ -0,0 +1,27 @@
1
+ import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
2
+ import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
3
+ import { OntologyValidationError } from '../../OntologyValidationError.js';
4
+ import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
5
+ import type { ValidationCache } from '../../ValidationCache.js';
6
+ /**
7
+ * Validates the display-value lens slots `look.displayLabel` /
8
+ * `look.displaySummary`. Their value names the property that supplies a
9
+ * resource's label/summary, so that property must be IN SCOPE for the
10
+ * declaring resource — its `domain` must be the class (or an ancestor,
11
+ * or rdfs.Resource). A value that resolves to a real property of some
12
+ * OTHER class would silently fall back to the resource's name at render
13
+ * time, which is exactly the kind of quiet failure the lens exists to
14
+ * prevent.
15
+ *
16
+ * Object-model rule: it reads the resolved `displayLabel`/`displaySummary`
17
+ * reference and checks it through the SDK's `resolvePropertyStep` (the
18
+ * same type-directed engine behind completion), rather than re-scanning
19
+ * raw `document.body`. Mirrors `MarkdownLinkRule`'s use of the cache's
20
+ * full-repo parse.
21
+ */
22
+ export declare class DisplayLensScopeRule implements IRepositoryValidationRule {
23
+ readonly ruleName = "DisplayLensScope";
24
+ validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
25
+ private checkLens;
26
+ private scopeError;
27
+ }
@@ -19,3 +19,4 @@ export { PropertyValueTypeRule } from './PropertyValueTypeRule.js';
19
19
  export { ClassDefinitionRule } from './ClassDefinitionRule.js';
20
20
  export { EmbeddedKanonakTypeRule } from './EmbeddedKanonakTypeRule.js';
21
21
  export { MarkdownLinkRule } from './MarkdownLinkRule.js';
22
+ export { DisplayLensScopeRule } from './DisplayLensScopeRule.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/sdk",
3
- "version": "3.48.0",
3
+ "version": "3.50.0",
4
4
  "description": "Kanonak Protocol SDK - Document repository and parsing implementations for TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -82,6 +82,10 @@
82
82
  "types": "./dist/server/index.d.ts",
83
83
  "default": "./dist/server/index.js"
84
84
  },
85
+ "./search": {
86
+ "types": "./dist/search/index.d.ts",
87
+ "default": "./dist/search/index.js"
88
+ },
85
89
  "./browser": {
86
90
  "types": "./dist/browser.d.ts",
87
91
  "default": "./dist/browser.js"
@@ -117,11 +121,14 @@
117
121
  "yaml-parser"
118
122
  ],
119
123
  "dependencies": {
120
- "@kanonak-protocol/types": "^3.48.0",
124
+ "@kanonak-protocol/types": "^3.50.0",
121
125
  "ignore": "^7.0.5",
122
126
  "js-yaml": "^4.1.0",
123
127
  "yaml": "^2.7.0"
124
128
  },
129
+ "optionalDependencies": {
130
+ "@huggingface/transformers": "^3.8.1"
131
+ },
125
132
  "devDependencies": {
126
133
  "@types/jest": "^29.5.0",
127
134
  "@types/js-yaml": "^4.0.9",
@@ -1 +0,0 @@
1
- import{b as u,c as i,g as m,h as p,i as d,j as f,k as b,l as k}from"./chunk-W6T7MOKY.js";function y(n){return`${n.publisher}/${n.package_}/${n.name}`}function s(n,t){return n.publisher===t.publisher&&n.package_===t.package_&&n.name===t.name}function S(n){let t=n.version;return t&&typeof t.major=="number"?`https://${n.publisher}/${n.package_}/${t.major}.${t.minor}.${t.patch}/${n.name}`:`https://${n.publisher}/${n.package_}/${n.name}`}function l(n,t){if(!(n instanceof u))return!1;for(let e of n.statement)if(e.predicate?.subject?.name==="type"&&e instanceof f){let a=e.object;if(s(a.subject,t))return!0}return!1}function j(n,t){let e=[];for(let r of n)r instanceof i&&l(r,t)&&e.push(r);return e}function K(n,t){let e=t.version,r=e&&typeof e.major=="number"?`${t.publisher}/${t.package_}@${e.major}.${e.minor}.${e.patch}`:void 0;for(let a of n){if(!(a instanceof i)||a.name!==t.name)continue;let c=a.namespace||"";if(r!==void 0){if(c===r)return a}else if(c.startsWith(`${t.publisher}/${t.package_}@`))return a}}function o(n,t){for(let e of n.statement){let r=e.predicate;if(r?.subject&&s(r.subject,t))return e}}function g(n,t){let e=o(n,t);if(e&&(e instanceof m||e instanceof p||e instanceof d))return e.object}function U(n,t){let e=g(n,t);return typeof e=="string"?e:void 0}function h(n,t){let e=o(n,t);if(e instanceof f)return e.object.subject}function $(n,t){let e=o(n,t);if(e instanceof b)return e.object}function x(n,t){let e=o(n,t);return e instanceof k?e.object??[]:[]}export{y as a,s as b,S as c,l as d,j as e,K as f,g,U as h,h as i,$ as j,x as k};
@@ -1 +0,0 @@
1
- import{a as k}from"./chunk-FUUTGGJS.js";var m=class{resourceResolver;constructor(r){this.resourceResolver=r}async buildFromNameAsync(r,e){return(await this.resourceResolver.resolveEntityAsync(r,e))?.uri??null}buildFromName(r,e,t){if(r.includes(".")){let o=r.split("."),c=o[0],p=o[1],u=this.findPackageNameForAlias(t,c);if(u){for(let l of e.values())if(l.entityName===p&&l.uri.package_===u)return l.uri}return null}let a=e.get(r);return a?a.uri:null}create(r,e,t,a){return new k(r,e,t,a)}findPackageNameForAlias(r,e){if(!r.metadata.imports)return null;for(let[t,a]of Object.entries(r.metadata.imports))for(let o of a)if(o.alias===e||!o.alias&&o.packageName===e)return o.packageName;return null}};function h(n){if(!n||n.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let r=n.trim(),e=r.split("/");if(e.length===1){let t=e[0];if(!t)throw new Error(`Invalid Kanonak address: "${n}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(t.includes("@"))throw new Error(`Invalid Kanonak address: "${n}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:t}}if(e.length===2){let[t,a]=e;if(!t||!a)throw new Error(`Invalid Kanonak address: "${n}". Expected publisher/package[@version].`);let o=a.indexOf("@");if(o===-1)return{kind:"package",publisher:t,package_:a};let c=a.substring(0,o),p=a.substring(o+1);if(!c||!p)throw new Error(`Invalid Kanonak address: "${n}". Expected publisher/package[@version].`);let u=K(p);return{kind:"package",publisher:t,package_:c,version:u}}return{kind:"resource",uri:k.parse(r)}}function R(n){switch(n.kind){case"publisher":return n.publisher;case"package":return n.version?`${n.publisher}/${n.package_}@${n.version.major}.${n.version.minor}.${n.version.patch}`:`${n.publisher}/${n.package_}`;case"resource":return n.uri.toString()}}function K(n){let r=n.split(".").map(Number);return _(r[0]||0,r[1]||0,r[2]||0)}function _(n,r,e){return{major:n,minor:r,patch:e,toString:()=>`${n}.${r}.${e}`,equals:t=>!t||typeof t!="object"?!1:t.major===n&&t.minor===r&&t.patch===e,getHashCode:()=>n<<20|r<<10|e,compareTo:t=>n!==t.major?n-t.major:r!==t.minor?r-t.minor:e-t.patch}}var v=new Set(["kanonak.org/core-rdf","kanonak.org/core-rdfs","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]),b={Class:{publisher:"kanonak.org",package_:"core-owl"},ObjectProperty:{publisher:"kanonak.org",package_:"core-owl"},DatatypeProperty:{publisher:"kanonak.org",package_:"core-owl"},AnnotationProperty:{publisher:"kanonak.org",package_:"core-owl"},Property:{publisher:"kanonak.org",package_:"core-rdf"},Datatype:{publisher:"kanonak.org",package_:"core-rdfs"},Resource:{publisher:"kanonak.org",package_:"core-rdfs"},Literal:{publisher:"kanonak.org",package_:"core-rdfs"},Thing:{publisher:"kanonak.org",package_:"core-owl"},Nothing:{publisher:"kanonak.org",package_:"core-owl"}};function s(n){let r=n;if(r.entity&&typeof r.entity=="object"){let e=r.entity.type;if(typeof e=="string"){let t=b[e];return t?{publisher:t.publisher,package_:t.package_,name:e}:{publisher:"",package_:"",name:e}}}if(r.statement&&Array.isArray(r.statement)){for(let e of r.statement)if(e.predicate?.subject?.name==="type"&&e.object?.subject){let t=e.object.subject;if(!t.publisher&&!t.package_||t.publisher===""&&t.package_===""){let a=b[t.name];if(a)return{publisher:a.publisher,package_:a.package_,name:t.name}}return t}}return null}function i(n,r){return v.has(`${n}/${r}`)}var y=class n{static getTypeUri(r){return s(r)}static isCoreOntologyType(r){return i(r.publisher,r.package_)}static isClassType(r){let e=s(r);return e?i(e.publisher,e.package_)&&e.name==="Class":!1}static isDatatypeType(r){let e=s(r);return e?i(e.publisher,e.package_)&&e.name==="Datatype":!1}static isDatatypePropertyType(r){let e=s(r);return e?i(e.publisher,e.package_)&&e.name==="DatatypeProperty":!1}static isObjectPropertyType(r){let e=s(r);return e?i(e.publisher,e.package_)&&e.name==="ObjectProperty":!1}static isAnnotationPropertyType(r){let e=s(r);return e?i(e.publisher,e.package_)&&e.name==="AnnotationProperty":!1}static isGenericPropertyType(r){let e=s(r);return e?i(e.publisher,e.package_)&&e.name==="Property":!1}static isAnyPropertyType(r){let e=s(r);return!e||!i(e.publisher,e.package_)?!1:e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"}static isSchemaDefinitionType(r){let e=s(r);return!e||!i(e.publisher,e.package_)?!1:e.name==="Class"||e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"||e.name==="Datatype"}static isInstanceOfKnownClass(r,e){if(n.isSchemaDefinitionType(r))return!1;let t=s(r);return t?e.has(t.name):!1}};async function j(n,r){let e=[],t=await n.getAllDocumentsAsync();for(let a of t){let o=a.metadata.namespace_;if(!o)continue;let c=o.publisher,p=o.package_,u=o.version?`${o.version.major}.${o.version.minor}.${o.version.patch}`:"0.0.0";for(let[l,g]of Object.entries(a.body)){if(!g||typeof g!="object")continue;let f=g.type;!f||typeof f!="string"||f!=="Package"&&P(f,r)&&e.push({entityName:l,entity:g,documentNamespace:`${c}/${p}@${u}`,publisher:c,package_:p,version:u})}}return e}function P(n,r){let e=d(n),t=d(r);return e===t}function d(n){let r=n.lastIndexOf(".");if(r!==-1)return n.substring(r+1);let e=n.lastIndexOf("/");return e!==-1?n.substring(e+1):n}export{y as a,m as b,h as c,R as d,j as e};
@@ -1 +0,0 @@
1
- var o=class{constructor(e,n){this.doc=e;this.broader=n}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(e){return this.broader.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,n){return this.broader.getDocumentsByNamespaceAsync(e,n)}async getHighestCompatibleVersionAsync(e,n){return this.broader.getHighestCompatibleVersionAsync(e,n)}async saveDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async deleteDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async clearNamespaceAsync(){throw new Error("SingleDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}async getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}};export{o as a};
@@ -1 +0,0 @@
1
- import{a as M,b as T,c as w,d,g,h as P,i as S,j as D,k as K,l as j}from"./chunk-W6T7MOKY.js";import{a as I}from"./chunk-7CUTGGH3.js";import{b as x,c as A}from"./chunk-HEMBMX7T.js";var k=class extends T{name};var h=class extends M{value};var R=class extends g{links=[]};var N=/\[\[([^\[\]\n]+)\]\]/g,V=/\[\[/g,E=/```[\s\S]*?```|`[^`\n]*`/g;function _(u){let e=[];for(let t of u.matchAll(E))e.push([t.index,t.index+t[0].length]);return e}function q(u){if(!u||!u.includes("[["))return[];let e=_(u),t=o=>e.some(([n,a])=>o>=n&&o<a),s=new Set(O(u).map(o=>o.startOffset)),r=[];for(let o of u.matchAll(V)){let n=o.index;if(t(n)||s.has(n))continue;let a=u.slice(n,n+48).replace(/\s+/g," ").trim();r.push({startOffset:n,snippet:a})}return r}function O(u){if(!u||!u.includes("[["))return[];let e=[];for(let r of u.matchAll(E))e.push([r.index,r.index+r[0].length]);let t=r=>e.some(([o,n])=>r>=o&&r<n),s=[];for(let r of u.matchAll(N)){let o=r.index;if(t(o))continue;let n=r[1],a=n.indexOf("|"),i=(a===-1?n:n.slice(0,a)).trim();if(i.length===0)continue;let p=a===-1?"":n.slice(a+1).trim(),c={reference:i,startOffset:o,endOffset:o+r[0].length};p.length>0&&(c.displayText=p),s.push(c)}return s}var v=class{constructor(e){}async parseKanonaks(e){let t=[],s=await e.getAllDocumentsAsync(),r=new x(e),o=new A(r);for(let i of s){let p=i.metadata.namespace_?.toString()??"";for(let[c,m]of Object.entries(i.body)){let f=new w,l=this.resolveCanonicalEntity(c,i,p);f.namespace=l.namespace,f.name=l.name,f.statement=[];let y=await this.parseStatements(m,i,r,o,e);f.statement.push(...y),t.push(f)}}let n=new Map,a=[];for(let i of t)if(i instanceof w){let p=`${i.namespace}/${i.name}`,c=n.get(p);c?c.statement.push(...i.statement):(n.set(p,i),a.push(i))}else a.push(i);return a}resolveCanonicalEntity(e,t,s){if(!e.includes(".")||!t.metadata?.imports)return{namespace:s,name:e};let r=e.indexOf("."),o=e.substring(0,r),n=e.substring(r+1);for(let[a,i]of Object.entries(t.metadata.imports))for(let p of i)if((p.alias??p.packageName)===o){let m=p.version;return{namespace:`${a}/${p.packageName}@${m.major}.${m.minor}.${m.patch}`,name:n}}return{namespace:s,name:e}}async parseStatements(e,t,s,r,o){let n=[];if(typeof e!="object"||e===null||Array.isArray(e))return n;for(let[a,i]of Object.entries(e))try{let p=await this.getPropertyMetadata(a,t,s,o,r);if(!p)continue;let c=await this.parsePropertyValue(a,i,p,t,s,r);c&&n.push(c)}catch(p){console.error(`Error parsing property ${a}:`,p)}return n}async getPropertyMetadata(e,t,s,r,o){let n=await s.resolveEntityAsync(e,t);if(!n)return;let a=n.entity,i=a.type?.toString()??"",p=i.includes(".")?i.substring(i.lastIndexOf(".")+1):i;if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(p))return;let m=o.getPropertyTypeClassification(i),f=a.range?.toString(),l;if(m==="ObjectProperty")l="ObjectProperty";else if(m==="DatatypeProperty")l="DatatypeProperty";else{let b=f&&f.includes(".")?f.substring(f.lastIndexOf(".")+1):f??"";(f?o.isKnownXsdDatatypeName(f):!1)||b==="Literal"?l="DatatypeProperty":l="ObjectProperty"}let y;return f&&(y=(await s.resolveEntityAsync(f,t))?.uri),{propertyUri:n.uri.toString(),propertyType:l,range:f,rangeUri:y,isImported:n.isImported,definedInNamespace:n.definedInNamespace}}async parsePropertyValue(e,t,s,r,o,n){let a=s.propertyUri;if(t!=null){if(Array.isArray(t))return this.parseListValue(a,t,s,r,o,n);if(s.propertyType==="DatatypeProperty")return this.parseDatatypeValue(a,t,s,r,o,n);if(s.propertyType==="ObjectProperty")return this.parseObjectValue(a,t,s,r,o,n)}}async parseDatatypeValue(e,t,s,r,o,n){if(t instanceof Date)return g.parse(e,t.toISOString());if(typeof t=="string")return n.isSubstitutableDatatype(s.rangeUri)?await this.parseSubstitutableValue(e,t,r,o):g.parse(e,t);if(typeof t=="number")return P.parse(e,t);if(typeof t=="boolean"){let a=new S;return a.predicate=d.parse(e),a.object=t,a}}async parseSubstitutableValue(e,t,s,r){let o=new R;o.predicate=d.parse(e),o.object=t;for(let n of O(t)){let a=await r.resolveEntityAsync(n.reference,s),i;a&&(i=new d,i.subject=a.uri);let p={reference:n.reference,startOffset:n.startOffset,endOffset:n.endOffset};n.displayText!==void 0&&(p.displayText=n.displayText),i!==void 0&&(p.target=i),o.links.push(p)}return o}async parseObjectValue(e,t,s,r,o,n){if(typeof t=="string"){let a=await this.resolveReference(t,r,o);if(!a)return;let i=new D;return i.predicate=d.parse(e),i.object=a,i}if(typeof t=="object"&&!Array.isArray(t)){let a=new k;if(a.statement=await this.parseStatements(t,r,o,n,{}),a.statement.length>0){let c=new K;return c.predicate=d.parse(e),c.object=a,c}let i=[];for(let[c,m]of Object.entries(t))if(typeof m=="object"&&m!==null&&!Array.isArray(m)){let f=new k;f.name=c,f.statement=await this.parseStatements(m,r,o,n,{}),i.push(f)}else if(typeof m=="string"){let f=await this.resolveReference(m,r,o);f&&i.push(f)}if(i.length>0){let c=new j;return c.predicate=d.parse(e),c.object=i,c}let p=new K;return p.predicate=d.parse(e),p.object=a,p}}async parseListValue(e,t,s,r,o,n){let a=[],i=s.propertyType==="DatatypeProperty";for(let c of t){if(i&&(typeof c=="string"||typeof c=="number"||typeof c=="boolean")){let m=new h;m.value=c,a.push(m);continue}if(i&&c instanceof Date){let m=new h;m.value=c.toISOString(),a.push(m);continue}if(typeof c=="string"){let m=await this.resolveReference(c,r,o);m&&a.push(m)}else if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let m=new k;m.statement=await this.parseStatements(c,r,o,n,{}),a.push(m)}}let p=new j;return p.predicate=d.parse(e),p.object=a,p}async resolveReference(e,t,s){let r=await s.resolveEntityAsync(e,t);if(r){let n=new d;return n.subject=r.uri,n}let o=t.metadata?.namespace_;if(o){let{KanonakUri:n}=await import("./KanonakUri-4VJGV3FN.js"),a=o.version??{major:0,minor:0,patch:0,toString:()=>"0.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};if(e.includes(".")){let p=e.indexOf("."),c=e.substring(0,p),m=e.substring(p+1);if(t.metadata?.imports){for(let[f,l]of Object.entries(t.metadata.imports))for(let y of l)if((y.alias??y.packageName)===c){let b=new d;return b.subject=new n(f,y.packageName,m,y.version),b}}}let i=new d;return i.subject=new n(o.publisher,o.package_,e,a),i}return null}async saveKanonaks(e,t){let s=new Map;for(let r of e)r instanceof w&&r.namespace&&(s.has(r.namespace)||s.set(r.namespace,[]),s.get(r.namespace).push(r));for(let[r,o]of s){let n=await this.convertKanonaksToDocument(r,o),a=`${r.split("@")[0]}.yml`;await t.saveDocumentAsync(n,a)}}async serializeToYaml(e,t){let s=e.filter(n=>n instanceof w&&n.namespace===t);if(s.length===0)throw new Error(`No kanonaks found with namespace '${t}'`);let r=await this.convertKanonaksToDocument(t,s);return new I().save(r)}async convertKanonaksToDocument(e,t){let r={metadata:{namespace_:e,get allImports(){if(!this.imports)return[];let n=[];for(let a of Object.values(this.imports))n.push(...a);return n}},body:{}},o=new Map;for(let n of t){let a={};for(let i of n.statement){let[p,c]=this.convertStatementToProperty(i);p&&c!==null&&c!==void 0&&(a[p]=c),this.collectImportsFromStatement(i,e,o)}r.body[n.name]=a}return r}convertStatementToProperty(e){if(e instanceof g)return[e.predicate.subject.name,e.object];if(e instanceof P)return[e.predicate.subject.name,e.object];if(e instanceof S)return[e.predicate.subject.name,e.object];if(e instanceof D)return[e.predicate.subject.name,e.object.subject.name];if(e instanceof j){let t=this.convertKanonakListToValue(e.object);return[e.predicate.subject.name,t]}else if(e instanceof K){let t=this.convertEmbeddedKanonakToValue(e.object);return[e.predicate.subject.name,t]}return[null,null]}convertKanonakListToValue(e){let t=[];for(let s of e)s instanceof d?t.push(s.subject.name):s instanceof k&&t.push(this.convertEmbeddedKanonakToValue(s));return t}convertEmbeddedKanonakToValue(e){let t={};for(let s of e.statement){let[r,o]=this.convertStatementToProperty(s);r&&o!==null&&o!==void 0&&(t[r]=o)}return t}collectImportsFromStatement(e,t,s){}};export{k as a,h as b,R as c,q as d,O as e,v as f};
@@ -1 +0,0 @@
1
- import{a as k}from"./chunk-FUUTGGJS.js";function R(d){if(Array.isArray(d))return d.map(t=>t?.toString()??"").filter(t=>t.length>0);let e=d?.toString();return e?[e]:[]}var A=class{cache=new Map;repository;logger;constructor(e,t){this.repository=e,this.logger=t}async resolveEntityAsync(e,t){let s=t.metadata?.namespace_?.toString()??"unknown",n=this.cache.get(s);if(n){let a=n.get(e);if(a)return a}let r=await this.buildEntityIndexAsyncInternal(t,new Set,"");return this.cache.set(s,r),r.get(e)??null}async resolveAllEntitiesAsync(e,t){let s=await this.buildAllEntitiesIndexAsync(t,new Set,"");if(e.includes(".")){let n=e.split("."),r=n[0],a=n[1],c=await this.findDocumentForAlias(t,r);return c?await this.resolveAllEntitiesAsync(a,c):[]}return s.filter(n=>n.entityName===e)}async buildAllEntitiesIndexAsync(e,t,s){let n=[],r=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${r}`),t.has(r))return this.logger?.debug?.(`Skipping ${r} - already visited (circular import prevention)`),n;t.add(r);let a=s.length===0?r:`${s} \u2192 ${r}`;for(let[c,o]of Object.entries(e.body))if(!c.includes(".")&&o&&typeof o=="object"&&!Array.isArray(o)){let i=e.metadata.namespace_?.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};n.push({entityName:c,uri:new k(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,c,i),entity:o,definedInNamespace:r,isImported:s.length>0,importPath:a})}if(this.logger?.debug?.(`Collected ${n.length} entities from ${r}`),e.metadata?.imports){let c=Object.values(e.metadata.imports).reduce((o,i)=>o+i.length,0);this.logger?.debug?.(`Processing ${c} import(s) for ${r}`);for(let[o,i]of Object.entries(e.metadata.imports))for(let g of i)try{this.logger?.debug?.(`Resolving import: ${o}/${g.packageName}`);let l=await this.repository.getHighestCompatibleVersionAsync(o,g);if(l){this.logger?.debug?.(`Successfully loaded import: ${l.metadata?.namespace_?.toString()}`);let u=await this.buildAllEntitiesIndexAsync(l,t,a);n.push(...u),this.logger?.debug?.(`Added ${u.length} entities from import ${l.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${o}/${g.packageName}`)}catch(l){let u=l;throw this.logger?.error?.(`Failed to process import ${o}/${g.packageName} for namespace ${r}. Error: ${u.message}`,u),new Error(`Failed to process import ${o}/${g.packageName} for namespace ${r}. See inner exception for details.`,{cause:l})}}return n}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"")}async buildEntityIndexAsyncInternal(e,t,s){let n=new Map,r=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${r}`),t.has(r))return this.logger?.debug?.(`Skipping ${r} - already visited (circular import prevention)`),n;t.add(r);let a=s.length===0?r:`${s} \u2192 ${r}`,c=0;for(let[o,i]of Object.entries(e.body))if(!o.includes(".")&&i&&typeof i=="object"&&!Array.isArray(i)&&!n.has(o)){let g=e.metadata.namespace_?.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};n.set(o,{entityName:o,uri:new k(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,o,g),entity:i,definedInNamespace:r,isImported:s.length>0,importPath:a}),c++}if(this.logger?.debug?.(`Indexed ${c} entities from ${r}`),e.metadata?.imports){let o=Object.values(e.metadata.imports).reduce((i,g)=>i+g.length,0);this.logger?.debug?.(`Processing ${o} import(s) for ${r}`);for(let[i,g]of Object.entries(e.metadata.imports))for(let l of g)try{this.logger?.debug?.(`Resolving import: ${i}/${l.packageName}`);let u=await this.repository.getHighestCompatibleVersionAsync(i,l);if(u){this.logger?.debug?.(`Successfully loaded import: ${u.metadata?.namespace_?.toString()}`);let h=await this.buildEntityIndexAsyncInternal(u,t,a),b=0;for(let[y,m]of h.entries()){let p=n.get(y);if(!p)n.set(y,m),b++;else if(p.isImported&&m.isImported&&(p.uri.publisher!==m.uri.publisher||p.uri.package_!==m.uri.package_)){let f=p.isAmbiguous?p:{...p,isAmbiguous:!0,ambiguousNamespaces:[p.definedInNamespace]};f.ambiguousNamespaces.includes(m.definedInNamespace)||f.ambiguousNamespaces.push(m.definedInNamespace),n.set(y,f),this.logger?.warn?.(`Ambiguous reference '${y}': defined in ${f.ambiguousNamespaces.join(", ")}`)}if(l.alias&&!y.includes(".")){let f=`${l.alias}.${y}`;n.has(f)||(n.set(f,m),b++)}}this.logger?.debug?.(`Merged ${b} entities from import ${u.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${i}/${l.packageName}`)}catch(u){let h=u;throw this.logger?.error?.(`Failed to process import ${i}/${l.packageName} for namespace ${r}. Error: ${h.message}`,h),new Error(`Failed to process import ${i}/${l.packageName} for namespace ${r}. See inner exception for details.`,{cause:u})}}return n}async findDocumentForAlias(e,t){if(!e.metadata?.imports)return null;for(let[s,n]of Object.entries(e.metadata.imports))for(let r of n){if(r.alias===t)return await this.repository.getHighestCompatibleVersionAsync(s,r);if(!r.alias&&r.packageName===t)return await this.repository.getHighestCompatibleVersionAsync(s,r)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}async isSubclassOfAsync(e,t,s){if(e===t)return!0;let n=new Set;return await this.isSubclassOfRecursiveAsync(e,t,s,n)}async isSubclassOfRecursiveAsync(e,t,s,n){if(n.has(e))return!1;n.add(e);let r=await this.resolveEntityAsync(e,s);if(!r?.entity)return!1;let a=r.entity.subClassOf;if(a){let c=R(a);for(let o of c)if(o===t||await this.isSubclassOfRecursiveAsync(o,t,s,n))return!0}return!1}async isSubpropertyOfAsync(e,t,s){if(e===t)return!0;let n=new Set;return await this.isSubpropertyOfRecursiveAsync(e,t,s,n)}async isSubpropertyOfRecursiveAsync(e,t,s,n){if(n.has(e))return!1;n.add(e);let r=await this.resolveEntityAsync(e,s);if(!r?.entity)return!1;let a=r.entity.subPropertyOf;if(a){let c=R(a);for(let o of c)if(o===t||await this.isSubpropertyOfRecursiveAsync(o,t,s,n))return!0}return!1}};var w=class d{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","bool","decimal","float","double","date","datetime","time","duration","anyuri","base64binary","hexbinary","long","short","byte","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte"]);resourceResolver;constructor(e){this.resourceResolver=e}isXsdDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-xsd"&&d.KNOWN_XSD_DATATYPES.has(e.name.toLowerCase()):!1}isLiteralType(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Literal":!1}isMarkdownDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&e.name==="Markdown":!1}isSubstitutableDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let t=e.includes(".")?e.split(".")[1]:e;return d.KNOWN_XSD_DATATYPES.has(t.toLowerCase())}async isClassTypeAsync(e,t){if(this.isKnownXsdDatatypeName(e))return!1;let s=await this.resourceResolver.resolveEntityAsync(e,t);if(s){let n=s.entity.type;if(n){let r=String(n);return r==="Class"||r==="rdfs.Class"||r.endsWith(".Class")}}return!0}getPropertyTypeClassification(e){if(!e||e.trim().length===0)return"Property";switch(e.includes(".")?e.split(".")[1]:e){case"DatatypeProperty":return"DatatypeProperty";case"ObjectProperty":return"ObjectProperty";case"AnnotationProperty":return"AnnotationProperty";case"Property":return"Property";default:return"Property"}}isEffectiveDatatypeProperty(e,t){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(t)||e==="Property"&&this.isLiteralType(t))}isEffectiveObjectProperty(e,t){return!!(e==="ObjectProperty"||e==="Property"&&t&&!this.isXsdDatatype(t)&&!this.isLiteralType(t))}};export{R as a,A as b,w as c};
@@ -1 +0,0 @@
1
- import{a as S,b as j,f as w}from"./chunk-FMYLEPMC.js";import{c as x,d as g,g as T,h as I,i as v,j as $,k as q,l as L}from"./chunk-W6T7MOKY.js";function u(t){return`${t.publisher}/${t.package_}/${t.name}`}function c(t,e,r){return`${t}/${e}/${r}`}function k(t){return`${t.s}|${t.p}|${P(t.o)}`}function P(t){switch(t.kind){case"uri":return`u:${t.key}`;case"literal":return`l:${t.datatype}:${t.lexical}`;case"blank":return`b:${t.id}`}}function s(t,e,r){return{s:t,p:e,o:{kind:"uri",key:r}}}var y=class{all=new Set;byPIdx=new Map;bySPIdx=new Map;byPOIdx=new Map;tripleList=[];add(e){let r=k(e);return this.all.has(r)?!1:(this.all.add(r),this.tripleList.push(e),h(this.byPIdx,e.p,e),h(this.bySPIdx,`${e.s}|${e.p}`,e),e.o.kind==="uri"&&h(this.byPOIdx,`${e.p}|${e.o.key}`,e),!0)}has(e){return this.all.has(k(e))}size(){return this.tripleList.length}snapshot(){return this.tripleList.slice()}byPredicate(e){let r=this.byPIdx.get(e);return r?r.slice():[]}bySubjectPredicate(e,r){let o=this.bySPIdx.get(`${e}|${r}`);return o?o.slice():[]}byPredicateObject(e,r){let o=this.byPOIdx.get(`${e}|${r}`);return o?o.slice():[]}subjectsWithPredicateObject(e,r){let o=this.byPOIdx.get(`${e}|${r}`);if(!o)return[];let i=new Set;for(let a of o)i.add(a.s);return Array.from(i)}uriObjectsOf(e,r){let o=this.bySPIdx.get(`${e}|${r}`);if(!o)return[];let i=new Set;for(let a of o)a.o.kind==="uri"&&i.add(a.o.key);return Array.from(i)}hasUri(e,r,o){return this.all.has(`${e}|${r}|u:${o}`)}hasTriple(e,r,o){return this.all.has(`${e}|${r}|${P(o)}`)}};function h(t,e,r){let o=t.get(e);o?o.push(r):t.set(e,[r])}var d=class{type=c("kanonak.org","core-rdf","type");subClassOf=c("kanonak.org","core-rdf","subClassOf");subPropertyOf=c("kanonak.org","core-rdf","subPropertyOf");domain=c("kanonak.org","core-rdf","domain");range=c("kanonak.org","core-rdf","range");equivalentClass=c("kanonak.org","core-owl","equivalentClass");equivalentProperty=c("kanonak.org","core-owl","equivalentProperty");inverseOf=c("kanonak.org","core-owl","inverseOf");sameAs=c("kanonak.org","core-owl","sameAs");transitiveProperty=c("kanonak.org","core-owl","TransitiveProperty");symmetricProperty=c("kanonak.org","core-owl","SymmetricProperty")};var _={name:"rdfs2",apply(t,e){let r=!1;for(let o of t.byPredicate(e.domain)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.byPredicate(i))t.add(s(n.s,e.type,a))&&(r=!0)}return r}},E={name:"rdfs3",apply(t,e){let r=!1;for(let o of t.byPredicate(e.range)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.byPredicate(i))n.o.kind==="uri"&&t.add(s(n.o.key,e.type,a))&&(r=!0)}return r}},A={name:"rdfs5",apply(t,e){let r=!1;for(let o of t.byPredicate(e.subPropertyOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.bySubjectPredicate(a,e.subPropertyOf))n.o.kind==="uri"&&t.add(s(i,e.subPropertyOf,n.o.key))&&(r=!0)}return r}},V={name:"rdfs7",apply(t,e){let r=!1;for(let o of t.byPredicate(e.subPropertyOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicate(i)){let p={s:n.s,p:a,o:n.o};t.add(p)&&(r=!0)}}return r}},W={name:"rdfs9",apply(t,e){let r=!1;for(let o of t.byPredicate(e.subClassOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicateObject(e.type,i))t.add(s(n.s,e.type,a))&&(r=!0)}return r}},F={name:"rdfs11",apply(t,e){let r=!1;for(let o of t.byPredicate(e.subClassOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.bySubjectPredicate(a,e.subClassOf))n.o.kind==="uri"&&t.add(s(i,e.subClassOf,n.o.key))&&(r=!0)}return r}},K=[_,E,A,V,W,F];var N={name:"prp-trp",apply(t,e){let r=!1,o=t.subjectsWithPredicateObject(e.type,e.transitiveProperty);for(let i of o){let a=t.byPredicate(i);for(let n of a){if(n.o.kind!=="uri")continue;let p=n.o.key;for(let l of t.bySubjectPredicate(p,i))l.o.kind==="uri"&&n.s!==l.o.key&&t.add(s(n.s,i,l.o.key))&&(r=!0)}}return r}},D={name:"prp-symp",apply(t,e){let r=!1,o=t.subjectsWithPredicateObject(e.type,e.symmetricProperty);for(let i of o)for(let a of t.byPredicate(i))a.o.kind==="uri"&&t.add(s(a.o.key,i,a.s))&&(r=!0);return r}},M={name:"prp-inv1",apply(t,e){let r=!1;for(let o of t.byPredicate(e.inverseOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.byPredicate(i))n.o.kind==="uri"&&t.add(s(n.o.key,a,n.s))&&(r=!0)}return r}},z={name:"prp-inv2",apply(t,e){let r=!1;for(let o of t.byPredicate(e.inverseOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.byPredicate(a))n.o.kind==="uri"&&t.add(s(n.o.key,i,n.s))&&(r=!0)}return r}},B={name:"prp-eqp1",apply(t,e){let r=!1;for(let o of t.byPredicate(e.equivalentProperty)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicate(i))t.add({s:n.s,p:a,o:n.o})&&(r=!0)}return r}},G={name:"prp-eqp2",apply(t,e){let r=!1;for(let o of t.byPredicate(e.equivalentProperty)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicate(a))t.add({s:n.s,p:i,o:n.o})&&(r=!0)}return r}},H={name:"cax-eqc1",apply(t,e){let r=!1;for(let o of t.byPredicate(e.equivalentClass)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicateObject(e.type,i))t.add(s(n.s,e.type,a))&&(r=!0)}return r}},J={name:"cax-eqc2",apply(t,e){let r=!1;for(let o of t.byPredicate(e.equivalentClass)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicateObject(e.type,a))t.add(s(n.s,e.type,i))&&(r=!0)}return r}},Q={name:"eq-rep-s",apply(t,e){let r=!1;for(let o of t.byPredicate(e.sameAs)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a){for(let n of t.snapshot())n.s===i&&t.add({s:a,p:n.p,o:n.o})&&(r=!0);for(let n of t.snapshot())n.s===a&&t.add({s:i,p:n.p,o:n.o})&&(r=!0)}}return r}},X={name:"eq-rep-o",apply(t,e){let r=!1;for(let o of t.byPredicate(e.sameAs)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.snapshot())n.o.kind==="uri"&&(n.o.key===i?t.add(s(n.s,n.p,a))&&(r=!0):n.o.key===a&&t.add(s(n.s,n.p,i))&&(r=!0))}return r}},U=[N,D,M,z,B,G,H,J,Q,X];var m=class{constructor(e,r){this.store=e;this.vocabulary=r}store;vocabulary;getInstancesOfClass(e){let r=f(e);return this.store.subjectsWithPredicateObject(this.vocabulary.type,r)}getSubclasses(e){let r=f(e);return this.store.subjectsWithPredicateObject(this.vocabulary.subClassOf,r).filter(i=>i!==r)}getSuperclasses(e){let r=f(e);return this.store.uriObjectsOf(r,this.vocabulary.subClassOf).filter(o=>o!==r)}getTypesOfIndividual(e){return this.store.uriObjectsOf(f(e),this.vocabulary.type)}isInstanceOf(e,r){return this.store.hasUri(f(e),this.vocabulary.type,f(r))}triples(){return this.store.snapshot()}size(){return this.store.size()}};function f(t){return typeof t=="string"?t:c(t.publisher,t.package_,t.name)}var R=class{vocabulary;profile;maxIterations;constructor(e={}){this.vocabulary=e.vocabulary??new d,this.profile=e.profile??"owl-rl-classification",this.maxIterations=e.maxIterations??100}async reason(e){let r=new y,i=await new w().parseKanonaks(e),a=new O;for(let l of i)if(l instanceof x){let b=Y(l);if(!b)continue;for(let C of l.statement)this.emitStatement(b,C,r,a)}let n=[...K];this.profile==="owl-rl-classification"&&n.push(...U);let p=0;for(;p<this.maxIterations;){let l=!1;for(let b of n)b.apply(r,this.vocabulary)&&(l=!0);if(!l)break;p++}return new m(r,this.vocabulary)}emitStatement(e,r,o,i){let a=Z(r);if(a){if(r instanceof T){o.add({s:e,p:a,o:{kind:"literal",lexical:r.object,datatype:"string"}});return}if(r instanceof I){o.add({s:e,p:a,o:{kind:"literal",lexical:String(r.object),datatype:"number"}});return}if(r instanceof v){o.add({s:e,p:a,o:{kind:"literal",lexical:String(r.object),datatype:"boolean"}});return}if(r instanceof $){let n=u(r.object.subject);o.add(s(e,a,n));return}if(r instanceof q){let n=i.next();o.add({s:e,p:a,o:{kind:"blank",id:n}}),this.emitEmbedded(n,r.object,o,i);return}if(r instanceof L){for(let n of r.object??[])this.emitListItem(e,a,n,o,i);return}}}emitListItem(e,r,o,i,a){if(o instanceof g)i.add(s(e,r,u(o.subject)));else if(o instanceof S){let n=a.next();i.add({s:e,p:r,o:{kind:"blank",id:n}}),this.emitEmbedded(n,o,i,a)}else if(o instanceof j){let n=typeof o.value=="number"?"number":typeof o.value=="boolean"?"boolean":"string";i.add({s:e,p:r,o:{kind:"literal",lexical:String(o.value),datatype:n}})}}emitEmbedded(e,r,o,i){let a=`_:${e}`;for(let n of r.statement)this.emitStatement(a,n,o,i)}},O=class{counter=0;next(){return`b${this.counter++}`}};function Y(t){let e=t.namespace??"",r=e.indexOf("@"),o=r===-1?e:e.substring(0,r),i=o.indexOf("/");if(i===-1)return null;let a=o.substring(0,i),n=o.substring(i+1);return!a||!n||!t.name?null:c(a,n,t.name)}function Z(t){let e=t.predicate;return e?.subject?u(e.subject):null}export{u as a,c as b,k as c,s as d,y as e,d as f,K as g,U as h,m as i,R as j};