gesttalt 0.7.5 → 0.7.7

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/README.md CHANGED
@@ -13,9 +13,20 @@ npm install gesttalt
13
13
  ```js
14
14
  const {
15
15
  createSnippet,
16
+ listSnippets,
16
17
  readSnippet,
17
18
  updateSnippet,
18
19
  deleteSnippet,
20
+ createPost,
21
+ listPosts,
22
+ readPost,
23
+ updatePost,
24
+ deletePost,
25
+ createNote,
26
+ listNotes,
27
+ readNote,
28
+ updateNote,
29
+ deleteNote,
19
30
  } = require('gesttalt');
20
31
 
21
32
  const projectDir = '.';
@@ -29,6 +40,7 @@ const path = createSnippet(
29
40
  'example.zig'
30
41
  );
31
42
 
43
+ const snippets = listSnippets(projectDir);
32
44
  const snippet = readSnippet(projectDir, timestamp);
33
45
  console.log(snippet);
34
46
 
@@ -37,16 +49,31 @@ updateSnippet(projectDir, timestamp, {
37
49
  });
38
50
 
39
51
  deleteSnippet(projectDir, timestamp);
52
+
53
+ const postPath = createPost(projectDir, 'hello-world', 'Hello', 'My first post', {
54
+ tags: ['zig', 'oauth2'],
55
+ });
56
+ const posts = listPosts(projectDir);
57
+ const post = readPost(projectDir, 'hello-world');
58
+ updatePost(projectDir, 'hello-world', { title: 'Updated title' });
59
+ deletePost(projectDir, 'hello-world');
60
+
61
+ const notePath = createNote(projectDir, timestamp, { body: 'Quick update' });
62
+ const notes = listNotes(projectDir);
63
+ const note = readNote(projectDir, String(timestamp));
64
+ updateNote(projectDir, String(timestamp), { body: 'Edited' });
65
+ deleteNote(projectDir, String(timestamp));
40
66
  ```
41
67
 
42
68
  ## Browser
43
69
 
44
- This package ships a WASM build for browser runtimes. Because snippets CRUD requires filesystem access, you must provide a WASI-compatible runtime with a mounted directory for the project.
70
+ This package ships a WASM build for browser runtimes with an in-memory storage backend. To persist data across reloads, enable the browser storage helper.
45
71
 
46
72
  ```js
47
- import { init, createSnippet } from 'gesttalt';
73
+ import { init, enableBrowserStorage, createSnippet } from 'gesttalt';
48
74
 
49
75
  await init();
76
+ await enableBrowserStorage('/project');
50
77
  createSnippet('/project', 1735148400, 'Example snippet', 'const x = 1;', 'example.zig');
51
78
  ```
52
79
 
@@ -77,9 +104,20 @@ npm test
77
104
  ## API
78
105
 
79
106
  - `createSnippet(projectDir, timestamp, description, body, filename)`
107
+ - `listSnippets(projectDir)`
80
108
  - `readSnippet(projectDir, timestamp)`
81
109
  - `updateSnippet(projectDir, timestamp, update)`
82
110
  - `deleteSnippet(projectDir, timestamp)`
111
+ - `createPost(projectDir, slug, title, description, options)`
112
+ - `listPosts(projectDir)`
113
+ - `readPost(projectDir, slug)`
114
+ - `updatePost(projectDir, slug, update)`
115
+ - `deletePost(projectDir, slug)`
116
+ - `createNote(projectDir, timestamp, options)`
117
+ - `listNotes(projectDir)`
118
+ - `readNote(projectDir, id)`
119
+ - `updateNote(projectDir, id, update)`
120
+ - `deleteNote(projectDir, id)`
83
121
 
84
122
  ## License
85
123
 
package/browser.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // Browser-only WASM module for Gesttalt snippets
1
+ // Browser-only WASM module for Gesttalt content (snippets/posts/notes).
2
2
 
