@dinoxx/dinox-cli 2.1.1 → 2.3.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.
- package/dist/cli.js +4 -0
- package/dist/commands/domain/options.d.ts +10 -0
- package/dist/commands/domain/options.js +75 -0
- package/dist/commands/domain/run.d.ts +24 -0
- package/dist/commands/domain/run.js +137 -0
- package/dist/commands/notes/actions.js +72 -20
- package/dist/commands/notes/createFromTemplate.d.ts +35 -0
- package/dist/commands/notes/createFromTemplate.js +58 -0
- package/dist/commands/notes/descriptors.js +12 -5
- package/dist/commands/notes/dryRun.d.ts +1 -0
- package/dist/commands/notes/dryRun.js +8 -2
- package/dist/commands/notes/repo/read.js +4 -23
- package/dist/commands/notes/repo/shared.d.ts +2 -0
- package/dist/commands/notes/repo/write.d.ts +3 -0
- package/dist/commands/notes/repo/write.js +16 -5
- package/dist/commands/properties/index.d.ts +16 -0
- package/dist/commands/properties/index.js +640 -0
- package/dist/commands/properties/repo.d.ts +150 -0
- package/dist/commands/properties/repo.js +272 -0
- package/dist/commands/savedViews/fields.d.ts +28 -0
- package/dist/commands/savedViews/fields.js +87 -0
- package/dist/commands/savedViews/index.js +203 -164
- package/dist/commands/savedViews/model.d.ts +27 -69
- package/dist/commands/savedViews/model.js +63 -279
- package/dist/commands/savedViews/repo.d.ts +64 -62
- package/dist/commands/savedViews/repo.js +309 -428
- package/dist/commands/schema/renderSkills.js +29 -5
- package/dist/commands/schema/spec.js +4 -0
- package/dist/commands/templates/index.d.ts +4 -0
- package/dist/commands/templates/index.js +290 -0
- package/dist/commands/templates/model.d.ts +12 -34
- package/dist/commands/templates/model.js +39 -83
- package/dist/commands/templates/repo.d.ts +53 -0
- package/dist/commands/templates/repo.js +78 -0
- package/dist/skills/registry.js +7 -0
- package/dist/utils/errorCodes.d.ts +212 -0
- package/dist/utils/errorCodes.js +53 -0
- package/dist/vendor/electron/domain/note-templates.d.ts +3 -0
- package/dist/vendor/electron/domain/note-templates.js +232 -0
- package/dist/vendor/electron/domain/properties.d.ts +10 -0
- package/dist/vendor/electron/domain/properties.js +1538 -0
- package/dist/vendor/electron/domain/saved-view-analytics.d.ts +45 -0
- package/dist/vendor/electron/domain/saved-view-analytics.js +365 -0
- package/dist/vendor/electron/domain/saved-view-relative-date.d.ts +21 -0
- package/dist/vendor/electron/domain/saved-view-relative-date.js +153 -0
- package/dist/vendor/electron/domain/saved-views.d.ts +61 -0
- package/dist/vendor/electron/domain/saved-views.js +1117 -0
- package/dist/vendor/electron/rpc.d.ts +22 -0
- package/dist/vendor/electron/rpc.js +27 -0
- package/dist/vendor/electron/shared/ai-errors.d.ts +11 -0
- package/dist/vendor/electron/shared/ai-errors.js +107 -0
- package/dist/vendor/electron/shared/external-types.d.ts +2 -0
- package/dist/vendor/electron/shared/external-types.js +1 -0
- package/dist/vendor/electron/shared/index.d.ts +9 -0
- package/dist/vendor/electron/shared/index.js +7 -0
- package/dist/vendor/electron/shared/note-properties.d.ts +312 -0
- package/dist/vendor/electron/shared/note-properties.js +982 -0
- package/dist/vendor/electron/shared/note-templates.d.ts +82 -0
- package/dist/vendor/electron/shared/note-templates.js +84 -0
- package/dist/vendor/electron/shared/powersync-read-models.d.ts +1710 -0
- package/dist/vendor/electron/shared/powersync-read-models.js +1 -0
- package/dist/vendor/electron/shared/saved-views.d.ts +394 -0
- package/dist/vendor/electron/shared/saved-views.js +981 -0
- package/dist/vendor/electron/sql-utils.d.ts +5 -0
- package/dist/vendor/electron/sql-utils.js +32 -0
- package/package.json +6 -3
- package/dist/commands/savedViews/semantics.d.ts +0 -46
- package/dist/commands/savedViews/semantics.js +0 -738
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Note reads: single-note lookup, context, preview, detail, and export rows.
|
|
2
|
-
import { DinoxError } from '../../../utils/errors.js';
|
|
3
2
|
import { loadZettelBoxNameMap, normalizeStoredFlag, normalizeStoredStarred, parseStoredTags, parseZettelBoxIds, resolveSummary, } from './shared.js';
|
|
3
|
+
import { parseRawNoteProperties } from '../../../vendor/electron/shared/index.js';
|
|
4
4
|
export async function getNote(db, id) {
|
|
5
5
|
return db.getOptional(`
|
|
6
6
|
SELECT
|
|
@@ -158,29 +158,10 @@ function parseStoredJsonValue(raw) {
|
|
|
158
158
|
return raw;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
+
// Same forgiving read as desktop: malformed storage reads as {} instead of failing the
|
|
162
|
+
// whole note read; `dino prop show` reports it via `valid: false`.
|
|
161
163
|
function parseStoredNoteProperties(raw) {
|
|
162
|
-
|
|
163
|
-
if (!value) {
|
|
164
|
-
return {};
|
|
165
|
-
}
|
|
166
|
-
let parsed;
|
|
167
|
-
try {
|
|
168
|
-
parsed = JSON.parse(value);
|
|
169
|
-
}
|
|
170
|
-
catch (cause) {
|
|
171
|
-
throw new DinoxError('c_note.properties must be valid JSON', {
|
|
172
|
-
code: 'NOTE_INVALID_PROPERTIES',
|
|
173
|
-
details: { cause: cause instanceof Error ? cause.message : String(cause) },
|
|
174
|
-
recoverable: false,
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
178
|
-
throw new DinoxError('c_note.properties must be a JSON object', {
|
|
179
|
-
code: 'NOTE_INVALID_PROPERTIES',
|
|
180
|
-
recoverable: false,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
return Object.fromEntries(Object.entries(parsed));
|
|
164
|
+
return parseRawNoteProperties(raw);
|
|
184
165
|
}
|
|
185
166
|
function mapNoteExportRow(note, boxNameMap) {
|
|
186
167
|
const boxIds = parseZettelBoxIds(note.zettel_boxes_raw);
|
|
@@ -163,6 +163,7 @@ export type NotePreview = {
|
|
|
163
163
|
};
|
|
164
164
|
export type NoteUpdateStateRow = {
|
|
165
165
|
id: string;
|
|
166
|
+
title: string | null;
|
|
166
167
|
tags: string | null;
|
|
167
168
|
zettel_boxes: string | null;
|
|
168
169
|
is_del: number | null;
|
|
@@ -176,6 +177,7 @@ export type UpdateNoteResult = {
|
|
|
176
177
|
id: string;
|
|
177
178
|
updated: boolean;
|
|
178
179
|
changed: string[];
|
|
180
|
+
title: string;
|
|
179
181
|
tags: string[];
|
|
180
182
|
zettelBoxIds: string[];
|
|
181
183
|
is_starred: boolean;
|
|
@@ -11,11 +11,14 @@ export declare function createNote(db: AbstractPowerSyncDatabase, input: {
|
|
|
11
11
|
zettelBoxIds: string[];
|
|
12
12
|
userId: string;
|
|
13
13
|
imageDetail?: unknown[];
|
|
14
|
+
/** Serialized `c_note.properties` (e.g. template-declared empty slots); defaults to NULL. */
|
|
15
|
+
properties?: string | null;
|
|
14
16
|
}): Promise<{
|
|
15
17
|
id: string;
|
|
16
18
|
}>;
|
|
17
19
|
export declare function updateNote(db: AbstractPowerSyncDatabase, input: {
|
|
18
20
|
id: string;
|
|
21
|
+
title?: string;
|
|
19
22
|
tags?: string[];
|
|
20
23
|
zettelBoxIds?: string[];
|
|
21
24
|
starred?: boolean;
|
|
@@ -77,7 +77,7 @@ export async function createNote(db, input) {
|
|
|
77
77
|
['resource_id', null],
|
|
78
78
|
['note_ids', '[]'],
|
|
79
79
|
['extra_data', '{}'],
|
|
80
|
-
['properties', null],
|
|
80
|
+
['properties', input.properties ?? null],
|
|
81
81
|
['is_pub', 0],
|
|
82
82
|
['format_type', ''],
|
|
83
83
|
['comments', '[]'],
|
|
@@ -124,14 +124,15 @@ export async function updateNote(db, input) {
|
|
|
124
124
|
if (!id) {
|
|
125
125
|
throw new DinoxError('Note id is required');
|
|
126
126
|
}
|
|
127
|
+
const shouldUpdateTitle = typeof input.title === 'string';
|
|
127
128
|
const shouldUpdateTags = Array.isArray(input.tags);
|
|
128
129
|
const shouldUpdateBoxes = Array.isArray(input.zettelBoxIds);
|
|
129
130
|
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');
|
|
131
|
+
if (!shouldUpdateTitle && !shouldUpdateTags && !shouldUpdateBoxes && !shouldUpdateStarred) {
|
|
132
|
+
throw new DinoxError('At least one field is required: title, tags, boxes, or starred');
|
|
132
133
|
}
|
|
133
134
|
const existing = await db.getOptional(`
|
|
134
|
-
SELECT id, tags, zettel_boxes, is_del, starred_at
|
|
135
|
+
SELECT id, title, tags, zettel_boxes, is_del, starred_at
|
|
135
136
|
FROM c_note
|
|
136
137
|
WHERE id = ?
|
|
137
138
|
`, [id]);
|
|
@@ -141,20 +142,24 @@ export async function updateNote(db, input) {
|
|
|
141
142
|
if (typeof existing.is_del === 'number' && existing.is_del !== 0) {
|
|
142
143
|
throw new DinoxError(`Note has been deleted: ${id}`);
|
|
143
144
|
}
|
|
145
|
+
const currentTitle = existing.title ?? '';
|
|
144
146
|
const currentTags = parseStoredTags(existing.tags);
|
|
145
147
|
const currentZettelBoxIds = parseZettelBoxIds(existing.zettel_boxes);
|
|
146
148
|
const currentStarred = existing.starred_at !== null;
|
|
149
|
+
const nextTitle = shouldUpdateTitle ? input.title : currentTitle;
|
|
147
150
|
const nextTags = shouldUpdateTags ? normalizeDistinctStrings(input.tags) : currentTags;
|
|
148
151
|
const nextZettelBoxIds = shouldUpdateBoxes ? normalizeDistinctStrings(input.zettelBoxIds) : currentZettelBoxIds;
|
|
149
152
|
const nextStarred = shouldUpdateStarred ? input.starred : currentStarred;
|
|
153
|
+
const titleChanged = shouldUpdateTitle && currentTitle !== nextTitle;
|
|
150
154
|
const tagsChanged = shouldUpdateTags && !sameTagSet(currentTags, nextTags);
|
|
151
155
|
const boxesChanged = shouldUpdateBoxes && !sameStringSet(currentZettelBoxIds, nextZettelBoxIds);
|
|
152
156
|
const starredChanged = shouldUpdateStarred && currentStarred !== nextStarred;
|
|
153
|
-
if (!tagsChanged && !boxesChanged && !starredChanged) {
|
|
157
|
+
if (!titleChanged && !tagsChanged && !boxesChanged && !starredChanged) {
|
|
154
158
|
return {
|
|
155
159
|
id,
|
|
156
160
|
updated: false,
|
|
157
161
|
changed: [],
|
|
162
|
+
title: currentTitle,
|
|
158
163
|
tags: currentTags,
|
|
159
164
|
zettelBoxIds: currentZettelBoxIds,
|
|
160
165
|
is_starred: currentStarred,
|
|
@@ -162,6 +167,10 @@ export async function updateNote(db, input) {
|
|
|
162
167
|
}
|
|
163
168
|
const setParts = [];
|
|
164
169
|
const params = [];
|
|
170
|
+
if (titleChanged) {
|
|
171
|
+
setParts.push('title = ?');
|
|
172
|
+
params.push(nextTitle);
|
|
173
|
+
}
|
|
165
174
|
if (tagsChanged) {
|
|
166
175
|
setParts.push('tags = ?');
|
|
167
176
|
params.push(JSON.stringify(nextTags));
|
|
@@ -190,10 +199,12 @@ export async function updateNote(db, input) {
|
|
|
190
199
|
id,
|
|
191
200
|
updated: true,
|
|
192
201
|
changed: [
|
|
202
|
+
...(titleChanged ? ['title'] : []),
|
|
193
203
|
...(tagsChanged ? ['tags'] : []),
|
|
194
204
|
...(boxesChanged ? ['boxes'] : []),
|
|
195
205
|
...(starredChanged ? ['is_starred'] : []),
|
|
196
206
|
],
|
|
207
|
+
title: nextTitle,
|
|
197
208
|
tags: nextTags,
|
|
198
209
|
zettelBoxIds: nextZettelBoxIds,
|
|
199
210
|
is_starred: nextStarred,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { PROPERTY_OPTION_COLORS, STATUS_PROPERTY_GROUPS } from '../../vendor/electron/shared/index.js';
|
|
3
|
+
import type { CommandGroupDescriptor } from '../descriptor/types.js';
|
|
4
|
+
type Color = (typeof PROPERTY_OPTION_COLORS)[number];
|
|
5
|
+
type Group = (typeof STATUS_PROPERTY_GROUPS)[number];
|
|
6
|
+
/** Parses `label[:color[:group]]`, peeling recognised color/group suffixes off the right. */
|
|
7
|
+
export declare function parseOptionSpec(spec: string): {
|
|
8
|
+
label: string;
|
|
9
|
+
color?: Color;
|
|
10
|
+
group?: Group;
|
|
11
|
+
};
|
|
12
|
+
/** Parses `key=value`; the value is JSON when it parses as JSON, otherwise a plain string. */
|
|
13
|
+
export declare function parseAssignment(spec: string): [string, unknown];
|
|
14
|
+
export declare const propertyCommandGroup: CommandGroupDescriptor;
|
|
15
|
+
export declare function registerPropertyCommands(program: Command): void;
|
|
16
|
+
export {};
|