@wirecat/cli-core 0.737.0 → 0.739.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/CHANGELOG.md +49 -0
- package/dist/cli/documents/file-edit.js +79 -34
- package/dist/cli/documents/file-update.d.ts +5 -0
- package/dist/cli/documents/index.d.ts +1 -0
- package/dist/cli/documents/index.js +1 -0
- package/dist/cli/documents/library.js +3 -1
- package/dist/cli/documents/rekey.d.ts +22 -0
- package/dist/cli/documents/rekey.js +25 -0
- package/dist/cli/documents/words.d.ts +1 -1
- package/dist/cli/setup-command.js +4 -2
- package/dist/cli/token-session.d.ts +4 -2
- package/dist/cli/token-session.js +8 -4
- package/dist/documents/file-mirror-model.d.ts +4 -1
- package/dist/documents/model.d.ts +6 -0
- package/dist/errors/reasons.js +2 -15
- package/dist/errors/sftp-reasons.d.ts +5 -0
- package/dist/errors/sftp-reasons.js +15 -0
- package/dist/office/create.d.ts +38 -7
- package/dist/office/create.js +84 -20
- package/dist/office/index.d.ts +1 -1
- package/dist/services/documents/file-text.d.ts +4 -1
- package/dist/services/documents/file-text.js +16 -2
- package/dist/services/documents/ingestion.d.ts +5 -0
- package/dist/services/documents/ingestion.js +21 -1
- package/dist/services/documents/plan.js +143 -101
- package/dist/services/files/guarded-write.d.ts +6 -0
- package/dist/services/files/guarded-write.js +7 -1
- package/dist/services/files/mirror.js +2 -3
- package/dist/services/metadata.d.ts +1 -1
- package/dist/setup/plain.d.ts +7 -4
- package/dist/setup/plain.js +7 -5
- package/dist/store/sqlite/file-note-rekey.d.ts +8 -0
- package/dist/store/sqlite/file-note-rekey.js +47 -0
- package/dist/store/sqlite/notes.d.ts +7 -2
- package/dist/store/sqlite/notes.js +4 -1
- package/dist/terminal/hyperlink.d.ts +8 -0
- package/dist/terminal/hyperlink.js +21 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,55 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
|
|
|
5
5
|
minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
|
|
6
6
|
shape of this file.
|
|
7
7
|
|
|
8
|
+
## 0.739.0 — 24.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **A documents sync reads every format cli-core's readers read.** `readableFile` now takes Word 97–2003 (`.doc`),
|
|
13
|
+
RTF, HTML, OpenDocument (`.odt`, `.ods`, `.odp`), PowerPoint (`.pptx`) and EPUB beside PDF, docx, xlsx, CSV, TSV,
|
|
14
|
+
plain text and Markdown, so Yandex Disk and other CLIs built on it no longer keep them by name only. Images and
|
|
15
|
+
scans stay by name only.
|
|
16
|
+
- **A documents sync lists several folders at once on a source that sets `parallelListings`** (a whole number up to
|
|
17
|
+
8). A source whose one listing takes seconds (Yandex Disk) can set it, for example to 4, so a sync of many folders
|
|
18
|
+
can take less time. Each listing takes its own request from the run's budget, and the walk files the same
|
|
19
|
+
documents, though the order they are saved in may differ. A call cut short or a failed listing loses nothing: the
|
|
20
|
+
folder stays on the saved walk and is listed again in the next sync. Unset, a sync lists one folder at a time as
|
|
21
|
+
before.
|
|
22
|
+
- **`addFileEditCommands` takes `creates: false`** for a provider that names a file by an id it gives, as Google
|
|
23
|
+
Drive does. `sheets create` and `documents create` are then left out, since a path the user types can't name a
|
|
24
|
+
new file there. The edits, `history` and `restore` stay.
|
|
25
|
+
- **`sheets create` makes several sheets, formulas and bold cells.** `--values` also takes
|
|
26
|
+
`[{"name": "Budget", "header": true, "rows": [...]}]` for several sheets, and a cell may be
|
|
27
|
+
`{"formula": "SUM(B2:B3)"}` or `{"value": "Total", "bold": true}`. Excel and LibreOffice compute the formulas when
|
|
28
|
+
the file opens. A text that starts with `=` still stays text, so data from elsewhere never becomes a formula. Today's
|
|
29
|
+
rows keep working. `createXlsx` takes the same cells and a sheet's `header` ([Editing Office files](docs/office.md#new-files)).
|
|
30
|
+
- **`documents create` makes bold and italic text and tables.** `--payload` also takes `{"text", "bold", "italic"}`,
|
|
31
|
+
`{"runs": [{"text": "grew", "bold": true}]}` and `{"table": [["Item", "Cost"], ["Rent", "950"]], "header": true}`.
|
|
32
|
+
Today's `[{"text", "style"}]` keeps working, and `createDocx` takes the same entries.
|
|
33
|
+
- **`rekeySyncedDocument`** (`@wirecat/cli-core/documents/cli`) moves a synced document to the new id a provider gave
|
|
34
|
+
the file after a replace, so the owner's tags, the notes about it and its links follow the file. A sync that ran in
|
|
35
|
+
between and filed the file anew is folded into the old document; a failure only warns. Behind it, the documents
|
|
36
|
+
ingestion's `rekey` and `renameFileNote(…, { fold: true })`
|
|
37
|
+
([DOCUMENTS](docs/dev/DOCUMENTS.md#write-one-file-at-the-hash-read)).
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- **A file an older version kept by name as `unsupported type: …` is read on the next sync** once its type is
|
|
42
|
+
readable, even when the file did not change. A file whose read failed (damaged, no text layer) is not read again.
|
|
43
|
+
- **A target's own conflict keeps its words.** `guardedFileWrite` and a mirror's sync replaced every `conflict` from
|
|
44
|
+
`upload` with "changed since it was read; nothing was written", even when the target had done something and said
|
|
45
|
+
so. A conflict with a reason other than `mirror.remote-changed`, such as the new `upload.replace-interrupted`, now
|
|
46
|
+
reaches the caller unchanged.
|
|
47
|
+
|
|
48
|
+
## 0.738.0 — 24.11.2026
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- **A token guide and the setup walk-through draw their links as links** in a terminal known to show OSC 8 links
|
|
53
|
+
(GNOME Terminal and other VTE ones, iTerm2, kitty, WezTerm, Windows Terminal, VS Code, Ghostty; `FORCE_HYPERLINK`
|
|
54
|
+
decides elsewhere), so a long address no longer fills the screen. Elsewhere the address is printed beside the words.
|
|
55
|
+
`session start` prints its guide as plain text with its own headings, not as a note line.
|
|
56
|
+
|
|
8
57
|
## 0.737.0 — 23.11.2026
|
|
9
58
|
|
|
10
59
|
### Added
|
|
@@ -113,8 +113,35 @@ const docxEditsOf = (payload) => payload.map((edit) => {
|
|
|
113
113
|
};
|
|
114
114
|
return edit;
|
|
115
115
|
});
|
|
116
|
-
const
|
|
117
|
-
const
|
|
116
|
+
const SCALAR = v.union([v.string(), v.number(), v.boolean(), v.null()]);
|
|
117
|
+
const BOLD = v.optional(v.boolean());
|
|
118
|
+
const NEW_ROWS = v.array(v.array(v.union([
|
|
119
|
+
SCALAR,
|
|
120
|
+
v.strictObject({ formula: v.string(), bold: BOLD }),
|
|
121
|
+
v.strictObject({ value: SCALAR, bold: BOLD }),
|
|
122
|
+
])));
|
|
123
|
+
const NEW_VALUES = v.union([
|
|
124
|
+
v.pipe(NEW_ROWS, v.minLength(1)),
|
|
125
|
+
v.pipe(v.array(v.strictObject({ name: v.string(), rows: NEW_ROWS, header: v.optional(v.boolean()) })), v.minLength(1)),
|
|
126
|
+
]);
|
|
127
|
+
const isRows = (values) => values.every(Array.isArray);
|
|
128
|
+
const NEW_VALUES_SHAPE = 'rows of cells as JSON, such as [["Item", "Cost"], ["Rent", 950], ["Total", {"formula": "SUM(B2)"}]], or sheets ' +
|
|
129
|
+
'as [{"name": "Budget", "rows": [...], "header": true}]; a cell is a text, number, boolean, null, ' +
|
|
130
|
+
'{"formula": "…"} or {"value": …, "bold": true}';
|
|
131
|
+
const STYLE = v.optional(v.picklist(NEW_PARAGRAPH_STYLES));
|
|
132
|
+
const NEW_PARAGRAPHS = v.pipe(v.array(v.union([
|
|
133
|
+
v.strictObject({ text: v.string(), style: STYLE, bold: BOLD, italic: BOLD }),
|
|
134
|
+
v.strictObject({
|
|
135
|
+
runs: v.pipe(v.array(v.strictObject({ text: v.string(), bold: BOLD, italic: BOLD })), v.minLength(1)),
|
|
136
|
+
style: STYLE,
|
|
137
|
+
}),
|
|
138
|
+
v.strictObject({
|
|
139
|
+
table: v.array(v.array(v.pipe(v.union([v.string(), v.number()]), v.toString()))),
|
|
140
|
+
header: v.optional(v.boolean()),
|
|
141
|
+
}),
|
|
142
|
+
])), v.minLength(1));
|
|
143
|
+
const NEW_PARAGRAPHS_SHAPE = 'paragraphs and tables as JSON: [{"text": "…", "style": "Heading1"}, {"runs": [{"text": "…", "bold": true}]}, ' +
|
|
144
|
+
`{"table": [["Item", "Cost"], ["Rent", "950"]], "header": true}]; a style is one of ${NEW_PARAGRAPH_STYLES.join(", ")}`;
|
|
118
145
|
const addFileEditCommandsDefinition = (files, helpers) => {
|
|
119
146
|
const { prefix, place } = wordsOf(helpers.words);
|
|
120
147
|
const group = files.name();
|
|
@@ -268,22 +295,35 @@ const addFileEditCommandsDefinition = (files, helpers) => {
|
|
|
268
295
|
}
|
|
269
296
|
});
|
|
270
297
|
});
|
|
271
|
-
|
|
272
|
-
.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
298
|
+
if (helpers.creates !== false)
|
|
299
|
+
examples(annotate(sheets.command("create"), { effects: REMOTE_WRITE, offline: false })
|
|
300
|
+
.summary("create a new workbook from rows of values and formulas")
|
|
301
|
+
.description(`create a new .xlsx on ${place} from rows from A1: one sheet, or several given as [{name, rows, header?}]. ` +
|
|
302
|
+
"Numbers and booleans are typed, a text stays text, even one that starts with =. A formula is only " +
|
|
303
|
+
'{"formula": "SUM(B2:B3)"}, computed when the file opens; {"value": "Total", "bold": true} is a bold cell ' +
|
|
304
|
+
"and header: true makes a sheet's first row bold. A file already there is refused: change it with sheets update")
|
|
305
|
+
.argument("<path>", `the new .xlsx file on ${place}`)
|
|
306
|
+
.option("--values <json>", 'the rows as JSON, or [{"name", "rows", "header"?}] for several sheets; a cell is a text, number, ' +
|
|
307
|
+
'boolean, null (empty), {"formula": "…", "bold"?} or {"value": …, "bold"?}')
|
|
308
|
+
.option("--name <name>", "the sheet's name when --values is rows; Sheet1 without it"), [
|
|
309
|
+
`${prefix} ${group} sheets create /budget.xlsx --values '[["Item", "Cost"], ["Rent", 950]]' --name Budget`,
|
|
310
|
+
`${prefix} ${group} sheets create /budget.xlsx --values '[{"name": "Budget", "header": true, "rows": [["Item", "Cost"], ["Rent", 950], ["Food", 300], [{"value": "Total", "bold": true}, {"formula": "SUM(B2:B3)"}]]}]'`,
|
|
311
|
+
]).action(async function (input, args) {
|
|
312
|
+
if (args.values === undefined)
|
|
313
|
+
throw new CliError("validation_error", `give the rows with --values: ${NEW_VALUES_SHAPE}`, {
|
|
314
|
+
param: "--values",
|
|
315
|
+
});
|
|
316
|
+
const values = jsonOf(args.values, "--values", NEW_VALUES, NEW_VALUES_SHAPE);
|
|
317
|
+
const sheets = isRows(values) ? [{ name: args.name ?? "Sheet1", rows: values }] : values;
|
|
318
|
+
if (args.name !== undefined && !isRows(values))
|
|
319
|
+
throw new CliError("validation_error", "--name names the one sheet of rows; with sheets, each has its name", {
|
|
320
|
+
param: "--name",
|
|
321
|
+
});
|
|
322
|
+
await createNew(this, "sheets", input, ".xlsx", {
|
|
323
|
+
bytes: createXlsx({ sheets }),
|
|
324
|
+
answer: { sheets: sheets.map(({ name, rows }) => ({ name, rows: rows.length })) },
|
|
325
|
+
});
|
|
285
326
|
});
|
|
286
|
-
});
|
|
287
327
|
const documents = annotate(files.command("documents"), { effects: REMOTE_READ }).description(`the paragraphs of a Word document (.docx) on ${place}, read and changed in place`);
|
|
288
328
|
examples(marksUntrusted(annotate(documents.command("show"), { effects: REMOTE_READ, offline: false }), ["paragraphs.text"])
|
|
289
329
|
.summary("show a document's paragraphs and the sha256 to edit them at")
|
|
@@ -328,25 +368,30 @@ const addFileEditCommandsDefinition = (files, helpers) => {
|
|
|
328
368
|
};
|
|
329
369
|
});
|
|
330
370
|
});
|
|
331
|
-
|
|
332
|
-
.
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
371
|
+
if (helpers.creates !== false)
|
|
372
|
+
examples(annotate(documents.command("create"), { effects: REMOTE_WRITE, offline: false })
|
|
373
|
+
.summary("create a new Word document from paragraphs and tables")
|
|
374
|
+
.description(`create a new .docx on ${place} with these paragraphs, each in a style: ${NEW_PARAGRAPH_STYLES.join(", ")} ` +
|
|
375
|
+
"(Normal without one; ListBullet is a bullet list), and tables. A paragraph is bold or italic as a whole, " +
|
|
376
|
+
"or made of runs that each are; a table is rows of cell texts, its first row bold with header: true. A " +
|
|
377
|
+
"file already there is refused: change it with documents update")
|
|
378
|
+
.argument("<path>", `the new .docx file on ${place}`)
|
|
379
|
+
.option("--payload <json>", "the body as JSON, in order: [{text, style?, bold?, italic?}, {runs: [{text, bold?, italic?}], style?}, " +
|
|
380
|
+
"{table: [[cell, …], …], header?}]"), [
|
|
381
|
+
`${prefix} ${group} documents create /report.docx --payload '[{"text": "Report", "style": "Title"}, {"text": "Revenue grew 12%."}]'`,
|
|
382
|
+
`${prefix} ${group} documents create /report.docx --payload '[{"runs": [{"text": "Revenue "}, {"text": "grew 12%", "bold": true}]}, {"table": [["Item", "Cost"], ["Rent", "950"]], "header": true}]'`,
|
|
383
|
+
]).action(async function (input, args) {
|
|
384
|
+
if (args.payload === undefined)
|
|
385
|
+
throw new CliError("validation_error", `give the paragraphs with --payload: ${NEW_PARAGRAPHS_SHAPE}`, {
|
|
386
|
+
param: "--payload",
|
|
387
|
+
});
|
|
388
|
+
const paragraphs = jsonOf(args.payload, "--payload", NEW_PARAGRAPHS, NEW_PARAGRAPHS_SHAPE);
|
|
389
|
+
const tables = paragraphs.filter((block) => "table" in block).length;
|
|
390
|
+
await createNew(this, "documents", input, ".docx", {
|
|
391
|
+
bytes: createDocx({ paragraphs }),
|
|
392
|
+
answer: { paragraphs: paragraphs.length - tables, ...(tables ? { tables } : {}) },
|
|
343
393
|
});
|
|
344
|
-
const paragraphs = jsonOf(args.payload, "--payload", NEW_PARAGRAPHS, NEW_PARAGRAPHS_SHAPE);
|
|
345
|
-
await createNew(this, "documents", input, ".docx", {
|
|
346
|
-
bytes: createDocx({ paragraphs }),
|
|
347
|
-
answer: { paragraphs: paragraphs.length },
|
|
348
394
|
});
|
|
349
|
-
});
|
|
350
395
|
examples(annotate(files.command("history"), { effects: REMOTE_READ, offline: false })
|
|
351
396
|
.summary("list the earlier versions of a file kept on this computer")
|
|
352
397
|
.description("list what the writes and syncs of this profile replaced in a file, newest last. Each entry's version is the " +
|
|
@@ -28,6 +28,11 @@ export interface FileUpdateCommands {
|
|
|
28
28
|
write(extra: readonly string[], act: (port: FileUpdatePort) => Promise<object>, command: Command): Promise<object>;
|
|
29
29
|
/** The key an overwrite also asks; `files.delete` when absent. */
|
|
30
30
|
deleteKey?: string;
|
|
31
|
+
/**
|
|
32
|
+
* False where the provider names a file by an id it gives, so a path the user types can't name a new file:
|
|
33
|
+
* `sheets create` and `documents create` are left out.
|
|
34
|
+
*/
|
|
35
|
+
creates?: boolean;
|
|
31
36
|
}
|
|
32
37
|
/** A sha256 the user typed, in lower case; `flag` names it in the refusal. */
|
|
33
38
|
export declare const sha256Of: (input: string | undefined, flag?: string) => string | undefined;
|
|
@@ -20,6 +20,7 @@ export { addDocumentHistoryCommands, DOCUMENT_HISTORY_SETTINGS, type DocumentHis
|
|
|
20
20
|
export { addDocumentKnowledgeCommands, type DocumentKnowledgeCommands, type DocumentKnowledgePort, } from "./knowledge.js";
|
|
21
21
|
export { addDocumentMirrorCommands, type DocumentMirrorCommands, type DocumentMirrorConnection } from "./mirrors.js";
|
|
22
22
|
export { documentQueries, FACT_QUERY, factItem, folderRow, IDENTITY_ROLES, identityRow, linkRow, MEMORY_QUERY, MEMORY_SEARCH_QUERY, memoryItem, memorySearch, mirrorRow, tagRow, } from "./queries.js";
|
|
23
|
+
export { rekeySyncedDocument, type SyncedDocumentRekey } from "./rekey.js";
|
|
23
24
|
export { addDocumentSearchCommand, type DocumentSearchCommands, type DocumentSearchOptions } from "./search.js";
|
|
24
25
|
export { addDocumentSyncCommands, type DocumentSyncArgs, type DocumentSyncCommands } from "./sync.js";
|
|
25
26
|
export { ageOf, type CopyAge, type DocumentTexts, type DocumentWords, staleCopy } from "./words.js";
|
|
@@ -18,6 +18,7 @@ export { addDocumentHistoryCommands, DOCUMENT_HISTORY_SETTINGS, keepVersionsForD
|
|
|
18
18
|
export { addDocumentKnowledgeCommands, } from "./knowledge.js";
|
|
19
19
|
export { addDocumentMirrorCommands } from "./mirrors.js";
|
|
20
20
|
export { documentQueries, FACT_QUERY, factItem, folderRow, IDENTITY_ROLES, identityRow, linkRow, MEMORY_QUERY, MEMORY_SEARCH_QUERY, memoryItem, memorySearch, mirrorRow, tagRow, } from "./queries.js";
|
|
21
|
+
export { rekeySyncedDocument } from "./rekey.js";
|
|
21
22
|
export { addDocumentSearchCommand } from "./search.js";
|
|
22
23
|
export { addDocumentSyncCommands } from "./sync.js";
|
|
23
24
|
export { ageOf, staleCopy } from "./words.js";
|
|
@@ -360,7 +360,9 @@ const libraryOf = (options, withSync) => {
|
|
|
360
360
|
isFolder: options.isFolder,
|
|
361
361
|
...(options.isDocument ? { isDocument: options.isDocument } : {}),
|
|
362
362
|
skipReason: options.skipReason ?? (() => undefined),
|
|
363
|
-
|
|
363
|
+
// A file an older version kept by name for its type is read once a newer one reads that type; the
|
|
364
|
+
// planner asks only when `skipReason` no longer gives a reason. The words are the CLIs' own.
|
|
365
|
+
retryable: (skip) => skip.reason.startsWith("unsupported type: "),
|
|
364
366
|
errorOf,
|
|
365
367
|
assertHeld,
|
|
366
368
|
storeVersion: app.version,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ProviderEntry } from "../../domain/providers.js";
|
|
2
|
+
import type { AppIdentity } from "../../ports/app.js";
|
|
3
|
+
import type { MessageStore } from "../../store/index.js";
|
|
4
|
+
export interface SyncedDocumentRekey {
|
|
5
|
+
env: NodeJS.ProcessEnv;
|
|
6
|
+
app: Pick<AppIdentity, "command" | "version">;
|
|
7
|
+
provider: ProviderEntry;
|
|
8
|
+
/** The same ingestion the CLI's documents commands file documents with. */
|
|
9
|
+
ingestion(store: MessageStore): {
|
|
10
|
+
rekey(principal: string, from: string, to: string): Promise<boolean>;
|
|
11
|
+
};
|
|
12
|
+
/** The account's principal, as the documents sync names it. */
|
|
13
|
+
account: string;
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
warn(message: string): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* After a write that gave a file a new id at the provider, moves its synced copy to that id, so the owner's tags and
|
|
20
|
+
* notes follow the file. The write already happened, so a failure only warns; a store never opened stays unopened.
|
|
21
|
+
*/
|
|
22
|
+
export declare const rekeySyncedDocument: (input: SyncedDocumentRekey) => Promise<boolean>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { storePath } from "../../store/path.js";
|
|
3
|
+
import { openAppStore } from "../app-store.js";
|
|
4
|
+
/**
|
|
5
|
+
* After a write that gave a file a new id at the provider, moves its synced copy to that id, so the owner's tags and
|
|
6
|
+
* notes follow the file. The write already happened, so a failure only warns; a store never opened stays unopened.
|
|
7
|
+
*/
|
|
8
|
+
export const rekeySyncedDocument = async (input) => {
|
|
9
|
+
if (!existsSync(storePath(input.env)))
|
|
10
|
+
return false;
|
|
11
|
+
try {
|
|
12
|
+
const store = await openAppStore(input.env, { app: input.app, provider: input.provider });
|
|
13
|
+
try {
|
|
14
|
+
return await input.ingestion(store).rekey(input.account, input.from, input.to);
|
|
15
|
+
}
|
|
16
|
+
finally {
|
|
17
|
+
await store.close();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
const why = error instanceof Error ? error.message : String(error);
|
|
22
|
+
input.warn(`the synced copy keeps its tags and notes under the old id ${input.from}: ${why}`);
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -58,8 +58,8 @@ export interface CopyAge {
|
|
|
58
58
|
}
|
|
59
59
|
export declare const ageOf: (lastSync: string | undefined, now?: number) => CopyAge;
|
|
60
60
|
export declare const staleCopy: (provider: string, lastSync: string | undefined, now?: number) => {
|
|
61
|
-
missing?: undefined;
|
|
62
61
|
next?: undefined;
|
|
62
|
+
readonly missing?: undefined;
|
|
63
63
|
meta?: undefined;
|
|
64
64
|
} | {
|
|
65
65
|
missing: {
|
|
@@ -6,6 +6,7 @@ import { agentOf } from "../runs/run-context.js";
|
|
|
6
6
|
import { checkField, holds, nextOf, walk, } from "../setup/answers.js";
|
|
7
7
|
import { SETUP_LIMITS } from "../setup/document.js";
|
|
8
8
|
import { plainSetupText } from "../setup/plain.js";
|
|
9
|
+
import { drawsHyperlinks, hyperlink } from "../terminal/hyperlink.js";
|
|
9
10
|
import { answerStdinOption, lineReader, signInSteps } from "../terminal/sign-in-steps.js";
|
|
10
11
|
import { refuseGuardedKey } from "./config-command.js";
|
|
11
12
|
import { baseContext, environmentOf, secretInputOf } from "./context.js";
|
|
@@ -265,7 +266,8 @@ export const setupCommand = (setup) => {
|
|
|
265
266
|
const text = (id, params = {}) => id === undefined
|
|
266
267
|
? ""
|
|
267
268
|
: (document.texts[language]?.[id] ?? document.texts.en[id] ?? id).replace(/\{([a-z][a-z0-9_]*)\}/g, (all, name) => params[name] ?? all);
|
|
268
|
-
const
|
|
269
|
+
const drawn = drawsHyperlinks(env) ? { link: hyperlink } : {};
|
|
270
|
+
const say = (line) => renderer.note(plainSetupText(line, drawn));
|
|
269
271
|
const environment = environmentOf(command);
|
|
270
272
|
const input = secretInputOf(command);
|
|
271
273
|
const ask = async (prompt, hidden) => {
|
|
@@ -369,7 +371,7 @@ export const setupCommand = (setup) => {
|
|
|
369
371
|
say(text(block.caption));
|
|
370
372
|
break;
|
|
371
373
|
case "link":
|
|
372
|
-
say(
|
|
374
|
+
say(`[${text(block.text)}](${block.href})`);
|
|
373
375
|
break;
|
|
374
376
|
case "requirement":
|
|
375
377
|
say(`${text(block.text)}${block.fix ? ` — ${text(block.fix)}` : ""}`);
|
|
@@ -48,8 +48,10 @@ export interface TokenSessionOptions {
|
|
|
48
48
|
/** One sentence more for `session start --help`: which token, and what it can see. */
|
|
49
49
|
about?: string;
|
|
50
50
|
/**
|
|
51
|
-
* How a person who never made one gets the token: the steps and their links, in plain words
|
|
52
|
-
*
|
|
51
|
+
* How a person who never made one gets the token: the steps and their links, in plain words, as the restricted
|
|
52
|
+
* Markdown of a setup text (a `##` heading, `**bold**`, `[words](link)`). `session start` prints it before the
|
|
53
|
+
* question at a terminal, its links drawn as links where the terminal shows them, and `session start --help` ends
|
|
54
|
+
* with it.
|
|
53
55
|
*/
|
|
54
56
|
guide?: string;
|
|
55
57
|
/** One sentence more for `session end --help`, such as what of the service's own tools it leaves alone. */
|
|
@@ -2,6 +2,8 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import { at as valueAt } from "../crm/manifest/map.js";
|
|
5
|
+
import { plainSetupText } from "../setup/plain.js";
|
|
6
|
+
import { drawsHyperlinks, hyperlink } from "../terminal/hyperlink.js";
|
|
5
7
|
import { readSecret } from "../terminal/prompt.js";
|
|
6
8
|
import { baseContext, environmentOf, outputFor, secretInputOf } from "./context.js";
|
|
7
9
|
import { refuseOffline } from "./early-refusal.js";
|
|
@@ -75,13 +77,13 @@ export const tokenSessionCommand = (options) => {
|
|
|
75
77
|
(options.about ? `. ${options.about}` : ""))
|
|
76
78
|
.option("--credential-storage <storage>", "where the token is kept: keyring, which falls back to a private file by itself, or file", storageOf, "keyring");
|
|
77
79
|
if (options.guide)
|
|
78
|
-
start.addHelpText("after", `\n${options.guide}`);
|
|
80
|
+
start.addHelpText("after", `\n${plainSetupText(options.guide)}`);
|
|
79
81
|
if (options.login)
|
|
80
82
|
start.option("--login <name>", `the ${service} user name the password belongs to`);
|
|
81
83
|
if (options.site)
|
|
82
84
|
start.option("--site <address>", `the ${service} site, as https://${options.site.example} or ${options.site.example}`);
|
|
83
85
|
start.action(async function (args) {
|
|
84
|
-
const { env, profile, tokens, run, renderer, keyring } = contextOf(this);
|
|
86
|
+
const { env, profile, tokens, run, renderer, keyring, streams } = contextOf(this);
|
|
85
87
|
refuseCommandName(profile, commandWords(rootOf(this)), app.command);
|
|
86
88
|
if (options.site && args.site === undefined)
|
|
87
89
|
throw new CliError("validation_error", `give the ${service} site: --site ${options.site.example}`);
|
|
@@ -97,8 +99,10 @@ export const tokenSessionCommand = (options) => {
|
|
|
97
99
|
const input = secretInputOf(this).input ?? process.stdin;
|
|
98
100
|
// Only a person at a terminal pastes it; piped in, the note would stand before the answer on stderr.
|
|
99
101
|
if (input.isTTY) {
|
|
100
|
-
if (options.guide)
|
|
101
|
-
|
|
102
|
+
if (options.guide) {
|
|
103
|
+
const link = drawsHyperlinks(env) ? hyperlink : undefined;
|
|
104
|
+
streams.diagnostic(`${plainSetupText(options.guide, link ? { link } : {})}\n\n`);
|
|
105
|
+
}
|
|
102
106
|
if (page)
|
|
103
107
|
renderer.note(`the ${word} of ${login}: make one at ${page}, then paste it here`);
|
|
104
108
|
}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
export interface RemoteFile {
|
|
3
3
|
/** Relative to the listed folder, with `/` separators. */
|
|
4
4
|
path: string;
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Stays the same across a move, so a remote rename is found by it. A replace may give a new one (Yandex Disk's
|
|
7
|
+
* replace through a temporary file); the mirror records what the upload returns.
|
|
8
|
+
*/
|
|
6
9
|
id: string;
|
|
7
10
|
size: number;
|
|
8
11
|
/** The plain sha256 of the content. A file without one (still being processed) is left for the next run. */
|
|
@@ -67,6 +67,12 @@ export interface FeedlessDocumentSource<M extends SourceFile = SourceFile> {
|
|
|
67
67
|
}>;
|
|
68
68
|
content(id: string, maxChars?: number, file?: M): Promise<SourceContent<M>>;
|
|
69
69
|
bytes(id: string, file?: M): Promise<Uint8Array>;
|
|
70
|
+
/**
|
|
71
|
+
* How many folders a sync lists at once, for a provider whose one listing takes seconds (Yandex Disk): a whole
|
|
72
|
+
* number up to 8; one when unset or anything else. Each listing takes its own request from the run's budget; a source that paces its requests keeps pacing
|
|
73
|
+
* them, so stay within the provider's rate limit.
|
|
74
|
+
*/
|
|
75
|
+
parallelListings?: number;
|
|
70
76
|
/**
|
|
71
77
|
* Whether a saved document is read again though it did not change: one saved before the source learned to read
|
|
72
78
|
* something (a page's authors). The sync reads at most `REREAD_BATCH` of them a pass, so new edits are not held back;
|
package/dist/errors/reasons.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QUERY_REASONS } from "@wirecat/cli-base/query";
|
|
2
2
|
import { defineReasons } from "@wirecat/cli-base/standards";
|
|
3
3
|
import { CHAT_SENDING_ASK_DETAILS } from "../models/chat-sending.js";
|
|
4
|
-
|
|
4
|
+
import { SFTP, validation } from "./sftp-reasons.js";
|
|
5
5
|
/** The query reasons only message search raises; the shared ones are cli-base's `QUERY_REASONS`. */
|
|
6
6
|
const QUERY = [
|
|
7
7
|
["query.aborted", "the search was stopped before it finished"],
|
|
@@ -97,20 +97,6 @@ const PROVIDER_API = [
|
|
|
97
97
|
validation("file.too-large", "the file is larger than the limit set for this read"),
|
|
98
98
|
validation("file.not-plain-text", "the file's text is extracted on a read; writing it back would replace the file"),
|
|
99
99
|
];
|
|
100
|
-
/** The read-only SFTP client (`./sftp`). */
|
|
101
|
-
const SFTP = [
|
|
102
|
-
["sftp.host-key-missing", "configuration_error", "no host key is pinned for the SFTP server"],
|
|
103
|
-
["sftp.host-key-mismatch", "authentication_error", "the SFTP server's host key is not the pinned one"],
|
|
104
|
-
["sftp.auth-missing", "configuration_error", "an SFTP connection needs a password or a private key"],
|
|
105
|
-
["sftp.key-invalid", "configuration_error", "the SFTP private key or its passphrase cannot be read"],
|
|
106
|
-
["sftp.library-missing", "configuration_error", "SFTP needs the ssh2 package in the CLI's dependencies"],
|
|
107
|
-
["sftp.timeout", "timeout", "the SFTP server did not answer in time"],
|
|
108
|
-
validation("sftp.too-large", "the file is larger than the read's byte limit"),
|
|
109
|
-
validation("sftp.closed", "the SFTP connection was closed before the operation"),
|
|
110
|
-
validation("sftp.file-changed", "the file changed on the server while a stream read it; read it again"),
|
|
111
|
-
["ssh.forward-refused", "permission_error", "the SSH server does not allow forwarding to that address"],
|
|
112
|
-
["ssh.forward-failed", "network_error", "the SSH server could not reach the address behind it"],
|
|
113
|
-
];
|
|
114
100
|
/** The read-only SQL reader (`./sql`). */
|
|
115
101
|
const SQL = [
|
|
116
102
|
validation("sql.bad-identifier", "a table or column name is not a plain identifier"),
|
|
@@ -307,6 +293,7 @@ const OTHERS = [
|
|
|
307
293
|
["mirror.remote-changed", "conflict", "the remote file changed since the listing; the next sync settles it"],
|
|
308
294
|
["mirror.local-changed", "conflict", "the local file changed since the conflict was found; nothing was written"],
|
|
309
295
|
["mirror.no-conflict", "not_found", "the path has no recorded conflict; the last sync settled it or never saw one"],
|
|
296
|
+
["upload.replace-interrupted", "conflict", "another file took the path during a replace; the new content is kept"],
|
|
310
297
|
["upload.mismatch", "conflict", "the uploaded file reads back with other content; the local file changed meanwhile"],
|
|
311
298
|
["download.mismatch", "invalid_response", "the downloaded file has other content than the listing said"],
|
|
312
299
|
["catalog.unavailable", "configuration_error", "the store has no shared catalog for this account"],
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ErrorReason } from "@wirecat/cli-base/standards";
|
|
2
|
+
export type Entry = [reason: string, code: ErrorReason["code"], message: string];
|
|
3
|
+
export declare const validation: (reason: string, message: string) => Entry;
|
|
4
|
+
/** The read-only SFTP client (`./sftp`). */
|
|
5
|
+
export declare const SFTP: Entry[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const validation = (reason, message) => [reason, "validation_error", message];
|
|
2
|
+
/** The read-only SFTP client (`./sftp`). */
|
|
3
|
+
export const SFTP = [
|
|
4
|
+
["sftp.host-key-missing", "configuration_error", "no host key is pinned for the SFTP server"],
|
|
5
|
+
["sftp.host-key-mismatch", "authentication_error", "the SFTP server's host key is not the pinned one"],
|
|
6
|
+
["sftp.auth-missing", "configuration_error", "an SFTP connection needs a password or a private key"],
|
|
7
|
+
["sftp.key-invalid", "configuration_error", "the SFTP private key or its passphrase cannot be read"],
|
|
8
|
+
["sftp.library-missing", "configuration_error", "SFTP needs the ssh2 package in the CLI's dependencies"],
|
|
9
|
+
["sftp.timeout", "timeout", "the SFTP server did not answer in time"],
|
|
10
|
+
validation("sftp.too-large", "the file is larger than the read's byte limit"),
|
|
11
|
+
validation("sftp.closed", "the SFTP connection was closed before the operation"),
|
|
12
|
+
validation("sftp.file-changed", "the file changed on the server while a stream read it; read it again"),
|
|
13
|
+
["ssh.forward-refused", "permission_error", "the SSH server does not allow forwarding to that address"],
|
|
14
|
+
["ssh.forward-failed", "network_error", "the SSH server could not reach the address behind it"],
|
|
15
|
+
];
|
package/dist/office/create.d.ts
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import type { CellValue } from "./xlsx.js";
|
|
2
|
+
/** A formula without a cached result, computed when the file opens; `=` in front is optional. */
|
|
3
|
+
export interface NewFormulaCell {
|
|
4
|
+
readonly formula: string;
|
|
5
|
+
readonly bold?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** A value with formatting; a text that starts with `=` stays text here too. */
|
|
8
|
+
export interface NewValueCell {
|
|
9
|
+
readonly value: CellValue;
|
|
10
|
+
readonly bold?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type NewCell = CellValue | NewFormulaCell | NewValueCell;
|
|
2
13
|
export interface NewSheet {
|
|
3
14
|
/** 1 to 31 characters, none of `[]:*?/\`, not starting or ending with `'`; unique in the workbook, ignoring case. */
|
|
4
15
|
readonly name: string;
|
|
5
16
|
/** Rows from A1 down; `null` leaves a cell empty. */
|
|
6
|
-
readonly rows: readonly (readonly
|
|
17
|
+
readonly rows: readonly (readonly NewCell[])[];
|
|
18
|
+
/** This sheet's first row in bold. */
|
|
19
|
+
readonly header?: boolean;
|
|
7
20
|
}
|
|
8
21
|
export interface CreateXlsxOptions {
|
|
9
22
|
readonly sheets: readonly NewSheet[];
|
|
@@ -12,23 +25,41 @@ export interface CreateXlsxOptions {
|
|
|
12
25
|
}
|
|
13
26
|
/**
|
|
14
27
|
* A new workbook with these sheets and values: strings in a shared strings part (a string that starts with `=` stays
|
|
15
|
-
* text), numbers and booleans typed. No document properties, so the same input gives the same
|
|
28
|
+
* text), numbers and booleans typed, `{formula}` a formula. No document properties, so the same input gives the same
|
|
29
|
+
* bytes.
|
|
16
30
|
*/
|
|
17
31
|
export declare const createXlsx: (options: CreateXlsxOptions) => Uint8Array;
|
|
18
32
|
export declare const NEW_PARAGRAPH_STYLES: readonly ["Title", "Heading1", "Heading2", "Heading3", "Normal", "ListBullet"];
|
|
19
33
|
export type NewParagraphStyle = (typeof NEW_PARAGRAPH_STYLES)[number];
|
|
20
|
-
export interface
|
|
34
|
+
export interface NewRun {
|
|
21
35
|
/** A tab is `\t`, a line break `\n`. */
|
|
22
36
|
readonly text: string;
|
|
37
|
+
readonly bold?: boolean;
|
|
38
|
+
readonly italic?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export type NewParagraph = ({
|
|
41
|
+
readonly text: string;
|
|
42
|
+
readonly bold?: boolean;
|
|
43
|
+
readonly italic?: boolean;
|
|
44
|
+
} | {
|
|
45
|
+
readonly runs: readonly NewRun[];
|
|
46
|
+
}) & {
|
|
23
47
|
/** `Normal` when absent. */
|
|
24
48
|
readonly style?: NewParagraphStyle;
|
|
49
|
+
};
|
|
50
|
+
export interface NewTable {
|
|
51
|
+
/** Rows of cell texts; a shorter row is filled with empty cells. */
|
|
52
|
+
readonly table: readonly (readonly string[])[];
|
|
53
|
+
/** The first row in bold, repeated at the top of each page. */
|
|
54
|
+
readonly header?: boolean;
|
|
25
55
|
}
|
|
26
56
|
export interface CreateDocxOptions {
|
|
27
|
-
|
|
57
|
+
/** The body in order: paragraphs and tables. */
|
|
58
|
+
readonly paragraphs: readonly (NewParagraph | NewTable)[];
|
|
28
59
|
}
|
|
29
60
|
/**
|
|
30
|
-
* A new Word document with these paragraphs, on A4 with 2.5 cm margins, and a styles part that defines
|
|
31
|
-
* Heading1 to Heading3, Normal and ListBullet (a bullet list). No document properties, so the same input gives
|
|
32
|
-
* same bytes.
|
|
61
|
+
* A new Word document with these paragraphs and tables, on A4 with 2.5 cm margins, and a styles part that defines
|
|
62
|
+
* Title, Heading1 to Heading3, Normal and ListBullet (a bullet list). No document properties, so the same input gives
|
|
63
|
+
* the same bytes.
|
|
33
64
|
*/
|
|
34
65
|
export declare const createDocx: (options: CreateDocxOptions) => Uint8Array;
|