superbee 0.1.5 → 0.1.6
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/README.md +1 -1
- package/dist/bundle-descriptor/generated/bundle-descriptor-v1.d.ts +30 -0
- package/dist/bundle-descriptor/index.d.ts +3 -0
- package/dist/bundle-descriptor/schema/bundle-descriptor-v1.schema.json +42 -0
- package/dist/bundle-descriptor/schema.d.ts +5 -0
- package/dist/bundle-descriptor.mjs +58 -0
- package/dist/publication-bridge.mjs +198 -105
- package/dist/publication.mjs +198 -105
- package/dist/superbee.mjs +1178 -585
- package/package.json +7 -2
package/dist/publication.mjs
CHANGED
|
@@ -3136,8 +3136,8 @@ var require_js_yaml = __commonJS({
|
|
|
3136
3136
|
var require_js_yaml2 = __commonJS({
|
|
3137
3137
|
"../../node_modules/js-yaml/index.js"(exports2, module2) {
|
|
3138
3138
|
"use strict";
|
|
3139
|
-
var
|
|
3140
|
-
module2.exports =
|
|
3139
|
+
var yaml4 = require_js_yaml();
|
|
3140
|
+
module2.exports = yaml4;
|
|
3141
3141
|
}
|
|
3142
3142
|
});
|
|
3143
3143
|
|
|
@@ -31491,6 +31491,53 @@ import path3 from "node:path";
|
|
|
31491
31491
|
// ../core/src/frontmatter.ts
|
|
31492
31492
|
var import_gray_matter = __toESM(require_gray_matter(), 1);
|
|
31493
31493
|
var import_js_yaml = __toESM(require_js_yaml2(), 1);
|
|
31494
|
+
|
|
31495
|
+
// ../core/src/frontmatter-contract.ts
|
|
31496
|
+
var MalformedDocumentError = class extends Error {
|
|
31497
|
+
name = "MalformedDocumentError";
|
|
31498
|
+
context;
|
|
31499
|
+
detail;
|
|
31500
|
+
constructor(context, cause) {
|
|
31501
|
+
const detail = ((cause instanceof Error ? cause.message : String(cause)).split("\n")[0] ?? "").trim();
|
|
31502
|
+
super(
|
|
31503
|
+
`malformed frontmatter${context ? ` in '${context}'` : ""}: ${detail} \u2014 fix the YAML or remove the file`
|
|
31504
|
+
);
|
|
31505
|
+
if (context !== void 0) this.context = context;
|
|
31506
|
+
this.detail = detail;
|
|
31507
|
+
if (cause !== void 0) this.cause = cause;
|
|
31508
|
+
}
|
|
31509
|
+
};
|
|
31510
|
+
|
|
31511
|
+
// ../core/src/frontmatter-splitter.ts
|
|
31512
|
+
function delimiterLineEnd(input, offset) {
|
|
31513
|
+
if (!input.startsWith("---", offset)) return null;
|
|
31514
|
+
const suffix = offset + 3;
|
|
31515
|
+
if (suffix === input.length) return suffix;
|
|
31516
|
+
if (input[suffix] === "\n") return suffix + 1;
|
|
31517
|
+
if (input[suffix] === "\r" && input[suffix + 1] === "\n") return suffix + 2;
|
|
31518
|
+
return null;
|
|
31519
|
+
}
|
|
31520
|
+
function splitLeadingFrontmatter(raw, context) {
|
|
31521
|
+
const input = raw.startsWith("\uFEFF") ? raw.slice(1) : raw;
|
|
31522
|
+
const openingEnd = delimiterLineEnd(input, 0);
|
|
31523
|
+
if (openingEnd === null) return { body: input };
|
|
31524
|
+
let lineStart = openingEnd;
|
|
31525
|
+
while (lineStart < input.length) {
|
|
31526
|
+
const closingEnd = delimiterLineEnd(input, lineStart);
|
|
31527
|
+
if (closingEnd !== null) {
|
|
31528
|
+
return {
|
|
31529
|
+
yamlSource: input.slice(openingEnd, lineStart),
|
|
31530
|
+
body: input.slice(closingEnd)
|
|
31531
|
+
};
|
|
31532
|
+
}
|
|
31533
|
+
const nextLineFeed = input.indexOf("\n", lineStart);
|
|
31534
|
+
if (nextLineFeed === -1) break;
|
|
31535
|
+
lineStart = nextLineFeed + 1;
|
|
31536
|
+
}
|
|
31537
|
+
throw new MalformedDocumentError(context, new Error("unterminated YAML frontmatter delimiter"));
|
|
31538
|
+
}
|
|
31539
|
+
|
|
31540
|
+
// ../core/src/frontmatter.ts
|
|
31494
31541
|
var YAML_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp";
|
|
31495
31542
|
function requireYamlTimestampType() {
|
|
31496
31543
|
const type = import_js_yaml.default.DEFAULT_SAFE_SCHEMA.implicit.find(
|
|
@@ -31527,38 +31574,17 @@ function normalizeFrontmatter(data) {
|
|
|
31527
31574
|
}
|
|
31528
31575
|
return out;
|
|
31529
31576
|
}
|
|
31530
|
-
var MalformedDocumentError = class extends Error {
|
|
31531
|
-
name = "MalformedDocumentError";
|
|
31532
|
-
/** The document id/path the malformed content belongs to (when the caller supplied one). */
|
|
31533
|
-
context;
|
|
31534
|
-
/** The underlying parser message, first line only — for compact per-doc reporting. */
|
|
31535
|
-
detail;
|
|
31536
|
-
constructor(context, cause) {
|
|
31537
|
-
const detail = ((cause instanceof Error ? cause.message : String(cause)).split("\n")[0] ?? "").trim();
|
|
31538
|
-
super(
|
|
31539
|
-
`malformed frontmatter${context ? ` in '${context}'` : ""}: ${detail} \u2014 fix the YAML or remove the file`
|
|
31540
|
-
);
|
|
31541
|
-
if (context !== void 0) this.context = context;
|
|
31542
|
-
this.detail = detail;
|
|
31543
|
-
if (cause !== void 0) this.cause = cause;
|
|
31544
|
-
}
|
|
31545
|
-
};
|
|
31546
31577
|
function parseMarkdown(raw, context) {
|
|
31547
|
-
|
|
31548
|
-
|
|
31549
|
-
const afterOpening = firstLineEnd === -1 ? "" : raw.slice(firstLineEnd + 1);
|
|
31550
|
-
if (!/^---\r?$/m.test(afterOpening)) {
|
|
31551
|
-
throw new MalformedDocumentError(context, new Error("unterminated YAML frontmatter delimiter"));
|
|
31552
|
-
}
|
|
31553
|
-
}
|
|
31578
|
+
const split = splitLeadingFrontmatter(raw, context);
|
|
31579
|
+
if (!("yamlSource" in split)) return { frontmatter: {}, body: split.body };
|
|
31554
31580
|
let parsed;
|
|
31555
31581
|
try {
|
|
31556
|
-
parsed = (
|
|
31582
|
+
parsed = yamlEngine.parse(split.yamlSource);
|
|
31557
31583
|
} catch (err) {
|
|
31558
31584
|
throw new MalformedDocumentError(context, err);
|
|
31559
31585
|
}
|
|
31560
|
-
const frontmatter2 = normalizeFrontmatter(parsed
|
|
31561
|
-
return { frontmatter: frontmatter2, body:
|
|
31586
|
+
const frontmatter2 = normalizeFrontmatter(parsed);
|
|
31587
|
+
return { frontmatter: frontmatter2, body: split.body };
|
|
31562
31588
|
}
|
|
31563
31589
|
function normalizeDocumentBodyForStorage(body) {
|
|
31564
31590
|
return body.endsWith("\n") ? body : `${body}
|
|
@@ -31566,13 +31592,13 @@ function normalizeDocumentBodyForStorage(body) {
|
|
|
31566
31592
|
}
|
|
31567
31593
|
function stringifyWithData(data, body) {
|
|
31568
31594
|
const engines2 = import_gray_matter.default.engines;
|
|
31569
|
-
const
|
|
31595
|
+
const yaml4 = engines2.yaml.stringify(data).trim();
|
|
31570
31596
|
const content3 = body ?? "";
|
|
31571
31597
|
const newline = (value) => value.endsWith("\n") ? value : `${value}
|
|
31572
31598
|
`;
|
|
31573
|
-
if (
|
|
31599
|
+
if (yaml4 === "{}") return normalizeDocumentBodyForStorage(content3);
|
|
31574
31600
|
return `---
|
|
31575
|
-
${newline(
|
|
31601
|
+
${newline(yaml4)}---
|
|
31576
31602
|
${normalizeDocumentBodyForStorage(content3)}`;
|
|
31577
31603
|
}
|
|
31578
31604
|
function stringifyDoc(frontmatter2, body) {
|
|
@@ -32478,25 +32504,12 @@ function mutationActorFromFrontmatter(frontmatter2) {
|
|
|
32478
32504
|
|
|
32479
32505
|
// ../core/src/versioning.ts
|
|
32480
32506
|
import { createHash as createHash3 } from "node:crypto";
|
|
32481
|
-
|
|
32482
|
-
|
|
32483
|
-
}
|
|
32484
|
-
function versionOfBytes(raw) {
|
|
32485
|
-
return `sha256:${sha256Hex(raw)}`;
|
|
32486
|
-
}
|
|
32487
|
-
function blobVersion(bytes) {
|
|
32488
|
-
return `sha256:${createHash3("sha256").update(bytes).digest("hex")}`;
|
|
32489
|
-
}
|
|
32490
|
-
function defaultActor() {
|
|
32491
|
-
return process.env.USER?.trim() || process.env.USERNAME?.trim() || process.env.LOGNAME?.trim() || "local";
|
|
32492
|
-
}
|
|
32507
|
+
|
|
32508
|
+
// ../core/src/version-transport.ts
|
|
32493
32509
|
var VersionConflict = class extends Error {
|
|
32494
32510
|
name = "VersionConflict";
|
|
32495
|
-
/** The concept id whose write was rejected. */
|
|
32496
32511
|
id;
|
|
32497
|
-
/** The version the caller expected the backend to currently hold (`null` = expected absent). */
|
|
32498
32512
|
expected;
|
|
32499
|
-
/** The version the backend actually holds (`null` if the document does not exist). */
|
|
32500
32513
|
actual;
|
|
32501
32514
|
constructor(id, expected, actual) {
|
|
32502
32515
|
super(
|
|
@@ -32508,6 +32521,20 @@ var VersionConflict = class extends Error {
|
|
|
32508
32521
|
}
|
|
32509
32522
|
};
|
|
32510
32523
|
|
|
32524
|
+
// ../core/src/versioning.ts
|
|
32525
|
+
function sha256Hex(input) {
|
|
32526
|
+
return createHash3("sha256").update(input, "utf8").digest("hex");
|
|
32527
|
+
}
|
|
32528
|
+
function versionOfBytes(raw) {
|
|
32529
|
+
return `sha256:${sha256Hex(raw)}`;
|
|
32530
|
+
}
|
|
32531
|
+
function blobVersion(bytes) {
|
|
32532
|
+
return `sha256:${createHash3("sha256").update(bytes).digest("hex")}`;
|
|
32533
|
+
}
|
|
32534
|
+
function defaultActor() {
|
|
32535
|
+
return process.env.USER?.trim() || process.env.USERNAME?.trim() || process.env.LOGNAME?.trim() || "local";
|
|
32536
|
+
}
|
|
32537
|
+
|
|
32511
32538
|
// ../core/src/backend.ts
|
|
32512
32539
|
var publicationRoots = /* @__PURE__ */ new WeakMap();
|
|
32513
32540
|
function firstString(...vals) {
|
|
@@ -32781,16 +32808,51 @@ function normalizeSegments(segments) {
|
|
|
32781
32808
|
function joinPosix(base, rel) {
|
|
32782
32809
|
return normalizeSegments([...base.split("/"), ...rel.split("/")]).join("/");
|
|
32783
32810
|
}
|
|
32784
|
-
var MD_LINK_RE = /\[([^\]]*)\]\(([^)\s]+)\)/g;
|
|
32785
32811
|
function isExternalHref(href) {
|
|
32786
32812
|
const h = href.trim();
|
|
32787
32813
|
return /^[a-z][a-z0-9+.-]*:\/\//i.test(h) || h.startsWith("mailto:") || h.startsWith("#");
|
|
32788
32814
|
}
|
|
32789
32815
|
function extractMarkdownLinks(body) {
|
|
32790
32816
|
const out = [];
|
|
32791
|
-
|
|
32792
|
-
|
|
32793
|
-
|
|
32817
|
+
let textOpen = -1;
|
|
32818
|
+
let afterClose;
|
|
32819
|
+
let hrefFirst;
|
|
32820
|
+
let hrefRest;
|
|
32821
|
+
for (let cursor = 0; cursor < body.length; cursor++) {
|
|
32822
|
+
const char = body[cursor];
|
|
32823
|
+
if (hrefRest) {
|
|
32824
|
+
if (char === ")") {
|
|
32825
|
+
if (hrefRest.open === 0 || body[hrefRest.open - 1] !== "!") {
|
|
32826
|
+
out.push({
|
|
32827
|
+
text: body.slice(hrefRest.open + 1, hrefRest.close),
|
|
32828
|
+
href: body.slice(hrefRest.hrefStart, cursor)
|
|
32829
|
+
});
|
|
32830
|
+
}
|
|
32831
|
+
textOpen = -1;
|
|
32832
|
+
afterClose = void 0;
|
|
32833
|
+
hrefFirst = void 0;
|
|
32834
|
+
hrefRest = void 0;
|
|
32835
|
+
continue;
|
|
32836
|
+
}
|
|
32837
|
+
if (char.trim() === "") hrefRest = void 0;
|
|
32838
|
+
}
|
|
32839
|
+
if (hrefFirst) {
|
|
32840
|
+
if (char !== ")" && char.trim() !== "" && !hrefRest) {
|
|
32841
|
+
hrefRest = hrefFirst;
|
|
32842
|
+
}
|
|
32843
|
+
hrefFirst = void 0;
|
|
32844
|
+
}
|
|
32845
|
+
if (afterClose) {
|
|
32846
|
+
if (char === "(") {
|
|
32847
|
+
hrefFirst = { ...afterClose, hrefStart: cursor + 1 };
|
|
32848
|
+
}
|
|
32849
|
+
afterClose = void 0;
|
|
32850
|
+
}
|
|
32851
|
+
if (textOpen >= 0 && char === "]") {
|
|
32852
|
+
afterClose = { open: textOpen, close: cursor };
|
|
32853
|
+
textOpen = -1;
|
|
32854
|
+
}
|
|
32855
|
+
if (char === "[" && textOpen < 0) textOpen = cursor;
|
|
32794
32856
|
}
|
|
32795
32857
|
return out;
|
|
32796
32858
|
}
|
|
@@ -32827,6 +32889,24 @@ function parseLinksFromDoc(doc) {
|
|
|
32827
32889
|
return links;
|
|
32828
32890
|
}
|
|
32829
32891
|
|
|
32892
|
+
// ../core/src/portable-frontmatter.ts
|
|
32893
|
+
var import_js_yaml2 = __toESM(require_js_yaml2(), 1);
|
|
32894
|
+
function parseLeadingFrontmatter(raw, context) {
|
|
32895
|
+
const split = splitLeadingFrontmatter(raw, context);
|
|
32896
|
+
if (!("yamlSource" in split)) return {};
|
|
32897
|
+
try {
|
|
32898
|
+
const parsed = import_js_yaml2.default.safeLoad(split.yamlSource);
|
|
32899
|
+
if (parsed === void 0 || parsed === null) return {};
|
|
32900
|
+
if (typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
32901
|
+
throw new TypeError("YAML frontmatter must be a mapping");
|
|
32902
|
+
}
|
|
32903
|
+
return parsed;
|
|
32904
|
+
} catch (error) {
|
|
32905
|
+
if (error instanceof MalformedDocumentError) throw error;
|
|
32906
|
+
throw new MalformedDocumentError(context, error);
|
|
32907
|
+
}
|
|
32908
|
+
}
|
|
32909
|
+
|
|
32830
32910
|
// ../core/src/query-filter.ts
|
|
32831
32911
|
function matchesFilter(doc, filter) {
|
|
32832
32912
|
if (filter.prefix && !doc.id.startsWith(filter.prefix)) return false;
|
|
@@ -32846,25 +32926,27 @@ function matchesFilter(doc, filter) {
|
|
|
32846
32926
|
return true;
|
|
32847
32927
|
}
|
|
32848
32928
|
|
|
32849
|
-
// ../core/src/
|
|
32850
|
-
function
|
|
32851
|
-
|
|
32852
|
-
}
|
|
32853
|
-
async function readBundleOkfVersion(bundle) {
|
|
32854
|
-
const index2 = await backendFor(bundle).readReserved("", "index.md");
|
|
32929
|
+
// ../core/src/engine.ts
|
|
32930
|
+
async function readBundleOkfVersion(backend) {
|
|
32931
|
+
const index2 = await backend.readReserved("", "index.md");
|
|
32855
32932
|
if (!index2) return void 0;
|
|
32856
|
-
const value =
|
|
32933
|
+
const value = parseLeadingFrontmatter(index2.content, "index.md").okf_version;
|
|
32857
32934
|
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
32858
32935
|
}
|
|
32859
|
-
|
|
32936
|
+
function assertReadableConceptId(id) {
|
|
32860
32937
|
assertSafeConceptId(id);
|
|
32861
32938
|
const rel = pathFromConceptId(id);
|
|
32862
32939
|
if (isReservedFile(rel)) {
|
|
32863
32940
|
throw new InvalidInputError(`'${id}' is a reserved file (index.md / log.md), not a concept document.`);
|
|
32864
32941
|
}
|
|
32865
|
-
return backendFor(bundle).read(id);
|
|
32866
32942
|
}
|
|
32867
|
-
|
|
32943
|
+
async function readDocVersioned(backend, id) {
|
|
32944
|
+
assertReadableConceptId(id);
|
|
32945
|
+
return backend.read(id);
|
|
32946
|
+
}
|
|
32947
|
+
function isEnoent(err) {
|
|
32948
|
+
return typeof err === "object" && err !== null && err.code === "ENOENT";
|
|
32949
|
+
}
|
|
32868
32950
|
async function readManyExisting(backend, ids, onMalformed) {
|
|
32869
32951
|
try {
|
|
32870
32952
|
return await backend.readMany(ids);
|
|
@@ -32875,13 +32957,13 @@ async function readManyExisting(backend, ids, onMalformed) {
|
|
|
32875
32957
|
for (const id of ids) {
|
|
32876
32958
|
try {
|
|
32877
32959
|
out.push(await backend.read(id));
|
|
32878
|
-
} catch (
|
|
32879
|
-
if (isEnoent(
|
|
32880
|
-
if (
|
|
32881
|
-
onMalformed({ id, reason:
|
|
32960
|
+
} catch (candidate) {
|
|
32961
|
+
if (isEnoent(candidate)) continue;
|
|
32962
|
+
if (candidate instanceof MalformedDocumentError && onMalformed) {
|
|
32963
|
+
onMalformed({ id, reason: candidate.detail });
|
|
32882
32964
|
continue;
|
|
32883
32965
|
}
|
|
32884
|
-
throw
|
|
32966
|
+
throw candidate;
|
|
32885
32967
|
}
|
|
32886
32968
|
}
|
|
32887
32969
|
return out;
|
|
@@ -32891,25 +32973,25 @@ async function scanMatching(backend, filter, onSkip) {
|
|
|
32891
32973
|
const ids = await backend.list(filter.prefix);
|
|
32892
32974
|
const results = [];
|
|
32893
32975
|
for (const result of await readManyExisting(backend, ids, onSkip)) {
|
|
32894
|
-
if (
|
|
32895
|
-
results.push(result);
|
|
32976
|
+
if (matchesFilter(result.doc, filter)) results.push(result);
|
|
32896
32977
|
}
|
|
32897
32978
|
results.sort((a, b) => a.doc.id.localeCompare(b.doc.id));
|
|
32898
32979
|
return results;
|
|
32899
32980
|
}
|
|
32900
|
-
async function query(
|
|
32901
|
-
|
|
32902
|
-
return scanned.map((r) => r.doc);
|
|
32981
|
+
async function query(backend, filter = {}, options2 = {}) {
|
|
32982
|
+
return (await scanMatching(backend, filter, options2.onSkip)).map((result) => result.doc);
|
|
32903
32983
|
}
|
|
32904
|
-
async function queryHeads(
|
|
32905
|
-
const backend = backendFor(bundle);
|
|
32984
|
+
async function queryHeads(backend, filter = {}, options2 = {}) {
|
|
32906
32985
|
if (backend.queryHeads) {
|
|
32907
|
-
const rows = (await backend.queryHeads(filter)).filter((
|
|
32986
|
+
const rows = (await backend.queryHeads(filter)).filter((row) => matchesFilter(row, filter));
|
|
32908
32987
|
rows.sort((a, b) => a.id.localeCompare(b.id));
|
|
32909
32988
|
return rows;
|
|
32910
32989
|
}
|
|
32911
|
-
|
|
32912
|
-
|
|
32990
|
+
return (await scanMatching(backend, filter, options2.onSkip)).map(({ doc, version }) => ({
|
|
32991
|
+
id: doc.id,
|
|
32992
|
+
frontmatter: doc.frontmatter,
|
|
32993
|
+
version
|
|
32994
|
+
}));
|
|
32913
32995
|
}
|
|
32914
32996
|
function normalizeEdgeSelector(raw) {
|
|
32915
32997
|
if (raw.endsWith("/")) {
|
|
@@ -32922,25 +33004,19 @@ function normalizeEdgeSelector(raw) {
|
|
|
32922
33004
|
}
|
|
32923
33005
|
function matchesEdgeSelector(value, selectors) {
|
|
32924
33006
|
if (selectors === void 0) return true;
|
|
32925
|
-
|
|
32926
|
-
|
|
32927
|
-
|
|
32928
|
-
} else if (value === normalized) {
|
|
32929
|
-
return true;
|
|
32930
|
-
}
|
|
32931
|
-
}
|
|
32932
|
-
return false;
|
|
33007
|
+
return selectors.some(
|
|
33008
|
+
(selector2) => selector2.endsWith("/") ? value.startsWith(selector2) : value === selector2
|
|
33009
|
+
);
|
|
32933
33010
|
}
|
|
32934
|
-
function toSelectorList(
|
|
32935
|
-
if (
|
|
32936
|
-
return Array.isArray(
|
|
33011
|
+
function toSelectorList(value) {
|
|
33012
|
+
if (value === void 0) return void 0;
|
|
33013
|
+
return Array.isArray(value) ? value : [value];
|
|
32937
33014
|
}
|
|
32938
|
-
async function queryEdges(
|
|
33015
|
+
async function queryEdges(backend, filter = {}) {
|
|
32939
33016
|
const fromSelectors = toSelectorList(filter.from)?.map(normalizeEdgeSelector);
|
|
32940
33017
|
const toSelectors = toSelectorList(filter.to)?.map(normalizeEdgeSelector);
|
|
32941
|
-
const docs = await query(bundle);
|
|
32942
33018
|
const edges = [];
|
|
32943
|
-
for (const doc of
|
|
33019
|
+
for (const doc of await query(backend)) {
|
|
32944
33020
|
for (const link of parseLinksFromDoc(doc)) {
|
|
32945
33021
|
if (!matchesEdgeSelector(link.from, fromSelectors)) continue;
|
|
32946
33022
|
if (!matchesEdgeSelector(link.to, toSelectors)) continue;
|
|
@@ -32952,6 +33028,26 @@ async function queryEdges(bundle, filter = {}) {
|
|
|
32952
33028
|
return edges;
|
|
32953
33029
|
}
|
|
32954
33030
|
|
|
33031
|
+
// ../core/src/bundle.ts
|
|
33032
|
+
function backendFor(bundle) {
|
|
33033
|
+
return bundle.backend ?? new FilesystemBackend(bundle.root);
|
|
33034
|
+
}
|
|
33035
|
+
async function readBundleOkfVersion2(bundle) {
|
|
33036
|
+
return readBundleOkfVersion(backendFor(bundle));
|
|
33037
|
+
}
|
|
33038
|
+
async function readDocVersioned2(bundle, id) {
|
|
33039
|
+
return readDocVersioned(backendFor(bundle), id);
|
|
33040
|
+
}
|
|
33041
|
+
async function query2(bundle, filter = {}, options2 = {}) {
|
|
33042
|
+
return query(backendFor(bundle), filter, options2);
|
|
33043
|
+
}
|
|
33044
|
+
async function queryHeads2(bundle, filter = {}, options2 = {}) {
|
|
33045
|
+
return queryHeads(backendFor(bundle), filter, options2);
|
|
33046
|
+
}
|
|
33047
|
+
async function queryEdges2(bundle, filter = {}) {
|
|
33048
|
+
return queryEdges(backendFor(bundle), filter);
|
|
33049
|
+
}
|
|
33050
|
+
|
|
32955
33051
|
// ../core/src/kinds.ts
|
|
32956
33052
|
var CONVENTIONS_PREFIX = "conventions/";
|
|
32957
33053
|
var CONVENTION_TYPE = "Convention";
|
|
@@ -33544,7 +33640,7 @@ function applyQuerySelectionFilters(rows, params, kinds = []) {
|
|
|
33544
33640
|
// ../core/src/kinds-load.ts
|
|
33545
33641
|
async function loadKinds(bundle) {
|
|
33546
33642
|
const warnings = [];
|
|
33547
|
-
const docs = await
|
|
33643
|
+
const docs = await query2(bundle, { prefix: CONVENTIONS_PREFIX, type: CONVENTION_TYPE }, {
|
|
33548
33644
|
onSkip: ({ id, reason }) => warnings.push({
|
|
33549
33645
|
code: "KIND_CONVENTION_MALFORMED",
|
|
33550
33646
|
message: `skipped kind convention '${id}' with unparseable frontmatter: ${reason}`,
|
|
@@ -42993,13 +43089,13 @@ var BridgeService = class {
|
|
|
42993
43089
|
let outcome;
|
|
42994
43090
|
try {
|
|
42995
43091
|
outcome = await this.execute(before, request);
|
|
42996
|
-
} catch
|
|
43092
|
+
} catch {
|
|
42997
43093
|
outcome = {
|
|
42998
43094
|
reply: fail(
|
|
42999
43095
|
request.id,
|
|
43000
43096
|
request.bridge,
|
|
43001
43097
|
"RUNTIME",
|
|
43002
|
-
|
|
43098
|
+
"the View request failed"
|
|
43003
43099
|
)
|
|
43004
43100
|
};
|
|
43005
43101
|
}
|
|
@@ -43043,11 +43139,8 @@ var BridgeService = class {
|
|
|
43043
43139
|
let next;
|
|
43044
43140
|
try {
|
|
43045
43141
|
next = await this.subscriptionSnapshot();
|
|
43046
|
-
} catch
|
|
43047
|
-
return this.reload(
|
|
43048
|
-
launchId,
|
|
43049
|
-
error instanceof Error ? error.message : String(error)
|
|
43050
|
-
);
|
|
43142
|
+
} catch {
|
|
43143
|
+
return this.reload(launchId, "the View subscription could not be refreshed");
|
|
43051
43144
|
}
|
|
43052
43145
|
const after = await this.options.launches.resolve(launchId, true);
|
|
43053
43146
|
if (!after) return this.reload(launchId, "the View changed while its subscription was polled");
|
|
@@ -43082,7 +43175,7 @@ var BridgeService = class {
|
|
|
43082
43175
|
return { status: "reload-required", message };
|
|
43083
43176
|
}
|
|
43084
43177
|
async subscriptionSnapshot() {
|
|
43085
|
-
const rows = await
|
|
43178
|
+
const rows = await queryHeads2(this.options.bundle, {});
|
|
43086
43179
|
if (rows.length > MAX_SUBSCRIPTION_HEADS) {
|
|
43087
43180
|
throw new Error("the bundle is too large for the experimental View polling snapshot");
|
|
43088
43181
|
}
|
|
@@ -43097,7 +43190,7 @@ var BridgeService = class {
|
|
|
43097
43190
|
return { reply: null, openPageId: request.pageId };
|
|
43098
43191
|
}
|
|
43099
43192
|
try {
|
|
43100
|
-
const target = await
|
|
43193
|
+
const target = await readDocVersioned2(this.options.bundle, request.pageId);
|
|
43101
43194
|
if (!isAnyRegistryId(target.doc.id) || !parseRegistration(target.doc.id, target.doc.frontmatter)) {
|
|
43102
43195
|
throw new Error("invalid View target");
|
|
43103
43196
|
}
|
|
@@ -43118,13 +43211,13 @@ var BridgeService = class {
|
|
|
43118
43211
|
};
|
|
43119
43212
|
}
|
|
43120
43213
|
if (request.type === "query") {
|
|
43121
|
-
const rows = await
|
|
43214
|
+
const rows = await queryHeads2(this.options.bundle, {
|
|
43122
43215
|
...request.params.type ? { type: request.params.type } : {},
|
|
43123
43216
|
...request.params.prefix ? { prefix: request.params.prefix } : {}
|
|
43124
43217
|
});
|
|
43125
43218
|
const [registry, okfVersion] = await Promise.all([
|
|
43126
43219
|
loadKinds(this.options.bundle),
|
|
43127
|
-
|
|
43220
|
+
readBundleOkfVersion2(this.options.bundle)
|
|
43128
43221
|
]);
|
|
43129
43222
|
const result = boundedRows(
|
|
43130
43223
|
rows,
|
|
@@ -43139,9 +43232,9 @@ var BridgeService = class {
|
|
|
43139
43232
|
}
|
|
43140
43233
|
if (request.type === "read" || request.type === "read-versioned") {
|
|
43141
43234
|
const [result, registry, okfVersion] = await Promise.all([
|
|
43142
|
-
|
|
43235
|
+
readDocVersioned2(this.options.bundle, request.docId),
|
|
43143
43236
|
loadKinds(this.options.bundle),
|
|
43144
|
-
|
|
43237
|
+
readBundleOkfVersion2(this.options.bundle)
|
|
43145
43238
|
]);
|
|
43146
43239
|
if (Buffer.byteLength(result.doc.body, "utf8") > MAX_DOCUMENT_BODY_BYTES) {
|
|
43147
43240
|
return { reply: fail(request.id, request.bridge, "TOO_LARGE", "the document body exceeded the 1 MiB View limit") };
|
|
@@ -43160,7 +43253,7 @@ var BridgeService = class {
|
|
|
43160
43253
|
if (request.type === "render-document") {
|
|
43161
43254
|
let result;
|
|
43162
43255
|
try {
|
|
43163
|
-
result = await
|
|
43256
|
+
result = await readDocVersioned2(this.options.bundle, request.docId);
|
|
43164
43257
|
} catch (error) {
|
|
43165
43258
|
if (error?.code === "ENOENT") {
|
|
43166
43259
|
return {
|
|
@@ -43187,7 +43280,7 @@ var BridgeService = class {
|
|
|
43187
43280
|
};
|
|
43188
43281
|
}
|
|
43189
43282
|
if (request.type === "edges") {
|
|
43190
|
-
const edges = await
|
|
43283
|
+
const edges = await queryEdges2(this.options.bundle, request.params);
|
|
43191
43284
|
if (edges.length > MAX_EDGE_ROWS) {
|
|
43192
43285
|
return { reply: fail(request.id, request.bridge, "TOO_LARGE", `the edge query exceeded ${MAX_EDGE_ROWS} rows`) };
|
|
43193
43286
|
}
|