@batalabs/virlow-mcp-core 3.18.0 → 3.68.0

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.
Files changed (73) hide show
  1. package/LICENSE +8 -18
  2. package/README.md +1 -1
  3. package/dist/api.d.ts +32 -0
  4. package/dist/api.d.ts.map +1 -1
  5. package/dist/api.js +38 -5
  6. package/dist/api.js.map +1 -1
  7. package/dist/attrs-extract.d.ts +48 -0
  8. package/dist/attrs-extract.d.ts.map +1 -0
  9. package/dist/attrs-extract.js +153 -0
  10. package/dist/attrs-extract.js.map +1 -0
  11. package/dist/attrs.d.ts +445 -0
  12. package/dist/attrs.d.ts.map +1 -0
  13. package/dist/attrs.js +604 -0
  14. package/dist/attrs.js.map +1 -0
  15. package/dist/cjs/api.d.ts +32 -0
  16. package/dist/cjs/api.js +38 -5
  17. package/dist/cjs/attrs-extract.d.ts +47 -0
  18. package/dist/cjs/attrs-extract.js +159 -0
  19. package/dist/cjs/attrs.d.ts +444 -0
  20. package/dist/cjs/attrs.js +635 -0
  21. package/dist/cjs/index.d.ts +5 -1
  22. package/dist/cjs/index.js +22 -1
  23. package/dist/cjs/memories.d.ts +79 -1
  24. package/dist/cjs/memories.js +249 -15
  25. package/dist/cjs/memory-graph.d.ts +105 -0
  26. package/dist/cjs/memory-graph.js +270 -0
  27. package/dist/cjs/memory-note.d.ts +57 -0
  28. package/dist/cjs/memory-note.js +174 -10
  29. package/dist/cjs/memory-secrets.d.ts +19 -0
  30. package/dist/cjs/memory-secrets.js +108 -0
  31. package/dist/cjs/notes.d.ts +208 -2
  32. package/dist/cjs/notes.js +721 -12
  33. package/dist/http/index.d.ts +4 -0
  34. package/dist/http/index.d.ts.map +1 -0
  35. package/dist/http/index.js +3 -0
  36. package/dist/http/index.js.map +1 -0
  37. package/dist/http/local-origin.d.ts +61 -0
  38. package/dist/http/local-origin.d.ts.map +1 -0
  39. package/dist/http/local-origin.js +92 -0
  40. package/dist/http/local-origin.js.map +1 -0
  41. package/dist/http/server.d.ts +39 -0
  42. package/dist/http/server.d.ts.map +1 -0
  43. package/dist/http/server.js +131 -0
  44. package/dist/http/server.js.map +1 -0
  45. package/dist/index.d.ts +5 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +2 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/memories.d.ts +79 -1
  50. package/dist/memories.d.ts.map +1 -1
  51. package/dist/memories.js +249 -15
  52. package/dist/memories.js.map +1 -1
  53. package/dist/memory-graph.d.ts +106 -0
  54. package/dist/memory-graph.d.ts.map +1 -0
  55. package/dist/memory-graph.js +258 -0
  56. package/dist/memory-graph.js.map +1 -0
  57. package/dist/memory-note.d.ts +57 -0
  58. package/dist/memory-note.d.ts.map +1 -1
  59. package/dist/memory-note.js +170 -10
  60. package/dist/memory-note.js.map +1 -1
  61. package/dist/memory-secrets.d.ts +20 -0
  62. package/dist/memory-secrets.d.ts.map +1 -0
  63. package/dist/memory-secrets.js +103 -0
  64. package/dist/memory-secrets.js.map +1 -0
  65. package/dist/notes.d.ts +208 -2
  66. package/dist/notes.d.ts.map +1 -1
  67. package/dist/notes.js +722 -13
  68. package/dist/notes.js.map +1 -1
  69. package/dist/tools.d.ts +8 -2
  70. package/dist/tools.d.ts.map +1 -1
  71. package/dist/tools.js +465 -10
  72. package/dist/tools.js.map +1 -1
  73. package/package.json +21 -5
