@dreamlake/dreamlake-cli 0.104.7 → 0.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/content.d.ts +4 -3
- package/dist/api/index.d.ts +33 -23
- package/dist/api/index.js +25 -16
- package/dist/api/memo-character-plan.d.ts +2 -0
- package/dist/api/memo-character-plan.js +2 -0
- package/dist/api/memo-editing.d.ts +2 -0
- package/dist/api/memo-editing.js +2 -0
- package/dist/api/memo-edits.d.ts +63 -0
- package/dist/api/memo-edits.js +206 -0
- package/dist/api/memo-events.d.ts +44 -0
- package/dist/api/memo-events.js +65 -0
- package/dist/api/memo-facade.d.ts +294 -0
- package/dist/api/memo-facade.js +382 -0
- package/dist/api/memo-files.d.ts +111 -0
- package/dist/api/memo-files.js +110 -0
- package/dist/api/memo-html-read.d.ts +2 -0
- package/dist/api/memo-html-read.js +2 -0
- package/dist/api/memo-html.d.ts +2 -0
- package/dist/api/memo-html.js +2 -0
- package/dist/api/memo-linger.d.ts +85 -0
- package/dist/api/memo-linger.js +271 -0
- package/dist/api/memo-presence.d.ts +109 -0
- package/dist/api/memo-presence.js +75 -0
- package/dist/api/memo-reading.d.ts +55 -0
- package/dist/api/memo-reading.js +43 -0
- package/dist/api/memo-toc.d.ts +2 -0
- package/dist/api/memo-toc.js +2 -0
- package/dist/api/memo-write.d.ts +119 -0
- package/dist/api/memo-write.js +221 -0
- package/dist/api/memos.d.ts +344 -0
- package/dist/api/memos.js +231 -0
- package/dist/api/note-character-plan.d.ts +2 -2
- package/dist/api/note-character-plan.js +2 -2
- package/dist/api/note-editing.d.ts +2 -2
- package/dist/api/note-editing.js +2 -2
- package/dist/api/note-edits.d.ts +2 -59
- package/dist/api/note-edits.js +2 -205
- package/dist/api/note-events.d.ts +2 -41
- package/dist/api/note-events.js +2 -64
- package/dist/api/note-facade.d.ts +2 -268
- package/dist/api/note-facade.js +2 -376
- package/dist/api/note-files.d.ts +2 -102
- package/dist/api/note-files.js +2 -107
- package/dist/api/note-html-read.d.ts +2 -2
- package/dist/api/note-html-read.js +2 -2
- package/dist/api/note-html.d.ts +2 -2
- package/dist/api/note-html.js +2 -2
- package/dist/api/note-linger.d.ts +2 -83
- package/dist/api/note-linger.js +2 -270
- package/dist/api/note-presence.d.ts +2 -100
- package/dist/api/note-presence.js +2 -73
- package/dist/api/note-reading.d.ts +2 -51
- package/dist/api/note-reading.js +2 -42
- package/dist/api/note-toc.d.ts +2 -2
- package/dist/api/note-toc.js +2 -2
- package/dist/api/note-write.d.ts +2 -110
- package/dist/api/note-write.js +2 -217
- package/dist/api/notes.d.ts +2 -335
- package/dist/api/notes.js +2 -230
- package/dist/api/open-resources.js +3 -3
- package/dist/api/workspace.d.ts +3 -2
- package/dist/api/workspace.js +7 -6
- package/dist/cli/artifact/index.js +3 -3
- package/dist/cli/folders/index.d.ts +1 -1
- package/dist/cli/folders/index.js +4 -4
- package/dist/cli/help-examples.generated.js +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/cli/{notes → memos}/api-transport.d.ts +1 -1
- package/dist/cli/{notes → memos}/api-transport.js +1 -1
- package/dist/cli/{notes → memos}/archive-command.d.ts +1 -1
- package/dist/cli/{notes → memos}/archive-command.js +5 -5
- package/dist/cli/{notes → memos}/character-plan.d.ts +3 -1
- package/dist/cli/{notes → memos}/character-plan.js +7 -5
- package/dist/cli/{notes → memos}/document.d.ts +9 -9
- package/dist/cli/{notes → memos}/document.js +12 -12
- package/dist/cli/{notes → memos}/edit-commands.d.ts +8 -8
- package/dist/cli/{notes → memos}/edit-commands.js +14 -14
- package/dist/cli/{notes → memos}/events.d.ts +3 -3
- package/dist/cli/{notes → memos}/events.js +2 -2
- package/dist/cli/{notes → memos}/files-commands.d.ts +2 -2
- package/dist/cli/{notes → memos}/files-commands.js +5 -5
- package/dist/cli/{notes → memos}/index.d.ts +16 -16
- package/dist/cli/{notes → memos}/index.js +53 -53
- package/dist/cli/{notes → memos}/linger.d.ts +3 -3
- package/dist/cli/{notes → memos}/linger.js +5 -5
- package/dist/cli/{notes → memos}/move-command.d.ts +5 -5
- package/dist/cli/{notes → memos}/move-command.js +6 -6
- package/dist/cli/{notes → memos}/rm-command.d.ts +2 -2
- package/dist/cli/{notes → memos}/rm-command.js +2 -2
- package/dist/cli/{notes → memos}/select-command.d.ts +1 -1
- package/dist/cli/{notes → memos}/select-command.js +4 -4
- package/dist/cli/{notes → memos}/suggest-diff.d.ts +1 -1
- package/dist/cli/{notes → memos}/suggest-diff.js +2 -2
- package/dist/cli/{notes → memos}/transfer-command.d.ts +2 -2
- package/dist/cli/{notes → memos}/transfer-command.js +2 -2
- package/dist/cli/share.d.ts +1 -1
- package/dist/cli/share.js +10 -6
- package/dist/cli/update/index.js +3 -3
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +9 -9
- /package/dist/cli/{notes → memos}/editing.d.ts +0 -0
- /package/dist/cli/{notes → memos}/editing.js +0 -0
- /package/dist/cli/{notes → memos}/html-read.d.ts +0 -0
- /package/dist/cli/{notes → memos}/html-read.js +0 -0
- /package/dist/cli/{notes → memos}/html.d.ts +0 -0
- /package/dist/cli/{notes → memos}/html.js +0 -0
- /package/dist/cli/{notes → memos}/media-commands.d.ts +0 -0
- /package/dist/cli/{notes → memos}/media-commands.js +0 -0
- /package/dist/cli/{notes → memos}/toc.d.ts +0 -0
- /package/dist/cli/{notes → memos}/toc.js +0 -0
- /package/dist/cli/{notes → memos}/version-commands.d.ts +0 -0
- /package/dist/cli/{notes → memos}/version-commands.js +0 -0
package/dist/api/notes.js
CHANGED
|
@@ -1,230 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { characterDiff } from "./note-character-plan.js";
|
|
4
|
-
import * as editing from "./note-editing.js";
|
|
5
|
-
import { markdownToc as outline } from "./note-toc.js";
|
|
6
|
-
import { parse as parseHtml, select as selectHtml, textPieces } from './note-html.js';
|
|
7
|
-
/** Notes: search, read, sections, conditional writes. Mirrors the CLI `notes` group. */
|
|
8
|
-
import { noteFilesApi } from "./note-files.js";
|
|
9
|
-
import { notePresenceApi } from "./note-presence.js";
|
|
10
|
-
import { watchNote } from "./note-linger.js";
|
|
11
|
-
import { sharingApi } from "./workspace.js";
|
|
12
|
-
import { createHash } from "node:crypto";
|
|
13
|
-
import { noteEdits, } from "./note-edits.js";
|
|
14
|
-
export { noteEdits, } from "./note-edits.js";
|
|
15
|
-
import { ApiError, isObjectId, seg } from "./client.js";
|
|
16
|
-
import { submitNotePatch, readNoteCommand, validateCommandId, refuseNewReadingViewLines } from "./note-write.js";
|
|
17
|
-
export function notesApi(t, namespace) {
|
|
18
|
-
const base = `/namespaces/${seg(namespace)}/notes`;
|
|
19
|
-
const id = (value) => {
|
|
20
|
-
if (!isObjectId(value))
|
|
21
|
-
throw new Error("expected a 24-hex memo id");
|
|
22
|
-
return value;
|
|
23
|
-
};
|
|
24
|
-
const source = async (noteId, at) => {
|
|
25
|
-
const value = await t.request("GET", `${base}/${id(noteId)}/body`, { query: { contract: "v2", at }, redirect: "error" });
|
|
26
|
-
if (!value ||
|
|
27
|
-
value.note !== noteId ||
|
|
28
|
-
!/^sha256:[a-f0-9]{64}$/.test(value.hash ?? "") ||
|
|
29
|
-
typeof value.revision !== "string" ||
|
|
30
|
-
!value.revision.trim() ||
|
|
31
|
-
/[\r\n]/.test(value.revision) ||
|
|
32
|
-
/^sha256:/i.test(value.revision))
|
|
33
|
-
throw new Error("server did not return the Memos v2 contract; upgrade the server");
|
|
34
|
-
if (at !== undefined && value.revision !== at)
|
|
35
|
-
throw new Error("server did not return the requested pinned revision");
|
|
36
|
-
if (typeof value.content !== "string" ||
|
|
37
|
-
value.hash !==
|
|
38
|
-
`sha256:${createHash("sha256").update(value.content, "utf8").digest("hex")}`)
|
|
39
|
-
throw new Error("source does not match the returned hash");
|
|
40
|
-
return value;
|
|
41
|
-
};
|
|
42
|
-
/** The one v2 write. `commandId` is sent only when supplied and must be echoed; see note-write.ts. */
|
|
43
|
-
const patch = async (noteId, input, options = {}) => {
|
|
44
|
-
if (!input.baseRevision ||
|
|
45
|
-
/[\r\n]/.test(input.baseRevision) ||
|
|
46
|
-
!["exact", "merge"].includes(input.mode))
|
|
47
|
-
throw new Error("original baseRevision and mode required");
|
|
48
|
-
return submitNotePatch(t, `${base}/${id(noteId)}/body`, noteId, input, options);
|
|
49
|
-
};
|
|
50
|
-
const withCommand = (request, options) => options?.commandId === undefined ? request : { ...request, commandId: options.commandId };
|
|
51
|
-
const api = {
|
|
52
|
-
...notePresenceApi(t, base),
|
|
53
|
-
linger: (noteId, options, receive) => watchNote(t, `${base}/${id(noteId)}`, noteId, options, receive),
|
|
54
|
-
namespace,
|
|
55
|
-
/** Resolve the same ID, exact slug or exact title accepted by the CLI in this namespace. */
|
|
56
|
-
resolve: async (ref) => {
|
|
57
|
-
if (/^[a-f0-9]{24}$/i.test(ref))
|
|
58
|
-
return ref;
|
|
59
|
-
let offset = 0;
|
|
60
|
-
for (;;) {
|
|
61
|
-
const result = await t.request('GET', base, { query: { limit: 200, offset, includeArchived: true } });
|
|
62
|
-
const hit = result.notes.find(row => row.slug === ref || row.id === ref || row.name === ref);
|
|
63
|
-
if (hit)
|
|
64
|
-
return hit.id;
|
|
65
|
-
offset += result.notes.length;
|
|
66
|
-
if (!result.notes.length || (result.total === undefined ? result.notes.length < 200 : offset >= result.total))
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
throw new ApiError(404, 'note_not_found', { namespace, ref });
|
|
70
|
-
},
|
|
71
|
-
/** CSS inspection is read-only; selectText publishes a separate agent selection. */
|
|
72
|
-
selectElement: async (noteId, css) => {
|
|
73
|
-
const body = await t.request('GET', `${base}/${id(noteId)}/body`);
|
|
74
|
-
const document = parseHtml(body.text), element = selectHtml(document, css);
|
|
75
|
-
return { etag: body.etag, tag: element.tag, attrs: element.attrs, outer: element.outer, inner: element.inner,
|
|
76
|
-
text: textPieces(document, element).map(piece => piece.decoded).join('') };
|
|
77
|
-
},
|
|
78
|
-
source,
|
|
79
|
-
patch,
|
|
80
|
-
replaceContent: async (noteId, baseRevision, content, mode = "exact", options) => {
|
|
81
|
-
const original = await source(noteId, baseRevision);
|
|
82
|
-
refuseNewReadingViewLines(original.content, content, "content");
|
|
83
|
-
return patch(noteId, withCommand(noteEdits(original, characterDiff(original.content, content).map((e) => ({
|
|
84
|
-
start: e.start,
|
|
85
|
-
end: e.end,
|
|
86
|
-
text: e.replacementText,
|
|
87
|
-
expected: e.expectedText,
|
|
88
|
-
})), mode), options));
|
|
89
|
-
},
|
|
90
|
-
replace: async (noteId, baseRevision, text, where, mode = "exact", options) => {
|
|
91
|
-
const original = await source(noteId, baseRevision), plan = editing.replacementPlan(original.content, text, where);
|
|
92
|
-
return patch(noteId, withCommand(noteEdits(original, plan.map(([start, end, text]) => ({ start, end, text })), mode), options));
|
|
93
|
-
},
|
|
94
|
-
insert: async (noteId, baseRevision, text, where, mode = "exact", options) => {
|
|
95
|
-
const original = await source(noteId, baseRevision), placement = editing.insertPlacement(original.content, text, where);
|
|
96
|
-
return patch(noteId, withCommand(noteEdits(original, [{ start: placement.at, end: placement.at, text: placement.text }], mode), options));
|
|
97
|
-
},
|
|
98
|
-
removeText: async (noteId, baseRevision, where, mode = "exact", options) => {
|
|
99
|
-
const original = await source(noteId, baseRevision), plan = editing.removalPlan(original.content, where);
|
|
100
|
-
return patch(noteId, withCommand(noteEdits(original, plan.map(([start, end, text]) => ({ start, end, text })), mode), options));
|
|
101
|
-
},
|
|
102
|
-
findInSource: async (noteId, at, query, options = {}) => {
|
|
103
|
-
const original = await source(noteId, at);
|
|
104
|
-
return {
|
|
105
|
-
...original,
|
|
106
|
-
matches: editing.find(original.content, query, options),
|
|
107
|
-
};
|
|
108
|
-
},
|
|
109
|
-
outline: async (noteId, at) => {
|
|
110
|
-
const original = await source(noteId, at);
|
|
111
|
-
return {
|
|
112
|
-
note: noteId,
|
|
113
|
-
revision: original.revision,
|
|
114
|
-
hash: original.hash,
|
|
115
|
-
entries: outline(original.content),
|
|
116
|
-
};
|
|
117
|
-
},
|
|
118
|
-
get: (noteId) => t.request("GET", `/notes/${id(noteId)}`),
|
|
119
|
-
/** Archive independently of delete/tags. A saved edit restores the note and its folder path. */
|
|
120
|
-
archive: (noteId) => t.request("PATCH", `${base}/${id(noteId)}`, { json: { archived: true } }),
|
|
121
|
-
unarchive: (noteId) => t.request("PATCH", `${base}/${id(noteId)}`, { json: { archived: false } }),
|
|
122
|
-
delete: (noteId) => t.request("DELETE", `${base}/${id(noteId)}`),
|
|
123
|
-
shared: (query = {}) => t.request("GET", "/me/notes/shared", { query }),
|
|
124
|
-
projects: (noteId, view) => t.request("GET", `/namespaces/${seg(namespace)}/resources/note/${id(noteId)}/projects`, { query: { view } }),
|
|
125
|
-
move: (noteId, input) => t.request("POST", `${base}/${id(noteId)}/move`, { json: input }),
|
|
126
|
-
share: (noteId) => sharingApi(t, namespace, "notes", id(noteId)),
|
|
127
|
-
files: (noteId) => noteFilesApi(t, `${base}/${id(noteId)}`),
|
|
128
|
-
media: async (form) => {
|
|
129
|
-
const receipt = await t.request('POST', '/notes/media', { body: form, redirect: 'error' });
|
|
130
|
-
if (!receipt || typeof receipt.url !== 'string' || !/^https?:\/\/[^\s]+$/.test(receipt.url) ||
|
|
131
|
-
!['http:', 'https:'].includes(new URL(receipt.url).protocol) || typeof receipt.contentType !== 'string' ||
|
|
132
|
-
!Number.isSafeInteger(receipt.sizeBytes) || receipt.sizeBytes < 0)
|
|
133
|
-
throw new Error('invalid media upload response: expected url, contentType and sizeBytes');
|
|
134
|
-
return receipt;
|
|
135
|
-
},
|
|
136
|
-
read: (noteId, query = {}, options = {}) => t.request("GET", `${base}/${id(noteId)}/body`, {
|
|
137
|
-
query: { contract: "v2", ...query },
|
|
138
|
-
...(options.ifMatch === undefined ? {} : { headers: { "If-Match": options.ifMatch } }),
|
|
139
|
-
}),
|
|
140
|
-
readView: (noteId, options = {}) => readNoteView(t, namespace, id(noteId), options),
|
|
141
|
-
html: async (noteId, options = {}) => {
|
|
142
|
-
if (!t.raw)
|
|
143
|
-
throw new Error("transport_does_not_support_streaming");
|
|
144
|
-
const response = await t.raw("GET", `${base}/${id(noteId)}/body`, {
|
|
145
|
-
query: {
|
|
146
|
-
contract: "v2",
|
|
147
|
-
view: "html",
|
|
148
|
-
contentFormat: "literal-markdown",
|
|
149
|
-
at: options.at,
|
|
150
|
-
section: options.section,
|
|
151
|
-
toc: options.toc,
|
|
152
|
-
tag: options.tag,
|
|
153
|
-
},
|
|
154
|
-
headers: {
|
|
155
|
-
Accept: "text/html",
|
|
156
|
-
...(options.ifMatch ? { "If-Match": options.ifMatch } : {}),
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
if (!/^text\/(?:html|plain)(?:;|$)/i.test(response.headers.get("content-type") ?? ""))
|
|
160
|
-
throw new Error("server did not return Memos HTML; upgrade the server");
|
|
161
|
-
const bytes = new Uint8Array(await response.arrayBuffer()), html = new TextDecoder("utf-8", {
|
|
162
|
-
fatal: true,
|
|
163
|
-
ignoreBOM: true,
|
|
164
|
-
}).decode(bytes);
|
|
165
|
-
const snapshot = validateHtmlSnapshot(html, noteId, options);
|
|
166
|
-
if (options.at && snapshot.revision !== options.at)
|
|
167
|
-
throw new Error("server did not return the requested pinned revision");
|
|
168
|
-
if (options.ifMatch && snapshot.revision !== options.ifMatch)
|
|
169
|
-
throw new ApiError(412, "stale", { note: noteId });
|
|
170
|
-
return { note: noteId, revision: snapshot.revision, html, bytes };
|
|
171
|
-
},
|
|
172
|
-
diff: (noteId, query) => t.request("GET", `${base}/${id(noteId)}/diff`, { query }),
|
|
173
|
-
saveVersion: (noteId, input) => t.request("POST", `${base}/${id(noteId)}/versions`, { json: input }),
|
|
174
|
-
find: (query) => t.request("GET", `${base}/search`, { query }),
|
|
175
|
-
create: (input) => t.request("POST", base, {
|
|
176
|
-
json: input,
|
|
177
|
-
}),
|
|
178
|
-
edit: async (noteId, baseRevision, edits, mode = "exact", options) => patch(noteId, withCommand(noteEdits(await source(noteId, baseRevision), edits, mode), options)),
|
|
179
|
-
/** The durable record of one command id, scoped to the calling actor; 404 `command_not_found` when none. */
|
|
180
|
-
commandStatus: async (noteId, commandId) => readNoteCommand(t, `${base}/${id(noteId)}/commands/${seg(validateCommandId(commandId))}`, commandId),
|
|
181
|
-
versions: (noteId, query = {}) => t.request("GET", `${base}/${id(noteId)}/versions`, { query }),
|
|
182
|
-
version: (noteId, versionId) => t.request("GET", `${base}/${id(noteId)}/versions/${seg(versionId)}`),
|
|
183
|
-
list: (query = {}) => t.request("GET", base, { query }),
|
|
184
|
-
search: (q, limit = 50, offset = 0, options = {}) => t.request("GET", base, {
|
|
185
|
-
query: { q, limit, offset, ...options },
|
|
186
|
-
}),
|
|
187
|
-
body: (noteId) => t.request("GET", `${base}/${id(noteId)}/body`),
|
|
188
|
-
sections: (noteId) => t.request("GET", `${base}/${id(noteId)}/sections`),
|
|
189
|
-
section: (noteId, anchor) => t.request("GET", `${base}/${id(noteId)}/sections/${encodeURIComponent(anchor)}`),
|
|
190
|
-
/** Replace the whole body, refused with 412 `stale` unless `ifMatch` is the current etag. */
|
|
191
|
-
write: (noteId, text, ifMatch) => t.request("PUT", `${base}/${id(noteId)}/body`, {
|
|
192
|
-
json: { text },
|
|
193
|
-
headers: { "If-Match": ifMatch },
|
|
194
|
-
}),
|
|
195
|
-
/** Read-then-conditional-write append; a concurrent edit refuses with 412 `stale` instead of being overwritten. */
|
|
196
|
-
append: async (noteId, addition, ifMatch) => {
|
|
197
|
-
const current = await t.request("GET", `${base}/${id(noteId)}/body`);
|
|
198
|
-
const text = (current.text && !current.text.endsWith("\n")
|
|
199
|
-
? current.text + "\n"
|
|
200
|
-
: current.text) + addition;
|
|
201
|
-
return t.request("PUT", `${base}/${id(noteId)}/body`, {
|
|
202
|
-
json: { text },
|
|
203
|
-
headers: { "If-Match": ifMatch ?? current.etag },
|
|
204
|
-
});
|
|
205
|
-
},
|
|
206
|
-
addSection: async (noteId, text, placement = {}, ifMatch) => {
|
|
207
|
-
const etag = ifMatch ??
|
|
208
|
-
(await t.request("GET", `${base}/${id(noteId)}/body`)).etag;
|
|
209
|
-
return t.request("POST", `${base}/${id(noteId)}/sections`, {
|
|
210
|
-
json: { text, ...placement },
|
|
211
|
-
headers: { "If-Match": etag },
|
|
212
|
-
});
|
|
213
|
-
},
|
|
214
|
-
removeSection: async (noteId, anchor, ifMatch) => {
|
|
215
|
-
const etag = ifMatch ??
|
|
216
|
-
(await t.request("GET", `${base}/${id(noteId)}/body`)).etag;
|
|
217
|
-
return t.request("DELETE", `${base}/${id(noteId)}/sections/${seg(anchor)}`, { headers: { "If-Match": etag } });
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
return Object.assign(api, {
|
|
221
|
-
/** The full original span of one mapped element (`s1.p2`) at a revision: the scoped HTML read's absolute code-point range. */
|
|
222
|
-
addressRange: async (noteId, address, at) => {
|
|
223
|
-
const scoped = await api.html(noteId, { tag: address, at });
|
|
224
|
-
const range = scopedSourceRange(scoped.html);
|
|
225
|
-
if (!range)
|
|
226
|
-
throw new Error(`address ${address} did not return a scoped source range`);
|
|
227
|
-
return { ...range, revision: scoped.revision };
|
|
228
|
-
},
|
|
229
|
-
});
|
|
230
|
-
}
|
|
1
|
+
/** @deprecated Import the canonical Memo module. */
|
|
2
|
+
export * from "./memos.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { ApiError } from "./client.js";
|
|
3
|
-
import {
|
|
3
|
+
import { memosApi } from "./memos.js";
|
|
4
4
|
import { projectToolsApi } from "./agent.js";
|
|
5
5
|
/** Descriptors are observations only. Each resource goes through the caller's permission-checked API. */
|
|
6
6
|
export function openResourcesApi(t) {
|
|
@@ -36,13 +36,13 @@ export function openResourcesApi(t) {
|
|
|
36
36
|
}
|
|
37
37
|
try {
|
|
38
38
|
if (item.kind === "note") {
|
|
39
|
-
const row = await
|
|
39
|
+
const row = await memosApi(t, "unused").get(id);
|
|
40
40
|
if (!row.namespaceSlug)
|
|
41
41
|
throw new ApiError(503, "note_namespace_unavailable", {});
|
|
42
42
|
results.push({
|
|
43
43
|
resource: id,
|
|
44
44
|
tabId: item.id,
|
|
45
|
-
matches: await
|
|
45
|
+
matches: await memosApi(t, row.namespaceSlug).find({
|
|
46
46
|
q: input.query,
|
|
47
47
|
note: id,
|
|
48
48
|
limit: 20,
|
package/dist/api/workspace.d.ts
CHANGED
|
@@ -209,11 +209,12 @@ export declare function connectionsApi(t: Transport, namespace: string): {
|
|
|
209
209
|
disable: (id: string, expectedSettingsRevision: number, key: string) => Promise<unknown>;
|
|
210
210
|
delete: (id: string, expectedSettingsRevision: number, key: string) => Promise<unknown>;
|
|
211
211
|
};
|
|
212
|
-
export
|
|
212
|
+
export type ArtifactVisibility = "private" | "public" | "unlisted";
|
|
213
|
+
export declare function sharingApi<K extends "notes" | "artifacts">(t: Transport, namespace: string, kind: K, id: string): {
|
|
213
214
|
get: () => Promise<Record<string, unknown>>;
|
|
214
215
|
create: (role?: "read" | "write") => Promise<unknown>;
|
|
215
216
|
revoke: (revokeAccepted?: boolean) => Promise<unknown>;
|
|
216
|
-
visibility: (visibility: "private" | "public" | "team") => Promise<unknown>;
|
|
217
|
+
visibility: (visibility: K extends "artifacts" ? ArtifactVisibility : "private" | "public" | "team") => Promise<unknown>;
|
|
217
218
|
access: () => Promise<unknown>;
|
|
218
219
|
remove: (userId: string) => Promise<unknown>;
|
|
219
220
|
};
|
package/dist/api/workspace.js
CHANGED
|
@@ -134,20 +134,21 @@ export function sharingApi(t, namespace, kind, id) {
|
|
|
134
134
|
const permissions = row.permissions;
|
|
135
135
|
if ((kind === "notes" ? permissions?.share : row.viewerCanManage) !== true)
|
|
136
136
|
throw new Error("not allowed to manage sharing for this resource");
|
|
137
|
-
return operation(
|
|
137
|
+
return operation(kind === "artifacts" && typeof row.artifactId === "string"
|
|
138
|
+
? `${namespacePath(namespace)}/artifacts/${seg(row.artifactId)}` : base);
|
|
138
139
|
}
|
|
139
140
|
return {
|
|
140
141
|
get,
|
|
141
|
-
create: (role = "read") => manage(() => kind === "notes"
|
|
142
|
+
create: (role = "read") => manage((base) => kind === "notes"
|
|
142
143
|
? call(t, "PUT", base + "/share", { role })
|
|
143
144
|
: call(t, "POST", base, { share: true })),
|
|
144
|
-
revoke: (revokeAccepted = false) => manage(() => kind === "notes"
|
|
145
|
+
revoke: (revokeAccepted = false) => manage((base) => kind === "notes"
|
|
145
146
|
? call(t, "DELETE", base + "/share", undefined, {
|
|
146
147
|
revokeAccepted: revokeAccepted ? "true" : undefined,
|
|
147
148
|
})
|
|
148
149
|
: call(t, "POST", base, { share: false })),
|
|
149
|
-
visibility: (visibility) => manage(() => call(t, kind === "notes" ? "PATCH" : "POST", base, { visibility })),
|
|
150
|
-
access: () => manage(() => call(t, "GET", base + "/share/access")),
|
|
151
|
-
remove: (userId) => manage(() => call(t, "DELETE", base + "/share/access/" + seg(userId))),
|
|
150
|
+
visibility: (visibility) => manage((base) => call(t, kind === "notes" ? "PATCH" : "POST", base, { visibility })),
|
|
151
|
+
access: () => manage((base) => call(t, "GET", base + "/share/access")),
|
|
152
|
+
remove: (userId) => manage((base) => call(t, "DELETE", base + "/share/access/" + seg(userId))),
|
|
152
153
|
};
|
|
153
154
|
}
|
|
@@ -126,8 +126,8 @@ export async function runDreamlakeArtifactPush(args, deps = {}) {
|
|
|
126
126
|
`use --kind (${[...KINDS].sort().join(", ")})`);
|
|
127
127
|
return 1;
|
|
128
128
|
}
|
|
129
|
-
if (args.visibility && args.visibility !== "public" && args.visibility !== "private") {
|
|
130
|
-
fail(`--visibility must be public or
|
|
129
|
+
if (args.visibility && args.visibility !== "public" && args.visibility !== "private" && args.visibility !== "unlisted") {
|
|
130
|
+
fail(`--visibility must be public, private or unlisted (got '${args.visibility}')`);
|
|
131
131
|
return 1;
|
|
132
132
|
}
|
|
133
133
|
const defaultTitle = directory
|
|
@@ -424,7 +424,7 @@ export function registerArtifactCommand(program) {
|
|
|
424
424
|
.option("--kind <kind>", "html, react, markdown, svg, code, mermaid (default: auto)")
|
|
425
425
|
.option("--id <artifact-id>", "stable artifact id for versioning (default: slug of title)")
|
|
426
426
|
.option("--namespace <slug>", "namespace (default: active login)")
|
|
427
|
-
.option("--visibility <visibility>", "read visibility: public | private (default: private)")
|
|
427
|
+
.option("--visibility <visibility>", "read visibility: public | private | unlisted (default: private)")
|
|
428
428
|
.option("--incremental", "upload only new compressed chunks (default; requires an updated viewer)", true)
|
|
429
429
|
.option("--full", "upload the entire file in the original single-blob format")
|
|
430
430
|
.addOption(new Option("--no-incremental", "compatibility alias for --full").hideHelp())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Folder lifecycle and browsing use the shared node API. */
|
|
2
2
|
import type { Command } from 'commander';
|
|
3
|
-
import { type ConnOpts } from '../
|
|
3
|
+
import { type ConnOpts } from '../memos/index.js';
|
|
4
4
|
type Options = ConnOpts & {
|
|
5
5
|
json?: boolean;
|
|
6
6
|
project?: string;
|
|
@@ -3,8 +3,8 @@ import { resolveCtx } from '../compat/ctx.js';
|
|
|
3
3
|
import { requireToken, requireNamespace } from '../compat/http.js';
|
|
4
4
|
import { withConnFlags } from '../compat/flags.js';
|
|
5
5
|
import { emitJson, fail, renderTable } from '../helpers.js';
|
|
6
|
-
import {
|
|
7
|
-
import { report } from '../
|
|
6
|
+
import { memoTransport } from '../memos/api-transport.js';
|
|
7
|
+
import { report } from '../memos/index.js';
|
|
8
8
|
export async function runFoldersList(opts) {
|
|
9
9
|
const c = resolveCtx(opts), token = requireToken(c);
|
|
10
10
|
if (!token)
|
|
@@ -22,7 +22,7 @@ export async function runFoldersList(opts) {
|
|
|
22
22
|
fail('--page must be positive; --page-size must be 1–200');
|
|
23
23
|
return 1;
|
|
24
24
|
}
|
|
25
|
-
const result = await nodesApi(
|
|
25
|
+
const result = await nodesApi(memoTransport({ remote: c.remote, token })).children({
|
|
26
26
|
...(opts.parentId ? { parentId: opts.parentId } : { namespace: namespace, project: opts.project }),
|
|
27
27
|
page, pageSize, ...(opts.includeArchived ? { includeArchived: true } : {}),
|
|
28
28
|
});
|
|
@@ -47,7 +47,7 @@ export async function runFoldersArchive(id, archived, opts) {
|
|
|
47
47
|
return 1;
|
|
48
48
|
}
|
|
49
49
|
try {
|
|
50
|
-
const api = nodesApi(
|
|
50
|
+
const api = nodesApi(memoTransport({ remote: c.remote, token }));
|
|
51
51
|
const result = await (archived ? api.archive(id) : api.unarchive(id));
|
|
52
52
|
if (opts.json)
|
|
53
53
|
emitJson(result);
|
|
@@ -8,7 +8,7 @@ export const helpExamples = {
|
|
|
8
8
|
"artifact push": "dreamlake artifact push ./dashboard.html --id q1-dashboard\n# Edit the file, then repeat the same command to upload only new chunks.\n\n# Static build with on-demand assets (CLI 0.101.0+; requires site hosting):\ndreamlake artifact push ./dist/client --site --id simulation\n\n# Compatibility with older self-hosted viewers:\ndreamlake artifact push ./dashboard.html --id q1-dashboard --full\n\n# Multiple self-contained HTML pages (requires an updated viewer):\ndreamlake artifact push ./report --entry index.html --id quarterly-report",
|
|
9
9
|
"artifact meta set": "# At push time:\ndreamlake artifact push ./report.html --id q1-dashboard \\\n --description \"Revenue, churn and pipeline for the quarter\" \\\n --cover ./cover.png\n\n# Or after the fact, for an artifact that already exists:\ndreamlake artifact meta set q1-dashboard --description \"Revenue, churn and pipeline\"\ndreamlake artifact meta set q1-dashboard --cover ./cover.png\ndreamlake artifact meta show q1-dashboard\n\n# Back to the automatic description / the generated cover:\ndreamlake artifact meta set q1-dashboard --clear-description --clear-cover",
|
|
10
10
|
"artifact share": "# Find the dashboard you already uploaded; no new version is needed.\ndreamlake artifact list\nARTIFACT=\"q1-dashboard\" # Replace with the id from list.\ndreamlake artifact share get \"$ARTIFACT\"\n\n# Give signed-in recipients read access, then verify the returned link.\ndreamlake artifact share create \"$ARTIFACT\"\ndreamlake artifact share get \"$ARTIFACT\"\n\n# When link access is no longer needed, revoke it and verify.\ndreamlake artifact share revoke \"$ARTIFACT\"\ndreamlake artifact share get \"$ARTIFACT\"",
|
|
11
|
-
"artifact visibility": "ARTIFACT=\"q1-dashboard\" # Your existing artifact id.\ndreamlake artifact visibility \"$ARTIFACT\" public\ndreamlake artifact visibility \"$ARTIFACT\" private",
|
|
11
|
+
"artifact visibility": "ARTIFACT=\"q1-dashboard\" # Your existing artifact id.\ndreamlake artifact visibility \"$ARTIFACT\" public\ndreamlake artifact visibility \"$ARTIFACT\" private\ndreamlake artifact visibility \"$ARTIFACT\" unlisted",
|
|
12
12
|
"artifact rename": "dreamlake artifact rename session-work-map-20261014 session-work-map --namespace my-team",
|
|
13
13
|
"runnable bind": "dreamlake runnable bind udf/acme/recipes.process@FULL_SHA256 \\\n --snapshot CODE_REPO_ID --project recipes \\\n --server \"$LAKESHORE_URL\" --cp-namespace acme --dry-run\ndreamlake runnable bind udf/acme/recipes.process@FULL_SHA256 \\\n --snapshot CODE_REPO_ID --project recipes --server \"$LAKESHORE_URL\" --cp-namespace acme",
|
|
14
14
|
"runnable execute": "dreamlake runnable execute exec/acme/recipes.process@EXECUTION_DIGEST \\\n --queue cpu --inputs record.json --timeout-seconds 600 --json\ndreamlake runnable execute exec/acme/recipes.process@EXECUTION_DIGEST \\\n --queue cpu --inputs record.json --timeout-seconds 600 --attempt 2 --json",
|
package/dist/cli/index.js
CHANGED
|
@@ -36,7 +36,7 @@ import { registerConnectionCommand } from "./connection/index.js";
|
|
|
36
36
|
import { registerSourceCommand } from "./source/index.js";
|
|
37
37
|
import { registerTasksCommand } from "./tasks/index.js";
|
|
38
38
|
import { registerFoldersCommand } from "./folders/index.js";
|
|
39
|
-
import {
|
|
39
|
+
import { registerMemosCommand } from "./memos/index.js";
|
|
40
40
|
import { registerDeclareCommand } from "./declare/index.js";
|
|
41
41
|
import { registerHostsCommand } from "./hosts/index.js";
|
|
42
42
|
import { registerSessionsCommand } from "./sessions/index.js";
|
|
@@ -197,7 +197,7 @@ async function main(argv) {
|
|
|
197
197
|
registerWorkflowCommand(program);
|
|
198
198
|
registerPageCommand(program);
|
|
199
199
|
registerSourceCommand(program);
|
|
200
|
-
|
|
200
|
+
registerMemosCommand(program);
|
|
201
201
|
registerFoldersCommand(program);
|
|
202
202
|
registerOwnershipCommand(program);
|
|
203
203
|
registerProjectCommand(program);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Adapt explicit resolved CLI credentials; attribution remains owned by the CLI transport. */
|
|
2
2
|
import { requestJson, requestRaw } from '../client.js';
|
|
3
3
|
import { requestUrl, RequestNotSent } from '../../api/http.js';
|
|
4
|
-
export function
|
|
4
|
+
export function memoTransport(c) {
|
|
5
5
|
return {
|
|
6
6
|
request: async (method, path, options) => {
|
|
7
7
|
if (method === 'HEAD')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Archive is reversible lifecycle metadata, independent of deletion and tags. */
|
|
2
2
|
import type { Command } from 'commander';
|
|
3
3
|
import { type ConnOpts } from './index.js';
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function runMemosArchive(ref: string, archived: boolean, opts: ConnOpts & {
|
|
5
5
|
json?: boolean;
|
|
6
6
|
}): Promise<number>;
|
|
7
7
|
export declare function registerArchiveCommands(notes: Command): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { memosApi } from '../../api/memos.js';
|
|
2
2
|
import { requestJson } from '../client.js';
|
|
3
3
|
import { resolveCtx } from '../compat/ctx.js';
|
|
4
4
|
import { requireNamespace, requireToken } from '../compat/http.js';
|
|
5
5
|
import { withConnFlags } from '../compat/flags.js';
|
|
6
6
|
import { emitJson, fail } from '../helpers.js';
|
|
7
|
-
import {
|
|
7
|
+
import { memoTransport } from './api-transport.js';
|
|
8
8
|
import { resolveNote, report, seg } from './index.js';
|
|
9
|
-
export async function
|
|
9
|
+
export async function runMemosArchive(ref, archived, opts) {
|
|
10
10
|
const c = resolveCtx(opts), token = requireToken(c);
|
|
11
11
|
if (!token)
|
|
12
12
|
return 1;
|
|
@@ -35,7 +35,7 @@ export async function runNotesArchive(ref, archived, opts) {
|
|
|
35
35
|
fail('you do not have permission to archive this memo');
|
|
36
36
|
return 1;
|
|
37
37
|
}
|
|
38
|
-
const api =
|
|
38
|
+
const api = memosApi(memoTransport({ remote: c.remote, token }), note.namespaceSlug);
|
|
39
39
|
const result = await (archived ? api.archive(id) : api.unarchive(id));
|
|
40
40
|
if (opts.json)
|
|
41
41
|
emitJson(result);
|
|
@@ -54,6 +54,6 @@ export function registerArchiveCommands(notes) {
|
|
|
54
54
|
.argument('<note>', 'memo id, slug or exact title')
|
|
55
55
|
.option('--namespace <slug>', 'whose memos for lookup; with an id, asserts the owner')
|
|
56
56
|
.option('--json', 'emit the updated memo metadata')
|
|
57
|
-
.action(async (note, opts) => { process.exitCode = await
|
|
57
|
+
.action(async (note, opts) => { process.exitCode = await runMemosArchive(note, action === 'archive', opts); });
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -13,10 +13,12 @@ export declare const PATCH_LIMITS: Readonly<{
|
|
|
13
13
|
maxDiffCells: 4000000;
|
|
14
14
|
maxTraceCells: 250000;
|
|
15
15
|
}>;
|
|
16
|
-
export declare class
|
|
16
|
+
export declare class MemoPatchError extends Error {
|
|
17
17
|
readonly code: 'INVALID_PATCH' | 'LIMIT_EXCEEDED';
|
|
18
18
|
constructor(message: string, code?: 'INVALID_PATCH' | 'LIMIT_EXCEEDED');
|
|
19
19
|
}
|
|
20
20
|
export declare function characterDiff(base: string, target: string, offset?: number, budget?: {
|
|
21
21
|
cells: number;
|
|
22
22
|
}): CharacterEdit[];
|
|
23
|
+
/** @deprecated Use MemoPatchError. */
|
|
24
|
+
export { MemoPatchError as NotePatchError };
|
|
@@ -6,18 +6,18 @@ export const PATCH_LIMITS = Object.freeze({
|
|
|
6
6
|
maxDiffCells: 4_000_000,
|
|
7
7
|
maxTraceCells: 250_000,
|
|
8
8
|
});
|
|
9
|
-
export class
|
|
9
|
+
export class MemoPatchError extends Error {
|
|
10
10
|
code;
|
|
11
11
|
constructor(message, code = 'INVALID_PATCH') {
|
|
12
12
|
super(message);
|
|
13
13
|
this.code = code;
|
|
14
|
-
this.name = '
|
|
14
|
+
this.name = 'MemoPatchError';
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
function invalid(message) { throw new
|
|
17
|
+
function invalid(message) { throw new MemoPatchError(message); }
|
|
18
18
|
function limit(condition, message) {
|
|
19
19
|
if (condition)
|
|
20
|
-
throw new
|
|
20
|
+
throw new MemoPatchError(message, 'LIMIT_EXCEEDED');
|
|
21
21
|
}
|
|
22
22
|
function checkText(text) {
|
|
23
23
|
if (typeof text !== 'string')
|
|
@@ -54,7 +54,7 @@ export function characterDiff(base, target, offset = 0, budget = { cells: 0 }) {
|
|
|
54
54
|
return sparseCharacterDiff(left, right, offset + prefix, budget);
|
|
55
55
|
}
|
|
56
56
|
catch (error) {
|
|
57
|
-
if (!(error instanceof
|
|
57
|
+
if (!(error instanceof MemoPatchError) || error.message !== 'Character alignment trace limit exceeded')
|
|
58
58
|
throw error;
|
|
59
59
|
return packedCharacterDiff(left, right, offset + prefix, budget);
|
|
60
60
|
}
|
|
@@ -230,3 +230,5 @@ function sparseCharacterDiff(a, b, offset, budget) {
|
|
|
230
230
|
}
|
|
231
231
|
return invalid('Character alignment failed');
|
|
232
232
|
}
|
|
233
|
+
/** @deprecated Use MemoPatchError. */
|
|
234
|
+
export { MemoPatchError as NotePatchError };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SourceSnapshot, DocumentPatchPayload } from "../../api/
|
|
2
|
-
import { type
|
|
1
|
+
import type { SourceSnapshot, DocumentPatchPayload } from "../../api/memo-edits.js";
|
|
2
|
+
import { type MemoPatchRequest, type MemoWriteReceipt } from "../../api/memo-write.js";
|
|
3
3
|
import { ctx, type ConnOpts } from "./index.js";
|
|
4
4
|
export interface DocumentReadOptions extends ConnOpts {
|
|
5
5
|
at?: string;
|
|
@@ -43,8 +43,8 @@ interface Tokens {
|
|
|
43
43
|
}
|
|
44
44
|
export declare function tokens(result: Tokens, note: string): void;
|
|
45
45
|
type DocumentContext = NonNullable<Awaited<ReturnType<typeof ctx>>>;
|
|
46
|
-
export type { SourceSnapshot, SourceEdit, DocumentPatchPayload } from "../../api/
|
|
47
|
-
export { documentEdits, documentInsertion } from "../../api/
|
|
46
|
+
export type { SourceSnapshot, SourceEdit, DocumentPatchPayload } from "../../api/memo-edits.js";
|
|
47
|
+
export { documentEdits, documentInsertion } from "../../api/memo-edits.js";
|
|
48
48
|
/** The retained snapshot every v2 editor plans from, read through the shared core. */
|
|
49
49
|
export declare function readDocumentSnapshot(c: DocumentContext, id: string, at?: string): Promise<SourceSnapshot>;
|
|
50
50
|
/** Inserted text must not carry a generated reading-view header (the core's rule); whole-body writes are checked against their baseline by writePlan. */
|
|
@@ -59,14 +59,14 @@ export declare function commandIdFlag(opts: {
|
|
|
59
59
|
/** The exact request body: `commandId` appears only when the flag was given. */
|
|
60
60
|
export declare function withCommandId(payload: DocumentPatchPayload, opts: {
|
|
61
61
|
commandId?: string;
|
|
62
|
-
}):
|
|
62
|
+
}): MemoPatchRequest;
|
|
63
63
|
/** One submission path for every editor: the shared core verifies the receipt and the command-id echo. */
|
|
64
|
-
export declare function submitDocumentPatch(c: DocumentContext, id: string, payload:
|
|
64
|
+
export declare function submitDocumentPatch(c: DocumentContext, id: string, payload: MemoPatchRequest, options?: {
|
|
65
65
|
ifMatch?: string;
|
|
66
|
-
}): Promise<
|
|
67
|
-
export declare function printPatchReceipt(result:
|
|
66
|
+
}): Promise<MemoWriteReceipt>;
|
|
67
|
+
export declare function printPatchReceipt(result: MemoWriteReceipt, json?: boolean): void;
|
|
68
68
|
/** `dreamlake notes command-status NOTE COMMAND_ID`: the durable record behind one --command-id. */
|
|
69
|
-
export declare function
|
|
69
|
+
export declare function runMemosCommandStatus(ref: string, commandId: string, opts: ConnOpts & {
|
|
70
70
|
json?: boolean;
|
|
71
71
|
}): Promise<number>;
|
|
72
72
|
/** The core classifies PATCH failures (see note-write.ts); this maps them to exit codes. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readMemoView, focusedRead } from "../../api/memo-reading.js";
|
|
2
2
|
import { validateHtmlSnapshot } from "./html-read.js";
|
|
3
|
-
import {
|
|
4
|
-
import { COMMAND_ID_PATTERN, UncertainOutcome, CommandIdentityUnsupported,
|
|
5
|
-
import {
|
|
3
|
+
import { memosApi } from "../../api/memos.js";
|
|
4
|
+
import { COMMAND_ID_PATTERN, UncertainOutcome, CommandIdentityUnsupported, MemoWriteNotSubmitted, CommandInProgress, CommandIntentMismatch, refuseReadingView, refuseReadingViewPatch, failureInfo, provenUnsubmitted } from "../../api/memo-write.js";
|
|
5
|
+
import { memoTransport } from "./api-transport.js";
|
|
6
6
|
/** V2 transports exact source and opaque revisions; the backend owns patch parsing. */
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
8
|
import { readFileSync } from "node:fs";
|
|
@@ -23,10 +23,10 @@ export function tokens(result, note) {
|
|
|
23
23
|
function printTokens(result) {
|
|
24
24
|
return `note: ${result.note}\nhash: ${result.hash}\nrevision: ${result.revision}\n`;
|
|
25
25
|
}
|
|
26
|
-
export { documentEdits, documentInsertion } from "../../api/
|
|
26
|
+
export { documentEdits, documentInsertion } from "../../api/memo-edits.js";
|
|
27
27
|
/** The retained snapshot every v2 editor plans from, read through the shared core. */
|
|
28
28
|
export function readDocumentSnapshot(c, id, at) {
|
|
29
|
-
return
|
|
29
|
+
return memosApi(memoTransport(c), c.ns).source(id, at);
|
|
30
30
|
}
|
|
31
31
|
/** Inserted text must not carry a generated reading-view header (the core's rule); whole-body writes are checked against their baseline by writePlan. */
|
|
32
32
|
export function canonicalInput(text, what) {
|
|
@@ -74,7 +74,7 @@ export function withCommandId(payload, opts) {
|
|
|
74
74
|
}
|
|
75
75
|
/** One submission path for every editor: the shared core verifies the receipt and the command-id echo. */
|
|
76
76
|
export function submitDocumentPatch(c, id, payload, options = {}) {
|
|
77
|
-
return
|
|
77
|
+
return memosApi(memoTransport(c), c.ns).patch(id, payload, options);
|
|
78
78
|
}
|
|
79
79
|
export function printPatchReceipt(result, json) {
|
|
80
80
|
if (json)
|
|
@@ -84,7 +84,7 @@ export function printPatchReceipt(result, json) {
|
|
|
84
84
|
process.stdout.write(`${printTokens(result)}mode: ${result.mode}\nbaseRevision: ${result.baseRevision}\n${result.commandId === null ? "" : `outcome: ${result.outcome}\ncommandId: ${result.commandId}\nreplayed: ${result.replayed}\n`}`);
|
|
85
85
|
}
|
|
86
86
|
/** `dreamlake notes command-status NOTE COMMAND_ID`: the durable record behind one --command-id. */
|
|
87
|
-
export async function
|
|
87
|
+
export async function runMemosCommandStatus(ref, commandId, opts) {
|
|
88
88
|
if (!COMMAND_ID_PATTERN.test(commandId)) {
|
|
89
89
|
fail("command id must be 8–128 characters of A-Z a-z 0-9 . _ : -");
|
|
90
90
|
return 1;
|
|
@@ -96,7 +96,7 @@ export async function runNotesCommandStatus(ref, commandId, opts) {
|
|
|
96
96
|
const id = await resolveNote(c, ref);
|
|
97
97
|
if (!id)
|
|
98
98
|
return 1;
|
|
99
|
-
const status = await
|
|
99
|
+
const status = await memosApi(memoTransport(c), c.ns).commandStatus(id, commandId);
|
|
100
100
|
if (opts.json) {
|
|
101
101
|
emitJson(status);
|
|
102
102
|
return 0;
|
|
@@ -110,7 +110,7 @@ export async function runNotesCommandStatus(ref, commandId, opts) {
|
|
|
110
110
|
}
|
|
111
111
|
/** The core classifies PATCH failures (see note-write.ts); this maps them to exit codes. */
|
|
112
112
|
export function documentWriteError(error) {
|
|
113
|
-
if (error instanceof
|
|
113
|
+
if (error instanceof MemoWriteNotSubmitted) {
|
|
114
114
|
fail(error.message);
|
|
115
115
|
return 1;
|
|
116
116
|
}
|
|
@@ -133,7 +133,7 @@ export function documentWriteError(error) {
|
|
|
133
133
|
// The core turns a PATCH 503 into a typed outcome above, so a raw 503 here came from the
|
|
134
134
|
// baseline read (or note resolution): nothing was submitted and nothing is ambiguous.
|
|
135
135
|
if (error instanceof HttpError && error.status === 503) {
|
|
136
|
-
fail(provenUnsubmitted(failureInfo(error).body) ? new
|
|
136
|
+
fail(provenUnsubmitted(failureInfo(error).body) ? new MemoWriteNotSubmitted().message
|
|
137
137
|
: `patch not submitted: the original baseline could not be read, so nothing was sent; preserve the original baseline and draft (${error.message})`);
|
|
138
138
|
return 1;
|
|
139
139
|
}
|
|
@@ -215,7 +215,7 @@ export async function runDocumentRead(ref, opts) {
|
|
|
215
215
|
let at = opts.at, start = 0, hash, total;
|
|
216
216
|
let fallback = false;
|
|
217
217
|
do {
|
|
218
|
-
const page = await
|
|
218
|
+
const page = await readMemoView(transport, c.ns, id, { at, start, section: opts.section, tag: opts.tag, toc: opts.toc });
|
|
219
219
|
// An HTML-source note has no Markdown reading view: the defaulted read falls back to exact source.
|
|
220
220
|
if (page.sourceType !== 'markdown' && defaultedView && start === 0) {
|
|
221
221
|
fallback = true;
|