@wirecat/cli-core 0.705.0 → 0.707.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 +77 -0
- package/dist/cli/bot/api.d.ts +8 -0
- package/dist/cli/bot/api.js +31 -3
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/list-query.d.ts +3 -1
- package/dist/cli/list-query.js +5 -2
- package/dist/cli/messenger/lacks.js +3 -0
- package/dist/cli/messenger/messages-delete-command.js +30 -25
- package/dist/cli/messenger/messages-edit-command.js +2 -0
- package/dist/cli/messenger/messages-scheduled-command.js +110 -4
- package/dist/cli/service-api.js +65 -27
- package/dist/cli/token-session.d.ts +4 -1
- package/dist/cli/token-session.js +6 -1
- package/dist/content/cli/index.d.ts +2 -2
- package/dist/content/cli/index.js +64 -54
- package/dist/content/manifest/writer.d.ts +4 -1
- package/dist/content/manifest/writer.js +15 -12
- package/dist/content/testing/index.d.ts +1 -0
- package/dist/content/testing/index.js +1 -0
- package/dist/content/testing/manifest-fake.d.ts +54 -0
- package/dist/content/testing/manifest-fake.js +426 -0
- package/dist/content/writer.d.ts +5 -0
- package/dist/content/writer.js +1 -4
- package/dist/content/writes.js +13 -7
- package/dist/entities/index.d.ts +8 -2
- package/dist/entities/index.js +4 -2
- package/dist/entities/message-change.d.ts +240 -0
- package/dist/entities/message-change.js +6 -0
- package/dist/kit/fake.d.ts +2 -2
- package/dist/kit/fake.js +21 -0
- package/dist/mcp/surface.js +6 -3
- package/dist/ports/messenger.d.ts +20 -1
- package/dist/sends/permissions.js +11 -1
- package/dist/services/messages.d.ts +31 -0
- package/dist/services/messages.js +62 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,83 @@ 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.707.0 — 19.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **A content write asks once.** `ContentWriteOptions.confirmed` carries the keys the `posts` command asked the owner
|
|
13
|
+
about (those at level `ask`), and `contentWriterFromManifest` hands them, with the call's own `api.<operation>` key
|
|
14
|
+
when there are any, to its `write` as a fourth argument. A CLI passes them to
|
|
15
|
+
`serviceApiWriter(...)(command, operation, input, { confirmed })`, so a terminal publish asks the owner once; a key
|
|
16
|
+
the command did not ask (the publish key for a post published at the source since the last sync) is still asked,
|
|
17
|
+
and `deny` or `readonly` still refuse.
|
|
18
|
+
- **`contentManifestFake` in `@wirecat/cli-core/content/testing`.** A content service in memory, built from a CLI's
|
|
19
|
+
own source manifest and generated API, as `crmManifestFake` is for a CRM: the contract kits and the CLI's `sync` run
|
|
20
|
+
over it without a hand-written fake of the service.
|
|
21
|
+
|
|
22
|
+
### Changed — may break callers
|
|
23
|
+
|
|
24
|
+
- **The content commands use the vocabulary's words**, so a CLI made from them passes `cli-dev lint` (it needs
|
|
25
|
+
cli-base 0.123.0 or later). A script that called the old names must change:
|
|
26
|
+
|
|
27
|
+
| Before | Now |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `authors list` | `users list` |
|
|
30
|
+
| `terms list` | `tags list` |
|
|
31
|
+
| `metrics show <post>` | `posts stats <post>` |
|
|
32
|
+
| `posts schedule <post> --at <time>` | `posts publish <post> --at-time <time>` |
|
|
33
|
+
| `posts list --since <day> --until <day>` | `posts list published:[<day> TO <day>]` (or `published:<day>`) |
|
|
34
|
+
| `posts list term:<id>` | `posts list tag:<id>` |
|
|
35
|
+
| `posts create\|update --body-file <path>` | `--text-file <path>` |
|
|
36
|
+
| `posts create\|update --excerpt <text>` | `--description <text>` |
|
|
37
|
+
| `posts create\|update --term <id>` (repeated) | `--tags <id,id>` |
|
|
38
|
+
| `posts delete --force` | `posts delete --allow-delete` |
|
|
39
|
+
|
|
40
|
+
`channels list`, `users list` and `tags list` take a query, which narrows by no field yet. The `posts.schedule` key
|
|
41
|
+
is gone: scheduling checks `posts.publish`, as it did already. A config that still sets `posts.schedule` now holds
|
|
42
|
+
an unknown key, so every command refuses to run and names the `config unset` that removes it.
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- **A profile on its own site keeps the site in its account.** `tokenSessionCommand` with `site` remembers
|
|
47
|
+
`<site>:<user id>`, the site as `--site` cleans it (host in lower case, no trailing slash), as bitrix24-cli keeps
|
|
48
|
+
`<portal>:<user id>`. Each WordPress site numbers its users from 1, so two profiles on two sites shared one copy in
|
|
49
|
+
the store, and a sync of one marked the other's posts deleted.
|
|
50
|
+
- **`posts list published:>…` leaves out a post published at that very second.** A strict start was read as `>=`.
|
|
51
|
+
- **`posts create|update --tags` with no ids is refused**, not taken as "remove every tag".
|
|
52
|
+
- **`contentManifestFake` puts a list where the call's own `items` says**, wraps a `get` answer at `get.items`, and
|
|
53
|
+
matches a route from the server's path only, so `/posts` no longer answers `/users/5/posts`.
|
|
54
|
+
|
|
55
|
+
## 0.706.0 — 19.11.2026
|
|
56
|
+
|
|
57
|
+
### Added
|
|
58
|
+
|
|
59
|
+
- **The generated `api` group mounts subgroups: `api <group> <command>`.** An operation whose manifest names a `group`
|
|
60
|
+
(cli-base's `names.groups`) is mounted under it without the repeated word, so `contacts-list` in `contacts` is
|
|
61
|
+
`api contacts list`, checked against `api.contacts.list`; `api.contacts` covers the whole group. A profile that still
|
|
62
|
+
names the old flat key `api.contacts-list` keeps its hold on that one command: it is checked beside the new key, from
|
|
63
|
+
the command line and over MCP, warns to rename it, and only ever tightens. The old path `api contacts-list` stops
|
|
64
|
+
working. `api show` takes the path (quoted, `api show "contacts list"`), the old name or the operation id, and `api list` prints the path and the group.
|
|
65
|
+
A manifest without groups mounts flat, as before, so nothing changes until a CLI regenerates with groups and
|
|
66
|
+
releases the move as a breaking change.
|
|
67
|
+
- **Cancel, edit and send now a scheduled message: `messages scheduled cancel <chat> <scheduled-id...>`,
|
|
68
|
+
`messages scheduled edit <chat> <scheduled-id> [text] [--at-time <time>]` and
|
|
69
|
+
`messages scheduled send <chat> <scheduled-id...>`.** Before, a scheduled message could only be listed, and the
|
|
70
|
+
owner cancelled one in the app. A scheduled message has an id of its own: `messages edit` on it failed, and
|
|
71
|
+
`messages delete` with the same number would have deleted an old, sent message. Each command takes only the ids
|
|
72
|
+
`messages scheduled <chat>` lists and checks them against that list before anything changes; an unknown id is
|
|
73
|
+
`not_found` and points at the list. Cancelling counts and asks as a delete does (`--allow-dangerous` at an `ask`
|
|
74
|
+
level), sending now as a send. An edit with only `--at-time` keeps the text, and one with only the text keeps the
|
|
75
|
+
time. The keys are `messages.scheduled.cancel`, `.edit` and `.send`; the answers are the entities
|
|
76
|
+
`scheduled_cancellation`, `message_write` and `scheduled_send`. An adapter adds them through the optional port
|
|
77
|
+
group `ScheduledChanges` (`cancelScheduled`, `editScheduled`, `sendScheduled`); a messenger without it answers
|
|
78
|
+
"this messenger cannot …". Needs cli-base with `scheduled` as a resource word, for `cli-dev lint`.
|
|
79
|
+
|
|
80
|
+
### Fixed
|
|
81
|
+
|
|
82
|
+
- **The MCP command search ranks the shorter name first on a tie**, so "send message" finds `messages send` before
|
|
83
|
+
`messages scheduled send`.
|
|
84
|
+
|
|
8
85
|
## 0.705.0 — 19.11.2026
|
|
9
86
|
|
|
10
87
|
### Added
|
package/dist/cli/bot/api.d.ts
CHANGED
|
@@ -26,5 +26,13 @@ export interface ApiCommands {
|
|
|
26
26
|
/** An upload's file, `-` for stdin. */
|
|
27
27
|
readBytes?: (command: Command, path: string) => Uint8Array<ArrayBuffer>;
|
|
28
28
|
execute: (command: Command, operation: ManifestOperation, input: ApiCommandInput) => Promise<void>;
|
|
29
|
+
/** Called with each operation's command once it is built, before it is mounted. */
|
|
30
|
+
configure?: (command: Command, operation: ManifestOperation) => void;
|
|
29
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* The words after `api`: `contacts-list` in the group `contacts` is `contacts list`, `move-page` in `pages` keeps its
|
|
34
|
+
* name, and an operation without a group stays `api <command>`. The same rule as cli-base's `apiCommandPath`; `group`
|
|
35
|
+
* is read as optional, so a manifest generated before groups mounts flat, as it always did.
|
|
36
|
+
*/
|
|
37
|
+
export declare const apiPathOf: (operation: ManifestOperation) => string[];
|
|
30
38
|
export declare const generatedApiCommand: (api: ApiCommands) => Command;
|
package/dist/cli/bot/api.js
CHANGED
|
@@ -2,19 +2,32 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
3
|
import { Command, Option } from "commander";
|
|
4
4
|
import { secretInput } from "../../runs/run-context.js";
|
|
5
|
-
import { REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
5
|
+
import { NO_EFFECTS, REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
6
6
|
import { apiFlagOf, apiJson, apiOptionKey, graphqlVariables, readApiBody, readApiBytes, sendsBytes, } from "./api-input.js";
|
|
7
|
+
/**
|
|
8
|
+
* The words after `api`: `contacts-list` in the group `contacts` is `contacts list`, `move-page` in `pages` keeps its
|
|
9
|
+
* name, and an operation without a group stays `api <command>`. The same rule as cli-base's `apiCommandPath`; `group`
|
|
10
|
+
* is read as optional, so a manifest generated before groups mounts flat, as it always did.
|
|
11
|
+
*/
|
|
12
|
+
export const apiPathOf = (operation) => {
|
|
13
|
+
const { command, group } = operation;
|
|
14
|
+
if (!group)
|
|
15
|
+
return [command];
|
|
16
|
+
return [group, command.startsWith(`${group}-`) ? command.slice(group.length + 1) : command];
|
|
17
|
+
};
|
|
7
18
|
const scalarOf = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : undefined;
|
|
8
19
|
export const generatedApiCommand = (api) => {
|
|
9
20
|
const group = new Command("api").description(api.description ?? "every operation of the official Bot API, generated from its schema");
|
|
10
21
|
group.option("--store-token <profile>", "keep a returned authentication token only in this bot profile's OS keyring; never print it");
|
|
22
|
+
const subgroups = new Set();
|
|
11
23
|
for (const operation of api.operations) {
|
|
12
24
|
const binding = operation.binding.kind === "http"
|
|
13
25
|
? `${operation.binding.method} ${operation.binding.path}`
|
|
14
26
|
: operation.binding.kind === "graphql"
|
|
15
27
|
? `${operation.binding.operation} ${operation.binding.field}`
|
|
16
28
|
: operation.binding.name;
|
|
17
|
-
const
|
|
29
|
+
const path = apiPathOf(operation);
|
|
30
|
+
const command = annotate(new Command(path.at(-1)), {
|
|
18
31
|
effects: operation.effect === "read" ? REMOTE_READ : REMOTE_WRITE,
|
|
19
32
|
}).description(`${operation.summary ?? operation.id} — ${operation.effect} (${binding})`);
|
|
20
33
|
for (const parameter of operation.parameters) {
|
|
@@ -99,7 +112,22 @@ export const generatedApiCommand = (api) => {
|
|
|
99
112
|
input.body = body;
|
|
100
113
|
await api.execute(this, operation, input);
|
|
101
114
|
});
|
|
102
|
-
|
|
115
|
+
api.configure?.(command, operation);
|
|
116
|
+
const [first] = path;
|
|
117
|
+
const taken = group.commands.find((one) => one.name() === first);
|
|
118
|
+
// A command and a group of one name would put an operation under another's command, or answer with the wrong one.
|
|
119
|
+
if (taken && (path.length === 1 || !subgroups.has(taken)))
|
|
120
|
+
throw new CliError("configuration_error", `api ${first} is both a group and an operation: rename one`);
|
|
121
|
+
if (path.length === 1 || first === undefined) {
|
|
122
|
+
group.addCommand(command);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const subgroup = taken ?? annotate(new Command(first), { effects: NO_EFFECTS }).description(`the ${first} operations`);
|
|
126
|
+
if (!taken) {
|
|
127
|
+
subgroups.add(subgroup);
|
|
128
|
+
group.addCommand(subgroup);
|
|
129
|
+
}
|
|
130
|
+
subgroup.addCommand(command);
|
|
103
131
|
}
|
|
104
132
|
return group;
|
|
105
133
|
};
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export { registerLinkConversationsPrompt } from "../mcp/prompts.js";
|
|
|
22
22
|
export { agentBody, agentJson, agentResult, UNTRUSTED, UNTRUSTED_INSTRUCTION, UNTRUSTED_NEUTRAL } from "../mcp/text.js";
|
|
23
23
|
export { MEETING_RESULT_ENTITIES } from "../meetings/index.js";
|
|
24
24
|
export { type AppIdentity, envName, readOnlyLockOf, readOnlyRefusal } from "../ports/app.js";
|
|
25
|
-
export type { AccountEditing, AccountHealth, AccountRecords, AccountSettings, AccountStanding, AccountTools, After, BotChats, ChannelComments, ChatDeletion, ChatFolders, ChatReading, ContactBook, Download, ForumControl, ForumState, GroupAdmin, GroupModeration, HistoryBatch, HistoryBatchHandler, HistoryChatEvent, HistoryReaction, HistoryStar, HistoryVote, InviteLinks, JoinRequests, LiveUpdates, MessageButtons, MessageEditing, MessageMedia, MessagePermalinks, MessagePins, MessagePolls, MessageReactions, MessageSearch, MessageStars, MessengerAdapter, MessengerCore, NewPoll, OfficialStats, PassiveUpdates, PersonProfiles, ProfileChange, ProfilePhotos, PushedHistory, ReadState, RemoteFile, ScheduledMessages, SenderIdentities, SenderSearch, SendOptions, Sent, ServerQuery, ServerReads, ThreadAddressing, TopicEditing, TopicHistory, TopicReadState, Transcript, } from "../ports/messenger.js";
|
|
25
|
+
export type { AccountEditing, AccountHealth, AccountRecords, AccountSettings, AccountStanding, AccountTools, After, BotChats, ChannelComments, ChatDeletion, ChatFolders, ChatReading, ContactBook, Download, ForumControl, ForumState, GroupAdmin, GroupModeration, HistoryBatch, HistoryBatchHandler, HistoryChatEvent, HistoryReaction, HistoryStar, HistoryVote, InviteLinks, JoinRequests, LiveUpdates, MessageButtons, MessageEditing, MessageMedia, MessagePermalinks, MessagePins, MessagePolls, MessageReactions, MessageSearch, MessageStars, MessengerAdapter, MessengerCore, NewPoll, OfficialStats, PassiveUpdates, PersonProfiles, ProfileChange, ProfilePhotos, PushedHistory, ReadState, RemoteFile, ScheduledChanges, ScheduledMessages, SenderIdentities, SenderSearch, SendOptions, Sent, ServerQuery, ServerReads, ThreadAddressing, TopicEditing, TopicHistory, TopicReadState, Transcript, } from "../ports/messenger.js";
|
|
26
26
|
export type { Fetching, MediaOption, MessengerTraits } from "../ports/traits.js";
|
|
27
27
|
export { senderFacts } from "../replies/dry-run.js";
|
|
28
28
|
export { type ReplyRender, replyRenderer } from "../replies/rendering.js";
|
package/dist/cli/list-query.d.ts
CHANGED
|
@@ -59,10 +59,12 @@ export declare const queryTerms: (words: QueryWords, registry: QueryRegistry, co
|
|
|
59
59
|
* A `time` term as epoch ms bounds: `time>=7d`, `time:[2026-10-01 TO 2026-10-07]`, `time:today`, and the `meta`
|
|
60
60
|
* an answer reports them by: the zone calendar words and bare dates were read in, and the bounds in UTC.
|
|
61
61
|
* `until` is inclusive: an exclusive end (a bare date's next midnight, `… TO …}`) comes back 1 ms inside. `since` stays
|
|
62
|
-
* as written, because the inbox reads strictly after a `date>` start
|
|
62
|
+
* as written, because the inbox reads strictly after a `date>` start; `from` is the first moment taken, for a reader
|
|
63
|
+
* that takes its start.
|
|
63
64
|
*/
|
|
64
65
|
export declare const timeBounds: (term: Predicate | undefined, zone?: string, now?: number) => {
|
|
65
66
|
since?: number;
|
|
67
|
+
from?: number;
|
|
66
68
|
until?: number;
|
|
67
69
|
meta?: {
|
|
68
70
|
timezone: string;
|
package/dist/cli/list-query.js
CHANGED
|
@@ -169,7 +169,8 @@ export const queryTerms = (words, registry, command, ranged = []) => {
|
|
|
169
169
|
* A `time` term as epoch ms bounds: `time>=7d`, `time:[2026-10-01 TO 2026-10-07]`, `time:today`, and the `meta`
|
|
170
170
|
* an answer reports them by: the zone calendar words and bare dates were read in, and the bounds in UTC.
|
|
171
171
|
* `until` is inclusive: an exclusive end (a bare date's next midnight, `… TO …}`) comes back 1 ms inside. `since` stays
|
|
172
|
-
* as written, because the inbox reads strictly after a `date>` start
|
|
172
|
+
* as written, because the inbox reads strictly after a `date>` start; `from` is the first moment taken, for a reader
|
|
173
|
+
* that takes its start.
|
|
173
174
|
*/
|
|
174
175
|
export const timeBounds = (term, zone = timezoneOf(), now) => {
|
|
175
176
|
if (!term)
|
|
@@ -178,7 +179,9 @@ export const timeBounds = (term, zone = timezoneOf(), now) => {
|
|
|
178
179
|
const range = dateRange(term.value, upper, term.operator === "range" ? term.lower_inclusive !== false : true, term.operator === "range" ? term.upper_inclusive !== false : true, zone, term.span, now);
|
|
179
180
|
const until = range.upper === undefined ? undefined : range.upper - (range.upper_inclusive ? 0 : 1);
|
|
180
181
|
return {
|
|
181
|
-
...(range.lower === undefined
|
|
182
|
+
...(range.lower === undefined
|
|
183
|
+
? {}
|
|
184
|
+
: { since: range.lower, from: range.lower_inclusive ? range.lower : range.lower + 1 }),
|
|
182
185
|
...(until === undefined ? {} : { until }),
|
|
183
186
|
meta: {
|
|
184
187
|
timezone: zone,
|
|
@@ -22,6 +22,9 @@ export const COMMAND_NEEDS = {
|
|
|
22
22
|
"messages comments": ["comments", "read comments on a channel post"],
|
|
23
23
|
"messages pin": ["pin", "pin a message"],
|
|
24
24
|
"messages unpin": ["unpin", "unpin a message"],
|
|
25
|
+
"messages scheduled cancel": ["cancelScheduled", "cancel a scheduled message"],
|
|
26
|
+
"messages scheduled edit": ["editScheduled", "edit a scheduled message"],
|
|
27
|
+
"messages scheduled send": ["sendScheduled", "send a scheduled message now"],
|
|
25
28
|
};
|
|
26
29
|
/** The commands the store answers for a messenger whose history is pushed to it, so the method is not needed there. */
|
|
27
30
|
const STORE_ANSWERS = new Set(["chats events"]);
|
|
@@ -12,28 +12,33 @@ import { messengerContext } from "./context.js";
|
|
|
12
12
|
* question, and `--allow-dangerous` is the yes. For everyone only
|
|
13
13
|
* with `--for-everyone` (max-cli `NEED-239`), and never for an agent (NEED-1423).
|
|
14
14
|
*/
|
|
15
|
-
export const deleteCommand = (messenger) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
15
|
+
export const deleteCommand = (messenger) => {
|
|
16
|
+
const command = annotate(new Command("delete"), {
|
|
17
|
+
examples: [`${messenger.app.command} personal messages delete "Book club" 101`],
|
|
18
|
+
effects: REMOTE_WRITE,
|
|
19
|
+
output: { entity: "message_deletion" },
|
|
20
|
+
})
|
|
21
|
+
.description("delete messages for you only; with --for-everyone, for everyone in the chat")
|
|
22
|
+
.argument("<chat>", messenger.chatArgument)
|
|
23
|
+
.argument("<message...>", `the message ids, by spaces or commas, at most ${DELETE_AT_ONCE}`)
|
|
24
|
+
.addOption(ownerOnlyOption("--for-everyone", "delete for everyone in the chat, not only for you — they cannot get it back"))
|
|
25
|
+
.addOption(ownerOnlyOption("--allow-dangerous", "go ahead without the question an ask level puts before a deletion"))
|
|
26
|
+
.action(async function (chat, messages) {
|
|
27
|
+
const everyone = this.opts().forEveryone === true;
|
|
28
|
+
if (environmentOf(this).agent && (everyone || messenger.deleteForMe === false))
|
|
29
|
+
throw new CliError("permission_error", `${everyone ? "" : `${messenger.name ?? messenger.provider} deletes only for everyone, and `}an agent never ` +
|
|
30
|
+
`deletes for everyone — the owner can run \`${lineOf(this, "messages delete --for-everyone")}\``, { permission: "messages.delete", sent: false });
|
|
31
|
+
const ids = messages
|
|
32
|
+
.flatMap((one) => one.split(","))
|
|
33
|
+
.map((one) => one.trim())
|
|
34
|
+
.filter(Boolean);
|
|
35
|
+
if (ids.length === 0)
|
|
36
|
+
throw new CliError("validation_error", "no message id given — name the messages to delete", { sent: false });
|
|
37
|
+
const context = messengerContext(this, messenger);
|
|
38
|
+
const deleted = await context.withServices((services) => services.messages.delete({ chat, messages: ids, forEveryone: everyone }));
|
|
39
|
+
renderAnswer(this, context, itemOf(snakeKeys(deleted)));
|
|
40
|
+
});
|
|
41
|
+
if (messenger.scheduledSends !== false)
|
|
42
|
+
command.addHelpText("after", "\nA message waiting to be sent has an id of its own; cancel it with `messages scheduled cancel`.");
|
|
43
|
+
return command;
|
|
44
|
+
};
|
|
@@ -39,5 +39,7 @@ export const editCommand = (messenger) => {
|
|
|
39
39
|
});
|
|
40
40
|
if (messenger.html)
|
|
41
41
|
edit.option("--html", HTML_HELP);
|
|
42
|
+
if (messenger.scheduledSends !== false)
|
|
43
|
+
edit.addHelpText("after", "\nA message waiting to be sent has an id of its own; change it with `messages scheduled edit`.");
|
|
42
44
|
return edit;
|
|
43
45
|
};
|
|
@@ -1,19 +1,41 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
1
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
2
3
|
import { Command } from "commander";
|
|
4
|
+
import { sendTime } from "../../domain/send-time.js";
|
|
3
5
|
import { capability } from "../../ports/messenger.js";
|
|
4
6
|
import { renderMessages } from "../../render/messages.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
+
import { DELETE_AT_ONCE } from "../../services/index.js";
|
|
8
|
+
import { ownerOnlyOption, REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
9
|
+
import { itemOf, listOf, renderAnswer, snakeKeys } from "../envelope.js";
|
|
7
10
|
import { messengerContext } from "./context.js";
|
|
8
|
-
import { messageItems, selfOf, viewOf } from "./message-items.js";
|
|
11
|
+
import { messageItem, messageItems, selfOf, viewOf } from "./message-items.js";
|
|
12
|
+
import { afterWrite, writtenAnswer } from "./message-writes.js";
|
|
13
|
+
import { HTML_HELP } from "./messages-send-command.js";
|
|
14
|
+
import { readAll } from "./stdin.js";
|
|
15
|
+
const SCHEDULED_IDS = "the scheduled ids `messages scheduled <chat>` lists, by spaces or commas, " +
|
|
16
|
+
`at most ${DELETE_AT_ONCE}; never the id of a sent message`;
|
|
17
|
+
const SAME_NUMBER = "A scheduled message has an id of its own: the same number in the chat's history is another, sent message. " +
|
|
18
|
+
"Each id is checked against the scheduled list before anything changes.";
|
|
19
|
+
const idsOf = (typed) => {
|
|
20
|
+
const ids = typed
|
|
21
|
+
.flatMap((one) => one.split(","))
|
|
22
|
+
.map((one) => one.trim())
|
|
23
|
+
.filter(Boolean);
|
|
24
|
+
if (ids.length === 0)
|
|
25
|
+
throw new CliError("validation_error", "no scheduled id given — `messages scheduled <chat>` lists them", {
|
|
26
|
+
sent: false,
|
|
27
|
+
});
|
|
28
|
+
return ids;
|
|
29
|
+
};
|
|
9
30
|
/** Where to look after a scheduled send ended without an answer: repeating it would schedule a second one. */
|
|
10
31
|
export const scheduledCommand = (messenger) => {
|
|
11
32
|
const command = annotate(new Command("scheduled"), {
|
|
12
33
|
examples: [`${messenger.app.command} personal messages scheduled "Book club"`],
|
|
13
34
|
effects: REMOTE_READ,
|
|
14
35
|
})
|
|
15
|
-
.description("messages waiting to be sent later in a chat, soonest first
|
|
36
|
+
.description("messages waiting to be sent later in a chat, soonest first, with their scheduled ids")
|
|
16
37
|
.argument("<chat>", messenger.chatArgument)
|
|
38
|
+
.addHelpText("after", `\n${SAME_NUMBER}`)
|
|
17
39
|
.action(async function (chat) {
|
|
18
40
|
const context = messengerContext(this, messenger);
|
|
19
41
|
const { items, reader } = await context.withMessenger(async (connection) => ({
|
|
@@ -28,5 +50,89 @@ export const scheduledCommand = (messenger) => {
|
|
|
28
50
|
has_more: false,
|
|
29
51
|
}), () => renderMessages(items.map((one) => ({ ...one, timestamp: one.scheduledFor ?? one.timestamp })), viewOf(context, messenger)));
|
|
30
52
|
});
|
|
53
|
+
command.addCommand(cancelCommand(messenger));
|
|
54
|
+
command.addCommand(editCommand(messenger));
|
|
55
|
+
command.addCommand(sendNowCommand(messenger));
|
|
31
56
|
return annotate(command, { output: { entity: "message" } });
|
|
32
57
|
};
|
|
58
|
+
/** Nobody gets a cancelled message back, so it asks as a deletion does where the profile's level is `ask`. */
|
|
59
|
+
const cancelCommand = (messenger) => annotate(new Command("cancel"), {
|
|
60
|
+
examples: [`${messenger.app.command} personal messages scheduled cancel "Book club" 3`],
|
|
61
|
+
effects: REMOTE_WRITE,
|
|
62
|
+
output: { entity: "scheduled_cancellation" },
|
|
63
|
+
})
|
|
64
|
+
.description("cancel scheduled messages before they are sent; they cannot be got back")
|
|
65
|
+
.argument("<chat>", messenger.chatArgument)
|
|
66
|
+
.argument("<scheduled-id...>", SCHEDULED_IDS)
|
|
67
|
+
.addOption(ownerOnlyOption("--allow-dangerous", "go ahead without the question an ask level puts before a cancellation"))
|
|
68
|
+
.addHelpText("after", `\n${SAME_NUMBER}`)
|
|
69
|
+
.action(async function (chat, typed) {
|
|
70
|
+
const ids = idsOf(typed);
|
|
71
|
+
const context = messengerContext(this, messenger);
|
|
72
|
+
const cancelled = await context.withServices((services) => services.messages.cancelScheduled({ chat, ids }));
|
|
73
|
+
renderAnswer(this, context, itemOf(snakeKeys(cancelled)));
|
|
74
|
+
});
|
|
75
|
+
const editCommand = (messenger) => {
|
|
76
|
+
const edit = annotate(new Command("edit"), {
|
|
77
|
+
literal_after_dashes: true,
|
|
78
|
+
examples: [
|
|
79
|
+
`${messenger.app.command} personal messages scheduled edit "Book club" 3 "The meeting starts at 11."`,
|
|
80
|
+
`${messenger.app.command} personal messages scheduled edit "Book club" 3 --at-time 2026-12-01T09:00`,
|
|
81
|
+
],
|
|
82
|
+
effects: REMOTE_WRITE,
|
|
83
|
+
output: { entity: "message_write" },
|
|
84
|
+
})
|
|
85
|
+
.description("change the text or the time of a scheduled message before it is sent")
|
|
86
|
+
.argument("<chat>", messenger.chatArgument)
|
|
87
|
+
.argument("<scheduled-id>", "the scheduled id `messages scheduled <chat>` lists; never the id of a sent message")
|
|
88
|
+
.argument("[text]", "the new text; without it and without --at-time, read from stdin")
|
|
89
|
+
.option("--at-time <time>", "send it at this time instead: 2026-09-25T09:00 (local time), or 30m, 2h, 1d from now")
|
|
90
|
+
.option("--md", "read this messenger's Markdown; see its formatting guide for supported syntax")
|
|
91
|
+
.addHelpText("after", `\n${SAME_NUMBER}`)
|
|
92
|
+
.action(async function (chat, id, text) {
|
|
93
|
+
const context = messengerContext(this, messenger);
|
|
94
|
+
const { md: markdown, html, atTime } = this.opts();
|
|
95
|
+
const at = atTime === undefined ? undefined : sendTime(atTime);
|
|
96
|
+
const body = text ?? (at === undefined ? await readAll(context.stdin) : undefined);
|
|
97
|
+
if (body !== undefined && body.trim() === "")
|
|
98
|
+
throw new CliError("validation_error", "no new text — give it, pipe it in, or change only the time with --at-time");
|
|
99
|
+
const { edited, reader } = await context.withServices(async (services) => {
|
|
100
|
+
const edited = await services.messages.editScheduled({
|
|
101
|
+
chat,
|
|
102
|
+
id: id.trim(),
|
|
103
|
+
...(body === undefined ? {} : { text: body }),
|
|
104
|
+
...(markdown === true ? { markdown } : {}),
|
|
105
|
+
...(html === true ? { html } : {}),
|
|
106
|
+
...(at === undefined ? {} : { at }),
|
|
107
|
+
});
|
|
108
|
+
return afterWrite(edited, async () => ({ edited, reader: await services.messages.reader() }));
|
|
109
|
+
});
|
|
110
|
+
await afterWrite(edited, () => renderAnswer(this, context, writtenAnswer(edited, reader)));
|
|
111
|
+
});
|
|
112
|
+
if (messenger.html)
|
|
113
|
+
edit.option("--html", HTML_HELP);
|
|
114
|
+
return edit;
|
|
115
|
+
};
|
|
116
|
+
const sendNowCommand = (messenger) => annotate(new Command("send"), {
|
|
117
|
+
examples: [`${messenger.app.command} personal messages scheduled send "Book club" 3`],
|
|
118
|
+
effects: REMOTE_WRITE,
|
|
119
|
+
output: { entity: "scheduled_send" },
|
|
120
|
+
})
|
|
121
|
+
.description("deliver what is scheduled right away instead of at its time; each gets a new id")
|
|
122
|
+
.argument("<chat>", messenger.chatArgument)
|
|
123
|
+
.argument("<scheduled-id...>", SCHEDULED_IDS)
|
|
124
|
+
.addHelpText("after", `\n${SAME_NUMBER}`)
|
|
125
|
+
.action(async function (chat, typed) {
|
|
126
|
+
const ids = idsOf(typed);
|
|
127
|
+
const context = messengerContext(this, messenger);
|
|
128
|
+
const { done, reader } = await context.withServices(async (services) => {
|
|
129
|
+
const done = await services.messages.sendScheduled({ chat, ids });
|
|
130
|
+
return afterWrite(done, async () => ({ done, reader: await services.messages.reader() }));
|
|
131
|
+
});
|
|
132
|
+
await afterWrite(done, () => renderAnswer(this, context, itemOf({
|
|
133
|
+
operation_id: done.operationId,
|
|
134
|
+
chat_id: done.chatId,
|
|
135
|
+
sent: done.sent,
|
|
136
|
+
messages: done.messages.map((one) => messageItem(one, reader)),
|
|
137
|
+
})));
|
|
138
|
+
});
|
package/dist/cli/service-api.js
CHANGED
|
@@ -7,7 +7,7 @@ import { keyedGuard } from "../sends/keyed-guard.js";
|
|
|
7
7
|
import { levelFor } from "../sends/permissions.js";
|
|
8
8
|
import { newOperationId } from "../sends/send-id.js";
|
|
9
9
|
import { refusedPlace } from "../sends/upload.js";
|
|
10
|
-
import { generatedApiCommand } from "./bot/api.js";
|
|
10
|
+
import { apiPathOf, generatedApiCommand } from "./bot/api.js";
|
|
11
11
|
import { httpApiExchange, httpApiRequest, unsendableBody } from "./bot/api-http.js";
|
|
12
12
|
import { apiJson, checkApiBody, checkApiParameter, graphqlVariables, parseApiJson, readApiBody, readApiBytes, sendsBytes, } from "./bot/api-input.js";
|
|
13
13
|
import { baseContext, outputFor } from "./context.js";
|
|
@@ -34,7 +34,18 @@ export const serviceApiOperations = (manifest) => {
|
|
|
34
34
|
/** How far `--all` reads: a service that never stops paging must not run a command forever. */
|
|
35
35
|
const MOST_PAGES = 500;
|
|
36
36
|
const isObject = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
37
|
-
const keyOf = (operation) =>
|
|
37
|
+
const keyOf = (operation) => ["api", ...apiPathOf(operation)].join(".");
|
|
38
|
+
/** `contacts list`: what follows `api` on the command line. */
|
|
39
|
+
const pathOf = (operation) => apiPathOf(operation).join(" ");
|
|
40
|
+
/**
|
|
41
|
+
* The key a grouped operation had while `api` was flat, `api.contacts-list`. A profile that still names it keeps its
|
|
42
|
+
* hold on that one command: checked beside the new key, it only ever tightens. A group never takes an old command's
|
|
43
|
+
* name (the generator refuses it), so the old key never reaches past its command.
|
|
44
|
+
*/
|
|
45
|
+
const formerKeyOf = (operation) => {
|
|
46
|
+
const former = `api.${operation.command}`;
|
|
47
|
+
return former === keyOf(operation) ? undefined : former;
|
|
48
|
+
};
|
|
38
49
|
const permissionsOf = (operation) => operation.permissions ?? [];
|
|
39
50
|
/** By its method too: an override may have marked a DELETE as a plain write. */
|
|
40
51
|
const destructive = (operation) => operation.effect === "destructive" || (operation.binding.kind === "http" && operation.binding.method === "DELETE");
|
|
@@ -89,18 +100,28 @@ export const serviceApiKeys = (input, operation, call) => {
|
|
|
89
100
|
*/
|
|
90
101
|
export const serviceApiPermissions = (input) => {
|
|
91
102
|
const checks = new Map();
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
const former = [];
|
|
104
|
+
for (const operation of input.manifest.operations) {
|
|
105
|
+
const old = formerKeyOf(operation);
|
|
106
|
+
if (old)
|
|
107
|
+
former.push(old);
|
|
108
|
+
checks.set(pathOf(operation), [
|
|
94
109
|
...permissionsOf(operation).map((permission) => {
|
|
95
110
|
const when = whenOf(permission);
|
|
96
111
|
return when === undefined ? permission.key : { key: permission.key, when };
|
|
97
112
|
}),
|
|
98
113
|
...(input.bodyPermissions?.[operation.command] ?? []).map(({ key, when }) => ({ key, when })),
|
|
114
|
+
...(old ? [{ key: old, when: "while a profile still names this old key" }] : []),
|
|
99
115
|
]);
|
|
100
|
-
|
|
116
|
+
}
|
|
117
|
+
const keys = [
|
|
118
|
+
...new Set([...checks.values()]
|
|
119
|
+
.flat()
|
|
120
|
+
.flatMap((one) => (typeof one === "string" ? [one] : former.includes(one.key) ? [] : [one.key]))),
|
|
121
|
+
];
|
|
101
122
|
return {
|
|
102
|
-
extra: keys,
|
|
103
|
-
alsoChecks: (path) => (path[0] === "api"
|
|
123
|
+
extra: [...keys, ...former],
|
|
124
|
+
alsoChecks: (path) => (path[0] === "api" ? (checks.get(path.slice(1).join(" ")) ?? []) : []),
|
|
104
125
|
defaults: {
|
|
105
126
|
...Object.fromEntries(keys.map((key) => [key, "ask"])),
|
|
106
127
|
...Object.fromEntries(input.manifest.operations.filter(destructive).map((operation) => [keyOf(operation), "ask"])),
|
|
@@ -108,7 +129,8 @@ export const serviceApiPermissions = (input) => {
|
|
|
108
129
|
};
|
|
109
130
|
};
|
|
110
131
|
const rowOf = (operation) => ({
|
|
111
|
-
command: operation
|
|
132
|
+
command: pathOf(operation),
|
|
133
|
+
group: apiPathOf(operation).length > 1 ? apiPathOf(operation)[0] : null,
|
|
112
134
|
method: operation.binding.kind === "http" ? operation.binding.method : operation.binding.kind === "graphql" ? "POST" : "",
|
|
113
135
|
path: operation.binding.kind === "http"
|
|
114
136
|
? operation.binding.path
|
|
@@ -162,10 +184,11 @@ const serviceApiCore = (options) => {
|
|
|
162
184
|
...(options.failure ? { failure: options.failure } : {}),
|
|
163
185
|
});
|
|
164
186
|
const operationOf = (name) => {
|
|
165
|
-
const
|
|
187
|
+
const named = (one) => pathOf(one) === name || one.command === name || one.id === name;
|
|
188
|
+
const found = operations.find(named);
|
|
166
189
|
if (found)
|
|
167
190
|
return found;
|
|
168
|
-
const id = manifest.operations.find(
|
|
191
|
+
const id = manifest.operations.find(named)?.id ?? name;
|
|
169
192
|
const why = options.excluded?.find((one) => one.id === name) ?? left.find((one) => one.id === id);
|
|
170
193
|
throw new CliError("not_found", why
|
|
171
194
|
? `${name} is not offered: ${why.reason}`
|
|
@@ -228,11 +251,23 @@ const serviceApiCore = (options) => {
|
|
|
228
251
|
throw error;
|
|
229
252
|
}
|
|
230
253
|
};
|
|
231
|
-
|
|
254
|
+
/** The old flat key, when the profile names it: on a read only its refusal or its question applies. */
|
|
255
|
+
const formerKeys = (command, operation) => {
|
|
256
|
+
const former = formerKeyOf(operation);
|
|
257
|
+
if (!former)
|
|
258
|
+
return [];
|
|
259
|
+
const { settings, renderer } = baseContext(command, configuration.resolveSettings);
|
|
260
|
+
const level = settings.permissions[former];
|
|
261
|
+
if (level === undefined)
|
|
262
|
+
return [];
|
|
263
|
+
renderer.warn(`permissions name ${former}, the old key of api ${pathOf(operation)}: rename it to ${keyOf(operation)}`);
|
|
264
|
+
return operation.effect === "read" && level !== "deny" && level !== "ask" ? [] : [former];
|
|
265
|
+
};
|
|
266
|
+
return { operations, left, baseUrlOf, defaults, exchange, formerKeys, operationOf, readsFreely, signed, write };
|
|
232
267
|
};
|
|
233
268
|
export const serviceApiCommand = (options) => {
|
|
234
269
|
const { app, configuration } = options;
|
|
235
|
-
const { operations, baseUrlOf, exchange, operationOf, readsFreely, signed, write } = serviceApiCore(options);
|
|
270
|
+
const { operations, baseUrlOf, exchange, formerKeys, operationOf, readsFreely, signed, write } = serviceApiCore(options);
|
|
236
271
|
const send = async (command, operation, request) => (await exchange(command, operation, request)).answer;
|
|
237
272
|
let schemas;
|
|
238
273
|
const loaded = () => {
|
|
@@ -240,6 +275,9 @@ export const serviceApiCommand = (options) => {
|
|
|
240
275
|
throw new CliError("configuration_error", "the api schemas were not loaded before the command ran");
|
|
241
276
|
return schemas;
|
|
242
277
|
};
|
|
278
|
+
const load = async () => {
|
|
279
|
+
schemas ??= await options.schemas();
|
|
280
|
+
};
|
|
243
281
|
/** Every page, in one run; a next page outside the server's address is never sent the sign-in. */
|
|
244
282
|
const allPages = async (command, operation, input) => {
|
|
245
283
|
const pagination = operation.pagination;
|
|
@@ -281,7 +319,7 @@ export const serviceApiCommand = (options) => {
|
|
|
281
319
|
call = step.next.input;
|
|
282
320
|
}
|
|
283
321
|
});
|
|
284
|
-
renderAnswer(command, outputFor(command), listOf(`api ${operation
|
|
322
|
+
renderAnswer(command, outputFor(command), listOf(`api ${pathOf(operation)}`, { items, limit: items.length, has_more: false }));
|
|
285
323
|
};
|
|
286
324
|
const refuseOwnFiles = (command, path) => {
|
|
287
325
|
if (path === "-")
|
|
@@ -303,8 +341,13 @@ export const serviceApiCommand = (options) => {
|
|
|
303
341
|
refuseOwnFiles(command, path);
|
|
304
342
|
return readApiBytes(path);
|
|
305
343
|
},
|
|
344
|
+
configure: (command, operation) => {
|
|
345
|
+
if (operation.pagination && !operation.parameters.some(({ name }) => name === "all"))
|
|
346
|
+
command.option("--all", "read every page, as the API pages it");
|
|
347
|
+
command.hook("preAction", load);
|
|
348
|
+
},
|
|
306
349
|
execute: async (command, operation, input) => {
|
|
307
|
-
const extra = serviceApiKeys(options, operation, input);
|
|
350
|
+
const extra = [...serviceApiKeys(options, operation, input), ...formerKeys(command, operation)];
|
|
308
351
|
const read = readsFreely(command, operation, extra);
|
|
309
352
|
if (operation.pagination && command.opts().all === true) {
|
|
310
353
|
if (!read)
|
|
@@ -334,10 +377,12 @@ export const serviceApiCommand = (options) => {
|
|
|
334
377
|
});
|
|
335
378
|
const show = annotate(new Command("show"), {
|
|
336
379
|
effects: NO_EFFECTS,
|
|
337
|
-
examples: [
|
|
380
|
+
examples: [
|
|
381
|
+
`${app.command} api show ${operations[0] ? JSON.stringify(pathOf(operations[0])) : "<operation>"} --json`,
|
|
382
|
+
],
|
|
338
383
|
})
|
|
339
384
|
.description(`show one operation's parameters and request schema, without calling ${options.service}`)
|
|
340
|
-
.argument("<operation>", "the operation
|
|
385
|
+
.argument("<operation>", "the operation as api list prints it (quoted), its old name, or its operation id")
|
|
341
386
|
.action(async function (name) {
|
|
342
387
|
const operation = operationOf(name);
|
|
343
388
|
const definitions = await options.definitions();
|
|
@@ -346,15 +391,8 @@ export const serviceApiCommand = (options) => {
|
|
|
346
391
|
});
|
|
347
392
|
const group = annotate(new Command("api"), { effects: NO_EFFECTS }).description(`the raw ${options.service} API, one command per operation of its OpenAPI document`);
|
|
348
393
|
group.addCommand(list).addCommand(show);
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
};
|
|
352
|
-
for (const child of generated.commands) {
|
|
353
|
-
const operation = operations.find((one) => one.command === child.name());
|
|
354
|
-
if (operation?.pagination && !operation.parameters.some(({ name }) => name === "all"))
|
|
355
|
-
child.option("--all", "read every page, as the API pages it");
|
|
356
|
-
group.addCommand(child.hook("preAction", load));
|
|
357
|
-
}
|
|
394
|
+
for (const child of [...generated.commands])
|
|
395
|
+
group.addCommand(child);
|
|
358
396
|
return group;
|
|
359
397
|
};
|
|
360
398
|
// Code may pass a number, a boolean or a list where a person types text; the check reads the text it stands for.
|
|
@@ -375,7 +413,7 @@ const writerBody = (operation, input, schemas) => {
|
|
|
375
413
|
* can be asked. A read that no key guards goes through `serviceApiCall`.
|
|
376
414
|
*/
|
|
377
415
|
export const serviceApiWriter = (options) => {
|
|
378
|
-
const { baseUrlOf, operationOf, signed, write } = serviceApiCore(options);
|
|
416
|
+
const { baseUrlOf, formerKeys, operationOf, signed, write } = serviceApiCore(options);
|
|
379
417
|
return async (command, name, input, { confirmed } = {}) => {
|
|
380
418
|
const operation = operationOf(name);
|
|
381
419
|
// The api group offers only declared parameters; code must not reach further, as WordPress's `_method` turns a
|
|
@@ -401,6 +439,6 @@ export const serviceApiWriter = (options) => {
|
|
|
401
439
|
throw new CliError("validation_error", problem);
|
|
402
440
|
}
|
|
403
441
|
const request = await signed(command, operation, httpApiRequest(operation, writerBody(operation, input, schemas), baseUrlOf(command)));
|
|
404
|
-
return write(command, operation, extra, request, confirmed);
|
|
442
|
+
return write(command, operation, [...extra, ...formerKeys(command, operation)], request, confirmed);
|
|
405
443
|
};
|
|
406
444
|
};
|
|
@@ -37,7 +37,10 @@ export interface TokenSessionOptions {
|
|
|
37
37
|
login?: {
|
|
38
38
|
page?: (site: string | undefined) => string;
|
|
39
39
|
};
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Keeps the account a profile signed in to; by default only remembers it. A CLI that refuses a taken one says so.
|
|
42
|
+
* With `site`, `id` is `<site>:<id>`, the site as `--site` was cleaned.
|
|
43
|
+
*/
|
|
41
44
|
claim?: (env: NodeJS.ProcessEnv, profile: string, id: string, tokens: ProfileTokenStore) => void;
|
|
42
45
|
/** What the token is, for the prompt and help: "API token" when not given. */
|
|
43
46
|
token?: string;
|