@bitcobblers/wod-wiki-core 0.61.2259 → 0.62.2260
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 +270 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +158 -13
- package/dist/index.d.ts +158 -13
- package/dist/index.mjs +264 -12
- package/dist/index.mjs.map +1 -1
- package/dist/testing.cjs +26 -0
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +77 -1
- package/dist/testing.d.ts +77 -1
- package/dist/testing.mjs +26 -1
- package/dist/testing.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1040,6 +1040,42 @@ function projectPlacements(placements) {
|
|
|
1040
1040
|
return projection;
|
|
1041
1041
|
}
|
|
1042
1042
|
|
|
1043
|
+
// src/models/timeFormatting.ts
|
|
1044
|
+
var TIME_METRIC_TYPES = /* @__PURE__ */ new Set(["duration", "elapsed", "total", "time"]);
|
|
1045
|
+
function metricToMs(metric) {
|
|
1046
|
+
if (typeof metric.value !== "number" || !Number.isFinite(metric.value)) {
|
|
1047
|
+
return void 0;
|
|
1048
|
+
}
|
|
1049
|
+
const unit = metric.unit?.trim().toLowerCase();
|
|
1050
|
+
if (unit === "ms" || unit === "millisecond" || unit === "milliseconds") {
|
|
1051
|
+
return metric.value;
|
|
1052
|
+
}
|
|
1053
|
+
if (unit === "s" || unit === "sec" || unit === "secs" || unit === "second" || unit === "seconds") {
|
|
1054
|
+
return metric.value * 1e3;
|
|
1055
|
+
}
|
|
1056
|
+
if (unit === "min" || unit === "m" || unit === "mins" || unit === "minute" || unit === "minutes") {
|
|
1057
|
+
return metric.value * 6e4;
|
|
1058
|
+
}
|
|
1059
|
+
if (unit === "h" || unit === "hr" || unit === "hrs" || unit === "hour" || unit === "hours") {
|
|
1060
|
+
return metric.value * 36e5;
|
|
1061
|
+
}
|
|
1062
|
+
if (!unit && TIME_METRIC_TYPES.has(String(metric.type ?? "").toLowerCase())) {
|
|
1063
|
+
return metric.value;
|
|
1064
|
+
}
|
|
1065
|
+
return metric.value;
|
|
1066
|
+
}
|
|
1067
|
+
function formatDurationMMSS(ms) {
|
|
1068
|
+
if (!Number.isFinite(ms) || ms <= 0) return "00:00";
|
|
1069
|
+
const totalSec = Math.round(ms / 1e3);
|
|
1070
|
+
const hours = Math.floor(totalSec / 3600);
|
|
1071
|
+
const mins = Math.floor(totalSec % 3600 / 60);
|
|
1072
|
+
const secs = totalSec % 60;
|
|
1073
|
+
if (hours > 0) {
|
|
1074
|
+
return `${hours}:${String(mins).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
|
|
1075
|
+
}
|
|
1076
|
+
return `${String(mins).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1043
1079
|
// src/types/storage.ts
|
|
1044
1080
|
var KNOWN_OUTPUT_TYPES = [
|
|
1045
1081
|
"segment",
|
|
@@ -1084,8 +1120,123 @@ function notebookSlugFromId(slugOrId) {
|
|
|
1084
1120
|
function toNotebookId(slugOrId) {
|
|
1085
1121
|
return `notebook/${notebookSlugFromId(slugOrId)}`;
|
|
1086
1122
|
}
|
|
1123
|
+
function hasExplicitSystemOrFeedStamp(note, feedSourceId, isRemotePreview) {
|
|
1124
|
+
return Boolean(
|
|
1125
|
+
note.seedOrigin === "seed" || note.feedOrigin === "feed" || isRemotePreview || note.retention === "cached" || note.retention === "session-pinned" || feedSourceId || note.seedChunkId || note.sourcePath?.startsWith("markdown/") || note.sourceId?.startsWith("notebook:") || note.sourceId?.startsWith("guides:") || note.sourceId === "efforts" || note.sourceId === "equipment" || note.sourceId === "dashboards" || note.notebookId?.trim() && isSystemReadOnlyNotebook(note.notebookId) || note.notebookIds?.some((id) => Boolean(id?.trim()) && isSystemReadOnlyNotebook(id))
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
function isUserLocalJournalOrPlayground(note) {
|
|
1129
|
+
return Boolean(
|
|
1130
|
+
(note.type === "journal" || note.type === "playground") && note.seedOrigin !== "seed" && note.feedOrigin !== "feed" && !note.retention && !note.id?.startsWith("remote:") && !note.feedSourceId && !(note.notebookId?.trim() && isSystemReadOnlyNotebook(note.notebookId)) && !note.notebookIds?.some((id) => Boolean(id?.trim()) && isSystemReadOnlyNotebook(id))
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
function inferSourceNotebookId(note, resolvedNotebookId) {
|
|
1134
|
+
if (note.provenance?.sourceNotebookId?.trim()) {
|
|
1135
|
+
return toNotebookId(note.provenance.sourceNotebookId);
|
|
1136
|
+
}
|
|
1137
|
+
if (note.sourceNotebookId?.trim()) {
|
|
1138
|
+
return toNotebookId(note.sourceNotebookId);
|
|
1139
|
+
}
|
|
1140
|
+
if (resolvedNotebookId?.trim()) {
|
|
1141
|
+
return toNotebookId(resolvedNotebookId);
|
|
1142
|
+
}
|
|
1143
|
+
if (note.notebookId?.trim()) {
|
|
1144
|
+
return toNotebookId(note.notebookId);
|
|
1145
|
+
}
|
|
1146
|
+
if (isUserLocalJournalOrPlayground(note)) {
|
|
1147
|
+
return note.type === "playground" ? "notebook/playground" : "notebook/journal";
|
|
1148
|
+
}
|
|
1149
|
+
if (note.sourceId?.startsWith("notebook:")) {
|
|
1150
|
+
const rest = note.sourceId.slice("notebook:".length);
|
|
1151
|
+
const slug = rest.split("/")[0];
|
|
1152
|
+
if (slug && slug !== "_root") return toNotebookId(slug);
|
|
1153
|
+
}
|
|
1154
|
+
if (note.sourceId?.startsWith("guides:")) return "notebook/guides";
|
|
1155
|
+
if (note.sourceId === "efforts") return "notebook/efforts";
|
|
1156
|
+
if (note.sourceId === "equipment") return "notebook/equipment";
|
|
1157
|
+
if (note.sourceId === "dashboards") return "notebook/dashboards";
|
|
1158
|
+
if (note.sourcePath) {
|
|
1159
|
+
const nbMatch = /^markdown\/notebooks\/([^/]+)\//.exec(note.sourcePath);
|
|
1160
|
+
if (nbMatch?.[1]) return toNotebookId(nbMatch[1]);
|
|
1161
|
+
if (note.sourcePath.startsWith("markdown/efforts/")) return "notebook/efforts";
|
|
1162
|
+
if (note.sourcePath.startsWith("markdown/equipment/")) return "notebook/equipment";
|
|
1163
|
+
if (note.sourcePath.startsWith("markdown/dashboards/")) return "notebook/dashboards";
|
|
1164
|
+
if (note.sourcePath.startsWith("markdown/canvas/")) return "notebook/guides";
|
|
1165
|
+
}
|
|
1166
|
+
if (note.seedChunkId?.startsWith("notebook.")) {
|
|
1167
|
+
const slug = note.seedChunkId.slice("notebook.".length);
|
|
1168
|
+
if (slug && slug !== "_root") return toNotebookId(slug);
|
|
1169
|
+
}
|
|
1170
|
+
if (note.seedChunkId === "efforts") return "notebook/efforts";
|
|
1171
|
+
if (note.seedChunkId === "equipment") return "notebook/equipment";
|
|
1172
|
+
if (note.seedChunkId === "dashboards") return "notebook/dashboards";
|
|
1173
|
+
if (note.seedChunkId === "canvas") return "notebook/guides";
|
|
1174
|
+
if (note.notebookIds?.length) {
|
|
1175
|
+
const nonDefault = note.notebookIds.map((id) => id.trim()).filter(Boolean).map((id) => toNotebookId(id)).find((id) => id !== "notebook/journal" && id !== "notebook/playground");
|
|
1176
|
+
return nonDefault ?? toNotebookId(note.notebookIds[0]);
|
|
1177
|
+
}
|
|
1178
|
+
return void 0;
|
|
1179
|
+
}
|
|
1180
|
+
function resolveNoteOwnership(note, notebookOrigin, resolvedNotebookId) {
|
|
1181
|
+
const feedSourceId = note.feedSourceId?.trim() || note.provenance?.feedSourceId?.trim() || void 0;
|
|
1182
|
+
const localDefaultNb = isUserLocalJournalOrPlayground(note) ? note.type === "playground" ? "notebook/playground" : "notebook/journal" : void 0;
|
|
1183
|
+
const sourceNotebookId = inferSourceNotebookId(note, resolvedNotebookId);
|
|
1184
|
+
const targetNb = resolvedNotebookId?.trim() ? toNotebookId(resolvedNotebookId) : note.notebookId?.trim() ? toNotebookId(note.notebookId) : localDefaultNb ?? sourceNotebookId;
|
|
1185
|
+
const isRemotePreview = Boolean(note.id?.startsWith("remote:")) || note.retention === "indexed";
|
|
1186
|
+
const hasFeedStamp = note.feedOrigin === "feed" || note.seedOrigin === "seed" || isRemotePreview;
|
|
1187
|
+
const isArchivedExternal = (note.upstreamStatus === "unsubscribed" || note.upstreamStatus === "removed") && (hasFeedStamp || note.retention === "session-pinned" || note.retention === "schedule-pinned" || Boolean(feedSourceId));
|
|
1188
|
+
const isSystemNb = Boolean(targetNb && isSystemReadOnlyNotebook(targetNb));
|
|
1189
|
+
const isUserForkInUserNb = note.seedOrigin === "user" && note.feedOrigin !== "feed" && !isRemotePreview && note.retention !== "session-pinned" && note.retention !== "schedule-pinned" && note.retention !== "cached";
|
|
1190
|
+
const isIntrinsicUserDashboard = note.type === "dashboard" && !hasExplicitSystemOrFeedStamp(note, feedSourceId, isRemotePreview) && (targetNb === "notebook/dashboards" || !targetNb);
|
|
1191
|
+
let kind;
|
|
1192
|
+
if (isArchivedExternal) {
|
|
1193
|
+
kind = "feed-archived";
|
|
1194
|
+
} else if (isIntrinsicUserDashboard) {
|
|
1195
|
+
kind = "user";
|
|
1196
|
+
} else if (isRemotePreview) {
|
|
1197
|
+
kind = isSystemNb && (!feedSourceId || feedSourceId === "core") ? "system" : "feed";
|
|
1198
|
+
} else if (isSystemNb && (!feedSourceId || feedSourceId === "core") && !(notebookOrigin === "user" && isUserForkInUserNb)) {
|
|
1199
|
+
kind = "system";
|
|
1200
|
+
} else if (hasFeedStamp || notebookOrigin === "feed") {
|
|
1201
|
+
kind = isSystemNb && (!feedSourceId || feedSourceId === "core") ? "system" : "feed";
|
|
1202
|
+
} else if (isSystemNb) {
|
|
1203
|
+
kind = "system";
|
|
1204
|
+
} else {
|
|
1205
|
+
kind = "user";
|
|
1206
|
+
}
|
|
1207
|
+
const editable = kind === "user";
|
|
1208
|
+
let canPublish = false;
|
|
1209
|
+
if (kind === "user") {
|
|
1210
|
+
const candidateNotebooks = [];
|
|
1211
|
+
if (resolvedNotebookId?.trim()) candidateNotebooks.push(toNotebookId(resolvedNotebookId));
|
|
1212
|
+
if (note.notebookId?.trim()) candidateNotebooks.push(toNotebookId(note.notebookId));
|
|
1213
|
+
for (const id of note.notebookIds ?? []) {
|
|
1214
|
+
if (id?.trim()) candidateNotebooks.push(toNotebookId(id));
|
|
1215
|
+
}
|
|
1216
|
+
canPublish = candidateNotebooks.some((nb) => !isNonPublishableNotebook(nb));
|
|
1217
|
+
}
|
|
1218
|
+
const upstreamStatus = note.upstreamStatus ?? (kind === "feed" ? "live" : void 0);
|
|
1219
|
+
return {
|
|
1220
|
+
kind,
|
|
1221
|
+
editable,
|
|
1222
|
+
canPublish,
|
|
1223
|
+
...feedSourceId ? { feedSourceId } : {},
|
|
1224
|
+
...sourceNotebookId ? { sourceNotebookId } : {},
|
|
1225
|
+
...upstreamStatus ? { upstreamStatus } : {}
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1087
1228
|
function isNoteEditable(note, notebookOrigin, resolvedNotebookId) {
|
|
1229
|
+
const isRemotePreview = Boolean(note.id?.startsWith("remote:")) || note.retention === "indexed";
|
|
1230
|
+
if (isRemotePreview) return false;
|
|
1231
|
+
if (note.upstreamStatus === "unsubscribed" || note.upstreamStatus === "removed") return false;
|
|
1232
|
+
if (note.retention === "session-pinned" && (note.seedOrigin === "seed" || note.feedOrigin === "feed")) {
|
|
1233
|
+
return false;
|
|
1234
|
+
}
|
|
1235
|
+
const feedSourceId = note.feedSourceId?.trim() || note.provenance?.feedSourceId?.trim() || void 0;
|
|
1088
1236
|
const targetNb = resolvedNotebookId ?? note.notebookId ?? void 0;
|
|
1237
|
+
if (note.type === "dashboard" && !hasExplicitSystemOrFeedStamp(note, feedSourceId, isRemotePreview) && (targetNb === "notebook/dashboards" || !targetNb)) {
|
|
1238
|
+
return true;
|
|
1239
|
+
}
|
|
1089
1240
|
if (targetNb && isSystemReadOnlyNotebook(targetNb)) return false;
|
|
1090
1241
|
if (notebookOrigin) return notebookOrigin !== "feed";
|
|
1091
1242
|
return note.seedOrigin !== "seed" && note.feedOrigin !== "feed";
|
|
@@ -1178,6 +1329,58 @@ var NOTEBOOK_TAG_PREFIX = "notebook:";
|
|
|
1178
1329
|
var toNotebookTag = (notebookId) => `${NOTEBOOK_TAG_PREFIX}${notebookId}`;
|
|
1179
1330
|
var fromNotebookTag = (tag) => tag.startsWith(NOTEBOOK_TAG_PREFIX) ? tag.slice(NOTEBOOK_TAG_PREFIX.length) : null;
|
|
1180
1331
|
var isNotebookTag = (tag) => tag.startsWith(NOTEBOOK_TAG_PREFIX);
|
|
1332
|
+
function isNotebookLanding(note) {
|
|
1333
|
+
return note.id.startsWith("notebook/") && note.notebookId === note.id;
|
|
1334
|
+
}
|
|
1335
|
+
function getNotebookCapabilities(input) {
|
|
1336
|
+
const raw = input.slug ?? input.notebookId ?? input.id ?? "";
|
|
1337
|
+
const slug = notebookSlugFromId(raw);
|
|
1338
|
+
const isBuiltIn = BUILTIN_NOTEBOOKS.some((b) => b.slug === slug);
|
|
1339
|
+
const isSystem = isSystemReadOnlyNotebook(slug);
|
|
1340
|
+
const isUserOrigin = input.origin === "user" || !input.origin && input.feedId === "local";
|
|
1341
|
+
return {
|
|
1342
|
+
slug,
|
|
1343
|
+
isBuiltIn,
|
|
1344
|
+
isSystem,
|
|
1345
|
+
canEdit: isUserOrigin && !isBuiltIn && !isSystem,
|
|
1346
|
+
canDelete: isUserOrigin && !isBuiltIn && !isSystem,
|
|
1347
|
+
canTogglePublic: isUserOrigin && !isNonPublishableNotebook(slug)
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
function countNotesByNotebook(notes, links = [], resolveIds) {
|
|
1351
|
+
const membership = /* @__PURE__ */ new Map();
|
|
1352
|
+
const landingIds = /* @__PURE__ */ new Set();
|
|
1353
|
+
for (const n of notes) {
|
|
1354
|
+
if (isNotebookLanding(n)) landingIds.add(n.id);
|
|
1355
|
+
}
|
|
1356
|
+
const addMember = (rawNbId, noteId) => {
|
|
1357
|
+
if (!rawNbId || !noteId || landingIds.has(noteId)) return;
|
|
1358
|
+
const nbId = toNotebookId(rawNbId);
|
|
1359
|
+
let set = membership.get(nbId);
|
|
1360
|
+
if (!set) {
|
|
1361
|
+
set = /* @__PURE__ */ new Set();
|
|
1362
|
+
membership.set(nbId, set);
|
|
1363
|
+
}
|
|
1364
|
+
set.add(noteId);
|
|
1365
|
+
};
|
|
1366
|
+
for (const link of links) {
|
|
1367
|
+
if (link.targetKind && link.targetKind !== "note") continue;
|
|
1368
|
+
const targetId = link.targetId ?? link.noteId;
|
|
1369
|
+
if (targetId) addMember(link.notebookId, targetId);
|
|
1370
|
+
}
|
|
1371
|
+
for (const note of notes) {
|
|
1372
|
+
if (isNotebookLanding(note)) continue;
|
|
1373
|
+
const ids = resolveIds ? resolveIds(note) : [note.notebookId, ...note.notebookIds ?? []].filter((v) => Boolean(v));
|
|
1374
|
+
for (const nbId of ids) {
|
|
1375
|
+
addMember(nbId, note.id);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
const counts = /* @__PURE__ */ new Map();
|
|
1379
|
+
for (const [nbId, set] of membership) {
|
|
1380
|
+
counts.set(nbId, set.size);
|
|
1381
|
+
}
|
|
1382
|
+
return counts;
|
|
1383
|
+
}
|
|
1181
1384
|
|
|
1182
1385
|
// src/sections/sectionParser.ts
|
|
1183
1386
|
var KNOWN_SECTION_WIDGETS = ["playground-run-tip", "attention", "code-example", "syntax-group"];
|
|
@@ -1777,13 +1980,13 @@ function parseFrontmatterProps(lines) {
|
|
|
1777
1980
|
}
|
|
1778
1981
|
|
|
1779
1982
|
// src/version.ts
|
|
1780
|
-
var VERSION = "0.
|
|
1781
|
-
var GIT_SHA = "
|
|
1782
|
-
var BUILD_TIME = "2026-11-
|
|
1983
|
+
var VERSION = "0.62.2260";
|
|
1984
|
+
var GIT_SHA = "d3581b3";
|
|
1985
|
+
var BUILD_TIME = "2026-11-23T01:01:07.332Z";
|
|
1783
1986
|
var SEMVER = {
|
|
1784
|
-
version: "0.
|
|
1785
|
-
gitSha: "
|
|
1786
|
-
buildTime: "2026-11-
|
|
1987
|
+
version: "0.62.2260",
|
|
1988
|
+
gitSha: "d3581b3",
|
|
1989
|
+
buildTime: "2026-11-23T01:01:07.332Z"
|
|
1787
1990
|
};
|
|
1788
1991
|
|
|
1789
1992
|
// src/portability/note-jsonl.ts
|
|
@@ -1803,10 +2006,10 @@ function hasValidOrigin(value) {
|
|
|
1803
2006
|
return value === void 0 || value === "journal" || value === "playground" || value === "user";
|
|
1804
2007
|
}
|
|
1805
2008
|
function validNote(value) {
|
|
1806
|
-
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");
|
|
2009
|
+
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") && (value.notebookIds === void 0 || Array.isArray(value.notebookIds) && value.notebookIds.every((id) => typeof id === "string"));
|
|
1807
2010
|
}
|
|
1808
2011
|
function validSession(value) {
|
|
1809
|
-
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);
|
|
2012
|
+
return isString(value.id) && isString(value.noteId) && isString(value.blockId) && isPositiveInteger(value.blockVersion) && isString(value.blockContentId) && (value.noteSourceRevision === void 0 || isPositiveInteger(value.noteSourceRevision)) && (value.sessionDate === void 0 || isString(value.sessionDate)) && (value.scheduleItemId === void 0 || isString(value.scheduleItemId)) && (value.pageId === void 0 || typeof value.pageId === "string") && 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);
|
|
1810
2013
|
}
|
|
1811
2014
|
function validParseRecord(value) {
|
|
1812
2015
|
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));
|
|
@@ -1817,6 +2020,15 @@ function validEvent(value) {
|
|
|
1817
2020
|
function validRevision(value) {
|
|
1818
2021
|
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");
|
|
1819
2022
|
}
|
|
2023
|
+
function validNoteRevision(value) {
|
|
2024
|
+
return isString(value.noteId) && isPositiveInteger(value.version) && typeof value.title === "string" && typeof value.rawContent === "string" && isObject(value.blocks) && isFiniteNumber(value.savedAt) && (value.tags === void 0 || Array.isArray(value.tags) && value.tags.every((tag) => typeof tag === "string")) && (value.notebookIds === void 0 || Array.isArray(value.notebookIds) && value.notebookIds.every((id) => typeof id === "string")) && (value.type === void 0 || typeof value.type === "string");
|
|
2025
|
+
}
|
|
2026
|
+
function validScheduleItem(value) {
|
|
2027
|
+
return isString(value.id) && isString(value.date) && isString(value.noteId) && isFiniteNumber(value.position) && (value.status === "planned" || value.status === "completed" || value.status === "skipped" || value.status === "moved") && isFiniteNumber(value.createdAt) && isFiniteNumber(value.updatedAt) && (value.pageId === void 0 || typeof value.pageId === "string") && (value.sourceNotebookId === void 0 || typeof value.sourceNotebookId === "string") && (value.fallbackTitle === void 0 || typeof value.fallbackTitle === "string") && (value.blockId === void 0 || typeof value.blockId === "string") && (value.slot === void 0 || typeof value.slot === "string") && (value.notes === void 0 || typeof value.notes === "string") && (value.movedFromDate === void 0 || typeof value.movedFromDate === "string");
|
|
2028
|
+
}
|
|
2029
|
+
function validNotebookLink(value) {
|
|
2030
|
+
return isString(value.id) && isString(value.notebookId) && (value.targetKind === "note" || value.targetKind === "session") && isString(value.targetId) && isString(value.noteId) && isFiniteNumber(value.createdAt);
|
|
2031
|
+
}
|
|
1820
2032
|
function revisionToJsonl(revision) {
|
|
1821
2033
|
const { kind: blockKind, ...identity } = revision;
|
|
1822
2034
|
return { kind: "revision", blockKind, ...identity };
|
|
@@ -1824,7 +2036,10 @@ function revisionToJsonl(revision) {
|
|
|
1824
2036
|
function serializeNoteBundleToJsonl(bundle) {
|
|
1825
2037
|
const records = [
|
|
1826
2038
|
...bundle.note ? [{ kind: "note", ...bundle.note }] : [],
|
|
2039
|
+
...(bundle.noteRevisions ?? []).map((rev) => ({ kind: "note_revision", ...rev })),
|
|
1827
2040
|
...(bundle.revisions ?? []).map(revisionToJsonl),
|
|
2041
|
+
...(bundle.notebookLinks ?? []).map((link) => ({ kind: "notebook_link", ...link })),
|
|
2042
|
+
...(bundle.scheduleItems ?? []).map((item) => ({ kind: "schedule_item", ...item })),
|
|
1828
2043
|
...(bundle.parses ?? []).map((parse) => ({ kind: "parse", ...parse })),
|
|
1829
2044
|
...bundle.sessions.map((session) => ({ kind: "session", ...session })),
|
|
1830
2045
|
...bundle.events.map((event) => ({ kind: "event", ...event }))
|
|
@@ -1834,7 +2049,10 @@ function serializeNoteBundleToJsonl(bundle) {
|
|
|
1834
2049
|
async function* streamNoteBundleToJsonlLines(bundles) {
|
|
1835
2050
|
for await (const bundle of bundles) {
|
|
1836
2051
|
if (bundle.note) yield JSON.stringify({ kind: "note", ...bundle.note });
|
|
2052
|
+
for (const noteRevision of bundle.noteRevisions ?? []) yield JSON.stringify({ kind: "note_revision", ...noteRevision });
|
|
1837
2053
|
for (const revision of bundle.revisions ?? []) yield JSON.stringify(revisionToJsonl(revision));
|
|
2054
|
+
for (const link of bundle.notebookLinks ?? []) yield JSON.stringify({ kind: "notebook_link", ...link });
|
|
2055
|
+
for (const item of bundle.scheduleItems ?? []) yield JSON.stringify({ kind: "schedule_item", ...item });
|
|
1838
2056
|
for (const parse of bundle.parses ?? []) yield JSON.stringify({ kind: "parse", ...parse });
|
|
1839
2057
|
for (const session of bundle.sessions) yield JSON.stringify({ kind: "session", ...session });
|
|
1840
2058
|
for (const event of bundle.events) yield JSON.stringify({ kind: "event", ...event });
|
|
@@ -1881,6 +2099,27 @@ function parseNoteBundleFromJsonl(jsonlText) {
|
|
|
1881
2099
|
const { blockKind, ...identity } = value;
|
|
1882
2100
|
const revision = { ...identity, kind: blockKind };
|
|
1883
2101
|
(bundleFor(revision.noteId).revisions ??= []).push(revision);
|
|
2102
|
+
} else if (kind === "note_revision") {
|
|
2103
|
+
if (!validNoteRevision(value)) {
|
|
2104
|
+
errors.push(`Line ${lineNumber}: invalid note_revision record`);
|
|
2105
|
+
continue;
|
|
2106
|
+
}
|
|
2107
|
+
const noteRevision = value;
|
|
2108
|
+
(bundleFor(noteRevision.noteId).noteRevisions ??= []).push(noteRevision);
|
|
2109
|
+
} else if (kind === "schedule_item") {
|
|
2110
|
+
if (!validScheduleItem(value)) {
|
|
2111
|
+
errors.push(`Line ${lineNumber}: invalid schedule_item record`);
|
|
2112
|
+
continue;
|
|
2113
|
+
}
|
|
2114
|
+
const scheduleItem = value;
|
|
2115
|
+
(bundleFor(scheduleItem.noteId).scheduleItems ??= []).push(scheduleItem);
|
|
2116
|
+
} else if (kind === "notebook_link") {
|
|
2117
|
+
if (!validNotebookLink(value)) {
|
|
2118
|
+
errors.push(`Line ${lineNumber}: invalid notebook_link record`);
|
|
2119
|
+
continue;
|
|
2120
|
+
}
|
|
2121
|
+
const link = value;
|
|
2122
|
+
(bundleFor(link.noteId).notebookLinks ??= []).push(link);
|
|
1884
2123
|
} else if (kind === "session") {
|
|
1885
2124
|
if (!validSession(value)) {
|
|
1886
2125
|
errors.push(`Line ${lineNumber}: invalid session record`);
|
|
@@ -1922,15 +2161,28 @@ function parseNoteBundleFromJsonl(jsonlText) {
|
|
|
1922
2161
|
|
|
1923
2162
|
// src/publication.ts
|
|
1924
2163
|
function isPublishableNotebookLanding(note) {
|
|
1925
|
-
return note.id.startsWith("notebook/") && note.notebookId === note.id && !isNonPublishableNotebook(note.id) && note.
|
|
2164
|
+
return note.id.startsWith("notebook/") && note.notebookId === note.id && !isNonPublishableNotebook(note.id) && resolveNoteOwnership(note).kind === "user";
|
|
2165
|
+
}
|
|
2166
|
+
function derivePublicationStatusLabel(visibility, ownership) {
|
|
2167
|
+
if (!ownership || ownership.kind === "user") return visibility;
|
|
2168
|
+
if (ownership.kind === "feed") return "Subscribed Feed";
|
|
2169
|
+
if (ownership.kind === "feed-archived") return "Archived Feed";
|
|
2170
|
+
return "System";
|
|
1926
2171
|
}
|
|
1927
2172
|
function derivePublicationVisibility(input) {
|
|
1928
|
-
const
|
|
1929
|
-
const
|
|
2173
|
+
const ownership = input.ownership ?? (input.note ? resolveNoteOwnership(input.note, void 0, input.notebookId) : void 0);
|
|
2174
|
+
const nonOwned = Boolean(ownership && ownership.kind !== "user");
|
|
2175
|
+
const notebookPublic = nonOwned ? false : input.notebookPublic === true;
|
|
2176
|
+
const publicSessions = nonOwned ? 0 : Math.max(0, Math.trunc(input.publicSessions));
|
|
1930
2177
|
const totalSessions = Math.max(publicSessions, Math.trunc(input.totalSessions));
|
|
1931
2178
|
const visibility = !notebookPublic ? "Private" : publicSessions > 0 ? "Published Note + Data" : "Published Note";
|
|
2179
|
+
const displayLabel = derivePublicationStatusLabel(visibility, ownership);
|
|
2180
|
+
const canPublish = ownership ? ownership.canPublish : !nonOwned;
|
|
1932
2181
|
return {
|
|
1933
2182
|
visibility,
|
|
2183
|
+
displayLabel,
|
|
2184
|
+
...ownership ? { ownership } : {},
|
|
2185
|
+
canPublish,
|
|
1934
2186
|
notebookPublic,
|
|
1935
2187
|
publicSessions,
|
|
1936
2188
|
totalSessions,
|
|
@@ -1974,8 +2226,10 @@ exports.buildRawContent = buildRawContent;
|
|
|
1974
2226
|
exports.calculateTotalLines = calculateTotalLines;
|
|
1975
2227
|
exports.comparePlacements = comparePlacements;
|
|
1976
2228
|
exports.convertViaCatalog = convertViaCatalog;
|
|
2229
|
+
exports.countNotesByNotebook = countNotesByNotebook;
|
|
1977
2230
|
exports.createMetricOwnershipLedger = createMetricOwnershipLedger;
|
|
1978
2231
|
exports.createTagIndex = createTagIndex;
|
|
2232
|
+
exports.derivePublicationStatusLabel = derivePublicationStatusLabel;
|
|
1979
2233
|
exports.derivePublicationVisibility = derivePublicationVisibility;
|
|
1980
2234
|
exports.detectScriptBlocks = detectScriptBlocks;
|
|
1981
2235
|
exports.dimensionKeyOf = dimensionKeyOf;
|
|
@@ -1986,14 +2240,17 @@ exports.fieldRefFromKey = fieldRefFromKey;
|
|
|
1986
2240
|
exports.fieldRefKey = fieldRefKey;
|
|
1987
2241
|
exports.findBlockAtLine = findBlockAtLine;
|
|
1988
2242
|
exports.flattenFieldLeaves = flattenFieldLeaves;
|
|
2243
|
+
exports.formatDurationMMSS = formatDurationMMSS;
|
|
1989
2244
|
exports.fromNotebookTag = fromNotebookTag;
|
|
1990
2245
|
exports.getList = getList;
|
|
1991
2246
|
exports.getMetricOwnershipLayer = getMetricOwnershipLayer;
|
|
2247
|
+
exports.getNotebookCapabilities = getNotebookCapabilities;
|
|
1992
2248
|
exports.getReferenceMetadata = getReferenceMetadata;
|
|
1993
2249
|
exports.getScalar = getScalar;
|
|
1994
2250
|
exports.getTagReference = getTagReference;
|
|
1995
2251
|
exports.isNonPublishableNotebook = isNonPublishableNotebook;
|
|
1996
2252
|
exports.isNoteEditable = isNoteEditable;
|
|
2253
|
+
exports.isNotebookLanding = isNotebookLanding;
|
|
1997
2254
|
exports.isNotebookTag = isNotebookTag;
|
|
1998
2255
|
exports.isPublishableNotebookLanding = isPublishableNotebookLanding;
|
|
1999
2256
|
exports.isSystemReadOnlyNotebook = isSystemReadOnlyNotebook;
|
|
@@ -2001,6 +2258,7 @@ exports.isWorkoutSectionType = isWorkoutSectionType;
|
|
|
2001
2258
|
exports.lookupUnit = lookupUnit;
|
|
2002
2259
|
exports.mapNoteBlockChanges = mapNoteBlockChanges;
|
|
2003
2260
|
exports.matchDialectFence = matchDialectFence;
|
|
2261
|
+
exports.metricToMs = metricToMs;
|
|
2004
2262
|
exports.normalizeFieldComponent = normalizeFieldComponent;
|
|
2005
2263
|
exports.normalizeFieldPath = normalizeFieldPath;
|
|
2006
2264
|
exports.notebookSlugFromId = notebookSlugFromId;
|
|
@@ -2017,6 +2275,7 @@ exports.patchFrontmatterProperty = patchFrontmatterProperty;
|
|
|
2017
2275
|
exports.projectPlacements = projectPlacements;
|
|
2018
2276
|
exports.reconcileNoteBlocks = reconcileNoteBlocks;
|
|
2019
2277
|
exports.resolveLayer = resolveLayer;
|
|
2278
|
+
exports.resolveNoteOwnership = resolveNoteOwnership;
|
|
2020
2279
|
exports.resolvePlacements = resolvePlacements;
|
|
2021
2280
|
exports.runAffordance = runAffordance;
|
|
2022
2281
|
exports.serializeFrontmatter = serializeFrontmatter;
|