@dinoxx/dinox-cli 1.1.1 → 2.1.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 (141) hide show
  1. package/README.md +44 -3
  2. package/dist/cli.js +4 -0
  3. package/dist/commands/auth/index.js +1 -2
  4. package/dist/commands/boxes/index.js +37 -13
  5. package/dist/commands/boxes/operations.d.ts +3 -3
  6. package/dist/commands/boxes/operations.js +51 -28
  7. package/dist/commands/info/index.js +30 -5
  8. package/dist/commands/meta/repo.js +2 -1
  9. package/dist/commands/notes/actions.js +20 -37
  10. package/dist/commands/notes/bulk.d.ts +2 -2
  11. package/dist/commands/notes/bulk.js +3 -18
  12. package/dist/commands/notes/contentPatch.d.ts +5 -1
  13. package/dist/commands/notes/contentPatch.js +12 -1
  14. package/dist/commands/notes/contentPatchCommand.d.ts +3 -0
  15. package/dist/commands/notes/contentPatchCommand.js +29 -8
  16. package/dist/commands/notes/descriptors.js +19 -16
  17. package/dist/commands/notes/export.js +3 -0
  18. package/dist/commands/notes/repo/read.d.ts +8 -0
  19. package/dist/commands/notes/repo/read.js +321 -0
  20. package/dist/commands/notes/repo/resolve.d.ts +8 -0
  21. package/dist/commands/notes/repo/resolve.js +187 -0
  22. package/dist/commands/notes/repo/search.d.ts +42 -0
  23. package/dist/commands/notes/repo/search.js +513 -0
  24. package/dist/commands/notes/repo/shared.d.ts +190 -0
  25. package/dist/commands/notes/repo/shared.js +102 -0
  26. package/dist/commands/notes/repo/write.d.ts +24 -0
  27. package/dist/commands/notes/repo/write.js +251 -0
  28. package/dist/commands/notes/repo.d.ts +7 -177
  29. package/dist/commands/notes/repo.js +7 -1310
  30. package/dist/commands/notes/searchOutput.d.ts +2 -1
  31. package/dist/commands/notes/searchOutput.js +2 -1
  32. package/dist/commands/notes/searchSql.js +9 -3
  33. package/dist/commands/prompt/index.d.ts +1 -0
  34. package/dist/commands/prompt/index.js +26 -11
  35. package/dist/commands/savedViews/index.d.ts +7 -0
  36. package/dist/commands/savedViews/index.js +458 -0
  37. package/dist/commands/savedViews/model.d.ts +87 -0
  38. package/dist/commands/savedViews/model.js +306 -0
  39. package/dist/commands/savedViews/repo.d.ts +123 -0
  40. package/dist/commands/savedViews/repo.js +512 -0
  41. package/dist/commands/savedViews/semantics.d.ts +46 -0
  42. package/dist/commands/savedViews/semantics.js +738 -0
  43. package/dist/commands/schema/commandMetadata.js +4 -4
  44. package/dist/commands/schema/index.d.ts +1 -0
  45. package/dist/commands/schema/index.js +23 -2
  46. package/dist/commands/schema/renderSkills.d.ts +6 -0
  47. package/dist/commands/schema/renderSkills.js +109 -11
  48. package/dist/commands/schema/spec.js +4 -0
  49. package/dist/commands/skills/index.d.ts +80 -0
  50. package/dist/commands/skills/index.js +572 -0
  51. package/dist/commands/storage/index.js +2 -2
  52. package/dist/commands/storage/repo/configs.d.ts +30 -0
  53. package/dist/commands/storage/repo/configs.js +259 -0
  54. package/dist/commands/storage/repo/operations.d.ts +25 -0
  55. package/dist/commands/storage/repo/operations.js +337 -0
  56. package/dist/commands/storage/repo/remote.d.ts +32 -0
  57. package/dist/commands/storage/repo/remote.js +132 -0
  58. package/dist/commands/storage/repo/resources.d.ts +12 -0
  59. package/dist/commands/storage/repo/resources.js +134 -0
  60. package/dist/commands/storage/repo/shared.d.ts +181 -0
  61. package/dist/commands/storage/repo/shared.js +36 -0
  62. package/dist/commands/storage/repo/targets.d.ts +12 -0
  63. package/dist/commands/storage/repo/targets.js +178 -0
  64. package/dist/commands/storage/repo.d.ts +3 -166
  65. package/dist/commands/storage/repo.js +4 -1034
  66. package/dist/commands/sync.js +2 -1
  67. package/dist/commands/tags/index.js +30 -11
  68. package/dist/commands/tags/operations.d.ts +3 -3
  69. package/dist/commands/tags/operations.js +45 -20
  70. package/dist/commands/templates/model.d.ts +50 -0
  71. package/dist/commands/templates/model.js +239 -0
  72. package/dist/commands/todo/index.js +3 -3
  73. package/dist/commands/update.d.ts +1 -0
  74. package/dist/commands/update.js +46 -9
  75. package/dist/commands/writeConfirmation.d.ts +13 -0
  76. package/dist/commands/writeConfirmation.js +54 -0
  77. package/dist/config/resolve.js +5 -10
  78. package/dist/config/types.d.ts +3 -6
  79. package/dist/constants/links.d.ts +18 -1
  80. package/dist/constants/links.js +26 -1
  81. package/dist/contract/snapshot.d.ts +30 -0
  82. package/dist/contract/snapshot.js +114 -0
  83. package/dist/daemon/client.d.ts +2 -2
  84. package/dist/daemon/client.js +108 -54
  85. package/dist/daemon/index.d.ts +5 -3
  86. package/dist/daemon/index.js +28 -5
  87. package/dist/daemon/lifecycle.d.ts +7 -2
  88. package/dist/daemon/lifecycle.js +53 -13
  89. package/dist/daemon/pid.d.ts +1 -1
  90. package/dist/daemon/pid.js +6 -3
  91. package/dist/dinox.js +9 -1
  92. package/dist/powersync/exclusiveRuntime.d.ts +1 -0
  93. package/dist/powersync/exclusiveRuntime.js +26 -8
  94. package/dist/powersync/runtime.d.ts +3 -2
  95. package/dist/powersync/runtime.js +19 -3
  96. package/dist/powersync/schema/content.d.ts +1 -78
  97. package/dist/powersync/schema/content.js +1 -78
  98. package/dist/powersync/schema/electronCanonical.d.ts +1561 -0
  99. package/dist/powersync/schema/electronCanonical.js +1154 -0
  100. package/dist/powersync/schema/index.d.ts +573 -129
  101. package/dist/powersync/schema/index.js +3 -32
  102. package/dist/powersync/schema/local.d.ts +1 -56
  103. package/dist/powersync/schema/local.js +1 -60
  104. package/dist/powersync/schema/note.d.ts +1 -35
  105. package/dist/powersync/schema/note.js +1 -35
  106. package/dist/powersync/schema/notesExtras.d.ts +1 -62
  107. package/dist/powersync/schema/notesExtras.js +1 -71
  108. package/dist/powersync/schema/projects.d.ts +1 -104
  109. package/dist/powersync/schema/projects.js +1 -104
  110. package/dist/powersync/schema/savedViews.d.ts +1 -0
  111. package/dist/powersync/schema/savedViews.js +1 -0
  112. package/dist/powersync/schema/storage.d.ts +1 -24
  113. package/dist/powersync/schema/storage.js +1 -24
  114. package/dist/powersync/schema/tags.d.ts +1 -37
  115. package/dist/powersync/schema/tags.js +1 -37
  116. package/dist/powersync/syncGate.d.ts +20 -2
  117. package/dist/powersync/uploader.d.ts +16 -2
  118. package/dist/powersync/uploader.js +152 -158
  119. package/dist/skills/check.d.ts +1 -0
  120. package/dist/skills/check.js +538 -70
  121. package/dist/skills/commandRefs.d.ts +21 -0
  122. package/dist/skills/commandRefs.js +132 -0
  123. package/dist/skills/generate.d.ts +13 -0
  124. package/dist/skills/generate.js +80 -0
  125. package/dist/skills/registry.d.ts +13 -0
  126. package/dist/skills/registry.js +58 -0
  127. package/dist/skills/retired.d.ts +60 -0
  128. package/dist/skills/retired.js +58 -0
  129. package/dist/utils/deadline.d.ts +8 -0
  130. package/dist/utils/deadline.js +31 -0
  131. package/dist/utils/dryRun.d.ts +20 -1
  132. package/dist/utils/dryRun.js +22 -3
  133. package/dist/utils/errorCodes.d.ts +311 -0
  134. package/dist/utils/errorCodes.js +92 -0
  135. package/dist/utils/errors.d.ts +15 -2
  136. package/dist/utils/errors.js +13 -0
  137. package/dist/utils/processExit.d.ts +1 -0
  138. package/dist/utils/processExit.js +33 -0
  139. package/dist/utils/updateNotice.d.ts +1 -0
  140. package/dist/utils/updateNotice.js +1 -1
  141. package/package.json +18 -8
