@dinoxx/dinox-cli 3.0.0 → 3.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 (30) hide show
  1. package/dist/chunks/{chunk-BZQYECIH.js → chunk-52XLDO77.js} +1 -1
  2. package/dist/chunks/{chunk-N5YDNM3P.js → chunk-5SORBZTD.js} +1 -1
  3. package/dist/chunks/{chunk-N2VYTZWU.js → chunk-DKY574LO.js} +3 -3
  4. package/dist/chunks/{chunk-ARBWJ3ZA.js → chunk-G6Y3MOUL.js} +1075 -109
  5. package/dist/chunks/{chunk-2DREJFKB.js → chunk-JNRA4TTH.js} +1 -1
  6. package/dist/chunks/{chunk-3VZNZWDG.js → chunk-LAWV5XGL.js} +5 -0
  7. package/dist/chunks/{chunk-MLOITAK6.js → chunk-LXC3IW4L.js} +2 -2
  8. package/dist/chunks/{chunk-NVKSI4BD.js → chunk-MMO7CINX.js} +50 -590
  9. package/dist/chunks/{chunk-HG3RZFDX.js → chunk-OZXS77HJ.js} +7 -7
  10. package/dist/chunks/{chunk-KJBN7TD7.js → chunk-PCB2JD6H.js} +6 -6
  11. package/dist/chunks/{chunk-6D3QLMRM.js → chunk-TOGYWN3D.js} +1 -1
  12. package/dist/chunks/{chunk-WABL3OUP.js → chunk-WCY3EKJQ.js} +4 -4
  13. package/dist/chunks/{chunk-SM2QOO45.js → chunk-YFGDTC2F.js} +9 -2
  14. package/dist/chunks/{chunk-QPVGA46P.js → chunk-YX4SIEVS.js} +3 -3
  15. package/dist/chunks/{cookies-ORQ3RLAH.js → cookies-UUQZXH4R.js} +4 -4
  16. package/dist/chunks/{ensure-MPOQ244L.js → ensure-2OPNFDRW.js} +7 -7
  17. package/dist/chunks/{execute-KMNZ5EFR.js → execute-C5W5ZJDC.js} +5 -5
  18. package/dist/chunks/{install-35YBLHXE.js → install-VBMWNPO6.js} +1 -1
  19. package/dist/chunks/{mcp-H667ML2O.js → mcp-WK7KIU44.js} +8 -6
  20. package/dist/chunks/{mcpServer-G2WEAD2O.js → mcpServer-M4HJFSNU.js} +13 -13
  21. package/dist/chunks/{run-7D6ATULD.js → run-WNHMZLSJ.js} +11 -11
  22. package/dist/chunks/{runCli-QEWWUIZN.js → runCli-GKTCIDBF.js} +12 -12
  23. package/dist/chunks/{setup-DSTOF3BZ.js → setup-UYCLFOZH.js} +6 -6
  24. package/dist/dinox.js +7 -7
  25. package/dist/dsh-plugin/lib/client.js +977 -267
  26. package/dist/dsh-plugin/lib/index.js +10 -6
  27. package/dist/dsh-plugin/package.json +1 -1
  28. package/dist/dsh-plugin/runtime.json +1 -1
  29. package/dist/editor-ui/mcp-app.html +420 -318
  30. package/package.json +5 -2
@@ -2,7 +2,7 @@ import { createRequire as __dinoxCreateRequire } from 'node:module';
2
2
  const require = __dinoxCreateRequire(import.meta.url);
