@bitcobblers/wod-wiki-core 0.61.2259 → 0.62.2261
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.mjs
CHANGED
|
@@ -1038,6 +1038,42 @@ function projectPlacements(placements) {
|
|
|
1038
1038
|
return projection;
|
|
1039
1039
|
}
|
|
1040
1040
|
|
|
1041
|
+
// src/models/timeFormatting.ts
|
|
1042
|
+
var TIME_METRIC_TYPES = /* @__PURE__ */ new Set(["duration", "elapsed", "total", "time"]);
|
|
1043
|
+
function metricToMs(metric) {
|
|
1044
|
+
if (typeof metric.value !== "number" || !Number.isFinite(metric.value)) {
|
|
1045
|
+
return void 0;
|
|
1046
|
+
}
|
|
1047
|
+
const unit = metric.unit?.trim().toLowerCase();
|
|
1048
|
+
if (unit === "ms" || unit === "millisecond" || unit === "milliseconds") {
|
|
1049
|
+
return metric.value;
|
|
1050
|
+
}
|
|
1051
|
+
if (unit === "s" || unit === "sec" || unit === "secs" || unit === "second" || unit === "seconds") {
|
|
1052
|
+
return metric.value * 1e3;
|
|
1053
|
+
}
|
|
1054
|
+
if (unit === "min" || unit === "m" || unit === "mins" || unit === "minute" || unit === "minutes") {
|
|
1055
|
+
return metric.value * 6e4;
|
|
1056
|
+
}
|
|
1057
|
+
if (unit === "h" || unit === "hr" || unit === "hrs" || unit === "hour" || unit === "hours") {
|
|
1058
|
+
return metric.value * 36e5;
|
|
1059
|
+
}
|
|
1060
|
+
if (!unit && TIME_METRIC_TYPES.has(String(metric.type ?? "").toLowerCase())) {
|
|
1061
|
+
return metric.value;
|
|
1062
|
+
}
|
|
1063
|
+
return metric.value;
|
|
1064
|
+
}
|
|
1065
|
+
function formatDurationMMSS(ms) {
|
|
1066
|
+
if (!Number.isFinite(ms) || ms <= 0) return "00:00";
|
|
1067
|
+
const totalSec = Math.round(ms / 1e3);
|
|
1068
|
+
const hours = Math.floor(totalSec / 3600);
|
|
1069
|
+
const mins = Math.floor(totalSec % 3600 / 60);
|
|
1070
|
+
const secs = totalSec % 60;
|
|
1071
|
+
if (hours > 0) {
|
|
1072
|
+
return `${hours}:${String(mins).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
|
|
1073
|
+
}
|
|
1074
|
+
return `${String(mins).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1041
1077
|
// src/types/storage.ts
|
|
1042
1078
|
var KNOWN_OUTPUT_TYPES = [
|
|
1043
1079
|
"segment",
|
|
@@ -1082,8 +1118,123 @@ function notebookSlugFromId(slugOrId) {
|
|
|
1082
1118
|
function toNotebookId(slugOrId) {
|
|
1083
1119
|
return `notebook/${notebookSlugFromId(slugOrId)}`;
|
|
1084
1120
|
}
|
|
1121
|
+
function hasExplicitSystemOrFeedStamp(note, feedSourceId, isRemotePreview) {
|
|
1122
|
+
return Boolean(
|
|
1123
|
+
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))
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
function isUserLocalJournalOrPlayground(note) {
|
|
1127
|
+
return Boolean(
|
|
1128
|
+
(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))
|
|
1129
|
+
);
|
|
1130
|
+
}
|
|
1131
|
+
function inferSourceNotebookId(note, resolvedNotebookId) {
|
|
1132
|
+
if (note.provenance?.sourceNotebookId?.trim()) {
|
|
1133
|
+
return toNotebookId(note.provenance.sourceNotebookId);
|
|
1134
|
+
}
|
|
1135
|
+
if (note.sourceNotebookId?.trim()) {
|
|
1136
|
+
return toNotebookId(note.sourceNotebookId);
|
|
1137
|
+
}
|
|
1138
|
+
if (resolvedNotebookId?.trim()) {
|
|
1139
|
+
return toNotebookId(resolvedNotebookId);
|
|
1140
|
+
}
|
|
1141
|
+
if (note.notebookId?.trim()) {
|
|
1142
|
+
return toNotebookId(note.notebookId);
|
|
1143
|
+
}
|
|
1144
|
+
if (isUserLocalJournalOrPlayground(note)) {
|
|
1145
|
+
return note.type === "playground" ? "notebook/playground" : "notebook/journal";
|
|
1146
|
+
}
|
|
1147
|
+
if (note.sourceId?.startsWith("notebook:")) {
|
|
1148
|
+
const rest = note.sourceId.slice("notebook:".length);
|
|
1149
|
+
const slug = rest.split("/")[0];
|
|
1150
|
+
if (slug && slug !== "_root") return toNotebookId(slug);
|
|
1151
|
+
}
|
|
1152
|
+
if (note.sourceId?.startsWith("guides:")) return "notebook/guides";
|
|
1153
|
+
if (note.sourceId === "efforts") return "notebook/efforts";
|
|
1154
|
+
if (note.sourceId === "equipment") return "notebook/equipment";
|
|
1155
|
+
if (note.sourceId === "dashboards") return "notebook/dashboards";
|
|
1156
|
+
if (note.sourcePath) {
|
|
1157
|
+
const nbMatch = /^markdown\/notebooks\/([^/]+)\//.exec(note.sourcePath);
|
|
1158
|
+
if (nbMatch?.[1]) return toNotebookId(nbMatch[1]);
|
|
1159
|
+
if (note.sourcePath.startsWith("markdown/efforts/")) return "notebook/efforts";
|
|
1160
|
+
if (note.sourcePath.startsWith("markdown/equipment/")) return "notebook/equipment";
|
|
1161
|
+
if (note.sourcePath.startsWith("markdown/dashboards/")) return "notebook/dashboards";
|
|
1162
|
+
if (note.sourcePath.startsWith("markdown/canvas/")) return "notebook/guides";
|
|
1163
|
+
}
|
|
1164
|
+
if (note.seedChunkId?.startsWith("notebook.")) {
|
|
1165
|
+
const slug = note.seedChunkId.slice("notebook.".length);
|
|
1166
|
+
if (slug && slug !== "_root") return toNotebookId(slug);
|
|
1167
|
+
}
|
|
1168
|
+
if (note.seedChunkId === "efforts") return "notebook/efforts";
|
|
1169
|
+
if (note.seedChunkId === "equipment") return "notebook/equipment";
|
|
1170
|
+
if (note.seedChunkId === "dashboards") return "notebook/dashboards";
|
|
1171
|
+
if (note.seedChunkId === "canvas") return "notebook/guides";
|
|
1172
|
+
if (note.notebookIds?.length) {
|
|
1173
|
+
const nonDefault = note.notebookIds.map((id) => id.trim()).filter(Boolean).map((id) => toNotebookId(id)).find((id) => id !== "notebook/journal" && id !== "notebook/playground");
|
|
1174
|
+
return nonDefault ?? toNotebookId(note.notebookIds[0]);
|
|
1175
|
+
}
|
|
1176
|
+
return void 0;
|
|
1177
|
+
}
|
|
1178
|
+
function resolveNoteOwnership(note, notebookOrigin, resolvedNotebookId) {
|
|
1179
|
+
const feedSourceId = note.feedSourceId?.trim() || note.provenance?.feedSourceId?.trim() || void 0;
|
|
1180
|
+
const localDefaultNb = isUserLocalJournalOrPlayground(note) ? note.type === "playground" ? "notebook/playground" : "notebook/journal" : void 0;
|
|
1181
|
+
const sourceNotebookId = inferSourceNotebookId(note, resolvedNotebookId);
|
|
1182
|
+
const targetNb = resolvedNotebookId?.trim() ? toNotebookId(resolvedNotebookId) : note.notebookId?.trim() ? toNotebookId(note.notebookId) : localDefaultNb ?? sourceNotebookId;
|
|
1183
|
+
const isRemotePreview = Boolean(note.id?.startsWith("remote:")) || note.retention === "indexed";
|
|
1184
|
+
const hasFeedStamp = note.feedOrigin === "feed" || note.seedOrigin === "seed" || isRemotePreview;
|
|
1185
|
+
const isArchivedExternal = (note.upstreamStatus === "unsubscribed" || note.upstreamStatus === "removed") && (hasFeedStamp || note.retention === "session-pinned" || note.retention === "schedule-pinned" || Boolean(feedSourceId));
|
|
1186
|
+
const isSystemNb = Boolean(targetNb && isSystemReadOnlyNotebook(targetNb));
|
|
1187
|
+
const isUserForkInUserNb = note.seedOrigin === "user" && note.feedOrigin !== "feed" && !isRemotePreview && note.retention !== "session-pinned" && note.retention !== "schedule-pinned" && note.retention !== "cached";
|
|
1188
|
+
const isIntrinsicUserDashboard = note.type === "dashboard" && !hasExplicitSystemOrFeedStamp(note, feedSourceId, isRemotePreview) && (targetNb === "notebook/dashboards" || !targetNb);
|
|
1189
|
+
let kind;
|
|
1190
|
+
if (isArchivedExternal) {
|
|
1191
|
+
kind = "feed-archived";
|
|
1192
|
+
} else if (isIntrinsicUserDashboard) {
|
|
1193
|
+
kind = "user";
|
|
1194
|
+
} else if (isRemotePreview) {
|
|
1195
|
+
kind = isSystemNb && (!feedSourceId || feedSourceId === "core") ? "system" : "feed";
|
|
1196
|
+
} else if (isSystemNb && (!feedSourceId || feedSourceId === "core") && !(notebookOrigin === "user" && isUserForkInUserNb)) {
|
|
1197
|
+
kind = "system";
|
|
1198
|
+
} else if (hasFeedStamp || notebookOrigin === "feed") {
|
|
1199
|
+
kind = isSystemNb && (!feedSourceId || feedSourceId === "core") ? "system" : "feed";
|
|
1200
|
+
} else if (isSystemNb) {
|
|
1201
|
+
kind = "system";
|
|
1202
|
+
} else {
|
|
1203
|
+
kind = "user";
|
|
1204
|
+
}
|
|
1205
|
+
const editable = kind === "user";
|
|
1206
|
+
let canPublish = false;
|
|
1207
|
+
if (kind === "user") {
|
|
1208
|
+
const candidateNotebooks = [];
|
|
1209
|
+
if (resolvedNotebookId?.trim()) candidateNotebooks.push(toNotebookId(resolvedNotebookId));
|
|
1210
|
+
if (note.notebookId?.trim()) candidateNotebooks.push(toNotebookId(note.notebookId));
|
|
1211
|
+
for (const id of note.notebookIds ?? []) {
|
|
1212
|
+
if (id?.trim()) candidateNotebooks.push(toNotebookId(id));
|
|
1213
|
+
}
|
|
1214
|
+
canPublish = candidateNotebooks.some((nb) => !isNonPublishableNotebook(nb));
|
|
1215
|
+
}
|
|
1216
|
+
const upstreamStatus = note.upstreamStatus ?? (kind === "feed" ? "live" : void 0);
|
|
1217
|
+
return {
|
|
1218
|
+
kind,
|
|
1219
|
+
editable,
|
|
1220
|
+
canPublish,
|
|
1221
|
+
...feedSourceId ? { feedSourceId } : {},
|
|
1222
|
+
...sourceNotebookId ? { sourceNotebookId } : {},
|
|
1223
|
+
...upstreamStatus ? { upstreamStatus } : {}
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1085
1226
|
function isNoteEditable(note, notebookOrigin, resolvedNotebookId) {
|
|
1227
|
+
const isRemotePreview = Boolean(note.id?.startsWith("remote:")) || note.retention === "indexed";
|
|
1228
|
+
if (isRemotePreview) return false;
|
|
1229
|
+
if (note.upstreamStatus === "unsubscribed" || note.upstreamStatus === "removed") return false;
|
|
1230
|
+
if (note.retention === "session-pinned" && (note.seedOrigin === "seed" || note.feedOrigin === "feed")) {
|
|
1231
|
+
return false;
|
|
1232
|
+
}
|
|
1233
|
+
const feedSourceId = note.feedSourceId?.trim() || note.provenance?.feedSourceId?.trim() || void 0;
|
|
1086
1234
|
const targetNb = resolvedNotebookId ?? note.notebookId ?? void 0;
|
|
1235
|
+
if (note.type === "dashboard" && !hasExplicitSystemOrFeedStamp(note, feedSourceId, isRemotePreview) && (targetNb === "notebook/dashboards" || !targetNb)) {
|
|
1236
|
+
return true;
|
|
1237
|
+
}
|
|
1087
1238
|
if (targetNb && isSystemReadOnlyNotebook(targetNb)) return false;
|
|
1088
1239
|
if (notebookOrigin) return notebookOrigin !== "feed";
|
|
1089
1240
|
return note.seedOrigin !== "seed" && note.feedOrigin !== "feed";
|
|
@@ -1176,6 +1327,58 @@ var NOTEBOOK_TAG_PREFIX = "notebook:";
|
|
|
1176
1327
|
var toNotebookTag = (notebookId) => `${NOTEBOOK_TAG_PREFIX}${notebookId}`;
|
|
1177
1328
|
var fromNotebookTag = (tag) => tag.startsWith(NOTEBOOK_TAG_PREFIX) ? tag.slice(NOTEBOOK_TAG_PREFIX.length) : null;
|
|
1178
1329
|
var isNotebookTag = (tag) => tag.startsWith(NOTEBOOK_TAG_PREFIX);
|
|
1330
|
+
function isNotebookLanding(note) {
|
|
1331
|
+
return note.id.startsWith("notebook/") && note.notebookId === note.id;
|
|
1332
|
+
}
|
|
1333
|
+
function getNotebookCapabilities(input) {
|
|
1334
|
+
const raw = input.slug ?? input.notebookId ?? input.id ?? "";
|
|
1335
|
+
const slug = notebookSlugFromId(raw);
|
|
1336
|
+
const isBuiltIn = BUILTIN_NOTEBOOKS.some((b) => b.slug === slug);
|
|
1337
|
+
const isSystem = isSystemReadOnlyNotebook(slug);
|
|
1338
|
+
const isUserOrigin = input.origin === "user" || !input.origin && input.feedId === "local";
|
|
1339
|
+
return {
|
|
1340
|
+
slug,
|
|
1341
|
+
isBuiltIn,
|
|
1342
|
+
isSystem,
|
|
1343
|
+
canEdit: isUserOrigin && !isBuiltIn && !isSystem,
|
|
1344
|
+
canDelete: isUserOrigin && !isBuiltIn && !isSystem,
|
|
1345
|
+
canTogglePublic: isUserOrigin && !isNonPublishableNotebook(slug)
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
function countNotesByNotebook(notes, links = [], resolveIds) {
|
|
1349
|
+
const membership = /* @__PURE__ */ new Map();
|
|
1350
|
+
const landingIds = /* @__PURE__ */ new Set();
|
|
1351
|
+
for (const n of notes) {
|
|
1352
|
+
if (isNotebookLanding(n)) landingIds.add(n.id);
|
|
1353
|
+
}
|
|
1354
|
+
const addMember = (rawNbId, noteId) => {
|
|
1355
|
+
if (!rawNbId || !noteId || landingIds.has(noteId)) return;
|
|
1356
|
+
const nbId = toNotebookId(rawNbId);
|
|
1357
|
+
let set = membership.get(nbId);
|
|
1358
|
+
if (!set) {
|
|
1359
|
+
set = /* @__PURE__ */ new Set();
|
|
1360
|
+
membership.set(nbId, set);
|
|
1361
|
+
}
|
|
1362
|
+
set.add(noteId);
|
|
1363
|
+
};
|
|
1364
|
+
for (const link of links) {
|
|
1365
|
+
if (link.targetKind && link.targetKind !== "note") continue;
|
|
1366
|
+
const targetId = link.targetId ?? link.noteId;
|
|
1367
|
+
if (targetId) addMember(link.notebookId, targetId);
|
|
1368
|
+
}
|
|
1369
|
+
for (const note of notes) {
|
|
1370
|
+
if (isNotebookLanding(note)) continue;
|
|
1371
|
+
const ids = resolveIds ? resolveIds(note) : [note.notebookId, ...note.notebookIds ?? []].filter((v) => Boolean(v));
|
|
1372
|
+
for (const nbId of ids) {
|
|
1373
|
+
addMember(nbId, note.id);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
const counts = /* @__PURE__ */ new Map();
|
|
1377
|
+
for (const [nbId, set] of membership) {
|
|
1378
|
+
counts.set(nbId, set.size);
|
|
1379
|
+
}
|
|
1380
|
+
return counts;
|
|
1381
|
+
}
|
|
1179
1382
|
|
|
1180
1383
|
// src/sections/sectionParser.ts
|
|
1181
1384
|
var KNOWN_SECTION_WIDGETS = ["playground-run-tip", "attention", "code-example", "syntax-group"];
|
|
@@ -1775,13 +1978,13 @@ function parseFrontmatterProps(lines) {
|
|
|
1775
1978
|
}
|
|
1776
1979
|
|
|
1777
1980
|
// src/version.ts
|
|
1778
|
-
var VERSION = "0.
|
|
1779
|
-
var GIT_SHA = "
|
|
1780
|
-
var BUILD_TIME = "2026-11-
|
|
1981
|
+
var VERSION = "0.62.2261";
|
|
1982
|
+
var GIT_SHA = "e0e9bb0";
|
|
1983
|
+
var BUILD_TIME = "2026-11-23T01:20:07.186Z";
|
|
1781
1984
|
var SEMVER = {
|
|
1782
|
-
version: "0.
|
|
1783
|
-
gitSha: "
|
|
1784
|
-
buildTime: "2026-11-
|
|
1985
|
+
version: "0.62.2261",
|
|
1986
|
+
gitSha: "e0e9bb0",
|
|
1987
|
+
buildTime: "2026-11-23T01:20:07.186Z"
|
|
1785
1988
|
};
|
|
1786
1989
|
|
|
1787
1990
|
// src/portability/note-jsonl.ts
|
|
@@ -1801,10 +2004,10 @@ function hasValidOrigin(value) {
|
|
|
1801
2004
|
return value === void 0 || value === "journal" || value === "playground" || value === "user";
|
|
1802
2005
|
}
|
|
1803
2006
|
function validNote(value) {
|
|
1804
|
-
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");
|
|
2007
|
+
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"));
|
|
1805
2008
|
}
|
|
1806
2009
|
function validSession(value) {
|
|
1807
|
-
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);
|
|
2010
|
+
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);
|
|
1808
2011
|
}
|
|
1809
2012
|
function validParseRecord(value) {
|
|
1810
2013
|
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));
|
|
@@ -1815,6 +2018,15 @@ function validEvent(value) {
|
|
|
1815
2018
|
function validRevision(value) {
|
|
1816
2019
|
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");
|
|
1817
2020
|
}
|
|
2021
|
+
function validNoteRevision(value) {
|
|
2022
|
+
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");
|
|
2023
|
+
}
|
|
2024
|
+
function validScheduleItem(value) {
|
|
2025
|
+
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");
|
|
2026
|
+
}
|
|
2027
|
+
function validNotebookLink(value) {
|
|
2028
|
+
return isString(value.id) && isString(value.notebookId) && (value.targetKind === "note" || value.targetKind === "session") && isString(value.targetId) && isString(value.noteId) && isFiniteNumber(value.createdAt);
|
|
2029
|
+
}
|
|
1818
2030
|
function revisionToJsonl(revision) {
|
|
1819
2031
|
const { kind: blockKind, ...identity } = revision;
|
|
1820
2032
|
return { kind: "revision", blockKind, ...identity };
|
|
@@ -1822,7 +2034,10 @@ function revisionToJsonl(revision) {
|
|
|
1822
2034
|
function serializeNoteBundleToJsonl(bundle) {
|
|
1823
2035
|
const records = [
|
|
1824
2036
|
...bundle.note ? [{ kind: "note", ...bundle.note }] : [],
|
|
2037
|
+
...(bundle.noteRevisions ?? []).map((rev) => ({ kind: "note_revision", ...rev })),
|
|
1825
2038
|
...(bundle.revisions ?? []).map(revisionToJsonl),
|
|
2039
|
+
...(bundle.notebookLinks ?? []).map((link) => ({ kind: "notebook_link", ...link })),
|
|
2040
|
+
...(bundle.scheduleItems ?? []).map((item) => ({ kind: "schedule_item", ...item })),
|
|
1826
2041
|
...(bundle.parses ?? []).map((parse) => ({ kind: "parse", ...parse })),
|
|
1827
2042
|
...bundle.sessions.map((session) => ({ kind: "session", ...session })),
|
|
1828
2043
|
...bundle.events.map((event) => ({ kind: "event", ...event }))
|
|
@@ -1832,7 +2047,10 @@ function serializeNoteBundleToJsonl(bundle) {
|
|
|
1832
2047
|
async function* streamNoteBundleToJsonlLines(bundles) {
|
|
1833
2048
|
for await (const bundle of bundles) {
|
|
1834
2049
|
if (bundle.note) yield JSON.stringify({ kind: "note", ...bundle.note });
|
|
2050
|
+
for (const noteRevision of bundle.noteRevisions ?? []) yield JSON.stringify({ kind: "note_revision", ...noteRevision });
|
|
1835
2051
|
for (const revision of bundle.revisions ?? []) yield JSON.stringify(revisionToJsonl(revision));
|
|
2052
|
+
for (const link of bundle.notebookLinks ?? []) yield JSON.stringify({ kind: "notebook_link", ...link });
|
|
2053
|
+
for (const item of bundle.scheduleItems ?? []) yield JSON.stringify({ kind: "schedule_item", ...item });
|
|
1836
2054
|
for (const parse of bundle.parses ?? []) yield JSON.stringify({ kind: "parse", ...parse });
|
|
1837
2055
|
for (const session of bundle.sessions) yield JSON.stringify({ kind: "session", ...session });
|
|
1838
2056
|
for (const event of bundle.events) yield JSON.stringify({ kind: "event", ...event });
|
|
@@ -1879,6 +2097,27 @@ function parseNoteBundleFromJsonl(jsonlText) {
|
|
|
1879
2097
|
const { blockKind, ...identity } = value;
|
|
1880
2098
|
const revision = { ...identity, kind: blockKind };
|
|
1881
2099
|
(bundleFor(revision.noteId).revisions ??= []).push(revision);
|
|
2100
|
+
} else if (kind === "note_revision") {
|
|
2101
|
+
if (!validNoteRevision(value)) {
|
|
2102
|
+
errors.push(`Line ${lineNumber}: invalid note_revision record`);
|
|
2103
|
+
continue;
|
|
2104
|
+
}
|
|
2105
|
+
const noteRevision = value;
|
|
2106
|
+
(bundleFor(noteRevision.noteId).noteRevisions ??= []).push(noteRevision);
|
|
2107
|
+
} else if (kind === "schedule_item") {
|
|
2108
|
+
if (!validScheduleItem(value)) {
|
|
2109
|
+
errors.push(`Line ${lineNumber}: invalid schedule_item record`);
|
|
2110
|
+
continue;
|
|
2111
|
+
}
|
|
2112
|
+
const scheduleItem = value;
|
|
2113
|
+
(bundleFor(scheduleItem.noteId).scheduleItems ??= []).push(scheduleItem);
|
|
2114
|
+
} else if (kind === "notebook_link") {
|
|
2115
|
+
if (!validNotebookLink(value)) {
|
|
2116
|
+
errors.push(`Line ${lineNumber}: invalid notebook_link record`);
|
|
2117
|
+
continue;
|
|
2118
|
+
}
|
|
2119
|
+
const link = value;
|
|
2120
|
+
(bundleFor(link.noteId).notebookLinks ??= []).push(link);
|
|
1882
2121
|
} else if (kind === "session") {
|
|
1883
2122
|
if (!validSession(value)) {
|
|
1884
2123
|
errors.push(`Line ${lineNumber}: invalid session record`);
|
|
@@ -1920,15 +2159,28 @@ function parseNoteBundleFromJsonl(jsonlText) {
|
|
|
1920
2159
|
|
|
1921
2160
|
// src/publication.ts
|
|
1922
2161
|
function isPublishableNotebookLanding(note) {
|
|
1923
|
-
return note.id.startsWith("notebook/") && note.notebookId === note.id && !isNonPublishableNotebook(note.id) && note.
|
|
2162
|
+
return note.id.startsWith("notebook/") && note.notebookId === note.id && !isNonPublishableNotebook(note.id) && resolveNoteOwnership(note).kind === "user";
|
|
2163
|
+
}
|
|
2164
|
+
function derivePublicationStatusLabel(visibility, ownership) {
|
|
2165
|
+
if (!ownership || ownership.kind === "user") return visibility;
|
|
2166
|
+
if (ownership.kind === "feed") return "Subscribed Feed";
|
|
2167
|
+
if (ownership.kind === "feed-archived") return "Archived Feed";
|
|
2168
|
+
return "System";
|
|
1924
2169
|
}
|
|
1925
2170
|
function derivePublicationVisibility(input) {
|
|
1926
|
-
const
|
|
1927
|
-
const
|
|
2171
|
+
const ownership = input.ownership ?? (input.note ? resolveNoteOwnership(input.note, void 0, input.notebookId) : void 0);
|
|
2172
|
+
const nonOwned = Boolean(ownership && ownership.kind !== "user");
|
|
2173
|
+
const notebookPublic = nonOwned ? false : input.notebookPublic === true;
|
|
2174
|
+
const publicSessions = nonOwned ? 0 : Math.max(0, Math.trunc(input.publicSessions));
|
|
1928
2175
|
const totalSessions = Math.max(publicSessions, Math.trunc(input.totalSessions));
|
|
1929
2176
|
const visibility = !notebookPublic ? "Private" : publicSessions > 0 ? "Published Note + Data" : "Published Note";
|
|
2177
|
+
const displayLabel = derivePublicationStatusLabel(visibility, ownership);
|
|
2178
|
+
const canPublish = ownership ? ownership.canPublish : !nonOwned;
|
|
1930
2179
|
return {
|
|
1931
2180
|
visibility,
|
|
2181
|
+
displayLabel,
|
|
2182
|
+
...ownership ? { ownership } : {},
|
|
2183
|
+
canPublish,
|
|
1932
2184
|
notebookPublic,
|
|
1933
2185
|
publicSessions,
|
|
1934
2186
|
totalSessions,
|
|
@@ -1938,6 +2190,6 @@ function derivePublicationVisibility(input) {
|
|
|
1938
2190
|
};
|
|
1939
2191
|
}
|
|
1940
2192
|
|
|
1941
|
-
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 };
|
|
2193
|
+
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, countNotesByNotebook, createMetricOwnershipLedger, createTagIndex, derivePublicationStatusLabel, derivePublicationVisibility, detectScriptBlocks, dimensionKeyOf, extractBlockContent, extractFrontmatterTags, extractTypedFrontmatterTags, fieldRefFromKey, fieldRefKey, findBlockAtLine, flattenFieldLeaves, formatDurationMMSS, fromNotebookTag, getList, getMetricOwnershipLayer, getNotebookCapabilities, getReferenceMetadata, getScalar, getTagReference, isNonPublishableNotebook, isNoteEditable, isNotebookLanding, isNotebookTag, isPublishableNotebookLanding, isSystemReadOnlyNotebook, isWorkoutSectionType, lookupUnit, mapNoteBlockChanges, matchDialectFence, metricToMs, normalizeFieldComponent, normalizeFieldPath, notebookSlugFromId, orderPlacements, ownershipRank, parseDocumentSections, parseFlatProperties, parseFrontmatter, parseFrontmatterBody, parseFrontmatterCategories, parseFrontmatterProps, parseNoteBundleFromJsonl, patchFrontmatterProperty, projectPlacements, reconcileNoteBlocks, resolveLayer, resolveNoteOwnership, resolvePlacements, runAffordance, serializeFrontmatter, serializeNoteBundleToJsonl, streamNoteBundleToJsonlLines, stripFrontmatter, systemDefaultUnit, toNotebookId, toNotebookTag, validateNoteBlocks, valueKindOf };
|
|
1942
2194
|
//# sourceMappingURL=index.mjs.map
|
|
1943
2195
|
//# sourceMappingURL=index.mjs.map
|