@superbee/core 0.1.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/backend.d.ts +77 -0
- package/dist/backend.d.ts.map +1 -0
- package/dist/backend.js +380 -0
- package/dist/backend.js.map +1 -0
- package/dist/bundle.d.ts +38 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +107 -0
- package/dist/bundle.js.map +1 -0
- package/dist/content-type.d.ts +72 -0
- package/dist/content-type.d.ts.map +1 -0
- package/dist/content-type.js +149 -0
- package/dist/content-type.js.map +1 -0
- package/dist/document-mutation.d.ts +83 -0
- package/dist/document-mutation.d.ts.map +1 -0
- package/dist/document-mutation.js +319 -0
- package/dist/document-mutation.js.map +1 -0
- package/dist/document-precondition.d.ts +62 -0
- package/dist/document-precondition.d.ts.map +1 -0
- package/dist/document-precondition.js +134 -0
- package/dist/document-precondition.js.map +1 -0
- package/dist/document-write-policy.d.ts +42 -0
- package/dist/document-write-policy.d.ts.map +1 -0
- package/dist/document-write-policy.js +134 -0
- package/dist/document-write-policy.js.map +1 -0
- package/dist/engine.d.ts +48 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +209 -0
- package/dist/engine.js.map +1 -0
- package/dist/errors.d.ts +36 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +50 -0
- package/dist/errors.js.map +1 -0
- package/dist/filesystem-identity.d.ts +208 -0
- package/dist/filesystem-identity.d.ts.map +1 -0
- package/dist/filesystem-identity.js +675 -0
- package/dist/filesystem-identity.js.map +1 -0
- package/dist/filesystem-lock.d.ts +65 -0
- package/dist/filesystem-lock.d.ts.map +1 -0
- package/dist/filesystem-lock.js +460 -0
- package/dist/filesystem-lock.js.map +1 -0
- package/dist/freshness.d.ts +31 -0
- package/dist/freshness.d.ts.map +1 -0
- package/dist/freshness.js +98 -0
- package/dist/freshness.js.map +1 -0
- package/dist/frontmatter-contract.d.ts +17 -0
- package/dist/frontmatter-contract.d.ts.map +1 -0
- package/dist/frontmatter-contract.js +29 -0
- package/dist/frontmatter-contract.js.map +1 -0
- package/dist/frontmatter.d.ts +30 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/frontmatter.js +115 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/index-marker.d.ts +3 -0
- package/dist/index-marker.d.ts.map +1 -0
- package/dist/index-marker.js +3 -0
- package/dist/index-marker.js.map +1 -0
- package/dist/index-projection.d.ts +79 -0
- package/dist/index-projection.d.ts.map +1 -0
- package/dist/index-projection.js +245 -0
- package/dist/index-projection.js.map +1 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +110 -0
- package/dist/index.js.map +1 -0
- package/dist/kinds-load.d.ts +13 -0
- package/dist/kinds-load.d.ts.map +1 -0
- package/dist/kinds-load.js +34 -0
- package/dist/kinds-load.js.map +1 -0
- package/dist/kinds.d.ts +241 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +1001 -0
- package/dist/kinds.js.map +1 -0
- package/dist/links.d.ts +62 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +203 -0
- package/dist/links.js.map +1 -0
- package/dist/meaningful-change-time.d.ts +11 -0
- package/dist/meaningful-change-time.d.ts.map +1 -0
- package/dist/meaningful-change-time.js +16 -0
- package/dist/meaningful-change-time.js.map +1 -0
- package/dist/memory-backend.d.ts +55 -0
- package/dist/memory-backend.d.ts.map +1 -0
- package/dist/memory-backend.js +214 -0
- package/dist/memory-backend.js.map +1 -0
- package/dist/mutation-attribution.d.ts +19 -0
- package/dist/mutation-attribution.d.ts.map +1 -0
- package/dist/mutation-attribution.js +34 -0
- package/dist/mutation-attribution.js.map +1 -0
- package/dist/mutation.d.ts +89 -0
- package/dist/mutation.d.ts.map +1 -0
- package/dist/mutation.js +94 -0
- package/dist/mutation.js.map +1 -0
- package/dist/page.d.ts +87 -0
- package/dist/page.d.ts.map +1 -0
- package/dist/page.js +151 -0
- package/dist/page.js.map +1 -0
- package/dist/paths.d.ts +78 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +148 -0
- package/dist/paths.js.map +1 -0
- package/dist/portable-frontmatter.d.ts +8 -0
- package/dist/portable-frontmatter.d.ts.map +1 -0
- package/dist/portable-frontmatter.js +35 -0
- package/dist/portable-frontmatter.js.map +1 -0
- package/dist/publication-filesystem.d.ts +6 -0
- package/dist/publication-filesystem.d.ts.map +1 -0
- package/dist/publication-filesystem.js +6 -0
- package/dist/publication-filesystem.js.map +1 -0
- package/dist/query-filter.d.ts +12 -0
- package/dist/query-filter.d.ts.map +1 -0
- package/dist/query-filter.js +29 -0
- package/dist/query-filter.js.map +1 -0
- package/dist/query-selection.d.ts +25 -0
- package/dist/query-selection.d.ts.map +1 -0
- package/dist/query-selection.js +48 -0
- package/dist/query-selection.js.map +1 -0
- package/dist/remote-backend.d.ts +152 -0
- package/dist/remote-backend.d.ts.map +1 -0
- package/dist/remote-backend.js +505 -0
- package/dist/remote-backend.js.map +1 -0
- package/dist/remote.d.ts +4 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +3 -0
- package/dist/remote.js.map +1 -0
- package/dist/storage.d.ts +7 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +6 -0
- package/dist/storage.js.map +1 -0
- package/dist/types.d.ts +438 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +22 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +12 -0
- package/dist/validation.js.map +1 -0
- package/dist/version-transport.d.ts +13 -0
- package/dist/version-transport.d.ts.map +1 -0
- package/dist/version-transport.js +26 -0
- package/dist/version-transport.js.map +1 -0
- package/dist/versioning.d.ts +48 -0
- package/dist/versioning.d.ts.map +1 -0
- package/dist/versioning.js +62 -0
- package/dist/versioning.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Freshness derivation from the document's edition-neutral meaningful-change clock.
|
|
3
|
+
*
|
|
4
|
+
* OKF v0.2's `stale_after` supplies an absolute date; v0.1 `timestamp` and v0.2
|
|
5
|
+
* `generated.at` supply the instant of the last meaningful change. The remaining
|
|
6
|
+
* staleness rules are consumer judgments layered on top:
|
|
7
|
+
* - `empty` — no usable meaningful-change time is present.
|
|
8
|
+
* - `stale` — a declared dependency was written more recently than this concept,
|
|
9
|
+
* OR the concept's age exceeds `maxAgeMs`.
|
|
10
|
+
* - `fresh` — otherwise.
|
|
11
|
+
* The v0.2 absolute date takes precedence, then dependency-newer, then the age rule.
|
|
12
|
+
*
|
|
13
|
+
* Pure and dependency-free, hence directly unit-testable.
|
|
14
|
+
*/
|
|
15
|
+
import { meaningfulChangeTimeValue } from "./meaningful-change-time.js";
|
|
16
|
+
/**
|
|
17
|
+
* Parse a timestamp to epoch ms, or `null`. Accepts an ISO-8601 (or any
|
|
18
|
+
* `Date.parse`-able) STRING — the normal case, since {@link parseMarkdown}
|
|
19
|
+
* normalizes frontmatter dates to strings — and, as belt-and-suspenders, a raw
|
|
20
|
+
* `Date` or epoch-millis `number` should one reach here unnormalized.
|
|
21
|
+
*/
|
|
22
|
+
export function parseTimestamp(ts) {
|
|
23
|
+
if (ts instanceof Date) {
|
|
24
|
+
const ms = ts.getTime();
|
|
25
|
+
return Number.isNaN(ms) ? null : ms;
|
|
26
|
+
}
|
|
27
|
+
if (typeof ts === "number") {
|
|
28
|
+
return Number.isFinite(ts) ? ts : null;
|
|
29
|
+
}
|
|
30
|
+
if (typeof ts !== "string" || ts.trim() === "")
|
|
31
|
+
return null;
|
|
32
|
+
const ms = Date.parse(ts);
|
|
33
|
+
return Number.isNaN(ms) ? null : ms;
|
|
34
|
+
}
|
|
35
|
+
/** Parse a strict ISO date without allowing Date.parse to normalize impossible calendar dates. */
|
|
36
|
+
function dateOnly(value) {
|
|
37
|
+
if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(value))
|
|
38
|
+
return null;
|
|
39
|
+
const parsed = new Date(`${value}T00:00:00Z`);
|
|
40
|
+
return !Number.isNaN(parsed.getTime()) && parsed.toISOString().slice(0, 10) === value
|
|
41
|
+
? value
|
|
42
|
+
: null;
|
|
43
|
+
}
|
|
44
|
+
/** The caller's local calendar day; OKF deliberately defines `today` without a UTC override. */
|
|
45
|
+
function localDateOnly(value) {
|
|
46
|
+
const year = String(value.getFullYear()).padStart(4, "0");
|
|
47
|
+
const month = String(value.getMonth() + 1).padStart(2, "0");
|
|
48
|
+
const day = String(value.getDate()).padStart(2, "0");
|
|
49
|
+
return `${year}-${month}-${day}`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Derive a freshness verdict from `generated.at`, falling back to legacy `timestamp`.
|
|
53
|
+
*
|
|
54
|
+
* @param doc the concept document (v0.2 `stale_after` and meaningful-change clocks are consulted).
|
|
55
|
+
* @param options bundle edition, `now` (defaults to the current instant), `maxAgeMs`, and
|
|
56
|
+
* the ISO timestamps of upstream `dependsOn` artifacts.
|
|
57
|
+
*/
|
|
58
|
+
export function freshness(doc, options = {}) {
|
|
59
|
+
const tsMs = parseTimestamp(meaningfulChangeTimeValue(doc.frontmatter));
|
|
60
|
+
const now = options.now ?? new Date();
|
|
61
|
+
const ageMs = tsMs === null ? undefined : now.getTime() - tsMs;
|
|
62
|
+
const staleAfter = options.okfVersion === "0.2"
|
|
63
|
+
? dateOnly(doc.frontmatter.stale_after)
|
|
64
|
+
: null;
|
|
65
|
+
if (staleAfter !== null && localDateOnly(now) >= staleAfter) {
|
|
66
|
+
return {
|
|
67
|
+
verdict: "stale",
|
|
68
|
+
...(ageMs === undefined ? {} : { ageMs }),
|
|
69
|
+
reason: `today is on or after stale_after ${staleAfter}`,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (tsMs === null) {
|
|
73
|
+
return { verdict: "empty", reason: "no usable meaningful-change time (`generated.at` or `timestamp`)" };
|
|
74
|
+
}
|
|
75
|
+
const meaningfulAgeMs = now.getTime() - tsMs;
|
|
76
|
+
// Dependency-based staleness wins: any dependency newer than this concept.
|
|
77
|
+
if (options.dependsOn && options.dependsOn.length > 0) {
|
|
78
|
+
for (const dep of options.dependsOn) {
|
|
79
|
+
const depMs = parseTimestamp(dep);
|
|
80
|
+
if (depMs !== null && depMs > tsMs) {
|
|
81
|
+
return {
|
|
82
|
+
verdict: "stale",
|
|
83
|
+
ageMs: meaningfulAgeMs,
|
|
84
|
+
reason: `a dependency (${dep}) is newer than this concept`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (typeof options.maxAgeMs === "number" && meaningfulAgeMs > options.maxAgeMs) {
|
|
90
|
+
return {
|
|
91
|
+
verdict: "stale",
|
|
92
|
+
ageMs: meaningfulAgeMs,
|
|
93
|
+
reason: `age ${meaningfulAgeMs}ms exceeds max ${options.maxAgeMs}ms`,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return { verdict: "fresh", ageMs: meaningfulAgeMs };
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=freshness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshness.js","sourceRoot":"","sources":["../src/freshness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,EAAW;IACxC,IAAI,EAAE,YAAY,IAAI,EAAE,CAAC;QACvB,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACtC,CAAC;IACD,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,MAAM,C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C;YACpC,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;gBACnC,OAAO;oBACL,OAAO,EAAE,OAAO;oBAChB,KAAK,EAAE,eAAe;oBACtB,MAAM,EAAE,iBAAiB,GAAG,8BAA8B;iBAC3D,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,eAAe,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/E,OAAO;YACL,OAAO,EAAE,OAAO;YAChB,KAAK,EAAE,eAAe;YACtB,MAAM,EAAE,OAAO,eAAe,kBAAkB,OAAO,CAAC,QAAQ,IAAI;SACrE,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Runtime-neutral error and predicates shared by storage adapters and the engine. */
|
|
2
|
+
/**
|
|
3
|
+
* A document whose YAML frontmatter could not be parsed. `context` identifies the document when
|
|
4
|
+
* known; `detail` is the first line of the parser error, and `cause` preserves the original error.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MalformedDocumentError extends Error {
|
|
7
|
+
readonly name = "MalformedDocumentError";
|
|
8
|
+
readonly context?: string;
|
|
9
|
+
readonly detail: string;
|
|
10
|
+
constructor(context: string | undefined, cause: unknown);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The engine's usable-document-timestamp predicate: a non-empty (post-trim) string. Anything else
|
|
14
|
+
* is unusable, and the edition-aware write path replaces it with the current time.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isUsableTimestamp(value: unknown): value is string;
|
|
17
|
+
//# sourceMappingURL=frontmatter-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-contract.d.ts","sourceRoot":"","sources":["../src/frontmatter-contract.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,SAAkB,IAAI,4BAA4B;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO;CAWxD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEjE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Runtime-neutral error and predicates shared by storage adapters and the engine. */
|
|
2
|
+
/**
|
|
3
|
+
* A document whose YAML frontmatter could not be parsed. `context` identifies the document when
|
|
4
|
+
* known; `detail` is the first line of the parser error, and `cause` preserves the original error.
|
|
5
|
+
*/
|
|
6
|
+
export class MalformedDocumentError extends Error {
|
|
7
|
+
name = "MalformedDocumentError";
|
|
8
|
+
context;
|
|
9
|
+
detail;
|
|
10
|
+
constructor(context, cause) {
|
|
11
|
+
const detail = ((cause instanceof Error ? cause.message : String(cause)).split("\n")[0] ?? "")
|
|
12
|
+
.trim();
|
|
13
|
+
super(`malformed frontmatter${context ? ` in '${context}'` : ""}: ${detail} — ` +
|
|
14
|
+
`fix the YAML or remove the file`);
|
|
15
|
+
if (context !== undefined)
|
|
16
|
+
this.context = context;
|
|
17
|
+
this.detail = detail;
|
|
18
|
+
if (cause !== undefined)
|
|
19
|
+
this.cause = cause;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The engine's usable-document-timestamp predicate: a non-empty (post-trim) string. Anything else
|
|
24
|
+
* is unusable, and the edition-aware write path replaces it with the current time.
|
|
25
|
+
*/
|
|
26
|
+
export function isUsableTimestamp(value) {
|
|
27
|
+
return typeof value === "string" && value.trim() !== "";
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=frontmatter-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-contract.js","sourceRoot":"","sources":["../src/frontmatter-contract.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC7B,IAAI,GAAG,wBAAwB,CAAC;IACzC,OAAO,CAAU;IACjB,MAAM,CAAS;IAExB,YAAY,OAA2B,EAAE,KAAc;QACrD,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aAC3F,IAAI,EAAE,CAAC;QACV,KAAK,CACH,wBAAwB,OAAO,CAAC,CAAC,CAAC,QAAQ,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,KAAK;YACvE,iCAAiC,CACpC,CAAC;QACF,IAAI,OAAO,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,KAAK,KAAK,SAAS;YAAG,IAA4B,CAAC,KAAK,GAAG,KAAK,CAAC;IACvE,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown + YAML frontmatter (de)serialization via `gray-matter`.
|
|
3
|
+
*
|
|
4
|
+
* This is the ONLY module that touches the YAML layer; every other module works
|
|
5
|
+
* with the already-parsed {@link Frontmatter}/body shapes. gray-matter delimits
|
|
6
|
+
* frontmatter with `---` lines (OKF §4.1) and preserves unknown keys on
|
|
7
|
+
* round-trip (OKF v0.1 §9 / v0.2 §11 permissive consumption).
|
|
8
|
+
*/
|
|
9
|
+
import type { Frontmatter } from "./types.js";
|
|
10
|
+
export { isUsableTimestamp, MalformedDocumentError } from "./frontmatter-contract.js";
|
|
11
|
+
/**
|
|
12
|
+
* Parse raw markdown into `{ frontmatter, body }`. Missing frontmatter yields `{}`. Malformed YAML
|
|
13
|
+
* throws an attributed {@link MalformedDocumentError} (naming `context` when given).
|
|
14
|
+
*
|
|
15
|
+
* Passing parser options bypasses gray-matter's input cache. Without options, gray-matter can cache
|
|
16
|
+
* a still-unparsed file before YAML parsing, causing a later parse of the same malformed bytes to
|
|
17
|
+
* return empty data instead of throwing again. The custom YAML engine also preserves timestamp-like
|
|
18
|
+
* scalars as strings so date-only values retain their original semantic shape.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseMarkdown(raw: string, context?: string): {
|
|
21
|
+
frontmatter: Frontmatter;
|
|
22
|
+
body: string;
|
|
23
|
+
};
|
|
24
|
+
/** Match the exact body shape emitted by the document serializer. */
|
|
25
|
+
export declare function normalizeDocumentBodyForStorage(body: string): string;
|
|
26
|
+
/** Serialize an arbitrary YAML-mapping + body to OKF markdown (used for reserved files). */
|
|
27
|
+
export declare function stringifyWithData(data: Record<string, unknown>, body: string): string;
|
|
28
|
+
/** Serialize a concept document's frontmatter + body to OKF-conformant markdown. */
|
|
29
|
+
export declare function stringifyDoc(frontmatter: Frontmatter, body: string): string;
|
|
30
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAmEtF;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,GACf;IAAE,WAAW,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAqB5C;AAED,qEAAqE;AACrE,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CASrF;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3E"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown + YAML frontmatter (de)serialization via `gray-matter`.
|
|
3
|
+
*
|
|
4
|
+
* This is the ONLY module that touches the YAML layer; every other module works
|
|
5
|
+
* with the already-parsed {@link Frontmatter}/body shapes. gray-matter delimits
|
|
6
|
+
* frontmatter with `---` lines (OKF §4.1) and preserves unknown keys on
|
|
7
|
+
* round-trip (OKF v0.1 §9 / v0.2 §11 permissive consumption).
|
|
8
|
+
*/
|
|
9
|
+
import matter from "gray-matter";
|
|
10
|
+
import yaml from "js-yaml";
|
|
11
|
+
import { isUsableTimestamp, MalformedDocumentError } from "./frontmatter-contract.js";
|
|
12
|
+
export { isUsableTimestamp, MalformedDocumentError } from "./frontmatter-contract.js";
|
|
13
|
+
const YAML_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp";
|
|
14
|
+
function requireYamlTimestampType() {
|
|
15
|
+
const type = yaml.DEFAULT_SAFE_SCHEMA.implicit.find((candidate) => candidate.tag === YAML_TIMESTAMP_TAG);
|
|
16
|
+
if (!type)
|
|
17
|
+
throw new Error("js-yaml safe schema is missing its timestamp type");
|
|
18
|
+
return type;
|
|
19
|
+
}
|
|
20
|
+
const yamlTimestampType = requireYamlTimestampType();
|
|
21
|
+
/**
|
|
22
|
+
* Keep YAML timestamps as their original strings. The default schema constructs both
|
|
23
|
+
* `2026-01-02` and `2026-01-02T00:00:00Z` as identical `Date` objects, irreversibly erasing the
|
|
24
|
+
* date-only distinction before unknown nested frontmatter can be preserved.
|
|
25
|
+
*/
|
|
26
|
+
const stringTimestampType = new yaml.Type(YAML_TIMESTAMP_TAG, {
|
|
27
|
+
kind: "scalar",
|
|
28
|
+
resolve: (value) => yamlTimestampType.resolve(value),
|
|
29
|
+
construct: (value) => value,
|
|
30
|
+
});
|
|
31
|
+
const losslessDateSchema = new yaml.Schema({
|
|
32
|
+
include: [yaml.DEFAULT_SAFE_SCHEMA],
|
|
33
|
+
implicit: [stringTimestampType],
|
|
34
|
+
});
|
|
35
|
+
const yamlEngine = {
|
|
36
|
+
parse(input) {
|
|
37
|
+
return (yaml.safeLoad(input, { schema: losslessDateSchema }) ?? {});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Normalize the legacy top-level `timestamp` field to an ISO-8601 string.
|
|
42
|
+
*
|
|
43
|
+
* gray-matter/js-yaml turns an UNQUOTED ISO timestamp scalar — the form OKF's own
|
|
44
|
+
* sample bundles use (`timestamp: 2026-07-01T12:05:00Z`) — into a non-string under its
|
|
45
|
+
* default schema. The parser above now retains all YAML timestamp scalars as strings so
|
|
46
|
+
* date-only values remain distinguishable at any depth. This legacy field still keeps its
|
|
47
|
+
* established canonical ISO behavior, including epoch-millisecond input.
|
|
48
|
+
*/
|
|
49
|
+
function normalizeFrontmatter(data) {
|
|
50
|
+
const out = { ...data };
|
|
51
|
+
const value = out.timestamp;
|
|
52
|
+
if (value instanceof Date) {
|
|
53
|
+
out.timestamp = value.toISOString();
|
|
54
|
+
}
|
|
55
|
+
else if (typeof value === "number" && Number.isFinite(value)) {
|
|
56
|
+
out.timestamp = new Date(value).toISOString();
|
|
57
|
+
}
|
|
58
|
+
else if (typeof value === "string" && yamlTimestampType.resolve(value)) {
|
|
59
|
+
const parsed = yamlTimestampType.construct(value);
|
|
60
|
+
if (parsed instanceof Date)
|
|
61
|
+
out.timestamp = parsed.toISOString();
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Parse raw markdown into `{ frontmatter, body }`. Missing frontmatter yields `{}`. Malformed YAML
|
|
67
|
+
* throws an attributed {@link MalformedDocumentError} (naming `context` when given).
|
|
68
|
+
*
|
|
69
|
+
* Passing parser options bypasses gray-matter's input cache. Without options, gray-matter can cache
|
|
70
|
+
* a still-unparsed file before YAML parsing, causing a later parse of the same malformed bytes to
|
|
71
|
+
* return empty data instead of throwing again. The custom YAML engine also preserves timestamp-like
|
|
72
|
+
* scalars as strings so date-only values retain their original semantic shape.
|
|
73
|
+
*/
|
|
74
|
+
export function parseMarkdown(raw, context) {
|
|
75
|
+
// An exact opening delimiter asserts that the document has YAML frontmatter. gray-matter accepts
|
|
76
|
+
// a missing closing delimiter when the remaining bytes happen to be valid YAML (Markdown heading
|
|
77
|
+
// lines are YAML comments), then returns an empty body. That is lossy ambiguity, not a successful
|
|
78
|
+
// parse: every caller must see the same attributed malformed-document result before it can read,
|
|
79
|
+
// export, or rewrite a body that silently disappeared.
|
|
80
|
+
if (/^---(?:\r?\n|$)/.test(raw)) {
|
|
81
|
+
const firstLineEnd = raw.indexOf("\n");
|
|
82
|
+
const afterOpening = firstLineEnd === -1 ? "" : raw.slice(firstLineEnd + 1);
|
|
83
|
+
if (!/^---\r?$/m.test(afterOpening)) {
|
|
84
|
+
throw new MalformedDocumentError(context, new Error("unterminated YAML frontmatter delimiter"));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
let parsed;
|
|
88
|
+
try {
|
|
89
|
+
parsed = matter(raw, { engines: { yaml: yamlEngine } });
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
throw new MalformedDocumentError(context, err);
|
|
93
|
+
}
|
|
94
|
+
const frontmatter = normalizeFrontmatter((parsed.data ?? {}));
|
|
95
|
+
return { frontmatter, body: parsed.content };
|
|
96
|
+
}
|
|
97
|
+
/** Match the exact body shape emitted by the document serializer. */
|
|
98
|
+
export function normalizeDocumentBodyForStorage(body) {
|
|
99
|
+
return body.endsWith("\n") ? body : `${body}\n`;
|
|
100
|
+
}
|
|
101
|
+
/** Serialize an arbitrary YAML-mapping + body to OKF markdown (used for reserved files). */
|
|
102
|
+
export function stringifyWithData(data, body) {
|
|
103
|
+
const engines = matter.engines;
|
|
104
|
+
const yaml = engines.yaml.stringify(data).trim();
|
|
105
|
+
const content = body ?? "";
|
|
106
|
+
const newline = (value) => (value.endsWith("\n") ? value : `${value}\n`);
|
|
107
|
+
if (yaml === "{}")
|
|
108
|
+
return normalizeDocumentBodyForStorage(content);
|
|
109
|
+
return `---\n${newline(yaml)}---\n${normalizeDocumentBodyForStorage(content)}`;
|
|
110
|
+
}
|
|
111
|
+
/** Serialize a concept document's frontmatter + body to OKF-conformant markdown. */
|
|
112
|
+
export function stringifyDoc(frontmatter, body) {
|
|
113
|
+
return stringifyWithData(frontmatter, body);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAGtF,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEtF,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AAUzD,SAAS,wBAAwB;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"file":"index-marker.d.ts","sourceRoot":"","sources":["../src/index-marker.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,eAAO,MAAM,sBAAsB,gDAAgD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-marker.js","sourceRoot":"","sources":["../src/index-marker.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,CAAC,MAAM,sBAAsB,GAAG,6CAA6C,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable `index.md` projection policy.
|
|
3
|
+
*
|
|
4
|
+
* Concept heads are authoritative. Index files are deterministic, replaceable views over
|
|
5
|
+
* one observed head set. Planning is pure; preparation reads and classifies EVERY target
|
|
6
|
+
* before a write; application uses those exact versions with single-shot CAS. A conflict
|
|
7
|
+
* stops the batch instead of silently re-deciding one file outside the global preflight.
|
|
8
|
+
*/
|
|
9
|
+
import type { Bundle, HeadResult, Version } from "./types.js";
|
|
10
|
+
export { GENERATED_INDEX_MARKER } from "./index-marker.js";
|
|
11
|
+
/** One directory's deterministic, frontmatter-free body. `dir === ""` is the bundle root. */
|
|
12
|
+
export interface PlannedIndex {
|
|
13
|
+
dir: string;
|
|
14
|
+
body: string;
|
|
15
|
+
}
|
|
16
|
+
/** A complete recursive projection over one observed set of concept heads. */
|
|
17
|
+
export interface IndexProjectionPlan {
|
|
18
|
+
targets: PlannedIndex[];
|
|
19
|
+
}
|
|
20
|
+
export type IndexProjectionDisposition = "missing" | "generated" | "unchanged" | "adopted" | "refused";
|
|
21
|
+
/** One target after reading its current bytes and classifying ownership. */
|
|
22
|
+
export interface PreparedIndexTarget {
|
|
23
|
+
dir: string;
|
|
24
|
+
content: string;
|
|
25
|
+
expectedVersion: Version | null;
|
|
26
|
+
disposition: IndexProjectionDisposition;
|
|
27
|
+
reason?: "unmarked" | "malformed-marker" | "duplicate-marker" | "nested-frontmatter" | "malformed-root";
|
|
28
|
+
}
|
|
29
|
+
export interface ReadyIndexProjection {
|
|
30
|
+
ready: true;
|
|
31
|
+
targets: PreparedIndexTarget[];
|
|
32
|
+
refused: [];
|
|
33
|
+
}
|
|
34
|
+
export interface RefusedIndexProjection {
|
|
35
|
+
ready: false;
|
|
36
|
+
targets: PreparedIndexTarget[];
|
|
37
|
+
refused: PreparedIndexTarget[];
|
|
38
|
+
}
|
|
39
|
+
/** Preparation is the dry-run/check result the future CLI can project directly. */
|
|
40
|
+
export type IndexProjectionPreparation = ReadyIndexProjection | RefusedIndexProjection;
|
|
41
|
+
export interface AppliedIndexTarget {
|
|
42
|
+
dir: string;
|
|
43
|
+
disposition: Exclude<IndexProjectionDisposition, "unchanged" | "refused">;
|
|
44
|
+
version: Version;
|
|
45
|
+
}
|
|
46
|
+
export interface IndexProjectionApplyResult {
|
|
47
|
+
completed: AppliedIndexTarget[];
|
|
48
|
+
unchanged: string[];
|
|
49
|
+
pending: [];
|
|
50
|
+
}
|
|
51
|
+
/** A terminal per-file failure after zero or more earlier targets completed. */
|
|
52
|
+
export declare class IndexProjectionWriteError extends Error {
|
|
53
|
+
readonly name = "IndexProjectionWriteError";
|
|
54
|
+
readonly failed: string;
|
|
55
|
+
readonly completed: AppliedIndexTarget[];
|
|
56
|
+
readonly pending: string[];
|
|
57
|
+
constructor(failed: string, completed: AppliedIndexTarget[], pending: string[], cause: unknown);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Plan root + every ancestor directory from ONE complete `queryHeads`-shaped set.
|
|
61
|
+
* The caller supplies the root display name; core never derives it from a local path or URL.
|
|
62
|
+
*/
|
|
63
|
+
export declare function planIndexProjection(displayName: string, heads: readonly HeadResult[]): IndexProjectionPlan;
|
|
64
|
+
/**
|
|
65
|
+
* Read and classify every planned target before any write. A single refusal blocks the
|
|
66
|
+
* whole preparation; `force` makes each unmarked/malformed target an explicit adoption.
|
|
67
|
+
*/
|
|
68
|
+
export declare function prepareIndexProjection(bundle: Bundle, plan: IndexProjectionPlan, options?: {
|
|
69
|
+
force?: boolean;
|
|
70
|
+
}): Promise<IndexProjectionPreparation>;
|
|
71
|
+
/**
|
|
72
|
+
* Apply a ready preparation deepest-first and root-last. Each target gets ONE CAS attempt
|
|
73
|
+
* against the version captured during global preparation; a conflict is terminal and reports
|
|
74
|
+
* completed/pending paths so a full re-prepare can resume idempotently.
|
|
75
|
+
*/
|
|
76
|
+
export declare function applyIndexProjection(bundle: Bundle, prepared: ReadyIndexProjection, options?: {
|
|
77
|
+
actor?: string;
|
|
78
|
+
}): Promise<IndexProjectionApplyResult>;
|
|
79
|
+
//# sourceMappingURL=index-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-projection.d.ts","sourceRoot":"","sources":["../src/index-projection.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,6FAA6F;AAC7F,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,8EAA8E;AAC9E,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;AAEvG,4EAA4E;AAC5E,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,WAAW,EAAE,0BAA0B,CAAC;IACxC,MAAM,CAAC,EAAE,UAAU,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,oBAAoB,GAAG,gBAAgB,CAAC;CACzG;AAED,MAAM,WAAW,oBAAoB;IACnC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