@kanonak-protocol/sdk 3.5.0 → 3.6.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 +26 -26
- package/dist/derivation/findDerivation.d.ts +85 -0
- package/dist/derivation/index.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +37 -37
- package/dist/parsing/KanonakObjectParser.d.ts +22 -0
- package/dist/parsing/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polymorphic derivation discovery.
|
|
3
|
+
*
|
|
4
|
+
* Given an instance, a target format, and a target variant, walks the
|
|
5
|
+
* Kanonak ontology to find the transformation that should produce
|
|
6
|
+
* that derived artifact. The walk respects the protocol's two-level
|
|
7
|
+
* override semantics:
|
|
8
|
+
*
|
|
9
|
+
* 1. **Per-instance override (replace):** if the instance itself
|
|
10
|
+
* declares `derivation.derivations`, those are the ONLY bindings
|
|
11
|
+
* considered. The instance takes full ownership; class-level
|
|
12
|
+
* bindings do not fall through.
|
|
13
|
+
*
|
|
14
|
+
* 2. **Class-hierarchy walk (merge by format+variant):** otherwise,
|
|
15
|
+
* the walk starts from the instance's declared type and ascends
|
|
16
|
+
* via `rdfs.subClassOf` chains. The closest class wins for any
|
|
17
|
+
* given (format, variant) pair. Different (format, variant)
|
|
18
|
+
* pairs may be sourced from different classes in the chain —
|
|
19
|
+
* one class can override `html/default` while inheriting
|
|
20
|
+
* `markdown/summary` from its parent.
|
|
21
|
+
*
|
|
22
|
+
* 3. **Universal default (the floor):** the universal-derivations
|
|
23
|
+
* package augments `rdfs.Resource` with bindings for
|
|
24
|
+
* `formats.html`, `formats.markdown`, and `formats.json`. The
|
|
25
|
+
* open-world parser merges those into `rdfs.Resource`'s
|
|
26
|
+
* canonical Subject, so the walk discovers them when it reaches
|
|
27
|
+
* the root of every type chain.
|
|
28
|
+
*
|
|
29
|
+
* Returns `undefined` when no binding is found — failure is visible,
|
|
30
|
+
* never silently filled (per the no-mocks/no-fallbacks rule).
|
|
31
|
+
*/
|
|
32
|
+
import { SubjectKanonak } from '../kanonaks/index.js';
|
|
33
|
+
import type { Kanonak } from '../kanonaks/index.js';
|
|
34
|
+
/**
|
|
35
|
+
* Canonical URI identity (publisher + package + name). Version is
|
|
36
|
+
* intentionally omitted from the comparison API — discovery looks up
|
|
37
|
+
* resources by their stable identity, not by version.
|
|
38
|
+
*/
|
|
39
|
+
export interface DerivationEntityUri {
|
|
40
|
+
publisher: string;
|
|
41
|
+
package_: string;
|
|
42
|
+
name: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The 4-tuple identifying a published transformation. Resolved later
|
|
46
|
+
* by the runtime against a repository to fetch the actual
|
|
47
|
+
* `SubjectKanonak`.
|
|
48
|
+
*/
|
|
49
|
+
export interface TransformationReferenceTuple {
|
|
50
|
+
publisher: string;
|
|
51
|
+
package_: string;
|
|
52
|
+
version: string;
|
|
53
|
+
name: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The result of a successful discovery — the transformation pointer
|
|
57
|
+
* plus provenance (where in the hierarchy the binding was found).
|
|
58
|
+
*/
|
|
59
|
+
export interface DerivationLookupResult {
|
|
60
|
+
/** Pointer to the transformation that produces the artifact. */
|
|
61
|
+
transformation: TransformationReferenceTuple;
|
|
62
|
+
/**
|
|
63
|
+
* Where the binding was sourced from:
|
|
64
|
+
* - 'instance': the resource declared its own derivations.
|
|
65
|
+
* - {publisher, package_, name}: the class (somewhere in the
|
|
66
|
+
* hierarchy) that supplied the binding. `rdfs.Resource` here
|
|
67
|
+
* means the universal default applied.
|
|
68
|
+
*/
|
|
69
|
+
source: 'instance' | DerivationEntityUri;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Discover the transformation that should produce a derived artifact
|
|
73
|
+
* of the given (format, variant) for an instance.
|
|
74
|
+
*
|
|
75
|
+
* @param instance The Kanonak resource being derived.
|
|
76
|
+
* @param format Canonical URI of the target Format instance (typically
|
|
77
|
+
* from `kanonak.org/formats@1.0.0`).
|
|
78
|
+
* @param variant Canonical URI of the target Variant instance
|
|
79
|
+
* (typically from `kanonak.org/derivation@1.0.0`).
|
|
80
|
+
* @param catalog All loaded kanonaks (parsed via `KanonakObjectParser`).
|
|
81
|
+
* Should include the instance's class hierarchy AND
|
|
82
|
+
* `kanonak.org/universal-derivations@1.0.0` if you
|
|
83
|
+
* want the universal defaults to apply.
|
|
84
|
+
*/
|
|
85
|
+
export declare function findDerivation(instance: SubjectKanonak, format: DerivationEntityUri, variant: DerivationEntityUri, catalog: Kanonak[]): DerivationLookupResult | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,5 +23,7 @@ export { CredentialStore, createAuthenticatedFetch, generateDPoPKeyPair, createD
|
|
|
23
23
|
export type { CredentialBackend, StoredCredential, DPoPKeyPair, AuthenticatedFetchFn, } from './auth/index.js';
|
|
24
24
|
export { loadLockFile, saveLockFile, computeIntegrity, } from './lock/index.js';
|
|
25
25
|
export type { LockFile, LockEntry } from './lock/index.js';
|
|
26
|
+
export { findDerivation } from './derivation/index.js';
|
|
27
|
+
export type { DerivationEntityUri, TransformationReferenceTuple, DerivationLookupResult, } from './derivation/index.js';
|
|
26
28
|
export { CtlKanonakUri, CtlParser, ResourceTypeClassifier, CtlValidator, CtlGraphResolver, CtlMarkdownRenderer, CtlValidationErrorType, CtlValidationSeverity, CtlKanonakUriType, PathSegmentType, ResolvedResourceType } from './ctl/index.js';
|
|
27
29
|
export type { CtlDocument, KanonakReference, CtlValidationResult, CtlValidationError, ResolvedResourceGraph, ResolvedResource, ResolvedProperty, UnresolvedResource } from './ctl/index.js';
|