3
3
  let wasmModule = null;
4
4
  let wasmReady = false;
@@ -6,17 +6,26 @@ let initPromise = null;
6
6
 
7
7
  const errorMessages = {
8
8
  1: 'Invalid timestamp',
9
- 2: 'Duplicate snippet',
10
- 3: 'Snippet not found',
9
+ 2: 'Duplicate content',
10
+ 3: 'Content not found',
11
11
  4: 'Invalid extension',
12
12
  5: 'Invalid description',
13
13
  6: 'Invalid filename',
14
14
  7: 'Parse error',
15
15
  8: 'I/O error',
16
16
  9: 'Out of memory',
17
+ 10: 'Invalid slug',
18
+ 11: 'Invalid date',
19
+ 12: 'Missing title',
20
+ 13: 'Missing description',
21
+ 14: 'Invalid argument',
17
22
  100: 'Unknown error',
18
23
  };
19
24
 
25
+ let storageEnabled = false;
26
+ let storageKey = null;
27
+ let storageProjectDir = '';
28
+
20
29
  export class GesttaltError extends Error {
21
30
  constructor(code, message) {
22
31
  super(message);
@@ -75,6 +84,82 @@ function readResult(exports, memory) {
75
84
  return resultStr;
76
85
  }
77
86
 
87
+ function writeOptional(exports, memory, value) {
88
+ if (value == null) return { ptr: 0, len: 0 };
89
+ return writeString(exports, memory, value);
90
+ }
91
+
92
+ function storageListWasm(prefix) {
93
+ ensureWasmReady();
94
+ const exports = wasmModule.exports;
95
+ const memory = exports.memory;
96
+ const prefixBuf = writeString(exports, memory, prefix);
97
+ const rc = exports.storage_list(prefixBuf.ptr, prefixBuf.len);
98
+ exports.dealloc(prefixBuf.ptr, prefixBuf.len);
99
+ throwForCode(rc);
100
+ return readResult(exports, memory);
101
+ }
102
+
103
+ function storageGetWasm(path) {
104
+ ensureWasmReady();
105
+ const exports = wasmModule.exports;
106
+ const memory = exports.memory;
107
+ const pathBuf = writeString(exports, memory, path);
108
+ const rc = exports.storage_get(pathBuf.ptr, pathBuf.len);
109
+ exports.dealloc(pathBuf.ptr, pathBuf.len);
110
+ throwForCode(rc);
111
+ return readResult(exports, memory);
112
+ }
113
+
114
+ function storagePutWasm(path, content, overwrite) {
115
+ ensureWasmReady();
116
+ const exports = wasmModule.exports;
117
+ const memory = exports.memory;
118
+ const pathBuf = writeString(exports, memory, path);
119
+ const contentBuf = writeString(exports, memory, content);
120
+ const rc = exports.storage_put(pathBuf.ptr, pathBuf.len, contentBuf.ptr, contentBuf.len, overwrite ? 1 : 0);
121
+ exports.dealloc(pathBuf.ptr, pathBuf.len);
122
+ exports.dealloc(contentBuf.ptr, contentBuf.len);
123
+ throwForCode(rc);
124
+ }
125
+
126
+ function storageDump(projectDir) {
127
+ const prefix = projectDir || '';
128
+ const listJson = storageListWasm(prefix);
129
+ const paths = listJson ? JSON.parse(listJson) : [];
130
+ const entries = {};
131
+ for (const path of paths) {
132
+ entries[path] = storageGetWasm(path);
133
+ }
134
+ return entries;
135
+ }
136
+
137
+ function storageRestore(projectDir, entries) {
138
+ for (const [path, content] of Object.entries(entries)) {
139
+ if (projectDir && !path.startsWith(projectDir)) continue;
140
+ storagePutWasm(path, content, true);
141
+ }
142
+ }
143
+
144
+ function persistStorage() {
145
+ if (!storageEnabled) return;
146
+ if (typeof localStorage === 'undefined') return;
147
+ const entries = storageDump(storageProjectDir);
148
+ localStorage.setItem(storageKey, JSON.stringify(entries));
149
+ }
150
+
151
+ export async function enableBrowserStorage(projectDir, key) {
152
+ await init();
153
+ storageProjectDir = projectDir || '';
154
+ storageKey = key || `gesttalt:${storageProjectDir || 'default'}`;
155
+ storageEnabled = true;
156
+ if (typeof localStorage === 'undefined') return;
157
+ const raw = localStorage.getItem(storageKey);
158
+ if (!raw) return;
159
+ const entries = JSON.parse(raw);
160
+ storageRestore(storageProjectDir, entries);
161
+ }
162
+
78
163
  function createSnippetWasm(projectDir, timestamp, description, body, filename) {
79
164
  ensureWasmReady();
80
165
  const exports = wasmModule.exports;
@@ -102,6 +187,19 @@ function createSnippetWasm(projectDir, timestamp, description, body, filename) {
102
187
  return readResult(exports, memory);
103
188
  }
104
189
 
190
+ function listSnippetsWasm(projectDir) {
191
+ ensureWasmReady();
192
+ const exports = wasmModule.exports;
193
+ const memory = exports.memory;
194
+
195
+ const project = writeString(exports, memory, projectDir);
196
+ const rc = exports.snippet_list(project.ptr, project.len);
197
+ exports.dealloc(project.ptr, project.len);
198
+
199
+ throwForCode(rc);
200
+ return readResult(exports, memory);
201
+ }
202
+
105
203
  function readSnippetWasm(projectDir, timestamp) {
106
204
  ensureWasmReady();
107
205
  const exports = wasmModule.exports;
@@ -153,8 +251,201 @@ function deleteSnippetWasm(projectDir, timestamp) {
153
251
  throwForCode(rc);
154
252
  }
155
253
 
254
+ function createPostWasm(projectDir, slug, title, description, tags, date) {
255
+ ensureWasmReady();
256
+ const exports = wasmModule.exports;
257
+ const memory = exports.memory;
258
+
259
+ const project = writeString(exports, memory, projectDir);
260
+ const slugBuf = writeString(exports, memory, slug);
261
+ const titleBuf = writeString(exports, memory, title);
262
+ const descBuf = writeString(exports, memory, description);
263
+ const tagsBuf = writeOptional(exports, memory, tags);
264
+ const dateBuf = writeOptional(exports, memory, date);
265
+
266
+ const rc = exports.post_create(
267
+ project.ptr, project.len,
268
+ slugBuf.ptr, slugBuf.len,
269
+ titleBuf.ptr, titleBuf.len,
270
+ descBuf.ptr, descBuf.len,
271
+ tagsBuf.ptr, tagsBuf.len,
272
+ dateBuf.ptr, dateBuf.len
273
+ );
274
+
275
+ exports.dealloc(project.ptr, project.len);
276
+ exports.dealloc(slugBuf.ptr, slugBuf.len);
277
+ exports.dealloc(titleBuf.ptr, titleBuf.len);
278
+ exports.dealloc(descBuf.ptr, descBuf.len);
279
+ if (tagsBuf.ptr) exports.dealloc(tagsBuf.ptr, tagsBuf.len);
280
+ if (dateBuf.ptr) exports.dealloc(dateBuf.ptr, dateBuf.len);
281
+
282
+ throwForCode(rc);
283
+ return readResult(exports, memory);
284
+ }
285
+
286
+ function listPostsWasm(projectDir) {
287
+ ensureWasmReady();
288
+ const exports = wasmModule.exports;
289
+ const memory = exports.memory;
290
+ const project = writeString(exports, memory, projectDir);
291
+ const rc = exports.post_list(project.ptr, project.len);
292
+ exports.dealloc(project.ptr, project.len);
293
+ throwForCode(rc);
294
+ return readResult(exports, memory);
295
+ }
296
+
297
+ function readPostWasm(projectDir, slug) {
298
+ ensureWasmReady();
299
+ const exports = wasmModule.exports;
300
+ const memory = exports.memory;
301
+ const project = writeString(exports, memory, projectDir);
302
+ const slugBuf = writeString(exports, memory, slug);
303
+ const rc = exports.post_read(project.ptr, project.len, slugBuf.ptr, slugBuf.len);
304
+ exports.dealloc(project.ptr, project.len);
305
+ exports.dealloc(slugBuf.ptr, slugBuf.len);
306
+ throwForCode(rc);
307
+ return readResult(exports, memory);
308
+ }
309
+
310
+ function updatePostWasm(projectDir, slug, updates = {}) {
311
+ ensureWasmReady();
312
+ const exports = wasmModule.exports;
313
+ const memory = exports.memory;
314
+ const project = writeString(exports, memory, projectDir);
315
+ const slugBuf = writeString(exports, memory, slug);
316
+ const titleBuf = writeOptional(exports, memory, updates.title);
317
+ const descBuf = writeOptional(exports, memory, updates.description);
318
+ const tagsBuf = writeOptional(exports, memory, updates.tags);
319
+ const addTagsBuf = writeOptional(exports, memory, updates.addTags);
320
+ const removeTagsBuf = writeOptional(exports, memory, updates.removeTags);
321
+
322
+ const rc = exports.post_update(
323
+ project.ptr, project.len,
324
+ slugBuf.ptr, slugBuf.len,
325
+ titleBuf.ptr, titleBuf.len,
326
+ descBuf.ptr, descBuf.len,
327
+ tagsBuf.ptr, tagsBuf.len,
328
+ addTagsBuf.ptr, addTagsBuf.len,
329
+ removeTagsBuf.ptr, removeTagsBuf.len
330
+ );
331
+
332
+ exports.dealloc(project.ptr, project.len);
333
+ exports.dealloc(slugBuf.ptr, slugBuf.len);
334
+ if (titleBuf.ptr) exports.dealloc(titleBuf.ptr, titleBuf.len);
335
+ if (descBuf.ptr) exports.dealloc(descBuf.ptr, descBuf.len);
336
+ if (tagsBuf.ptr) exports.dealloc(tagsBuf.ptr, tagsBuf.len);
337
+ if (addTagsBuf.ptr) exports.dealloc(addTagsBuf.ptr, addTagsBuf.len);
338
+ if (removeTagsBuf.ptr) exports.dealloc(removeTagsBuf.ptr, removeTagsBuf.len);
339
+
340
+ throwForCode(rc);
341
+ }
342
+
343
+ function deletePostWasm(projectDir, slug) {
344
+ ensureWasmReady();
345
+ const exports = wasmModule.exports;
346
+ const memory = exports.memory;
347
+ const project = writeString(exports, memory, projectDir);
348
+ const slugBuf = writeString(exports, memory, slug);
349
+ const rc = exports.post_delete(project.ptr, project.len, slugBuf.ptr, slugBuf.len);
350
+ exports.dealloc(project.ptr, project.len);
351
+ exports.dealloc(slugBuf.ptr, slugBuf.len);
352
+ throwForCode(rc);
353
+ }
354
+
355
+ function createNoteWasm(projectDir, timestamp, slug, body) {
356
+ ensureWasmReady();
357
+ const exports = wasmModule.exports;
358
+ const memory = exports.memory;
359
+ const project = writeString(exports, memory, projectDir);
360
+ const slugBuf = writeOptional(exports, memory, slug);
361
+ const bodyBuf = writeOptional(exports, memory, body);
362
+
363
+ const rc = exports.note_create(
364
+ project.ptr, project.len,
365
+ BigInt(timestamp),
366
+ slugBuf.ptr, slugBuf.len,
367
+ bodyBuf.ptr, bodyBuf.len
368
+ );
369
+
370
+ exports.dealloc(project.ptr, project.len);
371
+ if (slugBuf.ptr) exports.dealloc(slugBuf.ptr, slugBuf.len);
372
+ if (bodyBuf.ptr) exports.dealloc(bodyBuf.ptr, bodyBuf.len);
373
+
374
+ throwForCode(rc);
375
+ return readResult(exports, memory);
376
+ }
377
+
378
+ function listNotesWasm(projectDir) {
379
+ ensureWasmReady();
380
+ const exports = wasmModule.exports;
381
+ const memory = exports.memory;
382
+ const project = writeString(exports, memory, projectDir);
383
+ const rc = exports.note_list(project.ptr, project.len);
384
+ exports.dealloc(project.ptr, project.len);
385
+ throwForCode(rc);
386
+ return readResult(exports, memory);
387
+ }
388
+
389
+ function readNoteWasm(projectDir, id) {
390
+ ensureWasmReady();
391
+ const exports = wasmModule.exports;
392
+ const memory = exports.memory;
393
+ const project = writeString(exports, memory, projectDir);
394
+ const idBuf = writeString(exports, memory, id);
395
+ const rc = exports.note_read(project.ptr, project.len, idBuf.ptr, idBuf.len);
396
+ exports.dealloc(project.ptr, project.len);
397
+ exports.dealloc(idBuf.ptr, idBuf.len);
398
+ throwForCode(rc);
399
+ return readResult(exports, memory);
400
+ }
401
+
402
+ function updateNoteWasm(projectDir, id, updates = {}) {
403
+ ensureWasmReady();
404
+ const exports = wasmModule.exports;
405
+ const memory = exports.memory;
406
+ const project = writeString(exports, memory, projectDir);
407
+ const idBuf = writeString(exports, memory, id);
408
+ const slugBuf = writeOptional(exports, memory, updates.slug);
409
+ const bodyBuf = writeOptional(exports, memory, updates.body);
410
+ const clearSlug = updates.clearSlug ? 1 : 0;
411
+
412
+ const rc = exports.note_update(
413
+ project.ptr, project.len,
414
+ idBuf.ptr, idBuf.len,
415
+ slugBuf.ptr, slugBuf.len,
416
+ clearSlug,
417
+ bodyBuf.ptr, bodyBuf.len
418
+ );
419
+
420
+ exports.dealloc(project.ptr, project.len);
421
+ exports.dealloc(idBuf.ptr, idBuf.len);
422
+ if (slugBuf.ptr) exports.dealloc(slugBuf.ptr, slugBuf.len);
423
+ if (bodyBuf.ptr) exports.dealloc(bodyBuf.ptr, bodyBuf.len);
424
+
425
+ throwForCode(rc);
426
+ }
427
+
428
+ function deleteNoteWasm(projectDir, id) {
429
+ ensureWasmReady();
430
+ const exports = wasmModule.exports;
431
+ const memory = exports.memory;
432
+ const project = writeString(exports, memory, projectDir);
433
+ const idBuf = writeString(exports, memory, id);
434
+ const rc = exports.note_delete(project.ptr, project.len, idBuf.ptr, idBuf.len);
435
+ exports.dealloc(project.ptr, project.len);
436
+ exports.dealloc(idBuf.ptr, idBuf.len);
437
+ throwForCode(rc);
438
+ }
439
+
156
440
  export function createSnippet(projectDir, timestamp, description, body, filename) {
157
- return createSnippetWasm(projectDir, timestamp, description, body, filename);
441
+ const result = createSnippetWasm(projectDir, timestamp, description, body, filename);
442
+ persistStorage();
443
+ return result;
444
+ }
445
+
446
+ export function listSnippets(projectDir) {
447
+ const json = listSnippetsWasm(projectDir);
448
+ return json ? JSON.parse(json) : [];
158
449
  }
159
450
 
160
451
  export function readSnippet(projectDir, timestamp) {
@@ -166,11 +457,79 @@ export function updateSnippet(projectDir, timestamp, update = {}) {
166
457
  const description = update.description ?? null;
167
458
  const body = update.body ?? null;
168
459
  const filename = update.filename ?? null;
169
- return updateSnippetWasm(projectDir, timestamp, description, body, filename);
460
+ const result = updateSnippetWasm(projectDir, timestamp, description, body, filename);
461
+ persistStorage();
462
+ return result;
170
463
  }
171
464
 
172
465
  export function deleteSnippet(projectDir, timestamp) {
173
- return deleteSnippetWasm(projectDir, timestamp);
466
+ const result = deleteSnippetWasm(projectDir, timestamp);
467
+ persistStorage();
468
+ return result;
469
+ }
470
+
471
+ export function createPost(projectDir, slug, title, description, options = {}) {
472
+ const tags = Array.isArray(options.tags) ? options.tags.join(', ') : (options.tags ?? null);
473
+ const date = options.date ?? null;
474
+ const result = createPostWasm(projectDir, slug, title, description, tags, date);
475
+ persistStorage();
476
+ return result;
477
+ }
478
+
479
+ export function listPosts(projectDir) {
480
+ const json = listPostsWasm(projectDir);
481
+ return json ? JSON.parse(json) : [];
482
+ }
483
+
484
+ export function readPost(projectDir, slug) {
485
+ const json = readPostWasm(projectDir, slug);
486
+ return json ? JSON.parse(json) : null;
487
+ }
488
+
489
+ export function updatePost(projectDir, slug, updates = {}) {
490
+ const payload = { ...updates };
491
+ if (Array.isArray(payload.tags)) payload.tags = payload.tags.join(', ');
492
+ if (Array.isArray(payload.addTags)) payload.addTags = payload.addTags.join(', ');
493
+ if (Array.isArray(payload.removeTags)) payload.removeTags = payload.removeTags.join(', ');
494
+ const result = updatePostWasm(projectDir, slug, payload);
495
+ persistStorage();
496
+ return result;
497
+ }
498
+
499
+ export function deletePost(projectDir, slug) {
500
+ const result = deletePostWasm(projectDir, slug);
501
+ persistStorage();
502
+ return result;
503
+ }
504
+
505
+ export function createNote(projectDir, timestamp, options = {}) {
506
+ const slug = options.slug ?? null;
507
+ const body = options.body ?? null;
508
+ const result = createNoteWasm(projectDir, timestamp, slug, body);
509
+ persistStorage();
510
+ return result;
511
+ }
512
+
513
+ export function listNotes(projectDir) {
514
+ const json = listNotesWasm(projectDir);
515
+ return json ? JSON.parse(json) : [];
516
+ }
517
+
518
+ export function readNote(projectDir, id) {
519
+ const json = readNoteWasm(projectDir, id);
520
+ return json ? JSON.parse(json) : null;
521
+ }
522
+
523
+ export function updateNote(projectDir, id, updates = {}) {
524
+ const result = updateNoteWasm(projectDir, id, updates);
525
+ persistStorage();
526
+ return result;
527
+ }
528
+
529
+ export function deleteNote(projectDir, id) {
530
+ const result = deleteNoteWasm(projectDir, id);
531
+ persistStorage();
532
+ return result;
174
533
  }
175
534
 
176
535
  export function isNative() {
@@ -181,4 +540,25 @@ export function isWasm() {
181
540
  return wasmReady;
182
541
  }
183
542
 
184
- export default { init, createSnippet, readSnippet, updateSnippet, deleteSnippet, isNative, isWasm, GesttaltError };
543
+ export default {
544
+ init,
545
+ enableBrowserStorage,
546
+ createSnippet,
547
+ listSnippets,
548
+ readSnippet,
549
+ updateSnippet,
550
+ deleteSnippet,
551
+ createPost,
552
+ listPosts,
553
+ readPost,
554
+ updatePost,
555
+ deletePost,
556
+ createNote,
557
+ listNotes,
558
+ readNote,
559
+ updateNote,
560
+ deleteNote,
561
+ isNative,
562
+ isWasm,
563
+ GesttaltError,
564
+ };
package/gesttalt.wasm CHANGED
Binary file
package/index.d.ts CHANGED
@@ -12,11 +12,55 @@ export interface SnippetUpdate {
12
12
  filename?: string;
13
13
  }
14
14
 
15
+ export interface PostListItem {
16
+ date: string;
17
+ slug: string;
18
+ title: string;
19
+ tags: string[];
20
+ }
21
+
22
+ export interface Post {
23
+ date: string;
24
+ slug: string;
25
+ title: string;
26
+ description: string;
27
+ tags: string[];
28
+ content: string;
29
+ }
30
+
31
+ export interface PostUpdate {
32
+ title?: string;
33
+ description?: string;
34
+ tags?: string | string[];
35
+ addTags?: string | string[];
36
+ removeTags?: string | string[];
37
+ }
38
+
39
+ export interface NoteListItem {
40
+ date: string;
41
+ id: string;
42
+ slug?: string | null;
43
+ }
44
+
45
+ export interface Note {
46
+ date: string;
47
+ id: string;
48
+ slug?: string | null;
49
+ content: string;
50
+ }
51
+
52
+ export interface NoteUpdate {
53
+ slug?: string | null;
54
+ clearSlug?: boolean;
55
+ body?: string | null;
56
+ }
57
+
15
58
  export class GesttaltError extends Error {
16
59
  code: number;
17
60
  }
18
61
 
19
62
  export function init(): Promise<void>;
63
+ export function enableBrowserStorage(projectDir: string, key?: string): Promise<void>;
20
64
 
21
65
  export function createSnippet(
22
66
  projectDir: string,
@@ -26,6 +70,8 @@ export function createSnippet(
26
70
  filename: string
27
71
  ): string;
28
72
 
73
+ export function listSnippets(projectDir: string): Snippet[];
74
+
29
75
  export function readSnippet(projectDir: string, timestamp: number): Snippet | null;
30
76
 
31
77
  export function updateSnippet(
@@ -36,5 +82,49 @@ export function updateSnippet(
36
82
 
37
83
  export function deleteSnippet(projectDir: string, timestamp: number): void;
38
84
 
85
+ export function createPost(
86
+ projectDir: string,
87
+ slug: string,
88
+ title: string,
89
+ description: string,
90
+ options?: {
91
+ tags?: string | string[];
92
+ date?: string | null;
93
+ }
94
+ ): string;
95
+
96
+ export function listPosts(projectDir: string): PostListItem[];
97
+
98
+ export function readPost(projectDir: string, slug: string): Post | null;
99
+
100
+ export function updatePost(
101
+ projectDir: string,
102
+ slug: string,
103
+ update?: PostUpdate
104
+ ): void;
105
+
106
+ export function deletePost(projectDir: string, slug: string): void;
107
+
108
+ export function createNote(
109
+ projectDir: string,
110
+ timestamp: number,
111
+ options?: {
112
+ slug?: string | null;
113
+ body?: string | null;
114
+ }
115
+ ): string;
116
+
117
+ export function listNotes(projectDir: string): NoteListItem[];
118
+
119
+ export function readNote(projectDir: string, id: string): Note | null;
120
+
121
+ export function updateNote(
122
+ projectDir: string,
123
+ id: string,
124
+ update?: NoteUpdate
125
+ ): void;
126
+
127
+ export function deleteNote(projectDir: string, id: string): void;
128
+
39
129
  export function isNative(): boolean;
40
130
  export function isWasm(): boolean;