@dinoxx/dinox-cli 2.20.2 → 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.
- package/README.md +17 -16
- package/dist/chunks/{applePodcast-V4FSJOC5.js → applePodcast-YDYM4JYQ.js} +3 -3
- package/dist/chunks/{bbc-NTMRPYRF.js → bbc-N3BM2EGG.js} +3 -3
- package/dist/chunks/{bilibili-UA3MBSPH.js → bilibili-V4XVW33T.js} +63 -9
- package/dist/chunks/{bohaishibei-B7UVXH4Y.js → bohaishibei-IQO5CZTN.js} +3 -3
- package/dist/chunks/{chunk-BZQYECIH.js → chunk-52XLDO77.js} +1 -1
- package/dist/chunks/{chunk-XEPDFQYD.js → chunk-5SORBZTD.js} +27 -27
- package/dist/chunks/{chunk-XMMTGPZ6.js → chunk-AZ43P73A.js} +56 -2
- package/dist/chunks/{chunk-W4EWLODY.js → chunk-DKY574LO.js} +3 -3
- package/dist/chunks/{chunk-4GM3PRSK.js → chunk-G6Y3MOUL.js} +6167 -3846
- package/dist/chunks/{chunk-BKCNERPB.js → chunk-JNRA4TTH.js} +99 -18
- package/dist/chunks/{chunk-3VZNZWDG.js → chunk-LAWV5XGL.js} +5 -0
- package/dist/chunks/{chunk-FIQYJ6KZ.js → chunk-LLAXR5EG.js} +1 -1
- package/dist/chunks/{chunk-MLOITAK6.js → chunk-LXC3IW4L.js} +2 -2
- package/dist/chunks/{chunk-TILRKKRN.js → chunk-MKEL2KNU.js} +893 -468
- package/dist/chunks/{chunk-7MGDG5BW.js → chunk-MMO7CINX.js} +499 -651
- package/dist/chunks/{chunk-FGQRYB7F.js → chunk-MZMOE3RX.js} +13 -1
- package/dist/chunks/{chunk-D3CETVY5.js → chunk-OZXS77HJ.js} +7 -7
- package/dist/chunks/{chunk-MDWXLRRN.js → chunk-PCB2JD6H.js} +6 -6
- package/dist/chunks/{chunk-6AZT4ARG.js → chunk-R2CGNGOT.js} +3 -3
- package/dist/chunks/{chunk-GTDX2LIJ.js → chunk-RSSEVU2F.js} +58 -10
- package/dist/chunks/{chunk-6D3QLMRM.js → chunk-TOGYWN3D.js} +1 -1
- package/dist/chunks/{chunk-CHGKDZV6.js → chunk-WCY3EKJQ.js} +4 -4
- package/dist/chunks/{chunk-QFSMFANX.js → chunk-YFGDTC2F.js} +9 -2
- package/dist/chunks/{chunk-QFUD3I7W.js → chunk-YX4SIEVS.js} +3 -4
- package/dist/chunks/{cookies-6QQHSM26.js → cookies-UUQZXH4R.js} +4 -6
- package/dist/chunks/{doubanGroup-HR4K2KMY.js → doubanGroup-MADXDGDI.js} +4 -4
- package/dist/chunks/{doubao-MXUHPLUB.js → doubao-DKZERP6Y.js} +2 -2
- package/dist/chunks/{douyin-UU2FSQPS.js → douyin-PIWFZHK7.js} +91 -5
- package/dist/chunks/{ensure-E3DIRHSQ.js → ensure-2OPNFDRW.js} +7 -7
- package/dist/chunks/{execute-YP2N2AMS.js → execute-C5W5ZJDC.js} +5 -5
- package/dist/chunks/{facebook-SZFOVE7R.js → facebook-TI2CF5UY.js} +2 -2
- package/dist/chunks/{feishu-ISWRJ7HI.js → feishu-XSSEBWQD.js} +2 -2
- package/dist/chunks/{ima-D7CX5WR4.js → ima-SKE2C64C.js} +2 -2
- package/dist/chunks/{instagram-HNDPO37H.js → instagram-4W4HCWJN.js} +2 -2
- package/dist/chunks/{install-IIMVFNAT.js → install-VBMWNPO6.js} +1 -3
- package/dist/chunks/{jike-H7L4LJTN.js → jike-GS64MEEO.js} +4 -4
- package/dist/chunks/{mcp-AK373P5P.js → mcp-WK7KIU44.js} +14 -12
- package/dist/chunks/{mcpServer-7VL4KJH2.js → mcpServer-M4HJFSNU.js} +17 -15
- package/dist/chunks/{metaso-ZVZW5UBB.js → metaso-RRYEUXIL.js} +2 -2
- package/dist/chunks/{run-OYMMVKCB.js → run-WNHMZLSJ.js} +11 -11
- package/dist/chunks/{runCli-ZJ7WYHJ7.js → runCli-GKTCIDBF.js} +12 -12
- package/dist/chunks/{setup-EEU6GSWX.js → setup-UYCLFOZH.js} +6 -6
- package/dist/chunks/{threads-ADW6IANQ.js → threads-JKMT3E73.js} +3 -3
- package/dist/chunks/{twitter-NAGCB3NI.js → twitter-WNBOJELM.js} +2 -2
- package/dist/chunks/{web-QFKZCM4F.js → web-LJESVHHV.js} +4 -4
- package/dist/chunks/{wechat-OXNNLT4J.js → wechat-N7O77CB4.js} +40 -1
- package/dist/chunks/{weibo-PMVGDNQU.js → weibo-XPEV5CLQ.js} +4 -4
- package/dist/chunks/{workbuddy-NNAXIIIZ.js → workbuddy-ZXNDX7O7.js} +5 -5
- package/dist/chunks/{xiaoheihe-WFQJRBAD.js → xiaoheihe-WXFAORLQ.js} +3 -3
- package/dist/chunks/{xiaohongshu-5CXBELGW.js → xiaohongshu-3N3ZVSXJ.js} +2 -2
- package/dist/chunks/{xiaoyuzhou-6L6IB46Y.js → xiaoyuzhou-OGIWFABL.js} +3 -3
- package/dist/chunks/{youtube-52NGBTQC.js → youtube-YRSK7CWC.js} +3 -3
- package/dist/chunks/{zcool-HDSWK4KD.js → zcool-K5KJ2KDG.js} +2 -2
- package/dist/chunks/{zhihu-EX2VRJYY.js → zhihu-X6XSPD6B.js} +2 -2
- package/dist/dinox.js +7 -7
- package/dist/dsh-plugin/lib/client.js +1030 -578
- package/dist/dsh-plugin/lib/index.js +11 -7
- package/dist/dsh-plugin/package.json +1 -1
- package/dist/dsh-plugin/runtime.json +2 -2
- package/dist/editor-ui/mcp-app.html +449 -583
- package/package.json +25 -12
|
@@ -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-
|
|
5
|
+
} from "./chunk-PCB2JD6H.js";
|
|
6
6
|
import {
|
|
7
7
|
WRITE_DURABILITY_OPTION,
|
|
8
8
|
buildBatchWriteReceiptFields,
|
|
@@ -33,22 +33,21 @@ import {
|
|
|
33
33
|
withCommandRuntime,
|
|
34
34
|
withExclusivePowerSync,
|
|
35
35
|
withNoteDatabase
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-OZXS77HJ.js";
|
|
37
37
|
import {
|
|
38
38
|
reportProgress
|
|
39
|
-
} from "./chunk-
|
|
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,
|
|
44
|
+
NOTE_PROPERTY_LIMITS,
|
|
45
45
|
PROPERTY_OPTION_COLORS,
|
|
46
|
+
PROPERTY_OPTION_LABEL_MAX_LENGTH,
|
|
46
47
|
REQUIRED_NOTE_BOX_COLUMNS,
|
|
47
48
|
REQUIRED_NOTE_TAG_COLUMNS,
|
|
48
49
|
REQUIRED_TAG_NODE_COLUMNS,
|
|
49
50
|
SAVED_VIEW_LAYOUTS,
|
|
50
|
-
SAVED_VIEW_PRIMARY_RESOURCE_TYPES,
|
|
51
|
-
SAVED_VIEW_SYSTEM_FIELDS,
|
|
52
51
|
STATUS_PROPERTY_GROUPS,
|
|
53
52
|
acquirePowerSyncOwnerLease,
|
|
54
53
|
activeBoxNodes,
|
|
@@ -77,19 +76,18 @@ import {
|
|
|
77
76
|
buildStorageTarget,
|
|
78
77
|
buildStorageTestPlan,
|
|
79
78
|
buildStorageUploadPlan,
|
|
80
|
-
canSortSavedViewField,
|
|
81
79
|
canonicalizeBoxPath,
|
|
82
80
|
canonicalizeTagPath,
|
|
83
81
|
closePowerSyncAndReleaseOwner,
|
|
82
|
+
coercePropertyValue,
|
|
84
83
|
commandSchemasFromGroupDescriptor,
|
|
85
84
|
configureProperty,
|
|
86
85
|
connectPowerSync,
|
|
87
86
|
convertMarkdownToNoteContent,
|
|
88
|
-
|
|
89
|
-
createDefaultSavedViewConfig,
|
|
90
|
-
createDefaultSavedViewFilter,
|
|
87
|
+
countSavedViewRows,
|
|
91
88
|
createNote,
|
|
92
89
|
createProperty,
|
|
90
|
+
createSavedView,
|
|
93
91
|
createStorageCollisionError,
|
|
94
92
|
createStorageUploadOutcomeUnknownError,
|
|
95
93
|
createTimeoutSignal,
|
|
@@ -99,6 +97,7 @@ import {
|
|
|
99
97
|
defaultUploadBytes,
|
|
100
98
|
defaultUploadObject,
|
|
101
99
|
deleteProperty,
|
|
100
|
+
deleteSavedView,
|
|
102
101
|
descendantsOf,
|
|
103
102
|
descendantsOf2,
|
|
104
103
|
enrichSearchRows,
|
|
@@ -106,9 +105,9 @@ import {
|
|
|
106
105
|
ensureNoTagPathConflict,
|
|
107
106
|
executeNoteSearch,
|
|
108
107
|
executeTodoSearch,
|
|
108
|
+
extractMarkdownFrontmatter,
|
|
109
109
|
fetchCredentialsWithAuthorization,
|
|
110
110
|
fetchDomainReadModel,
|
|
111
|
-
fetchSavedViewScopedPage,
|
|
112
111
|
fetchUserInfoWithAuthorization,
|
|
113
112
|
fillEmptyNoteProperties,
|
|
114
113
|
findMarkdownLiteralRanges,
|
|
@@ -121,12 +120,14 @@ import {
|
|
|
121
120
|
getLeafName,
|
|
122
121
|
getLeafName2,
|
|
123
122
|
getNoteContext,
|
|
123
|
+
getNoteDetailSections,
|
|
124
124
|
getNoteDetails,
|
|
125
125
|
getNoteExportItems,
|
|
126
126
|
getNotePreview,
|
|
127
127
|
getOutlinks,
|
|
128
128
|
getRelatedNotes,
|
|
129
|
-
|
|
129
|
+
getSavedView,
|
|
130
|
+
getSavedViewAnalytics,
|
|
130
131
|
getStatusSnapshot,
|
|
131
132
|
getStorageStats,
|
|
132
133
|
getTableColumns,
|
|
@@ -144,10 +145,11 @@ import {
|
|
|
144
145
|
isMarkdownOffsetInSortedRanges,
|
|
145
146
|
isObjectCollisionError,
|
|
146
147
|
isPropertyKeyValid,
|
|
147
|
-
isSavedViewDisplayOnlyField,
|
|
148
148
|
isTagPathWithinPrefix,
|
|
149
149
|
listBoxes,
|
|
150
150
|
listProperties,
|
|
151
|
+
listSavedViewFields,
|
|
152
|
+
listSavedViews,
|
|
151
153
|
listStorageConfigs,
|
|
152
154
|
listStoredCustomStorageConfigs,
|
|
153
155
|
listTags,
|
|
@@ -156,11 +158,11 @@ import {
|
|
|
156
158
|
loadSharp,
|
|
157
159
|
loadTagNodes,
|
|
158
160
|
mapNoteTemplateRow,
|
|
159
|
-
mapPropertyDef,
|
|
160
161
|
mergeAuthIdentityIntoConfig,
|
|
161
162
|
migrateLegacyOptions,
|
|
162
163
|
migrationAffectedCount,
|
|
163
164
|
normalizeBoxLookupKey,
|
|
165
|
+
normalizeDatePropertyValue,
|
|
164
166
|
normalizePropertyDefConfig,
|
|
165
167
|
normalizeTagLookupKey,
|
|
166
168
|
normalizeTaskTexts,
|
|
@@ -168,7 +170,7 @@ import {
|
|
|
168
170
|
nowIsoUtc,
|
|
169
171
|
parentIdForPath,
|
|
170
172
|
parentPathOf,
|
|
171
|
-
|
|
173
|
+
parseRawNoteProperties,
|
|
172
174
|
parseStorageUploadCategory,
|
|
173
175
|
parseStoredBoxIds,
|
|
174
176
|
parseStoredTags,
|
|
@@ -180,11 +182,15 @@ import {
|
|
|
180
182
|
planTodoUpdates,
|
|
181
183
|
previewConfigureProperty,
|
|
182
184
|
previewCreateProperty,
|
|
185
|
+
previewCreateSavedView,
|
|
183
186
|
previewCreateTodoNote,
|
|
184
187
|
previewDeleteProperty,
|
|
188
|
+
previewDeleteSavedView,
|
|
185
189
|
previewInRolledBackTransaction,
|
|
186
190
|
previewMigrateLegacyOptions,
|
|
191
|
+
previewUpdateSavedView,
|
|
187
192
|
projectNoteContent,
|
|
193
|
+
querySavedView,
|
|
188
194
|
readNoteContentForPatch,
|
|
189
195
|
readNoteProperties,
|
|
190
196
|
rebuildNoteTokenIndex,
|
|
@@ -197,7 +203,6 @@ import {
|
|
|
197
203
|
requireActiveTagPath,
|
|
198
204
|
requireProperty,
|
|
199
205
|
resolveAuthIdentity,
|
|
200
|
-
resolveSavedViewQueryScope,
|
|
201
206
|
resolveStorageSelection,
|
|
202
207
|
resolveZettelBoxIdsForBulk,
|
|
203
208
|
resolveZettelBoxIdsForCreate,
|
|
@@ -206,8 +211,6 @@ import {
|
|
|
206
211
|
restartDaemonLocked,
|
|
207
212
|
rotatePersistedAuthStateRevision,
|
|
208
213
|
runDomainCommand,
|
|
209
|
-
savedViewConfigSchema,
|
|
210
|
-
savedViewFilterSchema,
|
|
211
214
|
searchNotes,
|
|
212
215
|
serializeRawNoteProperties,
|
|
213
216
|
setNoteProperties,
|
|
@@ -216,7 +219,6 @@ import {
|
|
|
216
219
|
stopDaemonLocked,
|
|
217
220
|
syncNoteTokenIndex,
|
|
218
221
|
toBoxListItem,
|
|
219
|
-
toDinoxError,
|
|
220
222
|
toTagListItem,
|
|
221
223
|
toTodoSearchWire,
|
|
222
224
|
trimString,
|
|
@@ -224,8 +226,12 @@ import {
|
|
|
224
226
|
uninstallDaemonService,
|
|
225
227
|
updateNote,
|
|
226
228
|
updateNotePropertySlots,
|
|
229
|
+
updateSavedView,
|
|
227
230
|
updateTodoTaskStatus,
|
|
228
231
|
updateTodoTasks,
|
|
232
|
+
upgradeLegacyNoteNodes,
|
|
233
|
+
validateSavedViewConfig,
|
|
234
|
+
validateSavedViewFilter,
|
|
229
235
|
validateTagsForBulk,
|
|
230
236
|
validateTagsForCreate,
|
|
231
237
|
validateTagsForUpdate,
|
|
@@ -233,12 +239,11 @@ import {
|
|
|
233
239
|
waitForLastSyncedAfter,
|
|
234
240
|
waitForUploadQueueEmpty,
|
|
235
241
|
withNestedWriteTransaction,
|
|
236
|
-
withPowerSyncWriteTransaction
|
|
237
|
-
|
|
238
|
-
} from "./chunk-4GM3PRSK.js";
|
|
242
|
+
withPowerSyncWriteTransaction
|
|
243
|
+
} from "./chunk-G6Y3MOUL.js";
|
|
239
244
|
import {
|
|
240
245
|
executeCommandLine
|
|
241
|
-
} from "./chunk-
|
|
246
|
+
} from "./chunk-DKY574LO.js";
|
|
242
247
|
import {
|
|
243
248
|
AI_SERVICE_URL,
|
|
244
249
|
FORMAT_OPTIONS,
|
|
@@ -264,8 +269,13 @@ import {
|
|
|
264
269
|
updateConfig,
|
|
265
270
|
validateRequestId,
|
|
266
271
|
withAsyncRelease
|
|
267
|
-
} from "./chunk-
|
|
272
|
+
} from "./chunk-WCY3EKJQ.js";
|
|
273
|
+
import {
|
|
274
|
+
TASK_STATUS_VALUES,
|
|
275
|
+
isTaskStatus
|
|
276
|
+
} from "./chunk-JNRA4TTH.js";
|
|
268
277
|
import {
|
|
278
|
+
DEFAULT_DAEMON_PORT,
|
|
269
279
|
acquireDaemonExclusiveIntentLock,
|
|
270
280
|
acquireDaemonStartLock,
|
|
271
281
|
getDaemonInfo,
|
|
@@ -277,7 +287,7 @@ import {
|
|
|
277
287
|
readPid,
|
|
278
288
|
sendDaemonRequest,
|
|
279
289
|
shutdownDaemonForExclusiveAccess
|
|
280
|
-
} from "./chunk-
|
|
290
|
+
} from "./chunk-YFGDTC2F.js";
|
|
281
291
|
import {
|
|
282
292
|
agentLaunch
|
|
283
293
|
} from "./chunk-7ODU7LXP.js";
|
|
@@ -286,7 +296,7 @@ import {
|
|
|
286
296
|
} from "./chunk-WMJXAF3X.js";
|
|
287
297
|
import {
|
|
288
298
|
readStringOrFile
|
|
289
|
-
} from "./chunk-
|
|
299
|
+
} from "./chunk-LXC3IW4L.js";
|
|
290
300
|
import {
|
|
291
301
|
assertStdinAvailable,
|
|
292
302
|
clearPendingStructuredNoticeProvider,
|
|
@@ -300,7 +310,7 @@ import {
|
|
|
300
310
|
resolveUserPath,
|
|
301
311
|
setPendingStructuredNoticeProvider,
|
|
302
312
|
toJson
|
|
303
|
-
} from "./chunk-
|
|
313
|
+
} from "./chunk-TOGYWN3D.js";
|
|
304
314
|
import {
|
|
305
315
|
getDataDir,
|
|
306
316
|
getLegacyPowerSyncDbPath,
|
|
@@ -308,7 +318,7 @@ import {
|
|
|
308
318
|
} from "./chunk-XZLFMJOG.js";
|
|
309
319
|
import {
|
|
310
320
|
DinoxError
|
|
311
|
-
} from "./chunk-
|
|
321
|
+
} from "./chunk-LAWV5XGL.js";
|
|
312
322
|
|
|
313
323
|
// src/commands/auth/index.ts
|
|
314
324
|
import crypto from "node:crypto";
|
|
@@ -1480,7 +1490,7 @@ var batchCommandDescriptor = {
|
|
|
1480
1490
|
fields: ["ok", "summary", "results"]
|
|
1481
1491
|
},
|
|
1482
1492
|
examples: [
|
|
1483
|
-
`echo '[["note","search","AI","--limit","5"],["todo","search","--status","
|
|
1493
|
+
`echo '[["note","search","AI","--limit","5"],["todo","search","--status","todo,in_progress"]]' | dino batch --format json`,
|
|
1484
1494
|
"dino batch --input ops.json --stop-on-error --format json"
|
|
1485
1495
|
]
|
|
1486
1496
|
},
|
|
@@ -3322,7 +3332,7 @@ var gatewayCommandGroup = {
|
|
|
3322
3332
|
examples: ["dino gateway mcp"]
|
|
3323
3333
|
},
|
|
3324
3334
|
action: async () => {
|
|
3325
|
-
const { serveDinoxMcpOverStdio } = await import("./mcpServer-
|
|
3335
|
+
const { serveDinoxMcpOverStdio } = await import("./mcpServer-M4HJFSNU.js");
|
|
3326
3336
|
await serveDinoxMcpOverStdio();
|
|
3327
3337
|
}
|
|
3328
3338
|
},
|
|
@@ -3404,7 +3414,7 @@ var editorCommandGroup = {
|
|
|
3404
3414
|
examples: ["dino editor mcp", "dino editor mcp --session codex"]
|
|
3405
3415
|
},
|
|
3406
3416
|
action: async (context) => {
|
|
3407
|
-
const { serveEditorMcpOverStdio } = await import("./mcp-
|
|
3417
|
+
const { serveEditorMcpOverStdio } = await import("./mcp-WK7KIU44.js");
|
|
3408
3418
|
await serveEditorMcpOverStdio({ session: String(context.options.session ?? "mcp") });
|
|
3409
3419
|
}
|
|
3410
3420
|
},
|
|
@@ -3427,7 +3437,7 @@ var editorCommandGroup = {
|
|
|
3427
3437
|
},
|
|
3428
3438
|
action: async (context) => {
|
|
3429
3439
|
hostOf(context);
|
|
3430
|
-
const { installDsh } = await import("./install-
|
|
3440
|
+
const { installDsh } = await import("./install-VBMWNPO6.js");
|
|
3431
3441
|
const result = await installDsh(installOptions(context));
|
|
3432
3442
|
report(result, "Installed the Dinox editor in DeepSeek Harness:", result.next);
|
|
3433
3443
|
}
|
|
@@ -3451,7 +3461,7 @@ var editorCommandGroup = {
|
|
|
3451
3461
|
},
|
|
3452
3462
|
action: async (context) => {
|
|
3453
3463
|
hostOf(context);
|
|
3454
|
-
const { uninstallDsh } = await import("./install-
|
|
3464
|
+
const { uninstallDsh } = await import("./install-VBMWNPO6.js");
|
|
3455
3465
|
report(await uninstallDsh(installOptions(context)), "Removed the Dinox editor from DeepSeek Harness:", "Restart DeepSeek Harness Desktop.");
|
|
3456
3466
|
}
|
|
3457
3467
|
},
|
|
@@ -3472,7 +3482,7 @@ var editorCommandGroup = {
|
|
|
3472
3482
|
examples: ["dino editor status", "dino editor status --format json"]
|
|
3473
3483
|
},
|
|
3474
3484
|
action: async (context) => {
|
|
3475
|
-
const { editorStatus } = await import("./install-
|
|
3485
|
+
const { editorStatus } = await import("./install-VBMWNPO6.js");
|
|
3476
3486
|
const status = editorStatus(installOptions(context));
|
|
3477
3487
|
if (getRequestedStructuredOutputFormat()) {
|
|
3478
3488
|
printSuccess(status);
|
|
@@ -5252,7 +5262,7 @@ function parseCreatedAtRange(input, now = /* @__PURE__ */ new Date()) {
|
|
|
5252
5262
|
throw new DinoxError("--days cannot be used together with --from/--to");
|
|
5253
5263
|
}
|
|
5254
5264
|
if (days !== void 0) {
|
|
5255
|
-
const
|
|
5265
|
+
const nowIso2 = now.toISOString();
|
|
5256
5266
|
const todayUtcStart = Date.UTC(
|
|
5257
5267
|
now.getUTCFullYear(),
|
|
5258
5268
|
now.getUTCMonth(),
|
|
@@ -5265,7 +5275,7 @@ function parseCreatedAtRange(input, now = /* @__PURE__ */ new Date()) {
|
|
|
5265
5275
|
const fromUtc = new Date(todayUtcStart - (days - 1) * DAY_MS).toISOString();
|
|
5266
5276
|
return {
|
|
5267
5277
|
createdAtFrom: fromUtc,
|
|
5268
|
-
createdAtTo:
|
|
5278
|
+
createdAtTo: nowIso2
|
|
5269
5279
|
};
|
|
5270
5280
|
}
|
|
5271
5281
|
if (from && to && from > to) {
|
|
@@ -5334,6 +5344,337 @@ function buildNoteSearchResponse(input) {
|
|
|
5334
5344
|
};
|
|
5335
5345
|
}
|
|
5336
5346
|
|
|
5347
|
+
// ../../packages/note-engine/src/frontmatter-properties.ts
|
|
5348
|
+
import { parse as parseYaml } from "yaml";
|
|
5349
|
+
var PROPERTY_PATH_SEPARATOR = ".";
|
|
5350
|
+
var SHORT_LIST_LIMIT = 20;
|
|
5351
|
+
var NESTED_TEXT_DEPTH = 6;
|
|
5352
|
+
var RESERVED_KEYS = /* @__PURE__ */ new Set([
|
|
5353
|
+
"title",
|
|
5354
|
+
"tags",
|
|
5355
|
+
"tag",
|
|
5356
|
+
"keywords",
|
|
5357
|
+
"created",
|
|
5358
|
+
"created_at",
|
|
5359
|
+
// Written by Dinox's own Markdown export; the note gets its own timestamps and id on import.
|
|
5360
|
+
"updated",
|
|
5361
|
+
"updated_at",
|
|
5362
|
+
"dinox_id",
|
|
5363
|
+
"cssclasses",
|
|
5364
|
+
"cssclass",
|
|
5365
|
+
"publish"
|
|
5366
|
+
]);
|
|
5367
|
+
var TAG_KEYS = /* @__PURE__ */ new Set(["tags", "tag", "keywords"]);
|
|
5368
|
+
var CREATED_KEYS = /* @__PURE__ */ new Set(["created", "created_at"]);
|
|
5369
|
+
var LIST_TYPES = /* @__PURE__ */ new Set(["list", "multitext", "aliases"]);
|
|
5370
|
+
var EMPTY_DOCUMENT = {
|
|
5371
|
+
title: "",
|
|
5372
|
+
tags: [],
|
|
5373
|
+
createdAt: null,
|
|
5374
|
+
dinoxId: null,
|
|
5375
|
+
properties: []
|
|
5376
|
+
};
|
|
5377
|
+
function readMarkdownFrontmatter(frontmatter, propertyTypes) {
|
|
5378
|
+
const source = frontmatter.trim();
|
|
5379
|
+
if (!source) return { ...EMPTY_DOCUMENT, properties: [] };
|
|
5380
|
+
let parsed;
|
|
5381
|
+
try {
|
|
5382
|
+
parsed = parseYaml(source);
|
|
5383
|
+
} catch {
|
|
5384
|
+
return null;
|
|
5385
|
+
}
|
|
5386
|
+
if (!isRecord(parsed)) return { ...EMPTY_DOCUMENT, properties: [] };
|
|
5387
|
+
const document = {
|
|
5388
|
+
title: "",
|
|
5389
|
+
tags: [],
|
|
5390
|
+
createdAt: null,
|
|
5391
|
+
dinoxId: null,
|
|
5392
|
+
properties: []
|
|
5393
|
+
};
|
|
5394
|
+
for (const [rawKey, value] of Object.entries(parsed)) {
|
|
5395
|
+
if (rawKey === "__proto__") continue;
|
|
5396
|
+
const lowered = rawKey.toLowerCase();
|
|
5397
|
+
if (lowered === "title" && !document.title) {
|
|
5398
|
+
document.title = readTitle(value);
|
|
5399
|
+
continue;
|
|
5400
|
+
}
|
|
5401
|
+
if (TAG_KEYS.has(lowered)) {
|
|
5402
|
+
document.tags.push(...flattenTagValues(value));
|
|
5403
|
+
continue;
|
|
5404
|
+
}
|
|
5405
|
+
if (CREATED_KEYS.has(lowered) && !document.createdAt) {
|
|
5406
|
+
document.createdAt = readCreatedAt(value);
|
|
5407
|
+
continue;
|
|
5408
|
+
}
|
|
5409
|
+
if (lowered === "dinox_id" && !document.dinoxId) {
|
|
5410
|
+
document.dinoxId = readTitle(value) || null;
|
|
5411
|
+
continue;
|
|
5412
|
+
}
|
|
5413
|
+
if (RESERVED_KEYS.has(lowered)) continue;
|
|
5414
|
+
const segment = normalizeSegment(rawKey);
|
|
5415
|
+
if (!segment) continue;
|
|
5416
|
+
collectProperty(document.properties, [segment], value, lookupType(propertyTypes, rawKey, lowered));
|
|
5417
|
+
}
|
|
5418
|
+
return document;
|
|
5419
|
+
}
|
|
5420
|
+
function chooseMarkdownPropertyDefinitions(notes, catalog) {
|
|
5421
|
+
const plans = [];
|
|
5422
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5423
|
+
for (const properties of notes) {
|
|
5424
|
+
for (const property of properties) {
|
|
5425
|
+
if (catalog.has(property.key) || seen.has(property.key)) continue;
|
|
5426
|
+
seen.add(property.key);
|
|
5427
|
+
plans.push({
|
|
5428
|
+
key: property.key,
|
|
5429
|
+
name: property.name,
|
|
5430
|
+
type: property.type,
|
|
5431
|
+
dateMode: property.dateMode
|
|
5432
|
+
});
|
|
5433
|
+
}
|
|
5434
|
+
}
|
|
5435
|
+
return plans;
|
|
5436
|
+
}
|
|
5437
|
+
function buildMarkdownPropertyValues(properties, resolved, currentPropertiesJson) {
|
|
5438
|
+
const current = parseRawNoteProperties(currentPropertiesJson);
|
|
5439
|
+
const patch = {};
|
|
5440
|
+
for (const property of properties) {
|
|
5441
|
+
if (Object.keys(patch).length >= NOTE_PROPERTY_LIMITS.mutationKeys) break;
|
|
5442
|
+
const choice = resolved.get(property.key);
|
|
5443
|
+
if (!choice) continue;
|
|
5444
|
+
if (Object.hasOwn(current, property.key) && current[property.key] !== null) continue;
|
|
5445
|
+
const value = coerceMarkdownPropertyValue(choice, property.value);
|
|
5446
|
+
if (value === null) continue;
|
|
5447
|
+
patch[property.key] = value;
|
|
5448
|
+
}
|
|
5449
|
+
return patch;
|
|
5450
|
+
}
|
|
5451
|
+
function collectProperty(properties, parts, value, explicitType) {
|
|
5452
|
+
if (properties.length >= NOTE_PROPERTY_LIMITS.mutationKeys) return;
|
|
5453
|
+
if (value == null) return;
|
|
5454
|
+
if (isRecord(value)) {
|
|
5455
|
+
const entries = Object.entries(value).filter(([key]) => key !== "__proto__");
|
|
5456
|
+
if (entries.length === 0) return;
|
|
5457
|
+
for (const [key, child] of entries) {
|
|
5458
|
+
const segment = normalizeSegment(key);
|
|
5459
|
+
if (!segment) continue;
|
|
5460
|
+
collectProperty(properties, [...parts, segment], child, void 0);
|
|
5461
|
+
}
|
|
5462
|
+
return;
|
|
5463
|
+
}
|
|
5464
|
+
if (Array.isArray(value)) {
|
|
5465
|
+
if (value.some((item) => isRecord(item) || Array.isArray(item))) {
|
|
5466
|
+
pushText(properties, parts, describeNested(value, 0));
|
|
5467
|
+
return;
|
|
5468
|
+
}
|
|
5469
|
+
pushList(properties, parts, value, explicitType);
|
|
5470
|
+
return;
|
|
5471
|
+
}
|
|
5472
|
+
pushScalar(properties, parts, value, explicitType);
|
|
5473
|
+
}
|
|
5474
|
+
function pushScalar(properties, parts, value, explicitType) {
|
|
5475
|
+
if (explicitType === "aliases" && typeof value === "string") {
|
|
5476
|
+
const items = value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
5477
|
+
pushList(properties, parts, items, "aliases");
|
|
5478
|
+
return;
|
|
5479
|
+
}
|
|
5480
|
+
const typed = scalarProperty(value, explicitType);
|
|
5481
|
+
if (!typed) return;
|
|
5482
|
+
pushProperty(properties, parts, typed);
|
|
5483
|
+
}
|
|
5484
|
+
function pushList(properties, parts, values, explicitType) {
|
|
5485
|
+
if (explicitType === "text") {
|
|
5486
|
+
pushText(properties, parts, values.map(scalarToText).filter(Boolean).join("\n"));
|
|
5487
|
+
return;
|
|
5488
|
+
}
|
|
5489
|
+
if (explicitType === "number" || explicitType === "checkbox" || explicitType === "date" || explicitType === "datetime") {
|
|
5490
|
+
pushScalar(properties, parts, values.length === 1 ? values[0] : null, explicitType);
|
|
5491
|
+
return;
|
|
5492
|
+
}
|
|
5493
|
+
const wantsList = explicitType === void 0 || LIST_TYPES.has(explicitType);
|
|
5494
|
+
const options = wantsList ? readShortList(values) : null;
|
|
5495
|
+
if (options) {
|
|
5496
|
+
pushProperty(properties, parts, {
|
|
5497
|
+
type: "multi_select",
|
|
5498
|
+
value: options,
|
|
5499
|
+
dateMode: "date"
|
|
5500
|
+
});
|
|
5501
|
+
return;
|
|
5502
|
+
}
|
|
5503
|
+
pushText(properties, parts, values.map(scalarToText).filter(Boolean).join("\n"));
|
|
5504
|
+
}
|
|
5505
|
+
function pushText(properties, parts, text) {
|
|
5506
|
+
const value = clipText(text);
|
|
5507
|
+
if (!value) return;
|
|
5508
|
+
pushProperty(properties, parts, { type: "text", value, dateMode: "date" });
|
|
5509
|
+
}
|
|
5510
|
+
function pushProperty(properties, parts, property) {
|
|
5511
|
+
if (properties.length >= NOTE_PROPERTY_LIMITS.mutationKeys) return;
|
|
5512
|
+
const key = parts.join(PROPERTY_PATH_SEPARATOR);
|
|
5513
|
+
if (!isPropertyKeyValid(key) || properties.some((item) => item.key === key)) return;
|
|
5514
|
+
properties.push({
|
|
5515
|
+
key,
|
|
5516
|
+
name: key,
|
|
5517
|
+
type: property.type,
|
|
5518
|
+
value: property.value,
|
|
5519
|
+
dateMode: property.dateMode
|
|
5520
|
+
});
|
|
5521
|
+
}
|
|
5522
|
+
function scalarProperty(value, explicitType) {
|
|
5523
|
+
if (explicitType === "checkbox") {
|
|
5524
|
+
const coerced = coercePropertyValue("checkbox", value);
|
|
5525
|
+
return typeof coerced === "boolean" ? { type: "checkbox", value: coerced, dateMode: "date" } : null;
|
|
5526
|
+
}
|
|
5527
|
+
if (explicitType === "number") {
|
|
5528
|
+
const coerced = coercePropertyValue("number", value);
|
|
5529
|
+
return typeof coerced === "number" ? { type: "number", value: coerced, dateMode: "date" } : null;
|
|
5530
|
+
}
|
|
5531
|
+
if (explicitType === "date" || explicitType === "datetime") {
|
|
5532
|
+
const dateMode2 = explicitType === "datetime" ? "datetime" : "date";
|
|
5533
|
+
const coerced = normalizeDatePropertyValue(dateInput(value), dateMode2);
|
|
5534
|
+
return coerced ? { type: "date", value: coerced, dateMode: dateMode2 } : null;
|
|
5535
|
+
}
|
|
5536
|
+
if (explicitType === "text" || explicitType !== void 0 && LIST_TYPES.has(explicitType)) {
|
|
5537
|
+
const text2 = scalarToText(value);
|
|
5538
|
+
return text2 ? { type: "text", value: clipText(text2), dateMode: "date" } : null;
|
|
5539
|
+
}
|
|
5540
|
+
if (typeof value === "boolean") return { type: "checkbox", value, dateMode: "date" };
|
|
5541
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
5542
|
+
return { type: "number", value, dateMode: "date" };
|
|
5543
|
+
}
|
|
5544
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) {
|
|
5545
|
+
const coerced = normalizeDatePropertyValue(value.toISOString(), "datetime");
|
|
5546
|
+
return coerced ? { type: "date", value: coerced, dateMode: "datetime" } : null;
|
|
5547
|
+
}
|
|
5548
|
+
if (typeof value !== "string") return null;
|
|
5549
|
+
const text = value.trim();
|
|
5550
|
+
if (!text) return null;
|
|
5551
|
+
const dateMode = inferDateMode(text);
|
|
5552
|
+
if (dateMode) {
|
|
5553
|
+
const coerced = normalizeDatePropertyValue(text, dateMode);
|
|
5554
|
+
if (coerced) return { type: "date", value: coerced, dateMode };
|
|
5555
|
+
}
|
|
5556
|
+
return { type: "text", value: clipText(text), dateMode: "date" };
|
|
5557
|
+
}
|
|
5558
|
+
function readShortList(values) {
|
|
5559
|
+
if (values.length === 0 || values.length > SHORT_LIST_LIMIT) return null;
|
|
5560
|
+
const options = [];
|
|
5561
|
+
for (const value of values) {
|
|
5562
|
+
const option = scalarToOption(value);
|
|
5563
|
+
if (!option) return null;
|
|
5564
|
+
options.push(option);
|
|
5565
|
+
}
|
|
5566
|
+
return options;
|
|
5567
|
+
}
|
|
5568
|
+
function scalarToOption(value) {
|
|
5569
|
+
const text = scalarToText(value);
|
|
5570
|
+
if (!text || text.length > PROPERTY_OPTION_LABEL_MAX_LENGTH) return null;
|
|
5571
|
+
return text;
|
|
5572
|
+
}
|
|
5573
|
+
function scalarToText(value) {
|
|
5574
|
+
if (typeof value === "string") return value.trim();
|
|
5575
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
5576
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
5577
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) return value.toISOString();
|
|
5578
|
+
return "";
|
|
5579
|
+
}
|
|
5580
|
+
function describeNested(value, depth) {
|
|
5581
|
+
if (depth > NESTED_TEXT_DEPTH || value == null) return "";
|
|
5582
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
5583
|
+
return scalarToText(value);
|
|
5584
|
+
}
|
|
5585
|
+
if (value instanceof Date) return scalarToText(value);
|
|
5586
|
+
if (Array.isArray(value)) {
|
|
5587
|
+
return value.map((item) => describeNested(item, depth + 1)).filter(Boolean).join("\n");
|
|
5588
|
+
}
|
|
5589
|
+
if (!isRecord(value)) return "";
|
|
5590
|
+
return Object.entries(value).filter(([key]) => key !== "__proto__").map(([key, child]) => {
|
|
5591
|
+
const rendered = describeNested(child, depth + 1);
|
|
5592
|
+
if (!rendered) return "";
|
|
5593
|
+
if (!rendered.includes("\n")) return `${key}: ${rendered}`;
|
|
5594
|
+
const indented = rendered.split("\n").map((line) => ` ${line}`).join("\n");
|
|
5595
|
+
return `${key}:
|
|
5596
|
+
${indented}`;
|
|
5597
|
+
}).filter(Boolean).join("\n");
|
|
5598
|
+
}
|
|
5599
|
+
function coerceMarkdownPropertyValue(choice, value) {
|
|
5600
|
+
if (choice.type === "date") {
|
|
5601
|
+
return normalizeDatePropertyValue(value, choice.dateMode ?? "date");
|
|
5602
|
+
}
|
|
5603
|
+
if ((choice.type === "text" || choice.type === "url" || choice.type === "email" || choice.type === "phone") && Array.isArray(value)) {
|
|
5604
|
+
const joined = value.filter((item) => typeof item === "string").join("\u3001");
|
|
5605
|
+
return coercePropertyValue("text", joined);
|
|
5606
|
+
}
|
|
5607
|
+
if ((choice.type === "select" || choice.type === "status") && Array.isArray(value)) {
|
|
5608
|
+
const first = value.find((item) => typeof item === "string" && item.trim());
|
|
5609
|
+
return typeof first === "string" ? coercePropertyValue(choice.type, first) : null;
|
|
5610
|
+
}
|
|
5611
|
+
return coercePropertyValue(choice.type, value);
|
|
5612
|
+
}
|
|
5613
|
+
function lookupType(propertyTypes, key, lowered) {
|
|
5614
|
+
const declared = propertyTypes?.[key];
|
|
5615
|
+
if (lowered === "aliases") return declared === "text" ? "text" : "aliases";
|
|
5616
|
+
return declared;
|
|
5617
|
+
}
|
|
5618
|
+
function readTitle(value) {
|
|
5619
|
+
if (typeof value === "string") return value.trim();
|
|
5620
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
5621
|
+
return "";
|
|
5622
|
+
}
|
|
5623
|
+
function readCreatedAt(value) {
|
|
5624
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) return value.toISOString();
|
|
5625
|
+
if (typeof value !== "string") return null;
|
|
5626
|
+
return parseCreatedAt(value);
|
|
5627
|
+
}
|
|
5628
|
+
function dateInput(value) {
|
|
5629
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) return value.toISOString();
|
|
5630
|
+
return value;
|
|
5631
|
+
}
|
|
5632
|
+
function inferDateMode(value) {
|
|
5633
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) return "date";
|
|
5634
|
+
if (/^\d{4}-\d{2}-\d{2}[T\s]\d{2}:\d{2}/.test(value)) return "datetime";
|
|
5635
|
+
return null;
|
|
5636
|
+
}
|
|
5637
|
+
function parseCreatedAt(value) {
|
|
5638
|
+
const trimmed = value.trim();
|
|
5639
|
+
if (!trimmed) return null;
|
|
5640
|
+
const local = trimmed.match(
|
|
5641
|
+
/^(\d{4})[-/](\d{2})[-/](\d{2})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/
|
|
5642
|
+
);
|
|
5643
|
+
if (local) {
|
|
5644
|
+
const year = local[1];
|
|
5645
|
+
const month = local[2];
|
|
5646
|
+
const day = local[3];
|
|
5647
|
+
const hour = local[4] ?? "00";
|
|
5648
|
+
const minute = local[5] ?? "00";
|
|
5649
|
+
const second = local[6] ?? "00";
|
|
5650
|
+
const parsed2 = /* @__PURE__ */ new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}`);
|
|
5651
|
+
return Number.isNaN(parsed2.getTime()) ? null : parsed2.toISOString();
|
|
5652
|
+
}
|
|
5653
|
+
const parsed = new Date(trimmed);
|
|
5654
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
|
|
5655
|
+
}
|
|
5656
|
+
function flattenTagValues(value) {
|
|
5657
|
+
if (typeof value === "string") {
|
|
5658
|
+
return value.split(",").map((part) => part.trim()).filter(Boolean);
|
|
5659
|
+
}
|
|
5660
|
+
if (typeof value === "number" || typeof value === "boolean") return [String(value)];
|
|
5661
|
+
if (!Array.isArray(value)) return [];
|
|
5662
|
+
return value.flatMap((item) => flattenTagValues(item));
|
|
5663
|
+
}
|
|
5664
|
+
function normalizeSegment(value) {
|
|
5665
|
+
const normalized = value.normalize("NFKC").replace(/[\n\r\t]/g, " ").replace(/\s+/g, " ").trim();
|
|
5666
|
+
if (!normalized || normalized === "__proto__") return "";
|
|
5667
|
+
return normalized;
|
|
5668
|
+
}
|
|
5669
|
+
function clipText(value) {
|
|
5670
|
+
const trimmed = value.trim();
|
|
5671
|
+
if (!trimmed) return "";
|
|
5672
|
+
return trimmed.length > NOTE_PROPERTY_LIMITS.textLength ? trimmed.slice(0, NOTE_PROPERTY_LIMITS.textLength) : trimmed;
|
|
5673
|
+
}
|
|
5674
|
+
function isRecord(value) {
|
|
5675
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5676
|
+
}
|
|
5677
|
+
|
|
5337
5678
|
// src/commands/domain/options.ts
|
|
5338
5679
|
function parseIntegerOption(value) {
|
|
5339
5680
|
const normalized = value.trim();
|
|
@@ -5507,7 +5848,7 @@ function parseNoteTemplateContent(raw) {
|
|
|
5507
5848
|
});
|
|
5508
5849
|
}
|
|
5509
5850
|
assertCanonicalTemplateDocument(parsed);
|
|
5510
|
-
return projectNoteContent(parsed).document;
|
|
5851
|
+
return projectNoteContent(upgradeLegacyNoteNodes(parsed)).document;
|
|
5511
5852
|
}
|
|
5512
5853
|
function serializeNoteTemplateContent(document) {
|
|
5513
5854
|
assertCanonicalTemplateDocument(document);
|
|
@@ -5658,6 +5999,21 @@ async function previewDeleteNoteTemplate(db, input) {
|
|
|
5658
5999
|
}
|
|
5659
6000
|
|
|
5660
6001
|
// src/commands/notes/createFromTemplate.ts
|
|
6002
|
+
function seedWritesProperties(seed) {
|
|
6003
|
+
return Boolean(seed.values) || seed.frontmatterProperties.length > 0;
|
|
6004
|
+
}
|
|
6005
|
+
function applyFrontmatterToSeed(seed, frontmatter) {
|
|
6006
|
+
if (!frontmatter) return [];
|
|
6007
|
+
const parsed = readMarkdownFrontmatter(frontmatter);
|
|
6008
|
+
if (!parsed) {
|
|
6009
|
+
throw new DinoxError("The content front matter is not valid YAML", {
|
|
6010
|
+
code: "USAGE_ERROR",
|
|
6011
|
+
suggestion: "Fix the YAML between the leading `---` lines, or remove it."
|
|
6012
|
+
});
|
|
6013
|
+
}
|
|
6014
|
+
seed.frontmatterProperties = parsed.properties;
|
|
6015
|
+
return parsed.tags;
|
|
6016
|
+
}
|
|
5661
6017
|
async function resolveNoteCreateSeed(db, input) {
|
|
5662
6018
|
const template = input.templateId ? await getNoteTemplate(db, { userId: input.userId, id: input.templateId }) : null;
|
|
5663
6019
|
const projection = template?.document ? projectNoteContent(hydrateNoteTemplateDocument(template.document)) : null;
|
|
@@ -5672,19 +6028,50 @@ async function resolveNoteCreateSeed(db, input) {
|
|
|
5672
6028
|
values = raw;
|
|
5673
6029
|
if (Object.keys(values).length === 0) values = null;
|
|
5674
6030
|
}
|
|
5675
|
-
return {
|
|
6031
|
+
return {
|
|
6032
|
+
template,
|
|
6033
|
+
templateContent,
|
|
6034
|
+
propertiesJson: serializeRawNoteProperties(declared),
|
|
6035
|
+
values,
|
|
6036
|
+
frontmatterProperties: []
|
|
6037
|
+
};
|
|
6038
|
+
}
|
|
6039
|
+
async function frontmatterValues(tx, userId, properties, updatedAt) {
|
|
6040
|
+
if (properties.length === 0) return {};
|
|
6041
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
6042
|
+
for (const definition of await listProperties(tx, { userId, limit: 5e3 })) {
|
|
6043
|
+
if (!definition.key) continue;
|
|
6044
|
+
resolved.set(definition.key, {
|
|
6045
|
+
type: definition.type,
|
|
6046
|
+
...definition.config?.type === "date" ? { dateMode: definition.config.mode } : {}
|
|
6047
|
+
});
|
|
6048
|
+
}
|
|
6049
|
+
for (const plan of chooseMarkdownPropertyDefinitions([properties], resolved)) {
|
|
6050
|
+
await runDomainCommand(tx, "properties.ensure", {
|
|
6051
|
+
key: plan.key,
|
|
6052
|
+
name: plan.name,
|
|
6053
|
+
type: plan.type,
|
|
6054
|
+
...plan.type === "date" && plan.dateMode === "datetime" ? { config: { version: 1, type: "date", mode: "datetime" } } : {},
|
|
6055
|
+
source: "manual",
|
|
6056
|
+
userId,
|
|
6057
|
+
updatedAt
|
|
6058
|
+
});
|
|
6059
|
+
resolved.set(plan.key, { type: plan.type, ...plan.type === "date" ? { dateMode: plan.dateMode } : {} });
|
|
6060
|
+
}
|
|
6061
|
+
return buildMarkdownPropertyValues(properties, resolved, null);
|
|
5676
6062
|
}
|
|
5677
6063
|
async function applyValues(tx, noteId, userId, seed) {
|
|
5678
|
-
if (!seed
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
userId,
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
6064
|
+
if (!seedWritesProperties(seed)) return;
|
|
6065
|
+
const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6066
|
+
const patch = {
|
|
6067
|
+
...await frontmatterValues(tx, userId, seed.frontmatterProperties, updatedAt),
|
|
6068
|
+
...seed.values ?? {}
|
|
6069
|
+
};
|
|
6070
|
+
if (Object.keys(patch).length === 0) return;
|
|
6071
|
+
await runDomainCommand(tx, "notes.updateProperties", { noteId, userId, patch, updatedAt });
|
|
5685
6072
|
}
|
|
5686
6073
|
async function createNoteWithSeed(db, input) {
|
|
5687
|
-
if (!input.seed
|
|
6074
|
+
if (!seedWritesProperties(input.seed)) {
|
|
5688
6075
|
await input.insert(db);
|
|
5689
6076
|
return;
|
|
5690
6077
|
}
|
|
@@ -6127,8 +6514,13 @@ async function runNoteCreate({ command, options }) {
|
|
|
6127
6514
|
const useTemplateContent = createOptions.content === void 0 && seed.templateContent !== null;
|
|
6128
6515
|
const contentMd = useTemplateContent ? seed.templateContent.contentMd : createOptions.content !== void 0 ? await parseStringInput(String(createOptions.content)) : "";
|
|
6129
6516
|
const canonicalContentMd = useTemplateContent ? contentMd : await canonicalizeBidlinksInMarkdown(db, contentMd, identity.userId);
|
|
6130
|
-
const { contentJson, contentText } = useTemplateContent ? { contentJson: seed.templateContent.contentJson, contentText: seed.templateContent.contentText } : convertMarkdownToNoteContent(canonicalContentMd);
|
|
6131
|
-
const
|
|
6517
|
+
const { contentJson, contentText, frontmatter } = useTemplateContent ? { contentJson: seed.templateContent.contentJson, contentText: seed.templateContent.contentText, frontmatter: null } : convertMarkdownToNoteContent(canonicalContentMd, { frontmatter: "extract" });
|
|
6518
|
+
const frontmatterTags = applyFrontmatterToSeed(seed, frontmatter);
|
|
6519
|
+
const storedContentMd = frontmatter ? extractMarkdownFrontmatter(canonicalContentMd).body : canonicalContentMd;
|
|
6520
|
+
const tagsInput = [
|
|
6521
|
+
...typeof createOptions.tags === "string" ? await parseStringListInput(createOptions.tags, "--tags") : [],
|
|
6522
|
+
...frontmatterTags
|
|
6523
|
+
];
|
|
6132
6524
|
const boxNames = typeof createOptions.boxes === "string" ? await parseStringListInput(createOptions.boxes, "--boxes") : [];
|
|
6133
6525
|
const noteType = parseNoteType(createOptions.type);
|
|
6134
6526
|
const id = generateId();
|
|
@@ -6136,7 +6528,7 @@ async function runNoteCreate({ command, options }) {
|
|
|
6136
6528
|
id,
|
|
6137
6529
|
title: String(createOptions.title),
|
|
6138
6530
|
noteType,
|
|
6139
|
-
contentMd:
|
|
6531
|
+
contentMd: storedContentMd,
|
|
6140
6532
|
contentJson,
|
|
6141
6533
|
contentText,
|
|
6142
6534
|
tags: await validateTagsForCreate(tx, tagsInput, identity.userId),
|
|
@@ -6156,7 +6548,7 @@ async function runNoteCreate({ command, options }) {
|
|
|
6156
6548
|
tagsInput,
|
|
6157
6549
|
zettelBoxNames: boxNames
|
|
6158
6550
|
});
|
|
6159
|
-
if (seed.template || seed
|
|
6551
|
+
if (seed.template || seedWritesProperties(seed)) {
|
|
6160
6552
|
const properties = await previewNoteCreateProperties(db, { noteId: id, userId: identity.userId, seed, insert });
|
|
6161
6553
|
preview.inputs = { ...preview.inputs, ...seed.template ? { template: { id: seed.template.id, name: seed.template.name } } : {} };
|
|
6162
6554
|
preview.changes = { ...preview.changes, properties: properties.properties };
|
|
@@ -6170,9 +6562,9 @@ async function runNoteCreate({ command, options }) {
|
|
|
6170
6562
|
ok: true,
|
|
6171
6563
|
id,
|
|
6172
6564
|
...seed.template ? { template: { id: seed.template.id, name: seed.template.name } } : {},
|
|
6173
|
-
...seed.template || seed
|
|
6565
|
+
...seed.template || seedWritesProperties(seed) ? { properties: (await readNoteProperties(db, { userId: identity.userId, noteId: id })).properties } : {},
|
|
6174
6566
|
...await readNoteWriteReceipt(db, id, {
|
|
6175
|
-
changed: ["title", "type", "content_md", "content_json", "content_text", "tags", "boxes", ...seed.template || seed
|
|
6567
|
+
changed: ["title", "type", "content_md", "content_json", "content_text", "tags", "boxes", ...seed.template || seedWritesProperties(seed) ? ["properties"] : []],
|
|
6176
6568
|
upload,
|
|
6177
6569
|
stale: commandStale(runtime)
|
|
6178
6570
|
})
|
|
@@ -8768,545 +9160,6 @@ function registerPropertyCommands(program) {
|
|
|
8768
9160
|
registerCommandGroup(program, propertyCommandGroup);
|
|
8769
9161
|
}
|
|
8770
9162
|
|
|
8771
|
-
// src/commands/savedViews/model.ts
|
|
8772
|
-
function issuesOf(error) {
|
|
8773
|
-
return error.issues.map((issue2) => ({ path: issue2.path.map(String).join("."), message: issue2.message }));
|
|
8774
|
-
}
|
|
8775
|
-
function invalid(code, message, issues) {
|
|
8776
|
-
return new DinoxError(message, { code, details: issues === void 0 ? void 0 : { issues }, recoverable: false });
|
|
8777
|
-
}
|
|
8778
|
-
function parseJson(raw, label, code) {
|
|
8779
|
-
const value = raw?.trim() ?? "";
|
|
8780
|
-
if (!value) throw invalid(code, `${label} is required`);
|
|
8781
|
-
try {
|
|
8782
|
-
return JSON.parse(value);
|
|
8783
|
-
} catch {
|
|
8784
|
-
throw invalid(code, `${label} must be valid JSON`);
|
|
8785
|
-
}
|
|
8786
|
-
}
|
|
8787
|
-
function validateSavedViewFilter(value) {
|
|
8788
|
-
const parsed = savedViewFilterSchema.safeParse(value);
|
|
8789
|
-
if (!parsed.success) {
|
|
8790
|
-
throw invalid("SAVED_VIEW_INVALID_FILTER", "Saved view filter is invalid", issuesOf(parsed.error));
|
|
8791
|
-
}
|
|
8792
|
-
return parsed.data;
|
|
8793
|
-
}
|
|
8794
|
-
function validateSavedViewConfig(value) {
|
|
8795
|
-
const parsed = savedViewConfigSchema.safeParse(value);
|
|
8796
|
-
if (!parsed.success) {
|
|
8797
|
-
throw invalid("SAVED_VIEW_INVALID_CONFIG", "Saved view config is invalid", issuesOf(parsed.error));
|
|
8798
|
-
}
|
|
8799
|
-
return parsed.data;
|
|
8800
|
-
}
|
|
8801
|
-
function parseSavedViewFilter(raw) {
|
|
8802
|
-
return validateSavedViewFilter(parseJson(raw, "Saved view filter_json", "SAVED_VIEW_INVALID_FILTER"));
|
|
8803
|
-
}
|
|
8804
|
-
function parseSavedViewConfig(raw) {
|
|
8805
|
-
return validateSavedViewConfig(parseJson(raw, "Saved view config_json", "SAVED_VIEW_INVALID_CONFIG"));
|
|
8806
|
-
}
|
|
8807
|
-
function baseFields(row) {
|
|
8808
|
-
return {
|
|
8809
|
-
id: row.id.trim(),
|
|
8810
|
-
userId: row.user_id?.trim() ?? "",
|
|
8811
|
-
name: row.name?.trim() ?? "",
|
|
8812
|
-
emoji: row.emoji,
|
|
8813
|
-
templateId: row.template_id,
|
|
8814
|
-
groupId: row.group_id,
|
|
8815
|
-
sortRank: row.sort_rank,
|
|
8816
|
-
pinnedAt: row.pinned_at,
|
|
8817
|
-
createdAt: row.created_at,
|
|
8818
|
-
updatedAt: row.updated_at
|
|
8819
|
-
};
|
|
8820
|
-
}
|
|
8821
|
-
function mapSavedViewRow(row) {
|
|
8822
|
-
const base = baseFields(row);
|
|
8823
|
-
if (!base.id || !base.userId || !base.name || base.name.length > 120) {
|
|
8824
|
-
throw invalid("SAVED_VIEW_INVALID_ROW", "c_saved_view row is missing a valid id, user_id, or name");
|
|
8825
|
-
}
|
|
8826
|
-
const filter = parseSavedViewFilter(row.filter_json);
|
|
8827
|
-
const config = parseSavedViewConfig(row.config_json);
|
|
8828
|
-
return { ...base, layout: config.layout, filter, config };
|
|
8829
|
-
}
|
|
8830
|
-
function inspectSavedViewRow(row) {
|
|
8831
|
-
try {
|
|
8832
|
-
return { valid: true, view: mapSavedViewRow(row) };
|
|
8833
|
-
} catch (error) {
|
|
8834
|
-
const dinoxError = error instanceof DinoxError ? error : invalid("SAVED_VIEW_INVALID_ROW", String(error));
|
|
8835
|
-
const issues = dinoxError.details?.issues;
|
|
8836
|
-
return {
|
|
8837
|
-
valid: false,
|
|
8838
|
-
view: {
|
|
8839
|
-
...baseFields(row),
|
|
8840
|
-
viewType: row.view_type,
|
|
8841
|
-
filterJson: row.filter_json,
|
|
8842
|
-
configJson: row.config_json
|
|
8843
|
-
},
|
|
8844
|
-
error: {
|
|
8845
|
-
code: dinoxError.code,
|
|
8846
|
-
message: dinoxError.message,
|
|
8847
|
-
...issues === void 0 ? {} : { issues }
|
|
8848
|
-
}
|
|
8849
|
-
};
|
|
8850
|
-
}
|
|
8851
|
-
}
|
|
8852
|
-
|
|
8853
|
-
// src/commands/savedViews/fields.ts
|
|
8854
|
-
var SYSTEM_FIELD_META = {
|
|
8855
|
-
"sys.title": { name: "Title", propertyType: "text", type: "text" },
|
|
8856
|
-
"sys.created_at": { name: "Created at", propertyType: "date", type: "date" },
|
|
8857
|
-
"sys.updated_at": { name: "Updated at", propertyType: "date", type: "date" },
|
|
8858
|
-
"sys.tags": { name: "Tags", propertyType: "multi_select", type: "list" },
|
|
8859
|
-
"sys.zettel_boxes": { name: "Zettel boxes", propertyType: "relation", type: "list" },
|
|
8860
|
-
"sys.source": { name: "Source", propertyType: "text", type: "text" },
|
|
8861
|
-
"sys.type": { name: "Type", propertyType: "text", type: "text" },
|
|
8862
|
-
"sys.primary_resource_type": { name: "Primary resource type", propertyType: "select", type: "select" },
|
|
8863
|
-
"sys.starred_at": { name: "Starred at", propertyType: "date", type: "date" },
|
|
8864
|
-
"sys.images": { name: "Images", propertyType: "text", type: "text" },
|
|
8865
|
-
"sys.cover": { name: "Cover", propertyType: "text", type: "text" },
|
|
8866
|
-
"sys.audio": { name: "Audio", propertyType: "text", type: "text" },
|
|
8867
|
-
"sys.video": { name: "Video", propertyType: "text", type: "text" },
|
|
8868
|
-
"sys.file": { name: "File", propertyType: "text", type: "text" }
|
|
8869
|
-
};
|
|
8870
|
-
function valueTypeForPropertyType(type) {
|
|
8871
|
-
switch (type) {
|
|
8872
|
-
case "number":
|
|
8873
|
-
case "unique_id":
|
|
8874
|
-
return "number";
|
|
8875
|
-
case "date":
|
|
8876
|
-
return "date";
|
|
8877
|
-
case "select":
|
|
8878
|
-
case "status":
|
|
8879
|
-
return "select";
|
|
8880
|
-
case "checkbox":
|
|
8881
|
-
return "boolean";
|
|
8882
|
-
case "multi_select":
|
|
8883
|
-
case "relation":
|
|
8884
|
-
return "list";
|
|
8885
|
-
default:
|
|
8886
|
-
return "text";
|
|
8887
|
-
}
|
|
8888
|
-
}
|
|
8889
|
-
function catalogItem(field, name, propertyType, type) {
|
|
8890
|
-
const displayOnly = isSavedViewDisplayOnlyField(field);
|
|
8891
|
-
const filterOperators = getSavedViewFilterOperatorsForField(field, propertyType);
|
|
8892
|
-
return {
|
|
8893
|
-
field,
|
|
8894
|
-
name,
|
|
8895
|
-
type,
|
|
8896
|
-
propertyType,
|
|
8897
|
-
sortable: canSortSavedViewField(field, propertyType),
|
|
8898
|
-
filterable: filterOperators.length > 0,
|
|
8899
|
-
displayOnly,
|
|
8900
|
-
filterOperators,
|
|
8901
|
-
available: true
|
|
8902
|
-
};
|
|
8903
|
-
}
|
|
8904
|
-
function propertyItem(definition) {
|
|
8905
|
-
const field = `prop.${definition.key}`;
|
|
8906
|
-
const item = {
|
|
8907
|
-
...catalogItem(field, definition.name || definition.key, definition.type, valueTypeForPropertyType(definition.type)),
|
|
8908
|
-
propertyDefinitionId: definition.id,
|
|
8909
|
-
description: definition.description ?? null,
|
|
8910
|
-
icon: definition.icon ?? null,
|
|
8911
|
-
...definition.options ? { options: definition.options } : {},
|
|
8912
|
-
...definition.config ? { config: definition.config } : {}
|
|
8913
|
-
};
|
|
8914
|
-
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;
|
|
8915
|
-
return error ? { ...item, available: false, error } : item;
|
|
8916
|
-
}
|
|
8917
|
-
async function listPropertyDefinitions(db, userId, limit) {
|
|
8918
|
-
const rows = await fetchDomainReadModel(db, "properties.catalog", { userId, ...limit ? { limit } : {} });
|
|
8919
|
-
return rows.map(mapPropertyDef);
|
|
8920
|
-
}
|
|
8921
|
-
async function listSavedViewFields(db, userId) {
|
|
8922
|
-
const systemItems = SAVED_VIEW_SYSTEM_FIELDS.map((name) => {
|
|
8923
|
-
const field = `sys.${name}`;
|
|
8924
|
-
const meta = SYSTEM_FIELD_META[field] ?? { name, propertyType: "text", type: "text" };
|
|
8925
|
-
const item = catalogItem(field, meta.name, meta.propertyType, meta.type);
|
|
8926
|
-
return field === "sys.primary_resource_type" ? { ...item, values: SAVED_VIEW_PRIMARY_RESOURCE_TYPES } : item;
|
|
8927
|
-
});
|
|
8928
|
-
const definitions = await listPropertyDefinitions(db, userId);
|
|
8929
|
-
return [...systemItems, ...definitions.map(propertyItem)];
|
|
8930
|
-
}
|
|
8931
|
-
|
|
8932
|
-
// src/commands/savedViews/repo.ts
|
|
8933
|
-
var ACTIVE_VIEW_TYPE_SQL = `view_type IN (${SAVED_VIEW_LAYOUTS.map((layout) => `'${layout}'`).join(", ")})`;
|
|
8934
|
-
var SAVED_VIEW_COLUMNS = `
|
|
8935
|
-
id, user_id, name, emoji, filter_json, view_type, config_json, template_id, group_id,
|
|
8936
|
-
sort_rank, pinned_at, created_at, updated_at, is_del
|
|
8937
|
-
`;
|
|
8938
|
-
function nowIso2() {
|
|
8939
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
8940
|
-
}
|
|
8941
|
-
function notFound2(id) {
|
|
8942
|
-
return new DinoxError(`Saved view not found: ${id}`, { code: "SAVED_VIEW_NOT_FOUND", details: { viewId: id } });
|
|
8943
|
-
}
|
|
8944
|
-
function catalogItem2(row) {
|
|
8945
|
-
const inspection = inspectSavedViewRow(row);
|
|
8946
|
-
const view = inspection.view;
|
|
8947
|
-
return {
|
|
8948
|
-
id: view.id,
|
|
8949
|
-
name: view.name,
|
|
8950
|
-
emoji: view.emoji,
|
|
8951
|
-
layout: inspection.valid ? inspection.view.layout : row.view_type,
|
|
8952
|
-
templateId: view.templateId,
|
|
8953
|
-
groupId: view.groupId,
|
|
8954
|
-
sortRank: view.sortRank,
|
|
8955
|
-
pinnedAt: view.pinnedAt,
|
|
8956
|
-
createdAt: view.createdAt,
|
|
8957
|
-
updatedAt: view.updatedAt,
|
|
8958
|
-
valid: inspection.valid,
|
|
8959
|
-
...inspection.valid ? {} : { error: { code: inspection.error.code, message: inspection.error.message } }
|
|
8960
|
-
};
|
|
8961
|
-
}
|
|
8962
|
-
async function listSavedViews(db, input) {
|
|
8963
|
-
const rows = await fetchDomainReadModel(db, "savedViews.catalog", {
|
|
8964
|
-
userId: input.userId,
|
|
8965
|
-
...input.limit === void 0 ? {} : { limit: input.limit }
|
|
8966
|
-
});
|
|
8967
|
-
return rows.filter((row) => row.id?.trim()).map(catalogItem2);
|
|
8968
|
-
}
|
|
8969
|
-
async function findSavedViewRow(db, input) {
|
|
8970
|
-
return await db.getOptional(
|
|
8971
|
-
`
|
|
8972
|
-
SELECT ${SAVED_VIEW_COLUMNS}
|
|
8973
|
-
FROM c_saved_view
|
|
8974
|
-
WHERE id = ?
|
|
8975
|
-
AND user_id = ?
|
|
8976
|
-
AND ${ACTIVE_VIEW_TYPE_SQL}
|
|
8977
|
-
AND (is_del IS NULL OR is_del = 0)
|
|
8978
|
-
LIMIT 1
|
|
8979
|
-
`,
|
|
8980
|
-
[input.id.trim(), input.userId]
|
|
8981
|
-
) ?? null;
|
|
8982
|
-
}
|
|
8983
|
-
async function getSavedView(db, input) {
|
|
8984
|
-
const row = await findSavedViewRow(db, input);
|
|
8985
|
-
if (!row) throw notFound2(input.id);
|
|
8986
|
-
return inspectSavedViewRow(row);
|
|
8987
|
-
}
|
|
8988
|
-
function parseJsonValue(raw) {
|
|
8989
|
-
if (!raw?.trim()) return void 0;
|
|
8990
|
-
try {
|
|
8991
|
-
return JSON.parse(raw);
|
|
8992
|
-
} catch {
|
|
8993
|
-
return void 0;
|
|
8994
|
-
}
|
|
8995
|
-
}
|
|
8996
|
-
function parseObject(raw) {
|
|
8997
|
-
const value = parseJsonValue(raw);
|
|
8998
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
8999
|
-
}
|
|
9000
|
-
function parseStringArray(raw) {
|
|
9001
|
-
const value = parseJsonValue(raw);
|
|
9002
|
-
return Array.isArray(value) ? value.flatMap((item) => typeof item === "string" && item.trim() ? [item.trim()] : []) : [];
|
|
9003
|
-
}
|
|
9004
|
-
function parseImages(raw) {
|
|
9005
|
-
const value = parseJsonValue(raw);
|
|
9006
|
-
return Array.isArray(value) ? value : [];
|
|
9007
|
-
}
|
|
9008
|
-
function resolveSystemValue(row, field) {
|
|
9009
|
-
switch (field) {
|
|
9010
|
-
case "sys.title":
|
|
9011
|
-
return row.title;
|
|
9012
|
-
case "sys.created_at":
|
|
9013
|
-
return row.created_at;
|
|
9014
|
-
case "sys.updated_at":
|
|
9015
|
-
return row.updated_at;
|
|
9016
|
-
case "sys.starred_at":
|
|
9017
|
-
return row.starred_at;
|
|
9018
|
-
case "sys.source":
|
|
9019
|
-
return row.source;
|
|
9020
|
-
case "sys.type":
|
|
9021
|
-
return row.type;
|
|
9022
|
-
case "sys.tags":
|
|
9023
|
-
return parseStringArray(row.tags);
|
|
9024
|
-
case "sys.zettel_boxes":
|
|
9025
|
-
return parseStringArray(row.zettel_boxes);
|
|
9026
|
-
case "sys.images":
|
|
9027
|
-
return parseImages(row.images);
|
|
9028
|
-
case "sys.cover":
|
|
9029
|
-
return parseImages(row.images)[0] ?? null;
|
|
9030
|
-
case "sys.primary_resource_type":
|
|
9031
|
-
return row.primary_resource_type ?? null;
|
|
9032
|
-
case "sys.audio":
|
|
9033
|
-
case "sys.video":
|
|
9034
|
-
case "sys.file":
|
|
9035
|
-
return row.primary_resource_type === field.slice("sys.".length);
|
|
9036
|
-
default:
|
|
9037
|
-
return void 0;
|
|
9038
|
-
}
|
|
9039
|
-
}
|
|
9040
|
-
function describeOption(value, options) {
|
|
9041
|
-
const option = options.find((candidate) => candidate.id === value);
|
|
9042
|
-
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 };
|
|
9043
|
-
}
|
|
9044
|
-
function displayValue(value, semantic) {
|
|
9045
|
-
const options = semantic?.options;
|
|
9046
|
-
if (!options) return value;
|
|
9047
|
-
if ((semantic.propertyType === "select" || semantic.propertyType === "status") && typeof value === "string") {
|
|
9048
|
-
return describeOption(value, options);
|
|
9049
|
-
}
|
|
9050
|
-
if (semantic.propertyType === "multi_select" && Array.isArray(value)) {
|
|
9051
|
-
return value.map((item) => typeof item === "string" ? describeOption(item, options) : item);
|
|
9052
|
-
}
|
|
9053
|
-
return value;
|
|
9054
|
-
}
|
|
9055
|
-
function evaluateComputedColumn(properties, column) {
|
|
9056
|
-
const read = (field) => {
|
|
9057
|
-
if (!field.startsWith("prop.")) return null;
|
|
9058
|
-
const raw = properties[field.slice("prop.".length)];
|
|
9059
|
-
return typeof raw === "number" && Number.isFinite(raw) ? raw : null;
|
|
9060
|
-
};
|
|
9061
|
-
const left = read(column.expr.left);
|
|
9062
|
-
const right = read(column.expr.right);
|
|
9063
|
-
if (left === null || right === null) return null;
|
|
9064
|
-
switch (column.expr.op) {
|
|
9065
|
-
case "*":
|
|
9066
|
-
return left * right;
|
|
9067
|
-
case "/":
|
|
9068
|
-
return right === 0 ? null : left / right;
|
|
9069
|
-
case "+":
|
|
9070
|
-
return left + right;
|
|
9071
|
-
case "-":
|
|
9072
|
-
return left - right;
|
|
9073
|
-
}
|
|
9074
|
-
}
|
|
9075
|
-
function projectRow(row, fields, computedColumns, semantics) {
|
|
9076
|
-
const properties = parseObject(row.properties);
|
|
9077
|
-
const values = {};
|
|
9078
|
-
const displayValues = {};
|
|
9079
|
-
for (const field of fields) {
|
|
9080
|
-
const value = field.startsWith("prop.") ? Object.hasOwn(properties, field.slice("prop.".length)) ? properties[field.slice("prop.".length)] : void 0 : resolveSystemValue(row, field);
|
|
9081
|
-
if (value === void 0) continue;
|
|
9082
|
-
values[field] = value;
|
|
9083
|
-
if (field === "sys.zettel_boxes") {
|
|
9084
|
-
const details = parseSavedViewZettelBoxDetails(row.zettel_box_details);
|
|
9085
|
-
if (details.length > 0) displayValues[field] = details;
|
|
9086
|
-
continue;
|
|
9087
|
-
}
|
|
9088
|
-
const display = displayValue(value, semantics.get(field));
|
|
9089
|
-
if (display !== value) displayValues[field] = display;
|
|
9090
|
-
}
|
|
9091
|
-
for (const column of computedColumns) {
|
|
9092
|
-
values[`calc.${column.id}`] = evaluateComputedColumn(properties, column);
|
|
9093
|
-
}
|
|
9094
|
-
return {
|
|
9095
|
-
id: row.id,
|
|
9096
|
-
title: row.title,
|
|
9097
|
-
values,
|
|
9098
|
-
...Object.keys(displayValues).length > 0 ? { displayValues } : {}
|
|
9099
|
-
};
|
|
9100
|
-
}
|
|
9101
|
-
function projectedColumns(config, semantics) {
|
|
9102
|
-
return [
|
|
9103
|
-
...config.columns.map((column) => {
|
|
9104
|
-
const semantic = semantics.get(column.field);
|
|
9105
|
-
return {
|
|
9106
|
-
field: column.field,
|
|
9107
|
-
type: semantic?.type ?? "text",
|
|
9108
|
-
propertyType: semantic?.propertyType ?? null,
|
|
9109
|
-
dateMode: semantic?.dateMode ?? null,
|
|
9110
|
-
...semantic?.displayOnly ? { displayOnly: true } : {},
|
|
9111
|
-
...semantic?.options ? { options: semantic.options } : {}
|
|
9112
|
-
};
|
|
9113
|
-
}),
|
|
9114
|
-
...(config.computedColumns ?? []).map((column) => ({
|
|
9115
|
-
field: `calc.${column.id}`,
|
|
9116
|
-
type: "number",
|
|
9117
|
-
propertyType: null,
|
|
9118
|
-
dateMode: null,
|
|
9119
|
-
computed: column
|
|
9120
|
-
}))
|
|
9121
|
-
];
|
|
9122
|
-
}
|
|
9123
|
-
async function resolveScope(db, input) {
|
|
9124
|
-
try {
|
|
9125
|
-
return await resolveSavedViewQueryScope(db, input);
|
|
9126
|
-
} catch (error) {
|
|
9127
|
-
const mapped = toDinoxError(error, "savedViews.query");
|
|
9128
|
-
if (mapped.code === "SAVED_VIEW_NOT_FOUND") throw notFound2(input.viewId);
|
|
9129
|
-
throw mapped;
|
|
9130
|
-
}
|
|
9131
|
-
}
|
|
9132
|
-
async function querySavedView(db, input) {
|
|
9133
|
-
const limit = Math.min(500, Math.max(1, Math.trunc(input.limit ?? 100)));
|
|
9134
|
-
const offset = Math.max(0, Math.trunc(input.offset ?? 0));
|
|
9135
|
-
return withReadTransaction(db, async (tx) => {
|
|
9136
|
-
const scope = await resolveScope(tx, input);
|
|
9137
|
-
const pageInput = { viewId: input.viewId, userId: input.userId, timeZone: input.timeZone, limit, offset };
|
|
9138
|
-
const rawRows = await fetchSavedViewScopedPage(tx, pageInput, scope);
|
|
9139
|
-
const totalCount = await countSavedViewScopedRows(tx, pageInput, scope);
|
|
9140
|
-
const view = await getSavedView(tx, { id: input.viewId, userId: input.userId });
|
|
9141
|
-
const fields = scope.config.columns.map((column) => column.field);
|
|
9142
|
-
const rows = rawRows.map((row) => projectRow(row, fields, scope.config.computedColumns ?? [], scope.semantics));
|
|
9143
|
-
const nextOffset = offset + rows.length;
|
|
9144
|
-
const hasMore = nextOffset < totalCount;
|
|
9145
|
-
return {
|
|
9146
|
-
view: view.view,
|
|
9147
|
-
columns: projectedColumns(scope.config, scope.semantics),
|
|
9148
|
-
totalCount,
|
|
9149
|
-
offset,
|
|
9150
|
-
limit,
|
|
9151
|
-
nextOffset: hasMore ? nextOffset : null,
|
|
9152
|
-
hasMore,
|
|
9153
|
-
rows
|
|
9154
|
-
};
|
|
9155
|
-
});
|
|
9156
|
-
}
|
|
9157
|
-
async function countSavedViewRows(db, input) {
|
|
9158
|
-
return withReadTransaction(db, async (tx) => {
|
|
9159
|
-
const scope = await resolveScope(tx, input);
|
|
9160
|
-
return countSavedViewScopedRows(tx, input, scope);
|
|
9161
|
-
});
|
|
9162
|
-
}
|
|
9163
|
-
async function getSavedViewAnalytics(db, input) {
|
|
9164
|
-
const view = await getSavedView(db, { id: input.viewId, userId: input.userId });
|
|
9165
|
-
const [analytics] = await fetchDomainReadModel(db, "savedViews.analytics", {
|
|
9166
|
-
viewId: input.viewId,
|
|
9167
|
-
userId: input.userId,
|
|
9168
|
-
...input.timeZone ? { timeZone: input.timeZone } : {}
|
|
9169
|
-
});
|
|
9170
|
-
const config = view.valid ? view.view.config : void 0;
|
|
9171
|
-
return {
|
|
9172
|
-
stats: analytics?.stats ?? [],
|
|
9173
|
-
charts: analytics?.charts ?? [],
|
|
9174
|
-
summary: analytics?.summary ?? [],
|
|
9175
|
-
config: {
|
|
9176
|
-
...config?.stats ? { stats: config.stats } : {},
|
|
9177
|
-
...config?.charts ? { charts: config.charts } : {},
|
|
9178
|
-
...config?.summary ? { summary: config.summary } : {},
|
|
9179
|
-
...config?.computedColumns ? { computedColumns: config.computedColumns } : {}
|
|
9180
|
-
}
|
|
9181
|
-
};
|
|
9182
|
-
}
|
|
9183
|
-
async function propertySemantics(db, userId) {
|
|
9184
|
-
const definitions = await listPropertyDefinitions(db, userId);
|
|
9185
|
-
return new Map(definitions.map((definition) => [
|
|
9186
|
-
`prop.${definition.key}`,
|
|
9187
|
-
{
|
|
9188
|
-
type: valueTypeForPropertyType(definition.type),
|
|
9189
|
-
propertyType: definition.type,
|
|
9190
|
-
...definition.options ? { options: definition.options } : {}
|
|
9191
|
-
}
|
|
9192
|
-
]));
|
|
9193
|
-
}
|
|
9194
|
-
async function getNoteDetailSections(db, input) {
|
|
9195
|
-
return withReadTransaction(db, async (tx) => {
|
|
9196
|
-
const sections = await fetchDomainReadModel(tx, "savedViews.noteDetail", {
|
|
9197
|
-
noteId: input.noteId,
|
|
9198
|
-
userId: input.userId,
|
|
9199
|
-
...input.timeZone ? { timeZone: input.timeZone } : {},
|
|
9200
|
-
...input.limit === void 0 ? {} : { limit: input.limit }
|
|
9201
|
-
});
|
|
9202
|
-
if (sections.length === 0) return [];
|
|
9203
|
-
const semantics = await propertySemantics(tx, input.userId);
|
|
9204
|
-
const result = [];
|
|
9205
|
-
for (const section of sections) {
|
|
9206
|
-
const view = await getSavedView(tx, { id: section.view_id, userId: input.userId });
|
|
9207
|
-
const config = view.valid ? view.view.config : createDefaultSavedViewConfig();
|
|
9208
|
-
const fields = config.columns.map((column) => column.field);
|
|
9209
|
-
result.push({
|
|
9210
|
-
viewId: section.view_id,
|
|
9211
|
-
name: section.name,
|
|
9212
|
-
emoji: section.emoji,
|
|
9213
|
-
totalCount: section.total_count,
|
|
9214
|
-
columns: projectedColumns(config, semantics),
|
|
9215
|
-
rows: section.rows.map((row) => projectRow(row, fields, config.computedColumns ?? [], semantics))
|
|
9216
|
-
});
|
|
9217
|
-
}
|
|
9218
|
-
return result;
|
|
9219
|
-
});
|
|
9220
|
-
}
|
|
9221
|
-
function withLayout(config, layout) {
|
|
9222
|
-
return layout === void 0 || layout === config.layout ? config : { ...config, layout };
|
|
9223
|
-
}
|
|
9224
|
-
async function resolveUpdateConfig(db, input) {
|
|
9225
|
-
if (input.config !== void 0) return withLayout(input.config, input.layout);
|
|
9226
|
-
if (input.layout === void 0) return void 0;
|
|
9227
|
-
const row = await findSavedViewRow(db, input);
|
|
9228
|
-
if (!row) throw notFound2(input.id);
|
|
9229
|
-
return withLayout(parseSavedViewConfig(row.config_json), input.layout);
|
|
9230
|
-
}
|
|
9231
|
-
function definedEntries(value) {
|
|
9232
|
-
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
|
|
9233
|
-
}
|
|
9234
|
-
async function runCreate2(db, input) {
|
|
9235
|
-
const config = withLayout(input.config ?? createDefaultSavedViewConfig(), input.layout);
|
|
9236
|
-
const { result: id } = await runDomainCommand(db, "savedViews.create", definedEntries({
|
|
9237
|
-
userId: input.userId,
|
|
9238
|
-
name: input.name,
|
|
9239
|
-
emoji: input.emoji,
|
|
9240
|
-
filter: input.filter ?? createDefaultSavedViewFilter(),
|
|
9241
|
-
config,
|
|
9242
|
-
templateId: input.templateId,
|
|
9243
|
-
groupId: input.groupId,
|
|
9244
|
-
sortRank: input.sortRank,
|
|
9245
|
-
pinnedAt: input.pinnedAt,
|
|
9246
|
-
updatedAt: nowIso2()
|
|
9247
|
-
}));
|
|
9248
|
-
return getSavedView(db, { id, userId: input.userId });
|
|
9249
|
-
}
|
|
9250
|
-
async function runUpdate2(db, input) {
|
|
9251
|
-
const config = await resolveUpdateConfig(db, input);
|
|
9252
|
-
const { result: changed } = await runDomainCommand(db, "savedViews.update", definedEntries({
|
|
9253
|
-
id: input.id,
|
|
9254
|
-
userId: input.userId,
|
|
9255
|
-
name: input.name,
|
|
9256
|
-
emoji: input.emoji,
|
|
9257
|
-
filter: input.filter,
|
|
9258
|
-
config,
|
|
9259
|
-
templateId: input.templateId,
|
|
9260
|
-
groupId: input.groupId,
|
|
9261
|
-
sortRank: input.sortRank,
|
|
9262
|
-
pinnedAt: input.pinnedAt,
|
|
9263
|
-
updatedAt: nowIso2()
|
|
9264
|
-
}));
|
|
9265
|
-
if (!changed) throw notFound2(input.id);
|
|
9266
|
-
return getSavedView(db, input);
|
|
9267
|
-
}
|
|
9268
|
-
async function runDelete2(db, input) {
|
|
9269
|
-
const before = await getSavedView(db, input);
|
|
9270
|
-
const { result: changed } = await runDomainCommand(db, "savedViews.softDelete", {
|
|
9271
|
-
id: input.id,
|
|
9272
|
-
userId: input.userId,
|
|
9273
|
-
updatedAt: nowIso2()
|
|
9274
|
-
});
|
|
9275
|
-
if (!changed) throw notFound2(input.id);
|
|
9276
|
-
return before;
|
|
9277
|
-
}
|
|
9278
|
-
async function createSavedView(db, input) {
|
|
9279
|
-
return runCreate2(db, input);
|
|
9280
|
-
}
|
|
9281
|
-
async function updateSavedView(db, input) {
|
|
9282
|
-
return runUpdate2(db, input);
|
|
9283
|
-
}
|
|
9284
|
-
async function deleteSavedView(db, input) {
|
|
9285
|
-
return runDelete2(db, input);
|
|
9286
|
-
}
|
|
9287
|
-
async function previewCreateSavedView(db, input) {
|
|
9288
|
-
return previewInRolledBackTransaction(db, (tx) => runCreate2(tx, input), async (_tx, after) => ({
|
|
9289
|
-
action: "create",
|
|
9290
|
-
before: null,
|
|
9291
|
-
after
|
|
9292
|
-
}));
|
|
9293
|
-
}
|
|
9294
|
-
async function previewUpdateSavedView(db, input) {
|
|
9295
|
-
const before = await getSavedView(db, input);
|
|
9296
|
-
return previewInRolledBackTransaction(db, (tx) => runUpdate2(tx, input), async (_tx, after) => ({
|
|
9297
|
-
action: "update",
|
|
9298
|
-
before,
|
|
9299
|
-
after
|
|
9300
|
-
}));
|
|
9301
|
-
}
|
|
9302
|
-
async function previewDeleteSavedView(db, input) {
|
|
9303
|
-
return previewInRolledBackTransaction(db, (tx) => runDelete2(tx, input), async (_tx, before) => ({
|
|
9304
|
-
action: "delete",
|
|
9305
|
-
before,
|
|
9306
|
-
after: null
|
|
9307
|
-
}));
|
|
9308
|
-
}
|
|
9309
|
-
|
|
9310
9163
|
// src/commands/savedViews/index.ts
|
|
9311
9164
|
var VIEW_GLOBAL_OPTIONS = [
|
|
9312
9165
|
...FORMAT_OPTIONS,
|
|
@@ -9802,7 +9655,7 @@ import { spawn as spawn2 } from "node:child_process";
|
|
|
9802
9655
|
import { readFile } from "node:fs/promises";
|
|
9803
9656
|
import { homedir as homedir2 } from "node:os";
|
|
9804
9657
|
import path5 from "node:path";
|
|
9805
|
-
import { parse as
|
|
9658
|
+
import { parse as parseYaml2 } from "yaml";
|
|
9806
9659
|
|
|
9807
9660
|
// src/skills/registry.ts
|
|
9808
9661
|
function commands(file, key) {
|
|
@@ -9937,7 +9790,7 @@ async function removeRetiredSkillLeftover(leftover) {
|
|
|
9937
9790
|
|
|
9938
9791
|
// src/commands/skills/index.ts
|
|
9939
9792
|
var MAX_CAPTURED_INSTALLER_OUTPUT_BYTES = 64 * 1024;
|
|
9940
|
-
function
|
|
9793
|
+
function isRecord2(value) {
|
|
9941
9794
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
9942
9795
|
}
|
|
9943
9796
|
function defaultLockFilePath() {
|
|
@@ -10004,7 +9857,7 @@ async function readSkillsLock(lockFilePath, readLockFile) {
|
|
|
10004
9857
|
} catch (error) {
|
|
10005
9858
|
throw invalidLockError(lockFilePath, "file is not valid JSON", error);
|
|
10006
9859
|
}
|
|
10007
|
-
if (!
|
|
9860
|
+
if (!isRecord2(parsed) || !isRecord2(parsed.skills)) {
|
|
10008
9861
|
throw invalidLockError(lockFilePath, "expected an object with a skills map");
|
|
10009
9862
|
}
|
|
10010
9863
|
return {
|
|
@@ -10064,7 +9917,7 @@ function scanRetiredSkills(lockFilePath, lock) {
|
|
|
10064
9917
|
};
|
|
10065
9918
|
}
|
|
10066
9919
|
const rawEntry = entries[skill.name];
|
|
10067
|
-
const entry =
|
|
9920
|
+
const entry = isRecord2(rawEntry) ? rawEntry : {};
|
|
10068
9921
|
const observed = {
|
|
10069
9922
|
source: typeof entry.source === "string" ? entry.source : null,
|
|
10070
9923
|
skillFolderHash: typeof entry.skillFolderHash === "string" ? entry.skillFolderHash : null
|
|
@@ -10104,12 +9957,12 @@ function readSkillVersion(skillMarkdown) {
|
|
|
10104
9957
|
if (!frontmatter) return null;
|
|
10105
9958
|
let parsed;
|
|
10106
9959
|
try {
|
|
10107
|
-
parsed =
|
|
9960
|
+
parsed = parseYaml2(frontmatter);
|
|
10108
9961
|
} catch {
|
|
10109
9962
|
return null;
|
|
10110
9963
|
}
|
|
10111
|
-
if (!
|
|
10112
|
-
const metadataVersion =
|
|
9964
|
+
if (!isRecord2(parsed)) return null;
|
|
9965
|
+
const metadataVersion = isRecord2(parsed.metadata) ? parsed.metadata.version : void 0;
|
|
10113
9966
|
const version = metadataVersion ?? parsed.version;
|
|
10114
9967
|
return typeof version === "string" && version.trim() ? version.trim() : null;
|
|
10115
9968
|
}
|
|
@@ -10123,7 +9976,7 @@ async function scanCurrentSkills(lockFilePath = defaultLockFilePath(), readLockF
|
|
|
10123
9976
|
skills.push({ name, status: "missing", source: null, installedVersion: null });
|
|
10124
9977
|
continue;
|
|
10125
9978
|
}
|
|
10126
|
-
const source =
|
|
9979
|
+
const source = isRecord2(rawEntry) && typeof rawEntry.source === "string" ? rawEntry.source : null;
|
|
10127
9980
|
if (source !== SKILLS_REPO_SLUG) {
|
|
10128
9981
|
skills.push({ name, status: "foreign", source, installedVersion: null });
|
|
10129
9982
|
continue;
|
|
@@ -11487,7 +11340,7 @@ var clipCommandGroup = {
|
|
|
11487
11340
|
examples: ["dino clip inspect https://example.com/article --format json"]
|
|
11488
11341
|
},
|
|
11489
11342
|
action: async (context) => {
|
|
11490
|
-
const { runClipInspect } = await import("./run-
|
|
11343
|
+
const { runClipInspect } = await import("./run-WNHMZLSJ.js");
|
|
11491
11344
|
await runClipInspect(context);
|
|
11492
11345
|
}
|
|
11493
11346
|
},
|
|
@@ -11545,7 +11398,7 @@ var clipCommandGroup = {
|
|
|
11545
11398
|
]
|
|
11546
11399
|
},
|
|
11547
11400
|
action: async (context) => {
|
|
11548
|
-
const { runClipAdd } = await import("./run-
|
|
11401
|
+
const { runClipAdd } = await import("./run-WNHMZLSJ.js");
|
|
11549
11402
|
await runClipAdd(context);
|
|
11550
11403
|
}
|
|
11551
11404
|
},
|
|
@@ -11566,7 +11419,7 @@ var clipCommandGroup = {
|
|
|
11566
11419
|
examples: ["dino clip process 01a1e3bb-3827-790d-b850-52b187c12b53 --format json"]
|
|
11567
11420
|
},
|
|
11568
11421
|
action: async (context) => {
|
|
11569
|
-
const { runClipProcess } = await import("./run-
|
|
11422
|
+
const { runClipProcess } = await import("./run-WNHMZLSJ.js");
|
|
11570
11423
|
await runClipProcess(context);
|
|
11571
11424
|
}
|
|
11572
11425
|
},
|
|
@@ -11590,7 +11443,7 @@ var clipCommandGroup = {
|
|
|
11590
11443
|
examples: ["dino clip setup", "dino clip setup --progress --format json", "dino clip setup --check --format json"]
|
|
11591
11444
|
},
|
|
11592
11445
|
action: async (context) => {
|
|
11593
|
-
const { runClipSetup } = await import("./setup-
|
|
11446
|
+
const { runClipSetup } = await import("./setup-UYCLFOZH.js");
|
|
11594
11447
|
await runClipSetup(context);
|
|
11595
11448
|
}
|
|
11596
11449
|
},
|
|
@@ -11610,7 +11463,7 @@ var clipCommandGroup = {
|
|
|
11610
11463
|
examples: ["dino clip cookies-list --format json"]
|
|
11611
11464
|
},
|
|
11612
11465
|
action: async () => {
|
|
11613
|
-
const { runClipCookiesList } = await import("./cookies-
|
|
11466
|
+
const { runClipCookiesList } = await import("./cookies-UUQZXH4R.js");
|
|
11614
11467
|
await runClipCookiesList();
|
|
11615
11468
|
}
|
|
11616
11469
|
},
|
|
@@ -11637,7 +11490,7 @@ var clipCommandGroup = {
|
|
|
11637
11490
|
]
|
|
11638
11491
|
},
|
|
11639
11492
|
action: async (context) => {
|
|
11640
|
-
const { runClipCookiesImport } = await import("./cookies-
|
|
11493
|
+
const { runClipCookiesImport } = await import("./cookies-UUQZXH4R.js");
|
|
11641
11494
|
await runClipCookiesImport(context);
|
|
11642
11495
|
}
|
|
11643
11496
|
},
|
|
@@ -11661,7 +11514,7 @@ var clipCommandGroup = {
|
|
|
11661
11514
|
examples: ["pbpaste | dino clip cookies-set example.com - --format json"]
|
|
11662
11515
|
},
|
|
11663
11516
|
action: async (context) => {
|
|
11664
|
-
const { runClipCookiesSet } = await import("./cookies-
|
|
11517
|
+
const { runClipCookiesSet } = await import("./cookies-UUQZXH4R.js");
|
|
11665
11518
|
await runClipCookiesSet(context);
|
|
11666
11519
|
}
|
|
11667
11520
|
},
|
|
@@ -11683,7 +11536,7 @@ var clipCommandGroup = {
|
|
|
11683
11536
|
examples: ["dino clip cookies-remove example.com --format json", "dino clip cookies-remove --all --format json"]
|
|
11684
11537
|
},
|
|
11685
11538
|
action: async (context) => {
|
|
11686
|
-
const { runClipCookiesRemove } = await import("./cookies-
|
|
11539
|
+
const { runClipCookiesRemove } = await import("./cookies-UUQZXH4R.js");
|
|
11687
11540
|
await runClipCookiesRemove(context);
|
|
11688
11541
|
}
|
|
11689
11542
|
}
|
|
@@ -11725,7 +11578,7 @@ function pathKey(value) {
|
|
|
11725
11578
|
function getPathId(path6, lookup) {
|
|
11726
11579
|
return lookup?.idByPath.get(pathKey(path6)) ?? canonicalizeTagPath(path6);
|
|
11727
11580
|
}
|
|
11728
|
-
function
|
|
11581
|
+
function parseJson(raw) {
|
|
11729
11582
|
if (!raw) {
|
|
11730
11583
|
return null;
|
|
11731
11584
|
}
|
|
@@ -11749,7 +11602,7 @@ function extractHashtagPath(attrs, lookup) {
|
|
|
11749
11602
|
return mapped ? canonicalizeTagPath(mapped) : canonicalizeTagPath(id);
|
|
11750
11603
|
}
|
|
11751
11604
|
function rewriteHashtagsInJson(raw, oldPrefix, newPrefix, preserveSuffix, lookup) {
|
|
11752
|
-
const parsed =
|
|
11605
|
+
const parsed = parseJson(raw);
|
|
11753
11606
|
if (!parsed) {
|
|
11754
11607
|
return { changed: false, contentJson: raw, plainText: null };
|
|
11755
11608
|
}
|
|
@@ -12835,8 +12688,8 @@ async function readPropertyKeys(options) {
|
|
|
12835
12688
|
...typeof options.propertyKeys === "string" ? parseListInput(await readStringOrFile(options.propertyKeys), "--property-keys") : []
|
|
12836
12689
|
];
|
|
12837
12690
|
if (options.propertyKey === void 0 && options.propertyKeys === void 0) return void 0;
|
|
12838
|
-
const
|
|
12839
|
-
if (
|
|
12691
|
+
const invalid = keys.find((key) => !isPropertyKeyValid(key));
|
|
12692
|
+
if (invalid !== void 0) throw new DinoxError(`Invalid property key: ${invalid}`, { code: "USAGE_ERROR" });
|
|
12840
12693
|
return [...new Set(keys)];
|
|
12841
12694
|
}
|
|
12842
12695
|
async function readWriteInput2(options) {
|
|
@@ -13141,7 +12994,7 @@ async function buildTodoUpdateDryRunPreview(args) {
|
|
|
13141
12994
|
const updates = args.updates ?? [{
|
|
13142
12995
|
taskId: args.taskId ?? "",
|
|
13143
12996
|
...args.noteId !== void 0 ? { noteId: args.noteId } : {},
|
|
13144
|
-
...args.
|
|
12997
|
+
...args.status !== void 0 ? { status: args.status } : {},
|
|
13145
12998
|
...args.priority !== void 0 ? { priority: args.priority } : {},
|
|
13146
12999
|
...args.schedule !== void 0 ? { schedule: args.schedule } : {}
|
|
13147
13000
|
}];
|
|
@@ -13153,16 +13006,16 @@ async function buildTodoUpdateDryRunPreview(args) {
|
|
|
13153
13006
|
note_id: plan.noteId,
|
|
13154
13007
|
note_title: (plan.row.title ?? "").trim(),
|
|
13155
13008
|
...result,
|
|
13156
|
-
updated: plan.write !== null && (result.
|
|
13009
|
+
updated: plan.write !== null && (result.status_from !== result.status_to || result.priority_from !== result.priority_to || JSON.stringify(result.due_from) !== JSON.stringify(result.due_to) || result.cascaded_task_ids.length > 0)
|
|
13157
13010
|
})));
|
|
13158
13011
|
const warnings = buildExecutionWarnings4(args.config, args.offline);
|
|
13159
13012
|
if (single) {
|
|
13160
13013
|
const task = tasks[0];
|
|
13161
13014
|
const patch = updates[0];
|
|
13162
13015
|
const changes = {};
|
|
13163
|
-
if (patch.
|
|
13164
|
-
changes.
|
|
13165
|
-
changes.
|
|
13016
|
+
if (patch.status !== void 0) {
|
|
13017
|
+
changes.status_from = task.status_from;
|
|
13018
|
+
changes.status_to = task.status_to;
|
|
13166
13019
|
}
|
|
13167
13020
|
if (patch.priority !== void 0) {
|
|
13168
13021
|
changes.priority_from = task.priority_from;
|
|
@@ -13184,7 +13037,7 @@ async function buildTodoUpdateDryRunPreview(args) {
|
|
|
13184
13037
|
inputs: {
|
|
13185
13038
|
task_id: task.task_id,
|
|
13186
13039
|
note_id: args.noteId?.trim() || null,
|
|
13187
|
-
...patch.
|
|
13040
|
+
...patch.status !== void 0 ? { status_to: patch.status } : {},
|
|
13188
13041
|
...patch.priority !== void 0 ? { priority_to: patch.priority ?? "none" } : {},
|
|
13189
13042
|
...patch.schedule !== void 0 ? { schedule: patch.schedule } : {}
|
|
13190
13043
|
},
|
|
@@ -13272,7 +13125,7 @@ function toDraftItems(value, path6 = "--items") {
|
|
|
13272
13125
|
throw new DinoxError(`${where}.text must be a string`, { code: "INVALID_ARGUMENT" });
|
|
13273
13126
|
}
|
|
13274
13127
|
const draft = { text: item.text };
|
|
13275
|
-
if (item.
|
|
13128
|
+
if (item.status !== void 0 && item.status !== null) draft.status = parseTaskStatusValue(item.status, `${where}.status`);
|
|
13276
13129
|
if (item.priority !== void 0 && item.priority !== null) {
|
|
13277
13130
|
draft.priority = parsePriorityValue(item.priority, `${where}.priority`);
|
|
13278
13131
|
}
|
|
@@ -13315,8 +13168,7 @@ function toTaskUpdates(value) {
|
|
|
13315
13168
|
const noteId = item.note_id ?? item.noteId;
|
|
13316
13169
|
const update = { taskId };
|
|
13317
13170
|
if (typeof noteId === "string") update.noteId = noteId;
|
|
13318
|
-
if (item.status !== void 0) update.
|
|
13319
|
-
if (typeof item.checked === "boolean") update.checked = item.checked;
|
|
13171
|
+
if (item.status !== void 0) update.status = parseTaskStatusValue(item.status, `${where}.status`);
|
|
13320
13172
|
if (item.priority !== void 0) {
|
|
13321
13173
|
update.priority = item.priority === null ? null : parsePriorityValue(item.priority, `${where}.priority`);
|
|
13322
13174
|
}
|
|
@@ -13326,24 +13178,20 @@ function toTaskUpdates(value) {
|
|
|
13326
13178
|
return update;
|
|
13327
13179
|
});
|
|
13328
13180
|
}
|
|
13329
|
-
|
|
13181
|
+
var TASK_STATUS_LIST = TASK_STATUS_VALUES.join(", ");
|
|
13182
|
+
function parseTaskStatusValue(value, optionName) {
|
|
13330
13183
|
const normalized = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
13331
|
-
if (normalized
|
|
13332
|
-
|
|
13333
|
-
}
|
|
13334
|
-
throw new DinoxError("--status must be one of: all, completed, uncompleted");
|
|
13184
|
+
if (isTaskStatus(normalized)) return normalized;
|
|
13185
|
+
throw new DinoxError(`${optionName} must be one of: ${TASK_STATUS_LIST}`, { code: "INVALID_ARGUMENT" });
|
|
13335
13186
|
}
|
|
13336
|
-
function
|
|
13337
|
-
|
|
13338
|
-
|
|
13339
|
-
|
|
13187
|
+
function parseTaskStatusFilter(value) {
|
|
13188
|
+
if (value === void 0 || value === null) return [];
|
|
13189
|
+
const entries = typeof value === "string" ? value.split(/[\s,,]+/).filter(Boolean) : [];
|
|
13190
|
+
if (entries.length === 0) {
|
|
13191
|
+
throw new DinoxError(`--status must list one or more of: ${TASK_STATUS_LIST}`, { code: "INVALID_ARGUMENT" });
|
|
13340
13192
|
}
|
|
13341
|
-
|
|
13342
|
-
|
|
13343
|
-
}
|
|
13344
|
-
throw new DinoxError(
|
|
13345
|
-
"--status must be one of: completed, uncompleted, done, undone, true, false, 1, 0"
|
|
13346
|
-
);
|
|
13193
|
+
const wanted = new Set(entries.map((entry) => parseTaskStatusValue(entry, "--status")));
|
|
13194
|
+
return TASK_STATUS_VALUES.filter((status) => wanted.has(status));
|
|
13347
13195
|
}
|
|
13348
13196
|
function parsePositiveIntegerOption2(value, optionName, fallback, max) {
|
|
13349
13197
|
if (value === void 0 || value === null || value === "") {
|
|
@@ -13442,7 +13290,7 @@ async function withTodoDatabase(globals, run) {
|
|
|
13442
13290
|
async function runTodoSearch({ args, globals, options }) {
|
|
13443
13291
|
const searchOptions = options;
|
|
13444
13292
|
const keyword = args.query?.trim() ?? "";
|
|
13445
|
-
const taskStatus =
|
|
13293
|
+
const taskStatus = parseTaskStatusFilter(searchOptions.status);
|
|
13446
13294
|
const taskTagFilter = typeof searchOptions.tags === "string" ? await parseTagFilterInput(searchOptions.tags) : [];
|
|
13447
13295
|
const taskPriorityFilter = parsePriorityFilter(searchOptions.priority);
|
|
13448
13296
|
const taskDateRange = parseTaskDateRange({
|
|
@@ -13558,7 +13406,7 @@ function parseSingleUpdate(taskId, options) {
|
|
|
13558
13406
|
const update = { taskId };
|
|
13559
13407
|
const noteId = optionalString(options.noteId);
|
|
13560
13408
|
if (noteId !== void 0) update.noteId = noteId;
|
|
13561
|
-
if (options.status !== void 0) update.
|
|
13409
|
+
if (options.status !== void 0) update.status = parseTaskStatusValue(options.status, "--status");
|
|
13562
13410
|
if (options.priority !== void 0) update.priority = parsePriorityValue(options.priority, "--priority");
|
|
13563
13411
|
const schedule = parseScheduleOptions(options.due, options.time);
|
|
13564
13412
|
if (options.clearDue) {
|
|
@@ -13610,7 +13458,7 @@ async function runTodoUpdate({ args, globals, options }) {
|
|
|
13610
13458
|
offline,
|
|
13611
13459
|
taskId: update.taskId,
|
|
13612
13460
|
noteId: update.noteId,
|
|
13613
|
-
|
|
13461
|
+
status: update.status,
|
|
13614
13462
|
priority: update.priority,
|
|
13615
13463
|
schedule: update.schedule
|
|
13616
13464
|
});
|
|
@@ -13637,7 +13485,7 @@ var todoSearchCommand = {
|
|
|
13637
13485
|
}
|
|
13638
13486
|
],
|
|
13639
13487
|
options: [
|
|
13640
|
-
{ flags: "--status <
|
|
13488
|
+
{ flags: "--status <list>", description: "Statuses to keep, comma-separated: backlog,todo,in_progress,done,cancelled (omit for every status)" },
|
|
13641
13489
|
{ flags: "--tags <string|@file>", description: "Tags every task must carry, via its own #tag or its note's tags (JSON array or comma/newline-separated)" },
|
|
13642
13490
|
{ flags: "--priority <list>", description: "Priorities to keep, comma-separated: high,medium,low,none" },
|
|
13643
13491
|
{ flags: "--from <date>", description: "Task date range start (YYYY-MM-DD or ISO datetime); matches tasks whose schedule overlaps the range" },
|
|
@@ -13660,9 +13508,9 @@ var todoSearchCommand = {
|
|
|
13660
13508
|
metaFields: ["stale", "meta.query", "meta.returned_count", "meta.total_count", "meta.total_count_is_lower_bound", "meta.matched_note_count", "meta.limit", "meta.offset", "meta.has_more", "meta.next_cursor", "meta.scan_limit", "meta.scanned_note_count", "meta.scan_truncated", "meta.truncated", "meta.applied_filters.status", "meta.applied_filters.tags", "meta.applied_filters.priority", "meta.applied_filters.include_deleted", "meta.applied_filters.date_range"]
|
|
13661
13509
|
},
|
|
13662
13510
|
examples: [
|
|
13663
|
-
'dino todo search "\u62A5\u9500" --status
|
|
13511
|
+
'dino todo search "\u62A5\u9500" --status backlog,todo,in_progress --format json',
|
|
13664
13512
|
"dino todo search --days 7 --format json",
|
|
13665
|
-
"dino todo search --status
|
|
13513
|
+
"dino todo search --status todo,in_progress --priority high,medium --format json"
|
|
13666
13514
|
]
|
|
13667
13515
|
},
|
|
13668
13516
|
action: runTodoSearch
|
|
@@ -13677,7 +13525,7 @@ var NEW_TASK_OPTIONS = [
|
|
|
13677
13525
|
{ flags: "--tasks <string|@file>", description: "Task list (JSON array or comma/newline-separated)" },
|
|
13678
13526
|
{
|
|
13679
13527
|
flags: "--items <json|@file>",
|
|
13680
|
-
description: "Structured tasks: JSON array of {text,
|
|
13528
|
+
description: "Structured tasks: JSON array of {text, status?, priority?, schedule?: {date, time?}, subtasks?: [...]} (status: backlog|todo|in_progress|done|cancelled, default todo)"
|
|
13681
13529
|
},
|
|
13682
13530
|
{ flags: "--priority <priority>", description: "Priority for --task/--tasks: high|medium|low" },
|
|
13683
13531
|
{ flags: "--due <date>", description: "Due date for --task/--tasks (local YYYY-MM-DD)" },
|
|
@@ -13708,7 +13556,7 @@ var todoAppendCommand = {
|
|
|
13708
13556
|
output: {
|
|
13709
13557
|
type: "structured",
|
|
13710
13558
|
summary: "Append result with target note, created tasks, and write receipt",
|
|
13711
|
-
fields: ["note_id", "appended_count", "source", "created", "day_key", "parent_task_id", "tasks.task_id", "tasks.text", "tasks.priority", "tasks.parent_task_id", "tasks.due_time", ...TODO_WRITE_RECEIPT_FIELDS]
|
|
13559
|
+
fields: ["note_id", "appended_count", "source", "created", "day_key", "parent_task_id", "tasks.task_id", "tasks.text", "tasks.status", "tasks.priority", "tasks.parent_task_id", "tasks.due_time", ...TODO_WRITE_RECEIPT_FIELDS]
|
|
13712
13560
|
},
|
|
13713
13561
|
examples: [
|
|
13714
13562
|
'dino todo append "\u8865\u4EA4\u62A5\u9500\u5355" --priority high --due 2026-11-10 --format json',
|
|
@@ -13741,7 +13589,7 @@ var todoCreateCommand = {
|
|
|
13741
13589
|
output: {
|
|
13742
13590
|
type: "structured",
|
|
13743
13591
|
summary: "Creation result with new note id, created task count, and write receipt",
|
|
13744
|
-
fields: ["note_id", "created_count", "title", "tasks.task_id", "tasks.text", "tasks.priority", "tasks.parent_task_id", "tasks.due_time", ...TODO_WRITE_RECEIPT_FIELDS]
|
|
13592
|
+
fields: ["note_id", "created_count", "title", "tasks.task_id", "tasks.text", "tasks.status", "tasks.priority", "tasks.parent_task_id", "tasks.due_time", ...TODO_WRITE_RECEIPT_FIELDS]
|
|
13745
13593
|
},
|
|
13746
13594
|
examples: ['dino todo create --task "\u8865\u4EA4\u62A5\u9500\u5355" --task "\u6574\u7406\u53D1\u7968" --format json']
|
|
13747
13595
|
},
|
|
@@ -13749,7 +13597,7 @@ var todoCreateCommand = {
|
|
|
13749
13597
|
};
|
|
13750
13598
|
var todoUpdateCommand = {
|
|
13751
13599
|
name: "update",
|
|
13752
|
-
description: "Update a task's status, priority, or due time by task id (
|
|
13600
|
+
description: "Update a task's status, priority, or due time by task id (closing cascades to subtasks, reopening to parents)",
|
|
13753
13601
|
arguments: [
|
|
13754
13602
|
{
|
|
13755
13603
|
syntax: "[taskId]",
|
|
@@ -13759,7 +13607,7 @@ var todoUpdateCommand = {
|
|
|
13759
13607
|
options: [
|
|
13760
13608
|
{
|
|
13761
13609
|
flags: "--status <status>",
|
|
13762
|
-
description: "
|
|
13610
|
+
description: "Set the status: backlog|todo|in_progress|done|cancelled"
|
|
13763
13611
|
},
|
|
13764
13612
|
{ flags: "--priority <priority>", description: "Set priority: high|medium|low, or none to clear" },
|
|
13765
13613
|
{ flags: "--due <date>", description: "Set the due date (local YYYY-MM-DD)" },
|
|
@@ -13781,10 +13629,10 @@ var todoUpdateCommand = {
|
|
|
13781
13629
|
output: {
|
|
13782
13630
|
type: "structured",
|
|
13783
13631
|
summary: "Mutation result with the task's new state, cascaded tasks, and write receipt (batch: per-task results and per-note receipts)",
|
|
13784
|
-
fields: ["task_id", "
|
|
13632
|
+
fields: ["task_id", "status", "priority", "due_time", "cascaded_task_ids", "updated", "note_id", "updated_count", "note_ids", "tasks.task_id", "tasks.updated", "notes.note_id", ...TODO_WRITE_RECEIPT_FIELDS]
|
|
13785
13633
|
},
|
|
13786
13634
|
examples: [
|
|
13787
|
-
"dino todo update <taskId> --note-id <noteId> --status
|
|
13635
|
+
"dino todo update <taskId> --note-id <noteId> --status done --format json",
|
|
13788
13636
|
"dino todo update <taskId> --priority high --due 2026-11-10 --time 09:30 --format json",
|
|
13789
13637
|
`dino todo update --updates '[{"task_id":"<id>","status":"done"},{"task_id":"<id2>","priority":"none"}]' --format json`
|
|
13790
13638
|
]
|
|
@@ -13952,7 +13800,7 @@ function readToolVersion(pm) {
|
|
|
13952
13800
|
child.on("error", () => resolve(null));
|
|
13953
13801
|
});
|
|
13954
13802
|
}
|
|
13955
|
-
async function
|
|
13803
|
+
async function runUpdate2(pm, options) {
|
|
13956
13804
|
const toolVersion = pm === "npm" || pm === "pnpm" ? await readToolVersion(pm) : null;
|
|
13957
13805
|
return runPackageManager(pm, appendNativeBuildPermissions(pm, PM_COMMANDS[pm].args, toolVersion), options);
|
|
13958
13806
|
}
|
|
@@ -13981,7 +13829,7 @@ async function installMissingAcpAdapters(pm, options, missing) {
|
|
|
13981
13829
|
function resolveDeps(overrides) {
|
|
13982
13830
|
return {
|
|
13983
13831
|
detectPackageManager,
|
|
13984
|
-
runUpdate:
|
|
13832
|
+
runUpdate: runUpdate2,
|
|
13985
13833
|
installAcpAdapters: (pm, options) => installMissingAcpAdapters(pm, options),
|
|
13986
13834
|
getVersion: getPackageVersion,
|
|
13987
13835
|
getLatestVersion: fetchLatestPublishedVersion,
|
|
@@ -14120,7 +13968,7 @@ function parseMcpGroups(raw) {
|
|
|
14120
13968
|
}
|
|
14121
13969
|
async function runMcp(context) {
|
|
14122
13970
|
const groups = parseMcpGroups(context.options.groups);
|
|
14123
|
-
const { serveStandaloneMcpOverStdio } = await import("./mcpServer-
|
|
13971
|
+
const { serveStandaloneMcpOverStdio } = await import("./mcpServer-M4HJFSNU.js");
|
|
14124
13972
|
await serveStandaloneMcpOverStdio({ readOnly: context.options.readOnly === true, groups });
|
|
14125
13973
|
}
|
|
14126
13974
|
var mcpCommandDescriptor = {
|