@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.mjs
CHANGED
|
@@ -1062,7 +1062,17 @@ function isWorkoutSectionType(type) {
|
|
|
1062
1062
|
}
|
|
1063
1063
|
|
|
1064
1064
|
// src/types/notebook.ts
|
|
1065
|
-
var DEFAULT_NOTEBOOK_SLUGS = ["journal", "playground", "defaults", "guides"];
|
|
1065
|
+
var DEFAULT_NOTEBOOK_SLUGS = ["journal", "playground", "defaults", "custom", "guides"];
|
|
1066
|
+
var READONLY_SYSTEM_NOTEBOOK_SLUGS = ["defaults", "guides", "efforts", "equipment", "dashboards"];
|
|
1067
|
+
var NON_PUBLISHABLE_NOTEBOOK_SLUGS = ["journal", "playground", "defaults", "custom", "guides", "efforts", "equipment", "dashboards"];
|
|
1068
|
+
var READONLY_SET = new Set(READONLY_SYSTEM_NOTEBOOK_SLUGS);
|
|
1069
|
+
var NON_PUBLISHABLE_SET = new Set(NON_PUBLISHABLE_NOTEBOOK_SLUGS);
|
|
1070
|
+
function isSystemReadOnlyNotebook(slugOrId) {
|
|
1071
|
+
return READONLY_SET.has(notebookSlugFromId(slugOrId));
|
|
1072
|
+
}
|
|
1073
|
+
function isNonPublishableNotebook(slugOrId) {
|
|
1074
|
+
return NON_PUBLISHABLE_SET.has(notebookSlugFromId(slugOrId));
|
|
1075
|
+
}
|
|
1066
1076
|
function notebookSlugFromId(slugOrId) {
|
|
1067
1077
|
const trimmed = slugOrId.trim();
|
|
1068
1078
|
if (trimmed.startsWith("notebook/")) return trimmed.slice("notebook/".length);
|
|
@@ -1072,7 +1082,9 @@ function notebookSlugFromId(slugOrId) {
|
|
|
1072
1082
|
function toNotebookId(slugOrId) {
|
|
1073
1083
|
return `notebook/${notebookSlugFromId(slugOrId)}`;
|
|
1074
1084
|
}
|
|
1075
|
-
function isNoteEditable(note, notebookOrigin) {
|
|
1085
|
+
function isNoteEditable(note, notebookOrigin, resolvedNotebookId) {
|
|
1086
|
+
const targetNb = resolvedNotebookId ?? note.notebookId ?? void 0;
|
|
1087
|
+
if (targetNb && isSystemReadOnlyNotebook(targetNb)) return false;
|
|
1076
1088
|
if (notebookOrigin) return notebookOrigin !== "feed";
|
|
1077
1089
|
return note.seedOrigin !== "seed" && note.feedOrigin !== "feed";
|
|
1078
1090
|
}
|
|
@@ -1081,33 +1093,51 @@ var BUILTIN_NOTEBOOKS = [
|
|
|
1081
1093
|
slug: "journal",
|
|
1082
1094
|
notebookId: "notebook/journal",
|
|
1083
1095
|
name: "Journal",
|
|
1084
|
-
description: "
|
|
1085
|
-
icon: "
|
|
1086
|
-
href: "/journal"
|
|
1096
|
+
description: "Private training log tracking all created notes and sessions across journal and playground.",
|
|
1097
|
+
icon: "J",
|
|
1098
|
+
href: "/journal",
|
|
1099
|
+
readOnly: false,
|
|
1100
|
+
publishable: false
|
|
1087
1101
|
},
|
|
1088
1102
|
{
|
|
1089
1103
|
slug: "playground",
|
|
1090
1104
|
notebookId: "notebook/playground",
|
|
1091
1105
|
name: "Playground",
|
|
1092
1106
|
description: "Scratchpad workouts and timer experiments.",
|
|
1093
|
-
icon: "
|
|
1094
|
-
href: "/playgrounds"
|
|
1107
|
+
icon: "P",
|
|
1108
|
+
href: "/playgrounds",
|
|
1109
|
+
readOnly: false,
|
|
1110
|
+
publishable: false
|
|
1095
1111
|
},
|
|
1096
1112
|
{
|
|
1097
1113
|
slug: "defaults",
|
|
1098
1114
|
notebookId: "notebook/defaults",
|
|
1099
1115
|
name: "Defaults",
|
|
1100
|
-
description: "
|
|
1101
|
-
icon: "
|
|
1102
|
-
href: "/notebook/defaults"
|
|
1116
|
+
description: "Read-only base primitives: Tags, Efforts, Equipment, and shared dynamic properties.",
|
|
1117
|
+
icon: "D",
|
|
1118
|
+
href: "/notebook/defaults",
|
|
1119
|
+
readOnly: true,
|
|
1120
|
+
publishable: false
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
slug: "custom",
|
|
1124
|
+
notebookId: "notebook/custom",
|
|
1125
|
+
name: "Custom",
|
|
1126
|
+
description: "User overrides and custom Tags, Efforts, Equipment, and starter workouts.",
|
|
1127
|
+
icon: "C",
|
|
1128
|
+
href: "/notebook/custom",
|
|
1129
|
+
readOnly: false,
|
|
1130
|
+
publishable: false
|
|
1103
1131
|
},
|
|
1104
1132
|
{
|
|
1105
1133
|
slug: "guides",
|
|
1106
1134
|
notebookId: "notebook/guides",
|
|
1107
1135
|
name: "Guides",
|
|
1108
|
-
description: "
|
|
1109
|
-
icon: "
|
|
1136
|
+
description: "Pre-subscribed read-only Whiteboard Language and WQL guides.",
|
|
1137
|
+
icon: "G",
|
|
1110
1138
|
href: "/notebook/guides",
|
|
1139
|
+
readOnly: true,
|
|
1140
|
+
publishable: false,
|
|
1111
1141
|
feedEntryId: "core",
|
|
1112
1142
|
seedChunkId: "canvas"
|
|
1113
1143
|
},
|
|
@@ -1738,15 +1768,169 @@ function parseFrontmatterProps(lines) {
|
|
|
1738
1768
|
}
|
|
1739
1769
|
|
|
1740
1770
|
// src/version.ts
|
|
1741
|
-
var VERSION = "0.
|
|
1742
|
-
var GIT_SHA = "
|
|
1743
|
-
var BUILD_TIME = "2026-11-
|
|
1771
|
+
var VERSION = "0.52.2198";
|
|
1772
|
+
var GIT_SHA = "15e2fcb";
|
|
1773
|
+
var BUILD_TIME = "2026-11-11T15:07:53.492Z";
|
|
1744
1774
|
var SEMVER = {
|
|
1745
|
-
version: "0.
|
|
1746
|
-
gitSha: "
|
|
1747
|
-
buildTime: "2026-11-
|
|
1775
|
+
version: "0.52.2198",
|
|
1776
|
+
gitSha: "15e2fcb",
|
|
1777
|
+
buildTime: "2026-11-11T15:07:53.492Z"
|
|
1748
1778
|
};
|
|
1749
1779
|
|
|
1750
|
-
|
|
1780
|
+
// src/portability/note-jsonl.ts
|
|
1781
|
+
function isObject(value) {
|
|
1782
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1783
|
+
}
|
|
1784
|
+
function isString(value) {
|
|
1785
|
+
return typeof value === "string" && value.length > 0;
|
|
1786
|
+
}
|
|
1787
|
+
function isFiniteNumber(value) {
|
|
1788
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
1789
|
+
}
|
|
1790
|
+
function isPositiveInteger(value) {
|
|
1791
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
1792
|
+
}
|
|
1793
|
+
function hasValidOrigin(value) {
|
|
1794
|
+
return value === void 0 || value === "journal" || value === "playground" || value === "user";
|
|
1795
|
+
}
|
|
1796
|
+
function validNote(value) {
|
|
1797
|
+
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");
|
|
1798
|
+
}
|
|
1799
|
+
function validSession(value) {
|
|
1800
|
+
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);
|
|
1801
|
+
}
|
|
1802
|
+
function validParseRecord(value) {
|
|
1803
|
+
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));
|
|
1804
|
+
}
|
|
1805
|
+
function validEvent(value) {
|
|
1806
|
+
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");
|
|
1807
|
+
}
|
|
1808
|
+
function validRevision(value) {
|
|
1809
|
+
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");
|
|
1810
|
+
}
|
|
1811
|
+
function revisionToJsonl(revision) {
|
|
1812
|
+
const { kind: blockKind, ...identity } = revision;
|
|
1813
|
+
return { kind: "revision", blockKind, ...identity };
|
|
1814
|
+
}
|
|
1815
|
+
function serializeNoteBundleToJsonl(bundle) {
|
|
1816
|
+
const records = [
|
|
1817
|
+
...bundle.note ? [{ kind: "note", ...bundle.note }] : [],
|
|
1818
|
+
...(bundle.revisions ?? []).map(revisionToJsonl),
|
|
1819
|
+
...(bundle.parses ?? []).map((parse) => ({ kind: "parse", ...parse })),
|
|
1820
|
+
...bundle.sessions.map((session) => ({ kind: "session", ...session })),
|
|
1821
|
+
...bundle.events.map((event) => ({ kind: "event", ...event }))
|
|
1822
|
+
];
|
|
1823
|
+
return records.map((record) => JSON.stringify(record)).join("\n");
|
|
1824
|
+
}
|
|
1825
|
+
async function* streamNoteBundleToJsonlLines(bundles) {
|
|
1826
|
+
for await (const bundle of bundles) {
|
|
1827
|
+
if (bundle.note) yield JSON.stringify({ kind: "note", ...bundle.note });
|
|
1828
|
+
for (const revision of bundle.revisions ?? []) yield JSON.stringify(revisionToJsonl(revision));
|
|
1829
|
+
for (const parse of bundle.parses ?? []) yield JSON.stringify({ kind: "parse", ...parse });
|
|
1830
|
+
for (const session of bundle.sessions) yield JSON.stringify({ kind: "session", ...session });
|
|
1831
|
+
for (const event of bundle.events) yield JSON.stringify({ kind: "event", ...event });
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
function parseNoteBundleFromJsonl(jsonlText) {
|
|
1835
|
+
const bundles = /* @__PURE__ */ new Map();
|
|
1836
|
+
const errors = [];
|
|
1837
|
+
const lines = jsonlText.split(/\r?\n/);
|
|
1838
|
+
const bundleFor = (noteId) => {
|
|
1839
|
+
const existing = bundles.get(noteId);
|
|
1840
|
+
if (existing) return existing;
|
|
1841
|
+
const created = { sessions: [], events: [] };
|
|
1842
|
+
bundles.set(noteId, created);
|
|
1843
|
+
return created;
|
|
1844
|
+
};
|
|
1845
|
+
for (const [index, line] of lines.entries()) {
|
|
1846
|
+
if (!line.trim()) continue;
|
|
1847
|
+
const lineNumber = index + 1;
|
|
1848
|
+
try {
|
|
1849
|
+
const parsed = JSON.parse(line);
|
|
1850
|
+
if (!isObject(parsed) || typeof parsed.kind !== "string") {
|
|
1851
|
+
errors.push(`Line ${lineNumber}: missing record kind`);
|
|
1852
|
+
continue;
|
|
1853
|
+
}
|
|
1854
|
+
const { kind, ...value } = parsed;
|
|
1855
|
+
if (kind === "note") {
|
|
1856
|
+
if (!validNote(value)) {
|
|
1857
|
+
errors.push(`Line ${lineNumber}: invalid note record`);
|
|
1858
|
+
continue;
|
|
1859
|
+
}
|
|
1860
|
+
const note = value;
|
|
1861
|
+
const bundle = bundleFor(note.id);
|
|
1862
|
+
if (bundle.note) {
|
|
1863
|
+
errors.push(`Line ${lineNumber}: duplicate note ${note.id}`);
|
|
1864
|
+
continue;
|
|
1865
|
+
}
|
|
1866
|
+
bundle.note = note;
|
|
1867
|
+
} else if (kind === "revision") {
|
|
1868
|
+
if (!validRevision(value)) {
|
|
1869
|
+
errors.push(`Line ${lineNumber}: invalid revision record`);
|
|
1870
|
+
continue;
|
|
1871
|
+
}
|
|
1872
|
+
const { blockKind, ...identity } = value;
|
|
1873
|
+
const revision = { ...identity, kind: blockKind };
|
|
1874
|
+
(bundleFor(revision.noteId).revisions ??= []).push(revision);
|
|
1875
|
+
} else if (kind === "session") {
|
|
1876
|
+
if (!validSession(value)) {
|
|
1877
|
+
errors.push(`Line ${lineNumber}: invalid session record`);
|
|
1878
|
+
continue;
|
|
1879
|
+
}
|
|
1880
|
+
const session = value;
|
|
1881
|
+
bundleFor(session.noteId).sessions.push(session);
|
|
1882
|
+
} else if (kind === "event") {
|
|
1883
|
+
if (!validEvent(value)) {
|
|
1884
|
+
errors.push(`Line ${lineNumber}: invalid event record`);
|
|
1885
|
+
continue;
|
|
1886
|
+
}
|
|
1887
|
+
const event = value;
|
|
1888
|
+
bundleFor(event.noteId).events.push(event);
|
|
1889
|
+
} else if (kind === "parse") {
|
|
1890
|
+
if (!validParseRecord(value)) {
|
|
1891
|
+
errors.push(`Line ${lineNumber}: invalid parse/load record`);
|
|
1892
|
+
continue;
|
|
1893
|
+
}
|
|
1894
|
+
const parseRec = value;
|
|
1895
|
+
(bundleFor(parseRec.noteId).parses ??= []).push(parseRec);
|
|
1896
|
+
} else {
|
|
1897
|
+
errors.push(`Line ${lineNumber}: unknown record kind ${kind}`);
|
|
1898
|
+
}
|
|
1899
|
+
} catch (error) {
|
|
1900
|
+
errors.push(`Line ${lineNumber}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
for (const bundle of bundles.values()) {
|
|
1904
|
+
const sessionIds = new Set(bundle.sessions.map((session) => session.id));
|
|
1905
|
+
for (const event of bundle.events) {
|
|
1906
|
+
if (!sessionIds.has(event.resultId)) {
|
|
1907
|
+
errors.push(`Event ${event.id}: no session ${event.resultId} for note ${event.noteId}`);
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
return { bundles: [...bundles.values()], errors };
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
// src/publication.ts
|
|
1915
|
+
function isPublishableNotebookLanding(note) {
|
|
1916
|
+
return note.id.startsWith("notebook/") && note.notebookId === note.id && !isNonPublishableNotebook(note.id) && note.feedOrigin !== "feed" && note.seedOrigin !== "seed";
|
|
1917
|
+
}
|
|
1918
|
+
function derivePublicationVisibility(input) {
|
|
1919
|
+
const notebookPublic = input.notebookPublic === true;
|
|
1920
|
+
const publicSessions = Math.max(0, Math.trunc(input.publicSessions));
|
|
1921
|
+
const totalSessions = Math.max(publicSessions, Math.trunc(input.totalSessions));
|
|
1922
|
+
const visibility = !notebookPublic ? "Private" : publicSessions > 0 ? "Published Note + Data" : "Published Note";
|
|
1923
|
+
return {
|
|
1924
|
+
visibility,
|
|
1925
|
+
notebookPublic,
|
|
1926
|
+
publicSessions,
|
|
1927
|
+
totalSessions,
|
|
1928
|
+
...input.notebookId ? { notebookId: input.notebookId } : {},
|
|
1929
|
+
...input.notebookIds ? { notebookIds: input.notebookIds } : {},
|
|
1930
|
+
...input.publicNotebookIds ? { publicNotebookIds: input.publicNotebookIds } : {}
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
export { BUILD_TIME, BUILTIN_NOTEBOOKS, BlockKey, CodeMetadata, CodeStatement, DEFAULT_NOTEBOOK_SLUGS, GIT_SHA, KNOWN_OUTPUT_TYPES, KNOWN_SECTION_WIDGETS, LEGACY_ORIGIN_TO_OWNERSHIP_LAYER, METRIC_OWNERSHIP_LAYER_CHAIN, Metric, MetricContainer, MetricType, NON_PUBLISHABLE_NOTEBOOK_SLUGS, NOTEBOOK_TAG_PREFIX, OutputStatement, OwnershipResolver, ParsedCodeStatement, READONLY_SYSTEM_NOTEBOOK_SLUGS, REFERENCE_METADATA_KEY, SEMVER, SYSTEM_DEFAULT_OUTPUT_UNIT, TAG_REFERENCE_METADATA_KEY, UNIT_CATALOG, UnitConversionError, VALID_FENCE_DIALECTS, VERSION, actionableSectionKind, blockContentId, buildRawContent, calculateTotalLines, comparePlacements, convertViaCatalog, createMetricOwnershipLedger, createTagIndex, derivePublicationVisibility, detectScriptBlocks, dimensionKeyOf, extractBlockContent, extractFrontmatterTags, extractTypedFrontmatterTags, fieldRefFromKey, fieldRefKey, findBlockAtLine, flattenFieldLeaves, fromNotebookTag, getList, getMetricOwnershipLayer, getReferenceMetadata, getScalar, getTagReference, isNonPublishableNotebook, isNoteEditable, isNotebookTag, isPublishableNotebookLanding, isSystemReadOnlyNotebook, isWorkoutSectionType, lookupUnit, mapNoteBlockChanges, matchDialectFence, normalizeFieldComponent, normalizeFieldPath, notebookSlugFromId, orderPlacements, ownershipRank, parseDocumentSections, parseFlatProperties, parseFrontmatter, parseFrontmatterBody, parseFrontmatterCategories, parseFrontmatterProps, parseNoteBundleFromJsonl, patchFrontmatterProperty, projectPlacements, reconcileNoteBlocks, resolveLayer, resolvePlacements, runAffordance, serializeFrontmatter, serializeNoteBundleToJsonl, streamNoteBundleToJsonlLines, stripFrontmatter, systemDefaultUnit, toNotebookId, toNotebookTag, validateNoteBlocks, valueKindOf };
|
|
1751
1935
|
//# sourceMappingURL=index.mjs.map
|
|
1752
1936
|
//# sourceMappingURL=index.mjs.map
|