@wirecat/cli-core 0.718.0 → 0.720.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 +68 -0
- package/dist/attachments/documents.d.ts +5 -0
- package/dist/attachments/documents.js +2 -2
- package/dist/cli/bot/api-http.d.ts +6 -1
- package/dist/cli/bot/api-http.js +3 -0
- package/dist/cli/messenger/chats-command.js +5 -4
- package/dist/cli/messenger/contacts-command.js +3 -2
- package/dist/cli/messenger/topics-command.js +4 -3
- package/dist/cli/service-api-call.d.ts +1 -0
- package/dist/cli/service-api-call.js +6 -1
- package/dist/cli/service-api.d.ts +2 -0
- package/dist/cli/service-api.js +1 -0
- package/dist/cli/untrusted-marks.d.ts +4 -0
- package/dist/cli/untrusted-marks.js +4 -0
- package/dist/documents/file-mirror-model.d.ts +14 -0
- package/dist/errors/reasons.js +2 -1
- package/dist/office/docx.d.ts +43 -0
- package/dist/office/docx.js +349 -0
- package/dist/office/index.d.ts +2 -0
- package/dist/office/index.js +2 -0
- package/dist/office/package.d.ts +39 -0
- package/dist/office/package.js +98 -0
- package/dist/office/xlsx.d.ts +55 -0
- package/dist/office/xlsx.js +550 -0
- package/dist/office/xml.d.ts +34 -0
- package/dist/office/xml.js +186 -0
- package/dist/office/zip.d.ts +10 -0
- package/dist/office/zip.js +116 -0
- package/dist/ports/messenger.d.ts +11 -1
- package/dist/services/archive.js +22 -2
- package/dist/services/files/listing.d.ts +28 -0
- package/dist/services/files/listing.js +47 -0
- package/dist/services/files/mirror.d.ts +1 -1
- package/dist/services/files/mirror.js +16 -2
- package/dist/services/metadata.d.ts +1 -1
- package/dist/store/index.d.ts +1 -0
- package/dist/store/people.d.ts +8 -0
- package/dist/store/people.js +2 -0
- package/dist/store/sqlite/account-purge.js +3 -0
- package/dist/store/sqlite/person-erase.d.ts +39 -0
- package/dist/store/sqlite/person-erase.js +152 -0
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,74 @@ 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.720.0 — 23.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **A file mirror's remote listing goes on across runs**, so a cloud disk too big to list in one run (100,000 files
|
|
13
|
+
at about 30 s a page) syncs fully over several. `FileTarget.list` takes an optional `from` and may return `next`
|
|
14
|
+
for an incomplete listing; the engine keeps the files so far and `next` in the mirror's state (`listing`), merges
|
|
15
|
+
the next run's files by path and by id, and proves deletions only once the listing completes, each still by a
|
|
16
|
+
direct `exists` read. A saved listing over 7 days old, of another root folder, or past 100,000 files starts over;
|
|
17
|
+
a dry run saves none. A target without `next` lists from the start each run, as before
|
|
18
|
+
([DOCUMENTS.md, point 12](docs/dev/DOCUMENTS.md#sync-plain-files-with-a-provider)).
|
|
19
|
+
- **Edit `.xlsx` cells and `.docx` paragraphs in place** (`@wirecat/cli-core/office`), for a service with no
|
|
20
|
+
document API that downloads and uploads whole files, such as Yandex Disk. `readXlsxCells` and `editXlsxCells` work
|
|
21
|
+
by sheet and A1 address: shared or inline strings, numbers, booleans and empty cells, the cell's format kept, new
|
|
22
|
+
cells and rows in order, formula cells refused unless `overwriteFormulas`, and the workbook marked to calculate
|
|
23
|
+
again on open. `readDocxParagraphs` and `editDocxParagraphs` replace, insert or delete body and table-cell
|
|
24
|
+
paragraphs, keeping each paragraph's properties and its first run's formatting (mixed inline formatting
|
|
25
|
+
collapses, and the result lists where); a paragraph with tracked changes, a field, an image, a comment, a link or
|
|
26
|
+
a footnote is refused with the reason. Only the changed XML is spliced in; every other zip entry is copied byte for
|
|
27
|
+
byte ([Editing Office files](docs/office.md)).
|
|
28
|
+
- **`people.erase` deletes a person and what memo knows of them alone.** Their identities go, with the tags, links,
|
|
29
|
+
aliases, mentions and involvements that name them. A fact, note, task or import record that names them stays and
|
|
30
|
+
loses the name. A message, mail or meeting belongs to its source: the sender stays as an identity with no person,
|
|
31
|
+
and the next sync or people scan gives it one again. `apply: false` answers what would go and changes nothing.
|
|
32
|
+
Owner only; refused for the owner's own person (`person.owner`), and while an invoice, order, subscription or a row
|
|
33
|
+
the person wrote still names them (`person.erase-blocked`).
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- **Removing an import's account now takes the people only its records made.** Its e-mail and phone identities were
|
|
38
|
+
never referenced by anything, so the purge kept them and the person stayed. A person the owner tagged, linked or
|
|
39
|
+
gave a task to, or one another source or a message also names, still stays.
|
|
40
|
+
|
|
41
|
+
## 0.719.0 — 22.11.2026
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
- **`threadReplies`: `messages sync` saves the thread replies a chat's history leaves out.** Slack's channel history
|
|
46
|
+
holds top-level messages only, so a new reply to an old thread never reached the store. A messenger adapter may
|
|
47
|
+
now offer `threadReplies(chatId, { since })`: after a chat's history pages the sync asks it for the replies sent
|
|
48
|
+
since its last read of them (`since` is left out on the first), and saves them without marking a stretch of the
|
|
49
|
+
history held, so the history's resume point does not move. `messages sync --all` no longer passes such a chat as
|
|
50
|
+
already held to its newest message, since a reply moves neither the newest stored message nor, on every
|
|
51
|
+
messenger, the chat's last message.
|
|
52
|
+
- **`failedAnswer`: a service's refusal inside an HTTP 200 answer.** Slack's Web API answers every failure with 200
|
|
53
|
+
and `{"ok": false, "error": …}`, so its failures printed as successes. A CLI now passes
|
|
54
|
+
`failedAnswer(answer, operation)` to `serviceApiCommand`, `serviceApiCall` or `httpApiExecutor`; the error it
|
|
55
|
+
returns for a 2xx answer of an HTTP operation is the run's error, for a write too, since the service said it did
|
|
56
|
+
nothing. `failure` is still asked only for a non-2xx answer and a GraphQL `errors[]`.
|
|
57
|
+
|
|
58
|
+
### Fixed
|
|
59
|
+
|
|
60
|
+
- **`messages sync --dry-run` previews and names its permission key where it cannot estimate.** Its own estimate
|
|
61
|
+
needs one chat named, no `--all`, `--last` or `--since-time`, and message ids that count messages. Any other
|
|
62
|
+
dry run, such as the command's own example with `--last 100` or a messenger whose ids are ordered by time, was
|
|
63
|
+
refused, so the deny-keys contract could not learn its key. It now gets run's preview: the permission key, and no
|
|
64
|
+
connection or sign-in.
|
|
65
|
+
- **Chat titles, descriptions and a contact's own text reach a scheduled agent marked as untrusted.** Other people
|
|
66
|
+
set a group's title and description, a forum topic's title and their own contact description, yet only messages
|
|
67
|
+
were marked. In a scheduled agent's run, `chats list`, `chats show`, `chats events`, `topics list`, `topics show`,
|
|
68
|
+
`search topics`, `contacts list` and `contacts show` now put `title`, `description` and a contact's shared
|
|
69
|
+
`chats.title` between the run's markers, as `messages list` marks a message's text. Outside such a run nothing
|
|
70
|
+
changes.
|
|
71
|
+
- **`messages sync --dry-run` refuses again where it cannot estimate** (#3202), so the entry "`messages sync
|
|
72
|
+
--dry-run` previews and names its permission key where it cannot estimate" does not hold. whatsapp-cli and
|
|
73
|
+
max-cli test and document the refusal: a messenger that pushes its history, or whose ids are ordered by time,
|
|
74
|
+
cannot count what is missing, and a dry run says so with exit 2.
|
|
75
|
+
|
|
8
76
|
## 0.718.0 — 21.11.2026
|
|
9
77
|
|
|
10
78
|
### Added
|
|
@@ -4,6 +4,11 @@ export type DocumentKind = "odt" | "ods" | "odp" | "xlsx" | "pptx" | "epub";
|
|
|
4
4
|
export declare const documentKind: (hint: FileHint) => DocumentKind | undefined;
|
|
5
5
|
/** v2 for spreadsheets: rows under their header instead of one line per cell, so older text is read again. */
|
|
6
6
|
export declare const documentExtractor: (kind: DocumentKind) => string;
|
|
7
|
+
export declare const relationships: (archive: Map<string, Uint8Array>, owner: string) => Map<string, {
|
|
8
|
+
path: string;
|
|
9
|
+
type: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const mainPart: (archive: Map<string, Uint8Array>, contentType: string) => string;
|
|
7
12
|
/** The cells of an XLSX or ODS workbook, one `Sheet` per worksheet in workbook order, values as displayed. */
|
|
8
13
|
export declare const readSpreadsheet: (bytes: Uint8Array, kind: "xlsx" | "ods", signal?: AbortSignal) => Promise<Sheet[]>;
|
|
9
14
|
export declare const readDocument: (bytes: Uint8Array, kind: DocumentKind, signal?: AbortSignal) => Promise<Extraction>;
|
|
@@ -83,7 +83,7 @@ const target = (owner, reference) => {
|
|
|
83
83
|
throw new Error("external_part");
|
|
84
84
|
return path;
|
|
85
85
|
};
|
|
86
|
-
const relationships = (archive, owner) => {
|
|
86
|
+
export const relationships = (archive, owner) => {
|
|
87
87
|
const path = owner ? posix.join(posix.dirname(owner), "_rels", `${posix.basename(owner)}.rels`) : "_rels/.rels";
|
|
88
88
|
const document = xmlPart(archive, path);
|
|
89
89
|
rootIs(document, "Relationships", [PACKAGE_REL]);
|
|
@@ -102,7 +102,7 @@ const relationships = (archive, owner) => {
|
|
|
102
102
|
return result;
|
|
103
103
|
};
|
|
104
104
|
const relationId = (element) => required(attribute(element, "id", REL) || attribute(element, "id", STRICT_REL));
|
|
105
|
-
const mainPart = (archive, contentType) => {
|
|
105
|
+
export const mainPart = (archive, contentType) => {
|
|
106
106
|
const types = xmlPart(archive, "[Content_Types].xml");
|
|
107
107
|
const namespace = "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
108
108
|
rootIs(types, "Types", [namespace]);
|
|
@@ -33,6 +33,11 @@ export interface HttpApiExecutorOptions {
|
|
|
33
33
|
* write that failed on the service's side: that is always `outcome_unknown`.
|
|
34
34
|
*/
|
|
35
35
|
failure?: (status: number, answer: unknown, operation: ManifestOperation) => CliError | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The service's refusal inside a 2xx answer of an HTTP operation, such as Slack's `{"ok": false}`; `undefined` keeps
|
|
38
|
+
* the answer. A write it refuses is that error, not `outcome_unknown`: the service said it did nothing.
|
|
39
|
+
*/
|
|
40
|
+
failedAnswer?: (answer: unknown, operation: ManifestOperation) => CliError | undefined;
|
|
36
41
|
maxBytes?: number;
|
|
37
42
|
}
|
|
38
43
|
/** Why the generated command cannot send the operation's body, or `undefined` when it can: JSON, or an upload's bytes. */
|
|
@@ -40,7 +45,7 @@ export declare const unsendableBody: (operation: ManifestOperation) => string |
|
|
|
40
45
|
/** One generated HTTP operation and its flags as the request they stand for; nothing is sent. */
|
|
41
46
|
export declare const httpApiRequest: (operation: ManifestOperation, input: ApiCommandInput, baseUrl: string) => HttpApiRequest;
|
|
42
47
|
/** What one exchange needs: the service's name, the fetch, its own refusals and the answer's size limit. */
|
|
43
|
-
export type HttpApiSendOptions = Pick<HttpApiExecutorOptions, "service" | "fetch" | "failure" | "maxBytes">;
|
|
48
|
+
export type HttpApiSendOptions = Pick<HttpApiExecutorOptions, "service" | "fetch" | "failure" | "failedAnswer" | "maxBytes">;
|
|
44
49
|
/**
|
|
45
50
|
* Sends one request, records it in the run by its path template, never an id, and gives the parsed answer with the
|
|
46
51
|
* response's headers, where a service may page (WordPress's `X-WP-TotalPages`). A write that got no answer is
|
package/dist/cli/bot/api-http.js
CHANGED
|
@@ -178,6 +178,9 @@ export const httpApiExchange = (options) => async (command, operation, request)
|
|
|
178
178
|
}
|
|
179
179
|
try {
|
|
180
180
|
const result = graphqlAnswer(options, operation, answer);
|
|
181
|
+
const refused = operation.binding.kind === "http" ? options.failedAnswer?.(answer, operation) : undefined;
|
|
182
|
+
if (refused)
|
|
183
|
+
throw refused;
|
|
181
184
|
end({ status });
|
|
182
185
|
return { answer: result, headers: response.headers };
|
|
183
186
|
}
|
|
@@ -7,6 +7,7 @@ import { itemOf, renderAnswer, snakeKeys } from "../envelope.js";
|
|
|
7
7
|
import { withQuery } from "../list-query.js";
|
|
8
8
|
import { withPaging } from "../paging.js";
|
|
9
9
|
import { commandAt } from "../steps.js";
|
|
10
|
+
import { CHAT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
|
|
10
11
|
import { groupCommands } from "./admin-commands.js";
|
|
11
12
|
import { foldersCommand } from "./admin-folders-command.js";
|
|
12
13
|
import { moderateCommand, rulesCommand } from "./admin-moderation-command.js";
|
|
@@ -23,7 +24,7 @@ import { hideNever } from "./lacks.js";
|
|
|
23
24
|
import { archiveCommands, chatDeletionCommands, chatPinCommands, markUnreadCommand, mediaCommand, muteCommands, } from "./records-command.js";
|
|
24
25
|
export const chatsCommand = (messenger) => {
|
|
25
26
|
const chats = new Command("chats").description("the account's chats");
|
|
26
|
-
chats.addCommand(withQuery(annotate(withPaging(annotate(new Command("list"), { effects: storedRead(messenger) })
|
|
27
|
+
chats.addCommand(withQuery(annotate(withPaging(marksUntrusted(annotate(new Command("list"), { effects: storedRead(messenger) }), CHAT_UNTRUSTED)
|
|
27
28
|
.summary("chats, newest first, archived ones included")
|
|
28
29
|
.description("chats, newest first, archived ones included; the query is answered from the local store, " +
|
|
29
30
|
"so online, where the messenger filters nothing, it needs --offline")), {
|
|
@@ -33,11 +34,11 @@ export const chatsCommand = (messenger) => {
|
|
|
33
34
|
const body = await context.withServices((services) => chatsList(services, words, context.settings));
|
|
34
35
|
renderAnswer(this, context, body, lines(({ id, title, kind, unread_count, last_message_at }) => [id, kind, title ?? "", unread_count ? `${unread_count} unread` : "", last_message_at ?? ""].join(" ")));
|
|
35
36
|
}));
|
|
36
|
-
chats.addCommand(withQuery(annotate(annotate(new Command("events"), {
|
|
37
|
+
chats.addCommand(withQuery(annotate(marksUntrusted(annotate(new Command("events"), {
|
|
37
38
|
effects: storedRead(messenger),
|
|
38
39
|
// Where the history is pushed, the store answers, --offline too.
|
|
39
40
|
...(messenger.history === "store" ? {} : { offline: false }),
|
|
40
|
-
})
|
|
41
|
+
}), CHAT_UNTRUSTED)
|
|
41
42
|
.summary("stored membership and title changes")
|
|
42
43
|
.description("who joined, left, was added or removed, and by whom — from the chat's service messages; " +
|
|
43
44
|
`the last ${EVENTS_DAYS} days unless the query names time`)
|
|
@@ -56,7 +57,7 @@ export const chatsCommand = (messenger) => {
|
|
|
56
57
|
const found = await context.withServices((services) => services.chats.inspect(link));
|
|
57
58
|
renderAnswer(this, context, itemOf(snakeKeys(found)));
|
|
58
59
|
});
|
|
59
|
-
chats.addCommand(annotate(annotate(new Command("show"), { effects: storedRead(messenger) })
|
|
60
|
+
chats.addCommand(annotate(marksUntrusted(annotate(new Command("show"), { effects: storedRead(messenger) }), CHAT_UNTRUSTED)
|
|
60
61
|
.description("one chat: its kind, unread count, last message time and who is in it")
|
|
61
62
|
.argument("<chat>", messenger.chatArgument), { output: { entity: "chat" } }).action(async function (chat) {
|
|
62
63
|
const context = messengerContext(this, messenger);
|
|
@@ -19,6 +19,7 @@ import { listQuery, nativeField, nativeTerms, termField, timeBounds, typedQuery,
|
|
|
19
19
|
import { positiveCount, window, withPaging } from "../paging.js";
|
|
20
20
|
import { casKey } from "../registry-keys.js";
|
|
21
21
|
import { commandAt, nextStep } from "../steps.js";
|
|
22
|
+
import { CONTACT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
|
|
22
23
|
import { contactWriteCommands } from "./admin-contacts-command.js";
|
|
23
24
|
import { contactAnswer, contactShown, lines, pageOf } from "./chat-answers.js";
|
|
24
25
|
import { messengerContext } from "./context.js";
|
|
@@ -43,7 +44,7 @@ const CONTACT_ACTIVITY_QUERY = defineQuery({
|
|
|
43
44
|
const collect = (value, previous = []) => [...previous, value];
|
|
44
45
|
export const contactsCommand = (messenger) => {
|
|
45
46
|
const contacts = new Command("contacts").description("people this account has a one-to-one chat with");
|
|
46
|
-
contacts.addCommand(withQuery(annotate(withPaging(annotate(new Command("list"), { effects: REMOTE_READ })
|
|
47
|
+
contacts.addCommand(withQuery(annotate(withPaging(marksUntrusted(annotate(new Command("list"), { effects: REMOTE_READ }), CONTACT_UNTRUSTED)
|
|
47
48
|
.summary("people you have a one-to-one chat with")
|
|
48
49
|
.description("people you have a one-to-one chat with; name: matches the name, your local alias or the @username, " +
|
|
49
50
|
"notes: your private notes about them")).option("--order <recent|name>", "newest conversation first, or alphabetical", "recent"), { output: { entity: "contact" } }), CONTACTS_QUERY).action(async function (words) {
|
|
@@ -75,7 +76,7 @@ export const contactsCommand = (messenger) => {
|
|
|
75
76
|
args: { order, ...(words.length > 0 ? { query: words.join(" ") } : {}) },
|
|
76
77
|
}), lines(({ id, name, username, last_messaged_at }) => [id, name ?? "", username ? `@${username}` : "", last_messaged_at ?? ""].join(" ")));
|
|
77
78
|
}));
|
|
78
|
-
contacts.addCommand(annotate(annotate(new Command("show"), { effects: REMOTE_READ })
|
|
79
|
+
contacts.addCommand(annotate(marksUntrusted(annotate(new Command("show"), { effects: REMOTE_READ }), CONTACT_UNTRUSTED)
|
|
79
80
|
.summary("one person's profile, your alias and notes, and the chats you share")
|
|
80
81
|
.description("one person: what the messenger says about them — handles, flags, last seen, phone, when they registered — " +
|
|
81
82
|
"your alias, the chats you share, how many of their messages the store holds in each, and the earlier " +
|
|
@@ -7,6 +7,7 @@ import { ownerOnlyOption, REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
|
7
7
|
import { itemOf, listOf, renderAnswer, snakeKeys } from "../envelope.js";
|
|
8
8
|
import { listQuery, typedQuery, unfilteredQuery, withQuery } from "../list-query.js";
|
|
9
9
|
import { window, withPaging } from "../paging.js";
|
|
10
|
+
import { CHAT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
|
|
10
11
|
import { lines, pageOf, topicAnswer, wholeList } from "./chat-answers.js";
|
|
11
12
|
import { messengerContext } from "./context.js";
|
|
12
13
|
import { TOPICS_QUERY, topicTitle } from "./list-result-queries.js";
|
|
@@ -28,18 +29,18 @@ const listed = (messenger) => async function (chat, value) {
|
|
|
28
29
|
}), lines(({ id, title, closed, pinned, unread_count }) => [id, title, closed ? "closed" : "", pinned ? "pinned" : "", unread_count ? `${unread_count} unread` : ""].join(" ")));
|
|
29
30
|
};
|
|
30
31
|
/** `search topics`: a forum group's topics whose title matches, asked of the messenger. */
|
|
31
|
-
export const topicsSearchCommand = (messenger) => withPaging(annotate(new Command("topics"), { effects: REMOTE_READ, offline: false })
|
|
32
|
+
export const topicsSearchCommand = (messenger) => withPaging(marksUntrusted(annotate(new Command("topics"), { effects: REMOTE_READ, offline: false }), CHAT_UNTRUSTED)
|
|
32
33
|
.description("a forum group's topics whose title matches")
|
|
33
34
|
.argument("<chat>", messenger.chatArgument)
|
|
34
35
|
.argument("<text>", "words from the topic's title")).action(listed(messenger));
|
|
35
36
|
/** `topics list` and the writes — a forum group's topics, with the ids its messages carry as `threadId`. */
|
|
36
37
|
export const topicsCommand = (messenger) => {
|
|
37
38
|
const topics = annotate(new Command("topics"), { offline: false }).description("the topics of a forum group");
|
|
38
|
-
topics.addCommand(withQuery(withPaging(annotate(new Command("list"), { effects: REMOTE_READ })
|
|
39
|
+
topics.addCommand(withQuery(withPaging(marksUntrusted(annotate(new Command("list"), { effects: REMOTE_READ }), CHAT_UNTRUSTED)
|
|
39
40
|
.description("a forum group's topics, newest activity first")
|
|
40
41
|
.argument("<chat>", messenger.chatArgument)), TOPICS_QUERY).action(listed(messenger)));
|
|
41
42
|
if (messenger.topicShow)
|
|
42
|
-
annotate(topics.command("show"), { effects: REMOTE_READ })
|
|
43
|
+
marksUntrusted(annotate(topics.command("show"), { effects: REMOTE_READ }), CHAT_UNTRUSTED)
|
|
43
44
|
.description("one forum topic: its title, state and last activity")
|
|
44
45
|
.argument("<chat>", messenger.chatArgument)
|
|
45
46
|
.argument("<topic>", "the topic id, from `topics list`")
|
|
@@ -25,6 +25,7 @@ export interface ServiceApiCallOptions {
|
|
|
25
25
|
/** Headers beside the sign-in, such as the API version. */
|
|
26
26
|
headers?: (operation: ManifestOperation) => Record<string, string>;
|
|
27
27
|
failure?: HttpApiSendOptions["failure"];
|
|
28
|
+
failedAnswer?: HttpApiSendOptions["failedAnswer"];
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* A fetch that reaches only `hosts` (WC-CMD-32), over the fetch a test gives in its environment, or the network when
|
|
@@ -21,7 +21,12 @@ const NO_COMMAND = new Command("source");
|
|
|
21
21
|
export const serviceApiCall = (options) => {
|
|
22
22
|
const baseUrl = manifestBaseUrl(options.manifest, options.baseUrl, options.serverVariables);
|
|
23
23
|
const operations = new Map(options.manifest.operations.map((one) => [one.id, one]));
|
|
24
|
-
const exchange = httpApiExchange({
|
|
24
|
+
const exchange = httpApiExchange({
|
|
25
|
+
service: options.service,
|
|
26
|
+
fetch: () => options.fetch,
|
|
27
|
+
failure: options.failure,
|
|
28
|
+
failedAnswer: options.failedAnswer,
|
|
29
|
+
});
|
|
25
30
|
const withHeaders = async (id, input) => {
|
|
26
31
|
const operation = operations.get(id);
|
|
27
32
|
if (!operation)
|
|
@@ -61,6 +61,8 @@ export interface ServiceApiOptions extends ServiceApiPermissionsInput {
|
|
|
61
61
|
/** Fields `api show` adds to every answer, such as the API version the commands send. */
|
|
62
62
|
shown?: Readonly<Record<string, unknown>>;
|
|
63
63
|
failure?: (status: number, answer: unknown, operation: ManifestOperation) => CliError | undefined;
|
|
64
|
+
/** The service's refusal inside a 2xx answer, such as Slack's `{"ok": false}`: see `HttpApiExecutorOptions`. */
|
|
65
|
+
failedAnswer?: (answer: unknown, operation: ManifestOperation) => CliError | undefined;
|
|
64
66
|
}
|
|
65
67
|
/**
|
|
66
68
|
* The operations the `api` group offers, and why it leaves out the rest: one that answers with a credential needs a
|
package/dist/cli/service-api.js
CHANGED
|
@@ -182,6 +182,7 @@ const serviceApiCore = (options) => {
|
|
|
182
182
|
service: options.service,
|
|
183
183
|
fetch: options.fetch,
|
|
184
184
|
...(options.failure ? { failure: options.failure } : {}),
|
|
185
|
+
...(options.failedAnswer ? { failedAnswer: options.failedAnswer } : {}),
|
|
185
186
|
});
|
|
186
187
|
const operationOf = (name) => {
|
|
187
188
|
const named = (one) => pathOf(one) === name || one.command === name || one.id === name;
|
|
@@ -20,6 +20,10 @@ export declare const withUntrustedMarked: <T>(value: T, mark: string, id?: strin
|
|
|
20
20
|
* its answer's own `untrusted` list, which would change what every caller reads.
|
|
21
21
|
*/
|
|
22
22
|
export declare const MESSAGE_UNTRUSTED: readonly ["text", "transcript", "excerpt", "sender_name", "sender_username", "chat_title", "subject", "snippet", "attachments.name", "attachments.title", "attachments.text", "from.name", "to.name", "cc.name", "bcc.name", "reply_addresses.name"];
|
|
23
|
+
/** Other people's text in a chat, its events or a forum topic: the title and the description or topic they set. */
|
|
24
|
+
export declare const CHAT_UNTRUSTED: readonly ["title", "description"];
|
|
25
|
+
/** Other people's text in a contact: what the person says about themselves and the titles of the chats shared. */
|
|
26
|
+
export declare const CONTACT_UNTRUSTED: readonly ["description", "chats.title"];
|
|
23
27
|
/** Declares the fields of a read's answer that hold other people's text, at any depth, for a scheduled agent's run. */
|
|
24
28
|
export declare const marksUntrusted: <T extends Command>(command: T, fields?: readonly string[]) => T;
|
|
25
29
|
export declare const untrustedFieldsOf: (command: Command) => readonly string[] | undefined;
|
|
@@ -86,6 +86,10 @@ export const MESSAGE_UNTRUSTED = [
|
|
|
86
86
|
"bcc.name",
|
|
87
87
|
"reply_addresses.name",
|
|
88
88
|
];
|
|
89
|
+
/** Other people's text in a chat, its events or a forum topic: the title and the description or topic they set. */
|
|
90
|
+
export const CHAT_UNTRUSTED = ["title", "description"];
|
|
91
|
+
/** Other people's text in a contact: what the person says about themselves and the titles of the chats shared. */
|
|
92
|
+
export const CONTACT_UNTRUSTED = ["description", "chats.title"];
|
|
89
93
|
const DECLARED = new WeakMap();
|
|
90
94
|
/** Declares the fields of a read's answer that hold other people's text, at any depth, for a scheduled agent's run. */
|
|
91
95
|
export const marksUntrusted = (command, fields = MESSAGE_UNTRUSTED) => {
|
|
@@ -30,13 +30,17 @@ export interface FileTarget {
|
|
|
30
30
|
* Every file under `root`, with the root folder's own id; undefined when the folder does not exist. `complete` is
|
|
31
31
|
* false when any page was skipped or a cap was hit: a file missing from such a listing is not taken as deleted.
|
|
32
32
|
* Files at paths `excluded` names are listed too, so a file moved there is found by its id, but count toward no cap.
|
|
33
|
+
* An incomplete listing that can go on later returns `next`, its position; given back as `from` in a later run, the
|
|
34
|
+
* listing returns only the files from there on.
|
|
33
35
|
*/
|
|
34
36
|
list(root: string, signal?: AbortSignal, options?: {
|
|
35
37
|
excluded?(path: string): boolean;
|
|
38
|
+
from?: string;
|
|
36
39
|
}): Promise<{
|
|
37
40
|
rootId: string;
|
|
38
41
|
files: RemoteFile[];
|
|
39
42
|
complete: boolean;
|
|
43
|
+
next?: string;
|
|
40
44
|
} | undefined>;
|
|
41
45
|
/**
|
|
42
46
|
* Whether anything is at `path` now, read directly rather than from a listing; false only when the provider says
|
|
@@ -90,6 +94,16 @@ export interface FileMirrorState {
|
|
|
90
94
|
operationId: string;
|
|
91
95
|
created?: boolean;
|
|
92
96
|
}>;
|
|
97
|
+
/**
|
|
98
|
+
* A remote listing that stopped before its end: the files listed so far and where the next run goes on. Cleared once
|
|
99
|
+
* a run completes it, or when it is too old, of another root, or cannot go on.
|
|
100
|
+
*/
|
|
101
|
+
listing?: {
|
|
102
|
+
rootId: string;
|
|
103
|
+
startedAt: string;
|
|
104
|
+
next: string;
|
|
105
|
+
files: RemoteFile[];
|
|
106
|
+
};
|
|
93
107
|
}
|
|
94
108
|
export interface FileMirrorStatePort {
|
|
95
109
|
read(): FileMirrorState;
|
package/dist/errors/reasons.js
CHANGED
|
@@ -583,8 +583,9 @@ const OTHERS = [
|
|
|
583
583
|
["person.no-owner", "not_found", "no person is marked as the owner in the store"],
|
|
584
584
|
["person.unknown", "not_found", "the store has no person by that reference; people list gives person:<uid>"],
|
|
585
585
|
["person.no-doubt", "not_found", "nothing about that person is in doubt; people links check lists who is"],
|
|
586
|
-
validation("person.owner", "the owner's own person is not test data"),
|
|
586
|
+
validation("person.owner", "the owner's own person is not test data, and is never deleted"),
|
|
587
587
|
validation("person.no-identity", "a person with no identity is not test data; there is nothing to hide"),
|
|
588
|
+
validation("person.erase-blocked", "an invoice, order, subscription or a row the person wrote still names them; change those first, nothing was deleted"),
|
|
588
589
|
validation("person.from-required", "say whom the identity leaves: --from person:<uid>, or person:me for the owner"),
|
|
589
590
|
[
|
|
590
591
|
"identity.separated",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface DocxParagraph {
|
|
2
|
+
/** Position among the body's paragraphs, table cells included, in document order; edits address it. */
|
|
3
|
+
readonly index: number;
|
|
4
|
+
readonly text: string;
|
|
5
|
+
readonly styleId?: string;
|
|
6
|
+
/** The style's display name from styles.xml, such as "Heading 1". */
|
|
7
|
+
readonly style?: string;
|
|
8
|
+
readonly location: "body" | "table";
|
|
9
|
+
/** Whether `editDocxParagraphs` may replace or delete it; `reason` says why not. */
|
|
10
|
+
readonly editable: boolean;
|
|
11
|
+
readonly reason?: string;
|
|
12
|
+
/** Runs with different formatting: replacing the text collapses them to the first run's formatting. */
|
|
13
|
+
readonly mixedFormatting: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type DocxEdit = {
|
|
16
|
+
readonly index: number;
|
|
17
|
+
readonly text: string;
|
|
18
|
+
}
|
|
19
|
+
/** `insertAfter: -1` puts the paragraph before the first one. `styleFrom` defaults to the neighbour. */
|
|
20
|
+
| {
|
|
21
|
+
readonly insertAfter: number;
|
|
22
|
+
readonly text: string;
|
|
23
|
+
readonly styleFrom?: number;
|
|
24
|
+
} | {
|
|
25
|
+
readonly delete: number;
|
|
26
|
+
};
|
|
27
|
+
export interface EditDocxResult {
|
|
28
|
+
readonly bytes: Uint8Array;
|
|
29
|
+
readonly replaced: number[];
|
|
30
|
+
readonly inserted: number;
|
|
31
|
+
readonly deleted: number[];
|
|
32
|
+
/** Replaced paragraphs whose mixed inline formatting (bold words, links of colour) became the first run's. */
|
|
33
|
+
readonly collapsed: number[];
|
|
34
|
+
}
|
|
35
|
+
/** The body's paragraphs, table cells included, with their style and whether the editor can change them. */
|
|
36
|
+
export declare const readDocxParagraphs: (bytes: Uint8Array) => Promise<DocxParagraph[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Edits paragraph text in place: only document.xml is rewritten, by splicing the edited paragraphs into its original
|
|
39
|
+
* text, and every other zip entry is copied byte for byte. Indexes refer to the document as it was read. A replaced
|
|
40
|
+
* paragraph keeps its properties (style, numbering, alignment) and its first text run's formatting; the rest of its
|
|
41
|
+
* inline formatting collapses to that (listed in `collapsed`).
|
|
42
|
+
*/
|
|
43
|
+
export declare const editDocxParagraphs: (bytes: Uint8Array, edits: readonly DocxEdit[]) => Promise<EditDocxResult>;
|