@wirecat/cli-core 0.691.0 → 0.693.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 +62 -0
- package/README.md +141 -203
- package/dist/calendar/prepare.d.ts +11 -0
- package/dist/cli/bot/api-http.d.ts +4 -1
- package/dist/cli/bot/api-http.js +17 -4
- package/dist/cli/bot/api-input.d.ts +4 -0
- package/dist/cli/bot/api-input.js +9 -0
- package/dist/cli/bot/api.d.ts +4 -0
- package/dist/cli/bot/api.js +16 -2
- package/dist/cli/documents/folders.js +1 -1
- package/dist/cli/documents/search.js +3 -3
- package/dist/cli/documents/words.d.ts +2 -0
- package/dist/cli/documents/words.js +1 -0
- package/dist/cli/envelope.d.ts +22 -0
- package/dist/cli/index.d.ts +7 -4
- package/dist/cli/index.js +7 -4
- package/dist/cli/oauth-session.d.ts +60 -0
- package/dist/cli/oauth-session.js +224 -0
- package/dist/cli/service-api-call.d.ts +27 -0
- package/dist/cli/service-api-call.js +32 -0
- package/dist/cli/service-api-manifest.d.ts +14 -10
- package/dist/cli/service-api-manifest.js +38 -34
- package/dist/cli/service-api.d.ts +17 -2
- package/dist/cli/service-api.js +42 -24
- package/dist/cli/token-session.d.ts +33 -0
- package/dist/cli/token-session.js +121 -0
- package/dist/crm/index.d.ts +3 -0
- package/dist/crm/index.js +3 -0
- package/dist/crm/manifest/manifest.d.ts +195 -0
- package/dist/crm/manifest/manifest.js +161 -0
- package/dist/crm/manifest/map.d.ts +58 -0
- package/dist/crm/manifest/map.js +240 -0
- package/dist/crm/manifest/paths.d.ts +11 -0
- package/dist/crm/manifest/paths.js +161 -0
- package/dist/crm/manifest/source.d.ts +18 -0
- package/dist/crm/manifest/source.js +385 -0
- package/dist/errors/reasons.js +1 -0
- package/dist/manifest/index.d.ts +53 -0
- package/dist/manifest/index.js +61 -0
- package/package.json +8 -3
package/dist/cli/bot/api.js
CHANGED
|
@@ -3,7 +3,7 @@ import { annotate } from "@wirecat/cli-base/commands";
|
|
|
3
3
|
import { Command, Option } from "commander";
|
|
4
4
|
import { secretInput } from "../../runs/run-context.js";
|
|
5
5
|
import { REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
6
|
-
import { apiFlagOf, apiOptionKey, readApiBody } from "./api-input.js";
|
|
6
|
+
import { apiFlagOf, apiOptionKey, readApiBody, readApiBytes, sendsBytes } from "./api-input.js";
|
|
7
7
|
export const generatedApiCommand = (api) => {
|
|
8
8
|
const group = new Command("api").description(api.description ?? "every operation of the official Bot API, generated from its schema");
|
|
9
9
|
group.option("--store-token <profile>", "keep a returned authentication token only in this bot profile's OS keyring; never print it");
|
|
@@ -20,7 +20,10 @@ export const generatedApiCommand = (api) => {
|
|
|
20
20
|
const option = new Option(`--${apiFlagOf(parameter.name)} <value>`, parameter.description?.split("\n")[0] ?? parameter.name);
|
|
21
21
|
command.addOption(parameter.required && parameter.in !== "body" ? option.makeOptionMandatory() : option);
|
|
22
22
|
}
|
|
23
|
-
if (operation.request) {
|
|
23
|
+
if (operation.request && sendsBytes(operation)) {
|
|
24
|
+
command.option("--body-file <path>", `the file to upload, sent as ${operation.request.contentType}; - is stdin`);
|
|
25
|
+
}
|
|
26
|
+
else if (operation.request) {
|
|
24
27
|
// A field the schema marks secret may ride in an inline body, and the flags never see it.
|
|
25
28
|
command.addOption(secretInput(new Option("--body <json>", "the request body as JSON; - reads it from stdin")));
|
|
26
29
|
command.option("--body-file <path>", "the request body from a JSON file; - is stdin");
|
|
@@ -57,6 +60,17 @@ export const generatedApiCommand = (api) => {
|
|
|
57
60
|
target[parameter.name] = raw;
|
|
58
61
|
}
|
|
59
62
|
await api.before?.(this, operation);
|
|
63
|
+
if (sendsBytes(operation)) {
|
|
64
|
+
const path = options.bodyFile;
|
|
65
|
+
if (path === undefined && operation.request?.required)
|
|
66
|
+
throw new CliError("validation_error", `${operation.command} uploads a file: give --body-file <path>, or - for stdin`);
|
|
67
|
+
if (path !== undefined) {
|
|
68
|
+
input.bytes = (api.readBytes ?? ((_command, from) => readApiBytes(from)))(this, path);
|
|
69
|
+
input.bodySource = path === "-" ? "stdin" : "file";
|
|
70
|
+
}
|
|
71
|
+
await api.execute(this, operation, input);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
60
74
|
const text = (api.readBody ?? ((_command, body) => readApiBody(body)))(this, options);
|
|
61
75
|
if (options.body !== undefined)
|
|
62
76
|
input.bodySource = options.body === "-" ? "stdin" : "argument";
|
|
@@ -12,7 +12,7 @@ const addDocumentFolderCommandsDefinition = (program, helpers) => {
|
|
|
12
12
|
const folders = annotate(program.command("folders"), { effects: LOCAL_READ }).description(text.folders);
|
|
13
13
|
examples(annotate(folders.command("add"), { effects: FETCH })
|
|
14
14
|
.argument("<folder>", text.folderArgument)
|
|
15
|
-
.description("import a folder and everything under it on the next sync"), [`${prefix} folders add
|
|
15
|
+
.description("import a folder and everything under it on the next sync"), [`${prefix} folders add ${text.folderToAdd}`]).action(async (input) => {
|
|
16
16
|
const { id, name } = await helpers.add(input);
|
|
17
17
|
output(itemOf({ id, name, added: true }));
|
|
18
18
|
});
|
|
@@ -3,12 +3,12 @@ import { honoursDryRun } from "../dry-run-guard.js";
|
|
|
3
3
|
import { LOCAL_READ } from "../effects.js";
|
|
4
4
|
import { itemOf } from "../envelope.js";
|
|
5
5
|
import { examples, positive, wordsOf } from "./words.js";
|
|
6
|
-
const notImported = (app, { profile, chosen, documents }) => {
|
|
6
|
+
const notImported = (app, folder, { profile, chosen, documents }) => {
|
|
7
7
|
if (documents > 0)
|
|
8
8
|
return undefined;
|
|
9
9
|
return !chosen
|
|
10
10
|
? `profile ${profile} has no folders selected, so nothing is imported to search — ` +
|
|
11
|
-
`${app} ${profile} folders add
|
|
11
|
+
`${app} ${profile} folders add ${folder}, then ${app} ${profile} sync`
|
|
12
12
|
: `profile ${profile} has imported no documents yet — ${app} ${profile} sync`;
|
|
13
13
|
};
|
|
14
14
|
const addDocumentSearchCommandDefinition = (program, helpers) => {
|
|
@@ -26,7 +26,7 @@ const addDocumentSearchCommandDefinition = (program, helpers) => {
|
|
|
26
26
|
offset: (page - 1) * args.limit,
|
|
27
27
|
exact: args.exact ?? false,
|
|
28
28
|
});
|
|
29
|
-
const hint = notImported(wording.app, helpers.imported());
|
|
29
|
+
const hint = notImported(wording.app, wording.text.folderToAdd, helpers.imported());
|
|
30
30
|
helpers.output(itemOf(hint ? { ...result, not_imported: hint } : result));
|
|
31
31
|
});
|
|
32
32
|
};
|
|
@@ -27,6 +27,8 @@ export interface DocumentTexts {
|
|
|
27
27
|
treeArgument: string;
|
|
28
28
|
folders: string;
|
|
29
29
|
folderArgument: string;
|
|
30
|
+
/** What `folders add` takes in examples and hints: `FOLDER_ID`, or a path for a CLI that adds by path. */
|
|
31
|
+
folderToAdd: string;
|
|
30
32
|
syncLimit: string;
|
|
31
33
|
identities: string;
|
|
32
34
|
identitiesList: string;
|
|
@@ -21,6 +21,7 @@ export const wordsOf = (words) => {
|
|
|
21
21
|
treeArgument: `${provider} folder id or URL; defaults to the explicitly selected profile's roots`,
|
|
22
22
|
folders: `choose the ${place} folders that sync imports`,
|
|
23
23
|
folderArgument: `folder id or ${place} URL`,
|
|
24
|
+
folderToAdd: "FOLDER_ID",
|
|
24
25
|
syncLimit: `how many documents to read from ${provider} in this run`,
|
|
25
26
|
identities: `the ${provider} accounts seen on a document, and the people they belong to`,
|
|
26
27
|
identitiesList: `list the people ${provider} shows for a document`,
|
package/dist/cli/envelope.d.ts
CHANGED
|
@@ -115,6 +115,17 @@ export declare const answerSchema: (item?: v.GenericSchema) => v.UnionSchema<[v.
|
|
|
115
115
|
}, undefined>, undefined>;
|
|
116
116
|
readonly ms: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
117
117
|
}, undefined>, undefined>;
|
|
118
|
+
readonly query: v.OptionalSchema<v.StrictObjectSchema<{
|
|
119
|
+
readonly chat: v.OptionalSchema<v.StrictObjectSchema<{
|
|
120
|
+
readonly word: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
121
|
+
readonly chat_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
122
|
+
readonly title: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>;
|
|
123
|
+
}, undefined>, undefined>;
|
|
124
|
+
readonly respelled: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
125
|
+
readonly word: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
126
|
+
readonly tried: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
127
|
+
}, undefined>, undefined>, undefined>;
|
|
128
|
+
}, undefined>, undefined>;
|
|
118
129
|
}, undefined>;
|
|
119
130
|
}, undefined>, v.StrictObjectSchema<{
|
|
120
131
|
readonly item: v.GenericSchema;
|
|
@@ -184,6 +195,17 @@ export declare const answerSchema: (item?: v.GenericSchema) => v.UnionSchema<[v.
|
|
|
184
195
|
}, undefined>, undefined>;
|
|
185
196
|
readonly ms: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
186
197
|
}, undefined>, undefined>;
|
|
198
|
+
readonly query: v.OptionalSchema<v.StrictObjectSchema<{
|
|
199
|
+
readonly chat: v.OptionalSchema<v.StrictObjectSchema<{
|
|
200
|
+
readonly word: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
201
|
+
readonly chat_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
202
|
+
readonly title: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>;
|
|
203
|
+
}, undefined>, undefined>;
|
|
204
|
+
readonly respelled: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
205
|
+
readonly word: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
206
|
+
readonly tried: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
207
|
+
}, undefined>, undefined>, undefined>;
|
|
208
|
+
}, undefined>, undefined>;
|
|
187
209
|
}, undefined>;
|
|
188
210
|
}, undefined>], undefined>;
|
|
189
211
|
/**
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -60,8 +60,8 @@ export { askBeforeWrite } from "./ask-before-write.js";
|
|
|
60
60
|
export { actorOf } from "./author.js";
|
|
61
61
|
export { type BaseStagesCommandOptions, baseStagesCommand } from "./base-stages-command.js";
|
|
62
62
|
export type { ApiCommandInput, ApiCommands } from "./bot/api.js";
|
|
63
|
-
export { type HttpApiExecutorOptions, type HttpApiRequest, httpApiExecutor, httpApiRequest } from "./bot/api-http.js";
|
|
64
|
-
export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, } from "./bot/api-input.js";
|
|
63
|
+
export { type HttpApiExecutorOptions, type HttpApiRequest, httpApiExecutor, httpApiRequest, unsendableBody, } from "./bot/api-http.js";
|
|
64
|
+
export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, readApiBytes, sendsBytes, } from "./bot/api-input.js";
|
|
65
65
|
export { prepareRpcApiBody, type RpcApiBody } from "./bot/api-rpc.js";
|
|
66
66
|
export { type BotContext, botContext, botWords } from "./bot/context.js";
|
|
67
67
|
export { type BotCopy, botCopy } from "./bot/copy.js";
|
|
@@ -140,6 +140,7 @@ export { type Saving, stored } from "./messenger/stored.js";
|
|
|
140
140
|
export { dateOrNone } from "./messenger/tasks-command.js";
|
|
141
141
|
export { MODEL_CATALOGUE_QUERY, type ModelCatalogueOptions } from "./model-catalogue-command.js";
|
|
142
142
|
export { writeNewFile } from "./new-file.js";
|
|
143
|
+
export { type OAuthEnvironment, type OAuthPreset, type OAuthPresetOptions, type OAuthSessionOptions, oauthFlowOf, oauthPreset, oauthSessionCommand, } from "./oauth-session.js";
|
|
143
144
|
export { pagingOf, positiveCount, window, withPaging } from "./paging.js";
|
|
144
145
|
export { type CommandPermissions, type ConditionalKey, commandPathKey, commandPermissions, knownBeside, knownPermissionKeys, type PermissionKeyOf, type PermissionKeySource, refuseUnknownPermissionKeys, unknownPermissionIssues, unknownPermissionKeys, } from "./permission-keys.js";
|
|
145
146
|
export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, runGroup, takesProfile, usableProfileName, } from "./profile.js";
|
|
@@ -152,8 +153,9 @@ export { fieldsOf, projectFields } from "./result-fields.js";
|
|
|
152
153
|
export { HARNESSES, type Harness, harnessesOn, harnessInfo, harnessOfArgv, isHarness, reportsCost, } from "./schedule/harnesses.js";
|
|
153
154
|
export { type AgentScheduleSpec, agentSchedule, backfillScheduleRun, pauseSchedule, removeSchedule, runScheduleNow, SCHEDULE_SETTINGS, type ScheduleHost, type ScheduleLimits, type ScheduleSite, scheduleLimitsOf, scheduleState, slotsOfAt, writeSchedule, } from "./schedule/schedule-command.js";
|
|
154
155
|
export { deniedKinds, deniedKindsOf, type LeftOut, type SearchedKind } from "./search-left-out.js";
|
|
155
|
-
export { type BodyPermission, type ServiceApiOptions, type ServiceApiPermissionsInput, serviceApiKeys, serviceApiPermissions, } from "./service-api.js";
|
|
156
|
-
export {
|
|
156
|
+
export { type BodyPermission, type ServiceApiOptions, type ServiceApiPermissionsInput, serviceApiKeys, serviceApiOperations, serviceApiPermissions, } from "./service-api.js";
|
|
157
|
+
export { type ServiceApiCall, type ServiceApiCallOptions, serviceApiCall } from "./service-api-call.js";
|
|
158
|
+
export { manifestBaseUrl, type ServiceApiManifest, signRequest } from "./service-api-manifest.js";
|
|
157
159
|
export { type DeclaredSetting, type SettingRow, settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
158
160
|
export { type Config, type Configuration, count, first, flag, fromFile, type GlobalFlags, NONE_NAMED, namedProfile, type ProfileKind, plain, type ResolveOptions, type Settings, type SettingsExtension, type SettingsExtensionContext, type Source, settingsFor, } from "./settings.js";
|
|
159
161
|
export { type PermissionAnswer, readSetupAnswers, type SetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
|
@@ -165,4 +167,5 @@ export { type StoreInfo, sharedStoreCommand, storeInfo, storeInfoCommand } from
|
|
|
165
167
|
export { type RecoveryCheck, type RecoveryRun, recoveryNotes, storeRecoverCommand, storeRecoveryCheck, storeRecoveryRun, } from "./store-recover.js";
|
|
166
168
|
export { changeStoreSetting, isStoreSetting, STORE_SETTINGS, storeSettings } from "./store-settings.js";
|
|
167
169
|
export type { TemplatesOptions } from "./templates-command.js";
|
|
170
|
+
export { type TokenSessionOptions, tokenSessionCommand } from "./token-session.js";
|
|
168
171
|
export { restartServers, type UpgradeContext } from "./upgrade-command.js";
|
package/dist/cli/index.js
CHANGED
|
@@ -53,8 +53,8 @@ export { openAppStore } from "./app-store.js";
|
|
|
53
53
|
export { askBeforeWrite } from "./ask-before-write.js";
|
|
54
54
|
export { actorOf } from "./author.js";
|
|
55
55
|
export { baseStagesCommand } from "./base-stages-command.js";
|
|
56
|
-
export { httpApiExecutor, httpApiRequest } from "./bot/api-http.js";
|
|
57
|
-
export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, } from "./bot/api-input.js";
|
|
56
|
+
export { httpApiExecutor, httpApiRequest, unsendableBody, } from "./bot/api-http.js";
|
|
57
|
+
export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, readApiBytes, sendsBytes, } from "./bot/api-input.js";
|
|
58
58
|
export { prepareRpcApiBody } from "./bot/api-rpc.js";
|
|
59
59
|
export { botContext, botWords } from "./bot/context.js";
|
|
60
60
|
export { botCopy } from "./bot/copy.js";
|
|
@@ -129,6 +129,7 @@ export { stored } from "./messenger/stored.js";
|
|
|
129
129
|
export { dateOrNone } from "./messenger/tasks-command.js";
|
|
130
130
|
export { MODEL_CATALOGUE_QUERY } from "./model-catalogue-command.js";
|
|
131
131
|
export { writeNewFile } from "./new-file.js";
|
|
132
|
+
export { oauthFlowOf, oauthPreset, oauthSessionCommand, } from "./oauth-session.js";
|
|
132
133
|
export { pagingOf, positiveCount, window, withPaging } from "./paging.js";
|
|
133
134
|
export { commandPathKey, commandPermissions, knownBeside, knownPermissionKeys, refuseUnknownPermissionKeys, unknownPermissionIssues, unknownPermissionKeys, } from "./permission-keys.js";
|
|
134
135
|
export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, runGroup, takesProfile, usableProfileName, } from "./profile.js";
|
|
@@ -141,8 +142,9 @@ export { fieldsOf, projectFields } from "./result-fields.js";
|
|
|
141
142
|
export { HARNESSES, harnessesOn, harnessInfo, harnessOfArgv, isHarness, reportsCost, } from "./schedule/harnesses.js";
|
|
142
143
|
export { agentSchedule, backfillScheduleRun, pauseSchedule, removeSchedule, runScheduleNow, SCHEDULE_SETTINGS, scheduleLimitsOf, scheduleState, slotsOfAt, writeSchedule, } from "./schedule/schedule-command.js";
|
|
143
144
|
export { deniedKinds, deniedKindsOf } from "./search-left-out.js";
|
|
144
|
-
export { serviceApiKeys, serviceApiPermissions, } from "./service-api.js";
|
|
145
|
-
export {
|
|
145
|
+
export { serviceApiKeys, serviceApiOperations, serviceApiPermissions, } from "./service-api.js";
|
|
146
|
+
export { serviceApiCall } from "./service-api-call.js";
|
|
147
|
+
export { manifestBaseUrl, signRequest } from "./service-api-manifest.js";
|
|
146
148
|
export { settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
147
149
|
export { count, first, flag, fromFile, NONE_NAMED, namedProfile, plain, settingsFor, } from "./settings.js";
|
|
148
150
|
export { readSetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
|
@@ -153,4 +155,5 @@ export { runnable, withSafety } from "./steps.js";
|
|
|
153
155
|
export { sharedStoreCommand, storeInfo, storeInfoCommand } from "./store-info.js";
|
|
154
156
|
export { recoveryNotes, storeRecoverCommand, storeRecoveryCheck, storeRecoveryRun, } from "./store-recover.js";
|
|
155
157
|
export { changeStoreSetting, isStoreSetting, STORE_SETTINGS, storeSettings } from "./store-settings.js";
|
|
158
|
+
export { tokenSessionCommand } from "./token-session.js";
|
|
156
159
|
export { restartServers } from "./upgrade-command.js";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { OAuthFlow } from "@wirecat/cli-base/codegen";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import type { OAuthClient, OAuthProvider } from "../oauth/provider.js";
|
|
4
|
+
import type { AppIdentity } from "../ports/app.js";
|
|
5
|
+
import type { EventSink } from "../runs/events.js";
|
|
6
|
+
import { type BaseEnvironment } from "./context.js";
|
|
7
|
+
import type { ServiceApiManifest } from "./service-api-manifest.js";
|
|
8
|
+
import type { GlobalFlags, ResolveOptions, Settings } from "./settings.js";
|
|
9
|
+
/** The authorization code flow an OpenAPI spec declares; a GraphQL service (Linear) writes the same object by hand. */
|
|
10
|
+
export declare const oauthFlowOf: (manifest: ServiceApiManifest, scheme?: string) => OAuthFlow;
|
|
11
|
+
export interface OAuthPresetOptions {
|
|
12
|
+
/** A short word, part of the keyring account: `attio`. */
|
|
13
|
+
id: string;
|
|
14
|
+
/** The name people know: `Attio`. */
|
|
15
|
+
name: string;
|
|
16
|
+
client: OAuthClient;
|
|
17
|
+
/** What the CLI asks for; each must be one the flow lists. */
|
|
18
|
+
scopes: readonly string[];
|
|
19
|
+
/** The spec cannot say which redirect the app registered; a provider that wants an exact one needs `relay`. */
|
|
20
|
+
redirect: OAuthProvider["redirect"];
|
|
21
|
+
revokeUrl?: string;
|
|
22
|
+
authorizeParams?: Record<string, string>;
|
|
23
|
+
/** The provider sends a new refresh token on each refresh; a run with moved folders then never refreshes. */
|
|
24
|
+
rotating?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface OAuthPreset {
|
|
27
|
+
provider: OAuthProvider;
|
|
28
|
+
scopes: readonly string[];
|
|
29
|
+
rotating: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** An installed app's sign-in (authorization code with PKCE) from the flow a spec declares, and the scopes it asks. */
|
|
32
|
+
export declare const oauthPreset: (flow: OAuthFlow, options: OAuthPresetOptions) => OAuthPreset;
|
|
33
|
+
/** What the CLI's entry hands `run()` beside cli-core's own; a test hands a fake service and browser. */
|
|
34
|
+
export interface OAuthEnvironment extends BaseEnvironment {
|
|
35
|
+
fetch?: typeof fetch;
|
|
36
|
+
/** Gets the command, so the entry opens nothing under `--json`, `--no-input`, CI or without a terminal. */
|
|
37
|
+
openBrowser?: (url: string, command?: Command) => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export interface OAuthSessionOptions {
|
|
40
|
+
app: AppIdentity;
|
|
41
|
+
resolveSettings: (flags: GlobalFlags, options?: ResolveOptions) => Settings;
|
|
42
|
+
/** The preset's `id` and `name`: `session list` and `status` read the sign-in without choosing a client. */
|
|
43
|
+
providerId: string;
|
|
44
|
+
service: string;
|
|
45
|
+
/** From `oauthPreset`; the client is the CLI's own choice (a flag, a variable, the config, WireCat's app). */
|
|
46
|
+
preset: (command: Command) => OAuthPreset;
|
|
47
|
+
/** Asks the service whose the access token is; `id` names the account, `account` is what start and status show. */
|
|
48
|
+
verify: (command: Command, accessToken: string, events: EventSink) => Promise<{
|
|
49
|
+
id: string;
|
|
50
|
+
account: Readonly<Record<string, unknown>>;
|
|
51
|
+
}>;
|
|
52
|
+
/** Runs before anything is saved; by default only remembers the account. A CLI that refuses a taken one throws. */
|
|
53
|
+
claim?: (env: NodeJS.ProcessEnv, profile: string, id: string) => void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* `session start | status | end | list` for a service signed in in the browser (WC-SECR-22): PKCE on the loopback,
|
|
57
|
+
* the account checked before the tokens are kept, refreshes under one lock, and a run with moved folders that never
|
|
58
|
+
* removes the owner's sign-in.
|
|
59
|
+
*/
|
|
60
|
+
export declare const oauthSessionCommand: (options: OAuthSessionOptions) => Command;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { CliError, isMovedRun, resolvePaths, systemKeyring } from "@wirecat/cli-base";
|
|
2
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
|
+
import { hostFetch } from "@wirecat/cli-base/http";
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { tokenKeeper } from "../oauth/keeper.js";
|
|
6
|
+
import { credentialStorage, oauthAccount, standardCodec } from "../oauth/storage.js";
|
|
7
|
+
import { editDistance } from "../search/correct.js";
|
|
8
|
+
import { signInSteps } from "../terminal/sign-in-steps.js";
|
|
9
|
+
import { baseContext, environmentOf, outputFor } from "./context.js";
|
|
10
|
+
import { refuseOffline } from "./early-refusal.js";
|
|
11
|
+
import { LOCAL_READ, LOCAL_WRITE, logsInOrOut, REMOTE_READ, REMOTE_WRITE } from "./effects.js";
|
|
12
|
+
import { itemOf, listOf, renderAnswer } from "./envelope.js";
|
|
13
|
+
import { profilesHere, rememberAccount } from "./messenger/accounts.js";
|
|
14
|
+
import { commandWords, profileFree, refuseCommandName, rootOf } from "./profile.js";
|
|
15
|
+
import { storageOf } from "./token-session.js";
|
|
16
|
+
/** The authorization code flow an OpenAPI spec declares; a GraphQL service (Linear) writes the same object by hand. */
|
|
17
|
+
export const oauthFlowOf = (manifest, scheme) => {
|
|
18
|
+
const schemes = Object.entries(manifest.securitySchemes ?? {}).filter(([name, one]) => (scheme === undefined || name === scheme) && one.flows?.authorizationCode !== undefined);
|
|
19
|
+
const flow = schemes.length === 1 ? schemes[0]?.[1].flows?.authorizationCode : undefined;
|
|
20
|
+
if (!flow?.authorizationUrl || !flow.tokenUrl)
|
|
21
|
+
throw new CliError("configuration_error", schemes.length > 1
|
|
22
|
+
? `the api has ${schemes.length} OAuth sign-ins in the browser; name one`
|
|
23
|
+
: `the api declares no OAuth authorization code flow with its URLs${scheme ? ` under ${scheme}` : ""}`);
|
|
24
|
+
return flow;
|
|
25
|
+
};
|
|
26
|
+
/** An installed app's sign-in (authorization code with PKCE) from the flow a spec declares, and the scopes it asks. */
|
|
27
|
+
export const oauthPreset = (flow, options) => {
|
|
28
|
+
const known = Object.keys(flow.scopes);
|
|
29
|
+
const unknown = options.scopes.filter((scope) => !known.includes(scope));
|
|
30
|
+
if (unknown.length)
|
|
31
|
+
throw new CliError("configuration_error", unknown
|
|
32
|
+
.map((scope) => {
|
|
33
|
+
const near = known.find((one) => editDistance(scope, one, 2) <= 2);
|
|
34
|
+
return `the ${options.name} sign-in has no scope ${scope}${near ? `; did you mean ${near}?` : ""}`;
|
|
35
|
+
})
|
|
36
|
+
.join("; "));
|
|
37
|
+
if (flow.refreshUrl && flow.refreshUrl !== flow.tokenUrl)
|
|
38
|
+
throw new CliError("configuration_error", `${options.name} refreshes at another URL, which the sign-in cannot use`);
|
|
39
|
+
const plain = [flow.authorizationUrl, flow.tokenUrl, options.revokeUrl].find((url) => url !== undefined && !url.startsWith("https://"));
|
|
40
|
+
// The code, the client secret and the tokens would cross the network in the clear.
|
|
41
|
+
if (plain)
|
|
42
|
+
throw new CliError("configuration_error", `${options.name} signs in at ${plain}, which is not https`);
|
|
43
|
+
const provider = {
|
|
44
|
+
id: options.id,
|
|
45
|
+
name: options.name,
|
|
46
|
+
authorizeUrl: flow.authorizationUrl,
|
|
47
|
+
tokenUrl: flow.tokenUrl,
|
|
48
|
+
client: options.client,
|
|
49
|
+
redirect: options.redirect,
|
|
50
|
+
...(options.revokeUrl ? { revokeUrl: options.revokeUrl } : {}),
|
|
51
|
+
...(options.authorizeParams ? { authorizeParams: options.authorizeParams } : {}),
|
|
52
|
+
};
|
|
53
|
+
return { provider, scopes: [...options.scopes], rotating: options.rotating === true };
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* `session start | status | end | list` for a service signed in in the browser (WC-SECR-22): PKCE on the loopback,
|
|
57
|
+
* the account checked before the tokens are kept, refreshes under one lock, and a run with moved folders that never
|
|
58
|
+
* removes the owner's sign-in.
|
|
59
|
+
*/
|
|
60
|
+
export const oauthSessionCommand = (options) => {
|
|
61
|
+
const { app, providerId, service } = options;
|
|
62
|
+
const pathsOf = (env) => ({ appName: app.appName, prefix: app.envPrefix, env });
|
|
63
|
+
const storageFor = (where, profile, storage = "auto", rotating = false) => credentialStorage({
|
|
64
|
+
credentials: {
|
|
65
|
+
service: app.appName,
|
|
66
|
+
configDir: resolvePaths(pathsOf(where.env)).config,
|
|
67
|
+
storage,
|
|
68
|
+
env: where.env,
|
|
69
|
+
isolated: isMovedRun(pathsOf(where.env)),
|
|
70
|
+
keyring: where.keyring ?? systemKeyring,
|
|
71
|
+
...(where.warn ? { warn: where.warn } : {}),
|
|
72
|
+
},
|
|
73
|
+
account: oauthAccount(providerId, profile),
|
|
74
|
+
codec: rotating ? { ...standardCodec(providerId), rotating: true } : standardCodec(providerId),
|
|
75
|
+
});
|
|
76
|
+
const contextOf = (command) => {
|
|
77
|
+
const base = baseContext(command, options.resolveSettings);
|
|
78
|
+
const environment = environmentOf(command);
|
|
79
|
+
const where = { env: base.env, keyring: base.keyring, warn: base.renderer.warn };
|
|
80
|
+
const { profile } = base.settings;
|
|
81
|
+
/** The preset is asked only here, after the refusals: a CLI's client choice may fail on its own. */
|
|
82
|
+
const keeperOf = (storage) => {
|
|
83
|
+
const { provider, scopes, rotating } = options.preset(command);
|
|
84
|
+
const keeper = tokenKeeper({
|
|
85
|
+
provider,
|
|
86
|
+
storage: storageFor(where, profile, storage ?? "auto", rotating),
|
|
87
|
+
lockDir: resolvePaths(pathsOf(base.env)).config,
|
|
88
|
+
// Only the provider's own sign-in hosts: a token request never reaches anything else.
|
|
89
|
+
fetch: environment.fetch ??
|
|
90
|
+
hostFetch({
|
|
91
|
+
hosts: [provider.authorizeUrl, provider.tokenUrl, provider.revokeUrl]
|
|
92
|
+
.filter((url) => url !== undefined)
|
|
93
|
+
.map((url) => new URL(url).hostname),
|
|
94
|
+
}),
|
|
95
|
+
signInCommand: `${app.command} ${profile} session start`,
|
|
96
|
+
...(environment.signal ? { signal: environment.signal } : {}),
|
|
97
|
+
});
|
|
98
|
+
return { keeper, scopes };
|
|
99
|
+
};
|
|
100
|
+
const saved = () => storageFor(where, profile).read();
|
|
101
|
+
return { ...base, environment, where, profile, keeperOf, saved };
|
|
102
|
+
};
|
|
103
|
+
const answer = (command, item) => renderAnswer(command, outputFor(command), itemOf(item));
|
|
104
|
+
const start = logsInOrOut(annotate(new Command("start"), {
|
|
105
|
+
effects: REMOTE_WRITE,
|
|
106
|
+
lifetime: "interactive",
|
|
107
|
+
mcp: false,
|
|
108
|
+
examples: [`${app.command} personal session start`, `${app.command} personal session start --no-browser`],
|
|
109
|
+
}))
|
|
110
|
+
.summary(`sign in to ${service} in the browser`)
|
|
111
|
+
.description(`sign this profile in to ${service} in the browser; the account is checked before anything is kept, in the ` +
|
|
112
|
+
"keyring or, with --credential-storage file, a private file")
|
|
113
|
+
.option("--no-browser", "print the sign-in URL instead of opening a browser")
|
|
114
|
+
.option("--credential-storage <storage>", "where the sign-in is kept: keyring, which falls back to a private file by itself, or file", storageOf, "keyring")
|
|
115
|
+
.action(async function (args) {
|
|
116
|
+
const context = contextOf(this);
|
|
117
|
+
refuseCommandName(context.profile, commandWords(rootOf(this)), app.command);
|
|
118
|
+
refuseOffline(this, service);
|
|
119
|
+
const { keeper, scopes: asked } = context.keeperOf(args.credentialStorage === "file" ? "file" : undefined);
|
|
120
|
+
const { streams } = outputFor(this);
|
|
121
|
+
const steps = signInSteps({
|
|
122
|
+
diagnostic: (line) => streams.diagnostic(`${line}\n`),
|
|
123
|
+
json: context.format !== "pretty" || context.environment.tty === false,
|
|
124
|
+
answers: false,
|
|
125
|
+
});
|
|
126
|
+
let shown = {};
|
|
127
|
+
const { scopes } = await context.run((events) => keeper.signIn({
|
|
128
|
+
scopes: asked,
|
|
129
|
+
openBrowser: async (url) => {
|
|
130
|
+
if (args.browser)
|
|
131
|
+
await context.environment.openBrowser?.(url, this);
|
|
132
|
+
},
|
|
133
|
+
showUrl: (url) => {
|
|
134
|
+
steps.openUrl(url, `Sign in to ${service} and allow access`);
|
|
135
|
+
streams.diagnostic(`Open ${service} sign-in: ${url}\n`);
|
|
136
|
+
},
|
|
137
|
+
// Before anything is saved, so a refused account leaves the profile's sign-in as it was.
|
|
138
|
+
accept: async (tokens) => {
|
|
139
|
+
if (!tokens.accessToken)
|
|
140
|
+
throw new CliError("authentication_error", `${service} returned no access token`);
|
|
141
|
+
const { id, account } = await options.verify(this, tokens.accessToken, events);
|
|
142
|
+
(options.claim ?? ((env, profile, key) => rememberAccount(app, profile, key, env)))(context.env, context.profile, id);
|
|
143
|
+
shown = account;
|
|
144
|
+
return undefined;
|
|
145
|
+
},
|
|
146
|
+
}));
|
|
147
|
+
// The owner chose the file: an older keyring copy must not outlive it with a live refresh token.
|
|
148
|
+
if (args.credentialStorage === "file")
|
|
149
|
+
try {
|
|
150
|
+
storageFor(context.where, context.profile, "keyring").remove();
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// No keyring on this computer: there is no copy to forget.
|
|
154
|
+
}
|
|
155
|
+
answer(this, { ...shown, profile: context.profile, signed_in: true, scopes });
|
|
156
|
+
});
|
|
157
|
+
const status = annotate(new Command("status"), {
|
|
158
|
+
effects: REMOTE_READ,
|
|
159
|
+
examples: [`${app.command} personal session status`, `${app.command} personal session status --check --json`],
|
|
160
|
+
})
|
|
161
|
+
.summary("show this profile's sign-in; tokens are never printed")
|
|
162
|
+
.description(`show this profile's sign-in and its scopes, never a token; --check asks ${service} whose it is`)
|
|
163
|
+
.option("--check", `ask ${service} whether the sign-in still works, and whose it is`)
|
|
164
|
+
.action(async function (args) {
|
|
165
|
+
const context = contextOf(this);
|
|
166
|
+
const saved = context.saved();
|
|
167
|
+
if (!saved)
|
|
168
|
+
return answer(this, { profile: context.profile, state: "missing", verified: false });
|
|
169
|
+
const state = { profile: context.profile, state: "saved", scopes: saved.tokens.scopes };
|
|
170
|
+
if (!args.check)
|
|
171
|
+
return answer(this, { ...state, verified: false });
|
|
172
|
+
refuseOffline(this, service);
|
|
173
|
+
const { keeper } = context.keeperOf();
|
|
174
|
+
const { account } = await context.run(async (events) => options.verify(this, await keeper.accessToken(), events));
|
|
175
|
+
answer(this, { ...account, ...state, verified: true });
|
|
176
|
+
});
|
|
177
|
+
const end = logsInOrOut(annotate(new Command("end"), {
|
|
178
|
+
effects: LOCAL_WRITE,
|
|
179
|
+
mcp: false,
|
|
180
|
+
examples: [`${app.command} personal session end`],
|
|
181
|
+
}))
|
|
182
|
+
.summary("sign this profile out on this computer")
|
|
183
|
+
.description(`forget this profile's sign-in on this computer; the grant stays in ${service}, and a run with moved folders ` +
|
|
184
|
+
"never removes the owner's sign-in")
|
|
185
|
+
.action(async function () {
|
|
186
|
+
const context = contextOf(this);
|
|
187
|
+
if (!context.saved())
|
|
188
|
+
return answer(this, { profile: context.profile, ended: false });
|
|
189
|
+
const { removed } = await context.keeperOf().keeper.signOut();
|
|
190
|
+
if (!context.saved())
|
|
191
|
+
return answer(this, { profile: context.profile, ended: true, removed });
|
|
192
|
+
answer(this, {
|
|
193
|
+
profile: context.profile,
|
|
194
|
+
ended: false,
|
|
195
|
+
removed,
|
|
196
|
+
why: isMovedRun(pathsOf(context.env))
|
|
197
|
+
? "this run has moved folders: the owner's sign-in in the system keyring stays, and this run still reads it"
|
|
198
|
+
: "the sign-in could not be removed from the keyring",
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
const list = profileFree(annotate(new Command("list"), {
|
|
202
|
+
effects: LOCAL_READ,
|
|
203
|
+
examples: [`${app.command} session list`, `${app.command} session list --json`],
|
|
204
|
+
}))
|
|
205
|
+
.summary("list the profiles here and whether each is signed in")
|
|
206
|
+
.description("list the profiles on this computer and whether each is signed in; picks none")
|
|
207
|
+
.action(function () {
|
|
208
|
+
const environment = environmentOf(this);
|
|
209
|
+
const env = environment.env ?? process.env;
|
|
210
|
+
const { configuredProfiles } = options.resolveSettings({}, { env, needsProfile: false });
|
|
211
|
+
const where = { env, keyring: environment.keyring, warn: outputFor(this).renderer.warn };
|
|
212
|
+
const items = profilesHere(app, configuredProfiles, env).map((profile) => ({
|
|
213
|
+
profile,
|
|
214
|
+
signed_in: storageFor(where, profile).read() !== undefined,
|
|
215
|
+
}));
|
|
216
|
+
renderAnswer(this, outputFor(this), listOf("session list", { items, limit: Math.max(1, items.length), has_more: false }));
|
|
217
|
+
});
|
|
218
|
+
return annotate(new Command("session"), { effects: LOCAL_READ })
|
|
219
|
+
.description(`sign in to ${service} in the browser and manage this profile's sign-in`)
|
|
220
|
+
.addCommand(start)
|
|
221
|
+
.addCommand(status)
|
|
222
|
+
.addCommand(end)
|
|
223
|
+
.addCommand(list);
|
|
224
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ManifestOperation } from "@wirecat/cli-base/codegen";
|
|
2
|
+
import type { FetchLike } from "@wirecat/cli-base/http";
|
|
3
|
+
import type { ApiCommandInput } from "./bot/api.js";
|
|
4
|
+
import { type HttpApiSendOptions } from "./bot/api-http.js";
|
|
5
|
+
import { type ServiceApiManifest } from "./service-api-manifest.js";
|
|
6
|
+
/** One operation of the generated manifest, by its id, sent with the sign-in its security scheme names. */
|
|
7
|
+
export type ServiceApiCall = (operation: string, input: ApiCommandInput) => Promise<unknown>;
|
|
8
|
+
export interface ServiceApiCallOptions {
|
|
9
|
+
manifest: ServiceApiManifest;
|
|
10
|
+
/** The service's name in messages: "HubSpot". */
|
|
11
|
+
service: string;
|
|
12
|
+
/** The host-checked fetch with the CLI's pace and retry of reads, as the `api` group gets it. */
|
|
13
|
+
fetch: FetchLike;
|
|
14
|
+
/** Left out, for a CLI without sign-in, no call carries one. */
|
|
15
|
+
token?: () => string | Promise<string>;
|
|
16
|
+
/** In place of the manifest's first server. */
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
/** Headers beside the sign-in, such as the API version. */
|
|
19
|
+
headers?: (operation: ManifestOperation) => Record<string, string>;
|
|
20
|
+
failure?: HttpApiSendOptions["failure"];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The `api` group's request path for code that is not a command, such as a source read from a manifest: the same
|
|
24
|
+
* request building, sign-in header, redirect rule, run record and refusals as `serviceApiCommand`, without a guard. It
|
|
25
|
+
* sends reads only; a write goes through the `api` group, where the profile's guard asks.
|
|
26
|
+
*/
|
|
27
|
+
export declare const serviceApiCall: (options: ServiceApiCallOptions) => ServiceApiCall;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { httpApiRequest, httpApiSend } from "./bot/api-http.js";
|
|
4
|
+
import { manifestBaseUrl, signRequest } from "./service-api-manifest.js";
|
|
5
|
+
// The run record and the fetch are the only things httpApiSend asks a command for, and a sync has no command of its own.
|
|
6
|
+
const NO_COMMAND = new Command("source");
|
|
7
|
+
/**
|
|
8
|
+
* The `api` group's request path for code that is not a command, such as a source read from a manifest: the same
|
|
9
|
+
* request building, sign-in header, redirect rule, run record and refusals as `serviceApiCommand`, without a guard. It
|
|
10
|
+
* sends reads only; a write goes through the `api` group, where the profile's guard asks.
|
|
11
|
+
*/
|
|
12
|
+
export const serviceApiCall = (options) => {
|
|
13
|
+
const baseUrl = manifestBaseUrl(options.manifest, options.baseUrl);
|
|
14
|
+
const operations = new Map(options.manifest.operations.map((one) => [one.id, one]));
|
|
15
|
+
const send = httpApiSend({ service: options.service, fetch: () => options.fetch, failure: options.failure });
|
|
16
|
+
return async (id, input) => {
|
|
17
|
+
const operation = operations.get(id);
|
|
18
|
+
if (!operation)
|
|
19
|
+
throw new CliError("configuration_error", `no ${options.service} API operation ${id}`);
|
|
20
|
+
if (operation.effect !== "read")
|
|
21
|
+
throw new CliError("configuration_error", `${operation.command} is not a read; a source only reads`);
|
|
22
|
+
const request = httpApiRequest(operation, input, baseUrl);
|
|
23
|
+
const extra = Object.entries(options.headers?.(operation) ?? {});
|
|
24
|
+
for (const [name, value] of extra)
|
|
25
|
+
request.headers.set(name, value);
|
|
26
|
+
await signRequest(options.manifest, operation, request, options.token);
|
|
27
|
+
// A redirect to another host drops only the standard sign-in headers; a hook's header would go along.
|
|
28
|
+
if (extra.length)
|
|
29
|
+
request.redirect = "manual";
|
|
30
|
+
return send(NO_COMMAND, operation, request);
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ApiServer, type ManifestOperation, type Pagination, type SecurityRequirement, type SecurityScheme } from "@wirecat/cli-base/codegen";
|
|
2
2
|
import type { ApiCommandInput } from "./bot/api.js";
|
|
3
3
|
/** What `generate` writes into a CLI's `generated/manifest.ts`: `import * as manifest from "./generated/manifest.js"`. */
|
|
4
4
|
export interface ServiceApiManifest {
|
|
@@ -12,20 +12,25 @@ export interface ServiceApiManifest {
|
|
|
12
12
|
* free one (`{subdomain}`) names the owner's own host, which the default would send the token past.
|
|
13
13
|
*/
|
|
14
14
|
export declare const manifestBaseUrl: (manifest: ServiceApiManifest, given?: string) => string;
|
|
15
|
-
type Auth = {
|
|
16
|
-
name: string;
|
|
17
|
-
value: (token: string) => string;
|
|
18
|
-
};
|
|
19
15
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
16
|
+
* Signs one request for its operation. Set the final URL first: a key in the query goes into it. Anything but the
|
|
17
|
+
* standard sign-in header, or a key in the query, never follows a redirect, even to the same host: another host would
|
|
18
|
+
* get the key. The URL then holds the key, so a fetch wrapper must not log it. Without `token`, for a CLI that never
|
|
19
|
+
* signs in, nothing is added.
|
|
23
20
|
*/
|
|
24
|
-
export declare const
|
|
21
|
+
export declare const signRequest: (manifest: ServiceApiManifest, operation: ManifestOperation, request: {
|
|
22
|
+
url: URL;
|
|
23
|
+
headers: Headers;
|
|
24
|
+
redirect?: "follow" | "manual" | "error";
|
|
25
|
+
}, token: (() => Promise<string> | string) | undefined) => Promise<void>;
|
|
25
26
|
export declare const parameterValue: (input: ApiCommandInput, parameter: {
|
|
26
27
|
in: "query" | "body";
|
|
27
28
|
name: string;
|
|
28
29
|
}) => unknown;
|
|
30
|
+
export declare const withValue: (input: ApiCommandInput, parameter: {
|
|
31
|
+
in: "query" | "body";
|
|
32
|
+
name: string;
|
|
33
|
+
}, value: string | number) => ApiCommandInput;
|
|
29
34
|
/** One page's items, and how to ask for the next: new flags, the next page's whole URL, or `undefined` at the end. */
|
|
30
35
|
export interface PageStep {
|
|
31
36
|
items: readonly unknown[];
|
|
@@ -37,4 +42,3 @@ export interface PageStep {
|
|
|
37
42
|
}
|
|
38
43
|
/** Reads one answer by the manifest's pagination: where its items are and what the next request is. */
|
|
39
44
|
export declare const nextPage: (pagination: Pagination, input: ApiCommandInput, answer: unknown) => PageStep;
|
|
40
|
-
export {};
|