3
3
  import {
4
4
  ensureDaemonRunning
5
- } from "./chunk-KJBN7TD7.js";
5
+ } from "./chunk-PCB2JD6H.js";
6
6
  import {
7
7
  WRITE_DURABILITY_OPTION,
8
8
  buildBatchWriteReceiptFields,
@@ -33,13 +33,12 @@ import {
33
33
  withCommandRuntime,
34
34
  withExclusivePowerSync,
35
35
  withNoteDatabase
36
- } from "./chunk-HG3RZFDX.js";
36
+ } from "./chunk-OZXS77HJ.js";
37
37
  import {
38
38
  reportProgress
39
- } from "./chunk-BZQYECIH.js";
39
+ } from "./chunk-52XLDO77.js";
40
40
  import {
41
41
  ACTIVE_PROPERTY_TYPES,
42
- DEFAULT_DAEMON_PORT,
43
42
  MAX_BOX_NAME_LENGTH,
44
43
  MAX_TAG_SEGMENT_LENGTH,
45
44
  NOTE_PROPERTY_LIMITS,
@@ -49,8 +48,6 @@ import {
49
48
  REQUIRED_NOTE_TAG_COLUMNS,
50
49
  REQUIRED_TAG_NODE_COLUMNS,
51
50
  SAVED_VIEW_LAYOUTS,
52
- SAVED_VIEW_PRIMARY_RESOURCE_TYPES,
53
- SAVED_VIEW_SYSTEM_FIELDS,
54
51
  STATUS_PROPERTY_GROUPS,
55
52
  acquirePowerSyncOwnerLease,
56
53
  activeBoxNodes,
@@ -79,7 +76,6 @@ import {
79
76
  buildStorageTarget,
80
77
  buildStorageTestPlan,
81
78
  buildStorageUploadPlan,
82
- canSortSavedViewField,
83
79
  canonicalizeBoxPath,
84
80
  canonicalizeTagPath,
85
81
  closePowerSyncAndReleaseOwner,
@@ -88,11 +84,10 @@ import {
88
84
  configureProperty,
89
85
  connectPowerSync,
90
86
  convertMarkdownToNoteContent,
91
- countSavedViewScopedRows,
92
- createDefaultSavedViewConfig,
93
- createDefaultSavedViewFilter,
87
+ countSavedViewRows,
94
88
  createNote,
95
89
  createProperty,
90
+ createSavedView,
96
91
  createStorageCollisionError,
97
92
  createStorageUploadOutcomeUnknownError,
98
93
  createTimeoutSignal,
@@ -102,6 +97,7 @@ import {
102
97
  defaultUploadBytes,
103
98
  defaultUploadObject,
104
99
  deleteProperty,
100
+ deleteSavedView,
105
101
  descendantsOf,
106
102
  descendantsOf2,
107
103
  enrichSearchRows,
@@ -112,7 +108,6 @@ import {
112
108
  extractMarkdownFrontmatter,
113
109
  fetchCredentialsWithAuthorization,
114
110
  fetchDomainReadModel,
115
- fetchSavedViewScopedPage,
116
111
  fetchUserInfoWithAuthorization,
117
112
  fillEmptyNoteProperties,
118
113
  findMarkdownLiteralRanges,
@@ -125,12 +120,14 @@ import {
125
120
  getLeafName,
126
121
  getLeafName2,
127
122
  getNoteContext,
123
+ getNoteDetailSections,
128
124
  getNoteDetails,
129
125
  getNoteExportItems,
130
126
  getNotePreview,
131
127
  getOutlinks,
132
128
  getRelatedNotes,
133
- getSavedViewFilterOperatorsForField,
129
+ getSavedView,
130
+ getSavedViewAnalytics,
134
131
  getStatusSnapshot,
135
132
  getStorageStats,
136
133
  getTableColumns,
@@ -148,10 +145,11 @@ import {
148
145
  isMarkdownOffsetInSortedRanges,
149
146
  isObjectCollisionError,
150
147
  isPropertyKeyValid,
151
- isSavedViewDisplayOnlyField,
152
148
  isTagPathWithinPrefix,
153
149
  listBoxes,
154
150
  listProperties,
151
+ listSavedViewFields,
152
+ listSavedViews,
155
153
  listStorageConfigs,
156
154
  listStoredCustomStorageConfigs,
157
155
  listTags,
@@ -160,7 +158,6 @@ import {
160
158
  loadSharp,
161
159
  loadTagNodes,
162
160
  mapNoteTemplateRow,
163
- mapPropertyDef,
164
161
  mergeAuthIdentityIntoConfig,
165
162
  migrateLegacyOptions,
166
163
  migrationAffectedCount,
@@ -174,7 +171,6 @@ import {
174
171
  parentIdForPath,
175
172
  parentPathOf,
176
173
  parseRawNoteProperties,
177
- parseSavedViewZettelBoxDetails,
178
174
  parseStorageUploadCategory,
179
175
  parseStoredBoxIds,
180
176
  parseStoredTags,
@@ -186,11 +182,15 @@ import {
186
182
  planTodoUpdates,
187
183
  previewConfigureProperty,
188
184
  previewCreateProperty,
185
+ previewCreateSavedView,
189
186
  previewCreateTodoNote,
190
187
  previewDeleteProperty,
188
+ previewDeleteSavedView,
191
189
  previewInRolledBackTransaction,
192
190
  previewMigrateLegacyOptions,
191
+ previewUpdateSavedView,
193
192
  projectNoteContent,
193
+ querySavedView,
194
194
  readNoteContentForPatch,
195
195
  readNoteProperties,
196
196
  rebuildNoteTokenIndex,
@@ -203,7 +203,6 @@ import {
203
203
  requireActiveTagPath,
204
204
  requireProperty,
205
205
  resolveAuthIdentity,
206
- resolveSavedViewQueryScope,
207
206
  resolveStorageSelection,
208
207
  resolveZettelBoxIdsForBulk,
209
208
  resolveZettelBoxIdsForCreate,
@@ -212,8 +211,6 @@ import {
212
211
  restartDaemonLocked,
213
212
  rotatePersistedAuthStateRevision,
214
213
  runDomainCommand,
215
- savedViewConfigSchema,
216
- savedViewFilterSchema,
217
214
  searchNotes,
218
215
  serializeRawNoteProperties,
219
216
  setNoteProperties,
@@ -222,7 +219,6 @@ import {
222
219
  stopDaemonLocked,
223
220
  syncNoteTokenIndex,
224
221
  toBoxListItem,
225
- toDinoxError,
226
222
  toTagListItem,
227
223
  toTodoSearchWire,
228
224
  trimString,
@@ -230,9 +226,12 @@ import {
230
226
  uninstallDaemonService,
231
227
  updateNote,
232
228
  updateNotePropertySlots,
229
+ updateSavedView,
233
230
  updateTodoTaskStatus,
234
231
  updateTodoTasks,
235
232
  upgradeLegacyNoteNodes,
233
+ validateSavedViewConfig,
234
+ validateSavedViewFilter,
236
235
  validateTagsForBulk,
237
236
  validateTagsForCreate,
238
237
  validateTagsForUpdate,
@@ -240,12 +239,11 @@ import {
240
239
  waitForLastSyncedAfter,
241
240
  waitForUploadQueueEmpty,
242
241
  withNestedWriteTransaction,
243
- withPowerSyncWriteTransaction,
244
- withReadTransaction
245
- } from "./chunk-ARBWJ3ZA.js";
242
+ withPowerSyncWriteTransaction
243
+ } from "./chunk-G6Y3MOUL.js";
246
244
  import {
247
245
  executeCommandLine
248
- } from "./chunk-N2VYTZWU.js";
246
+ } from "./chunk-DKY574LO.js";
249
247
  import {
250
248
  AI_SERVICE_URL,
251
249
  FORMAT_OPTIONS,
@@ -271,12 +269,13 @@ import {
271
269
  updateConfig,
272
270
  validateRequestId,
273
271
  withAsyncRelease
274
- } from "./chunk-WABL3OUP.js";
272
+ } from "./chunk-WCY3EKJQ.js";
275
273
  import {
276
274
  TASK_STATUS_VALUES,
277
275
  isTaskStatus
278
- } from "./chunk-2DREJFKB.js";
276
+ } from "./chunk-JNRA4TTH.js";
279
277
  import {
278
+ DEFAULT_DAEMON_PORT,
280
279
  acquireDaemonExclusiveIntentLock,
281
280
  acquireDaemonStartLock,
282
281
  getDaemonInfo,
@@ -288,7 +287,7 @@ import {
288
287
  readPid,
289
288
  sendDaemonRequest,
290
289
  shutdownDaemonForExclusiveAccess
291
- } from "./chunk-SM2QOO45.js";
290
+ } from "./chunk-YFGDTC2F.js";
292
291
  import {
293
292
  agentLaunch
294
293
  } from "./chunk-7ODU7LXP.js";
@@ -297,7 +296,7 @@ import {
297
296
  } from "./chunk-WMJXAF3X.js";
298
297
  import {
299
298
  readStringOrFile
300
- } from "./chunk-MLOITAK6.js";
299
+ } from "./chunk-LXC3IW4L.js";
301
300
  import {
302
301
  assertStdinAvailable,
303
302
  clearPendingStructuredNoticeProvider,
@@ -311,7 +310,7 @@ import {
311
310
  resolveUserPath,
312
311
  setPendingStructuredNoticeProvider,
313
312
  toJson
314
- } from "./chunk-6D3QLMRM.js";
313
+ } from "./chunk-TOGYWN3D.js";
315
314
  import {
316
315
  getDataDir,
317
316
  getLegacyPowerSyncDbPath,
@@ -319,7 +318,7 @@ import {
319
318
  } from "./chunk-XZLFMJOG.js";
320
319
  import {
321
320
  DinoxError
322
- } from "./chunk-3VZNZWDG.js";
321
+ } from "./chunk-LAWV5XGL.js";
323
322
 
324
323
  // src/commands/auth/index.ts
325
324
  import crypto from "node:crypto";
@@ -3333,7 +3332,7 @@ var gatewayCommandGroup = {
3333
3332
  examples: ["dino gateway mcp"]
3334
3333
  },
3335
3334
  action: async () => {
3336
- const { serveDinoxMcpOverStdio } = await import("./mcpServer-G2WEAD2O.js");
3335
+ const { serveDinoxMcpOverStdio } = await import("./mcpServer-M4HJFSNU.js");
3337
3336
  await serveDinoxMcpOverStdio();
3338
3337
  }
3339
3338
  },
@@ -3415,7 +3414,7 @@ var editorCommandGroup = {
3415
3414
  examples: ["dino editor mcp", "dino editor mcp --session codex"]
3416
3415
  },
3417
3416
  action: async (context) => {
3418
- const { serveEditorMcpOverStdio } = await import("./mcp-H667ML2O.js");
3417
+ const { serveEditorMcpOverStdio } = await import("./mcp-WK7KIU44.js");
3419
3418
  await serveEditorMcpOverStdio({ session: String(context.options.session ?? "mcp") });
3420
3419
  }
3421
3420
  },
@@ -3438,7 +3437,7 @@ var editorCommandGroup = {
3438
3437
  },
3439
3438
  action: async (context) => {
3440
3439
  hostOf(context);
3441
- const { installDsh } = await import("./install-35YBLHXE.js");
3440
+ const { installDsh } = await import("./install-VBMWNPO6.js");
3442
3441
  const result = await installDsh(installOptions(context));
3443
3442
  report(result, "Installed the Dinox editor in DeepSeek Harness:", result.next);
3444
3443
  }
@@ -3462,7 +3461,7 @@ var editorCommandGroup = {
3462
3461
  },
3463
3462
  action: async (context) => {
3464
3463
  hostOf(context);
3465
- const { uninstallDsh } = await import("./install-35YBLHXE.js");
3464
+ const { uninstallDsh } = await import("./install-VBMWNPO6.js");
3466
3465
  report(await uninstallDsh(installOptions(context)), "Removed the Dinox editor from DeepSeek Harness:", "Restart DeepSeek Harness Desktop.");
3467
3466
  }
3468
3467
  },
@@ -3483,7 +3482,7 @@ var editorCommandGroup = {
3483
3482
  examples: ["dino editor status", "dino editor status --format json"]
3484
3483
  },
3485
3484
  action: async (context) => {
3486
- const { editorStatus } = await import("./install-35YBLHXE.js");
3485
+ const { editorStatus } = await import("./install-VBMWNPO6.js");
3487
3486
  const status = editorStatus(installOptions(context));
3488
3487
  if (getRequestedStructuredOutputFormat()) {
3489
3488
  printSuccess(status);
@@ -5263,7 +5262,7 @@ function parseCreatedAtRange(input, now = /* @__PURE__ */ new Date()) {
5263
5262
  throw new DinoxError("--days cannot be used together with --from/--to");
5264
5263
  }
5265
5264
  if (days !== void 0) {
5266
- const nowIso3 = now.toISOString();
5265
+ const nowIso2 = now.toISOString();
5267
5266
  const todayUtcStart = Date.UTC(
5268
5267
  now.getUTCFullYear(),
5269
5268
  now.getUTCMonth(),
@@ -5276,7 +5275,7 @@ function parseCreatedAtRange(input, now = /* @__PURE__ */ new Date()) {
5276
5275
  const fromUtc = new Date(todayUtcStart - (days - 1) * DAY_MS).toISOString();
5277
5276
  return {
5278
5277
  createdAtFrom: fromUtc,
5279
- createdAtTo: nowIso3
5278
+ createdAtTo: nowIso2
5280
5279
  };
5281
5280
  }
5282
5281
  if (from && to && from > to) {
@@ -9161,545 +9160,6 @@ function registerPropertyCommands(program) {
9161
9160
  registerCommandGroup(program, propertyCommandGroup);
9162
9161
  }
9163
9162
 
9164
- // src/commands/savedViews/model.ts
9165
- function issuesOf(error) {
9166
- return error.issues.map((issue2) => ({ path: issue2.path.map(String).join("."), message: issue2.message }));
9167
- }
9168
- function invalid(code, message, issues) {
9169
- return new DinoxError(message, { code, details: issues === void 0 ? void 0 : { issues }, recoverable: false });
9170
- }
9171
- function parseJson(raw, label, code) {
9172
- const value = raw?.trim() ?? "";
9173
- if (!value) throw invalid(code, `${label} is required`);
9174
- try {
9175
- return JSON.parse(value);
9176
- } catch {
9177
- throw invalid(code, `${label} must be valid JSON`);
9178
- }
9179
- }
9180
- function validateSavedViewFilter(value) {
9181
- const parsed = savedViewFilterSchema.safeParse(value);
9182
- if (!parsed.success) {
9183
- throw invalid("SAVED_VIEW_INVALID_FILTER", "Saved view filter is invalid", issuesOf(parsed.error));
9184
- }
9185
- return parsed.data;
9186
- }
9187
- function validateSavedViewConfig(value) {
9188
- const parsed = savedViewConfigSchema.safeParse(value);
9189
- if (!parsed.success) {
9190
- throw invalid("SAVED_VIEW_INVALID_CONFIG", "Saved view config is invalid", issuesOf(parsed.error));
9191
- }
9192
- return parsed.data;
9193
- }
9194
- function parseSavedViewFilter(raw) {
9195
- return validateSavedViewFilter(parseJson(raw, "Saved view filter_json", "SAVED_VIEW_INVALID_FILTER"));
9196
- }
9197
- function parseSavedViewConfig(raw) {
9198
- return validateSavedViewConfig(parseJson(raw, "Saved view config_json", "SAVED_VIEW_INVALID_CONFIG"));
9199
- }
9200
- function baseFields(row) {
9201
- return {
9202
- id: row.id.trim(),
9203
- userId: row.user_id?.trim() ?? "",
9204
- name: row.name?.trim() ?? "",
9205
- emoji: row.emoji,
9206
- templateId: row.template_id,
9207
- groupId: row.group_id,
9208
- sortRank: row.sort_rank,
9209
- pinnedAt: row.pinned_at,
9210
- createdAt: row.created_at,
9211
- updatedAt: row.updated_at
9212
- };
9213
- }
9214
- function mapSavedViewRow(row) {
9215
- const base = baseFields(row);
9216
- if (!base.id || !base.userId || !base.name || base.name.length > 120) {
9217
- throw invalid("SAVED_VIEW_INVALID_ROW", "c_saved_view row is missing a valid id, user_id, or name");
9218
- }
9219
- const filter = parseSavedViewFilter(row.filter_json);
9220
- const config = parseSavedViewConfig(row.config_json);
9221
- return { ...base, layout: config.layout, filter, config };
9222
- }
9223
- function inspectSavedViewRow(row) {
9224
- try {
9225
- return { valid: true, view: mapSavedViewRow(row) };
9226
- } catch (error) {
9227
- const dinoxError = error instanceof DinoxError ? error : invalid("SAVED_VIEW_INVALID_ROW", String(error));
9228
- const issues = dinoxError.details?.issues;
9229
- return {
9230
- valid: false,
9231
- view: {
9232
- ...baseFields(row),
9233
- viewType: row.view_type,
9234
- filterJson: row.filter_json,
9235
- configJson: row.config_json
9236
- },
9237
- error: {
9238
- code: dinoxError.code,
9239
- message: dinoxError.message,
9240
- ...issues === void 0 ? {} : { issues }
9241
- }
9242
- };
9243
- }
9244
- }
9245
-
9246
- // src/commands/savedViews/fields.ts
9247
- var SYSTEM_FIELD_META = {
9248
- "sys.title": { name: "Title", propertyType: "text", type: "text" },
9249
- "sys.created_at": { name: "Created at", propertyType: "date", type: "date" },
9250
- "sys.updated_at": { name: "Updated at", propertyType: "date", type: "date" },
9251
- "sys.tags": { name: "Tags", propertyType: "multi_select", type: "list" },
9252
- "sys.zettel_boxes": { name: "Zettel boxes", propertyType: "relation", type: "list" },
9253
- "sys.source": { name: "Source", propertyType: "text", type: "text" },
9254
- "sys.type": { name: "Type", propertyType: "text", type: "text" },
9255
- "sys.primary_resource_type": { name: "Primary resource type", propertyType: "select", type: "select" },
9256
- "sys.starred_at": { name: "Starred at", propertyType: "date", type: "date" },
9257
- "sys.images": { name: "Images", propertyType: "text", type: "text" },
9258
- "sys.cover": { name: "Cover", propertyType: "text", type: "text" },
9259
- "sys.audio": { name: "Audio", propertyType: "text", type: "text" },
9260
- "sys.video": { name: "Video", propertyType: "text", type: "text" },
9261
- "sys.file": { name: "File", propertyType: "text", type: "text" }
9262
- };
9263
- function valueTypeForPropertyType(type) {
9264
- switch (type) {
9265
- case "number":
9266
- case "unique_id":
9267
- return "number";
9268
- case "date":
9269
- return "date";
9270
- case "select":
9271
- case "status":
9272
- return "select";
9273
- case "checkbox":
9274
- return "boolean";
9275
- case "multi_select":
9276
- case "relation":
9277
- return "list";
9278
- default:
9279
- return "text";
9280
- }
9281
- }
9282
- function catalogItem(field, name, propertyType, type) {
9283
- const displayOnly = isSavedViewDisplayOnlyField(field);
9284
- const filterOperators = getSavedViewFilterOperatorsForField(field, propertyType);
9285
- return {
9286
- field,
9287
- name,
9288
- type,
9289
- propertyType,
9290
- sortable: canSortSavedViewField(field, propertyType),
9291
- filterable: filterOperators.length > 0,
9292
- displayOnly,
9293
- filterOperators,
9294
- available: true
9295
- };
9296
- }
9297
- function propertyItem(definition) {
9298
- const field = `prop.${definition.key}`;
9299
- const item = {
9300
- ...catalogItem(field, definition.name || definition.key, definition.type, valueTypeForPropertyType(definition.type)),
9301
- propertyDefinitionId: definition.id,
9302
- description: definition.description ?? null,
9303
- icon: definition.icon ?? null,
9304
- ...definition.options ? { options: definition.options } : {},
9305
- ...definition.config ? { config: definition.config } : {}
9306
- };
9307
- const error = definition.optionsMigrationPending ? { code: "PROPERTY_OPTIONS_MIGRATION_REQUIRED", message: "Legacy select options must be migrated first (dino prop migrate-options)" } : definition.optionsInvalid ? { code: "PROPERTY_OPTIONS_INVALID", message: "Stored property options are invalid" } : definition.configInvalid ? { code: "PROPERTY_DEF_CONFIG_INVALID", message: "Stored property config is invalid" } : null;
9308
- return error ? { ...item, available: false, error } : item;
9309
- }
9310
- async function listPropertyDefinitions(db, userId, limit) {
9311
- const rows = await fetchDomainReadModel(db, "properties.catalog", { userId, ...limit ? { limit } : {} });
9312
- return rows.map(mapPropertyDef);
9313
- }
9314
- async function listSavedViewFields(db, userId) {
9315
- const systemItems = SAVED_VIEW_SYSTEM_FIELDS.map((name) => {
9316
- const field = `sys.${name}`;
9317
- const meta = SYSTEM_FIELD_META[field] ?? { name, propertyType: "text", type: "text" };
9318
- const item = catalogItem(field, meta.name, meta.propertyType, meta.type);
9319
- return field === "sys.primary_resource_type" ? { ...item, values: SAVED_VIEW_PRIMARY_RESOURCE_TYPES } : item;
9320
- });
9321
- const definitions = await listPropertyDefinitions(db, userId);
9322
- return [...systemItems, ...definitions.map(propertyItem)];
9323
- }
9324
-
9325
- // src/commands/savedViews/repo.ts
9326
- var ACTIVE_VIEW_TYPE_SQL = `view_type IN (${SAVED_VIEW_LAYOUTS.map((layout) => `'${layout}'`).join(", ")})`;
9327
- var SAVED_VIEW_COLUMNS = `
9328
- id, user_id, name, emoji, filter_json, view_type, config_json, template_id, group_id,
9329
- sort_rank, pinned_at, created_at, updated_at, is_del
9330
- `;
9331
- function nowIso2() {
9332
- return (/* @__PURE__ */ new Date()).toISOString();
9333
- }
9334
- function notFound2(id) {
9335
- return new DinoxError(`Saved view not found: ${id}`, { code: "SAVED_VIEW_NOT_FOUND", details: { viewId: id } });
9336
- }
9337
- function catalogItem2(row) {
9338
- const inspection = inspectSavedViewRow(row);
9339
- const view = inspection.view;
9340
- return {
9341
- id: view.id,
9342
- name: view.name,
9343
- emoji: view.emoji,
9344
- layout: inspection.valid ? inspection.view.layout : row.view_type,
9345
- templateId: view.templateId,
9346
- groupId: view.groupId,
9347
- sortRank: view.sortRank,
9348
- pinnedAt: view.pinnedAt,
9349
- createdAt: view.createdAt,
9350
- updatedAt: view.updatedAt,
9351
- valid: inspection.valid,
9352
- ...inspection.valid ? {} : { error: { code: inspection.error.code, message: inspection.error.message } }
9353
- };
9354
- }
9355
- async function listSavedViews(db, input) {
9356
- const rows = await fetchDomainReadModel(db, "savedViews.catalog", {
9357
- userId: input.userId,
9358
- ...input.limit === void 0 ? {} : { limit: input.limit }
9359
- });
9360
- return rows.filter((row) => row.id?.trim()).map(catalogItem2);
9361
- }
9362
- async function findSavedViewRow(db, input) {
9363
- return await db.getOptional(
9364
- `
9365
- SELECT ${SAVED_VIEW_COLUMNS}
9366
- FROM c_saved_view
9367
- WHERE id = ?
9368
- AND user_id = ?
9369
- AND ${ACTIVE_VIEW_TYPE_SQL}
9370
- AND (is_del IS NULL OR is_del = 0)
9371
- LIMIT 1
9372
- `,
9373
- [input.id.trim(), input.userId]
9374
- ) ?? null;
9375
- }
9376
- async function getSavedView(db, input) {
9377
- const row = await findSavedViewRow(db, input);
9378
- if (!row) throw notFound2(input.id);
9379
- return inspectSavedViewRow(row);
9380
- }
9381
- function parseJsonValue(raw) {
9382
- if (!raw?.trim()) return void 0;
9383
- try {
9384
- return JSON.parse(raw);
9385
- } catch {
9386
- return void 0;
9387
- }
9388
- }
9389
- function parseObject(raw) {
9390
- const value = parseJsonValue(raw);
9391
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
9392
- }
9393
- function parseStringArray(raw) {
9394
- const value = parseJsonValue(raw);
9395
- return Array.isArray(value) ? value.flatMap((item) => typeof item === "string" && item.trim() ? [item.trim()] : []) : [];
9396
- }
9397
- function parseImages(raw) {
9398
- const value = parseJsonValue(raw);
9399
- return Array.isArray(value) ? value : [];
9400
- }
9401
- function resolveSystemValue(row, field) {
9402
- switch (field) {
9403
- case "sys.title":
9404
- return row.title;
9405
- case "sys.created_at":
9406
- return row.created_at;
9407
- case "sys.updated_at":
9408
- return row.updated_at;
9409
- case "sys.starred_at":
9410
- return row.starred_at;
9411
- case "sys.source":
9412
- return row.source;
9413
- case "sys.type":
9414
- return row.type;
9415
- case "sys.tags":
9416
- return parseStringArray(row.tags);
9417
- case "sys.zettel_boxes":
9418
- return parseStringArray(row.zettel_boxes);
9419
- case "sys.images":
9420
- return parseImages(row.images);
9421
- case "sys.cover":
9422
- return parseImages(row.images)[0] ?? null;
9423
- case "sys.primary_resource_type":
9424
- return row.primary_resource_type ?? null;
9425
- case "sys.audio":
9426
- case "sys.video":
9427
- case "sys.file":
9428
- return row.primary_resource_type === field.slice("sys.".length);
9429
- default:
9430
- return void 0;
9431
- }
9432
- }
9433
- function describeOption(value, options) {
9434
- const option = options.find((candidate) => candidate.id === value);
9435
- return option ? { id: option.id, label: option.label, archived: option.archived, color: option.color, ...option.group ? { group: option.group } : {} } : { id: value, label: null, unknown: true };
9436
- }
9437
- function displayValue(value, semantic) {
9438
- const options = semantic?.options;
9439
- if (!options) return value;
9440
- if ((semantic.propertyType === "select" || semantic.propertyType === "status") && typeof value === "string") {
9441
- return describeOption(value, options);
9442
- }
9443
- if (semantic.propertyType === "multi_select" && Array.isArray(value)) {
9444
- return value.map((item) => typeof item === "string" ? describeOption(item, options) : item);
9445
- }
9446
- return value;
9447
- }
9448
- function evaluateComputedColumn(properties, column) {
9449
- const read = (field) => {
9450
- if (!field.startsWith("prop.")) return null;
9451
- const raw = properties[field.slice("prop.".length)];
9452
- return typeof raw === "number" && Number.isFinite(raw) ? raw : null;
9453
- };
9454
- const left = read(column.expr.left);
9455
- const right = read(column.expr.right);
9456
- if (left === null || right === null) return null;
9457
- switch (column.expr.op) {
9458
- case "*":
9459
- return left * right;
9460
- case "/":
9461
- return right === 0 ? null : left / right;
9462
- case "+":
9463
- return left + right;
9464
- case "-":
9465
- return left - right;
9466
- }
9467
- }
9468
- function projectRow(row, fields, computedColumns, semantics) {
9469
- const properties = parseObject(row.properties);
9470
- const values = {};
9471
- const displayValues = {};
9472
- for (const field of fields) {
9473
- const value = field.startsWith("prop.") ? Object.hasOwn(properties, field.slice("prop.".length)) ? properties[field.slice("prop.".length)] : void 0 : resolveSystemValue(row, field);
9474
- if (value === void 0) continue;
9475
- values[field] = value;
9476
- if (field === "sys.zettel_boxes") {
9477
- const details = parseSavedViewZettelBoxDetails(row.zettel_box_details);
9478
- if (details.length > 0) displayValues[field] = details;
9479
- continue;
9480
- }
9481
- const display = displayValue(value, semantics.get(field));
9482
- if (display !== value) displayValues[field] = display;
9483
- }
9484
- for (const column of computedColumns) {
9485
- values[`calc.${column.id}`] = evaluateComputedColumn(properties, column);
9486
- }
9487
- return {
9488
- id: row.id,
9489
- title: row.title,
9490
- values,
9491
- ...Object.keys(displayValues).length > 0 ? { displayValues } : {}
9492
- };
9493
- }
9494
- function projectedColumns(config, semantics) {
9495
- return [
9496
- ...config.columns.map((column) => {
9497
- const semantic = semantics.get(column.field);
9498
- return {
9499
- field: column.field,
9500
- type: semantic?.type ?? "text",
9501
- propertyType: semantic?.propertyType ?? null,
9502
- dateMode: semantic?.dateMode ?? null,
9503
- ...semantic?.displayOnly ? { displayOnly: true } : {},
9504
- ...semantic?.options ? { options: semantic.options } : {}
9505
- };
9506
- }),
9507
- ...(config.computedColumns ?? []).map((column) => ({
9508
- field: `calc.${column.id}`,
9509
- type: "number",
9510
- propertyType: null,
9511
- dateMode: null,
9512
- computed: column
9513
- }))
9514
- ];
9515
- }
9516
- async function resolveScope(db, input) {
9517
- try {
9518
- return await resolveSavedViewQueryScope(db, input);
9519
- } catch (error) {
9520
- const mapped = toDinoxError(error, "savedViews.query");
9521
- if (mapped.code === "SAVED_VIEW_NOT_FOUND") throw notFound2(input.viewId);
9522
- throw mapped;
9523
- }
9524
- }
9525
- async function querySavedView(db, input) {
9526
- const limit = Math.min(500, Math.max(1, Math.trunc(input.limit ?? 100)));
9527
- const offset = Math.max(0, Math.trunc(input.offset ?? 0));
9528
- return withReadTransaction(db, async (tx) => {
9529
- const scope = await resolveScope(tx, input);
9530
- const pageInput = { viewId: input.viewId, userId: input.userId, timeZone: input.timeZone, limit, offset };
9531
- const rawRows = await fetchSavedViewScopedPage(tx, pageInput, scope);
9532
- const totalCount = await countSavedViewScopedRows(tx, pageInput, scope);
9533
- const view = await getSavedView(tx, { id: input.viewId, userId: input.userId });
9534
- const fields = scope.config.columns.map((column) => column.field);
9535
- const rows = rawRows.map((row) => projectRow(row, fields, scope.config.computedColumns ?? [], scope.semantics));
9536
- const nextOffset = offset + rows.length;
9537
- const hasMore = nextOffset < totalCount;
9538
- return {
9539
- view: view.view,
9540
- columns: projectedColumns(scope.config, scope.semantics),
9541
- totalCount,
9542
- offset,
9543
- limit,
9544
- nextOffset: hasMore ? nextOffset : null,
9545
- hasMore,
9546
- rows
9547
- };
9548
- });
9549
- }
9550
- async function countSavedViewRows(db, input) {
9551
- return withReadTransaction(db, async (tx) => {
9552
- const scope = await resolveScope(tx, input);
9553
- return countSavedViewScopedRows(tx, input, scope);
9554
- });
9555
- }
9556
- async function getSavedViewAnalytics(db, input) {
9557
- const view = await getSavedView(db, { id: input.viewId, userId: input.userId });
9558
- const [analytics] = await fetchDomainReadModel(db, "savedViews.analytics", {
9559
- viewId: input.viewId,
9560
- userId: input.userId,
9561
- ...input.timeZone ? { timeZone: input.timeZone } : {}
9562
- });
9563
- const config = view.valid ? view.view.config : void 0;
9564
- return {
9565
- stats: analytics?.stats ?? [],
9566
- charts: analytics?.charts ?? [],
9567
- summary: analytics?.summary ?? [],
9568
- config: {
9569
- ...config?.stats ? { stats: config.stats } : {},
9570
- ...config?.charts ? { charts: config.charts } : {},
9571
- ...config?.summary ? { summary: config.summary } : {},
9572
- ...config?.computedColumns ? { computedColumns: config.computedColumns } : {}
9573
- }
9574
- };
9575
- }
9576
- async function propertySemantics(db, userId) {
9577
- const definitions = await listPropertyDefinitions(db, userId);
9578
- return new Map(definitions.map((definition) => [
9579
- `prop.${definition.key}`,
9580
- {
9581
- type: valueTypeForPropertyType(definition.type),
9582
- propertyType: definition.type,
9583
- ...definition.options ? { options: definition.options } : {}
9584
- }
9585
- ]));
9586
- }
9587
- async function getNoteDetailSections(db, input) {
9588
- return withReadTransaction(db, async (tx) => {
9589
- const sections = await fetchDomainReadModel(tx, "savedViews.noteDetail", {
9590
- noteId: input.noteId,
9591
- userId: input.userId,
9592
- ...input.timeZone ? { timeZone: input.timeZone } : {},
9593
- ...input.limit === void 0 ? {} : { limit: input.limit }
9594
- });
9595
- if (sections.length === 0) return [];
9596
- const semantics = await propertySemantics(tx, input.userId);
9597
- const result = [];
9598
- for (const section of sections) {
9599
- const view = await getSavedView(tx, { id: section.view_id, userId: input.userId });
9600
- const config = view.valid ? view.view.config : createDefaultSavedViewConfig();
9601
- const fields = config.columns.map((column) => column.field);
9602
- result.push({
9603
- viewId: section.view_id,
9604
- name: section.name,
9605
- emoji: section.emoji,
9606
- totalCount: section.total_count,
9607
- columns: projectedColumns(config, semantics),
9608
- rows: section.rows.map((row) => projectRow(row, fields, config.computedColumns ?? [], semantics))
9609
- });
9610
- }
9611
- return result;
9612
- });
9613
- }
9614
- function withLayout(config, layout) {
9615
- return layout === void 0 || layout === config.layout ? config : { ...config, layout };
9616
- }
9617
- async function resolveUpdateConfig(db, input) {
9618
- if (input.config !== void 0) return withLayout(input.config, input.layout);
9619
- if (input.layout === void 0) return void 0;
9620
- const row = await findSavedViewRow(db, input);
9621
- if (!row) throw notFound2(input.id);
9622
- return withLayout(parseSavedViewConfig(row.config_json), input.layout);
9623
- }
9624
- function definedEntries(value) {
9625
- return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
9626
- }
9627
- async function runCreate2(db, input) {
9628
- const config = withLayout(input.config ?? createDefaultSavedViewConfig(), input.layout);
9629
- const { result: id } = await runDomainCommand(db, "savedViews.create", definedEntries({
9630
- userId: input.userId,
9631
- name: input.name,
9632
- emoji: input.emoji,
9633
- filter: input.filter ?? createDefaultSavedViewFilter(),
9634
- config,
9635
- templateId: input.templateId,
9636
- groupId: input.groupId,
9637
- sortRank: input.sortRank,
9638
- pinnedAt: input.pinnedAt,
9639
- updatedAt: nowIso2()
9640
- }));
9641
- return getSavedView(db, { id, userId: input.userId });
9642
- }
9643
- async function runUpdate2(db, input) {
9644
- const config = await resolveUpdateConfig(db, input);
9645
- const { result: changed } = await runDomainCommand(db, "savedViews.update", definedEntries({
9646
- id: input.id,
9647
- userId: input.userId,
9648
- name: input.name,
9649
- emoji: input.emoji,
9650
- filter: input.filter,
9651
- config,
9652
- templateId: input.templateId,
9653
- groupId: input.groupId,
9654
- sortRank: input.sortRank,
9655
- pinnedAt: input.pinnedAt,
9656
- updatedAt: nowIso2()
9657
- }));
9658
- if (!changed) throw notFound2(input.id);
9659
- return getSavedView(db, input);
9660
- }
9661
- async function runDelete2(db, input) {
9662
- const before = await getSavedView(db, input);
9663
- const { result: changed } = await runDomainCommand(db, "savedViews.softDelete", {
9664
- id: input.id,
9665
- userId: input.userId,
9666
- updatedAt: nowIso2()
9667
- });
9668
- if (!changed) throw notFound2(input.id);
9669
- return before;
9670
- }
9671
- async function createSavedView(db, input) {
9672
- return runCreate2(db, input);
9673
- }
9674
- async function updateSavedView(db, input) {
9675
- return runUpdate2(db, input);
9676
- }
9677
- async function deleteSavedView(db, input) {
9678
- return runDelete2(db, input);
9679
- }
9680
- async function previewCreateSavedView(db, input) {
9681
- return previewInRolledBackTransaction(db, (tx) => runCreate2(tx, input), async (_tx, after) => ({
9682
- action: "create",
9683
- before: null,
9684
- after
9685
- }));
9686
- }
9687
- async function previewUpdateSavedView(db, input) {
9688
- const before = await getSavedView(db, input);
9689
- return previewInRolledBackTransaction(db, (tx) => runUpdate2(tx, input), async (_tx, after) => ({
9690
- action: "update",
9691
- before,
9692
- after
9693
- }));
9694
- }
9695
- async function previewDeleteSavedView(db, input) {
9696
- return previewInRolledBackTransaction(db, (tx) => runDelete2(tx, input), async (_tx, before) => ({
9697
- action: "delete",
9698
- before,
9699
- after: null
9700
- }));
9701
- }
9702
-
9703
9163
  // src/commands/savedViews/index.ts
9704
9164
  var VIEW_GLOBAL_OPTIONS = [
9705
9165
  ...FORMAT_OPTIONS,
@@ -11880,7 +11340,7 @@ var clipCommandGroup = {
11880
11340
  examples: ["dino clip inspect https://example.com/article --format json"]
11881
11341
  },
11882
11342
  action: async (context) => {
11883
- const { runClipInspect } = await import("./run-7D6ATULD.js");
11343
+ const { runClipInspect } = await import("./run-WNHMZLSJ.js");
11884
11344
  await runClipInspect(context);
11885
11345
  }
11886
11346
  },
@@ -11938,7 +11398,7 @@ var clipCommandGroup = {
11938
11398
  ]
11939
11399
  },
11940
11400
  action: async (context) => {
11941
- const { runClipAdd } = await import("./run-7D6ATULD.js");
11401
+ const { runClipAdd } = await import("./run-WNHMZLSJ.js");
11942
11402
  await runClipAdd(context);
11943
11403
  }
11944
11404
  },
@@ -11959,7 +11419,7 @@ var clipCommandGroup = {
11959
11419
  examples: ["dino clip process 01a1e3bb-3827-790d-b850-52b187c12b53 --format json"]
11960
11420
  },
11961
11421
  action: async (context) => {
11962
- const { runClipProcess } = await import("./run-7D6ATULD.js");
11422
+ const { runClipProcess } = await import("./run-WNHMZLSJ.js");
11963
11423
  await runClipProcess(context);
11964
11424
  }
11965
11425
  },
@@ -11983,7 +11443,7 @@ var clipCommandGroup = {
11983
11443
  examples: ["dino clip setup", "dino clip setup --progress --format json", "dino clip setup --check --format json"]
11984
11444
  },
11985
11445
  action: async (context) => {
11986
- const { runClipSetup } = await import("./setup-DSTOF3BZ.js");
11446
+ const { runClipSetup } = await import("./setup-UYCLFOZH.js");
11987
11447
  await runClipSetup(context);
11988
11448
  }
11989
11449
  },
@@ -12003,7 +11463,7 @@ var clipCommandGroup = {
12003
11463
  examples: ["dino clip cookies-list --format json"]
12004
11464
  },
12005
11465
  action: async () => {
12006
- const { runClipCookiesList } = await import("./cookies-ORQ3RLAH.js");
11466
+ const { runClipCookiesList } = await import("./cookies-UUQZXH4R.js");
12007
11467
  await runClipCookiesList();
12008
11468
  }
12009
11469
  },
@@ -12030,7 +11490,7 @@ var clipCommandGroup = {
12030
11490
  ]
12031
11491
  },
12032
11492
  action: async (context) => {
12033
- const { runClipCookiesImport } = await import("./cookies-ORQ3RLAH.js");
11493
+ const { runClipCookiesImport } = await import("./cookies-UUQZXH4R.js");
12034
11494
  await runClipCookiesImport(context);
12035
11495
  }
12036
11496
  },
@@ -12054,7 +11514,7 @@ var clipCommandGroup = {
12054
11514
  examples: ["pbpaste | dino clip cookies-set example.com - --format json"]
12055
11515
  },
12056
11516
  action: async (context) => {
12057
- const { runClipCookiesSet } = await import("./cookies-ORQ3RLAH.js");
11517
+ const { runClipCookiesSet } = await import("./cookies-UUQZXH4R.js");
12058
11518
  await runClipCookiesSet(context);
12059
11519
  }
12060
11520
  },
@@ -12076,7 +11536,7 @@ var clipCommandGroup = {
12076
11536
  examples: ["dino clip cookies-remove example.com --format json", "dino clip cookies-remove --all --format json"]
12077
11537
  },
12078
11538
  action: async (context) => {
12079
- const { runClipCookiesRemove } = await import("./cookies-ORQ3RLAH.js");
11539
+ const { runClipCookiesRemove } = await import("./cookies-UUQZXH4R.js");
12080
11540
  await runClipCookiesRemove(context);
12081
11541
  }
12082
11542
  }
@@ -12118,7 +11578,7 @@ function pathKey(value) {
12118
11578
  function getPathId(path6, lookup) {
12119
11579
  return lookup?.idByPath.get(pathKey(path6)) ?? canonicalizeTagPath(path6);
12120
11580
  }
12121
- function parseJson2(raw) {
11581
+ function parseJson(raw) {
12122
11582
  if (!raw) {
12123
11583
  return null;
12124
11584
  }
@@ -12142,7 +11602,7 @@ function extractHashtagPath(attrs, lookup) {
12142
11602
  return mapped ? canonicalizeTagPath(mapped) : canonicalizeTagPath(id);
12143
11603
  }
12144
11604
  function rewriteHashtagsInJson(raw, oldPrefix, newPrefix, preserveSuffix, lookup) {
12145
- const parsed = parseJson2(raw);
11605
+ const parsed = parseJson(raw);
12146
11606
  if (!parsed) {
12147
11607
  return { changed: false, contentJson: raw, plainText: null };
12148
11608
  }
@@ -13228,8 +12688,8 @@ async function readPropertyKeys(options) {
13228
12688
  ...typeof options.propertyKeys === "string" ? parseListInput(await readStringOrFile(options.propertyKeys), "--property-keys") : []
13229
12689
  ];
13230
12690
  if (options.propertyKey === void 0 && options.propertyKeys === void 0) return void 0;
13231
- const invalid2 = keys.find((key) => !isPropertyKeyValid(key));
13232
- if (invalid2 !== void 0) throw new DinoxError(`Invalid property key: ${invalid2}`, { code: "USAGE_ERROR" });
12691
+ const invalid = keys.find((key) => !isPropertyKeyValid(key));
12692
+ if (invalid !== void 0) throw new DinoxError(`Invalid property key: ${invalid}`, { code: "USAGE_ERROR" });
13233
12693
  return [...new Set(keys)];
13234
12694
  }
13235
12695
  async function readWriteInput2(options) {
@@ -14340,7 +13800,7 @@ function readToolVersion(pm) {
14340
13800
  child.on("error", () => resolve(null));
14341
13801
  });
14342
13802
  }
14343
- async function runUpdate3(pm, options) {
13803
+ async function runUpdate2(pm, options) {
14344
13804
  const toolVersion = pm === "npm" || pm === "pnpm" ? await readToolVersion(pm) : null;
14345
13805
  return runPackageManager(pm, appendNativeBuildPermissions(pm, PM_COMMANDS[pm].args, toolVersion), options);
14346
13806
  }
@@ -14369,7 +13829,7 @@ async function installMissingAcpAdapters(pm, options, missing) {
14369
13829
  function resolveDeps(overrides) {
14370
13830
  return {
14371
13831
  detectPackageManager,
14372
- runUpdate: runUpdate3,
13832
+ runUpdate: runUpdate2,
14373
13833
  installAcpAdapters: (pm, options) => installMissingAcpAdapters(pm, options),
14374
13834
  getVersion: getPackageVersion,
14375
13835
  getLatestVersion: fetchLatestPublishedVersion,
@@ -14508,7 +13968,7 @@ function parseMcpGroups(raw) {
14508
13968
  }
14509
13969
  async function runMcp(context) {
14510
13970
  const groups = parseMcpGroups(context.options.groups);
14511
- const { serveStandaloneMcpOverStdio } = await import("./mcpServer-G2WEAD2O.js");
13971
+ const { serveStandaloneMcpOverStdio } = await import("./mcpServer-M4HJFSNU.js");
14512
13972
  await serveStandaloneMcpOverStdio({ readOnly: context.options.readOnly === true, groups });
14513
13973
  }
14514
13974
  var mcpCommandDescriptor = {