@dinoxx/dinox-cli 2.0.0 → 2.1.1
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/commands/notes/repo/read.d.ts +8 -0
- package/dist/commands/notes/repo/read.js +321 -0
- package/dist/commands/notes/repo/resolve.d.ts +8 -0
- package/dist/commands/notes/repo/resolve.js +187 -0
- package/dist/commands/notes/repo/search.d.ts +42 -0
- package/dist/commands/notes/repo/search.js +513 -0
- package/dist/commands/notes/repo/shared.d.ts +190 -0
- package/dist/commands/notes/repo/shared.js +102 -0
- package/dist/commands/notes/repo/write.d.ts +24 -0
- package/dist/commands/notes/repo/write.js +251 -0
- package/dist/commands/notes/repo.d.ts +7 -186
- package/dist/commands/notes/repo.js +7 -1360
- package/dist/commands/schema/commandMetadata.js +4 -4
- package/dist/commands/schema/index.d.ts +1 -0
- package/dist/commands/schema/index.js +23 -2
- package/dist/commands/schema/renderSkills.d.ts +4 -0
- package/dist/commands/schema/renderSkills.js +41 -2
- package/dist/commands/skills/index.d.ts +26 -0
- package/dist/commands/skills/index.js +115 -11
- package/dist/commands/storage/repo/configs.d.ts +30 -0
- package/dist/commands/storage/repo/configs.js +259 -0
- package/dist/commands/storage/repo/operations.d.ts +25 -0
- package/dist/commands/storage/repo/operations.js +337 -0
- package/dist/commands/storage/repo/remote.d.ts +32 -0
- package/dist/commands/storage/repo/remote.js +132 -0
- package/dist/commands/storage/repo/resources.d.ts +12 -0
- package/dist/commands/storage/repo/resources.js +134 -0
- package/dist/commands/storage/repo/shared.d.ts +181 -0
- package/dist/commands/storage/repo/shared.js +36 -0
- package/dist/commands/storage/repo/targets.d.ts +12 -0
- package/dist/commands/storage/repo/targets.js +178 -0
- package/dist/commands/storage/repo.d.ts +3 -166
- package/dist/commands/storage/repo.js +4 -1034
- package/dist/contract/snapshot.d.ts +30 -0
- package/dist/contract/snapshot.js +114 -0
- package/dist/daemon/client.js +2 -2
- package/dist/powersync/uploader.js +27 -2
- package/dist/skills/commandRefs.d.ts +21 -0
- package/dist/skills/commandRefs.js +132 -0
- package/dist/skills/generate.d.ts +13 -0
- package/dist/skills/generate.js +80 -0
- package/dist/skills/registry.d.ts +13 -0
- package/dist/skills/registry.js +58 -0
- package/dist/utils/errorCodes.d.ts +311 -0
- package/dist/utils/errorCodes.js +92 -0
- package/dist/utils/errors.d.ts +13 -2
- package/dist/utils/errors.js +11 -0
- package/package.json +11 -4
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Row and result types plus stored-value normalizers shared by the note repository modules.
|
|
2
|
+
import { canonicalizeBoxPath } from '../../boxes/repo.js';
|
|
3
|
+
export const MAX_SEARCH_SUMMARY_CHARS = 200;
|
|
4
|
+
export function normalizeStoredFlag(value) {
|
|
5
|
+
if (typeof value === 'number') {
|
|
6
|
+
return value === 1;
|
|
7
|
+
}
|
|
8
|
+
if (typeof value === 'string') {
|
|
9
|
+
return value.trim() === '1';
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
export function normalizeStoredStarred(value) {
|
|
14
|
+
return normalizeStoredFlag(value);
|
|
15
|
+
}
|
|
16
|
+
export function parseStoredTags(raw) {
|
|
17
|
+
if (!raw) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(raw);
|
|
22
|
+
if (!Array.isArray(parsed)) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const result = [];
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
for (const value of parsed) {
|
|
28
|
+
const normalized = String(value).trim();
|
|
29
|
+
const key = normalizeLookupKey(normalized);
|
|
30
|
+
if (!key || seen.has(key)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
seen.add(key);
|
|
34
|
+
result.push(normalized);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function parseZettelBoxIds(raw) {
|
|
43
|
+
const value = raw?.trim();
|
|
44
|
+
if (!value) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const parsed = JSON.parse(value);
|
|
49
|
+
if (!Array.isArray(parsed)) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
return Array.from(new Set(parsed
|
|
53
|
+
.map((entry) => String(entry).trim())
|
|
54
|
+
.filter((entry) => entry.length > 0)));
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export async function loadZettelBoxNameMap(db, ids) {
|
|
61
|
+
const map = new Map();
|
|
62
|
+
if (ids.length === 0) {
|
|
63
|
+
return map;
|
|
64
|
+
}
|
|
65
|
+
const chunkSize = 500;
|
|
66
|
+
for (let i = 0; i < ids.length; i += chunkSize) {
|
|
67
|
+
const batch = ids.slice(i, i + chunkSize);
|
|
68
|
+
const placeholders = batch.map(() => '?').join(', ');
|
|
69
|
+
const rows = await db.getAll(`
|
|
70
|
+
SELECT id, name, path
|
|
71
|
+
FROM c_zettel_box
|
|
72
|
+
WHERE (is_del IS NULL OR is_del = 0)
|
|
73
|
+
AND id IN (${placeholders})
|
|
74
|
+
`, batch);
|
|
75
|
+
for (const row of rows) {
|
|
76
|
+
const id = row.id?.trim() ?? '';
|
|
77
|
+
if (!id) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const path = canonicalizeBoxPath(row.path ?? row.name ?? '');
|
|
81
|
+
map.set(id, path || row.name?.trim() || '');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return map;
|
|
85
|
+
}
|
|
86
|
+
export function resolveSummary(summary, contentText) {
|
|
87
|
+
const summaryValue = summary?.trim() ?? '';
|
|
88
|
+
if (summaryValue.length > 0) {
|
|
89
|
+
return truncateSearchSummary(summaryValue);
|
|
90
|
+
}
|
|
91
|
+
return truncateSearchSummary(contentText?.trim() ?? '');
|
|
92
|
+
}
|
|
93
|
+
export function truncateSearchSummary(value) {
|
|
94
|
+
const chars = Array.from(value);
|
|
95
|
+
if (chars.length <= MAX_SEARCH_SUMMARY_CHARS) {
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
98
|
+
return chars.slice(0, MAX_SEARCH_SUMMARY_CHARS).join('');
|
|
99
|
+
}
|
|
100
|
+
export function normalizeLookupKey(value) {
|
|
101
|
+
return value.trim().toLowerCase();
|
|
102
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AbstractPowerSyncDatabase } from '@powersync/common';
|
|
2
|
+
import { type UpdateNoteResult } from './shared.js';
|
|
3
|
+
export declare function createNote(db: AbstractPowerSyncDatabase, input: {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
noteType: 'note' | 'crawl';
|
|
7
|
+
contentMd: string;
|
|
8
|
+
contentText: string;
|
|
9
|
+
contentJson: unknown;
|
|
10
|
+
tags: string[];
|
|
11
|
+
zettelBoxIds: string[];
|
|
12
|
+
userId: string;
|
|
13
|
+
imageDetail?: unknown[];
|
|
14
|
+
}): Promise<{
|
|
15
|
+
id: string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function updateNote(db: AbstractPowerSyncDatabase, input: {
|
|
18
|
+
id: string;
|
|
19
|
+
tags?: string[];
|
|
20
|
+
zettelBoxIds?: string[];
|
|
21
|
+
starred?: boolean;
|
|
22
|
+
}): Promise<UpdateNoteResult>;
|
|
23
|
+
export declare function assertNotesUpdatable(db: AbstractPowerSyncDatabase, noteIds: string[]): Promise<void>;
|
|
24
|
+
export declare function softDeleteNote(db: AbstractPowerSyncDatabase, id: string): Promise<void>;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// Note writes: create, metadata update, updatability checks, and soft delete.
|
|
2
|
+
import { DinoxError } from '../../../utils/errors.js';
|
|
3
|
+
import { nowIsoUtc } from '../../../utils/time.js';
|
|
4
|
+
import { deriveImageDetailFromContentJson } from '../../todo/contentModel.js';
|
|
5
|
+
import { normalizeLookupKey, parseStoredTags, parseZettelBoxIds, } from './shared.js';
|
|
6
|
+
export async function createNote(db, input) {
|
|
7
|
+
const userId = input.userId.trim();
|
|
8
|
+
if (!userId) {
|
|
9
|
+
throw new DinoxError('userId is required to create a note');
|
|
10
|
+
}
|
|
11
|
+
const now = nowIsoUtc();
|
|
12
|
+
const contentJson = JSON.stringify(input.contentJson);
|
|
13
|
+
const tags = JSON.stringify(input.tags);
|
|
14
|
+
const zettelBoxes = JSON.stringify(input.zettelBoxIds);
|
|
15
|
+
const imageDetail = JSON.stringify(Array.isArray(input.imageDetail)
|
|
16
|
+
? input.imageDetail
|
|
17
|
+
: deriveImageDetailFromContentJson(input.contentJson, input.id));
|
|
18
|
+
const columns = await db.getAll('PRAGMA table_info(c_note)', []);
|
|
19
|
+
const columnNames = new Set(columns
|
|
20
|
+
.map((row) => row.name?.trim().toLowerCase() ?? '')
|
|
21
|
+
.filter((name) => name.length > 0));
|
|
22
|
+
const userColumns = [];
|
|
23
|
+
if (columnNames.has('user_id')) {
|
|
24
|
+
userColumns.push('user_id');
|
|
25
|
+
}
|
|
26
|
+
if (columnNames.has('user_no')) {
|
|
27
|
+
userColumns.push('user_no');
|
|
28
|
+
}
|
|
29
|
+
if (userColumns.length === 0) {
|
|
30
|
+
throw new DinoxError('c_note table is missing both user_id and user_no columns');
|
|
31
|
+
}
|
|
32
|
+
if (!columnNames.has('type')) {
|
|
33
|
+
throw new DinoxError('c_note table is missing type column');
|
|
34
|
+
}
|
|
35
|
+
const requiredColumns = [
|
|
36
|
+
'id',
|
|
37
|
+
'title',
|
|
38
|
+
'type',
|
|
39
|
+
'content_md',
|
|
40
|
+
'content_json',
|
|
41
|
+
'content_text',
|
|
42
|
+
'tags',
|
|
43
|
+
'zettel_boxes',
|
|
44
|
+
'created_at',
|
|
45
|
+
'updated_at',
|
|
46
|
+
'is_del',
|
|
47
|
+
'version',
|
|
48
|
+
];
|
|
49
|
+
const missingRequired = requiredColumns.filter((name) => !columnNames.has(name));
|
|
50
|
+
if (missingRequired.length > 0) {
|
|
51
|
+
throw new DinoxError(`c_note table is missing required columns: ${missingRequired.join(', ')}`);
|
|
52
|
+
}
|
|
53
|
+
const fullInsertEntries = [
|
|
54
|
+
['id', input.id],
|
|
55
|
+
['title', input.title],
|
|
56
|
+
['type', input.noteType],
|
|
57
|
+
['user_no', userId],
|
|
58
|
+
['user_id', userId],
|
|
59
|
+
['created_at', now],
|
|
60
|
+
['updated_at', now],
|
|
61
|
+
['is_del', 0],
|
|
62
|
+
['status', 0],
|
|
63
|
+
['version', 1],
|
|
64
|
+
['content', ''],
|
|
65
|
+
['content_json', contentJson],
|
|
66
|
+
['content_text', input.contentText],
|
|
67
|
+
['content_md', input.contentMd],
|
|
68
|
+
['summary', ''],
|
|
69
|
+
['tags', tags],
|
|
70
|
+
['zettel_boxes', zettelBoxes],
|
|
71
|
+
['images', '[]'],
|
|
72
|
+
['files', '[]'],
|
|
73
|
+
['audios', '[]'],
|
|
74
|
+
['audio_detail', '{}'],
|
|
75
|
+
['image_detail', imageDetail],
|
|
76
|
+
['source', ''],
|
|
77
|
+
['resource_id', null],
|
|
78
|
+
['note_ids', '[]'],
|
|
79
|
+
['extra_data', '{}'],
|
|
80
|
+
['properties', null],
|
|
81
|
+
['is_pub', 0],
|
|
82
|
+
['format_type', ''],
|
|
83
|
+
['comments', '[]'],
|
|
84
|
+
['is_top', 0],
|
|
85
|
+
['pinned_at', '1997-01-01T00:00:00.000Z'],
|
|
86
|
+
['starred_at', null],
|
|
87
|
+
['chat_context', '{}'],
|
|
88
|
+
['bid_links', '[]'],
|
|
89
|
+
];
|
|
90
|
+
const insertEntries = fullInsertEntries.filter(([column]) => columnNames.has(column));
|
|
91
|
+
const insertColumns = insertEntries.map(([column]) => column);
|
|
92
|
+
const placeholders = insertEntries.map(() => '?').join(', ');
|
|
93
|
+
const params = insertEntries.map(([, value]) => value);
|
|
94
|
+
await db.execute(`
|
|
95
|
+
INSERT INTO c_note (
|
|
96
|
+
${insertColumns.join(', ')}
|
|
97
|
+
) VALUES (${placeholders})
|
|
98
|
+
`, params);
|
|
99
|
+
return { id: input.id };
|
|
100
|
+
}
|
|
101
|
+
function normalizeDistinctStrings(values) {
|
|
102
|
+
return Array.from(new Set(values
|
|
103
|
+
.map((value) => value.trim())
|
|
104
|
+
.filter((value) => value.length > 0)));
|
|
105
|
+
}
|
|
106
|
+
function sameTagSet(left, right) {
|
|
107
|
+
if (left.length !== right.length) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const leftKeys = left.map(normalizeLookupKey).sort();
|
|
111
|
+
const rightKeys = right.map(normalizeLookupKey).sort();
|
|
112
|
+
return leftKeys.every((value, index) => value === rightKeys[index]);
|
|
113
|
+
}
|
|
114
|
+
function sameStringSet(left, right) {
|
|
115
|
+
if (left.length !== right.length) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const leftSorted = [...left].sort();
|
|
119
|
+
const rightSorted = [...right].sort();
|
|
120
|
+
return leftSorted.every((value, index) => value === rightSorted[index]);
|
|
121
|
+
}
|
|
122
|
+
export async function updateNote(db, input) {
|
|
123
|
+
const id = input.id.trim();
|
|
124
|
+
if (!id) {
|
|
125
|
+
throw new DinoxError('Note id is required');
|
|
126
|
+
}
|
|
127
|
+
const shouldUpdateTags = Array.isArray(input.tags);
|
|
128
|
+
const shouldUpdateBoxes = Array.isArray(input.zettelBoxIds);
|
|
129
|
+
const shouldUpdateStarred = typeof input.starred === 'boolean';
|
|
130
|
+
if (!shouldUpdateTags && !shouldUpdateBoxes && !shouldUpdateStarred) {
|
|
131
|
+
throw new DinoxError('At least one field is required: tags, boxes, or starred');
|
|
132
|
+
}
|
|
133
|
+
const existing = await db.getOptional(`
|
|
134
|
+
SELECT id, tags, zettel_boxes, is_del, starred_at
|
|
135
|
+
FROM c_note
|
|
136
|
+
WHERE id = ?
|
|
137
|
+
`, [id]);
|
|
138
|
+
if (!existing) {
|
|
139
|
+
throw new DinoxError(`Note not found: ${id}`);
|
|
140
|
+
}
|
|
141
|
+
if (typeof existing.is_del === 'number' && existing.is_del !== 0) {
|
|
142
|
+
throw new DinoxError(`Note has been deleted: ${id}`);
|
|
143
|
+
}
|
|
144
|
+
const currentTags = parseStoredTags(existing.tags);
|
|
145
|
+
const currentZettelBoxIds = parseZettelBoxIds(existing.zettel_boxes);
|
|
146
|
+
const currentStarred = existing.starred_at !== null;
|
|
147
|
+
const nextTags = shouldUpdateTags ? normalizeDistinctStrings(input.tags) : currentTags;
|
|
148
|
+
const nextZettelBoxIds = shouldUpdateBoxes ? normalizeDistinctStrings(input.zettelBoxIds) : currentZettelBoxIds;
|
|
149
|
+
const nextStarred = shouldUpdateStarred ? input.starred : currentStarred;
|
|
150
|
+
const tagsChanged = shouldUpdateTags && !sameTagSet(currentTags, nextTags);
|
|
151
|
+
const boxesChanged = shouldUpdateBoxes && !sameStringSet(currentZettelBoxIds, nextZettelBoxIds);
|
|
152
|
+
const starredChanged = shouldUpdateStarred && currentStarred !== nextStarred;
|
|
153
|
+
if (!tagsChanged && !boxesChanged && !starredChanged) {
|
|
154
|
+
return {
|
|
155
|
+
id,
|
|
156
|
+
updated: false,
|
|
157
|
+
changed: [],
|
|
158
|
+
tags: currentTags,
|
|
159
|
+
zettelBoxIds: currentZettelBoxIds,
|
|
160
|
+
is_starred: currentStarred,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const setParts = [];
|
|
164
|
+
const params = [];
|
|
165
|
+
if (tagsChanged) {
|
|
166
|
+
setParts.push('tags = ?');
|
|
167
|
+
params.push(JSON.stringify(nextTags));
|
|
168
|
+
}
|
|
169
|
+
if (boxesChanged) {
|
|
170
|
+
setParts.push('zettel_boxes = ?');
|
|
171
|
+
params.push(JSON.stringify(nextZettelBoxIds));
|
|
172
|
+
}
|
|
173
|
+
if (starredChanged) {
|
|
174
|
+
setParts.push('starred_at = ?');
|
|
175
|
+
}
|
|
176
|
+
const updatedAt = nowIsoUtc();
|
|
177
|
+
if (starredChanged) {
|
|
178
|
+
params.push(nextStarred ? updatedAt : null);
|
|
179
|
+
}
|
|
180
|
+
setParts.push('updated_at = ?');
|
|
181
|
+
params.push(updatedAt);
|
|
182
|
+
setParts.push('version = COALESCE(version, 0) + 1');
|
|
183
|
+
params.push(id);
|
|
184
|
+
await db.execute(`
|
|
185
|
+
UPDATE c_note
|
|
186
|
+
SET ${setParts.join(',\n ')}
|
|
187
|
+
WHERE id = ?
|
|
188
|
+
`, params);
|
|
189
|
+
return {
|
|
190
|
+
id,
|
|
191
|
+
updated: true,
|
|
192
|
+
changed: [
|
|
193
|
+
...(tagsChanged ? ['tags'] : []),
|
|
194
|
+
...(boxesChanged ? ['boxes'] : []),
|
|
195
|
+
...(starredChanged ? ['is_starred'] : []),
|
|
196
|
+
],
|
|
197
|
+
tags: nextTags,
|
|
198
|
+
zettelBoxIds: nextZettelBoxIds,
|
|
199
|
+
is_starred: nextStarred,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
export async function assertNotesUpdatable(db, noteIds) {
|
|
203
|
+
const ids = Array.from(new Set(noteIds
|
|
204
|
+
.map((id) => id.trim())
|
|
205
|
+
.filter((id) => id.length > 0)));
|
|
206
|
+
if (ids.length === 0) {
|
|
207
|
+
throw new DinoxError('At least one note id is required');
|
|
208
|
+
}
|
|
209
|
+
const existing = new Map();
|
|
210
|
+
const chunkSize = 500;
|
|
211
|
+
for (let index = 0; index < ids.length; index += chunkSize) {
|
|
212
|
+
const batch = ids.slice(index, index + chunkSize);
|
|
213
|
+
const placeholders = batch.map(() => '?').join(', ');
|
|
214
|
+
const rows = await db.getAll(`
|
|
215
|
+
SELECT id, is_del
|
|
216
|
+
FROM c_note
|
|
217
|
+
WHERE id IN (${placeholders})
|
|
218
|
+
`, batch);
|
|
219
|
+
for (const row of rows) {
|
|
220
|
+
const id = row.id?.trim();
|
|
221
|
+
if (!id) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
existing.set(id, row.is_del ?? null);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const missing = ids.filter((id) => !existing.has(id));
|
|
228
|
+
if (missing.length > 0) {
|
|
229
|
+
throw new DinoxError(`Notes not found: ${missing.join(', ')}`);
|
|
230
|
+
}
|
|
231
|
+
const deleted = ids.filter((id) => {
|
|
232
|
+
const isDel = existing.get(id);
|
|
233
|
+
return typeof isDel === 'number' && isDel !== 0;
|
|
234
|
+
});
|
|
235
|
+
if (deleted.length > 0) {
|
|
236
|
+
throw new DinoxError(`Notes have been deleted: ${deleted.join(', ')}`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
export async function softDeleteNote(db, id) {
|
|
240
|
+
const existing = await db.getOptional('SELECT id FROM c_note WHERE id = ?', [id]);
|
|
241
|
+
if (!existing) {
|
|
242
|
+
throw new DinoxError(`Note not found: ${id}`);
|
|
243
|
+
}
|
|
244
|
+
await db.execute(`
|
|
245
|
+
UPDATE c_note
|
|
246
|
+
SET is_del = 1,
|
|
247
|
+
updated_at = ?,
|
|
248
|
+
version = COALESCE(version, 0) + 1
|
|
249
|
+
WHERE id = ?
|
|
250
|
+
`, [nowIsoUtc(), id]);
|
|
251
|
+
}
|
|
@@ -1,186 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export type NoteRow
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
summary: string | null;
|
|
9
|
-
zettel_boxes: string | null;
|
|
10
|
-
tags: string | null;
|
|
11
|
-
created_at: string | null;
|
|
12
|
-
updated_at: string | null;
|
|
13
|
-
is_del: number | null;
|
|
14
|
-
starred_at: string | null;
|
|
15
|
-
is_starred: number | null;
|
|
16
|
-
version: number | null;
|
|
17
|
-
};
|
|
18
|
-
type SearchNotesOptions = {
|
|
19
|
-
includeDeleted: boolean;
|
|
20
|
-
starred?: boolean;
|
|
21
|
-
tagsExpression?: string;
|
|
22
|
-
createdAtFrom?: string;
|
|
23
|
-
createdAtTo?: string;
|
|
24
|
-
zettelBoxIds?: string[];
|
|
25
|
-
matchEmptyZettelBoxes?: boolean;
|
|
26
|
-
sqlExpression?: string;
|
|
27
|
-
};
|
|
28
|
-
export type SearchedNote = {
|
|
29
|
-
id: string;
|
|
30
|
-
title: string;
|
|
31
|
-
summary: string;
|
|
32
|
-
tags: string[];
|
|
33
|
-
created_at: string | null;
|
|
34
|
-
starred_at: string | null;
|
|
35
|
-
is_starred: boolean;
|
|
36
|
-
zettel_boxes: string[];
|
|
37
|
-
};
|
|
38
|
-
export type NoteDetail = {
|
|
39
|
-
id: string;
|
|
40
|
-
created_at: string | null;
|
|
41
|
-
updated_at: string | null;
|
|
42
|
-
title: string | null;
|
|
43
|
-
type: string | null;
|
|
44
|
-
source: string | null;
|
|
45
|
-
tags: string[];
|
|
46
|
-
is_del: number | null;
|
|
47
|
-
is_pub: boolean;
|
|
48
|
-
properties: Record<string, unknown>;
|
|
49
|
-
starred_at: string | null;
|
|
50
|
-
is_starred: boolean;
|
|
51
|
-
content_md: string | null;
|
|
52
|
-
content_text: string | null;
|
|
53
|
-
content_json: unknown;
|
|
54
|
-
zettel_boxes: string[];
|
|
55
|
-
};
|
|
56
|
-
export type NoteExportItem = {
|
|
57
|
-
id: string;
|
|
58
|
-
created_at: string | null;
|
|
59
|
-
updated_at: string | null;
|
|
60
|
-
title: string | null;
|
|
61
|
-
type: string | null;
|
|
62
|
-
source: string | null;
|
|
63
|
-
summary: string | null;
|
|
64
|
-
tags: string[];
|
|
65
|
-
is_del: number | null;
|
|
66
|
-
is_pub: boolean;
|
|
67
|
-
properties: Record<string, unknown>;
|
|
68
|
-
starred_at: string | null;
|
|
69
|
-
is_starred: boolean;
|
|
70
|
-
content_md: string;
|
|
71
|
-
content_text: string | null;
|
|
72
|
-
content_json: unknown;
|
|
73
|
-
box_ids: string[];
|
|
74
|
-
boxes: string[];
|
|
75
|
-
};
|
|
76
|
-
export type NoteContext = {
|
|
77
|
-
id: string;
|
|
78
|
-
title: string;
|
|
79
|
-
summary: string;
|
|
80
|
-
tags: string[];
|
|
81
|
-
created_at: string | null;
|
|
82
|
-
updated_at: string | null;
|
|
83
|
-
is_del: number | null;
|
|
84
|
-
starred_at: string | null;
|
|
85
|
-
is_starred: boolean;
|
|
86
|
-
zettel_boxes: string[];
|
|
87
|
-
links: {
|
|
88
|
-
backlinks: number;
|
|
89
|
-
outlinks: number;
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
export type NotePreview = {
|
|
93
|
-
id: string;
|
|
94
|
-
title: string;
|
|
95
|
-
requested_lines: number;
|
|
96
|
-
total_lines: number;
|
|
97
|
-
returned_lines: number;
|
|
98
|
-
truncated: boolean;
|
|
99
|
-
preview: string;
|
|
100
|
-
updated_at: string | null;
|
|
101
|
-
};
|
|
102
|
-
export type UpdateNoteResult = {
|
|
103
|
-
id: string;
|
|
104
|
-
updated: boolean;
|
|
105
|
-
changed: string[];
|
|
106
|
-
tags: string[];
|
|
107
|
-
zettelBoxIds: string[];
|
|
108
|
-
is_starred: boolean;
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* JSON-safe note-search request. Box *names/paths* are carried (not resolved ids) so the
|
|
112
|
-
* same payload can be executed either in-process or sent to the daemon over the wire;
|
|
113
|
-
* id resolution happens inside {@link executeNoteSearch} against whichever db runs it.
|
|
114
|
-
*/
|
|
115
|
-
export type NoteSearchExecuteParams = {
|
|
116
|
-
keyword: string;
|
|
117
|
-
includeDeleted: boolean;
|
|
118
|
-
tagsExpression?: string;
|
|
119
|
-
createdAtFrom?: string;
|
|
120
|
-
createdAtTo?: string;
|
|
121
|
-
starred?: boolean;
|
|
122
|
-
boxValues: string[];
|
|
123
|
-
matchEmptyZettelBoxes: boolean;
|
|
124
|
-
sqlExpression?: string;
|
|
125
|
-
limit?: number;
|
|
126
|
-
offset?: number;
|
|
127
|
-
};
|
|
128
|
-
export type NoteSearchExecuteResult = {
|
|
129
|
-
rows: SearchedNote[];
|
|
130
|
-
totalCount: number;
|
|
131
|
-
/** Resolved zettel-box ids, surfaced so callers can echo them in response metadata. */
|
|
132
|
-
zettelBoxIds: string[];
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Resolve box names to ids and run the note search. Shared by the local command path and
|
|
136
|
-
* the daemon RPC handler so both produce identical results from one implementation.
|
|
137
|
-
*/
|
|
138
|
-
export declare function executeNoteSearch(db: AbstractPowerSyncDatabase, params: NoteSearchExecuteParams): Promise<NoteSearchExecuteResult>;
|
|
139
|
-
export declare function searchNotes(db: AbstractPowerSyncDatabase, query: string, options: SearchNotesOptions): Promise<SearchedNote[]>;
|
|
140
|
-
type SearchNotesPageOptions = SearchNotesOptions & {
|
|
141
|
-
limit?: number;
|
|
142
|
-
offset?: number;
|
|
143
|
-
};
|
|
144
|
-
type SearchNotesPageResult = {
|
|
145
|
-
rows: SearchedNote[];
|
|
146
|
-
totalCount: number;
|
|
147
|
-
};
|
|
148
|
-
export declare function searchNotesPage(db: AbstractPowerSyncDatabase, query: string, options: SearchNotesPageOptions): Promise<SearchNotesPageResult>;
|
|
149
|
-
export declare function parseZettelBoxIds(raw: string | null): string[];
|
|
150
|
-
export declare function getNote(db: AbstractPowerSyncDatabase, id: string): Promise<NoteRow | null>;
|
|
151
|
-
export declare function getNoteContext(db: AbstractPowerSyncDatabase, id: string): Promise<NoteContext | null>;
|
|
152
|
-
export declare function getNotePreview(db: AbstractPowerSyncDatabase, id: string, requestedLines: number): Promise<NotePreview | null>;
|
|
153
|
-
export declare function getNoteDetails(db: AbstractPowerSyncDatabase, ids: string[]): Promise<NoteDetail[]>;
|
|
154
|
-
export declare function getNoteDetail(db: AbstractPowerSyncDatabase, id: string): Promise<NoteDetail | null>;
|
|
155
|
-
export declare function getNoteExportItems(db: AbstractPowerSyncDatabase, ids: string[]): Promise<NoteExportItem[]>;
|
|
156
|
-
export declare function createNote(db: AbstractPowerSyncDatabase, input: {
|
|
157
|
-
id: string;
|
|
158
|
-
title: string;
|
|
159
|
-
noteType: 'note' | 'crawl';
|
|
160
|
-
contentMd: string;
|
|
161
|
-
contentText: string;
|
|
162
|
-
contentJson: unknown;
|
|
163
|
-
tags: string[];
|
|
164
|
-
zettelBoxIds: string[];
|
|
165
|
-
userId: string;
|
|
166
|
-
imageDetail?: unknown[];
|
|
167
|
-
}): Promise<{
|
|
168
|
-
id: string;
|
|
169
|
-
}>;
|
|
170
|
-
export declare function validateTagsForCreate(db: AbstractPowerSyncDatabase, requestedTags: string[], userId: string): Promise<string[]>;
|
|
171
|
-
export declare function validateTagsForUpdate(db: AbstractPowerSyncDatabase, requestedTags: string[], userId: string): Promise<string[]>;
|
|
172
|
-
export declare function validateTagsForBulk(db: AbstractPowerSyncDatabase, requestedTags: string[], userId: string): Promise<string[]>;
|
|
173
|
-
export declare function parseStoredTags(raw: string | null): string[];
|
|
174
|
-
export declare function updateNote(db: AbstractPowerSyncDatabase, input: {
|
|
175
|
-
id: string;
|
|
176
|
-
tags?: string[];
|
|
177
|
-
zettelBoxIds?: string[];
|
|
178
|
-
starred?: boolean;
|
|
179
|
-
}): Promise<UpdateNoteResult>;
|
|
180
|
-
export declare function assertNotesUpdatable(db: AbstractPowerSyncDatabase, noteIds: string[]): Promise<void>;
|
|
181
|
-
export declare function resolveZettelBoxIdsForCreate(db: AbstractPowerSyncDatabase, requestedNames: string[]): Promise<string[]>;
|
|
182
|
-
export declare function resolveZettelBoxIdsForSearch(db: AbstractPowerSyncDatabase, requestedNames: string[]): Promise<string[]>;
|
|
183
|
-
export declare function resolveZettelBoxIdsForUpdate(db: AbstractPowerSyncDatabase, requestedNames: string[]): Promise<string[]>;
|
|
184
|
-
export declare function resolveZettelBoxIdsForBulk(db: AbstractPowerSyncDatabase, requestedNames: string[]): Promise<string[]>;
|
|
185
|
-
export declare function softDeleteNote(db: AbstractPowerSyncDatabase, id: string): Promise<void>;
|
|
186
|
-
export {};
|
|
1
|
+
export { parseStoredTags, parseZettelBoxIds, } from './repo/shared.js';
|
|
2
|
+
export type { NoteContext, NoteDetail, NoteExportItem, NotePreview, NoteRow, SearchedNote, UpdateNoteResult, } from './repo/shared.js';
|
|
3
|
+
export { executeNoteSearch, searchNotes, searchNotesPage, } from './repo/search.js';
|
|
4
|
+
export type { NoteSearchExecuteParams, NoteSearchExecuteResult, } from './repo/search.js';
|
|
5
|
+
export { getNote, getNoteContext, getNoteDetail, getNoteDetails, getNoteExportItems, getNotePreview, } from './repo/read.js';
|
|
6
|
+
export { assertNotesUpdatable, createNote, softDeleteNote, updateNote, } from './repo/write.js';
|
|
7
|
+
export { resolveZettelBoxIdsForBulk, resolveZettelBoxIdsForCreate, resolveZettelBoxIdsForSearch, resolveZettelBoxIdsForUpdate, validateTagsForBulk, validateTagsForCreate, validateTagsForUpdate, } from './repo/resolve.js';
|