@kanonak-protocol/sdk 6.2.0 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/credentialConfig.d.ts +0 -2
- package/dist/browser.d.ts +3 -1
- package/dist/browser.js +1 -1
- package/dist/{chunk-ED35OFGD.js → chunk-5AMN6MW7.js} +1 -1
- package/dist/{chunk-7JBKOJB4.js → chunk-5ZRVFYCP.js} +1 -1
- package/dist/{chunk-ADSDFJUO.js → chunk-7TNZ7ICK.js} +1 -1
- package/dist/{chunk-VORVR5BZ.js → chunk-A224OOBZ.js} +1 -1
- package/dist/{chunk-A3HRXFVX.js → chunk-AAYMTPG7.js} +1 -1
- package/dist/{chunk-R4LVLXAC.js → chunk-BDTJIUS4.js} +1 -1
- package/dist/{chunk-GKIX3OD6.js → chunk-FB5QKDNM.js} +1 -1
- package/dist/chunk-GGK6A6QK.js +1 -0
- package/dist/{chunk-TYVZXABI.js → chunk-GXEKJFXG.js} +1 -1
- package/dist/{chunk-66GZUKYS.js → chunk-K76UUREI.js} +1 -1
- package/dist/{chunk-22DSABP6.js → chunk-LKJVNKCN.js} +1 -1
- package/dist/{chunk-EKD2ZLKQ.js → chunk-MSOUPUUB.js} +1 -1
- package/dist/chunk-PC3MYDGL.js +1 -0
- package/dist/{chunk-MWJSYONH.js → chunk-Q57XCPAQ.js} +1 -1
- package/dist/chunk-WXUMROTA.js +1 -0
- package/dist/{chunk-6VIUXP4N.js → chunk-WXXZOJ4O.js} +1 -1
- package/dist/{chunk-D2X6J77P.js → chunk-X4V6DEZL.js} +1 -1
- package/dist/chunk-Z2444SWM.js +2 -0
- package/dist/config/packageUrlTemplatesConfig.d.ts +22 -0
- package/dist/config/userConfig.d.ts +10 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.js +2 -2
- package/dist/lock/LockFile.d.ts +7 -0
- package/dist/lock/index.d.ts +1 -1
- package/dist/parsing/index.js +1 -1
- package/dist/producer/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/repositories/HttpKanonakDocumentRepository.d.ts +9 -7
- package/dist/repositories/PackageUrlTemplates.d.ts +37 -0
- package/dist/repositories/PublisherIndex.d.ts +37 -1
- package/dist/repositories/browser.js +1 -1
- package/dist/repositories/buildLocalFirstRepository.d.ts +5 -1
- package/dist/repositories/index.d.ts +2 -0
- package/dist/repositories/index.js +1 -1
- package/dist/resolution/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/index.js +5 -5
- package/dist/server/loadResourceModel.d.ts +3 -0
- package/dist/server/requestRouter.d.ts +3 -0
- package/dist/server/types.d.ts +8 -1
- package/dist/transformations/index.js +1 -1
- package/dist/uri-helpers/index.js +1 -1
- package/dist/validation/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-D4QGPMRW.js +0 -1
- package/dist/chunk-MD4CAJIO.js +0 -2
- package/dist/chunk-NUTHBBDZ.js +0 -1
- package/dist/chunk-QILEJIFU.js +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ServerModel, RouteResponse } from './types.js';
|
|
2
2
|
import type { AuthenticatedFetchFn } from '../auth/index.js';
|
|
3
|
+
import type { PackageUrlTemplates } from '../repositories/PackageUrlTemplates.js';
|
|
3
4
|
import type { KanonakAddress } from '../resolution/KanonakAddress.js';
|
|
4
5
|
export interface RequestRouterOptions {
|
|
5
6
|
/**
|
|
@@ -10,6 +11,8 @@ export interface RequestRouterOptions {
|
|
|
10
11
|
root?: string;
|
|
11
12
|
/** Authenticated fetch for remote publisher fetches (auth / testing). */
|
|
12
13
|
fetchFn?: AuthenticatedFetchFn;
|
|
14
|
+
/** The consumer's package URL templates (#130), forwarded to every model build. */
|
|
15
|
+
packageUrlTemplates?: PackageUrlTemplates;
|
|
13
16
|
/**
|
|
14
17
|
* Progress/observability sink, forwarded to every model build — narrates
|
|
15
18
|
* render-stack resolution (where each ambient look package came from, every
|
package/dist/server/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/documen
|
|
|
3
3
|
import type { Kanonak } from '../kanonaks/index.js';
|
|
4
4
|
import { SubjectKanonak } from '../kanonaks/index.js';
|
|
5
5
|
import type { LookRenderer } from '../look/index.js';
|
|
6
|
-
import type { HttpCacheHooks } from '../repositories/index.js';
|
|
6
|
+
import type { HttpCacheHooks, PackageUrlTemplates } from '../repositories/index.js';
|
|
7
7
|
import type { AuthenticatedFetchFn } from '../auth/index.js';
|
|
8
8
|
import type { IPackageProducer } from '../producer/index.js';
|
|
9
9
|
import type { RenderStackReport } from './renderStack.js';
|
|
@@ -102,6 +102,13 @@ export interface LoadServerModelOptions {
|
|
|
102
102
|
* `fetch`. Ignored when `repository` is supplied (the caller owns transport).
|
|
103
103
|
*/
|
|
104
104
|
fetchFn?: AuthenticatedFetchFn;
|
|
105
|
+
/**
|
|
106
|
+
* The consumer's package URL templates (#130): where the default stack and
|
|
107
|
+
* the render-stack fetch take package sources from, instead of where each
|
|
108
|
+
* publisher says. Ignored when `repository` is supplied, like `fetchFn`.
|
|
109
|
+
* The publisher's own served `kanonak.lock` is unaffected.
|
|
110
|
+
*/
|
|
111
|
+
packageUrlTemplates?: PackageUrlTemplates;
|
|
105
112
|
/**
|
|
106
113
|
* Progress/observability sink. When provided, model loading narrates what it
|
|
107
114
|
* is doing — workspace scan results, where each render-stack package
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as pe}from"../chunk-
|
|
1
|
+
import{a as pe}from"../chunk-5AMN6MW7.js";import"../chunk-FB5QKDNM.js";import{a as ve,b as M,c as Vn,n as X,o as Rn,p as vn,q as le,r as q,t as G}from"../chunk-GXEKJFXG.js";import"../chunk-QHABFCRC.js";import"../chunk-WXXZOJ4O.js";import{b as $n,c as Tn,d as Bn,e as xn,f as Un,k as fe}from"../chunk-LKJVNKCN.js";import{a as se}from"../chunk-5ZRVFYCP.js";import"../chunk-PEJALHXK.js";import{c as U}from"../chunk-WXUMROTA.js";import{b as Y,c as D,d as ce,e as E,f as ue,i as $,j as T,k as B,l as w,m as me,n as x,o as de,q as N,r as S,x as A}from"../chunk-PC3MYDGL.js";import"../chunk-F67UH4FD.js";import{g as ie}from"../chunk-GGK6A6QK.js";import"../chunk-FUUTGGJS.js";var Le="kanonak.org",Oe="document-ast",i=e=>({publisher:Le,package_:Oe,name:e}),m={Document:i("Document"),Block:i("Block"),Inline:i("Inline"),StructuredValue:i("StructuredValue"),Heading:i("Heading"),Paragraph:i("Paragraph"),RawBlock:i("RawBlock"),Text:i("Text"),StructuredMap:i("StructuredMap"),StructuredEntry:i("StructuredEntry"),StructuredList:i("StructuredList"),StringScalar:i("StringScalar"),IntegerScalar:i("IntegerScalar"),EscapeHint:i("EscapeHint"),MediaType:i("MediaType"),metadata:i("metadata"),children:i("children"),level:i("level"),inlines:i("inlines"),text:i("text"),entries:i("entries"),key:i("key"),value:i("value"),escapeHint:i("escapeHint"),items:i("items"),stringValue:i("stringValue"),integerValue:i("integerValue"),rawContent:i("rawContent"),mediaType:i("mediaType"),mimeType:i("mimeType"),ESC_RAW:i("esc-raw"),ESC_YAML_SAFE:i("esc-yaml-safe"),ESC_TOML_STRING:i("esc-toml-string"),ESC_TOML_MULTILINE:i("esc-toml-multiline"),ESC_JSON:i("esc-json"),ESC_DYNAMODB_BOOL:i("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:i("esc-dynamodb-number"),ESC_DYNAMODB_NULL:i("esc-dynamodb-null"),TEXT_PLAIN:i("text-plain"),TEXT_MARKDOWN:i("text-markdown"),TEXT_HTML:i("text-html"),TEXT_CSS:i("text-css"),APPLICATION_JSON:i("application-json"),TEXT_YAML:i("text-yaml"),IMAGE_SVG_XML:i("image-svg-xml"),ResourceLink:i("ResourceLink"),target:i("target"),linkLabel:i("linkLabel"),PropertyList:i("PropertyList"),propertyEntries:i("propertyEntries"),PropertyEntry:i("PropertyEntry"),propertyKey:i("propertyKey"),propertyValue:i("propertyValue"),Table:i("Table"),tableColumnLabels:i("tableColumnLabels"),tableRows:i("tableRows"),TableRow:i("TableRow"),tableCells:i("tableCells")};function ge(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var V=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(n,t){let r=Ie(n.metadata,t),o=Ke(n.children),s=["---",...r,"---","",o].join(`
|
|
2
2
|
`);return t?.trailingNewline&&(s.endsWith(`
|
|
3
3
|
`)||(s+=`
|
|
4
4
|
`)),s}};function Ie(e,n){if(!e)return[];let t=new Map;for(let c of e.entries)t.set(P(c.key),c);let r=new Map;if(n?.metadataRenames)for(let[c,u]of n.metadataRenames)r.set(P(c),u);let a=(n?.metadataKeys??e.entries.map(c=>c.key)).map(P),s=[];for(let c of a){let u=t.get(c);if(!u)continue;let f=r.get(c),l=P(f??c),d=ye(u.value,u.escapeHint);d!==void 0&&s.push(`${l}: ${d}`)}return s}function P(e){let n=e.lastIndexOf(".");return n===-1?e:e.substring(n+1)||e}function ye(e,n){switch(e.kind){case"StringScalar":return _e(e.stringValue,n);case"IntegerScalar":return String(e.integerValue);case"StructuredList":{let t=[];for(let r of e.items){let o=ye(r,n);o!==void 0&&t.push(o)}return t.join(", ")}case"StructuredMap":return;default:return}}function _e(e,n){return!n||ge(n,m.ESC_RAW)?e:ge(n,m.ESC_YAML_SAFE)?Ce(e):e}function Ce(e){return e.includes(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import{A as l,B as m,C as n,D as o,E as p,F as q,G as r,H as s,J as t,p as a,q as b,r as c,s as d,t as e,u as f,v as g,w as h,x as i,y as j,z as k}from"../chunk-PC3MYDGL.js";import"../chunk-GGK6A6QK.js";import"../chunk-FUUTGGJS.js";export{t as SingleDocumentRepository,j as findAllResourcesByCanonicalUri,k as findStatement,i as findSubjectByUri,h as findSubjectsByType,m as getDatatypeValue,p as getEmbeddedValue,q as getListValues,o as getReferenceUri,n as getStringValue,l as hasProperty,g as hasType,f as rawValuesOf,e as referenceUris,s as subjectAddress,c as toCanonicalUrl,d as typeReferenceUris,a as uriKey,b as uriMatches,r as valuesOf};
|
package/dist/validation/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,D,E,F,G,H,I,J,K,L,M,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-
|
|
1
|
+
import{A,B,C,D,E,F,G,H,I,J,K,L,M,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-Q57XCPAQ.js";import"../chunk-A224OOBZ.js";import"../chunk-GXEKJFXG.js";import"../chunk-QHABFCRC.js";import"../chunk-5FVUBF7N.js";import"../chunk-WXXZOJ4O.js";import"../chunk-LKJVNKCN.js";import"../chunk-5ZRVFYCP.js";import"../chunk-PEJALHXK.js";import"../chunk-WXUMROTA.js";import"../chunk-PC3MYDGL.js";import"../chunk-F67UH4FD.js";import"../chunk-GGK6A6QK.js";import"../chunk-FUUTGGJS.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,o as ClassHierarchyCycleRule,L as DiamondNameClashRule,D as DisplayLensScopeRule,l as EmbeddedKanonakTypeRule,m as ImportExistenceRule,M as KanonakObjectValidator,f as LinkTargetRule,H as LookBandPathRule,E as LookSemanticSvgPathRule,C as MarkdownLinkRule,t as NamespaceImportCycleRule,g as NamespacePrefixRule,x as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,K as OwlOneOfRule,k as PackageHeaderRule,y as PropertyDomainRule,p as PropertyHierarchyCycleRule,z as PropertyKindRangeConsistencyRule,w as PropertyRangeReferenceRule,q as PropertyRangeRequiredRule,i as PropertyTypeSpecificityRule,A as ReservedNameShadowRule,h as ResourceNamingRule,G as SequenceNarrativeRule,J as ShaclShapeRule,r as SubClassOfReferenceRule,s as SubPropertyOfReferenceRule,j as SubjectKanonakTypeRequiredRule,F as TxExpressionCompilesRule,I as TxExpressionPathRule,u as UnresolvedPredicateRule,n as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0",
|
|
4
4
|
"description": "TypeScript SDK for the Kanonak Protocol — parse, resolve, validate, reason over, and render .kan.yml packages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
],
|
|
136
136
|
"dependencies": {
|
|
137
137
|
"@kanonak-protocol/canonical": "^0.1.3",
|
|
138
|
-
"@kanonak-protocol/types": "^6.
|
|
138
|
+
"@kanonak-protocol/types": "^6.4.0",
|
|
139
139
|
"ignore": "^7.0.5",
|
|
140
140
|
"js-yaml": "^4.1.0",
|
|
141
141
|
"yaml": "^2.7.0",
|
package/dist/chunk-D4QGPMRW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as S}from"./chunk-FUUTGGJS.js";import{c as A,g as v}from"./chunk-QILEJIFU.js";var p=class{};var f=class extends p{statement=[];unresolvedPredicates=[];sourceDoc="";sourceKey};var l=class extends f{namespace;name;icon};var k=class extends f{name;rangeType};var s=class e extends p{subject;sourceKey;static parse(n){let t=new e;return t.subject=S.parse(n),t}};var $=class extends p{value;carrier;lexical;links;sourceKey};var m=class{predicate;object;sourceKey};var d=class extends m{carrier;lexical};var b=class e extends d{static parse(n,t){let r=new e;return r.predicate=s.parse(n),r.object=t,r}};var K=class e extends d{static parse(n,t){let r=new e;return r.predicate=s.parse(n),r.object=t,r}};var x=class extends d{};var y=class e extends m{static parse(n,t){let r=new e;return r.predicate=s.parse(n),r.object=s.parse(t),r}};var h=class extends m{};var j=class extends m{};var U=class extends b{links=[]};function E(e){return`${e.publisher}/${e.package_}/${e.name}`}function w(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}function C(e){let n=e.version;return n&&typeof n.major=="number"?`https://${e.publisher}/${e.package_}/${n.major}.${n.minor}.${n.patch}/${e.name}`:`https://${e.publisher}/${e.package_}/${e.name}`}function T(e){return L(e,B)}var B={publisher:"kanonak.org",package_:"core-rdf",name:"type"};function L(e,n){let t=[];for(let r of D(e,n))r.item instanceof s&&t.push(r.item.subject);return t}function D(e,n){if(!(e instanceof f))return[];let t=[];for(let r of e.statement){let a=r.predicate;if(!(!a?.subject||!w(a.subject,n)))if(r instanceof y)t.push({item:r.object,fromList:!1});else if(r instanceof h)t.push({item:r.object,fromList:!1});else if(r instanceof U)t.push({item:{literal:!0,value:r.object,carrier:r.carrier,lexical:r.lexical,links:r.links},fromList:!1});else if(r instanceof b||r instanceof K||r instanceof x)t.push({item:{literal:!0,value:r.object,carrier:r.carrier,lexical:r.lexical},fromList:!1});else if(r instanceof j)for(let o of r.object??[])if(o instanceof s||o instanceof k)t.push({item:o,fromList:!0});else if(o instanceof $)t.push({item:{literal:!0,value:o.value,carrier:o.carrier,lexical:o.lexical,links:o.links},fromList:!0});else throw new Error(`rawValuesOf: a list value of '${n.name}' is a ${o?.constructor?.name??typeof o}; list items are references, embedded values or literals.`);else throw new Error(`rawValuesOf: '${n.name}' has a statement of unknown kind ${r?.constructor?.name??typeof r}.`)}return t}function I(e,n){if(!(e instanceof f))return!1;for(let t of e.statement)if(t.predicate?.subject?.name==="type"&&t instanceof y){let a=t.object;if(w(a.subject,n))return!0}return!1}function N(e,n){let t=[];for(let r of e)r instanceof l&&I(r,n)&&t.push(r);return t}function H(e,n){let t=n.version,r=t&&typeof t.major=="number"?`${n.publisher}/${n.package_}@${t.major}.${t.minor}.${t.patch}`:void 0;for(let a of e){if(!(a instanceof l)||a.name!==n.name)continue;let o=a.namespace||"";if(r!==void 0){if(o===r)return a}else if(o.startsWith(`${n.publisher}/${n.package_}@`))return a}}function W(e,n){let t=[];for(let r of e){if(!(r instanceof l)||r.name!==n.name)continue;(r.namespace||"").startsWith(`${n.publisher}/${n.package_}@`)&&t.push(r)}return t.sort((r,a)=>{let o=v((r.namespace||"").split("@")[1]??""),i=v((a.namespace||"").split("@")[1]??"");return o?i?A(i,o):-1:i?1:0}),t}function g(e,n){for(let t of e.statement){let r=t.predicate;if(r?.subject&&w(r.subject,n))return t}}function q(e,n){return g(e,n)!==void 0}function M(e,n){let t=g(e,n);if(t&&(t instanceof b||t instanceof K||t instanceof x))return t.object}function F(e,n){let t=M(e,n);return typeof t=="string"?t:void 0}function Y(e,n){let t=g(e,n);if(t instanceof y)return t.object.subject}function z(e,n){let t=g(e,n);if(t instanceof h)return t.object}function G(e,n){let t=g(e,n);return t instanceof j?t.object??[]:[]}function _(e){if(!e||e.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let n=e.trim(),t=n.split("/");if(t.length===1){let r=t[0];if(!r)throw new Error(`Invalid Kanonak address: "${e}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(r.includes("@"))throw new Error(`Invalid Kanonak address: "${e}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:r}}if(t.length===2){let[r,a]=t;if(!r||!a)throw new Error(`Invalid Kanonak address: "${e}". Expected publisher/package[@version].`);let o=a.indexOf("@");if(o===-1)return{kind:"package",publisher:r,package_:a};let i=a.substring(0,o),c=a.substring(o+1);if(!i||!c)throw new Error(`Invalid Kanonak address: "${e}". Expected publisher/package[@version].`);let u=J(c);return{kind:"package",publisher:r,package_:i,version:u}}return{kind:"resource",uri:S.parse(n)}}function Ge(e){switch(e.kind){case"publisher":return e.publisher;case"package":return e.version?`${e.publisher}/${e.package_}@${e.version.major}.${e.version.minor}.${e.version.patch}`:`${e.publisher}/${e.package_}`;case"resource":return e.uri.toString()}}function J(e){let n=e.split(".").map(Number);return Q(n[0]||0,n[1]||0,n[2]||0)}function Q(e,n,t){return{major:e,minor:n,patch:t,toString:()=>`${e}.${n}.${t}`,equals:r=>!r||typeof r!="object"?!1:r.major===e&&r.minor===n&&r.patch===t,getHashCode:()=>e<<20|n<<10|t,compareTo:r=>e!==r.major?e-r.major:n!==r.minor?n-r.minor:t-r.patch}}function X(e,n,t,r){let a=ee(e,n,r);if(a.length===0)return[];let o=ne(t);return a.map(({value:i,address:c})=>{let u=i.fromList;if(i.item instanceof s){let P=o.resolve(i.item.subject);return P?{kind:"subject",node:P,uri:i.item.subject,address:c,fromList:u}:{kind:"unresolved",uri:i.item.subject,address:c,fromList:u}}if(i.item instanceof k)return{kind:"embedded",node:i.item,address:c,fromList:u};let V={kind:"literal",value:i.item.value,carrier:i.item.carrier,lexical:i.item.lexical,address:c,fromList:u};return i.item.links&&(V.links=i.item.links),V})}function Z(e){let n=_(`${e.namespace}/${e.name}`);if(n.kind!=="resource")throw new Error(`subjectAddress: '${e.namespace}/${e.name}' is not a resource address`);return E(n.uri)}function ee(e,n,t){let r=D(e,n);if(r.length===0)return[];let a=t.includes("#")?`${t}.${n.name}`:`${t}#${n.name}`,o=r.length>1||r.some(i=>i.fromList);return r.map((i,c)=>({value:i,address:i.item instanceof k&&i.item.name?`${a}.${i.item.name}`:o?`${a}[${c}]`:a}))}var O=new WeakMap;function ne(e){let n=O.get(e);if(n)return n;let t=new Map,r=new Map;for(let a of e){if(!(a instanceof l))continue;let o=a.namespace||"",i=`${o}\0${a.name}`;t.has(i)||t.set(i,a);let c=o.indexOf("@");if(c>=0){let u=`${o.slice(0,c)}\0${a.name}`;r.has(u)||r.set(u,a)}}return n={resolve(a){let o=a.version;return o&&typeof o.major=="number"?t.get(`${a.publisher}/${a.package_}@${o.major}.${o.minor}.${o.patch}\0${a.name}`):r.get(`${a.publisher}/${a.package_}\0${a.name}`)}},O.set(e,n),n}var R=class{constructor(n,t){this.doc=n;this.broader=t}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(n){return this.broader.getDocumentAsync(n)}async getDocumentsByNamespaceAsync(n,t){return this.broader.getDocumentsByNamespaceAsync(n,t)}async getHighestCompatibleVersionAsync(n,t){return this.broader.getHighestCompatibleVersionAsync(n,t)}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(n){return this.broader.getDocumentContentAsync(n)}async getDocumentUriAsync(n){return this.broader.getDocumentUriAsync(n)}};export{p as a,f as b,l as c,k as d,s as e,$ as f,m as g,d as h,b as i,K as j,x as k,y as l,h as m,j as n,U as o,_ as p,Ge as q,E as r,w as s,C as t,T as u,L as v,D as w,I as x,N as y,H as z,W as A,g as B,q as C,M as D,F as E,Y as F,z as G,G as H,X as I,Z as J,ee as K,R as L};
|
package/dist/chunk-MD4CAJIO.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as k}from"./chunk-SC5M74NM.js";import{b as l,d as L,e as d}from"./chunk-5FVUBF7N.js";import{a as R}from"./chunk-7JBKOJB4.js";import{e as m,g as P,j as C}from"./chunk-QILEJIFU.js";var K="@kanonak-protocol/sdk (+https://kanonak.org)",v=K;function W(o){v=o}function q(){return v}function f(o){let e;try{e=typeof o=="string"?new URL(o):o}catch{throw new Error(`Kanonak requires an absolute https:// URL \u2014 got an unparseable or relative URL: ${String(o)}`)}if(e.protocol!=="https:")throw new Error(`Kanonak requires HTTPS \u2014 refusing to fetch ${e.href} (only https:// is supported).`)}var I=new Set([429,502,503,504]),b=4,T=500,x=2e4;function g(o,e){f(o);let t=new Headers(e?.headers);return t.has("User-Agent")||t.set("User-Agent",v),H(o,{...e,headers:t})}var y=b;function G(o){y=Math.max(0,o)}async function H(o,e){let t;for(let r=0;r<=y;r++){let n;try{n=await fetch(o,e)}catch(i){if(t=i,r>=y)throw i;await E(A(r,void 0));continue}if(!I.has(n.status)||r>=y)return n;let s=L(n.headers.get("retry-after"));if(s!==void 0&&s*1e3>x)return n;await E(A(r,s))}throw t??new Error("kanonakFetch: exhausted retries")}function A(o,e){if(e!==void 0)return e*1e3;let t=Math.min(x,T*2**o);return Math.floor(t/2+Math.random()*(t/2))}function E(o){return new Promise(e=>setTimeout(e,o))}var M="https://{publisher}/{package}/{version}.kan.yml",$={version:1};function Q(){return{version:1}}var w=class{constructor(e){this.fetchFn=e}fetchFn;cache=new Map;getConfig(e){let t=this.cache.get(e);return t||(t=this.fetchConfig(e),this.cache.set(e,t),t.catch(()=>{this.cache.get(e)===t&&this.cache.delete(e)})),t}async fetchConfig(e){let t=`https://${e}/.well-known/kanonak.json`,r;try{r=await(this.fetchFn?this.fetchFn(t,e):g(t))}catch(i){if(i instanceof d)throw i;return $}if(r.status===404)return $;if(!r.ok)throw await l("publisher config",t,r);let n=await r.json();if(typeof n.version!="number")throw new Error(`Invalid publisher config at ${t}: missing or invalid "version" field`);let s={version:n.version};return typeof n.package_url_template=="string"&&(O(t,"package_url_template",n.package_url_template),s.package_url_template=n.package_url_template),Array.isArray(n.featured_packages)&&n.featured_packages.every(i=>typeof i=="string")&&(s.featured_packages=n.featured_packages),s}resolvePackageUrl(e,t,r,n){let s=n.package_url_template??M,i=S(s,{publisher:e,package:t,version:r});return f(i),i}};function O(o,e,t){if(!t.startsWith("https://"))throw new Error(`Invalid publisher config at ${o}: ${e} must be an absolute https:// URL template (got "${t}").`)}function S(o,e){let t=o;for(let[n,s]of Object.entries(e))t=t.replaceAll(`{${n}}`,s);let r=t.match(/\{[a-z]+\}/);if(r)throw new Error(`Unresolved variable ${r[0]} in URL template: ${o}`);return t}import U from"js-yaml";function te(o,e,t){return o.packages[`${e}/${t}`]?.version}var j=`# This file is generated by Kanonak CLI. Do not edit manually.
|
|
2
|
-
`,B="sha256:";function _(o){let e=U.load(o);return!e||typeof e!="object"||e.version!=="1"?null:{version:"1",lastUpdated:e.lastUpdated??"",packages:e.packages??{}}}function ne(o){let e={};for(let r of Object.keys(o.packages).sort())e[r]=o.packages[r];let t=U.dump({...o,packages:e},{lineWidth:-1,sortKeys:!1,quotingType:'"'});return j+t}async function re(o){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(o)),t=Array.from(new Uint8Array(e),r=>r.toString(16).padStart(2,"0")).join("");return`${B}${t}`}var p=class{configResolver;fetchFn;lockCache=new Map;packageLockCache=new Map;constructor(e){this.configResolver=e?.configResolver??new w(e?.fetchFn),this.fetchFn=e?.fetchFn}getConfig(e){return this.configResolver.getConfig(e)}async getPackageUrl(e,t,r){let n=await this.configResolver.getConfig(e);return this.configResolver.resolvePackageUrl(e,t,r,n)}getLock(e){let t=this.lockCache.get(e);return t||(t=this.fetchLock(e),this.lockCache.set(e,t),t.catch(()=>{this.lockCache.get(e)===t&&this.lockCache.delete(e)})),t}async getPackageLockEntry(e,t){let r=`${e}/${t}`,n=this.packageLockCache.get(r);return n||(n=this.fetchLock(e,t),this.packageLockCache.set(r,n),n.catch(()=>{this.packageLockCache.get(r)===n&&this.packageLockCache.delete(r)})),(await n)?.packages[r]??null}async fetchLock(e,t){let r=t?`https://${e}/${t}/kanonak.lock`:`https://${e}/kanonak.lock`,n;try{n=this.fetchFn?await this.fetchFn(r,e):await g(r)}catch(s){if(s instanceof d)throw s;return null}if(n.status===404)return null;if(!n.ok)throw await l("publisher lock",r,n);return _(await n.text())}};import{VersionOperator as F}from"@kanonak-protocol/types/document/models/enums";function N(o,e){let t=P(o);return t?C(t,e):!1}var D=class{parser=new R;publisherIndex;documents=new Map;contentCache=new Map;fetchFn;onFetch;getFromCache;constructor(e){this.onFetch=e?.onFetch,this.getFromCache=e?.getFromCache,this.fetchFn=e?.fetchFn,this.publisherIndex=e?.fetchFn?new p({fetchFn:e.fetchFn}):new p}async getHighestCompatibleVersionAsync(e,t){if(t.versionOperator===F.Exact){let s=await this.fromMemoOrCache(e,t.packageName,m(t.version));if(s)return s}let n=(await this.publisherIndex.getLock(e))?.packages[`${e}/${t.packageName}`]??await this.publisherIndex.getPackageLockEntry(e,t.packageName)??void 0;return n&&N(n.version,t)?this.fetchPinned(e,t.packageName,n):n&&t.versionOperator!==F.Exact?null:this.resolveByDirectFetch(e,t)}async fetchPinned(e,t,r){let n=r.version,s=`${e}/${t}@${n}`,i=await this.fromMemoOrCache(e,t,n);if(i)return i;let a=r.resolved,c=this.fetchFn?await this.fetchFn(a,e):await g(a);if(!c.ok)throw await l("Kanonak package",a,c);let h=await c.text(),u=this.parser.parse(h);return k(u,e,t,n),this.onFetch&&await this.onFetch(e,t,n,h),this.documents.set(s,u),this.contentCache.set(s,h),u}async fromMemoOrCache(e,t,r){let n=`${e}/${t}@${r}`,s=this.documents.get(n);if(s)return s;if(!this.getFromCache)return null;let i=await this.getFromCache(e,t,r);if(i==null)return null;let a;try{a=this.parser.parse(i),k(a,e,t,r)}catch(c){throw new Error(`Cached content for ${n} is not a usable copy of that package \u2014 refusing to fall through to a fetch that would hide it. ${c.message}`,{cause:c})}return this.documents.set(n,a),this.contentCache.set(n,i),a}async resolveByDirectFetch(e,t){let r=t.packageName,s=t.versionOperator===F.Exact?await this.publisherIndex.getPackageUrl(e,r,m(t.version)):`https://${e}/${r}.kan.yml`,i=await this.fetchFollowing(s,e);if(!i)return null;let a=this.parser.parse(i.content),c=a.metadata.namespace_;if(!c||!c.version)throw new Error(`Producer origin returned a package with no namespace/version for ${e}/${r}`);let h=m(c.version);k(a,e,r,h);let u=`${e}/${r}@${h}`;return this.onFetch&&await this.onFetch(e,r,h,i.content),this.documents.set(u,a),this.contentCache.set(u,i.content),a}async fetchFollowing(e,t,r=4){let n=e;for(let s=0;s<r;s++){f(n);let i=this.fetchFn?await this.fetchFn(n,t):await g(n,{redirect:"manual"});if(i.status===301||i.status===302){let a=i.headers.get("location");if(!a)throw new Error(`Redirect with no Location header from ${n}`);n=new URL(a,n).toString();continue}if(i.status===404)return null;if(!i.ok)throw await l("Kanonak package",n,i);return{url:n,content:await i.text()}}throw new Error(`Too many redirects resolving ${e}`)}async getAllDocumentsAsync(){return Array.from(this.documents.values())}async getDocumentAsync(e){return this.documents.get(e)??null}async getDocumentsByNamespaceAsync(e,t){return Array.from(this.documents.values()).filter(r=>{let n=r.metadata.namespace_;return n&&n.publisher===e&&n.package_===t})}async saveDocumentAsync(e,t){throw new Error("HttpKanonakDocumentRepository is read-only")}async deleteDocumentAsync(e){throw new Error("HttpKanonakDocumentRepository is read-only")}async clearNamespaceAsync(e,t){throw new Error("HttpKanonakDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return this.contentCache.get(e)??null}async getDocumentUriAsync(e){let t=e.match(/^(.+?)\/(.+?)@(.+)$/);if(!t)return null;let[,r,n,s]=t;return this.publisherIndex.getPackageUrl(r,n,s)}};export{K as a,W as b,q as c,f as d,g as e,G as f,Q as g,w as h,te as i,B as j,_ as k,ne as l,re as m,p as n,D as o};
|
package/dist/chunk-NUTHBBDZ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as v,E as L,F as Q,c as B,d as G,p as X,r as S,s as Y,u as q,v as I,z as W}from"./chunk-D4QGPMRW.js";import{a as x}from"./chunk-FUUTGGJS.js";import{b as H}from"./chunk-F67UH4FD.js";var z=class{cache=new Map;repository;logger;constructor(e,n){this.repository=e,this.logger=n}async resolveEntityAsync(e,n){let o=n.metadata?.namespace_?.toString()??"unknown",s=this.cache.get(o);if(s){let i=s.get(e);if(i)return i}let a=await this.buildEntityIndexAsyncInternal(n,new Set,"",new Map);return this.cache.set(o,a),a.get(e)??null}async resolveAllEntitiesAsync(e,n){let o=await this.buildAllEntitiesIndexAsync(n,new Set,"");if(e.includes(".")){let s=e.split("."),a=s[0],i=s[1],y=await this.findDocumentForAlias(n,a);return y?await this.resolveAllEntitiesAsync(i,y):[]}return o.filter(s=>s.entityName===e)}async buildAllEntitiesIndexAsync(e,n,o){let s=[],a=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${a}`),n.has(a))return this.logger?.debug?.(`Skipping ${a} - already visited (circular import prevention)`),s;n.add(a);let i=o.length===0?a:`${o} \u2192 ${a}`;for(let[y,l]of Object.entries(e.body))if(!y.includes(".")&&l&&typeof l=="object"&&!Array.isArray(l)){if(!e.metadata.namespace_)continue;let g=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};s.push({entityName:y,uri:new x(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,y,g),entity:l,definedInNamespace:a,isImported:o.length>0,importPath:i})}if(this.logger?.debug?.(`Collected ${s.length} entities from ${a}`),e.metadata?.imports){let y=Object.values(e.metadata.imports).reduce((l,g)=>l+g.length,0);this.logger?.debug?.(`Processing ${y} import(s) for ${a}`);for(let[l,g]of Object.entries(e.metadata.imports))for(let d of g)if(!H(d))try{this.logger?.debug?.(`Resolving import: ${l}/${d.packageName}`);let m=await this.repository.getHighestCompatibleVersionAsync(l,d);if(m){this.logger?.debug?.(`Successfully loaded import: ${m.metadata?.namespace_?.toString()}`);let k=await this.buildAllEntitiesIndexAsync(m,n,i);s.push(...k),this.logger?.debug?.(`Added ${k.length} entities from import ${m.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${l}/${d.packageName}`)}catch(m){let k=m;throw this.logger?.error?.(`Failed to process import ${l}/${d.packageName} for namespace ${a}. Error: ${k.message}`,k),new Error(`Failed to process import ${l}/${d.packageName} for namespace ${a}. See inner exception for details.`,{cause:m})}}return s}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"",new Map)}async buildEntityIndexAsyncInternal(e,n,o,s){let a=new Map,i=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${i}`),n.has(i))return this.logger?.debug?.(`Skipping ${i} - circular import in progress`),a;let y=s.get(i);if(y)return y;n.add(i);let l=o.length===0?i:`${o} \u2192 ${i}`,g=0;for(let[d,m]of Object.entries(e.body))if(!d.includes(".")&&m&&typeof m=="object"&&!Array.isArray(m)){if(!e.metadata.namespace_)continue;if(!a.has(d)){let k=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};a.set(d,{entityName:d,uri:new x(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,d,k),entity:m,definedInNamespace:i,isImported:o.length>0,importPath:l}),g++}}if(this.logger?.debug?.(`Indexed ${g} entities from ${i}`),e.metadata?.imports){let d=Object.values(e.metadata.imports).reduce((m,k)=>m+k.length,0);this.logger?.debug?.(`Processing ${d} import(s) for ${i}`);for(let[m,k]of Object.entries(e.metadata.imports))for(let b of k)if(!H(b))try{this.logger?.debug?.(`Resolving import: ${m}/${b.packageName}`);let h=await this.repository.getHighestCompatibleVersionAsync(m,b);if(h){this.logger?.debug?.(`Successfully loaded import: ${h.metadata?.namespace_?.toString()}`);let U=await this.buildEntityIndexAsyncInternal(h,n,l,s),M=0;for(let[A,P]of U.entries()){let _=a.get(A);if(!_)a.set(A,P),M++;else if(_.isImported&&P.isImported&&(_.uri.publisher!==P.uri.publisher||_.uri.package_!==P.uri.package_)){let C=_.isAmbiguous?_:{..._,isAmbiguous:!0,ambiguousNamespaces:[_.definedInNamespace]};C.ambiguousNamespaces.includes(P.definedInNamespace)||C.ambiguousNamespaces.push(P.definedInNamespace),a.set(A,C),this.logger?.warn?.(`Ambiguous reference '${A}': defined in ${C.ambiguousNamespaces.join(", ")}`)}if(b.alias&&!A.includes(".")){let C=`${b.alias}.${A}`;a.has(C)||(a.set(C,P),M++)}}this.logger?.debug?.(`Merged ${M} entities from import ${h.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${m}/${b.packageName}`)}catch(h){let U=h;throw this.logger?.error?.(`Failed to process import ${m}/${b.packageName} for namespace ${i}. Error: ${U.message}`,U),new Error(`Failed to process import ${m}/${b.packageName} for namespace ${i}. See inner exception for details.`,{cause:h})}}return n.delete(i),s.set(i,a),a}async findDocumentForAlias(e,n){if(!e.metadata?.imports)return null;for(let[o,s]of Object.entries(e.metadata.imports))for(let a of s)if(!H(a)){if(a.alias===n)return await this.repository.getHighestCompatibleVersionAsync(o,a);if(!a.alias&&a.packageName===n)return await this.repository.getHighestCompatibleVersionAsync(o,a)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}};var J=class t{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","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"&&t.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 t.isSubstitutableDatatypeUri(e)}static isSubstitutableDatatypeUri(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let n=e.includes(".")?e.split(".")[1]:e;return t.KNOWN_XSD_DATATYPES.has(n.toLowerCase())}async isClassTypeAsync(e,n){if(this.isKnownXsdDatatypeName(e))return!1;let o=await this.resourceResolver.resolveEntityAsync(e,n);if(o){let s=o.entity.type;if(s){let a=String(s);return a==="Class"||a==="rdfs.Class"||a.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,n){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(n)||e==="Property"&&this.isLiteralType(n))}isEffectiveObjectProperty(e,n){return!!(e==="ObjectProperty"||e==="Property"&&n&&!this.isXsdDatatype(n)&&!this.isLiteralType(n))}};function Ue(t){return`${t.publisher}/${t.package_}/${t.name}`}function u(t,e,n){return`${t}/${e}/${n}`}function He(t){return`${t.s}|${t.p}|${ae(t.o)}`}function ae(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 Ie(t,e,n){return{s:t,p:e,o:{kind:"uri",key:n}}}var se="kanonak.org",ie="core-shacl",r=t=>({publisher:se,package_:ie,name:t}),D=r("Shape"),N=r("NodeShape"),T=r("PropertyShape"),Ne=r("targetClass"),Te=r("property"),je=r("path"),$e=r("minCount"),Me=r("maxCount"),ve=r("datatype"),Le=r("class"),we=r("in"),Ve=r("pattern"),Fe=r("flags"),Be=r("minLength"),Ge=r("maxLength"),Xe=r("minInclusive"),Ye=r("maxInclusive"),qe=r("message"),We=r("targetNode"),Qe=r("targetSubjectsOf"),ze=r("targetObjectsOf"),Je=r("closed"),Ze=r("ignoredProperties"),et=r("nodeKind"),tt=r("IRI"),nt=r("BlankNode"),rt=r("Literal"),ot=r("severity"),at=r("Violation"),st=r("Warning"),it=r("Info"),pt=r("ValidationReport"),ct=r("conforms"),lt=r("result"),ut=r("ValidationResult"),yt=r("focusNode"),mt=r("resultPath"),dt=r("resultMessage"),gt=r("resultSeverity"),ft=r("sourceShape"),kt=r("value"),St=r("sourceConstraintComponent"),bt=r("MinCountConstraintComponent"),_t=r("MaxCountConstraintComponent"),ht=r("DatatypeConstraintComponent"),Pt=r("ClassConstraintComponent"),Ct=r("InConstraintComponent"),Kt=r("PatternConstraintComponent"),Et=r("MinLengthConstraintComponent"),At=r("MaxLengthConstraintComponent"),xt=r("MinInclusiveConstraintComponent"),Rt=r("MaxInclusiveConstraintComponent"),Ot=r("NodeKindConstraintComponent"),Ut=r("ClosedConstraintComponent"),Ht=r("hasValue"),It=r("qualifiedValueShape"),Dt=r("qualifiedMinCount"),Nt=r("qualifiedMaxCount"),Tt=r("HasValueConstraintComponent"),jt=r("QualifiedMinCountConstraintComponent"),$t=r("QualifiedMaxCountConstraintComponent");var p="kanonak.org",c="core-rdf",f="core-owl",ee="core-kanonak",j=new Map([["type",c],["subClassOf",c],["subPropertyOf",c],["domain",c],["range",c],["label",c],["comment",c],["seeAlso",c],["isDefinedBy",c],["member",c],["Resource",c],["Class",c],["Property",c],["Datatype",c],["Literal",c],["List",c],["ObjectProperty",f],["DatatypeProperty",f],["AnnotationProperty",f],["Thing",f],["Nothing",f],["Package",ee]]),pe=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function wt(t){return j.has(t)}function ce(t){let e=j.get(t);return e?{publisher:p,package_:e}:void 0}function Vt(){return[...new Set(j.values())].map(t=>({publisher:p,package_:t}))}function Ft(t){let e=ce(t);if(!e)throw new Error(`builtinUri: '${t}' is not a reserved built-in term.`);return{...e,name:t}}function V(t,e,n){if(!t||!t.name)return;let o=j.get(t.name);if(!o)return;let s=()=>{t.publisher=p,t.package_=o,n&&(t.version=n.get(o))};if(pe.has(t.name)){let a=t.publisher===p&&t.package_===o;t.publisher=p,t.package_=o,!a&&n&&(t.version=n.get(o));return}t.publisher===p&&t.package_===o||t.publisher&&t.publisher.length>0&&(!e||e(t))||s()}var Z=class{type=u(p,c,"type");subClassOf=u(p,c,"subClassOf");subPropertyOf=u(p,c,"subPropertyOf");domain=u(p,c,"domain");range=u(p,c,"range");label=u(p,c,"label");comment=u(p,c,"comment");resource=u(p,c,"Resource");class_=u(p,c,"Class");datatype=u(p,c,"Datatype");literal=u(p,c,"Literal");equivalentClass=u(p,f,"equivalentClass");equivalentProperty=u(p,f,"equivalentProperty");inverseOf=u(p,f,"inverseOf");sameAs=u(p,f,"sameAs");transitiveProperty=u(p,f,"TransitiveProperty");symmetricProperty=u(p,f,"SymmetricProperty");objectProperty=u(p,f,"ObjectProperty");datatypeProperty=u(p,f,"DatatypeProperty");annotationProperty=u(p,f,"AnnotationProperty");package_=u(p,ee,"Package");shape=w(D);nodeShape=w(N);propertyShape=w(T)};function w(t){return u(t.publisher,t.package_,t.name)}var le=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function R(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=e.entity.type;if(typeof n=="string"){let s={publisher:"",package_:"",name:n.includes(".")?n.substring(n.lastIndexOf(".")+1):n};return V(s),{publisher:s.publisher,package_:s.package_,name:s.name}}}return ne(t)[0]??null}function ne(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=R(t);return n?[n]:[]}return Array.isArray(e.statement)?q(t).map(n=>{let o={publisher:n.publisher??"",package_:n.package_??"",name:n.name};return V(o),{publisher:o.publisher,package_:o.package_,name:o.name}}):[]}var ue=[D,N,T];function O(t,e){return le.has(`${t}/${e}`)}var ye=new Set(["Property","ObjectProperty","DatatypeProperty","AnnotationProperty"]);function F(t){if(O(t.publisher,t.package_))return ye.has(t.name)?t.name:void 0}var te=class t{static getTypeUri(e){return R(e)}static isCoreOntologyType(e){return O(e.publisher,e.package_)}static hasCoreType(e,n){return ne(e).some(o=>O(o.publisher,o.package_)&&o.name===n)}static isClassType(e){return t.hasCoreType(e,"Class")}static isDatatypeType(e){return t.hasCoreType(e,"Datatype")}static isDatatypePropertyType(e){return t.hasCoreType(e,"DatatypeProperty")}static isObjectPropertyType(e){return t.hasCoreType(e,"ObjectProperty")}static isAnnotationPropertyType(e){return t.hasCoreType(e,"AnnotationProperty")}static isGenericPropertyType(e){return t.hasCoreType(e,"Property")}static isAnyPropertyType(e){let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"}static isShapeType(e){let n=R(e);return n?ue.some(o=>Y(n,o)):!1}static isSchemaDefinitionType(e){if(t.isShapeType(e))return!0;let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Class"||n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"||n.name==="Datatype"}static isInstanceOfKnownClass(e,n){if(t.isSchemaDefinitionType(e))return!1;let o=R(e);return o?n.has(o.name):!1}};var K="kanonak.org",E="core-rdf",me={publisher:K,package_:E,name:"domain"},de={publisher:K,package_:E,name:"range"},ge={publisher:K,package_:E,name:"subClassOf"},fe={publisher:K,package_:E,name:"type"},ke={publisher:K,package_:E,name:"label"},Se={publisher:K,package_:E,name:"comment"},be=new x(K,E,"Resource");function _e(t){try{let e=X(`${t.namespace}/${t.name}`);return e.kind==="resource"?e.uri:void 0}catch{return}}function oe(t,e){let n=[],o=new Set,s="version"in e?e.version:void 0,a=[new x(e.publisher,e.package_,e.name,s??void 0)];for(;a.length>0;){let i=a.shift(),y=S(i);if(o.has(y))continue;o.add(y),n.push(i);let l=he(t,i);l&&a.push(...I(l,ge))}return n}function he(t,e){return e.version&&typeof e.version.major=="number"?W(t,e)??v(t,e)[0]:v(t,e)[0]}function $(t,e){let n;for(let o of Ee(e)){let s=Pe(t,o);if(s){if(s!=="Property")return s;n??=s}}return n}function Pe(t,e){let n=F(e);if(n)return n;let o=re.get(t);o||(o=new Map,re.set(t,o));let s=e.version,a=s&&typeof s.major=="number"?`${S(e)}@${s.major}.${s.minor}.${s.patch}`:S(e),i=o.get(a);if(i!==void 0)return i??void 0;let y;for(let l of oe(t,e)){let g=F(l);if(g){if(g!=="Property"){y=g;break}y??="Property"}}return o.set(a,y??null),y}var re=new WeakMap;function nn(t,e){return $(t,e)!==void 0}function rn(t,e){return $(t,e)==="ObjectProperty"}function on(t,e){return $(t,e)==="DatatypeProperty"}function Ce(t,e){let n=new Set([S(be)]);for(let o of oe(t,e))n.add(S(o));return n}function Ke(t,e){let n=Ce(t,e),o=[],s=new Set;for(let a of t){if(!(a instanceof B))continue;let i=$(t,a);if(!i)continue;let y=I(a,me);if(!y.some(d=>n.has(S(d))))continue;let l=_e(a);if(!l)continue;let g=S(l);s.has(g)||(s.add(g),o.push({uri:l,label:L(a,ke),comment:L(a,Se),kind:i==="ObjectProperty"?"object":i==="DatatypeProperty"?"datatype":"other",range:Q(a,de),domains:y}))}return o}function an(t,e,n){let o=Ke(t,e).find(s=>S(s.uri)===S(n));return o?{ok:!0,descriptor:o}:{ok:!1,message:`Property ${n.publisher}/${n.package_}/${n.name} is not in scope for ${e.publisher}/${e.package_}/${e.name}.`}}function Ee(t){let e=I(t,fe);return e.length>0?e:t instanceof G&&t.rangeType?[t.rangeType]:[]}export{z as a,J as b,Ue as c,u as d,He as e,ae as f,Ie as g,se as h,ie as i,D as j,N as k,T as l,Ne as m,Te as n,je as o,$e as p,Me as q,ve as r,Le as s,we as t,Ve as u,Fe as v,Be as w,Ge as x,Xe as y,Ye as z,qe as A,We as B,Qe as C,ze as D,Je as E,Ze as F,et as G,tt as H,nt as I,rt as J,ot as K,at as L,st as M,it as N,bt as O,_t as P,ht as Q,Pt as R,Ct as S,Kt as T,Et as U,At as V,xt as W,Rt as X,Ot as Y,Ut as Z,Ht as _,It as $,Dt as aa,Nt as ba,Tt as ca,jt as da,$t as ea,wt as fa,ce as ga,Vt as ha,Ft as ia,V as ja,Z as ka,F as la,te as ma,_e as na,oe as oa,$ as pa,nn as qa,rn as ra,on as sa,Ke as ta,an as ua,Ee as va};
|
package/dist/chunk-QILEJIFU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{VersionOperator as t}from"@kanonak-protocol/types/document/models/enums";function g(e){switch(e){case"=":return t.Exact;case"~":return t.Compatible;case"^":return t.Major;case"*":return t.Any;default:return t.Compatible}}function v(e){switch(e){case t.Exact:return"=";case t.Compatible:return"~";case t.Major:return"^";case t.Any:return"*";default:return"~"}}function a(e,r){return e.major!==r.major?e.major-r.major:e.minor!==r.minor?e.minor-r.minor:e.patch-r.patch}function l(e,r){return e.major===r.major&&e.minor===r.minor&&e.patch===r.patch}function c(e){return`${e.major}.${e.minor}.${e.patch}`}function p(e,r,o){let u=`${e}.${r}.${o}`;return{major:e,minor:r,patch:o,toString:()=>u,equals:n=>n?.major===e&&n?.minor===r&&n?.patch===o,getHashCode:()=>e<<20|r<<10|o,compareTo:n=>e!==n.major?e-n.major:r!==n.minor?r-n.minor:o-n.patch}}function h(e){let r=/^(\d+)\.(\d+)\.(\d+)$/.exec(e);return r?p(Number(r[1]),Number(r[2]),Number(r[3])):null}function f(e,r){return a(e,r)>=0&&e.major===r.major&&e.minor===r.minor}function V(e,r){return r.major===0?a(e,r)>=0&&e.major===0&&e.minor===r.minor:a(e,r)>=0&&e.major===r.major}function j(e,r){switch(r.versionOperator){case t.Exact:return l(e,r.version);case t.Compatible:return f(e,r.version);case t.Major:return V(e,r.version);case t.Any:return a(e,r.minVersion)>=0;default:return!1}}function b(e,r={}){let{requestedVersion:o}=r;if(e.length===0)return{chosen:null,alternatives:[],multipleVersionsPresent:!1,exactRequestedVersionMissing:!!o};if(o){let n=e.find(i=>{let s=i.metadata.namespace_?.version;return!!s&&c(s)===o});return n?{chosen:n,alternatives:e.filter(i=>i!==n),multipleVersionsPresent:e.length>1,exactRequestedVersionMissing:!1}:{chosen:null,alternatives:e,multipleVersionsPresent:e.length>1,exactRequestedVersionMissing:!0}}if(e.length===1)return{chosen:e[0],alternatives:[],multipleVersionsPresent:!1,exactRequestedVersionMissing:!1};let u=[...e].sort((n,i)=>{let s=n.metadata.namespace_?.version,m=i.metadata.namespace_?.version;return!s&&!m?0:s?m?a(m,s):-1:1});return{chosen:u[0],alternatives:u.slice(1),multipleVersionsPresent:!0,exactRequestedVersionMissing:!1}}export{g as a,v as b,a as c,l as d,c as e,p as f,h as g,f as h,V as i,j,b as k};
|