@sendmux/cli 1.0.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/README.md +26 -0
- package/bin/run.js +5 -0
- package/dist/base-command.d.ts +25 -0
- package/dist/base-command.d.ts.map +1 -0
- package/dist/base-command.js +93 -0
- package/dist/commands/mailbox/folders/list.d.ts +24 -0
- package/dist/commands/mailbox/folders/list.d.ts.map +1 -0
- package/dist/commands/mailbox/folders/list.js +6 -0
- package/dist/commands/mailbox/me/get.d.ts +21 -0
- package/dist/commands/mailbox/me/get.d.ts.map +1 -0
- package/dist/commands/mailbox/me/get.js +6 -0
- package/dist/commands/mailbox/messages/get.d.ts +24 -0
- package/dist/commands/mailbox/messages/get.d.ts.map +1 -0
- package/dist/commands/mailbox/messages/get.js +6 -0
- package/dist/commands/mailbox/messages/list.d.ts +87 -0
- package/dist/commands/mailbox/messages/list.d.ts.map +1 -0
- package/dist/commands/mailbox/messages/list.js +6 -0
- package/dist/commands/management/domains/get.d.ts +24 -0
- package/dist/commands/management/domains/get.d.ts.map +1 -0
- package/dist/commands/management/domains/get.js +6 -0
- package/dist/commands/management/domains/list.d.ts +24 -0
- package/dist/commands/management/domains/list.d.ts.map +1 -0
- package/dist/commands/management/domains/list.js +6 -0
- package/dist/commands/management/mailboxes/list.d.ts +27 -0
- package/dist/commands/management/mailboxes/list.d.ts.map +1 -0
- package/dist/commands/management/mailboxes/list.js +6 -0
- package/dist/commands/management/providers/list.d.ts +30 -0
- package/dist/commands/management/providers/list.d.ts.map +1 -0
- package/dist/commands/management/providers/list.js +6 -0
- package/dist/commands/profiles/list.d.ts +9 -0
- package/dist/commands/profiles/list.d.ts.map +1 -0
- package/dist/commands/profiles/list.js +28 -0
- package/dist/commands/profiles/set.d.ts +14 -0
- package/dist/commands/profiles/set.d.ts.map +1 -0
- package/dist/commands/profiles/set.js +57 -0
- package/dist/commands/profiles/show.d.ts +9 -0
- package/dist/commands/profiles/show.d.ts.map +1 -0
- package/dist/commands/profiles/show.js +36 -0
- package/dist/commands/sending/send/batch.d.ts +21 -0
- package/dist/commands/sending/send/batch.d.ts.map +1 -0
- package/dist/commands/sending/send/batch.js +6 -0
- package/dist/commands/sending/send.d.ts +21 -0
- package/dist/commands/sending/send.d.ts.map +1 -0
- package/dist/commands/sending/send.js +6 -0
- package/dist/generated/operations.d.ts +2340 -0
- package/dist/generated/operations.d.ts.map +1 -0
- package/dist/generated/operations.js +2511 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/key-kind.d.ts +4 -0
- package/dist/key-kind.d.ts.map +1 -0
- package/dist/key-kind.js +15 -0
- package/dist/operation-command.d.ts +18 -0
- package/dist/operation-command.d.ts.map +1 -0
- package/dist/operation-command.js +11 -0
- package/dist/operation-flags.d.ts +33 -0
- package/dist/operation-flags.d.ts.map +1 -0
- package/dist/operation-flags.js +103 -0
- package/dist/operation-runner.d.ts +5 -0
- package/dist/operation-runner.d.ts.map +1 -0
- package/dist/operation-runner.js +45 -0
- package/dist/operation-types.d.ts +19 -0
- package/dist/operation-types.d.ts.map +1 -0
- package/dist/operation-types.js +1 -0
- package/dist/profiles.d.ts +12 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +35 -0
- package/oclif.manifest.json +1546 -0
- package/package.json +60 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-kind.d.ts","sourceRoot":"","sources":["../src/key-kind.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;AAE5C,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAU1D;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMjD"}
|
package/dist/key-kind.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function inferApiKeyKind(apiKey) {
|
|
2
|
+
if (apiKey.startsWith("smx_root_")) {
|
|
3
|
+
return "root";
|
|
4
|
+
}
|
|
5
|
+
if (apiKey.startsWith("smx_mbx_")) {
|
|
6
|
+
return "mailbox";
|
|
7
|
+
}
|
|
8
|
+
throw new Error("Sendmux API keys must start with smx_root_ or smx_mbx_");
|
|
9
|
+
}
|
|
10
|
+
export function maskApiKey(apiKey) {
|
|
11
|
+
if (apiKey.length <= 16) {
|
|
12
|
+
return "********";
|
|
13
|
+
}
|
|
14
|
+
return `${apiKey.slice(0, 9)}...${apiKey.slice(-4)}`;
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SendmuxCommand } from "./base-command.js";
|
|
2
|
+
export declare abstract class OperationCommand extends SendmuxCommand {
|
|
3
|
+
static flags: {
|
|
4
|
+
body: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
5
|
+
"body-file": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
header: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
"idempotency-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
"if-match": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
"if-none-match": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
path: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
query: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
"api-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
"base-url": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<unknown>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=operation-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-command.d.ts","sourceRoot":"","sources":["../src/operation-command.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMnD,8BAAsB,gBAAiB,SAAQ,cAAc;IAC3D,MAAM,CAAC,KAAK;;;;;;;;;;;;MAAkB;IAExB,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;CAK9B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { operationFlags } from "./operation-flags.js";
|
|
2
|
+
import { runSdkOperation } from "./operation-runner.js";
|
|
3
|
+
import { SendmuxCommand } from "./base-command.js";
|
|
4
|
+
export class OperationCommand extends SendmuxCommand {
|
|
5
|
+
static flags = operationFlags;
|
|
6
|
+
async run() {
|
|
7
|
+
const constructor = this.constructor;
|
|
8
|
+
const { flags } = await this.parse(constructor);
|
|
9
|
+
return runSdkOperation(this, constructor.operation, flags);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type AuthFlags, type SendmuxCommand } from "./base-command.js";
|
|
2
|
+
import type { OperationDefinition } from "./operation-types.js";
|
|
3
|
+
export interface OperationFlags extends AuthFlags {
|
|
4
|
+
body?: string;
|
|
5
|
+
"body-file"?: string;
|
|
6
|
+
header?: string[];
|
|
7
|
+
"idempotency-key"?: string;
|
|
8
|
+
"if-match"?: string;
|
|
9
|
+
"if-none-match"?: string;
|
|
10
|
+
path?: string[];
|
|
11
|
+
query?: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface ParsedOperationOptions {
|
|
14
|
+
body?: unknown;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
path?: Record<string, string>;
|
|
17
|
+
query?: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
export declare const operationFlags: {
|
|
20
|
+
body: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
"body-file": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
header: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
"idempotency-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
"if-match": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
"if-none-match": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
+
path: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
+
query: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
|
+
"api-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
|
+
"base-url": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
31
|
+
};
|
|
32
|
+
export declare function parseOperationOptions(command: SendmuxCommand, operation: OperationDefinition, flags: OperationFlags): Promise<ParsedOperationOptions>;
|
|
33
|
+
//# sourceMappingURL=operation-flags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-flags.d.ts","sourceRoot":"","sources":["../src/operation-flags.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;CA6B1B,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,sBAAsB,CAAC,CAgCjC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Flags } from "@oclif/core";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { authFlags, } from "./base-command.js";
|
|
4
|
+
export const operationFlags = {
|
|
5
|
+
...authFlags,
|
|
6
|
+
body: Flags.string({
|
|
7
|
+
description: "JSON request body for POST, PUT, and PATCH operations.",
|
|
8
|
+
}),
|
|
9
|
+
"body-file": Flags.string({
|
|
10
|
+
description: "Path to a JSON request body file.",
|
|
11
|
+
}),
|
|
12
|
+
header: Flags.string({
|
|
13
|
+
description: "Header as name=value. Repeat for multiple headers.",
|
|
14
|
+
multiple: true,
|
|
15
|
+
}),
|
|
16
|
+
"idempotency-key": Flags.string({
|
|
17
|
+
description: "Set the Idempotency-Key header.",
|
|
18
|
+
}),
|
|
19
|
+
"if-match": Flags.string({
|
|
20
|
+
description: "Set the If-Match header.",
|
|
21
|
+
}),
|
|
22
|
+
"if-none-match": Flags.string({
|
|
23
|
+
description: "Set the If-None-Match header.",
|
|
24
|
+
}),
|
|
25
|
+
path: Flags.string({
|
|
26
|
+
description: "Path parameter as name=value. Repeat for multiple path parameters.",
|
|
27
|
+
multiple: true,
|
|
28
|
+
}),
|
|
29
|
+
query: Flags.string({
|
|
30
|
+
description: "Query parameter as name=value. Repeat for multiple query parameters.",
|
|
31
|
+
multiple: true,
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
export async function parseOperationOptions(command, operation, flags) {
|
|
35
|
+
const path = parsePairs(flags.path ?? [], "--path");
|
|
36
|
+
for (const parameter of operation.pathParams) {
|
|
37
|
+
if (parameter.required && !path[parameter.name]) {
|
|
38
|
+
command.error(`Missing path parameter "${parameter.name}". Pass --path ${parameter.name}=<value>.`, {
|
|
39
|
+
exit: 2,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const query = parsePairs(flags.query ?? [], "--query");
|
|
44
|
+
const headers = parsePairs(flags.header ?? [], "--header");
|
|
45
|
+
if (flags["idempotency-key"]) {
|
|
46
|
+
headers["Idempotency-Key"] = flags["idempotency-key"];
|
|
47
|
+
}
|
|
48
|
+
if (flags["if-match"]) {
|
|
49
|
+
headers["If-Match"] = flags["if-match"];
|
|
50
|
+
}
|
|
51
|
+
if (flags["if-none-match"]) {
|
|
52
|
+
headers["If-None-Match"] = flags["if-none-match"];
|
|
53
|
+
}
|
|
54
|
+
const body = await parseBody(command, operation, flags);
|
|
55
|
+
return dropEmpty({
|
|
56
|
+
body,
|
|
57
|
+
headers,
|
|
58
|
+
path,
|
|
59
|
+
query,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function parsePairs(values, flagName) {
|
|
63
|
+
const pairs = {};
|
|
64
|
+
for (const value of values) {
|
|
65
|
+
const separator = value.indexOf("=");
|
|
66
|
+
if (separator <= 0) {
|
|
67
|
+
throw new Error(`${flagName} values must use name=value syntax`);
|
|
68
|
+
}
|
|
69
|
+
pairs[value.slice(0, separator)] = value.slice(separator + 1);
|
|
70
|
+
}
|
|
71
|
+
return pairs;
|
|
72
|
+
}
|
|
73
|
+
async function parseBody(command, operation, flags) {
|
|
74
|
+
if (flags.body && flags["body-file"]) {
|
|
75
|
+
command.error("Pass only one of --body or --body-file.", { exit: 2 });
|
|
76
|
+
}
|
|
77
|
+
const raw = flags["body-file"] ? await readFile(flags["body-file"], "utf8") : flags.body;
|
|
78
|
+
if (!raw) {
|
|
79
|
+
if (operation.requestBodyRequired) {
|
|
80
|
+
command.error("This command requires a JSON body. Pass --body or --body-file.", { exit: 2 });
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
return JSON.parse(raw);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
command.error("Request body must be valid JSON.", { exit: 2 });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function dropEmpty(options) {
|
|
92
|
+
const next = {};
|
|
93
|
+
for (const [key, value] of Object.entries(options)) {
|
|
94
|
+
if (value === undefined) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
next[key] = value;
|
|
101
|
+
}
|
|
102
|
+
return next;
|
|
103
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SendmuxCommand } from "./base-command.js";
|
|
2
|
+
import { type OperationFlags } from "./operation-flags.js";
|
|
3
|
+
import type { OperationDefinition } from "./operation-types.js";
|
|
4
|
+
export declare function runSdkOperation(command: SendmuxCommand, operation: OperationDefinition, flags: OperationFlags): Promise<unknown>;
|
|
5
|
+
//# sourceMappingURL=operation-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-runner.d.ts","sourceRoot":"","sources":["../src/operation-runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAoBhE,wBAAsB,eAAe,CACnC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,OAAO,CAAC,CAelB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as sdk from "@sendmux/sdk";
|
|
2
|
+
import { parseOperationOptions, } from "./operation-flags.js";
|
|
3
|
+
const surfaceModules = {
|
|
4
|
+
mailbox: sdk.mailbox,
|
|
5
|
+
management: sdk.management,
|
|
6
|
+
sending: sdk.sending,
|
|
7
|
+
};
|
|
8
|
+
const clientFactories = {
|
|
9
|
+
mailbox: sdk.mailbox.createMailboxClient,
|
|
10
|
+
management: sdk.management.createManagementClient,
|
|
11
|
+
sending: sdk.sending.createSendingClient,
|
|
12
|
+
};
|
|
13
|
+
export async function runSdkOperation(command, operation, flags) {
|
|
14
|
+
const auth = await command.resolveAuth(flags, operation.requiredKeyKind);
|
|
15
|
+
const clientConfig = {
|
|
16
|
+
apiKey: auth.apiKey,
|
|
17
|
+
...(auth.baseUrl ? { baseUrl: auth.baseUrl } : {}),
|
|
18
|
+
};
|
|
19
|
+
const client = clientFactories[operation.surface](clientConfig);
|
|
20
|
+
const operationOptions = await parseOperationOptions(command, operation, flags);
|
|
21
|
+
const sdkOperation = operationFor(operation);
|
|
22
|
+
const response = await sdkOperation({
|
|
23
|
+
client,
|
|
24
|
+
...operationOptions,
|
|
25
|
+
});
|
|
26
|
+
return command.renderResult(rawEnvelope(response));
|
|
27
|
+
}
|
|
28
|
+
function operationFor(operation) {
|
|
29
|
+
const module = surfaceModules[operation.surface];
|
|
30
|
+
const sdkOperation = module[operation.operationId];
|
|
31
|
+
if (typeof sdkOperation !== "function") {
|
|
32
|
+
throw new Error(`SDK operation ${operation.operationId} is not exported by @sendmux/sdk`);
|
|
33
|
+
}
|
|
34
|
+
return sdkOperation;
|
|
35
|
+
}
|
|
36
|
+
function rawEnvelope(value) {
|
|
37
|
+
if (!value || typeof value !== "object" || !("data" in value)) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
const data = value.data;
|
|
41
|
+
if (!data || typeof data !== "object" || !("ok" in data)) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ApiKeyKind } from "./key-kind.js";
|
|
2
|
+
export interface OperationParameter {
|
|
3
|
+
name: string;
|
|
4
|
+
required: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface OperationDefinition {
|
|
7
|
+
command: string;
|
|
8
|
+
description: string;
|
|
9
|
+
headerParams: readonly OperationParameter[];
|
|
10
|
+
method: string;
|
|
11
|
+
operationId: string;
|
|
12
|
+
path: string;
|
|
13
|
+
pathParams: readonly OperationParameter[];
|
|
14
|
+
queryParams: readonly OperationParameter[];
|
|
15
|
+
requestBodyRequired: boolean;
|
|
16
|
+
requiredKeyKind: ApiKeyKind;
|
|
17
|
+
surface: "mailbox" | "management" | "sending";
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=operation-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-types.d.ts","sourceRoot":"","sources":["../src/operation-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAC1C,WAAW,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAC3C,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,UAAU,CAAC;IAC5B,OAAO,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;CAC/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface CliProfile {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface CliConfig {
|
|
6
|
+
defaultProfile?: string;
|
|
7
|
+
profiles: Record<string, CliProfile>;
|
|
8
|
+
}
|
|
9
|
+
export declare function readCliConfig(configDir: string): Promise<CliConfig>;
|
|
10
|
+
export declare function writeCliConfig(configDir: string, config: CliConfig): Promise<void>;
|
|
11
|
+
export declare function configPath(configDir: string): string;
|
|
12
|
+
//# sourceMappingURL=profiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACtC;AAID,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAiBzE;AAED,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAQxF;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
package/dist/profiles.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { chmod, mkdir, readFile, rename, writeFile, } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
const CONFIG_FILE = "config.json";
|
|
4
|
+
export async function readCliConfig(configDir) {
|
|
5
|
+
const path = configPath(configDir);
|
|
6
|
+
try {
|
|
7
|
+
const raw = await readFile(path, "utf8");
|
|
8
|
+
const parsed = JSON.parse(raw);
|
|
9
|
+
return {
|
|
10
|
+
profiles: parsed.profiles ?? {},
|
|
11
|
+
...(parsed.defaultProfile ? { defaultProfile: parsed.defaultProfile } : {}),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (isNodeError(error) && error.code === "ENOENT") {
|
|
16
|
+
return { profiles: {} };
|
|
17
|
+
}
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export async function writeCliConfig(configDir, config) {
|
|
22
|
+
await mkdir(configDir, { mode: 0o700, recursive: true });
|
|
23
|
+
const path = configPath(configDir);
|
|
24
|
+
const tempPath = `${path}.${process.pid}.tmp`;
|
|
25
|
+
await writeFile(tempPath, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
|
|
26
|
+
await chmod(tempPath, 0o600);
|
|
27
|
+
await rename(tempPath, path);
|
|
28
|
+
await chmod(path, 0o600);
|
|
29
|
+
}
|
|
30
|
+
export function configPath(configDir) {
|
|
31
|
+
return join(configDir, CONFIG_FILE);
|
|
32
|
+
}
|
|
33
|
+
function isNodeError(error) {
|
|
34
|
+
return Boolean(error && typeof error === "object" && "code" in error);
|
|
35
|
+
}
|