@bitcobblers/wod-wiki-core 0.51.2195 → 0.52.2198
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/index.cjs +211 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +172 -10
- package/dist/index.d.ts +172 -10
- package/dist/index.mjs +203 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1064,7 +1064,17 @@ function isWorkoutSectionType(type) {
|
|
|
1064
1064
|
}
|
|
1065
1065
|
|
|
1066
1066
|
// src/types/notebook.ts
|
|
1067
|
-
var DEFAULT_NOTEBOOK_SLUGS = ["journal", "playground", "defaults", "guides"];
|
|
1067
|
+
var DEFAULT_NOTEBOOK_SLUGS = ["journal", "playground", "defaults", "custom", "guides"];
|
|
1068
|
+
var READONLY_SYSTEM_NOTEBOOK_SLUGS = ["defaults", "guides", "efforts", "equipment", "dashboards"];
|
|
1069
|
+
var NON_PUBLISHABLE_NOTEBOOK_SLUGS = ["journal", "playground", "defaults", "custom", "guides", "efforts", "equipment", "dashboards"];
|
|
1070
|
+
var READONLY_SET = new Set(READONLY_SYSTEM_NOTEBOOK_SLUGS);
|
|
1071
|
+
var NON_PUBLISHABLE_SET = new Set(NON_PUBLISHABLE_NOTEBOOK_SLUGS);
|
|
1072
|
+
function isSystemReadOnlyNotebook(slugOrId) {
|
|
1073
|
+
return READONLY_SET.has(notebookSlugFromId(slugOrId));
|
|
1074
|
+
}
|
|
1075
|
+
function isNonPublishableNotebook(slugOrId) {
|
|
1076
|
+
return NON_PUBLISHABLE_SET.has(notebookSlugFromId(slugOrId));
|
|
1077
|
+
}
|
|
1068
1078
|
function notebookSlugFromId(slugOrId) {
|
|
1069
1079
|
const trimmed = slugOrId.trim();
|
|
1070
1080
|
if (trimmed.startsWith("notebook/")) return trimmed.slice("notebook/".length);
|
|
@@ -1074,7 +1084,9 @@ function notebookSlugFromId(slugOrId) {
|
|
|
1074
1084
|
function toNotebookId(slugOrId) {
|
|
1075
1085
|
return `notebook/${notebookSlugFromId(slugOrId)}`;
|
|
1076
1086
|
}
|
|
1077
|
-
function isNoteEditable(note, notebookOrigin) {
|
|
1087
|
+
function isNoteEditable(note, notebookOrigin, resolvedNotebookId) {
|
|
1088
|
+
const targetNb = resolvedNotebookId ?? note.notebookId ?? void 0;
|
|
1089
|
+
if (targetNb && isSystemReadOnlyNotebook(targetNb)) return false;
|
|
1078
1090
|
if (notebookOrigin) return notebookOrigin !== "feed";
|
|
1079
1091
|
return note.seedOrigin !== "seed" && note.feedOrigin !== "feed";
|
|
1080
1092
|
}
|
|
@@ -1083,33 +1095,51 @@ var BUILTIN_NOTEBOOKS = [
|
|
|
1083
1095
|
slug: "journal",
|
|
1084
1096
|
notebookId: "notebook/journal",
|
|
1085
1097
|
name: "Journal",
|
|
1086
|
-
description: "
|
|
1087
|
-
icon: "
|
|
1088
|
-
href: "/journal"
|
|
1098
|
+
description: "Private training log tracking all created notes and sessions across journal and playground.",
|
|
1099
|
+
icon: "J",
|
|
1100
|
+
href: "/journal",
|
|
1101
|
+
readOnly: false,
|
|
1102
|
+
publishable: false
|
|
1089
1103
|
},
|
|
1090
1104
|
{
|
|
1091
1105
|
slug: "playground",
|
|
1092
1106
|
notebookId: "notebook/playground",
|
|
1093
1107
|
name: "Playground",
|
|
1094
1108
|
description: "Scratchpad workouts and timer experiments.",
|
|
1095
|
-
icon: "
|
|
1096
|
-
href: "/playgrounds"
|
|
1109
|
+
icon: "P",
|
|
1110
|
+
href: "/playgrounds",
|
|
1111
|
+
readOnly: false,
|
|
1112
|
+
publishable: false
|
|
1097
1113
|
},
|
|
1098
1114
|
{
|
|
1099
1115
|
slug: "defaults",
|
|
1100
1116
|
notebookId: "notebook/defaults",
|
|
1101
1117
|
name: "Defaults",
|
|
1102
|
-
description: "
|
|
1103
|
-
icon: "
|
|
1104
|
-
href: "/notebook/defaults"
|
|
1118
|
+
description: "Read-only base primitives: Tags, Efforts, Equipment, and shared dynamic properties.",
|
|
1119
|
+
icon: "D",
|
|
1120
|
+
href: "/notebook/defaults",
|
|
1121
|
+
readOnly: true,
|
|
1122
|
+
publishable: false
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
slug: "custom",
|
|
1126
|
+
notebookId: "notebook/custom",
|
|
1127
|
+
name: "Custom",
|
|
1128
|
+
description: "User overrides and custom Tags, Efforts, Equipment, and starter workouts.",
|
|
1129
|
+
icon: "C",
|
|
1130
|
+
href: "/notebook/custom",
|
|
1131
|
+
readOnly: false,
|
|
1132
|
+
publishable: false
|
|
1105
1133
|
},
|
|
1106
1134
|
{
|
|
1107
1135
|
slug: "guides",
|
|
1108
1136
|
notebookId: "notebook/guides",
|
|
1109
1137
|
name: "Guides",
|
|
1110
|
-
description: "
|
|
1111
|
-
icon: "
|
|
1138
|
+
description: "Pre-subscribed read-only Whiteboard Language and WQL guides.",
|
|
1139
|
+
icon: "G",
|
|
1112
1140
|
href: "/notebook/guides",
|
|
1141
|
+
readOnly: true,
|
|
1142
|
+
publishable: false,
|
|
1113
1143
|
feedEntryId: "core",
|
|
1114
1144
|
seedChunkId: "canvas"
|
|
1115
1145
|
},
|
|
@@ -1740,15 +1770,169 @@ function parseFrontmatterProps(lines) {
|
|
|
1740
1770
|
}
|
|
1741
1771
|
|
|
1742
1772
|
// src/version.ts
|
|
1743
|
-
var VERSION = "0.
|
|
1744
|
-
var GIT_SHA = "
|
|
1745
|
-
var BUILD_TIME = "2026-11-
|
|
1773
|
+
var VERSION = "0.52.2198";
|
|
1774
|
+
var GIT_SHA = "15e2fcb";
|
|
1775
|
+
var BUILD_TIME = "2026-11-11T15:07:53.492Z";
|
|
1746
1776
|
var SEMVER = {
|
|
1747
|
-
version: "0.
|
|
1748
|
-
gitSha: "
|
|
1749
|
-
buildTime: "2026-11-
|
|
1777
|
+
version: "0.52.2198",
|
|
1778
|
+
gitSha: "15e2fcb",
|
|
1779
|
+
buildTime: "2026-11-11T15:07:53.492Z"
|
|
1750
1780
|
};
|
|
1751
1781
|
|
|
1782
|
+
// src/portability/note-jsonl.ts
|
|
1783
|
+
function isObject(value) {
|
|
1784
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1785
|
+
}
|
|
1786
|
+
function isString(value) {
|
|
1787
|
+
return typeof value === "string" && value.length > 0;
|
|
1788
|
+
}
|
|
1789
|
+
function isFiniteNumber(value) {
|
|
1790
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
1791
|
+
}
|
|
1792
|
+
function isPositiveInteger(value) {
|
|
1793
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
1794
|
+
}
|
|
1795
|
+
function hasValidOrigin(value) {
|
|
1796
|
+
return value === void 0 || value === "journal" || value === "playground" || value === "user";
|
|
1797
|
+
}
|
|
1798
|
+
function validNote(value) {
|
|
1799
|
+
return isString(value.id) && typeof value.title === "string" && isFiniteNumber(value.createdAt) && isFiniteNumber(value.updatedAt) && isFiniteNumber(value.targetDate) && typeof value.rawContent === "string" && (value.sourceRevision === void 0 || isPositiveInteger(value.sourceRevision)) && (value.blocks === void 0 || isObject(value.blocks)) && (value.tags === void 0 || Array.isArray(value.tags) && value.tags.every((tag) => typeof tag === "string")) && (value.type === void 0 || typeof value.type === "string") && (value.sourceId === void 0 || typeof value.sourceId === "string");
|
|
1800
|
+
}
|
|
1801
|
+
function validSession(value) {
|
|
1802
|
+
return isString(value.id) && isString(value.noteId) && isString(value.blockId) && isPositiveInteger(value.blockVersion) && isString(value.blockContentId) && hasValidOrigin(value.origin) && (value.status === void 0 || value.status === "in-progress" || value.status === "completed") && (value.public === void 0 || typeof value.public === "boolean") && isFiniteNumber(value.startTime) && isFiniteNumber(value.endTime) && isFiniteNumber(value.duration) && typeof value.completed === "boolean" && isFiniteNumber(value.createdAt);
|
|
1803
|
+
}
|
|
1804
|
+
function validParseRecord(value) {
|
|
1805
|
+
return isString(value.id) && isString(value.noteId) && (value.blockId === void 0 || isString(value.blockId)) && (value.blockVersion === void 0 || isPositiveInteger(value.blockVersion)) && (value.stage === "parse" || value.stage === "load") && (value.status === "ok" || value.status === "warning" || value.status === "error") && isFiniteNumber(value.timestamp) && (value.diagnostics === void 0 || Array.isArray(value.diagnostics) && value.diagnostics.every((d) => typeof d === "string")) && (value.metrics === void 0 || isObject(value.metrics));
|
|
1806
|
+
}
|
|
1807
|
+
function validEvent(value) {
|
|
1808
|
+
return isString(value.id) && isString(value.resultId) && isString(value.noteId) && isString(value.blockId) && isPositiveInteger(value.blockVersion) && isString(value.blockContentId) && hasValidOrigin(value.origin) && isFiniteNumber(value.timestamp) && (value.grain === "event" || value.grain === "summary") && typeof value.outputType === "string" && Array.isArray(value.metrics) && value.metrics.every((metric) => isObject(metric) && typeof metric.type === "string") && (value.grain !== "summary" || value.metrics.length === 1) && (value.representationKind === void 0 || value.representationKind === "direct" || value.representationKind === "calculated" || value.representationKind === "substitute_summary");
|
|
1809
|
+
}
|
|
1810
|
+
function validRevision(value) {
|
|
1811
|
+
return isString(value.noteId) && isString(value.blockId) && isPositiveInteger(value.version) && ["wod", "query", "widget", "embed"].includes(String(value.blockKind)) && typeof value.rawContent === "string" && isFiniteNumber(value.savedAt) && (value.dialect === void 0 || value.dialect === "time" || value.dialect === "log") && (value.sport === void 0 || typeof value.sport === "string");
|
|
1812
|
+
}
|
|
1813
|
+
function revisionToJsonl(revision) {
|
|
1814
|
+
const { kind: blockKind, ...identity } = revision;
|
|
1815
|
+
return { kind: "revision", blockKind, ...identity };
|
|
1816
|
+
}
|
|
1817
|
+
function serializeNoteBundleToJsonl(bundle) {
|
|
1818
|
+
const records = [
|
|
1819
|
+
...bundle.note ? [{ kind: "note", ...bundle.note }] : [],
|
|
1820
|
+
...(bundle.revisions ?? []).map(revisionToJsonl),
|
|
1821
|
+
...(bundle.parses ?? []).map((parse) => ({ kind: "parse", ...parse })),
|
|
1822
|
+
...bundle.sessions.map((session) => ({ kind: "session", ...session })),
|
|
1823
|
+
...bundle.events.map((event) => ({ kind: "event", ...event }))
|
|
1824
|
+
];
|
|
1825
|
+
return records.map((record) => JSON.stringify(record)).join("\n");
|
|
1826
|
+
}
|
|
1827
|
+
async function* streamNoteBundleToJsonlLines(bundles) {
|
|
1828
|
+
for await (const bundle of bundles) {
|
|
1829
|
+
if (bundle.note) yield JSON.stringify({ kind: "note", ...bundle.note });
|
|
1830
|
+
for (const revision of bundle.revisions ?? []) yield JSON.stringify(revisionToJsonl(revision));
|
|
1831
|
+
for (const parse of bundle.parses ?? []) yield JSON.stringify({ kind: "parse", ...parse });
|
|
1832
|
+
for (const session of bundle.sessions) yield JSON.stringify({ kind: "session", ...session });
|
|
1833
|
+
for (const event of bundle.events) yield JSON.stringify({ kind: "event", ...event });
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
function parseNoteBundleFromJsonl(jsonlText) {
|
|
1837
|
+
const bundles = /* @__PURE__ */ new Map();
|
|
1838
|
+
const errors = [];
|
|
1839
|
+
const lines = jsonlText.split(/\r?\n/);
|
|
1840
|
+
const bundleFor = (noteId) => {
|
|
1841
|
+
const existing = bundles.get(noteId);
|
|
1842
|
+
if (existing) return existing;
|
|
1843
|
+
const created = { sessions: [], events: [] };
|
|
1844
|
+
bundles.set(noteId, created);
|
|
1845
|
+
return created;
|
|
1846
|
+
};
|
|
1847
|
+
for (const [index, line] of lines.entries()) {
|
|
1848
|
+
if (!line.trim()) continue;
|
|
1849
|
+
const lineNumber = index + 1;
|
|
1850
|
+
try {
|
|
1851
|
+
const parsed = JSON.parse(line);
|
|
1852
|
+
if (!isObject(parsed) || typeof parsed.kind !== "string") {
|
|
1853
|
+
errors.push(`Line ${lineNumber}: missing record kind`);
|
|
1854
|
+
continue;
|
|
1855
|
+
}
|
|
1856
|
+
const { kind, ...value } = parsed;
|
|
1857
|
+
if (kind === "note") {
|
|
1858
|
+
if (!validNote(value)) {
|
|
1859
|
+
errors.push(`Line ${lineNumber}: invalid note record`);
|
|
1860
|
+
continue;
|
|
1861
|
+
}
|
|
1862
|
+
const note = value;
|
|
1863
|
+
const bundle = bundleFor(note.id);
|
|
1864
|
+
if (bundle.note) {
|
|
1865
|
+
errors.push(`Line ${lineNumber}: duplicate note ${note.id}`);
|
|
1866
|
+
continue;
|
|
1867
|
+
}
|
|
1868
|
+
bundle.note = note;
|
|
1869
|
+
} else if (kind === "revision") {
|
|
1870
|
+
if (!validRevision(value)) {
|
|
1871
|
+
errors.push(`Line ${lineNumber}: invalid revision record`);
|
|
1872
|
+
continue;
|
|
1873
|
+
}
|
|
1874
|
+
const { blockKind, ...identity } = value;
|
|
1875
|
+
const revision = { ...identity, kind: blockKind };
|
|
1876
|
+
(bundleFor(revision.noteId).revisions ??= []).push(revision);
|
|
1877
|
+
} else if (kind === "session") {
|
|
1878
|
+
if (!validSession(value)) {
|
|
1879
|
+
errors.push(`Line ${lineNumber}: invalid session record`);
|
|
1880
|
+
continue;
|
|
1881
|
+
}
|
|
1882
|
+
const session = value;
|
|
1883
|
+
bundleFor(session.noteId).sessions.push(session);
|
|
1884
|
+
} else if (kind === "event") {
|
|
1885
|
+
if (!validEvent(value)) {
|
|
1886
|
+
errors.push(`Line ${lineNumber}: invalid event record`);
|
|
1887
|
+
continue;
|
|
1888
|
+
}
|
|
1889
|
+
const event = value;
|
|
1890
|
+
bundleFor(event.noteId).events.push(event);
|
|
1891
|
+
} else if (kind === "parse") {
|
|
1892
|
+
if (!validParseRecord(value)) {
|
|
1893
|
+
errors.push(`Line ${lineNumber}: invalid parse/load record`);
|
|
1894
|
+
continue;
|
|
1895
|
+
}
|
|
1896
|
+
const parseRec = value;
|
|
1897
|
+
(bundleFor(parseRec.noteId).parses ??= []).push(parseRec);
|
|
1898
|
+
} else {
|
|
1899
|
+
errors.push(`Line ${lineNumber}: unknown record kind ${kind}`);
|
|
1900
|
+
}
|
|
1901
|
+
} catch (error) {
|
|
1902
|
+
errors.push(`Line ${lineNumber}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
for (const bundle of bundles.values()) {
|
|
1906
|
+
const sessionIds = new Set(bundle.sessions.map((session) => session.id));
|
|
1907
|
+
for (const event of bundle.events) {
|
|
1908
|
+
if (!sessionIds.has(event.resultId)) {
|
|
1909
|
+
errors.push(`Event ${event.id}: no session ${event.resultId} for note ${event.noteId}`);
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
return { bundles: [...bundles.values()], errors };
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
// src/publication.ts
|
|
1917
|
+
function isPublishableNotebookLanding(note) {
|
|
1918
|
+
return note.id.startsWith("notebook/") && note.notebookId === note.id && !isNonPublishableNotebook(note.id) && note.feedOrigin !== "feed" && note.seedOrigin !== "seed";
|
|
1919
|
+
}
|
|
1920
|
+
function derivePublicationVisibility(input) {
|
|
1921
|
+
const notebookPublic = input.notebookPublic === true;
|
|
1922
|
+
const publicSessions = Math.max(0, Math.trunc(input.publicSessions));
|
|
1923
|
+
const totalSessions = Math.max(publicSessions, Math.trunc(input.totalSessions));
|
|
1924
|
+
const visibility = !notebookPublic ? "Private" : publicSessions > 0 ? "Published Note + Data" : "Published Note";
|
|
1925
|
+
return {
|
|
1926
|
+
visibility,
|
|
1927
|
+
notebookPublic,
|
|
1928
|
+
publicSessions,
|
|
1929
|
+
totalSessions,
|
|
1930
|
+
...input.notebookId ? { notebookId: input.notebookId } : {},
|
|
1931
|
+
...input.notebookIds ? { notebookIds: input.notebookIds } : {},
|
|
1932
|
+
...input.publicNotebookIds ? { publicNotebookIds: input.publicNotebookIds } : {}
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1752
1936
|
exports.BUILD_TIME = BUILD_TIME;
|
|
1753
1937
|
exports.BUILTIN_NOTEBOOKS = BUILTIN_NOTEBOOKS;
|
|
1754
1938
|
exports.BlockKey = BlockKey;
|
|
@@ -1763,10 +1947,12 @@ exports.METRIC_OWNERSHIP_LAYER_CHAIN = METRIC_OWNERSHIP_LAYER_CHAIN;
|
|
|
1763
1947
|
exports.Metric = Metric;
|
|
1764
1948
|
exports.MetricContainer = MetricContainer;
|
|
1765
1949
|
exports.MetricType = MetricType;
|
|
1950
|
+
exports.NON_PUBLISHABLE_NOTEBOOK_SLUGS = NON_PUBLISHABLE_NOTEBOOK_SLUGS;
|
|
1766
1951
|
exports.NOTEBOOK_TAG_PREFIX = NOTEBOOK_TAG_PREFIX;
|
|
1767
1952
|
exports.OutputStatement = OutputStatement;
|
|
1768
1953
|
exports.OwnershipResolver = OwnershipResolver;
|
|
1769
1954
|
exports.ParsedCodeStatement = ParsedCodeStatement;
|
|
1955
|
+
exports.READONLY_SYSTEM_NOTEBOOK_SLUGS = READONLY_SYSTEM_NOTEBOOK_SLUGS;
|
|
1770
1956
|
exports.REFERENCE_METADATA_KEY = REFERENCE_METADATA_KEY;
|
|
1771
1957
|
exports.SEMVER = SEMVER;
|
|
1772
1958
|
exports.SYSTEM_DEFAULT_OUTPUT_UNIT = SYSTEM_DEFAULT_OUTPUT_UNIT;
|
|
@@ -1783,6 +1969,7 @@ exports.comparePlacements = comparePlacements;
|
|
|
1783
1969
|
exports.convertViaCatalog = convertViaCatalog;
|
|
1784
1970
|
exports.createMetricOwnershipLedger = createMetricOwnershipLedger;
|
|
1785
1971
|
exports.createTagIndex = createTagIndex;
|
|
1972
|
+
exports.derivePublicationVisibility = derivePublicationVisibility;
|
|
1786
1973
|
exports.detectScriptBlocks = detectScriptBlocks;
|
|
1787
1974
|
exports.dimensionKeyOf = dimensionKeyOf;
|
|
1788
1975
|
exports.extractBlockContent = extractBlockContent;
|
|
@@ -1798,8 +1985,11 @@ exports.getMetricOwnershipLayer = getMetricOwnershipLayer;
|
|
|
1798
1985
|
exports.getReferenceMetadata = getReferenceMetadata;
|
|
1799
1986
|
exports.getScalar = getScalar;
|
|
1800
1987
|
exports.getTagReference = getTagReference;
|
|
1988
|
+
exports.isNonPublishableNotebook = isNonPublishableNotebook;
|
|
1801
1989
|
exports.isNoteEditable = isNoteEditable;
|
|
1802
1990
|
exports.isNotebookTag = isNotebookTag;
|
|
1991
|
+
exports.isPublishableNotebookLanding = isPublishableNotebookLanding;
|
|
1992
|
+
exports.isSystemReadOnlyNotebook = isSystemReadOnlyNotebook;
|
|
1803
1993
|
exports.isWorkoutSectionType = isWorkoutSectionType;
|
|
1804
1994
|
exports.lookupUnit = lookupUnit;
|
|
1805
1995
|
exports.mapNoteBlockChanges = mapNoteBlockChanges;
|
|
@@ -1815,6 +2005,7 @@ exports.parseFrontmatter = parseFrontmatter;
|
|
|
1815
2005
|
exports.parseFrontmatterBody = parseFrontmatterBody;
|
|
1816
2006
|
exports.parseFrontmatterCategories = parseFrontmatterCategories;
|
|
1817
2007
|
exports.parseFrontmatterProps = parseFrontmatterProps;
|
|
2008
|
+
exports.parseNoteBundleFromJsonl = parseNoteBundleFromJsonl;
|
|
1818
2009
|
exports.patchFrontmatterProperty = patchFrontmatterProperty;
|
|
1819
2010
|
exports.projectPlacements = projectPlacements;
|
|
1820
2011
|
exports.reconcileNoteBlocks = reconcileNoteBlocks;
|
|
@@ -1822,6 +2013,8 @@ exports.resolveLayer = resolveLayer;
|
|
|
1822
2013
|
exports.resolvePlacements = resolvePlacements;
|
|
1823
2014
|
exports.runAffordance = runAffordance;
|
|
1824
2015
|
exports.serializeFrontmatter = serializeFrontmatter;
|
|
2016
|
+
exports.serializeNoteBundleToJsonl = serializeNoteBundleToJsonl;
|
|
2017
|
+
exports.streamNoteBundleToJsonlLines = streamNoteBundleToJsonlLines;
|
|
1825
2018
|
exports.stripFrontmatter = stripFrontmatter;
|
|
1826
2019
|
exports.systemDefaultUnit = systemDefaultUnit;
|
|
1827
2020
|
exports.toNotebookId = toNotebookId;
|