@kanonak-protocol/sdk 6.8.0 → 7.0.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/browser.d.ts +2 -0
- package/dist/browser.js +1 -1
- package/dist/{chunk-IT37WOHT.js → chunk-4NTZY2KP.js} +1 -1
- package/dist/chunk-7PTZF5LK.js +1 -0
- package/dist/{chunk-AZFLKLPB.js → chunk-A4OVTNMT.js} +1 -1
- package/dist/{chunk-Q2ZUKZEU.js → chunk-A5EAI5ZU.js} +1 -1
- package/dist/chunk-AEH3NZLH.js +3 -0
- package/dist/chunk-BA5J2DKJ.js +0 -0
- package/dist/{chunk-2GV6GXRF.js → chunk-C5HHCD6P.js} +1 -1
- package/dist/{chunk-FKLZDYWF.js → chunk-IXCD4K3K.js} +1 -1
- package/dist/{chunk-FCRP7KXR.js → chunk-IZBZDLCX.js} +1 -1
- package/dist/chunk-PC3DHZGV.js +1 -0
- package/dist/{chunk-PXUSA72Q.js → chunk-RFSARH5S.js} +1 -1
- package/dist/chunk-RXIKK3KZ.js +1 -0
- package/dist/chunk-VAZY57HJ.js +1 -0
- package/dist/chunk-YEUSFSC7.js +1 -0
- package/dist/filtering/GitIgnoreFilter.d.ts +25 -1
- package/dist/filtering/IGitIgnoreFilter.d.ts +3 -0
- package/dist/filtering/index.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/lock/VersionIndex.d.ts +97 -0
- package/dist/lock/VersionIndexIO.d.ts +4 -0
- package/dist/lock/index.d.ts +3 -0
- package/dist/parsing/index.js +1 -1
- package/dist/producer/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/repositories/InMemoryKanonakDocumentRepository.d.ts +8 -1
- package/dist/repositories/PublisherIndex.d.ts +17 -10
- package/dist/repositories/browser.js +1 -1
- package/dist/repositories/buildLocalFirstRepository.d.ts +25 -3
- package/dist/repositories/index.d.ts +1 -1
- package/dist/repositories/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/assembleModel.d.ts +1 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +19 -19
- package/dist/server/route.d.ts +1 -1
- package/dist/server/types.d.ts +6 -0
- package/dist/server/workspacePackages.d.ts +26 -0
- package/dist/server/workspaceVersionIndex.d.ts +23 -0
- package/dist/transformations/index.js +1 -1
- package/dist/validation/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-3ABGZHKM.js +0 -1
- package/dist/chunk-6CI3HTKF.js +0 -1
- package/dist/chunk-F4UHQVGA.js +0 -1
- package/dist/chunk-NYCGUDVW.js +0 -1
- package/dist/chunk-ODIECDN7.js +0 -1
- package/dist/chunk-X2URIXH7.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ut}from"./chunk-QRF7AT2M.js";import{c as At,g as Nt,h as pt,i as lt,j as Tt,k as xt,l as _t,t as mt,u as Lt,v as Mt}from"./chunk-AZFLKLPB.js";import{a as Et,e as vt}from"./chunk-5FVUBF7N.js";import{a as F,f as z,i as wt,k as O}from"./chunk-Q2ZUKZEU.js";import{a as Vt}from"./chunk-6CI3HTKF.js";import{$ as ne,_ as ct,aa as jt,b as St,ba as Ot,ha as rt,ia as Ct,oa as j,pa as x,qa as W,ra as q,sa as Q,va as Pt,wa as Y,xa as pe}from"./chunk-TVMOJ2QS.js";import{B as H,C as ee,D as te,E,F as C,G as T,K as B,c as f,d as V,e as N,f as ot,l as ce,m as J,n as L,o as nt,p as k,q as Z,s as $t,t as M,u as oe,w as A,y as g,z as It}from"./chunk-6USORWEP.js";import{b as se,c as tt}from"./chunk-F67UH4FD.js";import{e as U,l as Dt}from"./chunk-7IMLHHSA.js";var le=class{isValid=!1;errors=[];warnings=[];infos=[];get totalIssues(){return this.errors.length+this.warnings.length+this.infos.length}get allDiagnostics(){return[...this.errors,...this.warnings,...this.infos]}};var R=(o=>(o.Info="Info",o.Warning="Warning",o.Error="Error",o))(R||{});var d=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var ut=class p{resolvedDocuments=[];currentEntityPath;withPath(e){let t=new p;return t.resolvedDocuments=this.resolvedDocuments,t.currentEntityPath=e,t}};var re=class{constructor(e){this.underlying=e;this.repository=new dt(e)}underlying;repository;parsePromise=null;getKanonaks(){return this.parseOnce().then(e=>e.merged)}getAuthoredKanonaks(){return this.parseOnce().then(e=>e.authored)}parseOnce(){return this.parsePromise||(this.parsePromise=(async()=>{let e=await this.underlying.getAllDocumentsAsync();await Ut(e,this.repository);let t={};return{merged:await new O().parseKanonaks(this.underlying,t),authored:t.authored??[]}})()),this.parsePromise}},dt=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){let o=`${e}/${t}`,n=this.byNamespaceCache.get(o);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,t),this.byNamespaceCache.set(o,n),n)}getHighestCompatibleVersionAsync(e,t){let o=t.version,n=o?`${o.major}.${o.minor}.${o.patch}`:"",r=`${e}/${t.packageName}@${t.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,t),this.highestVersionCache.set(r,a),a)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};async function S(p,e,t){return t?t.getKanonaks():new O().parseKanonaks(new me(p,e))}async function P(p,e,t){let o=await S(p,e,t),n=at(p);return n?o.filter(r=>r instanceof f&&r.namespace===n):[]}async function ue(p,e,t){let o=at(p);if(!o)return[];let n;if(t)n=await t.getAuthoredKanonaks();else{let r={};await new O().parseKanonaks(new me(p,e),r),n=r.authored??[]}return n.filter(r=>r instanceof f&&r.sourceDoc===o)}function at(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var me=class{constructor(e,t){this.document=e;this.broader=t}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),t=(await this.broader.getAllDocumentsAsync()).filter(o=>o.metadata.namespace_?.toString()!==e);return[this.document,...t]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){return this.broader.getDocumentsByNamespaceAsync(e,t)}getHighestCompatibleVersionAsync(e,t){return this.broader.getHighestCompatibleVersionAsync(e,t)}getAllDocumentReferencesAsync(){return this.broader.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}saveDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}deleteDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}clearNamespaceAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}};async function Bt(p,e,t){let o=new Map;for(let[a,i]of Object.entries(p.metadata?.imports??{}))for(let s of i){if(!se(s))continue;let c=`${a}/${s.packageName}`;o.set(c,{key:c,publisher:a,import_:s,references:[],target:null})}if(o.size===0)return[];let n=(a,i,s)=>{o.get(`${a.publisher}/${a.package_}`)?.references.push({uri:a,where:i,predicate:s})};F(e,({kanonak:a,path:i})=>{for(let s of a.statement){let c=s.predicate?.subject?.name??"(unknown)";if(s instanceof ce)n(s.object.subject,i,c);else if(s instanceof L)for(let l of s.object)l instanceof N&&n(l.subject,i,c);else if(s instanceof nt)for(let l of s.links)l.target&&n(l.target.subject,i,c)}});let r=[...o.values()].filter(a=>a.references.length>0);for(let a of r)try{a.target=await t.getHighestCompatibleVersionAsync(a.publisher,a.import_)}catch(i){a.failure=i instanceof Error?i.message:String(i)}return r}function qt(p,e){return Object.prototype.hasOwnProperty.call(p.body,e)}var de=class{constructor(e={}){this.options=e}options;ruleName="LinkTarget";async validateAsync(e,t,o){let n=[];if(tt(e).size===0)return n;let r=await P(e,t,o);for(let{key:a,references:i,target:s,failure:c}of await Bt(e,r,t)){if(!s){let l=i[0],m=`${i.length} reference${i.length===1?"":"s"}, first at '${l.where}.${l.predicate}'`;this.options.offline?n.push(this.finding("Warning",l.where,l.predicate,a,`Link target package '${a}' could not be resolved offline (${m}); the link is UNVERIFIED, not known to be broken.`,"Run without --offline to verify the link over HTTP, or add the package to the workspace or cache.")):n.push(this.finding("Error",l.where,l.predicate,a,`Link target package '${a}' could not be resolved${c?` (${c})`:""} \u2014 ${m}.`,"Check the publisher and package name of the link import; a link must dereference even though it is not a dependency. Use --offline to validate without the network (the link is then reported as unverified)."));continue}for(let{uri:l,where:m,predicate:u}of i)qt(s,l.name)||n.push(this.finding("Error",m,u,`${a}/${l.name}`,`Link to '${l.name}' in '${u}' at '${m}' does not dereference: package '${a}' (resolved to ${s.metadata.namespace_?.toString()??a}) defines no resource named '${l.name}'.`,`Check for a typo, or a resource renamed or removed in '${a}'; a link addresses a resource by name in its package's current version unless the import is pinned with '='.`))}return n}finding(e,t,o,n,r,a){let i=new d;return i.ruleType=this.ruleName,i.severity=e,i.entityName=t,i.propertyName=o,i.actualValue=n,i.expectedValue="A link that dereferences to a resource its target package defines",i.message=r,i.suggestion=a,i}};var fe=class p{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):[A-Za-z_][A-Za-z0-9_.-]*$/i;ruleName="NamespacePrefix";validate(e){let t=[];for(let[o,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(o,n,t);return t}validateEntity(e,t,o){for(let[n,r]of Object.entries(t)){let a=r?.toString()??"";if(a&&p.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),s=e.split(".")[0],c=new d;c.ruleType=this.ruleName,c.severity="Error",c.entityName=s,c.propertyName=e,c.actualValue=n,c.expectedValue=i,c.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,c.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",o.push(c)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,o)}}getSuggestionForPrefixedValue(e){let t=e.toLowerCase();if(t==="rdfs:class"||t==="owl:class")return"Class";if(t==="rdfs:property"||t==="rdf:property")return"DatatypeProperty or ObjectProperty";if(t.startsWith("xsd:"))return e.substring(4);let o=e.indexOf(":");return o>=0?e.substring(o+1):e}};var ye=class p{static RESERVED_WORDS=new Set(["imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let t=[],o=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[n,r]of Object.entries(e.body)){let a=p.VALID_AUGMENTATION_PATTERN.test(n);if(!a&&!o&&p.RESERVED_WORDS.has(n.toLowerCase())){let i=new d;i.ruleType=this.ruleName,i.severity="Error",i.entityName=n,i.message=`Entity name '${n}' is a reserved word and cannot be used.`,i.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",t.push(i);continue}if(!a&&!p.VALID_NAME_PATTERN.test(n)){let i;/^\d/.test(n)?i="Entity names must start with a letter, not a number.":n.includes(" ")?i="Entity names cannot contain spaces. Use camelCase or underscores instead.":i="Entity names must start with a letter and contain only letters, numbers, and underscores.";let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=n,s.message=`Invalid entity name '${n}'. ${i}`,s.suggestion=i,t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,t)}return t}validatePropertyNames(e,t,o){for(let n of Object.keys(t))if(!p.VALID_PROPERTIES.has(n)&&!p.VALID_PROPERTY_NAME_PATTERN.test(n)){let r=new d;r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=n,r.message=`Property name '${n}' in entity '${e}' doesn't follow naming conventions.`,r.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",o.push(r)}}};var he=class p{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let t=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return t;let o=this.isPropertyDefinedAsClass(e);for(let[n,r]of Object.entries(e.body))if(r&&typeof r=="object"&&!Array.isArray(r)){let a=r,i=a.type;if(i){let s=[];if(Array.isArray(i))for(let c of i){let l=c?.toString();l&&l==="Property"&&!o&&s.push(l)}else{let c=i?.toString();c&&c==="Property"&&!o&&s.push(c)}for(let c of s){let l=this.getPropertyValue(a,"range"),m=this.determinePropertyType(l),u=new d;u.ruleType=this.ruleName,u.severity="Error",u.entityName=n,u.propertyName="type",u.actualValue=c,u.expectedValue=m,u.message=`Invalid property type '${c}'. Use '${m}' instead.`,u.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",t.push(u)}}}return t}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":p.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,t){let o=e[t];return o?o.toString():null}isPropertyDefinedAsClass(e){let t=e.body.Property;if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var ke=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let t=[];for(let[o,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||o.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=o,s.propertyName="type",s.message=`Subject Kanonak '${o}' must have a 'type' property.`,s.suggestion=`Add a type statement like:
|
|
1
|
+
import{a as Ut}from"./chunk-QRF7AT2M.js";import{c as At,g as Nt,h as pt,i as lt,j as Tt,k as xt,l as _t,t as mt,u as Lt,v as Mt}from"./chunk-A4OVTNMT.js";import{a as Et,e as vt}from"./chunk-5FVUBF7N.js";import{a as F,f as z,i as wt,k as O}from"./chunk-A5EAI5ZU.js";import{a as Vt}from"./chunk-VAZY57HJ.js";import{$ as ne,_ as ct,aa as jt,b as St,ba as Ot,ha as rt,ia as Ct,oa as j,pa as x,qa as W,ra as q,sa as Q,va as Pt,wa as Y,xa as pe}from"./chunk-TVMOJ2QS.js";import{B as H,C as ee,D as te,E,F as C,G as T,K as B,c as f,d as V,e as N,f as ot,l as ce,m as J,n as L,o as nt,p as k,q as Z,s as $t,t as M,u as oe,w as A,y as g,z as It}from"./chunk-6USORWEP.js";import{b as se,c as tt}from"./chunk-F67UH4FD.js";import{e as U,l as Dt}from"./chunk-7IMLHHSA.js";var le=class{isValid=!1;errors=[];warnings=[];infos=[];get totalIssues(){return this.errors.length+this.warnings.length+this.infos.length}get allDiagnostics(){return[...this.errors,...this.warnings,...this.infos]}};var R=(o=>(o.Info="Info",o.Warning="Warning",o.Error="Error",o))(R||{});var d=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var ut=class p{resolvedDocuments=[];currentEntityPath;withPath(e){let t=new p;return t.resolvedDocuments=this.resolvedDocuments,t.currentEntityPath=e,t}};var re=class{constructor(e){this.underlying=e;this.repository=new dt(e)}underlying;repository;parsePromise=null;getKanonaks(){return this.parseOnce().then(e=>e.merged)}getAuthoredKanonaks(){return this.parseOnce().then(e=>e.authored)}parseOnce(){return this.parsePromise||(this.parsePromise=(async()=>{let e=await this.underlying.getAllDocumentsAsync();await Ut(e,this.repository);let t={};return{merged:await new O().parseKanonaks(this.underlying,t),authored:t.authored??[]}})()),this.parsePromise}},dt=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){let o=`${e}/${t}`,n=this.byNamespaceCache.get(o);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,t),this.byNamespaceCache.set(o,n),n)}getHighestCompatibleVersionAsync(e,t){let o=t.version,n=o?`${o.major}.${o.minor}.${o.patch}`:"",r=`${e}/${t.packageName}@${t.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,t),this.highestVersionCache.set(r,a),a)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};async function S(p,e,t){return t?t.getKanonaks():new O().parseKanonaks(new me(p,e))}async function P(p,e,t){let o=await S(p,e,t),n=at(p);return n?o.filter(r=>r instanceof f&&r.namespace===n):[]}async function ue(p,e,t){let o=at(p);if(!o)return[];let n;if(t)n=await t.getAuthoredKanonaks();else{let r={};await new O().parseKanonaks(new me(p,e),r),n=r.authored??[]}return n.filter(r=>r instanceof f&&r.sourceDoc===o)}function at(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var me=class{constructor(e,t){this.document=e;this.broader=t}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),t=(await this.broader.getAllDocumentsAsync()).filter(o=>o.metadata.namespace_?.toString()!==e);return[this.document,...t]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){return this.broader.getDocumentsByNamespaceAsync(e,t)}getHighestCompatibleVersionAsync(e,t){return this.broader.getHighestCompatibleVersionAsync(e,t)}getAllDocumentReferencesAsync(){return this.broader.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}saveDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}deleteDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}clearNamespaceAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}};async function Bt(p,e,t){let o=new Map;for(let[a,i]of Object.entries(p.metadata?.imports??{}))for(let s of i){if(!se(s))continue;let c=`${a}/${s.packageName}`;o.set(c,{key:c,publisher:a,import_:s,references:[],target:null})}if(o.size===0)return[];let n=(a,i,s)=>{o.get(`${a.publisher}/${a.package_}`)?.references.push({uri:a,where:i,predicate:s})};F(e,({kanonak:a,path:i})=>{for(let s of a.statement){let c=s.predicate?.subject?.name??"(unknown)";if(s instanceof ce)n(s.object.subject,i,c);else if(s instanceof L)for(let l of s.object)l instanceof N&&n(l.subject,i,c);else if(s instanceof nt)for(let l of s.links)l.target&&n(l.target.subject,i,c)}});let r=[...o.values()].filter(a=>a.references.length>0);for(let a of r)try{a.target=await t.getHighestCompatibleVersionAsync(a.publisher,a.import_)}catch(i){a.failure=i instanceof Error?i.message:String(i)}return r}function qt(p,e){return Object.prototype.hasOwnProperty.call(p.body,e)}var de=class{constructor(e={}){this.options=e}options;ruleName="LinkTarget";async validateAsync(e,t,o){let n=[];if(tt(e).size===0)return n;let r=await P(e,t,o);for(let{key:a,references:i,target:s,failure:c}of await Bt(e,r,t)){if(!s){let l=i[0],m=`${i.length} reference${i.length===1?"":"s"}, first at '${l.where}.${l.predicate}'`;this.options.offline?n.push(this.finding("Warning",l.where,l.predicate,a,`Link target package '${a}' could not be resolved offline (${m}); the link is UNVERIFIED, not known to be broken.`,"Run without --offline to verify the link over HTTP, or add the package to the workspace or cache.")):n.push(this.finding("Error",l.where,l.predicate,a,`Link target package '${a}' could not be resolved${c?` (${c})`:""} \u2014 ${m}.`,"Check the publisher and package name of the link import; a link must dereference even though it is not a dependency. Use --offline to validate without the network (the link is then reported as unverified)."));continue}for(let{uri:l,where:m,predicate:u}of i)qt(s,l.name)||n.push(this.finding("Error",m,u,`${a}/${l.name}`,`Link to '${l.name}' in '${u}' at '${m}' does not dereference: package '${a}' (resolved to ${s.metadata.namespace_?.toString()??a}) defines no resource named '${l.name}'.`,`Check for a typo, or a resource renamed or removed in '${a}'; a link addresses a resource by name in its package's current version unless the import is pinned with '='.`))}return n}finding(e,t,o,n,r,a){let i=new d;return i.ruleType=this.ruleName,i.severity=e,i.entityName=t,i.propertyName=o,i.actualValue=n,i.expectedValue="A link that dereferences to a resource its target package defines",i.message=r,i.suggestion=a,i}};var fe=class p{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):[A-Za-z_][A-Za-z0-9_.-]*$/i;ruleName="NamespacePrefix";validate(e){let t=[];for(let[o,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(o,n,t);return t}validateEntity(e,t,o){for(let[n,r]of Object.entries(t)){let a=r?.toString()??"";if(a&&p.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),s=e.split(".")[0],c=new d;c.ruleType=this.ruleName,c.severity="Error",c.entityName=s,c.propertyName=e,c.actualValue=n,c.expectedValue=i,c.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,c.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",o.push(c)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,o)}}getSuggestionForPrefixedValue(e){let t=e.toLowerCase();if(t==="rdfs:class"||t==="owl:class")return"Class";if(t==="rdfs:property"||t==="rdf:property")return"DatatypeProperty or ObjectProperty";if(t.startsWith("xsd:"))return e.substring(4);let o=e.indexOf(":");return o>=0?e.substring(o+1):e}};var ye=class p{static RESERVED_WORDS=new Set(["imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let t=[],o=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[n,r]of Object.entries(e.body)){let a=p.VALID_AUGMENTATION_PATTERN.test(n);if(!a&&!o&&p.RESERVED_WORDS.has(n.toLowerCase())){let i=new d;i.ruleType=this.ruleName,i.severity="Error",i.entityName=n,i.message=`Entity name '${n}' is a reserved word and cannot be used.`,i.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",t.push(i);continue}if(!a&&!p.VALID_NAME_PATTERN.test(n)){let i;/^\d/.test(n)?i="Entity names must start with a letter, not a number.":n.includes(" ")?i="Entity names cannot contain spaces. Use camelCase or underscores instead.":i="Entity names must start with a letter and contain only letters, numbers, and underscores.";let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=n,s.message=`Invalid entity name '${n}'. ${i}`,s.suggestion=i,t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,t)}return t}validatePropertyNames(e,t,o){for(let n of Object.keys(t))if(!p.VALID_PROPERTIES.has(n)&&!p.VALID_PROPERTY_NAME_PATTERN.test(n)){let r=new d;r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=n,r.message=`Property name '${n}' in entity '${e}' doesn't follow naming conventions.`,r.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",o.push(r)}}};var he=class p{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let t=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return t;let o=this.isPropertyDefinedAsClass(e);for(let[n,r]of Object.entries(e.body))if(r&&typeof r=="object"&&!Array.isArray(r)){let a=r,i=a.type;if(i){let s=[];if(Array.isArray(i))for(let c of i){let l=c?.toString();l&&l==="Property"&&!o&&s.push(l)}else{let c=i?.toString();c&&c==="Property"&&!o&&s.push(c)}for(let c of s){let l=this.getPropertyValue(a,"range"),m=this.determinePropertyType(l),u=new d;u.ruleType=this.ruleName,u.severity="Error",u.entityName=n,u.propertyName="type",u.actualValue=c,u.expectedValue=m,u.message=`Invalid property type '${c}'. Use '${m}' instead.`,u.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",t.push(u)}}}return t}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":p.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,t){let o=e[t];return o?o.toString():null}isPropertyDefinedAsClass(e){let t=e.body.Property;if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var ke=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let t=[];for(let[o,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||o.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=o,s.propertyName="type",s.message=`Subject Kanonak '${o}' must have a 'type' property.`,s.suggestion=`Add a type statement like:
|
|
2
2
|
type: Scene
|
|
3
3
|
|
|
4
4
|
Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,s.expectedValue="A valid class name (Scene, Character, Story, etc.)",t.push(s)}}return t}};var yo=new Set(["EphemeralPackage"]),ge=class{get ruleName(){return"PackageHeader"}validate(e){let t=e.metadata;if(!t.type_)return[];let o=[],n=this.packageKey(e,t.type_);return t.namespace_?(!yo.has(t.type_)&&!t.namespace_.version&&o.push(this.error(n,"version",`Package resource '${n}' requires a 'version' property \u2014 packages are addressed by name@version.`,`Add a version, e.g.:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import h from"ignore";import*as o from"fs";import*as r from"path";var a=class{basePath;matchers=new Map;constructor(e){this.basePath=r.resolve(e)}shouldIgnore(e){return this.excluded(e,!1)}shouldIgnoreDirectory(e){return this.excluded(e,!0)}excluded(e,i){let t=r.relative(this.basePath,r.resolve(e));if(t==="")return!1;if(t===".."||t.startsWith(`..${r.sep}`)||r.isAbsolute(t))throw new Error(`GitIgnoreFilter: ${e} is not under ${this.basePath}`);let s=t.split(r.sep);for(let n=1;n<s.length;n++)if(this.decides(s.slice(0,n),!0))return!0;return this.decides(s,i)}decides(e,i){for(let t=e.length-1;t>=0;t--){let s=this.matcherFor(r.join(this.basePath,...e.slice(0,t)));if(!s)continue;let{ignored:n,unignored:l}=s.test(e.slice(t).join("/")+(i?"/":""));if(n)return!0;if(l)return!1}return!1}matcherFor(e){let i=this.matchers.get(e);if(i===void 0){let t=r.join(e,".gitignore");if(o.existsSync(t))try{i=h().add(o.readFileSync(t,"utf8"))}catch(s){throw new Error(`GitIgnoreFilter: cannot read ${t}`,{cause:s})}else i=null;this.matchers.set(e,i)}return i}};export{a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as j}from"./chunk-
|
|
1
|
+
import{e as j}from"./chunk-AEH3NZLH.js";import{a as I,b as K,c as ee,e as T}from"./chunk-5FVUBF7N.js";import{k as re}from"./chunk-A5EAI5ZU.js";import{oa as _,ra as z}from"./chunk-TVMOJ2QS.js";import{c as G,o as te}from"./chunk-6USORWEP.js";var se=(i=>(i.Class="Class",i.DatatypeProperty="DatatypeProperty",i.ObjectProperty="ObjectProperty",i.AnnotationProperty="AnnotationProperty",i.Instance="Instance",i.Datatype="Datatype",i.Shape="Shape",i.Unknown="Unknown",i))(se||{}),ae=(i=>(i.InstanceOf="instanceOf",i.SubClassOf="subClassOf",i.Domain="domain",i.Range="range",i.ObjectRelationship="objectRelationship",i.SubPropertyOf="subPropertyOf",i.PropertyValue="propertyValue",i.EmbeddedLink="embeddedLink",i))(ae||{}),H=class{static async buildFromRepository(e,r){let s=await new re().parseKanonaks(e),o=await e.getAllDocumentsAsync(),c=[],p=[],i=new Set,h=new Set,b=new Map;for(let g of s){let a=g;if(a.name&&(_.isClassType(a)&&i.add(a.name),g instanceof G)){let d=z(s,g);(d==="ObjectProperty"||d==="Property")&&h.add(a.name)}}for(let g of o)for(let[a,d]of Object.entries(g.body))h.has(a)&&d?.range&&typeof d.range=="string"&&b.set(a,d.range);let w=new Map;for(let g of s){let a=g;a.name&&w.set(a.name,a)}for(let g of o){let a=g.metadata.namespace_,d=a?`${a.publisher}/${a.package_}`:"",u=a?.version?`${a.version.major}.${a.version.minor}.${a.version.patch}`:"",y=ne(g);for(let[f,l]of Object.entries(g.body)){if(!l||typeof l!="object")continue;let A=w.get(f),m="Unknown";if(A){let E=A,k=A instanceof G?z(s,A):void 0;_.isClassType(E)?m="Class":k==="ObjectProperty"?m="ObjectProperty":k==="DatatypeProperty"?m="DatatypeProperty":k==="AnnotationProperty"?m="AnnotationProperty":_.isDatatypeType(E)?m="Datatype":k==="Property"?m="ObjectProperty":_.isShapeType(E)?m="Shape":_.isInstanceOfKnownClass(E,i)&&(m="Instance")}let C=d&&u?`${d}/${f}@${u}`:f,R={};for(let[E,k]of Object.entries(l))E!=="type"&&(typeof k!="object"||k===null)&&(R[E]=k);c.push({id:C,label:l.label??f,type:m,namespace:d,properties:R}),oe(C,l,m,i,h,p,d,u,y,r),q(C,l,h,b,c,p,d,u,y),Ce(C,A,p)}}return{nodes:c,edges:p}}static buildFromDocument(e,r){let n=[],s=[],o=e.metadata.namespace_,c=o?.version?`${o.version.major}.${o.version.minor}.${o.version.patch}`:"",p=o?`${o.publisher}/${o.package_}`:"",i=new Set,h=new Set,b=new Map,w=ne(e);for(let[d,u]of Object.entries(e.body)){let y=u?.type;y&&(be(y,w)&&i.add(d),Pe(y,w)&&(h.add(d),u.range&&typeof u.range=="string"&&b.set(d,u.range)))}for(let[d,u]of Object.entries(e.body)){if(!u||typeof u!="object")continue;let y=u.type,f=Ae(y,d,i,w),l=p&&c?`${p}/${d}@${c}`:d,A={};for(let[m,C]of Object.entries(u))m!=="type"&&(typeof C!="object"||C===null)&&(A[m]=C);n.push({id:l,label:u.label??d,type:f,namespace:p,properties:A}),oe(l,u,f,i,h,s,p,c,w,r),q(l,u,h,b,n,s,p,c,w)}let g=new Set(n.map(d=>d.id)),a=s.filter(d=>g.has(d.source)&&g.has(d.target));return{nodes:n,edges:a}}};function ne(t,e){let r=new Map;if(t.metadata?.imports)for(let[n,s]of Object.entries(t.metadata.imports))for(let o of s){let c=o.alias??o.packageName,p=o.version,i=`${p.major}.${p.minor}.${p.patch}`;r.set(c,{publisher:n,package_:o.packageName,version:i})}return r}var ie={"kanonak.org/core-rdf/Class":"Class","kanonak.org/core-owl/Class":"Class","kanonak.org/core-rdfs/Class":"Class","kanonak.org/core-owl/ObjectProperty":"ObjectProperty","kanonak.org/core-owl/DatatypeProperty":"DatatypeProperty","kanonak.org/core-owl/AnnotationProperty":"AnnotationProperty","kanonak.org/core-rdf/Property":"ObjectProperty","kanonak.org/core-rdfs/Datatype":"Datatype"},ke=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function W(t,e){if(t.includes(".")){let r=t.indexOf("."),n=t.substring(0,r),s=t.substring(r+1),o=e.get(n);if(o)return`${o.publisher}/${o.package_}/${s}`}return null}function be(t,e){let r=W(t,e);return r?ie[r]==="Class":!1}function Pe(t,e){let r=W(t,e);return r?ke.has(r):!1}function Ae(t,e,r,n){if(!t||t==="Package")return"Unknown";let s=W(t,n);if(s){let c=ie[s];if(c)return c;let p=s.split("/").pop()?.split("@")[0]??"";return r.has(p)?"Instance":"Unknown"}let o=t.split(".").pop()??t;return r.has(o)?"Instance":"Unknown"}var ce=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function oe(t,e,r,n,s,o,c,p,i,h){let b=e.type,w=e.subClassOf;if(w){let f=Array.isArray(w)?w:[w];for(let l of f)typeof l=="string"&&o.push({source:t,target:O(l,c,p,i),type:"subClassOf",label:"subClassOf"})}let g=e.subPropertyOf;if(g){let f=Array.isArray(g)?g:[g];for(let l of f)typeof l=="string"&&o.push({source:t,target:O(l,c,p,i),type:"subPropertyOf",label:"subPropertyOf"})}let a=e.domain,d=e.range;if(h?.includePropertyEdges){let f=[[a,"domain","domain"],[d,"range","range"]];for(let[l,A,m]of f)if(l!=null)for(let C of Array.isArray(l)?l:[l])typeof C=="string"&&o.push({source:t,target:O(C,c,p,i),type:A,label:m})}if(r==="Instance"&&b){let f=b.split(".").pop()??b;o.push({source:t,target:O(f,c,p,i),type:"instanceOf",label:"type"})}if(r==="Instance")for(let[f,l]of Object.entries(e)){if(ce.has(f)||!s.has(f))continue;let A=Array.isArray(l)?l:[l];for(let m of A)typeof m=="string"&&Ee(m)&&o.push({source:t,target:O(m,c,p,i),type:"propertyValue",label:f,propertyId:O(f,c,p,i)})}if((r==="ObjectProperty"||r==="DatatypeProperty"||a&&d)&&a&&d){let f=typeof a=="string"?a:null,l=typeof d=="string"?d:null;f&&l&&o.push({source:O(f,c,p,i),target:O(l,c,p,i),type:"objectRelationship",label:e.label??t.split("/").pop()??"",propertyId:t})}}function q(t,e,r,n,s,o,c,p,i){for(let[h,b]of Object.entries(e)){if(ce.has(h)||typeof b!="object"||b===null||Array.isArray(b))continue;let w=b,g=`${t}/${h}`,a=n.get(h),d=a?a.split(".").pop()??a:"Unknown",u={};for(let[f,l]of Object.entries(w))(typeof l!="object"||l===null)&&(u[f]=l);s.push({id:g,label:`${d} (embedded)`,type:"Instance",namespace:c,properties:u});let y=c&&p?`${c}/${h}@${p}`:h;o.push({source:t,target:g,type:"propertyValue",label:h,propertyId:r.has(h)?y:void 0}),a&&o.push({source:g,target:O(d,c,p,i),type:"instanceOf",label:"type (inferred)"}),q(g,w,r,n,s,o,c,p,i)}}function Ce(t,e,r){let n=e?.statement;if(Array.isArray(n))for(let s of n){if(!(s instanceof te))continue;let o=s.predicate?.subject?.name??"";for(let c of s.links){let p=c.target?.subject;if(!p)continue;let i=p.version,h=i&&typeof i.major=="number"?`@${i.major}.${i.minor}.${i.patch}`:"";r.push({source:t,target:`${p.publisher}/${p.package_}/${p.name}${h}`,type:"embeddedLink",label:o})}}}function Ee(t){return!(!t||t.includes(" ")||t.includes(`
|
|
2
2
|
`)||t.startsWith("http://")||t.startsWith("https://")||/^\d{4}-\d{2}/.test(t)||/^\d+(\.\d+)?$/.test(t))}function O(t,e,r,n){if(t.includes("@")&&t.includes("/"))return t;if(t.includes(".")){let s=t.indexOf("."),o=t.substring(0,s),c=t.substring(s+1);if(n){let p=n.get(o);if(p)return`${p.publisher}/${p.package_}/${c}@${p.version}`}return e&&r?`${e}/${c}@${r}`:c}return e&&r?`${e}/${t}@${r}`:t}function M(t){let e=t.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!e)throw new Error("Publisher host cannot be empty");return e}function v(t){let e;try{e=new URL(t)}catch{throw new Error(`credential scope '${t}' is not an absolute URL`)}if(e.protocol!=="https:")throw new Error(`credential scope '${t}' is not https`);if(e.username||e.password)throw new Error(`credential scope '${t}' carries userinfo`);if(e.search||t.includes("?"))throw new Error(`credential scope '${t}' has a query`);if(e.hash||t.includes("#"))throw new Error(`credential scope '${t}' has a fragment`);let r=e.pathname;return{origin:e.origin,prefix:r.endsWith("/")?r:`${r}/`}}function N(t,e){let r=typeof t=="string"?v(t):t,n;try{n=new URL(e)}catch{return!1}if(n.protocol!=="https:"||n.origin!==r.origin)return!1;let s=n.pathname;return s.startsWith(r.prefix)||`${s}/`===r.prefix}function V(t,e){let r,n=-1;for(let s of t){let o=v(s.scope);N(o,e)&&o.prefix.length>n&&(r=s,n=o.prefix.length)}return r}var Oe="key_thumbprint",x=class{cache=new Map;wellKnownCache=new Map;metadataUrlCache=new Map;async protectedResourceMetadata(e){let r=new URL(e).href,n=this.wellKnownCache.get(r);return n||(n=this.fetchWellKnown(r),this.wellKnownCache.set(r,n)),n}async protectedResourceMetadataAt(e,r){let n=new URL(e).href,s=this.metadataUrlCache.get(n);s||(s=this.fetchMetadataAt(n),this.metadataUrlCache.set(n,s));let o=await s,c;try{c=N(v(o.resource),r)}catch(p){throw new Error(`Protected resource metadata at ${n} names an unusable resource '${o.resource}': ${p.message}`)}if(!c)throw new Error(`Protected resource metadata at ${n} names the resource '${o.resource}', which does not contain the requested ${r}. RFC 9728 \xA73.3 forbids using it.`);return o}async fetchWellKnown(e){let r=new URL(e),n=r.pathname==="/"?"":r.pathname,s=`${r.origin}/.well-known/oauth-protected-resource${n}`,o=await j(s,{redirect:"manual"});if(o.status===404||o.status===410||o.status>=300&&o.status<400)return null;if(!o.ok)throw await K("protected resource metadata",s,o);if(!pe(o.headers.get("content-type")))return null;let c=de(s,await o.text());if(!URL.canParse(c.resource)||new URL(c.resource).href!==e)throw new Error(`Protected resource metadata at ${s} names the resource '${c.resource}', not '${e}'. RFC 9728 \xA73.3 forbids using it.`);return c}async fetchMetadataAt(e){let r=await j(e,{redirect:"manual"});if(!r.ok)throw await K("protected resource metadata",e,r);if(!pe(r.headers.get("content-type")))throw new Error(`Protected resource metadata at ${e} is not a JSON document (${r.headers.get("content-type")??"no content type"})`);return de(e,await r.text())}async discover(e){let r=M(e);if(this.cache.has(r))return this.cache.get(r);let n=`https://${r}/.well-known/oauth-authorization-server`,s=await this.tryEndpoint(n);if(!s){let o=`https://${r}/.well-known/openid-configuration`;s=await this.tryEndpoint(o)}return this.cache.set(r,s),s}async supportsOAuth(e){return await this.discover(e)!==null}static supportsPkceS256(e){return e.codeChallengeMethodsSupported?.some(r=>r.toUpperCase()==="S256")??!1}static supportsDynamicRegistration(e){return!!e.registrationEndpoint}static supportsAuthorizationCode(e){return e.responseTypesSupported?.some(r=>r.toLowerCase()==="code")??!1}static supportsEnrollment(e){return!!e.enrollmentEndpoint}static supportsSession(e){return!!e.sessionEndpoint}async tryEndpoint(e){let r;try{r=await fetch(e)}catch(s){let o=s instanceof Error?s.message:String(s);return o.includes("ENOTFOUND")||o.includes("ECONNREFUSED")?(console.error(` OAuth discovery: ${e} \u2014 host unreachable (${o})`),console.error(" If the server is behind a VPN, ensure you are connected.")):o.includes("CERT")||o.includes("SSL")||o.includes("TLS")?(console.error(` OAuth discovery: ${e} \u2014 TLS error (${o})`),console.error(" If using a custom CA certificate, set NODE_EXTRA_CA_CERTS=/path/to/ca.pem")):console.error(` OAuth discovery: ${e} \u2014 network error: ${o}`),null}if(!r.ok)return r.status===404||(r.status===403?(console.error(` OAuth discovery: ${e} \u2014 HTTP 403 Forbidden`),console.error(" Access may be blocked by a firewall, proxy, or WAF.")):r.status>=500&&(console.error(` OAuth discovery: ${e} \u2014 HTTP ${r.status} server error`),console.error(" The authorization server returned an internal error. Contact your IDP administrator."))),null;let n;try{n=await r.json()}catch{return console.error(` OAuth discovery: ${e} \u2014 response is not valid JSON`),console.error(" The endpoint may be returning HTML instead of JSON. Check IDP configuration."),null}return{issuer:$(n.issuer),authorizationEndpoint:$(n.authorization_endpoint),tokenEndpoint:$(n.token_endpoint),registrationEndpoint:$(n.registration_endpoint),revocationEndpoint:$(n.revocation_endpoint),scopesSupported:S(n.scopes_supported),responseTypesSupported:S(n.response_types_supported),grantTypesSupported:S(n.grant_types_supported),codeChallengeMethodsSupported:S(n.code_challenge_methods_supported),tokenEndpointAuthMethodsSupported:S(n.token_endpoint_auth_methods_supported),dpopSigningAlgValuesSupported:S(n.dpop_signing_alg_values_supported),enrollmentEndpoint:$(n.enrollment_endpoint),enrollmentIssuanceProtocols:S(n.enrollment_issuance_protocols),enrollmentKeyTypes:S(n.enrollment_key_types),enrollmentScopesSupported:S(n.enrollment_scopes_supported),enrollmentConsentBindingParam:$(n.enrollment_consent_binding_param),sessionEndpoint:$(n.session_endpoint),sessionEndpointAuthMethod:$(n.session_endpoint_auth_method)}}};function pe(t){let e=(t??"").split(";")[0].trim().toLowerCase();return e==="application/json"||e.endsWith("+json")}function de(t,e){let r;try{r=JSON.parse(e)}catch{throw new Error(`Protected resource metadata at ${t} is not valid JSON`)}if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`Protected resource metadata at ${t} is not a JSON object`);let n=r;if(typeof n.resource!="string")throw new Error(`Protected resource metadata at ${t} has no "resource"`);let s=n.authorization_servers;if(s!==void 0&&!(Array.isArray(s)&&s.every(o=>typeof o=="string")))throw new Error(`Protected resource metadata at ${t} has an "authorization_servers" that is not a list of strings`);return{resource:n.resource,authorizationServers:s??[]}}function $(t){return typeof t=="string"?t:null}function S(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):null}var D=1,$e=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Se=/[\r\n\0]/;function P(t,e){return{ok:!1,problem:t,message:e}}function L(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function U(t,e,r){if(!L(e))return P("malformed","the answer is not a JSON object");if(e.status==="declined")return e.reason!==void 0&&typeof e.reason!="string"?P("reason",`a decline's "reason" must be a string`):{ok:!0,answer:e.reason===void 0?{status:"declined"}:{status:"declined",reason:e.reason}};if(e.status!=="credential")return P("status",`"status" must be "credential" or "declined", not ${JSON.stringify(e.status)}`);let n=e.headers;if(!L(n)||Object.keys(n).length===0)return P("headers",'a credential needs "headers": an object with at least one header');let s={};for(let[i,h]of Object.entries(n)){if(!$e.test(i))return P("headers",`header name ${JSON.stringify(i)} is not a valid field name`);if(typeof h!="string"||Se.test(h))return P("headers",`header '${i}' must be a string without CR, LF or NUL`);s[i]=h}if(typeof e.scope!="string")return P("scope",'a credential needs a "scope" string');let o;try{o=v(e.scope)}catch(i){return P("scope",i.message)}if(!N(o,t.resource))return P("scope-excludes-resource",`scope '${e.scope}' does not contain the requested resource ${t.resource}`);let c;if(e.expiresAt!==void 0){if(typeof e.expiresAt!="number"||!Number.isFinite(e.expiresAt))return P("expires-at",'"expiresAt" must be a number of Unix seconds');if(e.expiresAt<=r)return P("expired",`the credential expired at ${e.expiresAt} (now ${Math.floor(r)})`);c=e.expiresAt}let p={status:"credential",headers:s,scope:e.scope};return c!==void 0&&(p.expiresAt=c),{ok:!0,answer:p}}function Re(t,e,r){return L(e)?e.version!==D?P("version",`"version" must be ${D}, not ${JSON.stringify(e.version)}`):U(t,e,r):P("malformed","the answer is not a JSON object")}function Te(t){return L(t)?t.version!==D?P("version",`"version" must be ${D}, not ${JSON.stringify(t.version)}`):t.status!=="erased"?P("status",`"status" must be "erased", not ${JSON.stringify(t.status)}`):{ok:!0,answer:{status:"erased"}}:P("malformed","the answer is not a JSON object")}function B(t){let e=new J(t),r=[];for(e.skipListSeparators();!e.atEnd();){let n=e.token();if(!n)throw e.error("expected an auth-scheme");let s={scheme:n,params:{}};r.push(s);let o=e.skipSpaces();if(e.atEnd()||e.peek()===","){e.skipListSeparators();continue}if(!o)throw e.error(`expected a space after the auth-scheme '${n}'`);let c=e.tryParam();if(c)for(ue(s,c,e);e.skipOws(),!e.atEnd();){if(e.peek()!==",")throw e.error('expected "," between auth-params');if(e.skipListSeparators(),e.atEnd())break;let p=e.pos,i=e.tryParam();if(!i){e.pos=p;break}ue(s,i,e)}else{let p=e.token68();if(!p)throw e.error(`expected a token68 or auth-params after '${n}'`);if(s.token68=p,e.skipOws(),!e.atEnd()&&e.peek()!==",")throw e.error("unexpected text after token68")}e.skipListSeparators()}return r}function ue(t,[e,r],n){if(Object.prototype.hasOwnProperty.call(t.params,e))throw n.error(`auth-param '${e}' appears twice in the '${t.scheme}' challenge`);t.params[e]=r}var ve=/[!#$%&'*+\-.^_`|~0-9A-Za-z]/,xe=/[A-Za-z0-9\-._~+/]/,J=class{constructor(e){this.s=e}s;pos=0;atEnd(){return this.pos>=this.s.length}peek(){return this.s[this.pos]}error(e){return new Error(`Malformed WWW-Authenticate (${e} at offset ${this.pos}): ${this.s}`)}skipSpaces(){let e=this.pos;for(;!this.atEnd()&&(this.peek()===" "||this.peek()===" ");)this.pos++;return this.pos>e}skipOws(){this.skipSpaces()}skipListSeparators(){for(;;){if(this.skipOws(),this.peek()!==",")return;this.pos++}}token(){let e=this.pos;for(;!this.atEnd()&&ve.test(this.peek());)this.pos++;return this.s.slice(e,this.pos)}token68(){let e=this.pos;for(;!this.atEnd()&&xe.test(this.peek());)this.pos++;if(this.pos===e)return"";for(;!this.atEnd()&&this.peek()==="=";)this.pos++;return this.s.slice(e,this.pos)}tryParam(){let e=this.pos,r=this.token();if(!r)return null;if(this.skipOws(),this.peek()!=="=")return this.pos=e,null;this.pos++,this.skipOws();let n;if(this.peek()==='"')n=this.quotedString();else if(n=this.token(),!n)return this.pos=e,null;return[r.toLowerCase(),n]}quotedString(){this.pos++;let e="";for(;;){if(this.atEnd())throw this.error("unterminated quoted-string");let r=this.s[this.pos++];if(r==='"')return e;if(r==="\\"){if(this.atEnd())throw this.error("unterminated quoted-pair");e+=this.s[this.pos++]}else e+=r}}};var ye=30;function _e(t,e={}){let r=e.discovery??new x,n=e.nowSeconds??(()=>Date.now()/1e3),s=[],o=new WeakSet,c=new Map,p=new Map,i=a=>{let d=n();return s=s.filter(u=>u.expiresAt===void 0||u.expiresAt-ye>d),V(s,a)},h=(a,d)=>{let u=(p.get(a)??Promise.resolve()).then(d);return p.set(a,u.then(()=>{},()=>{})),u},b=a=>{let d=c.get(a);return d||(d=r.protectedResourceMetadata(a).then(u=>u!==null,u=>{if(u instanceof I&&(u.status===401||u.status===403))return!0;throw new T(`Could not learn whether ${a} requires a credential: ${me(u)}`)}),c.set(a,d)),d},w=async(a,d)=>{let u=U(d,await le(()=>a.get(d),d.resource),n());if(!u.ok)throw new T(`The credential provider answered for ${d.resource} outside the protocol (${u.problem}): ${u.message}`);let y=u.answer;if(y.status==="declined")return y.reason===void 0?{}:{declined:y.reason};let f={headers:y.headers,scope:y.scope};return y.expiresAt!==void 0&&(f.expiresAt=y.expiresAt),s=s.filter(l=>l.scope!==f.scope),s.push(f),f},g=(a,d,u)=>j(a,{method:d,redirect:"manual",headers:u?.headers??{}});return async(a,d,u="GET")=>{let y=new URL(a).origin,f=i(a);if(!f&&t&&await b(y)){let k=await h(y,async()=>i(a)??w(t,{resource:a,method:u}));fe(k)&&(f=k)}let l=await g(a,u,f);if(l.status!==401&&l.status!==403)return l;let A=ge(l,a),m=l.status===401;if(!m&&!he(A))return l;if(c.set(y,Promise.resolve(!0)),!t)throw await Y(`${a} requires a credential, and no credential provider is configured`,l);let C={resource:a,method:u,challenges:A},R=await h(y,async()=>{let k=i(a);if(k&&k!==f)return k;if(m&&f&&!o.has(f)){o.add(f);let Q=f;s=s.filter(we=>we!==Q),await le(()=>t.erase({...C,scope:Q.scope}),a)}return w(t,C)});if(!fe(R)){let k=R.declined?`: ${R.declined}`:"";throw await Y(`${a} requires a credential, and the credential provider declined${k}`,l)}let E=await g(a,u,R);if(E.status===401||E.status===403&&he(ge(E,a)))throw await Y(`${a} rejected the credential for ${R.scope} after asking the provider again`,E);return E}}async function le(t,e){try{return await t()}catch(r){throw r instanceof T?r:new T(`The credential provider failed for ${e}: ${me(r)}`)}}function me(t){return t instanceof Error?t.message:String(t)}function fe(t){return"scope"in t}function he(t){return t.some(e=>e.params.error==="insufficient_scope")}function ge(t,e){let r=t.headers.get("www-authenticate");if(!r)return[];try{return B(r)}catch(n){throw new T(`${e} answered ${t.status} with a challenge that cannot be read: ${n.message}`)}}async function Y(t,e){return new T(`${t}. The server answered ${await ee(e)}`)}var F="KANONAK_TOKEN";function Ne(){return typeof process<"u"&&process.env?process.env:{}}function Z(t){return`${F}_${M(t).toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}var X=class{tokens;env;discovery;constructor(e={}){this.tokens=e.tokens??{},this.env=e.env??Ne(),this.discovery=e.discovery??new x}async get(e){let r=await this.metadataFor(e);if("declined"in r)return{status:"declined",reason:r.declined};let n=r.metadata;if(n.authorizationServers.length===0)return{status:"declined",reason:`the protected-resource metadata for ${n.resource} names no authorization server`};let s=n.authorizationServers.map(o=>new URL(o).host);for(let o of s){let c=this.tokens[o]??this.env[Z(o)]??this.env[F];if(c)return{status:"credential",headers:{Authorization:`Bearer ${c}`},scope:n.resource}}return{status:"declined",reason:`no token is configured for ${s.join(" or ")}: set ${s.map(Z).join(" or ")}, or ${F}`}}async erase(){}async metadataFor(e){let r=e.challenges?.find(o=>o.params.resource_metadata!==void 0)?.params.resource_metadata;if(r!==void 0)return{metadata:await this.discovery.protectedResourceMetadataAt(r,e.resource)};let n=new URL(e.resource).origin,s;try{s=await this.discovery.protectedResourceMetadata(n)}catch(o){if(o instanceof I&&(o.status===401||o.status===403))return{declined:`${n} requires a credential even for its protected-resource metadata, and its challenge names no resource_metadata`};throw o}return s?{metadata:s}:{declined:`${n} publishes no RFC 9728 protected-resource metadata naming its authorization server, so no token is presented to it`}}};export{se as a,ae as b,H as c,M as d,v as e,N as f,V as g,Oe as h,x as i,D as j,U as k,Re as l,Te as m,B as n,ye as o,_e as p,F as q,Z as r,X as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as i,p as r,q as t,u as o,v as s}from"./chunk-AEH3NZLH.js";import{readFileSync as c,writeFileSync as u,existsSync as a}from"fs";import{createHash as d}from"crypto";var l="kanonak.lock";function g(e=l){return a(e)?r(c(e,"utf-8")):null}function k(e,n=l){e.lastUpdated=new Date().toISOString(),u(n,t(e),"utf-8")}function y(e){let n=d("sha256").update(e).digest("hex");return`${i}${n}`}import{readFileSync as f,writeFileSync as x,existsSync as p}from"fs";function v(e){return p(e)?o(f(e,"utf-8"),e):null}function w(e,n){x(n,s(e),"utf-8")}export{g as a,k as b,y as c,v as d,w as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d}from"./chunk-F67UH4FD.js";import{a as l,b as f}from"./chunk-7IMLHHSA.js";import*as c from"js-yaml";var g=new Set(["Package","EphemeralPackage"]);function h(m){return typeof m=="string"&&g.has(m)}var y=class{parse(e){let r=this.parseWithErrors(e);if(!r.isValid){let n=r.errors[0];throw new Error(`YAML parse error at line ${n.line}, column ${n.column}: ${n.message}`)}return r.document}parseWithErrors(e){let r=[],n;try{e=e.replace(/^\uFEFF/,"");let a=c.load(e,{schema:c.FAILSAFE_SCHEMA});if(!a||typeof a!="object")return n={metadata:this.createEmptyMetadata(),body:{},toString:()=>"KanonakDocument(empty)"},{document:n,errors:r,isValid:!0};let t=this.extractMetadata(a),o=this.extractBody(a,t);return n={metadata:t,body:o,toString:function(){return this.metadata.namespace_?`KanonakDocument(${this.metadata.namespace_.publisher}/${this.metadata.namespace_.package_})`:"KanonakDocument(no namespace)"}},{document:n,errors:r,isValid:!0}}catch(a){let t=a,o=t.mark?t.mark.line+1:0,i=t.mark?t.mark.column+1:0,s={message:t.message||"Unknown parse error",line:o,column:i,errorType:t.name==="YAMLException"?"SyntaxError":"Unknown",toString:()=>`${t.name==="YAMLException"?"SyntaxError":"Unknown"} at line ${o}: ${t.message||"Unknown parse error"}`};return r.push(s),{document:void 0,errors:r,isValid:!1}}}save(e){let r={};if(e.metadata.namespace_){let n=e.metadata.namespace_,a={type:"Package",publisher:n.publisher};n.version&&(a.version=`${n.version.major}.${n.version.minor}.${n.version.patch}`),e.metadata.imports&&(a.imports=this.serializeImports(e.metadata.imports)),r[n.package_]=a}for(let[n,a]of Object.entries(e.body)){let t=r[n];r[n]=t!==void 0&&a&&typeof a=="object"&&!Array.isArray(a)?{...t,...a}:a}return c.dump(r,{indent:2,noRefs:!0,sortKeys:!1})}createEmptyMetadata(){return{get allImports(){return[]}}}addAllImportsGetter(e){let r=e.imports;return Object.defineProperty(e,"allImports",{get:function(){if(!r)return[];let n=[];for(let a of Object.values(r))n.push(...a);return n},enumerable:!0,configurable:!0}),e}createVersion(e,r,n){return{major:e,minor:r,patch:n,toString:()=>`${e}.${r}.${n}`,equals:t=>!t||typeof t!="object"?!1:t.major===e&&t.minor===r&&t.patch===n,getHashCode:()=>e<<20|r<<10|n,compareTo:t=>e!==t.major?e-t.major:r!==t.minor?r-t.minor:n-t.patch}}extractMetadata(e){let r=this.createEmptyMetadata();for(let[n,a]of Object.entries(e))if(a&&typeof a=="object"&&h(a.type)){r.type_=a.type;let t=n,o=a.publisher,i=a.version?this.parseVersion(a.version):void 0;return o&&t&&(r.namespace_={publisher:o,package_:t,version:i,toString:function(){return this.version?`${this.publisher}/${this.package_}@${this.version.major}.${this.version.minor}.${this.version.patch}`:`${this.publisher}/${this.package_}`},equals:s=>!s||typeof s!="object"?!1:s.publisher===o&&s.package_===t&&(!i||!s.version||i.equals(s.version)),getHashCode:()=>{let s=0;for(let p=0;p<o.length;p++)s=(s<<5)-s+o.charCodeAt(p);for(let p=0;p<t.length;p++)s=(s<<5)-s+t.charCodeAt(p);return s|0}}),a.imports&&Array.isArray(a.imports)&&(r.imports=this.parseImportsV3(a.imports)),this.addAllImportsGetter(r)}return r}extractBody(e,r){let n={};for(let[a,t]of Object.entries(e))if(t&&typeof t=="object"&&h(t.type)){let o={};for(let[i,s]of Object.entries(t))i==="publisher"||i==="version"||i==="imports"||(o[i]=s);n[a]=o}else n[a]=t;return n}parseVersion(e){if(typeof e=="string"){let r=e.split(".").map(Number);return this.createVersion(r[0]||0,r[1]||0,r[2]||0)}return this.createVersion(e.major||0,e.minor||0,e.patch||0)}parseImportsV3(e){let r={};for(let n of e)if(!(!n||typeof n!="object"))if(n.packages&&Array.isArray(n.packages)){let a=n.publisher;if(!a)throw new Error("PublisherImport requires 'publisher' property");r[a]||(r[a]=[]);for(let t of n.packages){if(!t||typeof t!="object")continue;let o=this.parseImportFromEmbeddedObject(t,a);r[a].push(o)}}else{let a=this.parseImportFromEmbeddedObject(n,n.publisher),t=a.publisher||"";r[t]||(r[t]=[]),r[t].push(a)}return r}parseImportFromEmbeddedObject(e,r){let n=e.package;if(!n)throw new Error("Import requires 'package' property");let a=e.match;if(!a)throw new Error("Import requires 'match' property");let t=e.version;if(!t)throw new Error("Import requires 'version' property");let o;if(e.mode!==void 0&&e.mode!==null){if(!d.includes(e.mode))throw new Error(`Import '${n}' has an unknown mode '${e.mode}'; expected one of: ${d.join(", ")}`);o=e.mode}return this.makeImport(n,a,t,r,e.alias,o)}makeImport(e,r,n,a,t,o){let i=this.parseVersion(n),s=this.parseVersionOperator(r),p=this.calculateMaxVersion(r,i);return{package_:`${e} ${r} ${i.toString()}`,publisher:a,packageName:e,versionOperator:s,version:i,alias:t,...o?{mode:o}:{},minVersion:i,maxVersion:p,toEmbeddedObject:()=>{let u={package:e,match:r,version:i.toString()};return t&&(u.alias=t),o&&(u.mode=o),u},toString:()=>t?`${e} ${r} ${i.toString()} as ${t}`:`${e} ${r} ${i.toString()}`}}buildImport(e,r,n,a){return this.makeImport(e,r,n,a)}parseVersionOperator(e){return l(e)}calculateMaxVersion(e,r){switch(e){case"~":return this.createVersion(r.major,r.minor+1,0);case"^":return r.major===0?this.createVersion(0,r.minor+1,0):this.createVersion(r.major+1,0,0);default:return this.createVersion(999,999,999)}}serializeImports(e){let r=[];for(let[n,a]of Object.entries(e)){let t={publisher:n,packages:a.map(o=>{let i=f(o.versionOperator),s={package:o.packageName,match:i,version:`${o.version.major}.${o.version.minor}.${o.version.patch}`};return o.alias&&(s.alias=o.alias),s})};r.push(t)}return r}};export{y as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as m,j as i}from"./chunk-7IMLHHSA.js";var u=class{documents=new Map;documentContents=new Map;parser;constructor(e){this.parser=e}async getAllDocumentsAsync(){return Array.from(this.documents.values())}async getDocumentAsync(e){return this.documents.get(e)??null}async getDocumentsByNamespaceAsync(e,n){let t=[];for(let s of this.documents.values())s.metadata?.namespace_?.publisher===e&&s.metadata?.namespace_?.package_===n&&t.push(s);return t}async getHighestCompatibleVersionAsync(e,n){let t=[];for(let a of this.documents.values())a.metadata?.namespace_?.publisher===e&&a.metadata?.namespace_?.package_===n.packageName&&a.metadata?.namespace_?.version!==void 0&&t.push(a);if(t.length===0)return null;let s=t.filter(a=>{let o=a.metadata.namespace_.version;return o?i(o,n):!1});return s.length===0?null:(s.sort((a,o)=>{let r=a.metadata.namespace_.version,c=o.metadata.namespace_.version;return!r&&!c?0:r?c?m(c,r):-1:1}),s[0])}async saveDocumentAsync(e,n,t){this.documents.set(n,e),this.documentContents.set(n,t??this.parser.save(e))}async deleteDocumentAsync(e){this.documents.delete(e),this.documentContents.delete(e)}async clearNamespaceAsync(e,n){let t=[];for(let[s,a]of this.documents.entries())a.metadata?.namespace_?.publisher===e&&a.metadata?.namespace_?.package_===n&&t.push(s);for(let s of t)this.documents.delete(s),this.documentContents.delete(s)}async getAllDocumentReferencesAsync(){let e=[];for(let n of this.documents.values())n.metadata?.namespace_&&e.push({identifier:n.metadata.namespace_.toString(),uri:`kanonak://${n.metadata.namespace_}`,hasParseError:!1});return e}async getDocumentContentAsync(e){let n=this.documentContents.get(e);if(n!==void 0)return n;let t=this.documents.get(e);return t!==void 0?this.parser.save(t):null}async getDocumentUriAsync(e){let n=this.documents.get(e);return n?n.metadata?.namespace_?`kanonak://${n.metadata.namespace_}`:`kanonak://${e}`:null}};export{u as a};
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
import type { IGitIgnoreFilter } from './IGitIgnoreFilter.js';
|
|
2
|
+
/**
|
|
3
|
+
* Which paths under a folder its `.gitignore` files exclude, read the way git
|
|
4
|
+
* reads them (typescript#142):
|
|
5
|
+
* - the `.gitignore` in each directory from `basePath` down applies to the
|
|
6
|
+
* paths beneath that directory, relative to it;
|
|
7
|
+
* - a deeper file's decision overrides a shallower one's, and within a file
|
|
8
|
+
* the last matching pattern wins, so `!keep.kan.yml` re-includes a file;
|
|
9
|
+
* - nothing under an excluded directory is re-included.
|
|
10
|
+
*
|
|
11
|
+
* Patterns are git's (the `ignore` package): `kits/` names a directory,
|
|
12
|
+
* `/kits` only the one at that file's level. Only the `.gitignore` files at
|
|
13
|
+
* `basePath` and below are read, never git's global excludes or
|
|
14
|
+
* `.git/info/exclude`, so the answer depends on the folder alone. A
|
|
15
|
+
* `.gitignore` that cannot be read is an error.
|
|
16
|
+
*/
|
|
2
17
|
export declare class GitIgnoreFilter implements IGitIgnoreFilter {
|
|
3
|
-
private readonly ignoreInstance;
|
|
4
18
|
private readonly basePath;
|
|
19
|
+
/** Each directory's parsed `.gitignore`, or null when it has none. */
|
|
20
|
+
private readonly matchers;
|
|
5
21
|
constructor(basePath: string);
|
|
6
22
|
shouldIgnore(absolutePath: string): boolean;
|
|
23
|
+
shouldIgnoreDirectory(absolutePath: string): boolean;
|
|
24
|
+
private excluded;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the `.gitignore` files exclude this one path, its ancestors being
|
|
27
|
+
* included: the deepest file with a matching pattern decides.
|
|
28
|
+
*/
|
|
29
|
+
private decides;
|
|
30
|
+
private matcherFor;
|
|
7
31
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export interface IGitIgnoreFilter {
|
|
2
|
+
/** Whether the file at this path is excluded. */
|
|
2
3
|
shouldIgnore(absolutePath: string): boolean;
|
|
4
|
+
/** Whether the directory at this path is excluded, and with it everything under it. */
|
|
5
|
+
shouldIgnoreDirectory(absolutePath: string): boolean;
|
|
3
6
|
}
|
package/dist/filtering/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import"../chunk-BA5J2DKJ.js";import{a}from"../chunk-PC3DHZGV.js";export{a as GitIgnoreFilter};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { InMemoryKanonakDocumentRepository, FileSystemKanonakDocumentRepository, CompositeKanonakDocumentRepository, RepositoryFactory, DocumentLocation, HttpKanonakDocumentRepository, LocalFirstRepository, LockAwareRepository, buildLocalFirstRepository, collectKanonakFiles, PublisherIndex, PublisherConfigResolver, getGlobalCachePath, ANY_PUBLISHER, checkPackageUrlTemplates, checkPackageUrlTemplate, packageUrlTemplateFor, fillPackageUrlTemplate, } from './repositories/index.js';
|
|
2
|
-
export type { PublisherConfig, HttpCacheHooks, HttpCacheRead, HttpCacheWrite, PackageUrlTemplates } from './repositories/index.js';
|
|
2
|
+
export type { PublisherConfig, HttpCacheHooks, HttpCacheRead, HttpCacheWrite, PackageUrlTemplates, IgnoredKanonakPath, CollectKanonakFilesOptions } from './repositories/index.js';
|
|
3
3
|
export { GraphBuilder, NodeType, EdgeType } from './graph/index.js';
|
|
4
4
|
export type { GraphNode, GraphEdge, GraphData } from './graph/index.js';
|
|
5
5
|
export { Reasoner, ReasoningResult, TripleStore, KanonakVocabulary, OWL_HAS_KEY, builtinUri, builtinHomePackages, uriKey, makeUriKey, tripleKey, uriTriple, RDFS_RULES, OWL_RL_CLASSIFICATION_RULES, } from './reasoning/index.js';
|
|
@@ -35,8 +35,8 @@ export type { PackageUrlTemplatesConfigOptions } from './config/packageUrlTempla
|
|
|
35
35
|
export { kanonakFetch, assertHttpsUrl, setKanonakFetchRetries, setKanonakUserAgent, getKanonakUserAgent, KANONAK_USER_AGENT, } from './http/kanonakFetch.js';
|
|
36
36
|
export { KanonakHttpError, httpError, describeResponse, retryAfterSecondsOf } from './http/HttpError.js';
|
|
37
37
|
export type { ProblemDetails } from './http/HttpError.js';
|
|
38
|
-
export { loadLockFile, saveLockFile, computeIntegrity, parseLockFile, serializeLockFile, computeIntegrityAsync, assertIntegrityAsync, lockedVersion, INTEGRITY_PREFIX, } from './lock/index.js';
|
|
39
|
-
export type { LockFile, LockEntry } from './lock/index.js';
|
|
38
|
+
export { loadLockFile, saveLockFile, computeIntegrity, parseLockFile, serializeLockFile, computeIntegrityAsync, assertIntegrityAsync, lockedVersion, INTEGRITY_PREFIX, VERSION_INDEX_FILE, parseVersionIndex, serializeVersionIndex, indexedVersion, planVersionIndex, setYanked, loadVersionIndex, saveVersionIndex, } from './lock/index.js';
|
|
39
|
+
export type { LockFile, LockEntry, VersionIndex, IndexedVersion, PublishedSource, VersionIndexChange, VersionIndexRefusal, VersionIndexPlan, } from './lock/index.js';
|
|
40
40
|
export { findDerivation } from './derivation/index.js';
|
|
41
41
|
export type { DerivationEntityUri, TransformationReferenceTuple, DerivationLookupResult, } from './derivation/index.js';
|
|
42
42
|
export { LookRenderer, resolveDisplayValue, URI_DISPLAY_LABEL, URI_DISPLAY_SUMMARY, supportedBandKeys } from './look/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as tr,b as rr,c as ir,d as ar,e as z}from"./chunk-IXCD4K3K.js";import{a as uo,b as lo,c as po,d as fo,e as mo}from"./chunk-RXIKK3KZ.js";import{a as er,b as nr,c as or,d as hi,e as Si,f as gi,g as ki,h as yi,i as Ei,j as Ze,k as Ci,l as en,m as nn,n as bi,o as _i,p as Pi,q as ve,r as Ri,s as on}from"./chunk-RFSARH5S.js";import{a as vi}from"./chunk-FYAZ345F.js";import{a as ui,b as li,c as pi,d as ne,e as fi,f as mi,g as Je,h as wi,i as xi,j as Ki,k as Ii,l as Oi}from"./chunk-4NTZY2KP.js";import{a as Jo,b as Zo,c as et,d as nt,e as ot,f as bt,g as _t,h as Rt,i as vt}from"./chunk-7PTZF5LK.js";import{A as Ct,a as st,b as ct,c as dt,d as ut,e as lt,f as pt,g as Ve,h as Me,i as Ue,j as St,k as gt,m as kt,n as Sn,o as gn,p as kn,q as yn,r as En,s as Cn,t as bn,u as _n,v as Pn,w as Rn,x as vn,y as wn,z as yt}from"./chunk-AEH3NZLH.js";import{a as sr,b as cr,c as dr,d as ur,e as lr,f as pr}from"./chunk-C5HHCD6P.js";import{a as fr,b as hr}from"./chunk-TR7PC72M.js";import{a as Et}from"./chunk-SC5M74NM.js";import{A as jr,B as Dr,C as Tr,D as Fr,E as Wr,F as qr,G as Br,H as Gr,I as ti,J as ri,K as ii,L as ai,M as si,N as ci,O as di,a as Sr,b as gr,c as kr,d as yr,e as Er,f as ro,g as io,h as Cr,i as br,j as _r,k as Pr,l as Rr,m as vr,n as wr,o as xr,p as Kr,q as Ir,r as Or,s as Nr,t as Ar,u as Lr,v as Vr,w as Mr,x as Ur,y as $r,z as Hr}from"./chunk-IZBZDLCX.js";import{a as oo,b as to}from"./chunk-QRF7AT2M.js";import{c as ao,d as zr,e as Xr,f as Yr,g as Qr,i as Jr,j as Zr,m as ei,o as Qe,q as so,s as co,u as ni,v as oi}from"./chunk-A4OVTNMT.js";import"./chunk-QHABFCRC.js";import{a as tt,b as rt,c as it,d as at,e as L}from"./chunk-5FVUBF7N.js";import{a as Le}from"./chunk-YEUSFSC7.js";import{a as Xe,g as D,h as Ye,i as Jt,j as Zt,k as M}from"./chunk-A5EAI5ZU.js";import{a as X}from"./chunk-VAZY57HJ.js";import{a as mr}from"./chunk-PEJALHXK.js";import{$ as Re,A as Tn,B as Fn,C as Wn,D as qn,E as Bn,F as Gn,G as zn,H as Xn,I as Yn,J as Qn,K as Te,L as Jn,M as Zn,N as eo,O as me,P as he,Q as Se,R as ge,S as ke,T as ye,U as Ee,V as Ce,W as be,X as _e,Y as Pe,Z,_ as no,a as Ht,aa as Fe,b as jt,ba as We,c as Q,ca as W,d as Tt,da as H,e as Ft,ea as j,fa as q,g as Wt,ga as qe,h as le,i as pe,j as Kn,ja as qt,k as J,ka as Bt,l as fe,m as In,ma as Gt,n as On,o as je,oa as zt,p as Nn,pa as E,q as An,qa as Ge,r as Ln,ra as Xt,s as Vn,sa as ze,t as De,u as Mn,v as Un,va as Yt,w as $n,wa as Qt,x as Hn,xa as G,y as jn,z as Dn}from"./chunk-TVMOJ2QS.js";import{B as F,C as O,D as ue,E as k,F as Y,G as He,H as ee,I as B,K as Be,a as wt,b as xt,c as g,d as V,e as K,f as Kt,g as It,h as Ot,i as Nt,j as At,k as Lt,l as Vt,m as Mt,n as Ut,o as $t,p,s as Dt,t as T,u as $e,v as xn,w as de,y as I}from"./chunk-6USORWEP.js";import"./chunk-F67UH4FD.js";import{a as Fo,b as Wo,c as ce,d as qo,e as $,f as Bo,g as Go,h as zo,i as Xo,j as Yo,k as Qo,l as ft,m as mt,n as ht}from"./chunk-7IMLHHSA.js";import"./chunk-BA5J2DKJ.js";import{a as Pt}from"./chunk-PC3DHZGV.js";async function ho(n){let e=await new M().parseKanonaks(n);return{kind:"merged",catalog:e,reasoning:new z().reasonOver(e)}}async function So(n,e){let t=new Set(n.map(oe)),o=new Set,i=[];if(await oo(n,e,{onDocument:l=>o.add(oe(l)),onUnresolvedEdge:l=>i.push(l)}),i.length>0){let l=i.map(h=>`${h.fromNamespace} imports ${h.publisher}/${h.packageName} ${h.constraint} (${h.reason})`);throw new Error(`Cannot build the conformance scope: ${i.length} import(s) did not resolve:
|
|
2
2
|
${l.join(`
|
|
3
|
-
`)}`)}let r=new Qn(e,o),d=new Set((await r.getAllDocumentsAsync()).map(oe)),i=[...t].filter(l=>!d.has(l));if(i.length>0)throw new Error(`scopeFromClosureAsync: ${i.join(", ")} is not a document of the repository the closure is resolved through.`);let c={},u=await new U().parseKanonaks(r,c),s=c.authored.filter(l=>l instanceof g&&t.has(l.sourceDoc)),f=new Set(s.map(B)),m=await Pa(n,s,e);return{kind:"merged",catalog:u,reasoning:new z().reasonOver(u),focus:f,links:m}}async function Pa(n,e,t){let o=[],a=new Map,r=new Map;for(let d of n){let i=oe(d),c=e.filter(u=>u.sourceDoc===i);for(let{key:u,references:s,target:f,failure:m}of await Jn(d,c,t)){let l=f?oe(f):void 0;if(r.has(u)&&r.get(u)!==l)throw new Error(`scopeFromClosureAsync: the seeds link ${u} at different versions (${r.get(u)??"unresolved"} and ${l??"unresolved"}); judge them in separate scopes.`);r.has(u)||(r.set(u,l),f&&o.push(...await new U().parseKanonaks(new Be(f,t))));for(let{uri:h}of s)f?Zn(f,h.name)||a.set(p(h),`${l} defines no resource named '${h.name}'`):a.set(p(h),`its package ${u} could not be resolved${m?` (${m})`:""}`)}}return r.size>0?{subjects:o,unresolved:a}:void 0}function oe(n){let e=n.metadata?.namespace_;if(!e)throw new Error("scopeFromClosureAsync: a document has no namespace, so it cannot be identified.");return e.toString()}function co(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function uo(n,e){let t=e??new Le(new X);return{kind:"standalone",catalog:await new U().parseKanonaks(new Be(n,t))}}function $(n){return typeof n=="number"?n:void 0}function Ra(n){if(!n)return;let e=p(n);if(e===p(Fn))return"IRI";if(e===p(Wn))return"BlankNode";if(e===p(qn))return"Literal"}function po(n){if(!n)return;let e=p(n);if(e===p(Bn))return"Violation";if(e===p(Gn))return"Warning";if(e===p(zn))return"Info"}function fo(n,e,t,o){let a=k(e,je);if(!a)return;let r={path:a},d=$(A(e,vn)),i=$(A(e,wn));d!==void 0&&(r.minCount=d),i!==void 0&&(r.maxCount=i);let c=$(A(e,xn)),u=$(A(e,In));c!==void 0&&(r.minLength=c),u!==void 0&&(r.maxLength=u);let s=$(A(e,Ln)),f=$(A(e,Mn));s!==void 0&&(r.minInclusive=s),f!==void 0&&(r.maxInclusive=f);let m=ue(e,Nn);if(m!==void 0){let S=ue(e,An);r.pattern=S!==void 0?{regex:m,flags:S}:{regex:m}}if(F(e,Te)){let S=[],K=[];for(let{item:C}of Ve(e,Te))"literal"in C?S.push(C.value):C instanceof O&&K.push(C.subject);S.length>0&&(r.inValues=S),K.length>0&&(r.inRefs=K)}let l=k(e,Kn);l&&(r.datatype=l);let h=k(e,On);h&&(r.classRef=h);let y=Ra(k(e,Dn));y&&(r.nodeKind=y);let R=k(e,Xn);if(R&&(r.hasValue=R),F(e,Re)||F(e,Fe)||F(e,We)){let S={},K=$(A(e,Fe)),C=$(A(e,We));K!==void 0&&(S.minCount=K),C!==void 0&&(S.maxCount=C);let x=va(n,e,o);"problem"in x?S.problem=x.problem:S.shape=x.shape,r.qualified=S}let v=ue(e,Un);v!==void 0&&(r.message=v);let w=po(k(e,De))??t;return w&&(r.severity=w),r}function va(n,e,t){let o=Y(e,Re);if(o)return lo(n,o,void 0,t);let a=k(e,Re);if(!a)return{problem:"sh:qualifiedValueShape is missing"};let r=p(a);if(t.has(r))return{problem:`sh:qualifiedValueShape '${a.name}' leads back to itself (a cycle through named shapes)`};let d=N(n,a);return d?lo(n,d,r,t):{problem:`sh:qualifiedValueShape '${a.name}' does not resolve`}}function lo(n,e,t,o){let a=t?new Set([...o,t]):o,r=de(e,J);if((de(e,fe)||F(e,je))&&!r){let c=fo(n,e,void 0,a);return c?{shape:{kind:"property",constraint:c}}:{problem:"the qualified property shape has no sh:path"}}return e instanceof g&&!r?{problem:`sh:qualifiedValueShape '${e.name}' is not a shape`}:{shape:{kind:"node",shape:mo(n,e,a)}}}function mo(n,e,t){let o=po(k(e,De)),a={name:e instanceof g?e.name:"(inline shape)",uri:e instanceof g?E(e):void 0,targetClass:k(e,Pn),targetNodes:D(e,$n),targetSubjectsOf:D(e,Vn),targetObjectsOf:D(e,Hn),closed:A(e,jn)===!0,ignoredProperties:[],severity:o,properties:[]};a.ignoredProperties.push(...D(e,Tn));for(let{item:r}of Ve(e,Rn)){let d;if(r instanceof M?d=r:r instanceof O&&(d=N(n,r.subject)),!d)continue;let i=fo(n,d,o,t);i&&a.properties.push(i)}return a}function we(n){let e=[];for(let t of n){if(!(t instanceof g)||!de(t,J))continue;let o=E(t);e.push(mo(n,t,new Set(o?[p(o)]:[])))}return e}function Ke(n){let e=new Map;for(let t of n)if(t instanceof g)for(let o of bn(t,qe)){let a=E(t);if(!a)throw new Error(`owl.hasKey on '${t.namespace}/${t.name}': the class has no resolvable URI.`);if(o.length===0)throw new Error(`owl.hasKey on '${t.name}' lists no properties; a key needs at least one.`);let r=o.map(({item:d})=>{let i=d instanceof O?N(n,d.subject):void 0;if(!i||!ze(n,i)){let c=d instanceof O?`'${p(d.subject)}'`:"a value that is not a reference";throw new Error(`owl.hasKey on '${t.name}' lists ${c}, which is not a property defined in scope; a key lists properties.`)}return d.subject});e.set(`${p(a)}|${r.map(p).join(",")}`,{classUri:a,className:t.name,properties:r})}return[...e.values()]}var _="kanonak.org/transformations",te="values";var Oe="allowed",rn="expected",b=n=>({type:`${_}/VarRef`,varName:n}),tn=n=>({type:`${_}/IntegerLiteral`,integerLiteral:n}),wa=n=>({type:`${_}/DecimalLiteral`,decimalLiteral:n}),ho=n=>Number.isInteger(n)?tn(n):wa(n),So=n=>({type:`${_}/Count`,source:n}),go=(n,e)=>({type:`${_}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),ko=(n,e)=>({type:`${_}/LessThanOrEqual`,compareLeft:n,compareRight:e});function an(n,e){if(!e||e.length===0)return n;let t=new Set(["i","m","s"]),o=[...new Set(e.split(""))];if(o.filter(r=>!t.has(r)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${n}`}function Ne(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:go(So(b(te)),tn(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:ko(So(b(te)),tn(n.maxCount))}),n.hasValue!==void 0&&e.push({component:"hasValue",per:"node",expr:{type:`${_}/Contains`,haystack:b(te),needle:b(rn)}}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${_}/Contains`,haystack:b(Oe),needle:b("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:an(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:go(b("v"),ho(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:ko(b("v"),ho(n.maxInclusive))}),e}import{evaluate as Oa,ExpressionError as Na}from"@kanonak-protocol/expression";function Co(n,e){let t=yo(e)?e:we(e),o=[],a=n.catalog.filter(c=>c instanceof g).map(Ae),r=new Map;Aa(a,r);let d=n.links?[...n.catalog,...n.links.subjects]:n.catalog,i={scope:n,membership:new cn(n),values:d,embeddedFocus:r};for(let c of t)for(let u of xa(i,c,a))sn(n,u)&&_o(i,c,u,o);if(!yo(e))for(let c of Ke(e))Ia(i,c,a,o);return{conforms:!o.some(c=>c.severity==="Violation"),results:o}}function yo(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function bo(n){let e=n.predicate;return e instanceof O?e:void 0}function sn(n,e){return!n.focus||e.subject!==void 0&&n.focus.has(e.subject)}function Ae(n){let e=B(n);return{node:n,key:e,uri:E(n),subject:e,label:n.name}}function un(n,e,t){return{node:n,key:e,subject:t,label:e.includes("#")?e.slice(e.indexOf("#")):e}}function Aa(n,e){for(let t of n)Xe([t.node],({kanonak:o,address:a})=>{o instanceof M&&!e.has(o)&&e.set(o,un(o,a,t.subject))})}var cn=class{constructor(e){this.scope=e}scope;ancestors=new Map;defined;defines(e){return this.defined??=new Set(this.scope.catalog.filter(t=>t instanceof g).map(B)),this.defined.has(p(e))}isInstance(e,t){let o=p(t);return e.some(a=>p(a)===o||this.ancestorsOf(a).has(o))}ancestorsOf(e){let t=e.version&&typeof e.version.major=="number"?`${p(e)}@${V(e.version)}`:p(e),o=this.ancestors.get(t);return o||(o=this.scope.reasoning?new Set(this.scope.reasoning.getSuperclasses(e)):new Set(Ge(this.scope.catalog,e).map(a=>p(a))),this.ancestors.set(t,o)),o}};function xa(n,e,t){let{scope:o}=n,a=new Map,r=i=>{a.set(i.key,i)},d=()=>[...t,...n.embeddedFocus.values()];if(e.targetClass){let i=e.targetClass;for(let c of d())n.membership.isInstance(G(c.node),i)&&r(c)}for(let i of e.targetNodes){let c=N(o.catalog,i);c instanceof g&&r(Ae(c))}for(let i of e.targetSubjectsOf){let c=p(i);for(let u of d())u.node.statement.some(s=>{let f=bo(s);return f&&p(f.subject)===c})&&r(u)}for(let i of e.targetObjectsOf)for(let c of d())for(let u of ee(c.node,i,o.catalog,c.key))u.kind==="subject"?r(Ae(u.node)):u.kind==="embedded"&&r(n.embeddedFocus.get(u.node)??un(u.node,u.address,c.subject));return[...a.values()]}function Ia(n,e,t,o){let a=new Map;for(let c of t)n.membership.isInstance(G(c.node),e.classUri)&&a.set(c.key,c);let r=[];for(let c of[...a.values()].sort((u,s)=>u.key<s.key?-1:u.key>s.key?1:0)){let u=e.properties.map(s=>La(n,c,s));u.every(s=>s.size>0)&&r.push({focus:c,values:u})}let d=new Map;r.forEach(({values:c},u)=>{for(let s of c[0].keys()){let f=d.get(s);f?f.push(u):d.set(s,[u])}});let i=new Set;for(let c of d.values())for(let u=0;u<c.length;u++)for(let s=u+1;s<c.length;s++){let f=`${c[u]}:${c[s]}`;if(i.has(f))continue;let m=r[c[u]],l=r[c[s]],h=m.values.map((w,S)=>[...w.keys()].find(K=>l.values[S].has(K)));if(h.some(w=>w===void 0))continue;i.add(f);let[y,R]=sn(n.scope,m.focus)?[m.focus,l.focus]:sn(n.scope,l.focus)?[l.focus,m.focus]:[void 0,void 0];if(!y||!R)continue;let v=e.properties.map((w,S)=>`${w.name} = ${m.values[S].get(h[S])}`).join(", ");o.push({focusNode:y.key,focusUri:y.uri,valueRef:R.uri,constraintComponent:q,severity:"Violation",message:`'${y.label}' and '${R.label}' are distinct instances of ${e.className} with the same key (${v}); its owl.hasKey makes the key unique.`})}}function La(n,e,t){let o=new Map;for(let a of ee(e.node,t,n.scope.catalog,e.key))switch(a.kind){case"subject":case"unresolved":o.set(`ref:${p(a.uri)}`,a.uri.name);break;case"literal":o.set(`${typeof a.value}:${String(a.value)}`,JSON.stringify(a.value));break;case"embedded":break}return o}function Ma(n,e,t){return e.node?ee(e.node,t,n.values,e.key).map(o=>Ua(n,o,e.subject)):[]}function Ua(n,e,t){switch(e.kind){case"subject":return{kernel:{ref:p(e.uri)},kind:"reference",ref:e.uri,subject:e.node};case"unresolved":return{kernel:{ref:p(e.uri)},kind:"reference",ref:e.uri};case"embedded":{let o=n.embeddedFocus.get(e.node)??un(e.node,e.address,t);return{kernel:{ref:o.key},kind:"embedded",embedded:o}}case"literal":return typeof e.value=="boolean"?{kernel:e.value?1:0,kind:"boolean",literal:e.value}:{kernel:e.value,kind:typeof e.value=="number"?"number":"string",literal:e.value}}}function _o(n,e,t,o){for(let a of e.properties)Ro(n,e,t,a,o);e.closed&&Ga(e,t,o)}function dn(n,e,t,o,a={},r){return{focusNode:e.key,focusUri:e.uri,constraintComponent:t,severity:r??Po(n),message:o,sourceShape:n.name,sourceShapeUri:n.uri,...a}}function Po(n){return n.severity??"Violation"}var $a={minCount:me,maxCount:he,hasValue:W,in:ke,pattern:ye,minLength:Ee,maxLength:Ce,minInclusive:be,maxInclusive:_e};function Ro(n,e,t,o,a){let r=Ma(n,t,o.path),d=o.severity??Po(e),i=o.path.name,c=[...(o.inValues??[]).map(s=>typeof s=="boolean"?s?1:0:s),...(o.inRefs??[]).map(s=>({ref:p(s)}))],u=(s,f,m)=>{let l=dn(e,t,s,o.message??f,{resultPath:o.path,value:m?.literal,valueRef:m?.ref},d);return a.push(l),l};for(let s of Ne(o)){let f=$a[s.component];if(s.per==="node"){let m={[te]:r.map(l=>l.kernel),[Oe]:c};o.hasValue&&(m[rn]={ref:p(o.hasValue)}),Eo(s,m)||u(f,Va(s,i,o,r.length));continue}for(let m of r){if((s.component==="pattern"||s.component==="minLength"||s.component==="maxLength")&&m.kind!=="string"){u(f,`'${i}' value is not a string; ${s.component} applies to string values.`,m);continue}Eo(s,{v:m.kernel,[Oe]:c})||u(f,Fa(s,i,o,m),m)}}if(o.nodeKind)for(let s of r)Wa(o.nodeKind,s)||u(Pe,`'${i}' value is ${s.kind}; nodeKind requires ${o.nodeKind}.`,s);if(o.datatype)for(let s of r){let f=qa(o.datatype,s);f&&u(Se,`'${i}' ${f}`,s)}if(o.classRef)for(let s of r){let f=Ba(n,o.classRef,s);f&&u(ge,`'${i}' ${f}`,s)}o.qualified&&Ha(n,o,r,i,u)}function Va(n,e,t,o){switch(n.component){case"minCount":return`'${e}' has ${o} value(s); minCount is ${t.minCount}.`;case"maxCount":return`'${e}' has ${o} value(s); maxCount is ${t.maxCount}.`;case"hasValue":return`'${e}' has no value equal to ${t.hasValue?p(t.hasValue):"(unset)"}.`;default:return`'${e}' violates ${n.component}.`}}function Ha(n,e,t,o,a){let r=e.qualified,d=r.maxCount!==void 0?j:H,i=(u,s)=>{vo.add(a(d,u,s))};if(!r.shape){i(`'${o}' qualified value shape cannot be evaluated: ${r.problem??"it could not be built"}.`);return}let c=0;for(let u of t){let s=u.ref?p(u.ref):u.embedded?u.embedded.label:JSON.stringify(u.literal),f=ja(n,u);if(!f){i(`'${o}' value ${s} does not resolve in this scope; whether it conforms to the qualified shape cannot be decided.`,u);continue}let m=Da(n,r.shape,f);if(m.kind==="undecided"){i(`'${o}' value ${s}: whether it conforms to the qualified shape cannot be decided \u2014 ${m.reason}`,u);continue}m.kind==="conforms"&&c++}r.minCount!==void 0&&c<r.minCount&&a(H,`'${o}' has ${c} value(s) that conform to the qualified shape; qualifiedMinCount is ${r.minCount}.`),r.maxCount!==void 0&&c>r.maxCount&&a(j,`'${o}' has ${c} value(s) that conform to the qualified shape; qualifiedMaxCount is ${r.maxCount}.`)}function ja(n,e){switch(e.kind){case"reference":return e.subject?Ae(e.subject):void 0;case"embedded":return e.embedded;default:{let t=JSON.stringify(e.literal);return{key:t,label:t}}}}var Ta={name:"(qualified value shape)",targetNodes:[],targetSubjectsOf:[],targetObjectsOf:[],closed:!1,ignoredProperties:[],properties:[]},vo=new WeakSet;function Da(n,e,t){let o=[];e.kind==="property"?Ro(n,Ta,t,e.constraint,o):_o(n,e.shape,t,o);let a=o.find(r=>vo.has(r));return a?{kind:"undecided",reason:a.message}:o.length===0?{kind:"conforms"}:{kind:"fails"}}function Fa(n,e,t,o){let a=o.ref?p(o.ref):o.embedded?o.embedded.label:JSON.stringify(o.literal);switch(n.component){case"in":return`'${e}' value ${a} is not in the permitted set.`;case"pattern":return`'${e}' value ${a} does not match pattern ${t.pattern?.regex}.`;case"minLength":return`'${e}' value ${a} is shorter than minLength ${t.minLength}.`;case"maxLength":return`'${e}' value ${a} is longer than maxLength ${t.maxLength}.`;case"minInclusive":return`'${e}' value ${a} is below minInclusive ${t.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${a} is above maxInclusive ${t.maxInclusive} (or not numeric).`;default:return`'${e}' value ${a} violates ${n.component}.`}}function Eo(n,e){let t=o=>{let a=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof a=="string"&&a in e)return e[a];throw new Na(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return Oa(n.expr,void 0,t)===1}function Wa(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function qa(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let t=Ye(n);if(t!==void 0)switch(t){case T.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case T.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case T.Decimal:case T.Double:case T.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function Ba(n,e,t){if(t.kind==="embedded"&&t.embedded?.node){let d=G(t.embedded.node);return d.length===0?`value ${t.embedded.label} has no type; sh:class requires an instance of ${e.name}.`:n.membership.isInstance(d,e)?void 0:`value ${t.embedded.label} is not an instance of ${e.name}.`}if(t.kind!=="reference"||!t.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let o=t.subject;if(!o){let d=n.scope.links?.unresolved.get(p(t.ref));return d?`value ${p(t.ref)} is a link that does not dereference: ${d} (sh:class ${e.name}).`:`value ${p(t.ref)} does not resolve in this scope (sh:class ${e.name}).`}let a=G(o);if(n.membership.isInstance(a,e))return;let r=a.filter(d=>!n.membership.defines(d));return r.length>0?`value ${p(t.ref)} is typed ${r.map(p).join(", ")}, which this scope does not define, so it cannot be shown to be an instance of ${e.name}. A class is in scope when the judged document imports the package that defines it.`:`value ${p(t.ref)} is not an instance of ${e.name}.`}function Ga(n,e,t){if(!e.node)return;let o=new Set([...n.properties.map(r=>p(r.path)),...n.ignoredProperties.map(r=>p(r))]),a=new Set;for(let r of e.node.statement){let d=bo(r);if(!d)continue;let i=p(d.subject);o.has(i)||a.has(i)||(a.add(i),t.push(dn(n,e,Z,`'${e.label}' carries undeclared property '${d.subject.name}' (closed shape).`,{resultPath:d.subject})))}for(let r of e.node.unresolvedPredicates)a.has(r.key)||(a.add(r.key),t.push(dn(n,e,Z,`'${e.label}' carries unresolvable property '${r.key}' (closed shape).`,{value:r.key})))}var za="1.1.0",Xa=new Set([W,H,j].map(n=>n.name)),Ya=new Set([q].map(n=>n.name));function Qa(n){let e=new Set(n.results.map(t=>t.constraintComponent.name));return[...e].some(t=>Ya.has(t))?"1.3.0":[...e].some(t=>Xa.has(t))?"1.2.0":za}async function wo(n){let e=new ne(n.repository),t=e.imports(),o=t.ensure(le,pe,Qa(n.result),"sh"),a=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${t.ensure(i.publisher,i.package_,V(i.version),i.package_)}.${i.name}`:c,r={},d=[];return n.result.results.forEach((i,c)=>{let u=`result-${c+1}`;d.push(u);let s={type:`${o}.ValidationResult`,[`${o}.focusNode`]:a(i.focusUri,i.focusNode),[`${o}.resultMessage`]:i.message,[`${o}.resultSeverity`]:`${o}.${i.severity}`,[`${o}.sourceConstraintComponent`]:`${o}.${i.constraintComponent.name}`};i.resultPath&&(s[`${o}.resultPath`]=a(i.resultPath,p(i.resultPath))),i.sourceShapeUri&&i.sourceShape!==void 0&&(s[`${o}.sourceShape`]=a(i.sourceShapeUri,i.sourceShape)),i.valueRef?s[`${o}.value`]=a(i.valueRef,p(i.valueRef)):i.value!==void 0&&(s[`${o}.value`]=i.value),r[u]=s}),r.report={type:`${o}.ValidationReport`,[`${o}.conforms`]:n.result.conforms,...d.length>0?{[`${o}.result`]:d}:{}},e.buildContentAddressed({publisher:n.publisher,book:t,body:r,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as tc}from"@kanonak-protocol/types/document/models/enums";import{spawn as Ja}from"child_process";var Oo=12e4,Za=4096,re=class{argv;interactive;timeoutMs;stderr;now;constructor(e){this.argv=No(e.command),this.interactive=e.interactive??!1,this.timeoutMs=e.timeoutMs??Oo,this.stderr=e.stderr??process.stderr,this.now=e.nowSeconds??(()=>Date.now()/1e3)}get command(){return this.argv.join(" ")}async get(e){let t=await this.run("get",this.wireRequest("get",e)),o=en(e,t,this.now());if(!o.ok)throw new L(`credential helper '${this.command}' answered get for ${e.resource} outside the protocol (${o.problem}): ${o.message}`);return o.answer}async erase(e){let t=await this.run("erase",{...this.wireRequest("erase",e),scope:e.scope}),o=nn(t);if(!o.ok)throw new L(`credential helper '${this.command}' answered erase for ${e.resource} outside the protocol (${o.problem}): ${o.message}`)}wireRequest(e,t){let o={version:Ze,operation:e,resource:t.resource,method:t.method};return t.challenges&&(o.challenges=t.challenges),o.interactive=this.interactive,o}run(e,t){let o=`credential helper '${this.command}' ${e}`;return new Promise((a,r)=>{let d=!1,i=l=>{d||(d=!0,l())},c;try{c=Ja(this.argv[0],[...this.argv.slice(1),e],{stdio:["pipe","pipe","pipe"],shell:!1,windowsHide:!0})}catch(l){r(Ko(o,l));return}let u=[],s="",f=!1,m=setTimeout(()=>{f=!0,c.kill()},this.timeoutMs);c.stdout.on("data",l=>u.push(l)),c.stderr.on("data",l=>{this.stderr.write(l),s=(s+l.toString("utf8")).slice(-Za)}),c.on("error",l=>{clearTimeout(m),i(()=>r(Ko(o,l)))}),c.on("close",(l,h)=>{clearTimeout(m);let y=s.trim()?`: ${s.trim()}`:"";if(f){i(()=>r(new L(`${o} did not finish within ${Math.round(this.timeoutMs/1e3)}s${y}`)));return}if(l!==0){let v=l!==null?`exit ${l}`:`signal ${h}`;i(()=>r(new L(`${o} failed (${v})${y}`)));return}let R=Buffer.concat(u).toString("utf8").trim();try{let v=JSON.parse(R);i(()=>a(v))}catch{i(()=>r(new L(`${o} exited 0 without printing one JSON answer${y}`)))}}),c.stdin.on("error",()=>{}),c.stdin.end(`${JSON.stringify(t)}
|
|
4
|
-
`)})}};function No(n){let e=n.trim().split(/\s+/).filter(t=>t!=="");if(e.length===0)throw new Error("the credential helper command is empty");return e}function Ko(n,e){let t=e.code,o="";return t==="ENOENT"&&(o=" (not found: give its path, or put it on PATH)"),t==="EINVAL"&&process.platform==="win32"&&(o=" (a .cmd or .bat file cannot run without a shell: configure an executable, e.g. `node path/to/helper.js`)"),new L(`${n} could not be started: ${e.message}${o}`)}import{existsSync as ei,readFileSync as ni}from"fs";import{homedir as oi}from"os";import{join as ti}from"path";function ae(){return ti(oi(),".kanonak","config.json")}function ie(n){if(!ei(n))return;let e;try{e=JSON.parse(ni(n,"utf-8"))}catch(t){throw new Error(`${n} is not valid JSON: ${t.message}`)}if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${n} must hold a JSON object`);return e}var ln="KANONAK_CREDENTIAL_HELPER";function ri(n={}){let e=n.env??process.env,t=n.configPath??ae(),o=ai(e,t);if(o){let r=Object.keys(e).filter(d=>(d===ve||d.startsWith(`${ve}_`))&&(e[d]??"").trim()!=="").sort();if(r.length>0)throw new Error(`A credential helper is configured (${o.source}: ${o.command}) and so is ${r.join(", ")}. Configure one or the other.`);return new re({command:o.command,interactive:n.interactive??!1})}let a={env:e};return n.discovery&&(a.discovery=n.discovery),new on(a)}function ai(n,e){let t=(n[ln]??"").trim();if(t)return{command:t,source:ln};let o=ie(e)?.credentialHelper;if(o!==void 0){if(typeof o!="string"||o.trim()==="")throw new Error(`"credentialHelper" in ${e} must be a non-empty command line`);return{command:o.trim(),source:e}}}var pn="KANONAK_PACKAGE_URL_TEMPLATE";function ii(n={}){let e=n.env??process.env,t=n.configPath??ae(),o=ie(t)?.packageUrlTemplates,a=o===void 0?{}:{...Ue(o,"packageUrlTemplates",t)},r=(e[pn]??"").trim();return r&&(a[Me]=$e(r,pn,!0)),Object.keys(a).length>0?Object.freeze(a):void 0}var P="kanonak.org",I="view",Ao="core-kanonak",si={publisher:P,package_:I,name:"rootView"},ci={publisher:P,package_:I,name:"bind"},di={publisher:P,package_:I,name:"produces"},ui={publisher:P,package_:I,name:"projections"},li={publisher:P,package_:I,name:"where"},pi={publisher:P,package_:I,name:"value"},fi={publisher:P,package_:I,name:"as"},xe=class{constructor(e,t=new X){this.repository=e;this.parser=t;this.objectParser=new U(this.parser),this.builder=new ne(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,t={}){let o=await this.objectParser.parseKanonaks(this.repository),a=this.resolveView(o,e),r=k(a,ci);if(!r)throw new Error(`View ${a.namespace}/${a.name} declares no view.bind; cannot materialize.`);let d=k(a,di);if(!d)throw new Error(`View ${a.namespace}/${a.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let i=mi(a),c=xo(o,P,Ao),u=xo(o,P,I),s=this.builder.imports(),f=s.ensure(P,Ao,c,"ck"),m=s.ensure(P,I,u,"v"),l=s.ref(d),h=new oo(this.repository,this.parser,this.objectParser),y=new no(h,o),R=this.readProjections(o,a),v=gi(a,li),w=this.findInstances(o,r,await this.reason(t)),S={},K=new Set;for(let se of w){if(!await this.passesWhere(y,o,v,se))continue;let Ie={type:l};for(let mn of R){let Lo=await this.evaluateValue(y,o,mn.value,se),hn=this.builder.serializeValue(Io(Lo),s);hn!==void 0&&(Ie[s.ref(mn.as)]=hn)}let fn=E(se);fn&&(Ie[`${m}.derivedFrom`]=s.ref(fn)),S[this.rowName(se,K)]=Ie}let C={};t.resolvedAt&&(C[`${f}.resolvedAt`]=t.resolvedAt),t.invocationId&&(C[`${f}.id`]=t.invocationId);let x=await this.builder.buildContentAddressed({publisher:i,book:s,body:S,contentHashProperty:`${f}.contentHash`,header:C});return{yaml:x.yaml,contentHash:x.contentHash,packageName:x.packageName,publisher:x.publisher,rowCount:x.resourceCount}}resolveView(e,t){let o=N(e,t);if(!o)throw new Error(`View ${t.publisher}/${t.package_}/${t.name} not found in the catalog.`);let a=k(o,si);if(a){let r=N(e,a);if(!r)throw new Error(`ViewPackage ${t.name} names rootView ${a.name}, which is not in the catalog.`);return r}return o}readProjections(e,t){let o=[];for(let a of He(t,ui)){let r=a instanceof M?a:a instanceof O?N(e,a.subject):void 0;if(!r)continue;let d=Y(r,pi),i=k(r,fi);d&&i&&o.push({value:d,as:i})}return o}async reason(e){return new z({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,t,o){let a=Si(e),r=[],d=new Set;for(let i of o.getInstancesOfClass(t)){if(d.has(i))continue;d.add(i);let c=a.get(i);c&&r.push(c)}return r.sort((i,c)=>{let u=Q(E(i)),s=Q(E(c));return u<s?-1:u>s?1:0}),r}async passesWhere(e,t,o,a){for(let r of o){let d=await this.evaluateValue(e,t,r,a);if(!ki(d))return!1}return!0}async evaluateValue(e,t,o,a){let r=eo(o,"view-projection",{catalog:t,depth:0}),d=new Map([["input",a]]);return e.evaluate(r,d)}rowName(e,t){let o=Je(e.name)||"row",a=o,r=2;for(;t.has(a);)a=`${o}-${r++}`;return t.add(a),a}};function Io(n){return Qe(n)?n.value:Array.isArray(n)?n.map(Io):n}function mi(n){let e=E(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function xo(n,e,t){let o=hi(n,e,t);if(!o)throw new Error(`Package ${e}/${t} is not in the catalog; it must be importable to materialize a view.`);return o}function hi(n,e,t){let o;for(let a of n){if(!(a instanceof g))continue;let r=E(a);!r||r.publisher!==e||r.package_!==t||!r.version||(!o||ce(r.version,o)>0)&&(o=r.version)}return o?V(o):void 0}function Si(n){let e=new Map,t=new Map;for(let o of n){if(!(o instanceof g))continue;let a=E(o);if(!a||!a.version)continue;let r=Q(a),d=t.get(r);(!d||ce(a.version,d)>0)&&(t.set(r,a.version),e.set(r,o))}return e}function gi(n,e){let t=Y(n,e);return t?[t]:He(n,e).filter(o=>o instanceof M)}function ki(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:Qe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{Me as ANY_PUBLISHER,Or as AmbiguousReferenceRule,Rt as BooleanStatement,ra as CANONICAL_FORM_VERSION,ha as CREDENTIAL_EXPIRY_SKEW_SECONDS,ln as CREDENTIAL_HELPER_ENV,Ze as CREDENTIAL_HELPER_PROTOCOL_VERSION,Oo as CREDENTIAL_HELPER_TIMEOUT_MS,T as Carrier,Mr as ClassDefinitionRule,br as ClassHierarchyCycleRule,Bo as CompositeKanonakDocumentRepository,L as CredentialError,la as DEFAULT_CONSENT_BINDING_PARAM,yt as DefinedKanonak,ea as DiamondNameClashRule,$r as DisplayLensScopeRule,qo as DocumentLocation,Bt as EdgeType,M as EmbeddedKanonak,yr as EmbeddedKanonakTypeRule,wt as EmbeddedStatement,ba as EntitlementDeniedError,_a as EntitlementProducer,re as ExecCredentialProvider,Wo as FileSystemKanonakDocumentRepository,Jt as GitIgnoreFilter,Gt as GraphBuilder,ft as HttpKanonakDocumentRepository,gn as INTEGRITY_PREFIX,ia as ImportBook,Er as ImportExistenceRule,Le as InMemoryKanonakDocumentRepository,Zo as KANONAK_USER_AGENT,kt as Kanonak,er as KanonakDocumentPositions,Xo as KanonakHttpError,U as KanonakObjectParser,na as KanonakObjectValidator,X as KanonakParser,at as KanonakUri,ar as KanonakUriBuilder,ir as KanonakUrlResolver,Vt as KanonakVocabulary,Fr as LINE_STYLES,fr as LinkTargetRule,Kt as ListStatement,Et as LiteralKanonak,mt as LocalFirstRepository,ht as LockAwareRepository,Yr as LookBandPathRule,Gr as LookRenderer,Vr as LookSemanticSvgPathRule,Ur as MarkdownLinkRule,Ot as MarkdownStatement,wr as NamespaceImportCycleRule,mr as NamespacePrefixRule,qt as NodeType,Pt as NumberStatement,pa as OAuthDiscovery,qe as OWL_HAS_KEY,Yt as OWL_RL_CLASSIFICATION_RULES,Ar as ObjectPropertyValueValidationRule,ur as OntologyValidationError,cr as OntologyValidationResult,Zr as OwlOneOfRule,pn as PACKAGE_URL_TEMPLATE_ENV,ne as PackageBuilder,kr as PackageHeaderRule,ya as ProducerRepository,xr as PropertyDomainRule,_r as PropertyHierarchyCycleRule,Ir as PropertyKindRangeConsistencyRule,Zt as PropertyMetadata,Nr as PropertyRangeReferenceRule,Pr as PropertyRangeRequiredRule,Sr as PropertyTypeSpecificityRule,ut as PublisherConfigResolver,lt as PublisherIndex,Xt as RDFS_RULES,z as Reasoner,Qt as ReasoningResult,O as ReferenceKanonak,vt as ReferenceStatement,zo as RepositoryFactory,Lr as ReservedNameShadowRule,hr as ResourceNamingRule,Nt as ResourceResolver,Ht as ResourceTypeClassifier,pe as SHACL_PACKAGE,le as SHACL_PUBLISHER,ge as SH_COMP_CLASS,Z as SH_COMP_CLOSED,Se as SH_COMP_DATATYPE,q as SH_COMP_HAS_KEY,W as SH_COMP_HAS_VALUE,ke as SH_COMP_IN,he as SH_COMP_MAX_COUNT,_e as SH_COMP_MAX_INCLUSIVE,Ce as SH_COMP_MAX_LENGTH,me as SH_COMP_MIN_COUNT,be as SH_COMP_MIN_INCLUSIVE,Ee as SH_COMP_MIN_LENGTH,Pe as SH_COMP_NODE_KIND,ye as SH_COMP_PATTERN,j as SH_COMP_QUALIFIED_MAX_COUNT,H as SH_COMP_QUALIFIED_MIN_COUNT,J as SH_NODE_SHAPE,fe as SH_PROPERTY_SHAPE,_n as SH_SHAPE,bt as ScalarStatement,Xr as SequenceNarrativeRule,Jr as ShaclShapeRule,Ct as Statement,_t as StringStatement,Rr as SubClassOfReferenceRule,vr as SubPropertyOfReferenceRule,g as SubjectKanonak,gr as SubjectKanonakTypeRequiredRule,ve as TOKEN_ENV,on as TokenCredentialProvider,zt as TripleStore,Hr as TxExpressionCompilesRule,Qr as TxExpressionPathRule,At as TypeResolver,jr as URI_DISPLAY_LABEL,Tr as URI_DISPLAY_SUMMARY,Kr as UnresolvedPredicateRule,Cr as UnresolvedReferenceRule,pr as ValidationCache,lr as ValidationContext,dr as ValidationSeverity,tc as VersionOperator,xe as ViewMaterializer,Ea as allowAllPolicy,ot as assertHttpsUrl,Cn as assertIntegrityAsync,pt as assertPackageIdentity,Ke as buildKeysModel,gt as buildLocalFirstRepository,Br as buildOntologyModel,wo as buildReportPackageAsync,we as buildShapesModel,Ut as builtinHomePackages,$t as builtinUri,oa as canonicalForm,ta as canonicalHash,Ye as carrierOf,fa as checkCredentialAnswer,en as checkHelperAnswer,nn as checkHelperEraseAnswer,$e as checkPackageUrlTemplate,Ue as checkPackageUrlTemplates,St as collectKanonakFiles,ce as compareVersions,ao as computeIntegrity,En as computeIntegrityAsync,aa as contentAddressedName,G as contextTypesOf,Sa as createCredentialedFetch,Vo as createVersion,ri as credentialProviderFromConfig,Qo as describeResponse,Co as evaluateConformance,Wt as extractMarkdownLinks,dt as fillPackageUrlTemplate,ka as findDerivation,Ft as findMalformedReferences,or as findMarkdownLinkAt,an as foldFlagsIntoPattern,st as formatKanonakAddress,V as formatVersion,Go as getGlobalCachePath,nt as getKanonakUserAgent,Yo as httpError,jo as isCompatibleVersion,To as isMajorCompatible,ze as isPropertySubject,tt as kanonakFetch,to as loadLockFile,Sn as lockedVersion,Ne as lowerConstraint,It as makeUriKey,ua as narrowestScope,Ca as noopMeter,sa as normalizeHost,ct as packageUrlTemplateFor,ii as packageUrlTemplatesFromConfig,it as parseKanonakAddress,kn as parseLockFile,ca as parseScope,Ho as parseVersionString,nr as parseWithPositions,ma as parseWwwAuthenticate,Fo as pickHighestDocument,Tt as propertiesInScope,jt as propertyClassOf,Wr as readSequenceConnectors,ie as readUserConfig,sr as referenceSpelling,D as referenceUris,Dr as resolveDisplayValue,Dt as resolvePropertyStep,Jo as retryAfterSecondsOf,Je as sanitizeName,Do as satisfiesVersionOperator,ro as saveLockFile,da as scopeContains,co as scopeFromCatalog,so as scopeFromClosureAsync,uo as scopeFromDocumentAsync,io as scopeFromRepositoryAsync,yn as serializeLockFile,rt as setKanonakFetchRetries,et as setKanonakUserAgent,rr as sourceSymbolAt,tr as sourceSymbols,No as splitCommandLine,B as subjectAddress,E as subjectUri,Ge as superClassChain,zr as supportedBandKeys,ga as tokenEnvKeyFor,Lt as tripleKey,xt as typeReferenceUris,Q as uriKey,Mt as uriTriple,ae as userConfigPath,ee as valuesOf,Mo as versionOperatorFromChar,Uo as versionOperatorToChar,$o as versionsEqual,Xe as walkDefinedKanonaks,qr as walkSequence};
|
|
3
|
+
`)}`)}let r=new to(e,o),d=new Set((await r.getAllDocumentsAsync()).map(oe)),a=[...t].filter(l=>!d.has(l));if(a.length>0)throw new Error(`scopeFromClosureAsync: ${a.join(", ")} is not a document of the repository the closure is resolved through.`);let c={},u=await new M().parseKanonaks(r,c),s=c.authored.filter(l=>l instanceof g&&t.has(l.sourceDoc)),f=new Set(s.map(B)),m=await Ni(n,s,e);return{kind:"merged",catalog:u,reasoning:new z().reasonOver(u),focus:f,links:m}}async function Ni(n,e,t){let o=[],i=new Map,r=new Map;for(let d of n){let a=oe(d),c=e.filter(u=>u.sourceDoc===a);for(let{key:u,references:s,target:f,failure:m}of await ro(d,c,t)){let l=f?oe(f):void 0;if(r.has(u)&&r.get(u)!==l)throw new Error(`scopeFromClosureAsync: the seeds link ${u} at different versions (${r.get(u)??"unresolved"} and ${l??"unresolved"}); judge them in separate scopes.`);r.has(u)||(r.set(u,l),f&&o.push(...await new M().parseKanonaks(new Be(f,t))));for(let{uri:h}of s)f?io(f,h.name)||i.set(p(h),`${l} defines no resource named '${h.name}'`):i.set(p(h),`its package ${u} could not be resolved${m?` (${m})`:""}`)}}return r.size>0?{subjects:o,unresolved:i}:void 0}function oe(n){let e=n.metadata?.namespace_;if(!e)throw new Error("scopeFromClosureAsync: a document has no namespace, so it cannot be identified.");return e.toString()}function go(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function ko(n,e){let t=e??new Le(new X);return{kind:"standalone",catalog:await new M().parseKanonaks(new Be(n,t))}}function U(n){return typeof n=="number"?n:void 0}function Ai(n){if(!n)return;let e=p(n);if(e===p(Xn))return"IRI";if(e===p(Yn))return"BlankNode";if(e===p(Qn))return"Literal"}function Eo(n){if(!n)return;let e=p(n);if(e===p(Jn))return"Violation";if(e===p(Zn))return"Warning";if(e===p(eo))return"Info"}function Co(n,e,t,o){let i=k(e,je);if(!i)return;let r={path:i},d=U(O(e,Nn)),a=U(O(e,An));d!==void 0&&(r.minCount=d),a!==void 0&&(r.maxCount=a);let c=U(O(e,$n)),u=U(O(e,Hn));c!==void 0&&(r.minLength=c),u!==void 0&&(r.maxLength=u);let s=U(O(e,jn)),f=U(O(e,Dn));s!==void 0&&(r.minInclusive=s),f!==void 0&&(r.maxInclusive=f);let m=ue(e,Mn);if(m!==void 0){let S=ue(e,Un);r.pattern=S!==void 0?{regex:m,flags:S}:{regex:m}}if(F(e,De)){let S=[],x=[];for(let{item:C}of $e(e,De))"literal"in C?S.push(C.value):C instanceof K&&x.push(C.subject);S.length>0&&(r.inValues=S),x.length>0&&(r.inRefs=x)}let l=k(e,Ln);l&&(r.datatype=l);let h=k(e,Vn);h&&(r.classRef=h);let y=Ai(k(e,zn));y&&(r.nodeKind=y);let R=k(e,no);if(R&&(r.hasValue=R),F(e,Re)||F(e,Fe)||F(e,We)){let S={},x=U(O(e,Fe)),C=U(O(e,We));x!==void 0&&(S.minCount=x),C!==void 0&&(S.maxCount=C);let N=Li(n,e,o);"problem"in N?S.problem=N.problem:S.shape=N.shape,r.qualified=S}let v=ue(e,Tn);v!==void 0&&(r.message=v);let w=Eo(k(e,Te))??t;return w&&(r.severity=w),r}function Li(n,e,t){let o=Y(e,Re);if(o)return yo(n,o,void 0,t);let i=k(e,Re);if(!i)return{problem:"sh:qualifiedValueShape is missing"};let r=p(i);if(t.has(r))return{problem:`sh:qualifiedValueShape '${i.name}' leads back to itself (a cycle through named shapes)`};let d=I(n,i);return d?yo(n,d,r,t):{problem:`sh:qualifiedValueShape '${i.name}' does not resolve`}}function yo(n,e,t,o){let i=t?new Set([...o,t]):o,r=de(e,J);if((de(e,fe)||F(e,je))&&!r){let c=Co(n,e,void 0,i);return c?{shape:{kind:"property",constraint:c}}:{problem:"the qualified property shape has no sh:path"}}return e instanceof g&&!r?{problem:`sh:qualifiedValueShape '${e.name}' is not a shape`}:{shape:{kind:"node",shape:bo(n,e,i)}}}function bo(n,e,t){let o=Eo(k(e,Te)),i={name:e instanceof g?e.name:"(inline shape)",uri:e instanceof g?E(e):void 0,targetClass:k(e,In),targetNodes:T(e,Fn),targetSubjectsOf:T(e,Wn),targetObjectsOf:T(e,qn),closed:O(e,Bn)===!0,ignoredProperties:[],severity:o,properties:[]};i.ignoredProperties.push(...T(e,Gn));for(let{item:r}of $e(e,On)){let d;if(r instanceof V?d=r:r instanceof K&&(d=I(n,r.subject)),!d)continue;let a=Co(n,d,o,t);a&&i.properties.push(a)}return i}function we(n){let e=[];for(let t of n){if(!(t instanceof g)||!de(t,J))continue;let o=E(t);e.push(bo(n,t,new Set(o?[p(o)]:[])))}return e}function xe(n){let e=new Map;for(let t of n)if(t instanceof g)for(let o of xn(t,qe)){let i=E(t);if(!i)throw new Error(`owl.hasKey on '${t.namespace}/${t.name}': the class has no resolvable URI.`);if(o.length===0)throw new Error(`owl.hasKey on '${t.name}' lists no properties; a key needs at least one.`);let r=o.map(({item:d})=>{let a=d instanceof K?I(n,d.subject):void 0;if(!a||!ze(n,a)){let c=d instanceof K?`'${p(d.subject)}'`:"a value that is not a reference";throw new Error(`owl.hasKey on '${t.name}' lists ${c}, which is not a property defined in scope; a key lists properties.`)}return d.subject});e.set(`${p(i)}|${r.map(p).join(",")}`,{classUri:i,className:t.name,properties:r})}return[...e.values()]}var _="kanonak.org/transformations",te="values";var Ke="allowed",rn="expected",b=n=>({type:`${_}/VarRef`,varName:n}),tn=n=>({type:`${_}/IntegerLiteral`,integerLiteral:n}),Vi=n=>({type:`${_}/DecimalLiteral`,decimalLiteral:n}),_o=n=>Number.isInteger(n)?tn(n):Vi(n),Po=n=>({type:`${_}/Count`,source:n}),Ro=(n,e)=>({type:`${_}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),vo=(n,e)=>({type:`${_}/LessThanOrEqual`,compareLeft:n,compareRight:e});function an(n,e){if(!e||e.length===0)return n;let t=new Set(["i","m","s"]),o=[...new Set(e.split(""))];if(o.filter(r=>!t.has(r)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${n}`}function Ie(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Ro(Po(b(te)),tn(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:vo(Po(b(te)),tn(n.maxCount))}),n.hasValue!==void 0&&e.push({component:"hasValue",per:"node",expr:{type:`${_}/Contains`,haystack:b(te),needle:b(rn)}}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${_}/Contains`,haystack:b(Ke),needle:b("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:an(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Ro(b("v"),_o(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:vo(b("v"),_o(n.maxInclusive))}),e}import{evaluate as Ui,ExpressionError as $i}from"@kanonak-protocol/expression";function Ko(n,e){let t=wo(e)?e:we(e),o=[],i=n.catalog.filter(c=>c instanceof g).map(Oe),r=new Map;Hi(i,r);let d=n.links?[...n.catalog,...n.links.subjects]:n.catalog,a={scope:n,membership:new cn(n),values:d,embeddedFocus:r};for(let c of t)for(let u of ji(a,c,i))sn(n,u)&&Oo(a,c,u,o);if(!wo(e))for(let c of xe(e))Di(a,c,i,o);return{conforms:!o.some(c=>c.severity==="Violation"),results:o}}function wo(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function Io(n){let e=n.predicate;return e instanceof K?e:void 0}function sn(n,e){return!n.focus||e.subject!==void 0&&n.focus.has(e.subject)}function Oe(n){let e=B(n);return{node:n,key:e,uri:E(n),subject:e,label:n.name}}function un(n,e,t){return{node:n,key:e,subject:t,label:e.includes("#")?e.slice(e.indexOf("#")):e}}function Hi(n,e){for(let t of n)Xe([t.node],({kanonak:o,address:i})=>{o instanceof V&&!e.has(o)&&e.set(o,un(o,i,t.subject))})}var cn=class{constructor(e){this.scope=e}scope;ancestors=new Map;defined;defines(e){return this.defined??=new Set(this.scope.catalog.filter(t=>t instanceof g).map(B)),this.defined.has(p(e))}isInstance(e,t){let o=p(t);return e.some(i=>p(i)===o||this.ancestorsOf(i).has(o))}ancestorsOf(e){let t=e.version&&typeof e.version.major=="number"?`${p(e)}@${$(e.version)}`:p(e),o=this.ancestors.get(t);return o||(o=this.scope.reasoning?new Set(this.scope.reasoning.getSuperclasses(e)):new Set(Ge(this.scope.catalog,e).map(i=>p(i))),this.ancestors.set(t,o)),o}};function ji(n,e,t){let{scope:o}=n,i=new Map,r=a=>{i.set(a.key,a)},d=()=>[...t,...n.embeddedFocus.values()];if(e.targetClass){let a=e.targetClass;for(let c of d())n.membership.isInstance(G(c.node),a)&&r(c)}for(let a of e.targetNodes){let c=I(o.catalog,a);c instanceof g&&r(Oe(c))}for(let a of e.targetSubjectsOf){let c=p(a);for(let u of d())u.node.statement.some(s=>{let f=Io(s);return f&&p(f.subject)===c})&&r(u)}for(let a of e.targetObjectsOf)for(let c of d())for(let u of ee(c.node,a,o.catalog,c.key))u.kind==="subject"?r(Oe(u.node)):u.kind==="embedded"&&r(n.embeddedFocus.get(u.node)??un(u.node,u.address,c.subject));return[...i.values()]}function Di(n,e,t,o){let i=new Map;for(let c of t)n.membership.isInstance(G(c.node),e.classUri)&&i.set(c.key,c);let r=[];for(let c of[...i.values()].sort((u,s)=>u.key<s.key?-1:u.key>s.key?1:0)){let u=e.properties.map(s=>Ti(n,c,s));u.every(s=>s.size>0)&&r.push({focus:c,values:u})}let d=new Map;r.forEach(({values:c},u)=>{for(let s of c[0].keys()){let f=d.get(s);f?f.push(u):d.set(s,[u])}});let a=new Set;for(let c of d.values())for(let u=0;u<c.length;u++)for(let s=u+1;s<c.length;s++){let f=`${c[u]}:${c[s]}`;if(a.has(f))continue;let m=r[c[u]],l=r[c[s]],h=m.values.map((w,S)=>[...w.keys()].find(x=>l.values[S].has(x)));if(h.some(w=>w===void 0))continue;a.add(f);let[y,R]=sn(n.scope,m.focus)?[m.focus,l.focus]:sn(n.scope,l.focus)?[l.focus,m.focus]:[void 0,void 0];if(!y||!R)continue;let v=e.properties.map((w,S)=>`${w.name} = ${m.values[S].get(h[S])}`).join(", ");o.push({focusNode:y.key,focusUri:y.uri,valueRef:R.uri,constraintComponent:q,severity:"Violation",message:`'${y.label}' and '${R.label}' are distinct instances of ${e.className} with the same key (${v}); its owl.hasKey makes the key unique.`})}}function Ti(n,e,t){let o=new Map;for(let i of ee(e.node,t,n.scope.catalog,e.key))switch(i.kind){case"subject":case"unresolved":o.set(`ref:${p(i.uri)}`,i.uri.name);break;case"literal":o.set(`${typeof i.value}:${String(i.value)}`,JSON.stringify(i.value));break;case"embedded":break}return o}function Fi(n,e,t){return e.node?ee(e.node,t,n.values,e.key).map(o=>Wi(n,o,e.subject)):[]}function Wi(n,e,t){switch(e.kind){case"subject":return{kernel:{ref:p(e.uri)},kind:"reference",ref:e.uri,subject:e.node};case"unresolved":return{kernel:{ref:p(e.uri)},kind:"reference",ref:e.uri};case"embedded":{let o=n.embeddedFocus.get(e.node)??un(e.node,e.address,t);return{kernel:{ref:o.key},kind:"embedded",embedded:o}}case"literal":return typeof e.value=="boolean"?{kernel:e.value?1:0,kind:"boolean",literal:e.value}:{kernel:e.value,kind:typeof e.value=="number"?"number":"string",literal:e.value}}}function Oo(n,e,t,o){for(let i of e.properties)Ao(n,e,t,i,o);e.closed&&na(e,t,o)}function dn(n,e,t,o,i={},r){return{focusNode:e.key,focusUri:e.uri,constraintComponent:t,severity:r??No(n),message:o,sourceShape:n.name,sourceShapeUri:n.uri,...i}}function No(n){return n.severity??"Violation"}var qi={minCount:me,maxCount:he,hasValue:W,in:ke,pattern:ye,minLength:Ee,maxLength:Ce,minInclusive:be,maxInclusive:_e};function Ao(n,e,t,o,i){let r=Fi(n,t,o.path),d=o.severity??No(e),a=o.path.name,c=[...(o.inValues??[]).map(s=>typeof s=="boolean"?s?1:0:s),...(o.inRefs??[]).map(s=>({ref:p(s)}))],u=(s,f,m)=>{let l=dn(e,t,s,o.message??f,{resultPath:o.path,value:m?.literal,valueRef:m?.ref},d);return i.push(l),l};for(let s of Ie(o)){let f=qi[s.component];if(s.per==="node"){let m={[te]:r.map(l=>l.kernel),[Ke]:c};o.hasValue&&(m[rn]={ref:p(o.hasValue)}),xo(s,m)||u(f,Bi(s,a,o,r.length));continue}for(let m of r){if((s.component==="pattern"||s.component==="minLength"||s.component==="maxLength")&&m.kind!=="string"){u(f,`'${a}' value is not a string; ${s.component} applies to string values.`,m);continue}xo(s,{v:m.kernel,[Ke]:c})||u(f,Qi(s,a,o,m),m)}}if(o.nodeKind)for(let s of r)Ji(o.nodeKind,s)||u(Pe,`'${a}' value is ${s.kind}; nodeKind requires ${o.nodeKind}.`,s);if(o.datatype)for(let s of r){let f=Zi(o.datatype,s);f&&u(Se,`'${a}' ${f}`,s)}if(o.classRef)for(let s of r){let f=ea(n,o.classRef,s);f&&u(ge,`'${a}' ${f}`,s)}o.qualified&&Gi(n,o,r,a,u)}function Bi(n,e,t,o){switch(n.component){case"minCount":return`'${e}' has ${o} value(s); minCount is ${t.minCount}.`;case"maxCount":return`'${e}' has ${o} value(s); maxCount is ${t.maxCount}.`;case"hasValue":return`'${e}' has no value equal to ${t.hasValue?p(t.hasValue):"(unset)"}.`;default:return`'${e}' violates ${n.component}.`}}function Gi(n,e,t,o,i){let r=e.qualified,d=r.maxCount!==void 0?j:H,a=(u,s)=>{Lo.add(i(d,u,s))};if(!r.shape){a(`'${o}' qualified value shape cannot be evaluated: ${r.problem??"it could not be built"}.`);return}let c=0;for(let u of t){let s=u.ref?p(u.ref):u.embedded?u.embedded.label:JSON.stringify(u.literal),f=zi(n,u);if(!f){a(`'${o}' value ${s} does not resolve in this scope; whether it conforms to the qualified shape cannot be decided.`,u);continue}let m=Yi(n,r.shape,f);if(m.kind==="undecided"){a(`'${o}' value ${s}: whether it conforms to the qualified shape cannot be decided \u2014 ${m.reason}`,u);continue}m.kind==="conforms"&&c++}r.minCount!==void 0&&c<r.minCount&&i(H,`'${o}' has ${c} value(s) that conform to the qualified shape; qualifiedMinCount is ${r.minCount}.`),r.maxCount!==void 0&&c>r.maxCount&&i(j,`'${o}' has ${c} value(s) that conform to the qualified shape; qualifiedMaxCount is ${r.maxCount}.`)}function zi(n,e){switch(e.kind){case"reference":return e.subject?Oe(e.subject):void 0;case"embedded":return e.embedded;default:{let t=JSON.stringify(e.literal);return{key:t,label:t}}}}var Xi={name:"(qualified value shape)",targetNodes:[],targetSubjectsOf:[],targetObjectsOf:[],closed:!1,ignoredProperties:[],properties:[]},Lo=new WeakSet;function Yi(n,e,t){let o=[];e.kind==="property"?Ao(n,Xi,t,e.constraint,o):Oo(n,e.shape,t,o);let i=o.find(r=>Lo.has(r));return i?{kind:"undecided",reason:i.message}:o.length===0?{kind:"conforms"}:{kind:"fails"}}function Qi(n,e,t,o){let i=o.ref?p(o.ref):o.embedded?o.embedded.label:JSON.stringify(o.literal);switch(n.component){case"in":return`'${e}' value ${i} is not in the permitted set.`;case"pattern":return`'${e}' value ${i} does not match pattern ${t.pattern?.regex}.`;case"minLength":return`'${e}' value ${i} is shorter than minLength ${t.minLength}.`;case"maxLength":return`'${e}' value ${i} is longer than maxLength ${t.maxLength}.`;case"minInclusive":return`'${e}' value ${i} is below minInclusive ${t.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${i} is above maxInclusive ${t.maxInclusive} (or not numeric).`;default:return`'${e}' value ${i} violates ${n.component}.`}}function xo(n,e){let t=o=>{let i=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof i=="string"&&i in e)return e[i];throw new $i(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return Ui(n.expr,void 0,t)===1}function Ji(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function Zi(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let t=Ye(n);if(t!==void 0)switch(t){case D.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case D.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case D.Decimal:case D.Double:case D.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function ea(n,e,t){if(t.kind==="embedded"&&t.embedded?.node){let d=G(t.embedded.node);return d.length===0?`value ${t.embedded.label} has no type; sh:class requires an instance of ${e.name}.`:n.membership.isInstance(d,e)?void 0:`value ${t.embedded.label} is not an instance of ${e.name}.`}if(t.kind!=="reference"||!t.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let o=t.subject;if(!o){let d=n.scope.links?.unresolved.get(p(t.ref));return d?`value ${p(t.ref)} is a link that does not dereference: ${d} (sh:class ${e.name}).`:`value ${p(t.ref)} does not resolve in this scope (sh:class ${e.name}).`}let i=G(o);if(n.membership.isInstance(i,e))return;let r=i.filter(d=>!n.membership.defines(d));return r.length>0?`value ${p(t.ref)} is typed ${r.map(p).join(", ")}, which this scope does not define, so it cannot be shown to be an instance of ${e.name}. A class is in scope when the judged document imports the package that defines it.`:`value ${p(t.ref)} is not an instance of ${e.name}.`}function na(n,e,t){if(!e.node)return;let o=new Set([...n.properties.map(r=>p(r.path)),...n.ignoredProperties.map(r=>p(r))]),i=new Set;for(let r of e.node.statement){let d=Io(r);if(!d)continue;let a=p(d.subject);o.has(a)||i.has(a)||(i.add(a),t.push(dn(n,e,Z,`'${e.label}' carries undeclared property '${d.subject.name}' (closed shape).`,{resultPath:d.subject})))}for(let r of e.node.unresolvedPredicates)i.has(r.key)||(i.add(r.key),t.push(dn(n,e,Z,`'${e.label}' carries unresolvable property '${r.key}' (closed shape).`,{value:r.key})))}var oa="1.1.0",ta=new Set([W,H,j].map(n=>n.name)),ra=new Set([q].map(n=>n.name));function ia(n){let e=new Set(n.results.map(t=>t.constraintComponent.name));return[...e].some(t=>ra.has(t))?"1.3.0":[...e].some(t=>ta.has(t))?"1.2.0":oa}async function Vo(n){let e=new ne(n.repository),t=e.imports(),o=t.ensure(le,pe,ia(n.result),"sh"),i=(a,c)=>a&&a.version&&typeof a.version.major=="number"?`${t.ensure(a.publisher,a.package_,$(a.version),a.package_)}.${a.name}`:c,r={},d=[];return n.result.results.forEach((a,c)=>{let u=`result-${c+1}`;d.push(u);let s={type:`${o}.ValidationResult`,[`${o}.focusNode`]:i(a.focusUri,a.focusNode),[`${o}.resultMessage`]:a.message,[`${o}.resultSeverity`]:`${o}.${a.severity}`,[`${o}.sourceConstraintComponent`]:`${o}.${a.constraintComponent.name}`};a.resultPath&&(s[`${o}.resultPath`]=i(a.resultPath,p(a.resultPath))),a.sourceShapeUri&&a.sourceShape!==void 0&&(s[`${o}.sourceShape`]=i(a.sourceShapeUri,a.sourceShape)),a.valueRef?s[`${o}.value`]=i(a.valueRef,p(a.valueRef)):a.value!==void 0&&(s[`${o}.value`]=a.value),r[u]=s}),r.report={type:`${o}.ValidationReport`,[`${o}.conforms`]:n.result.conforms,...d.length>0?{[`${o}.result`]:d}:{}},e.buildContentAddressed({publisher:n.publisher,book:t,body:r,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as fc}from"@kanonak-protocol/types/document/models/enums";import{spawn as aa}from"child_process";var Uo=12e4,sa=4096,re=class{argv;interactive;timeoutMs;stderr;now;constructor(e){this.argv=$o(e.command),this.interactive=e.interactive??!1,this.timeoutMs=e.timeoutMs??Uo,this.stderr=e.stderr??process.stderr,this.now=e.nowSeconds??(()=>Date.now()/1e3)}get command(){return this.argv.join(" ")}async get(e){let t=await this.run("get",this.wireRequest("get",e)),o=en(e,t,this.now());if(!o.ok)throw new L(`credential helper '${this.command}' answered get for ${e.resource} outside the protocol (${o.problem}): ${o.message}`);return o.answer}async erase(e){let t=await this.run("erase",{...this.wireRequest("erase",e),scope:e.scope}),o=nn(t);if(!o.ok)throw new L(`credential helper '${this.command}' answered erase for ${e.resource} outside the protocol (${o.problem}): ${o.message}`)}wireRequest(e,t){let o={version:Ze,operation:e,resource:t.resource,method:t.method};return t.challenges&&(o.challenges=t.challenges),o.interactive=this.interactive,o}run(e,t){let o=`credential helper '${this.command}' ${e}`;return new Promise((i,r)=>{let d=!1,a=l=>{d||(d=!0,l())},c;try{c=aa(this.argv[0],[...this.argv.slice(1),e],{stdio:["pipe","pipe","pipe"],shell:!1,windowsHide:!0})}catch(l){r(Mo(o,l));return}let u=[],s="",f=!1,m=setTimeout(()=>{f=!0,c.kill()},this.timeoutMs);c.stdout.on("data",l=>u.push(l)),c.stderr.on("data",l=>{this.stderr.write(l),s=(s+l.toString("utf8")).slice(-sa)}),c.on("error",l=>{clearTimeout(m),a(()=>r(Mo(o,l)))}),c.on("close",(l,h)=>{clearTimeout(m);let y=s.trim()?`: ${s.trim()}`:"";if(f){a(()=>r(new L(`${o} did not finish within ${Math.round(this.timeoutMs/1e3)}s${y}`)));return}if(l!==0){let v=l!==null?`exit ${l}`:`signal ${h}`;a(()=>r(new L(`${o} failed (${v})${y}`)));return}let R=Buffer.concat(u).toString("utf8").trim();try{let v=JSON.parse(R);a(()=>i(v))}catch{a(()=>r(new L(`${o} exited 0 without printing one JSON answer${y}`)))}}),c.stdin.on("error",()=>{}),c.stdin.end(`${JSON.stringify(t)}
|
|
4
|
+
`)})}};function $o(n){let e=n.trim().split(/\s+/).filter(t=>t!=="");if(e.length===0)throw new Error("the credential helper command is empty");return e}function Mo(n,e){let t=e.code,o="";return t==="ENOENT"&&(o=" (not found: give its path, or put it on PATH)"),t==="EINVAL"&&process.platform==="win32"&&(o=" (a .cmd or .bat file cannot run without a shell: configure an executable, e.g. `node path/to/helper.js`)"),new L(`${n} could not be started: ${e.message}${o}`)}import{existsSync as ca,readFileSync as da}from"fs";import{homedir as ua}from"os";import{join as la}from"path";function ie(){return la(ua(),".kanonak","config.json")}function ae(n){if(!ca(n))return;let e;try{e=JSON.parse(da(n,"utf-8"))}catch(t){throw new Error(`${n} is not valid JSON: ${t.message}`)}if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${n} must hold a JSON object`);return e}var ln="KANONAK_CREDENTIAL_HELPER";function pa(n={}){let e=n.env??process.env,t=n.configPath??ie(),o=fa(e,t);if(o){let r=Object.keys(e).filter(d=>(d===ve||d.startsWith(`${ve}_`))&&(e[d]??"").trim()!=="").sort();if(r.length>0)throw new Error(`A credential helper is configured (${o.source}: ${o.command}) and so is ${r.join(", ")}. Configure one or the other.`);return new re({command:o.command,interactive:n.interactive??!1})}let i={env:e};return n.discovery&&(i.discovery=n.discovery),new on(i)}function fa(n,e){let t=(n[ln]??"").trim();if(t)return{command:t,source:ln};let o=ae(e)?.credentialHelper;if(o!==void 0){if(typeof o!="string"||o.trim()==="")throw new Error(`"credentialHelper" in ${e} must be a non-empty command line`);return{command:o.trim(),source:e}}}var pn="KANONAK_PACKAGE_URL_TEMPLATE";function ma(n={}){let e=n.env??process.env,t=n.configPath??ie(),o=ae(t)?.packageUrlTemplates,i=o===void 0?{}:{...Me(o,"packageUrlTemplates",t)},r=(e[pn]??"").trim();return r&&(i[Ve]=Ue(r,pn,!0)),Object.keys(i).length>0?Object.freeze(i):void 0}var P="kanonak.org",A="view",Ho="core-kanonak",ha={publisher:P,package_:A,name:"rootView"},Sa={publisher:P,package_:A,name:"bind"},ga={publisher:P,package_:A,name:"produces"},ka={publisher:P,package_:A,name:"projections"},ya={publisher:P,package_:A,name:"where"},Ea={publisher:P,package_:A,name:"value"},Ca={publisher:P,package_:A,name:"as"},Ne=class{constructor(e,t=new X){this.repository=e;this.parser=t;this.objectParser=new M(this.parser),this.builder=new ne(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,t={}){let o=await this.objectParser.parseKanonaks(this.repository),i=this.resolveView(o,e),r=k(i,Sa);if(!r)throw new Error(`View ${i.namespace}/${i.name} declares no view.bind; cannot materialize.`);let d=k(i,ga);if(!d)throw new Error(`View ${i.namespace}/${i.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let a=ba(i),c=jo(o,P,Ho),u=jo(o,P,A),s=this.builder.imports(),f=s.ensure(P,Ho,c,"ck"),m=s.ensure(P,A,u,"v"),l=s.ref(d),h=new co(this.repository,this.parser,this.objectParser),y=new so(h,o),R=this.readProjections(o,i),v=Ra(i,ya),w=this.findInstances(o,r,await this.reason(t)),S={},x=new Set;for(let se of w){if(!await this.passesWhere(y,o,v,se))continue;let Ae={type:l};for(let mn of R){let To=await this.evaluateValue(y,o,mn.value,se),hn=this.builder.serializeValue(Do(To),s);hn!==void 0&&(Ae[s.ref(mn.as)]=hn)}let fn=E(se);fn&&(Ae[`${m}.derivedFrom`]=s.ref(fn)),S[this.rowName(se,x)]=Ae}let C={};t.resolvedAt&&(C[`${f}.resolvedAt`]=t.resolvedAt),t.invocationId&&(C[`${f}.id`]=t.invocationId);let N=await this.builder.buildContentAddressed({publisher:a,book:s,body:S,contentHashProperty:`${f}.contentHash`,header:C});return{yaml:N.yaml,contentHash:N.contentHash,packageName:N.packageName,publisher:N.publisher,rowCount:N.resourceCount}}resolveView(e,t){let o=I(e,t);if(!o)throw new Error(`View ${t.publisher}/${t.package_}/${t.name} not found in the catalog.`);let i=k(o,ha);if(i){let r=I(e,i);if(!r)throw new Error(`ViewPackage ${t.name} names rootView ${i.name}, which is not in the catalog.`);return r}return o}readProjections(e,t){let o=[];for(let i of He(t,ka)){let r=i instanceof V?i:i instanceof K?I(e,i.subject):void 0;if(!r)continue;let d=Y(r,Ea),a=k(r,Ca);d&&a&&o.push({value:d,as:a})}return o}async reason(e){return new z({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,t,o){let i=Pa(e),r=[],d=new Set;for(let a of o.getInstancesOfClass(t)){if(d.has(a))continue;d.add(a);let c=i.get(a);c&&r.push(c)}return r.sort((a,c)=>{let u=Q(E(a)),s=Q(E(c));return u<s?-1:u>s?1:0}),r}async passesWhere(e,t,o,i){for(let r of o){let d=await this.evaluateValue(e,t,r,i);if(!va(d))return!1}return!0}async evaluateValue(e,t,o,i){let r=ao(o,"view-projection",{catalog:t,depth:0}),d=new Map([["input",i]]);return e.evaluate(r,d)}rowName(e,t){let o=Je(e.name)||"row",i=o,r=2;for(;t.has(i);)i=`${o}-${r++}`;return t.add(i),i}};function Do(n){return Qe(n)?n.value:Array.isArray(n)?n.map(Do):n}function ba(n){let e=E(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function jo(n,e,t){let o=_a(n,e,t);if(!o)throw new Error(`Package ${e}/${t} is not in the catalog; it must be importable to materialize a view.`);return o}function _a(n,e,t){let o;for(let i of n){if(!(i instanceof g))continue;let r=E(i);!r||r.publisher!==e||r.package_!==t||!r.version||(!o||ce(r.version,o)>0)&&(o=r.version)}return o?$(o):void 0}function Pa(n){let e=new Map,t=new Map;for(let o of n){if(!(o instanceof g))continue;let i=E(o);if(!i||!i.version)continue;let r=Q(i),d=t.get(r);(!d||ce(i.version,d)>0)&&(t.set(r,i.version),e.set(r,o))}return e}function Ra(n,e){let t=Y(n,e);return t?[t]:He(n,e).filter(o=>o instanceof V)}function va(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:Qe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{Ve as ANY_PUBLISHER,Ur as AmbiguousReferenceRule,Lt as BooleanStatement,pi as CANONICAL_FORM_VERSION,_i as CREDENTIAL_EXPIRY_SKEW_SECONDS,ln as CREDENTIAL_HELPER_ENV,Ze as CREDENTIAL_HELPER_PROTOCOL_VERSION,Uo as CREDENTIAL_HELPER_TIMEOUT_MS,D as Carrier,Fr as ClassDefinitionRule,Ir as ClassHierarchyCycleRule,et as CompositeKanonakDocumentRepository,L as CredentialError,yi as DEFAULT_CONSENT_BINDING_PARAM,xt as DefinedKanonak,ci as DiamondNameClashRule,qr as DisplayLensScopeRule,Zo as DocumentLocation,nr as EdgeType,V as EmbeddedKanonak,wr as EmbeddedKanonakTypeRule,Mt as EmbeddedStatement,Ii as EntitlementDeniedError,Oi as EntitlementProducer,re as ExecCredentialProvider,Jo as FileSystemKanonakDocumentRepository,Pt as GitIgnoreFilter,or as GraphBuilder,Ct as HttpKanonakDocumentRepository,gn as INTEGRITY_PREFIX,mi as ImportBook,xr as ImportExistenceRule,Le as InMemoryKanonakDocumentRepository,st as KANONAK_USER_AGENT,wt as Kanonak,cr as KanonakDocumentPositions,tt as KanonakHttpError,M as KanonakObjectParser,di as KanonakObjectValidator,X as KanonakParser,ft as KanonakUri,fr as KanonakUriBuilder,mr as KanonakUrlResolver,Gt as KanonakVocabulary,Qr as LINE_STYLES,Cr as LinkTargetRule,Ut as ListStatement,Kt as LiteralKanonak,bt as LocalFirstRepository,_t as LockAwareRepository,ri as LookBandPathRule,ni as LookRenderer,Br as LookSemanticSvgPathRule,Wr as MarkdownLinkRule,$t as MarkdownStatement,Vr as NamespaceImportCycleRule,br as NamespacePrefixRule,er as NodeType,At as NumberStatement,Ei as OAuthDiscovery,qe as OWL_HAS_KEY,ir as OWL_RL_CLASSIFICATION_RULES,Hr as ObjectPropertyValueValidationRule,kr as OntologyValidationError,Sr as OntologyValidationResult,si as OwlOneOfRule,pn as PACKAGE_URL_TEMPLATE_ENV,ne as PackageBuilder,vr as PackageHeaderRule,wi as ProducerRepository,jr as PropertyDomainRule,Or as PropertyHierarchyCycleRule,Dr as PropertyKindRangeConsistencyRule,sr as PropertyMetadata,$r as PropertyRangeReferenceRule,Nr as PropertyRangeRequiredRule,Pr as PropertyTypeSpecificityRule,kt as PublisherConfigResolver,yt as PublisherIndex,rr as RDFS_RULES,z as Reasoner,ar as ReasoningResult,K as ReferenceKanonak,Vt as ReferenceStatement,ot as RepositoryFactory,Tr as ReservedNameShadowRule,_r as ResourceNamingRule,Ht as ResourceResolver,zt as ResourceTypeClassifier,pe as SHACL_PACKAGE,le as SHACL_PUBLISHER,ge as SH_COMP_CLASS,Z as SH_COMP_CLOSED,Se as SH_COMP_DATATYPE,q as SH_COMP_HAS_KEY,W as SH_COMP_HAS_VALUE,ke as SH_COMP_IN,he as SH_COMP_MAX_COUNT,_e as SH_COMP_MAX_INCLUSIVE,Ce as SH_COMP_MAX_LENGTH,me as SH_COMP_MIN_COUNT,be as SH_COMP_MIN_INCLUSIVE,Ee as SH_COMP_MIN_LENGTH,Pe as SH_COMP_NODE_KIND,ye as SH_COMP_PATTERN,j as SH_COMP_QUALIFIED_MAX_COUNT,H as SH_COMP_QUALIFIED_MIN_COUNT,J as SH_NODE_SHAPE,fe as SH_PROPERTY_SHAPE,Kn as SH_SHAPE,Ot as ScalarStatement,ti as SequenceNarrativeRule,ai as ShaclShapeRule,It as Statement,Nt as StringStatement,Ar as SubClassOfReferenceRule,Lr as SubPropertyOfReferenceRule,g as SubjectKanonak,Rr as SubjectKanonakTypeRequiredRule,ve as TOKEN_ENV,on as TokenCredentialProvider,tr as TripleStore,Gr as TxExpressionCompilesRule,ii as TxExpressionPathRule,jt as TypeResolver,zr as URI_DISPLAY_LABEL,Xr as URI_DISPLAY_SUMMARY,Mr as UnresolvedPredicateRule,Kr as UnresolvedReferenceRule,bn as VERSION_INDEX_FILE,Er as ValidationCache,yr as ValidationContext,gr as ValidationSeverity,fc as VersionOperator,Ne as ViewMaterializer,xi as allowAllPolicy,ut as assertHttpsUrl,Cn as assertIntegrityAsync,Et as assertPackageIdentity,xe as buildKeysModel,vt as buildLocalFirstRepository,ei as buildOntologyModel,Vo as buildReportPackageAsync,we as buildShapesModel,qt as builtinHomePackages,Bt as builtinUri,ui as canonicalForm,li as canonicalHash,Ye as carrierOf,Ci as checkCredentialAnswer,en as checkHelperAnswer,nn as checkHelperEraseAnswer,Ue as checkPackageUrlTemplate,Me as checkPackageUrlTemplates,Rt as collectKanonakFiles,ce as compareVersions,po as computeIntegrity,En as computeIntegrityAsync,fi as contentAddressedName,G as contextTypesOf,Pi as createCredentialedFetch,Bo as createVersion,pa as credentialProviderFromConfig,it as describeResponse,Ko as evaluateConformance,Zt as extractMarkdownLinks,gt as fillPackageUrlTemplate,vi as findDerivation,Jt as findMalformedReferences,ur as findMarkdownLinkAt,an as foldFlagsIntoPattern,ht as formatKanonakAddress,$ as formatVersion,nt as getGlobalCachePath,dt as getKanonakUserAgent,rt as httpError,Rn as indexedVersion,zo as isCompatibleVersion,Xo as isMajorCompatible,ze as isPropertySubject,lt as kanonakFetch,uo as loadLockFile,fo as loadVersionIndex,Sn as lockedVersion,Ie as lowerConstraint,Tt as makeUriKey,ki as narrowestScope,Ki as noopMeter,hi as normalizeHost,St as packageUrlTemplateFor,ma as packageUrlTemplatesFromConfig,mt as parseKanonakAddress,kn as parseLockFile,Si as parseScope,_n as parseVersionIndex,Go as parseVersionString,dr as parseWithPositions,bi as parseWwwAuthenticate,Qo as pickHighestDocument,vn as planVersionIndex,Yt as propertiesInScope,Xt as propertyClassOf,Jr as readSequenceConnectors,ae as readUserConfig,hr as referenceSpelling,T as referenceUris,Yr as resolveDisplayValue,Qt as resolvePropertyStep,at as retryAfterSecondsOf,Je as sanitizeName,Yo as satisfiesVersionOperator,lo as saveLockFile,mo as saveVersionIndex,gi as scopeContains,go as scopeFromCatalog,So as scopeFromClosureAsync,ko as scopeFromDocumentAsync,ho as scopeFromRepositoryAsync,yn as serializeLockFile,Pn as serializeVersionIndex,pt as setKanonakFetchRetries,ct as setKanonakUserAgent,wn as setYanked,pr as sourceSymbolAt,lr as sourceSymbols,$o as splitCommandLine,B as subjectAddress,E as subjectUri,Ge as superClassChain,oi as supportedBandKeys,Ri as tokenEnvKeyFor,Ft as tripleKey,Dt as typeReferenceUris,Q as uriKey,Wt as uriTriple,ie as userConfigPath,ee as valuesOf,Fo as versionOperatorFromChar,Wo as versionOperatorToChar,qo as versionsEqual,Xe as walkDefinedKanonaks,Zr as walkSequence};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Version } from '@kanonak-protocol/types/document/models/types';
|
|
2
|
+
/**
|
|
3
|
+
* The publisher's index: every version of every package it has published,
|
|
4
|
+
* each with the sha256 of its bytes and whether it is yanked. A publisher
|
|
5
|
+
* keeps it at the root of its workspace and serves it at
|
|
6
|
+
* `https://{publisher}/kanonak.index`.
|
|
7
|
+
*
|
|
8
|
+
* A version's entry is written once, when the version is published, and only
|
|
9
|
+
* its yank ever changes: published bytes never change, and a published
|
|
10
|
+
* version is never removed. A yanked version is still served and still read
|
|
11
|
+
* wherever a text or a lock names it; it is only never taken as the newest.
|
|
12
|
+
*
|
|
13
|
+
* NORMATIVE: consumers MUST parse `kanonak.index` as YAML, and producers
|
|
14
|
+
* SHOULD emit it through {@link serializeVersionIndex}.
|
|
15
|
+
*/
|
|
16
|
+
export declare const VERSION_INDEX_FILE = "kanonak.index";
|
|
17
|
+
declare const VERSION_INDEX_FORMAT = "1";
|
|
18
|
+
export interface IndexedVersion {
|
|
19
|
+
/** `sha256:` of the version's source bytes, as a lock's `integrity`. */
|
|
20
|
+
integrity: string;
|
|
21
|
+
/** Present only when the version is yanked. */
|
|
22
|
+
yanked?: true;
|
|
23
|
+
}
|
|
24
|
+
export interface VersionIndex {
|
|
25
|
+
version: typeof VERSION_INDEX_FORMAT;
|
|
26
|
+
publisher: string;
|
|
27
|
+
/** package name → version (`MAJOR.MINOR.PATCH`) → its entry. */
|
|
28
|
+
packages: Record<string, Record<string, IndexedVersion>>;
|
|
29
|
+
}
|
|
30
|
+
/** One version a publisher's workspace holds: what its index must agree with. */
|
|
31
|
+
export interface PublishedSource {
|
|
32
|
+
package_: string;
|
|
33
|
+
version: Version;
|
|
34
|
+
source: string;
|
|
35
|
+
}
|
|
36
|
+
/** A change {@link planVersionIndex} makes to the workspace's index. */
|
|
37
|
+
export interface VersionIndexChange {
|
|
38
|
+
kind: 'added' | 'rehashed' | 'removed';
|
|
39
|
+
package_: string;
|
|
40
|
+
version: string;
|
|
41
|
+
message: string;
|
|
42
|
+
}
|
|
43
|
+
/** Something the publisher's served index forbids: a published version's bytes changed, or its source is gone. */
|
|
44
|
+
export interface VersionIndexRefusal {
|
|
45
|
+
kind: 'changed' | 'removed';
|
|
46
|
+
package_: string;
|
|
47
|
+
version: string;
|
|
48
|
+
message: string;
|
|
49
|
+
}
|
|
50
|
+
export interface VersionIndexPlan {
|
|
51
|
+
index: VersionIndex;
|
|
52
|
+
changes: VersionIndexChange[];
|
|
53
|
+
refusals: VersionIndexRefusal[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse a `kanonak.index`, and throw, naming `from` and what is wrong, on
|
|
57
|
+
* anything that is not one: a different format version, a version that is not
|
|
58
|
+
* `MAJOR.MINOR.PATCH`, an integrity that is not `sha256:` and 64 hex digits, a
|
|
59
|
+
* yank that is not `true`, or a field the format doesn't have.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseVersionIndex(raw: string, from: string): VersionIndex;
|
|
62
|
+
/**
|
|
63
|
+
* The canonical `kanonak.index` text: generated-file header, packages sorted
|
|
64
|
+
* by name, and each package's versions in version order. Pure and
|
|
65
|
+
* deterministic, so the same index always gives the same bytes.
|
|
66
|
+
*/
|
|
67
|
+
export declare function serializeVersionIndex(index: VersionIndex): string;
|
|
68
|
+
/** The entry an index holds for one version of one package, or undefined when it has none. */
|
|
69
|
+
export declare function indexedVersion(index: VersionIndex, packageName: string, version: Version): IndexedVersion | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* The index a publisher's workspace should hold, with its changes and
|
|
72
|
+
* refusals in package and version order, given its `current` index
|
|
73
|
+
* (null when it has none), the versions it holds (`sources`), and the index
|
|
74
|
+
* its origin serves (`served`, null when it serves none, as before its first
|
|
75
|
+
* publication).
|
|
76
|
+
*
|
|
77
|
+
* Each source gets an entry with the sha256 of its bytes. A version the origin
|
|
78
|
+
* serves is published, so its bytes must still hash to the served entry and
|
|
79
|
+
* its source must still be there: anything else is a refusal, since a
|
|
80
|
+
* published version's bytes never change and it is never removed. A version
|
|
81
|
+
* the origin doesn't serve yet is still being written, so its entry follows
|
|
82
|
+
* its bytes, and goes when its source does. Yanks are carried over from
|
|
83
|
+
* `current`, or from `served` for an entry `current` has lost, and only
|
|
84
|
+
* {@link setYanked} changes one.
|
|
85
|
+
*/
|
|
86
|
+
export declare function planVersionIndex(params: {
|
|
87
|
+
publisher: string;
|
|
88
|
+
current: VersionIndex | null;
|
|
89
|
+
sources: readonly PublishedSource[];
|
|
90
|
+
served: VersionIndex | null;
|
|
91
|
+
}): Promise<VersionIndexPlan>;
|
|
92
|
+
/**
|
|
93
|
+
* The index with one version's yank set or cleared. Throws when the index has
|
|
94
|
+
* no entry for it: only a version the index holds can be yanked.
|
|
95
|
+
*/
|
|
96
|
+
export declare function setYanked(index: VersionIndex, packageName: string, version: Version, yanked: boolean): VersionIndex;
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type VersionIndex } from './VersionIndex.js';
|
|
2
|
+
/** The `kanonak.index` at `path`, or null when there is no file there. A file that isn't one throws. */
|
|
3
|
+
export declare function loadVersionIndex(path: string): VersionIndex | null;
|
|
4
|
+
export declare function saveVersionIndex(index: VersionIndex, path: string): void;
|
package/dist/lock/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { loadLockFile, saveLockFile, computeIntegrity, } from './LockFileIO.js';
|
|
2
2
|
export { parseLockFile, serializeLockFile, computeIntegrityAsync, assertIntegrityAsync, lockedVersion, INTEGRITY_PREFIX, } from './LockFile.js';
|
|
3
3
|
export type { LockFile, LockEntry } from './LockFile.js';
|
|
4
|
+
export { VERSION_INDEX_FILE, parseVersionIndex, serializeVersionIndex, indexedVersion, planVersionIndex, setYanked, } from './VersionIndex.js';
|
|
5
|
+
export type { VersionIndex, IndexedVersion, PublishedSource, VersionIndexChange, VersionIndexRefusal, VersionIndexPlan, } from './VersionIndex.js';
|
|
6
|
+
export { loadVersionIndex, saveVersionIndex } from './VersionIndexIO.js';
|
package/dist/parsing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c,b as d,c as e,d as f,e as g,f as h}from"../chunk-
|
|
1
|
+
import{a as c,b as d,c as e,d as f,e as g,f as h}from"../chunk-C5HHCD6P.js";import{k as b}from"../chunk-A5EAI5ZU.js";import{a}from"../chunk-VAZY57HJ.js";import"../chunk-TVMOJ2QS.js";import"../chunk-6USORWEP.js";import"../chunk-F67UH4FD.js";import"../chunk-7IMLHHSA.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions,h as sourceSymbolAt,g as sourceSymbols};
|
package/dist/producer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"../chunk-
|
|
1
|
+
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"../chunk-4NTZY2KP.js";import"../chunk-QHABFCRC.js";import"../chunk-A5EAI5ZU.js";import"../chunk-VAZY57HJ.js";import"../chunk-TVMOJ2QS.js";import"../chunk-6USORWEP.js";import"../chunk-F67UH4FD.js";import"../chunk-7IMLHHSA.js";export{h as EntitlementDeniedError,i as EntitlementProducer,c as ImportBook,a as PackageBuilder,e as ProducerRepository,f as allowAllPolicy,b as contentAddressedName,g as noopMeter,d as sanitizeName};
|
package/dist/reasoning/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as j,b as k,c as l,d as m,e as n}from"../chunk-
|
|
1
|
+
import{a as j,b as k,c as l,d as m,e as n}from"../chunk-IXCD4K3K.js";import"../chunk-A5EAI5ZU.js";import"../chunk-VAZY57HJ.js";import{c as a,d as b,e as c,g as d,ga as e,ja as f,ka as g,la as h,ma as i}from"../chunk-TVMOJ2QS.js";import"../chunk-6USORWEP.js";import"../chunk-F67UH4FD.js";import"../chunk-7IMLHHSA.js";export{i as KanonakVocabulary,e as OWL_HAS_KEY,l as OWL_RL_CLASSIFICATION_RULES,k as RDFS_RULES,n as Reasoner,m as ReasoningResult,j as TripleStore,f as builtinHomePackages,g as builtinUri,h as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
|