@@ -0,0 +1,187 @@
1
+ // Tag validation and zettel box name/path resolution for note writes and search.
2
+ import { DinoxError } from '../../../utils/errors.js';
3
+ import { canonicalizeBoxPath, listBoxes } from '../../boxes/repo.js';
4
+ import { listTags } from '../../tags/repo.js';
5
+ import { normalizeLookupKey } from './shared.js';
6
+ function normalizeZettelBoxLookupKey(value) {
7
+ return canonicalizeBoxPath(value).toLowerCase();
8
+ }
9
+ function buildZettelBoxRetryQuestion(intent, type) {
10
+ const command = intent === 'search'
11
+ ? 'dino note search'
12
+ : intent === 'update'
13
+ ? 'dino note update'
14
+ : intent === 'bulk'
15
+ ? 'dino note bulk'
16
+ : 'dino note create';
17
+ if (type === 'ambiguous') {
18
+ return `Do you want to specify box paths and retry \`${command}\`?`;
19
+ }
20
+ return `Do you want to add these missing boxes and retry \`${command}\`?`;
21
+ }
22
+ export async function validateTagsForCreate(db, requestedTags, userId) {
23
+ return validateTagsForWrite(db, requestedTags, userId, 'dino note create');
24
+ }
25
+ export async function validateTagsForUpdate(db, requestedTags, userId) {
26
+ return validateTagsForWrite(db, requestedTags, userId, 'dino note update');
27
+ }
28
+ export async function validateTagsForBulk(db, requestedTags, userId) {
29
+ return validateTagsForWrite(db, requestedTags, userId, 'dino note bulk');
30
+ }
31
+ async function validateTagsForWrite(db, requestedTags, userId, retryCommand) {
32
+ const normalizedUserId = userId.trim();
33
+ if (!normalizedUserId) {
34
+ throw new DinoxError('Tag validation requires the current userId. Run `dino auth login` first, or set DINOX_TOKEN and run an online command so the CLI can resolve the token identity.');
35
+ }
36
+ if (requestedTags.length === 0) {
37
+ return [];
38
+ }
39
+ const tags = await listTags(db, { userId: normalizedUserId });
40
+ const existingTagMap = new Map();
41
+ for (const tag of tags) {
42
+ const key = normalizeLookupKey(tag);
43
+ if (!key || existingTagMap.has(key)) {
44
+ continue;
45
+ }
46
+ existingTagMap.set(key, tag);
47
+ }
48
+ const resolved = [];
49
+ const seen = new Set();
50
+ const missing = [];
51
+ for (const requested of requestedTags) {
52
+ const key = normalizeLookupKey(requested);
53
+ if (!key || seen.has(key)) {
54
+ continue;
55
+ }
56
+ seen.add(key);
57
+ const matched = existingTagMap.get(key);
58
+ if (!matched) {
59
+ missing.push(requested);
60
+ continue;
61
+ }
62
+ resolved.push(matched);
63
+ }
64
+ if (missing.length > 0) {
65
+ throw new DinoxError(`Unknown tags: ${missing.join(', ')}`, {
66
+ details: {
67
+ type: 'missing_tags',
68
+ missing,
69
+ knownCount: tags.length,
70
+ knownSample: tags.slice(0, 20),
71
+ question: `Do you want to add these missing tags and retry \`${retryCommand}\`?`,
72
+ },
73
+ });
74
+ }
75
+ return resolved;
76
+ }
77
+ export async function resolveZettelBoxIdsForCreate(db, requestedNames) {
78
+ return resolveZettelBoxIdsByName(db, requestedNames, 'create');
79
+ }
80
+ export async function resolveZettelBoxIdsForSearch(db, requestedNames) {
81
+ return resolveZettelBoxIdsByName(db, requestedNames, 'search');
82
+ }
83
+ export async function resolveZettelBoxIdsForUpdate(db, requestedNames) {
84
+ return resolveZettelBoxIdsByName(db, requestedNames, 'update');
85
+ }
86
+ export async function resolveZettelBoxIdsForBulk(db, requestedNames) {
87
+ return resolveZettelBoxIdsByName(db, requestedNames, 'bulk');
88
+ }
89
+ async function resolveZettelBoxIdsByName(db, requestedNames, intent) {
90
+ if (requestedNames.length === 0) {
91
+ return [];
92
+ }
93
+ const boxes = await listBoxes(db);
94
+ const availablePaths = Array.from(new Set(boxes.map((box) => box.path.trim()).filter(Boolean)));
95
+ const boxByPath = new Map();
96
+ const boxByName = new Map();
97
+ for (const box of boxes) {
98
+ const name = box.name.trim();
99
+ const path = canonicalizeBoxPath(box.path || name);
100
+ const pathKey = normalizeZettelBoxLookupKey(path);
101
+ if (pathKey && !boxByPath.has(pathKey)) {
102
+ boxByPath.set(pathKey, box.id);
103
+ }
104
+ const nameKey = normalizeLookupKey(name);
105
+ if (!nameKey) {
106
+ continue;
107
+ }
108
+ const current = boxByName.get(nameKey);
109
+ if (!current) {
110
+ boxByName.set(nameKey, {
111
+ name,
112
+ ids: [box.id],
113
+ paths: path ? [path] : [],
114
+ });
115
+ continue;
116
+ }
117
+ if (!current.ids.includes(box.id)) {
118
+ current.ids.push(box.id);
119
+ }
120
+ if (path && !current.paths.includes(path)) {
121
+ current.paths.push(path);
122
+ }
123
+ }
124
+ const resolvedIds = [];
125
+ const seenIds = new Set();
126
+ const missing = [];
127
+ const ambiguous = [];
128
+ const seenAmbiguous = new Set();
129
+ for (const requested of requestedNames) {
130
+ const pathKey = normalizeZettelBoxLookupKey(requested);
131
+ if (!pathKey) {
132
+ continue;
133
+ }
134
+ const pathMatchId = boxByPath.get(pathKey);
135
+ if (pathMatchId) {
136
+ if (!seenIds.has(pathMatchId)) {
137
+ seenIds.add(pathMatchId);
138
+ resolvedIds.push(pathMatchId);
139
+ }
140
+ continue;
141
+ }
142
+ const lookup = boxByName.get(normalizeLookupKey(requested));
143
+ if (!lookup) {
144
+ missing.push(requested);
145
+ continue;
146
+ }
147
+ if (lookup.ids.length > 1) {
148
+ const marker = `${requested.toLowerCase()}::${lookup.ids.join(',')}`;
149
+ if (!seenAmbiguous.has(marker)) {
150
+ seenAmbiguous.add(marker);
151
+ ambiguous.push({
152
+ name: requested,
153
+ ids: lookup.ids,
154
+ paths: lookup.paths,
155
+ });
156
+ }
157
+ continue;
158
+ }
159
+ const id = lookup.ids[0];
160
+ if (!seenIds.has(id)) {
161
+ seenIds.add(id);
162
+ resolvedIds.push(id);
163
+ }
164
+ }
165
+ if (ambiguous.length > 0) {
166
+ throw new DinoxError(`Ambiguous zettel box names: ${ambiguous.map((item) => `${item.name} -> [${item.paths.join(', ')}]`).join('; ')}`, {
167
+ details: {
168
+ type: 'ambiguous_zettel_boxes',
169
+ ambiguous,
170
+ availablePathsSample: availablePaths.slice(0, 20),
171
+ question: buildZettelBoxRetryQuestion(intent, 'ambiguous'),
172
+ },
173
+ });
174
+ }
175
+ if (missing.length > 0) {
176
+ throw new DinoxError(`Unknown zettel box paths or names: ${missing.join(', ')}`, {
177
+ details: {
178
+ type: 'missing_zettel_boxes',
179
+ missing,
180
+ availableCount: availablePaths.length,
181
+ availablePathsSample: availablePaths.slice(0, 20),
182
+ question: buildZettelBoxRetryQuestion(intent, 'missing'),
183
+ },
184
+ });
185
+ }
186
+ return resolvedIds;
187
+ }
@@ -0,0 +1,42 @@
1
+ import type { AbstractPowerSyncDatabase } from '@powersync/common';
2
+ import { type SearchNotesOptions, type SearchedNote } from './shared.js';
3
+ /**
4
+ * JSON-safe note-search request. Box *names/paths* are carried (not resolved ids) so the
5
+ * same payload can be executed either in-process or sent to the daemon over the wire;
6
+ * id resolution happens inside {@link executeNoteSearch} against whichever db runs it.
7
+ */
8
+ export type NoteSearchExecuteParams = {
9
+ keyword: string;
10
+ includeDeleted: boolean;
11
+ tagsExpression?: string;
12
+ createdAtFrom?: string;
13
+ createdAtTo?: string;
14
+ starred?: boolean;
15
+ boxValues: string[];
16
+ matchEmptyZettelBoxes: boolean;
17
+ sqlExpression?: string;
18
+ limit?: number;
19
+ offset?: number;
20
+ };
21
+ export type NoteSearchExecuteResult = {
22
+ rows: SearchedNote[];
23
+ totalCount: number;
24
+ /** Resolved zettel-box ids, surfaced so callers can echo them in response metadata. */
25
+ zettelBoxIds: string[];
26
+ };
27
+ /**
28
+ * Resolve box names to ids and run the note search. Shared by the local command path and
29
+ * the daemon RPC handler so both produce identical results from one implementation.
30
+ */
31
+ export declare function executeNoteSearch(db: AbstractPowerSyncDatabase, params: NoteSearchExecuteParams): Promise<NoteSearchExecuteResult>;
32
+ export declare function searchNotes(db: AbstractPowerSyncDatabase, query: string, options: SearchNotesOptions): Promise<SearchedNote[]>;
33
+ type SearchNotesPageOptions = SearchNotesOptions & {
34
+ limit?: number;
35
+ offset?: number;
36
+ };
37
+ type SearchNotesPageResult = {
38
+ rows: SearchedNote[];
39
+ totalCount: number;
40
+ };
41
+ export declare function searchNotesPage(db: AbstractPowerSyncDatabase, query: string, options: SearchNotesPageOptions): Promise<SearchNotesPageResult>;
42
+ export {};