package/dist/attrs.js ADDED
@@ -0,0 +1,604 @@
1
+ import { decryptStringBlob, encryptStringBlob } from '@batalabs/virlow-crypto';
2
+ const FILTER_OPS = ['is', 'has', 'checked', 'unchecked', 'empty', 'notEmpty'];
3
+ export function isPropertyFilter(value) {
4
+ if (!isRecord(value))
5
+ return false;
6
+ if (typeof value.propId !== 'string' || value.propId === '')
7
+ return false;
8
+ if (!FILTER_OPS.includes(value.op))
9
+ return false;
10
+ if (value.op === 'is' || value.op === 'has')
11
+ return typeof value.value === 'string';
12
+ return value.value === undefined;
13
+ }
14
+ /** Whether a value counts as absent. An empty string and an empty list read as
15
+ * nothing to the person looking at the row, so they filter as nothing too. */
16
+ function isEmptyValue(value) {
17
+ if (value === undefined)
18
+ return true;
19
+ switch (value.t) {
20
+ case 'text':
21
+ case 'url':
22
+ case 'select':
23
+ case 'date':
24
+ return value.v === '';
25
+ case 'multiSelect':
26
+ case 'relation':
27
+ return value.v.length === 0;
28
+ case 'number':
29
+ return Number.isNaN(value.v);
30
+ case 'checkbox':
31
+ // A checkbox is never absent: false is an answer, not a blank.
32
+ return false;
33
+ default:
34
+ return true;
35
+ }
36
+ }
37
+ export function matchesFilter(attrs, filter) {
38
+ const value = attrs?.props[filter.propId];
39
+ switch (filter.op) {
40
+ case 'is':
41
+ return value?.t === 'select' && value.v === filter.value;
42
+ case 'has':
43
+ return value?.t === 'multiSelect' && value.v.includes(filter.value);
44
+ case 'checked':
45
+ return value?.t === 'checkbox' && value.v === true;
46
+ case 'unchecked':
47
+ // Unticked and never touched are the same thing to the reader, so a note
48
+ // with no value for the box counts as unchecked rather than dropping out
49
+ // of both halves of the filter.
50
+ return value === undefined || (value.t === 'checkbox' && value.v === false);
51
+ case 'empty':
52
+ return isEmptyValue(value);
53
+ case 'notEmpty':
54
+ return !isEmptyValue(value);
55
+ default:
56
+ return true;
57
+ }
58
+ }
59
+ /** Every filter passes. Filters across different properties are an AND: each
60
+ * one narrows what the last one left, which is what picking two of them from
61
+ * a menu looks like it should do. */
62
+ export function matchesAll(attrs, filters) {
63
+ return (filters ?? []).every((filter) => matchesFilter(attrs, filter));
64
+ }
65
+ export function isHomeSort(value) {
66
+ return (isRecord(value) &&
67
+ typeof value.by === 'string' &&
68
+ value.by !== '' &&
69
+ (value.dir === 'asc' || value.dir === 'desc'));
70
+ }
71
+ const PINNED_LOOKS = ['list', 'notes'];
72
+ /** The most notes one pinned block holds. Past this it is a listing, and a
73
+ * table with a filter is the block for a listing. */
74
+ export const PINNED_MAX = 50;
75
+ /** The longest a table block's title may be: a heading, not a description. */
76
+ export const HOME_TITLE_MAX = 60;
77
+ /** The longest a `text` widget may be. A home is a surface, not a document;
78
+ * anything longer belongs in a note. */
79
+ export const HOME_TEXT_MAX = 280;
80
+ /** The longest a `summary` may be. Room for a paragraph or two of context,
81
+ * and short of the point where the dashboard becomes a document. */
82
+ export const HOME_SUMMARY_MAX = 2000;
83
+ const HOME_KINDS = [
84
+ 'counts',
85
+ 'recent',
86
+ 'starred',
87
+ 'breakdown',
88
+ 'upcoming',
89
+ 'text',
90
+ 'summary',
91
+ 'table',
92
+ 'calendar',
93
+ 'board',
94
+ 'activity',
95
+ 'stale',
96
+ 'tasks',
97
+ 'pinned',
98
+ 'quick',
99
+ ];
100
+ const SPANS = ['half', 'full'];
101
+ /**
102
+ * A block's width when it has not been given one.
103
+ *
104
+ * A table's columns and a month grid need the room; a stat row and a short
105
+ * list do not, and pairing them is what makes the page read as a dashboard
106
+ * rather than a column of cards.
107
+ */
108
+ const DEFAULT_SPAN = {
109
+ counts: 'half',
110
+ recent: 'half',
111
+ starred: 'half',
112
+ breakdown: 'half',
113
+ upcoming: 'half',
114
+ text: 'full',
115
+ summary: 'full',
116
+ table: 'full',
117
+ calendar: 'full',
118
+ board: 'full',
119
+ activity: 'half',
120
+ stale: 'half',
121
+ tasks: 'half',
122
+ pinned: 'half',
123
+ quick: 'full',
124
+ };
125
+ export function spanOf(widget) {
126
+ return widget.span ?? DEFAULT_SPAN[widget.kind] ?? 'half';
127
+ }
128
+ /** True for a block this build can draw. Exported so the MCP layer can refuse
129
+ * one at the tool boundary rather than writing it and skipping it on read. */
130
+ export function isHomeWidget(value) {
131
+ if (!isRecord(value))
132
+ return false;
133
+ if (typeof value.id !== 'string')
134
+ return false;
135
+ if (!HOME_KINDS.includes(value.kind))
136
+ return false;
137
+ // An unknown span is dropped rather than rendered at some guessed width.
138
+ if (value.span !== undefined && !SPANS.includes(value.span))
139
+ return false;
140
+ if (value.kind === 'breakdown' ||
141
+ value.kind === 'upcoming' ||
142
+ value.kind === 'calendar' ||
143
+ value.kind === 'board') {
144
+ return typeof value.propId === 'string';
145
+ }
146
+ if (value.kind === 'table' || value.kind === 'tasks') {
147
+ // A malformed filter is refused rather than ignored: a table that silently
148
+ // shows everything is wrong in the way that is hardest to notice.
149
+ if (value.filters !== undefined) {
150
+ if (!Array.isArray(value.filters) || !value.filters.every(isPropertyFilter))
151
+ return false;
152
+ }
153
+ if (value.kind === 'table') {
154
+ if (value.sort !== undefined && !isHomeSort(value.sort))
155
+ return false;
156
+ if (value.title !== undefined) {
157
+ if (typeof value.title !== 'string' || value.title.length > HOME_TITLE_MAX)
158
+ return false;
159
+ }
160
+ }
161
+ return true;
162
+ }
163
+ if (value.kind === 'pinned') {
164
+ if (!Array.isArray(value.noteIds) ||
165
+ value.noteIds.length > PINNED_MAX ||
166
+ !value.noteIds.every((id) => typeof id === 'string' && id !== ''))
167
+ return false;
168
+ if (value.look !== undefined && !PINNED_LOOKS.includes(value.look))
169
+ return false;
170
+ if (value.colors !== undefined) {
171
+ if (!isRecord(value.colors))
172
+ return false;
173
+ if (!Object.values(value.colors).every((c) => typeof c === 'string' && c.length <= 24))
174
+ return false;
175
+ }
176
+ return true;
177
+ }
178
+ if (value.kind === 'text')
179
+ return typeof value.body === 'string';
180
+ if (value.kind === 'summary') {
181
+ if (typeof value.body !== 'string')
182
+ return false;
183
+ return value.at === undefined || typeof value.at === 'string';
184
+ }
185
+ return true;
186
+ }
187
+ /**
188
+ * What a workspace shows when nobody has arranged its home.
189
+ *
190
+ * A default rather than an empty screen: a workspace should be worth opening
191
+ * the first time, and these three need no configuration to mean something.
192
+ */
193
+ export const DEFAULT_HOME_WIDGETS = [
194
+ { id: 'default-counts', kind: 'counts' },
195
+ { id: 'default-recent', kind: 'recent', limit: 5 },
196
+ { id: 'default-starred', kind: 'starred', limit: 5 },
197
+ ];
198
+ /**
199
+ * The widgets to draw, dropping any this build cannot read.
200
+ *
201
+ * Mirrors sortedProps: a newer client may write a kind this one does not
202
+ * know, and the right answer is to skip it rather than to throw away the
203
+ * whole home or crash rendering it.
204
+ */
205
+ /**
206
+ * A home with `widgets` written out in full.
207
+ *
208
+ * The first edit to a workspace that has never been arranged has to write the
209
+ * defaults down alongside the change. Otherwise removing a default block does
210
+ * nothing: homeWidgets would see an empty list, fall back, and put it
211
+ * straight back. Materialising turns "no opinion" into "this arrangement",
212
+ * which is what an edit means.
213
+ */
214
+ export function withHomeWidgets(schema, widgets) {
215
+ return { ...schema, home: { ...schema.home, widgets } };
216
+ }
217
+ /** A widget id that will not collide with another in the same home. */
218
+ export function newWidgetId() {
219
+ const bytes = crypto.getRandomValues(new Uint8Array(6));
220
+ return [...bytes].map((b) => b.toString(16).padStart(2, '0')).join('');
221
+ }
222
+ export function homeWidgets(schema,
223
+ /** The workspace's properties. Given them, an unarranged home leads with a
224
+ * calendar when there is a date property to place notes on. Omitted, the
225
+ * default is the plain three, which is what a caller with no schema to
226
+ * hand should get. */
227
+ defs) {
228
+ const configured = schema?.home?.widgets;
229
+ if (!Array.isArray(configured))
230
+ return defaultWidgets(defs);
231
+ const known = configured.filter(isHomeWidget);
232
+ return known.length > 0 ? known : defaultWidgets(defs);
233
+ }
234
+ /**
235
+ * What an unarranged workspace shows.
236
+ *
237
+ * A calendar first: dates are what people open a workspace to see, and a
238
+ * month grid answers "what is happening here" in a way three counts cannot.
239
+ */
240
+ function defaultWidgets(defs) {
241
+ // A workspace's own date property when it has one, and otherwise the notes'
242
+ // edit times, so every workspace opens on a calendar rather than only the
243
+ // ones that have been configured.
244
+ const date = defs?.find((def) => def.type === 'date');
245
+ return [
246
+ {
247
+ id: 'default-calendar',
248
+ kind: 'calendar',
249
+ propId: date ? date.id : LAST_CHANGED,
250
+ },
251
+ ...DEFAULT_HOME_WIDGETS,
252
+ ];
253
+ }
254
+ /**
255
+ * Starting arrangements.
256
+ *
257
+ * An empty page is where most people stall: every block exists, and none of
258
+ * them says which six to put together for a project. A preset is that
259
+ * answer written down, built from the workspace's own properties where it
260
+ * has them (a board wants a select, a calendar wants a date) and from the
261
+ * notes' own dates where it does not, so every preset draws something on
262
+ * the workspace it is applied to. Applying one replaces the arrangement,
263
+ * and the one it replaced is kept for undo like any other change.
264
+ */
265
+ export const HOME_PRESETS = ['project', 'research', 'journal'];
266
+ export const HOME_PRESET_LABELS = {
267
+ project: {
268
+ name: 'Project',
269
+ blurb: 'Open tasks, a board by stage, a calendar, and what has gone quiet.',
270
+ },
271
+ research: {
272
+ name: 'Research',
273
+ blurb: 'Pinned sources, the latest additions, and a calendar of when things arrived.',
274
+ },
275
+ journal: {
276
+ name: 'Journal',
277
+ blurb: 'This week, recent entries, open tasks, and how often you write.',
278
+ },
279
+ };
280
+ export function isHomePreset(value) {
281
+ return HOME_PRESETS.includes(value);
282
+ }
283
+ export function presetWidgets(preset, defs = [], id = newWidgetId) {
284
+ const select = defs.find((d) => d.type === 'select');
285
+ const date = defs.find((d) => d.type === 'date');
286
+ switch (preset) {
287
+ case 'project':
288
+ return [
289
+ { id: id(), kind: 'tasks', limit: 10, span: 'half' },
290
+ { id: id(), kind: 'counts', span: 'half' },
291
+ select
292
+ ? { id: id(), kind: 'board', propId: select.id, span: 'full' }
293
+ : { id: id(), kind: 'table', limit: 10, span: 'full' },
294
+ { id: id(), kind: 'calendar', propId: date ? date.id : LAST_CHANGED, span: 'full' },
295
+ { id: id(), kind: 'pinned', noteIds: [], look: 'notes', span: 'half' },
296
+ { id: id(), kind: 'stale', days: 30, limit: 5, span: 'half' },
297
+ ];
298
+ case 'research':
299
+ return [
300
+ { id: id(), kind: 'pinned', noteIds: [], look: 'notes', span: 'half' },
301
+ { id: id(), kind: 'recent', limit: 10, span: 'half' },
302
+ {
303
+ id: id(),
304
+ kind: 'table',
305
+ title: 'Latest additions',
306
+ limit: 10,
307
+ sort: { by: CREATED, dir: 'desc' },
308
+ span: 'full',
309
+ },
310
+ select
311
+ ? { id: id(), kind: 'breakdown', propId: select.id, span: 'half' }
312
+ : { id: id(), kind: 'activity', weeks: 12, span: 'half' },
313
+ { id: id(), kind: 'tasks', limit: 10, span: 'half' },
314
+ { id: id(), kind: 'calendar', propId: CREATED, span: 'full' },
315
+ ];
316
+ case 'journal':
317
+ return [
318
+ { id: id(), kind: 'quick', span: 'full' },
319
+ { id: id(), kind: 'calendar', propId: LAST_CHANGED, range: 'week', span: 'full' },
320
+ { id: id(), kind: 'recent', limit: 7, span: 'half' },
321
+ { id: id(), kind: 'tasks', limit: 10, span: 'half' },
322
+ { id: id(), kind: 'activity', weeks: 26, span: 'half' },
323
+ { id: id(), kind: 'stale', days: 14, limit: 5, span: 'half' },
324
+ ];
325
+ default:
326
+ return defaultWidgets(defs);
327
+ }
328
+ }
329
+ /** True when a note is on one of this home's Pinned blocks. */
330
+ export function isPinned(schema, noteId) {
331
+ return homeWidgets(schema).some((w) => w.kind === 'pinned' && w.noteIds.includes(noteId));
332
+ }
333
+ /**
334
+ * Pins a note to a workspace's home, or unpins it: what "Pin to dashboard" in
335
+ * a note's menu writes.
336
+ *
337
+ * Unpinning takes the note off every Pinned block it is on. Pinning puts it
338
+ * on the first block with room, and when the home has no Pinned block yet it
339
+ * adds one, as sticky notes, at the top: pinning from a note is a request to
340
+ * see it on the dashboard, and a pin into a block nobody can see is not that.
341
+ * An unarranged home is written out as its defaults plus the new block, so
342
+ * nothing already on it disappears.
343
+ *
344
+ * Null when every Pinned block is full, which the caller has to say.
345
+ */
346
+ export function withPinToggled(schema, defs, noteId) {
347
+ const widgets = homeWidgets(schema, defs);
348
+ if (isPinned(schema, noteId)) {
349
+ return withHomeWidgets(schema, widgets.map((w) => w.kind === 'pinned' && w.noteIds.includes(noteId)
350
+ ? { ...w, noteIds: w.noteIds.filter((id) => id !== noteId) }
351
+ : w));
352
+ }
353
+ const target = widgets.find((w) => w.kind === 'pinned' && w.noteIds.length < PINNED_MAX);
354
+ if (target) {
355
+ return withHomeWidgets(schema, widgets.map((w) => w === target && w.kind === 'pinned'
356
+ ? { ...w, noteIds: [...w.noteIds, noteId] }
357
+ : w));
358
+ }
359
+ if (widgets.some((w) => w.kind === 'pinned'))
360
+ return null;
361
+ return withHomeWidgets(schema, [
362
+ { id: newWidgetId(), kind: 'pinned', noteIds: [noteId], look: 'notes' },
363
+ ...widgets,
364
+ ]);
365
+ }
366
+ /**
367
+ * The reserved property id meaning "place notes by when they last changed".
368
+ *
369
+ * Not a property: it is a fact every note already carries. A calendar could
370
+ * previously only be drawn by a workspace that had defined a date property,
371
+ * which made "calendar by default" false for exactly the workspaces that had
372
+ * never set anything up, which is most of them at the point somebody first
373
+ * opens a dashboard. A calendar of when you last touched things needs no
374
+ * setup and answers a real question.
375
+ *
376
+ * A calendar in this mode is read only: you cannot decide when a note was
377
+ * last edited.
378
+ */
379
+ export const LAST_CHANGED = '@lastChanged';
380
+ /**
381
+ * The reserved property id meaning "place notes by when they were created".
382
+ *
383
+ * The other half of the same idea as LAST_CHANGED. They answer different
384
+ * questions and people want both: what have I touched lately, and what did I
385
+ * start when. Neither needs a workspace to have defined anything, and neither
386
+ * can be dragged, because you cannot decide when a note came into existence.
387
+ */
388
+ export const CREATED = '@created';
389
+ /** True for the built-in date sources, which come from the note itself rather
390
+ * than from a property somebody defined. */
391
+ export function isNoteDate(propId) {
392
+ return propId === LAST_CHANGED || propId === CREATED;
393
+ }
394
+ /** The reserved property id that carries what used to be the plaintext tags column. */
395
+ export const TAGS_PROP = 'tags';
396
+ /** Matches the server's cap on the encrypted attrs blob (HTTP 413
397
+ * `ATTRS_TOO_LARGE`), measured as UTF-8 bytes of the ciphertext string. The
398
+ * single source of truth for both mcp-core (notes.ts) and the web app
399
+ * (src/lib/attrs/next.ts), so the two never drift apart. */
400
+ export const ATTRS_MAX_BYTES = 16384;
401
+ /** Matches the server's cap on the encrypted folder schema blob (HTTP 413
402
+ * `SCHEMA_TOO_LARGE`), measured as UTF-8 bytes of the ciphertext string. Lives
403
+ * beside ATTRS_MAX_BYTES for the same reason: mcp-core (notes.ts) and the web
404
+ * app (src/hooks/useFolderSchema.ts) both refuse an oversize blob before
405
+ * sending it, and two copies of the number would eventually disagree. */
406
+ export const SCHEMA_MAX_BYTES = 32768;
407
+ const DATE = new Intl.DateTimeFormat('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
408
+ function day(value) {
409
+ // Date-only strings are parsed as UTC; formatting them in the local zone
410
+ // would show the day before for anyone west of Greenwich.
411
+ const iso = /^\d{4}-\d{2}-\d{2}$/.test(value) ? `${value}T12:00:00Z` : value;
412
+ const parsed = new Date(iso);
413
+ return Number.isNaN(parsed.getTime()) ? '' : DATE.format(parsed);
414
+ }
415
+ export function formatProp(def, value) {
416
+ if (!value)
417
+ return '';
418
+ switch (value.t) {
419
+ case 'text':
420
+ case 'url':
421
+ return value.v;
422
+ case 'number':
423
+ return String(value.v);
424
+ case 'checkbox':
425
+ return value.v ? 'Yes' : 'No';
426
+ case 'date':
427
+ return value.end ? `${day(value.v)} to ${day(value.end)}` : day(value.v);
428
+ case 'select':
429
+ return def.options?.find((o) => o.id === value.v)?.name ?? '';
430
+ case 'multiSelect':
431
+ return value.v.map((id) => def.options?.find((o) => o.id === id)?.name).filter(Boolean).join(', ');
432
+ case 'relation':
433
+ return value.v.length === 1 ? '1 note' : `${value.v.length} notes`;
434
+ default:
435
+ return '';
436
+ }
437
+ }
438
+ export function emptyAttrs(now = new Date().toISOString()) {
439
+ return { v: 1, props: {}, links: [], mentions: [], updated: now };
440
+ }
441
+ export function emptySchema() {
442
+ return { v: 1, properties: [], views: { default: 'list' } };
443
+ }
444
+ const PROP_TYPES = ['text', 'number', 'select', 'multiSelect', 'date', 'checkbox', 'url', 'relation'];
445
+ /** 12 hex characters, enough entropy that two properties never collide. */
446
+ export function newPropId() {
447
+ const bytes = crypto.getRandomValues(new Uint8Array(6));
448
+ return [...bytes].map((b) => b.toString(16).padStart(2, '0')).join('');
449
+ }
450
+ function isPropDefinition(value) {
451
+ if (!isRecord(value))
452
+ return false;
453
+ return (typeof value.id === 'string' &&
454
+ typeof value.name === 'string' &&
455
+ PROP_TYPES.includes(value.type) &&
456
+ typeof value.order === 'number');
457
+ }
458
+ /** Definitions in display order. Unknown shapes are dropped rather than
459
+ * thrown on: a newer client may write a type this one does not know. */
460
+ export function sortedProps(schema) {
461
+ const list = Array.isArray(schema?.properties) ? schema.properties : [];
462
+ return list
463
+ .filter(isPropDefinition)
464
+ .slice()
465
+ .sort((a, b) => a.order - b.order);
466
+ }
467
+ /**
468
+ * Everything in `properties` that `sortedProps` drops: an entry whose type
469
+ * this build does not know, or whose shape it cannot read. A newer client
470
+ * writes those, and this one must hand them back untouched.
471
+ *
472
+ * Every mutator below rebuilds `properties`, and rebuilding it from
473
+ * `sortedProps` alone deleted these: renaming one property in the web app
474
+ * silently destroyed a property the desktop build had defined. The same vault
475
+ * is edited by three clients, and `setProperties` already keeps unknown attrs
476
+ * fields, so dropping them here made the codec disagree with itself.
477
+ *
478
+ * They are re-appended at the end and never renumbered. Their `order` belongs
479
+ * to a definition this build cannot read, and rewriting it would be guessing.
480
+ */
481
+ function unreadableProps(schema) {
482
+ const list = Array.isArray(schema?.properties) ? schema.properties : [];
483
+ return list.filter((p) => !isPropDefinition(p));
484
+ }
485
+ /** The id an entry carries, whether or not this build can read the rest of
486
+ * it, so an explicit remove can still find it. */
487
+ function idOf(prop) {
488
+ const id = prop.id;
489
+ return typeof id === 'string' ? id : undefined;
490
+ }
491
+ /** Appends a new property definition, assigning it a fresh id (unless one is
492
+ * given) and an order past the current last property. Never mutates schema. */
493
+ export function defineProp(schema, def) {
494
+ const props = sortedProps(schema);
495
+ const last = props[props.length - 1];
496
+ const order = last === undefined ? 0 : last.order + 1;
497
+ const { id, ...rest } = def;
498
+ return { ...schema, properties: [...props, { ...rest, id: id ?? newPropId(), order }, ...unreadableProps(schema)] };
499
+ }
500
+ /** Patches a property definition by id, keeping its id fixed regardless of
501
+ * what the patch contains. Never mutates schema. */
502
+ export function updateProp(schema, id, patch) {
503
+ return {
504
+ ...schema,
505
+ properties: [
506
+ ...sortedProps(schema).map((p) => (p.id === id ? { ...p, ...patch, id: p.id } : p)),
507
+ // Never patched: a patch is written against a type this build knows,
508
+ // and applying it to a definition it cannot read would corrupt it.
509
+ ...unreadableProps(schema),
510
+ ],
511
+ };
512
+ }
513
+ /** Removes a property definition by id. Never mutates schema. */
514
+ export function removeProp(schema, id) {
515
+ return {
516
+ ...schema,
517
+ properties: [
518
+ ...sortedProps(schema).filter((p) => p.id !== id),
519
+ // Keeping the unreadable ones is about not deleting them by accident.
520
+ // A remove naming that id is not an accident, so it takes effect.
521
+ ...unreadableProps(schema).filter((p) => idOf(p) !== id),
522
+ ],
523
+ };
524
+ }
525
+ /** Reassigns order so the definitions match orderedIds; any definition whose
526
+ * id is not in the list keeps its relative position after the known ones.
527
+ * Never mutates schema. */
528
+ export function reorderProps(schema, orderedIds) {
529
+ const props = sortedProps(schema);
530
+ const rank = new Map(orderedIds.map((id, i) => [id, i]));
531
+ const next = props
532
+ .slice()
533
+ .sort((a, b) => (rank.get(a.id) ?? Number.MAX_SAFE_INTEGER) - (rank.get(b.id) ?? Number.MAX_SAFE_INTEGER))
534
+ .map((p, i) => ({ ...p, order: i }));
535
+ return { ...schema, properties: [...next, ...unreadableProps(schema)] };
536
+ }
537
+ function isRecord(value) {
538
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
539
+ }
540
+ function stringArray(value) {
541
+ return Array.isArray(value) ? value.filter((x) => typeof x === 'string') : [];
542
+ }
543
+ /**
544
+ * The type says v: 1, but a blob written by a future client may carry a
545
+ * higher version number. That numeric value is preserved on purpose, not
546
+ * downgraded, so a round trip through this reader does not lose it; only a
547
+ * missing or non-numeric v falls back to 1. The cast is needed because the
548
+ * field's declared type is the literal 1, not number.
549
+ */
550
+ function decodedVersion(r) {
551
+ return (typeof r.v === 'number' && Number.isFinite(r.v) ? r.v : 1);
552
+ }
553
+ /** Normalize a decoded object into a NoteAttrsV1, keeping unknown fields. */
554
+ function asAttrs(raw) {
555
+ const r = isRecord(raw) ? raw : {};
556
+ return {
557
+ ...r,
558
+ v: decodedVersion(r),
559
+ props: isRecord(r.props) ? r.props : {},
560
+ links: stringArray(r.links),
561
+ mentions: stringArray(r.mentions),
562
+ ...(r.aliases !== undefined ? { aliases: stringArray(r.aliases) } : {}),
563
+ updated: typeof r.updated === 'string' ? r.updated : new Date(0).toISOString(),
564
+ };
565
+ }
566
+ function asSchema(raw) {
567
+ const r = isRecord(raw) ? raw : {};
568
+ const views = isRecord(r.views) ? r.views : {};
569
+ const def = views.default;
570
+ // 'home' was briefly one of these. It is not a way of listing notes, so it
571
+ // moved to the editor pane and out of this union; a workspace saved as
572
+ // 'home' by that build clamps to 'list' here rather than rendering nothing.
573
+ const allowed = ['list', 'table', 'board', 'calendar'];
574
+ return {
575
+ ...r,
576
+ v: decodedVersion(r),
577
+ properties: Array.isArray(r.properties) ? r.properties : [],
578
+ views: { ...views, default: allowed.includes(def) ? def : 'list' },
579
+ };
580
+ }
581
+ export async function encodeAttrs(key, attrs) {
582
+ return encryptStringBlob(key, JSON.stringify(attrs));
583
+ }
584
+ export async function decodeAttrs(key, blob) {
585
+ if (!blob)
586
+ return null;
587
+ return asAttrs(JSON.parse(await decryptStringBlob(key, blob)));
588
+ }
589
+ export async function encodeSchema(key, schema) {
590
+ return encryptStringBlob(key, JSON.stringify(schema));
591
+ }
592
+ export async function decodeSchema(key, blob) {
593
+ if (!blob)
594
+ return null;
595
+ return asSchema(JSON.parse(await decryptStringBlob(key, blob)));
596
+ }
597
+ export function tagsFromAttrs(attrs) {
598
+ const value = attrs?.props[TAGS_PROP];
599
+ return value && value.t === 'multiSelect' ? [...value.v] : [];
600
+ }
601
+ export function withTags(attrs, tags, now = new Date().toISOString()) {
602
+ return { ...attrs, props: { ...attrs.props, [TAGS_PROP]: { t: 'multiSelect', v: [...tags] } }, updated: now };
603
+ }
604
+ //# sourceMappingURL=attrs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attrs.js","sourceRoot":"","sources":["../src/attrs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAA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