@prospera/eprospera-cli 0.1.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 +13 -0
- package/LICENSE +21 -0
- package/README.md +140 -0
- package/bin/eprospera.js +3 -0
- package/cli.ocs.yaml +406 -0
- package/dist/bundle/eprospera.mjs +28349 -0
- package/dist/completions/eprospera.bash +7 -0
- package/dist/completions/eprospera.fish +2 -0
- package/dist/completions/eprospera.ps1 +7 -0
- package/dist/completions/eprospera.zsh +4 -0
- package/dist/src/api/client.d.ts +29 -0
- package/dist/src/api/client.js +131 -0
- package/dist/src/api/errors.d.ts +11 -0
- package/dist/src/api/errors.js +125 -0
- package/dist/src/api/generated.d.ts +1159 -0
- package/dist/src/api/generated.js +6 -0
- package/dist/src/commands/application/create.d.ts +5 -0
- package/dist/src/commands/application/create.js +62 -0
- package/dist/src/commands/application/get.d.ts +2 -0
- package/dist/src/commands/application/get.js +11 -0
- package/dist/src/commands/application/list.d.ts +2 -0
- package/dist/src/commands/application/list.js +8 -0
- package/dist/src/commands/application/pay.d.ts +5 -0
- package/dist/src/commands/application/pay.js +27 -0
- package/dist/src/commands/application/watch.d.ts +7 -0
- package/dist/src/commands/application/watch.js +42 -0
- package/dist/src/commands/auth/login.d.ts +7 -0
- package/dist/src/commands/auth/login.js +60 -0
- package/dist/src/commands/auth/logout.d.ts +2 -0
- package/dist/src/commands/auth/logout.js +14 -0
- package/dist/src/commands/auth/whoami.d.ts +2 -0
- package/dist/src/commands/auth/whoami.js +19 -0
- package/dist/src/commands/completion.d.ts +3 -0
- package/dist/src/commands/completion.js +80 -0
- package/dist/src/commands/config/get.d.ts +2 -0
- package/dist/src/commands/config/get.js +9 -0
- package/dist/src/commands/config/list.d.ts +2 -0
- package/dist/src/commands/config/list.js +7 -0
- package/dist/src/commands/config/set.d.ts +2 -0
- package/dist/src/commands/config/set.js +9 -0
- package/dist/src/commands/config/unset.d.ts +2 -0
- package/dist/src/commands/config/unset.js +9 -0
- package/dist/src/commands/entity/documents.d.ts +2 -0
- package/dist/src/commands/entity/documents.js +11 -0
- package/dist/src/commands/entity/get.d.ts +2 -0
- package/dist/src/commands/entity/get.js +11 -0
- package/dist/src/commands/entity/search.d.ts +2 -0
- package/dist/src/commands/entity/search.js +17 -0
- package/dist/src/commands/entity/verify.d.ts +2 -0
- package/dist/src/commands/entity/verify.js +9 -0
- package/dist/src/commands/files.d.ts +2 -0
- package/dist/src/commands/files.js +24 -0
- package/dist/src/commands/me/id-verification.d.ts +2 -0
- package/dist/src/commands/me/id-verification.js +8 -0
- package/dist/src/commands/me/profile.d.ts +2 -0
- package/dist/src/commands/me/profile.js +8 -0
- package/dist/src/commands/me/residency.d.ts +2 -0
- package/dist/src/commands/me/residency.js +8 -0
- package/dist/src/commands/runtime.d.ts +56 -0
- package/dist/src/commands/runtime.js +101 -0
- package/dist/src/commands/schema.d.ts +2 -0
- package/dist/src/commands/schema.js +13 -0
- package/dist/src/config/store.d.ts +14 -0
- package/dist/src/config/store.js +99 -0
- package/dist/src/credentials/resolve.d.ts +15 -0
- package/dist/src/credentials/resolve.js +63 -0
- package/dist/src/credentials/store.d.ts +22 -0
- package/dist/src/credentials/store.js +184 -0
- package/dist/src/credentials/types.d.ts +15 -0
- package/dist/src/credentials/types.js +5 -0
- package/dist/src/errors.d.ts +39 -0
- package/dist/src/errors.js +38 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +244 -0
- package/dist/src/output/format.d.ts +27 -0
- package/dist/src/output/format.js +126 -0
- package/dist/src/output/table.d.ts +5 -0
- package/dist/src/output/table.js +124 -0
- package/dist/src/output/tty.d.ts +26 -0
- package/dist/src/output/tty.js +41 -0
- package/dist/src/polling/watch.d.ts +19 -0
- package/dist/src/polling/watch.js +86 -0
- package/dist/src/prompts/confirm.d.ts +2 -0
- package/dist/src/prompts/confirm.js +19 -0
- package/dist/src/scopes/check.d.ts +17 -0
- package/dist/src/scopes/check.js +64 -0
- package/dist/src/scopes/map.d.ts +81 -0
- package/dist/src/scopes/map.js +76 -0
- package/dist/src/version.d.ts +1 -0
- package/dist/src/version.js +35 -0
- package/package.json +70 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type GlobalOptions, type RuntimeDependencies } from "../runtime.js";
|
|
2
|
+
export type CreateApplicationOptions = {
|
|
3
|
+
file?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function runApplicationCreate(options: CreateApplicationOptions, globals: GlobalOptions, deps?: RuntimeDependencies): Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { print } from "../../output/format.js";
|
|
3
|
+
import { confirmAction } from "../../prompts/confirm.js";
|
|
4
|
+
import { authenticatedContext, nonEmptyStringSchema, parseInput, printDryRun, readJsonFile, } from "../runtime.js";
|
|
5
|
+
const addressSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
country: z.string().optional(),
|
|
8
|
+
line1: z.string().optional(),
|
|
9
|
+
line2: z.string().nullable().optional(),
|
|
10
|
+
city: z.string().optional(),
|
|
11
|
+
state: z.string().nullable().optional(),
|
|
12
|
+
postalCode: z.string().optional(),
|
|
13
|
+
})
|
|
14
|
+
.passthrough();
|
|
15
|
+
const extensionSchema = z.enum([
|
|
16
|
+
"LLC",
|
|
17
|
+
"L.L.C.",
|
|
18
|
+
"Limited Liability Company",
|
|
19
|
+
"S. de R.L.",
|
|
20
|
+
"SRL",
|
|
21
|
+
"Limited Company",
|
|
22
|
+
"L.C.",
|
|
23
|
+
"LC",
|
|
24
|
+
"Limited Liability Co.",
|
|
25
|
+
"Limited Co.",
|
|
26
|
+
"Ltd. Co.",
|
|
27
|
+
]);
|
|
28
|
+
const createApplicationSchema = z
|
|
29
|
+
.object({
|
|
30
|
+
applicationData: z
|
|
31
|
+
.object({
|
|
32
|
+
residencyType: z.enum(["e-Resident", "Resident"]),
|
|
33
|
+
entityType: z.literal("llc"),
|
|
34
|
+
name: nonEmptyStringSchema,
|
|
35
|
+
extension: extensionSchema,
|
|
36
|
+
principalOffice: addressSchema,
|
|
37
|
+
contactEmail: z.string().email(),
|
|
38
|
+
registeredAgentProvider: z.literal("prospera_employment_solutions").nullable().optional(),
|
|
39
|
+
registeredAgentDetails: z.unknown().optional(),
|
|
40
|
+
analytics: z.record(z.string(), z.unknown()).optional(),
|
|
41
|
+
})
|
|
42
|
+
.passthrough(),
|
|
43
|
+
referralCode: z.string().optional(),
|
|
44
|
+
redirectUrl: z.string().url().optional(),
|
|
45
|
+
})
|
|
46
|
+
.passthrough();
|
|
47
|
+
export async function runApplicationCreate(options, globals, deps = {}) {
|
|
48
|
+
const file = parseInput(nonEmptyStringSchema, options.file);
|
|
49
|
+
const body = (await readJsonFile(file, createApplicationSchema, deps));
|
|
50
|
+
if (globals.dryRun) {
|
|
51
|
+
printDryRun({ method: "POST", path: "/api/v1/legal_entity_applications", body }, globals, deps);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const confirmed = await confirmAction("Create legal-entity application?", globals, deps);
|
|
55
|
+
if (!confirmed) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const context = await authenticatedContext("application.create", globals, deps);
|
|
59
|
+
const response = await context.api.raw.POST("/api/v1/legal_entity_applications", { body });
|
|
60
|
+
print(response.data ?? null, { ...context.output, table: "applications" });
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { print } from "../../output/format.js";
|
|
2
|
+
import { authenticatedContext, parseInput, uuidSchema, } from "../runtime.js";
|
|
3
|
+
export async function runApplicationGet(id, globals, deps = {}) {
|
|
4
|
+
const applicationId = parseInput(uuidSchema, id);
|
|
5
|
+
const context = await authenticatedContext("application.get", globals, deps);
|
|
6
|
+
const response = await context.api.raw.GET("/api/v1/legal_entity_applications/{id}", {
|
|
7
|
+
params: { path: { id: applicationId } },
|
|
8
|
+
});
|
|
9
|
+
print(response.data ?? null, { ...context.output, table: "applications" });
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { print } from "../../output/format.js";
|
|
2
|
+
import { authenticatedContext } from "../runtime.js";
|
|
3
|
+
export async function runApplicationList(globals, deps = {}) {
|
|
4
|
+
const context = await authenticatedContext("application.list", globals, deps);
|
|
5
|
+
const response = await context.api.raw.GET("/api/v1/legal_entity_applications");
|
|
6
|
+
print(response.data ?? null, { ...context.output, table: "applications" });
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type GlobalOptions, type RuntimeDependencies } from "../runtime.js";
|
|
2
|
+
export type PayApplicationOptions = {
|
|
3
|
+
coupon?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function runApplicationPay(id: string, options: PayApplicationOptions, globals: GlobalOptions, deps?: RuntimeDependencies): Promise<void>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { print } from "../../output/format.js";
|
|
2
|
+
import { confirmAction } from "../../prompts/confirm.js";
|
|
3
|
+
import { authenticatedContext, nonEmptyStringSchema, parseInput, printDryRun, uuidSchema, } from "../runtime.js";
|
|
4
|
+
export async function runApplicationPay(id, options, globals, deps = {}) {
|
|
5
|
+
const applicationId = parseInput(uuidSchema, id);
|
|
6
|
+
const couponCode = parseInput(nonEmptyStringSchema, options.coupon);
|
|
7
|
+
const body = { couponCode };
|
|
8
|
+
if (globals.dryRun) {
|
|
9
|
+
printDryRun({
|
|
10
|
+
method: "POST",
|
|
11
|
+
path: `/api/v1/legal_entity_applications/${applicationId}/pay/coupon`,
|
|
12
|
+
body,
|
|
13
|
+
}, globals, deps);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const confirmed = await confirmAction("Apply coupon to legal-entity application?", globals, deps);
|
|
17
|
+
if (!confirmed) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const context = await authenticatedContext("application.pay", globals, deps);
|
|
21
|
+
const response = await context.api.raw.POST("/api/v1/legal_entity_applications/{id}/pay/coupon", {
|
|
22
|
+
params: { path: { id: applicationId } },
|
|
23
|
+
body,
|
|
24
|
+
});
|
|
25
|
+
print(response.data ?? null, { ...context.output, table: "applications" });
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=pay.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type GlobalOptions, type RuntimeDependencies } from "../runtime.js";
|
|
2
|
+
export type WatchApplicationOptions = {
|
|
3
|
+
timeout?: string;
|
|
4
|
+
initialInterval?: string;
|
|
5
|
+
maxInterval?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function runApplicationWatch(id: string, options: WatchApplicationOptions, globals: GlobalOptions, deps?: RuntimeDependencies): Promise<void>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ExitCodes, ExitError } from "../../errors.js";
|
|
2
|
+
import { print } from "../../output/format.js";
|
|
3
|
+
import { resolveOutputMode } from "../../output/tty.js";
|
|
4
|
+
import { parseDurationMs, watchApplication } from "../../polling/watch.js";
|
|
5
|
+
import { authenticatedContext, parseInput, uuidSchema, } from "../runtime.js";
|
|
6
|
+
const DEFAULT_TIMEOUT_MS = 30 * 60 * 1000;
|
|
7
|
+
const DEFAULT_INITIAL_INTERVAL_MS = 30 * 1000;
|
|
8
|
+
const DEFAULT_MAX_INTERVAL_MS = 5 * 60 * 1000;
|
|
9
|
+
export async function runApplicationWatch(id, options, globals, deps = {}) {
|
|
10
|
+
const applicationId = parseInput(uuidSchema, id);
|
|
11
|
+
const context = await authenticatedContext("application.watch", globals, deps);
|
|
12
|
+
const mode = resolveOutputMode(context.output, deps.streams);
|
|
13
|
+
const stdout = deps.streams?.stdout ?? process.stdout;
|
|
14
|
+
const result = await watchApplication(async () => {
|
|
15
|
+
const response = await context.api.raw.GET("/api/v1/legal_entity_applications/{id}", {
|
|
16
|
+
params: { path: { id: applicationId } },
|
|
17
|
+
});
|
|
18
|
+
return response.data?.data ?? {};
|
|
19
|
+
}, {
|
|
20
|
+
timeoutMs: parseDurationMs(options.timeout, DEFAULT_TIMEOUT_MS),
|
|
21
|
+
initialIntervalMs: parseDurationMs(options.initialInterval, DEFAULT_INITIAL_INTERVAL_MS),
|
|
22
|
+
maxIntervalMs: parseDurationMs(options.maxInterval, DEFAULT_MAX_INTERVAL_MS),
|
|
23
|
+
now: deps.now,
|
|
24
|
+
sleep: deps.sleep,
|
|
25
|
+
onTransition: (application) => {
|
|
26
|
+
if (mode === "json" || mode === "raw") {
|
|
27
|
+
stdout.write(`${JSON.stringify({ data: application })}\n`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
print({ data: application }, { ...context.output, table: "applications" });
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
if (result.terminal !== "approved") {
|
|
34
|
+
throw new ExitError({
|
|
35
|
+
code: "WATCH_FAILED",
|
|
36
|
+
message: "Application watch ended unexpectedly.",
|
|
37
|
+
exitCode: ExitCodes.Generic,
|
|
38
|
+
details: result,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type GlobalOptions, type RuntimeDependencies } from "../runtime.js";
|
|
2
|
+
export type LoginOptions = {
|
|
3
|
+
agentKey?: boolean;
|
|
4
|
+
standardKey?: boolean;
|
|
5
|
+
scopes?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function runAuthLogin(options: LoginOptions, globals: GlobalOptions, deps?: RuntimeDependencies): Promise<void>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { input, password } from "@inquirer/prompts";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { saveCredential } from "../../credentials/store.js";
|
|
4
|
+
import { ExitCodes, ExitError } from "../../errors.js";
|
|
5
|
+
import { print } from "../../output/format.js";
|
|
6
|
+
import { configStoreOptions, outputOptions, parseInput, } from "../runtime.js";
|
|
7
|
+
const agentKeySchema = z
|
|
8
|
+
.string()
|
|
9
|
+
.trim()
|
|
10
|
+
.regex(/^ak-.+/, "Agent Key must start with ak-.");
|
|
11
|
+
const standardKeySchema = z
|
|
12
|
+
.string()
|
|
13
|
+
.trim()
|
|
14
|
+
.regex(/^sk-.+/, "Standard API key must start with sk-.");
|
|
15
|
+
export async function runAuthLogin(options, globals, deps = {}) {
|
|
16
|
+
if (options.agentKey === options.standardKey) {
|
|
17
|
+
throw new ExitError({
|
|
18
|
+
code: "INVALID_AUTH_MODE",
|
|
19
|
+
message: "Choose exactly one login mode: --agent-key or --standard-key.",
|
|
20
|
+
exitCode: ExitCodes.Usage,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const kind = options.agentKey ? "ak" : "sk";
|
|
24
|
+
const promptMessage = kind === "ak" ? "Agent Key" : "Standard API key";
|
|
25
|
+
const token = globals.apiKey?.trim() || (await promptSecret(promptMessage, deps));
|
|
26
|
+
const scopes = kind === "ak" ? await resolveScopes(options.scopes, deps) : [];
|
|
27
|
+
const credential = {
|
|
28
|
+
kind,
|
|
29
|
+
token: parseInput(kind === "ak" ? agentKeySchema : standardKeySchema, token),
|
|
30
|
+
scopes,
|
|
31
|
+
};
|
|
32
|
+
const source = (await deps.saveStoredCredential?.(credential)) ??
|
|
33
|
+
(await saveCredential(credential, configStoreOptions(deps)));
|
|
34
|
+
print({
|
|
35
|
+
kind: credential.kind,
|
|
36
|
+
source,
|
|
37
|
+
scopes: credential.scopes,
|
|
38
|
+
saved: true,
|
|
39
|
+
}, outputOptions(globals, deps));
|
|
40
|
+
}
|
|
41
|
+
async function promptSecret(message, deps) {
|
|
42
|
+
return deps.promptPassword?.(message) ?? password({ message });
|
|
43
|
+
}
|
|
44
|
+
async function resolveScopes(scopes, deps) {
|
|
45
|
+
if (scopes !== undefined) {
|
|
46
|
+
return parseScopes(scopes);
|
|
47
|
+
}
|
|
48
|
+
const value = (await deps.promptInput?.("Agent Key scopes (comma-separated, optional)")) ??
|
|
49
|
+
(await input({ message: "Agent Key scopes (comma-separated, optional)", default: "" }));
|
|
50
|
+
return parseScopes(value);
|
|
51
|
+
}
|
|
52
|
+
function parseScopes(value) {
|
|
53
|
+
return [
|
|
54
|
+
...new Set(value
|
|
55
|
+
.split(",")
|
|
56
|
+
.map((scope) => scope.trim())
|
|
57
|
+
.filter(Boolean)),
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { deleteCredential } from "../../credentials/store.js";
|
|
2
|
+
import { print } from "../../output/format.js";
|
|
3
|
+
import { confirmAction } from "../../prompts/confirm.js";
|
|
4
|
+
import { configStoreOptions, outputOptions, } from "../runtime.js";
|
|
5
|
+
export async function runAuthLogout(globals, deps = {}) {
|
|
6
|
+
const confirmed = await confirmAction("Delete locally stored credentials?", globals, deps);
|
|
7
|
+
if (!confirmed) {
|
|
8
|
+
print({ deleted: false }, outputOptions(globals, deps));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const deleted = (await deps.deleteStoredCredential?.()) ?? (await deleteCredential(configStoreOptions(deps)));
|
|
12
|
+
print({ deleted }, outputOptions(globals, deps));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { resolveCredential } from "../../credentials/resolve.js";
|
|
2
|
+
import { print } from "../../output/format.js";
|
|
3
|
+
import { configStoreOptions, outputOptions, } from "../runtime.js";
|
|
4
|
+
export async function runAuthWhoami(globals, deps = {}) {
|
|
5
|
+
const credential = await resolveCredential({
|
|
6
|
+
apiKey: globals.apiKey,
|
|
7
|
+
env: deps.env ?? process.env,
|
|
8
|
+
store: configStoreOptions(deps),
|
|
9
|
+
loadStoredCredential: deps.loadStoredCredential,
|
|
10
|
+
});
|
|
11
|
+
print({
|
|
12
|
+
kind: credential.kind,
|
|
13
|
+
source: credential.source,
|
|
14
|
+
owner: credential.owner ?? null,
|
|
15
|
+
scopes: credential.scopes,
|
|
16
|
+
expiresAt: credential.expiresAt ?? null,
|
|
17
|
+
}, outputOptions(globals, deps));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type GlobalOptions, type RuntimeDependencies } from "./runtime.js";
|
|
2
|
+
export type CompletionShell = "bash" | "zsh" | "fish" | "powershell";
|
|
3
|
+
export declare function runCompletion(shell: CompletionShell, globals: GlobalOptions, deps?: RuntimeDependencies): Promise<void>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { parse } from "yaml";
|
|
2
|
+
import { print } from "../output/format.js";
|
|
3
|
+
import { readPackageFile } from "./files.js";
|
|
4
|
+
import { outputOptions } from "./runtime.js";
|
|
5
|
+
export async function runCompletion(shell, globals, deps = {}) {
|
|
6
|
+
const document = parse(await readPackageFile("cli.ocs.yaml", import.meta.url));
|
|
7
|
+
const words = Array.from(new Set([...commandWords(document.command), ...optionWords(document.command)]));
|
|
8
|
+
const script = renderCompletion(shell, words);
|
|
9
|
+
if (globals.json || globals.raw) {
|
|
10
|
+
print(script, outputOptions(globals, deps));
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
(deps.streams?.stdout ?? process.stdout).write(script);
|
|
14
|
+
}
|
|
15
|
+
function renderCompletion(shell, values) {
|
|
16
|
+
if (shell === "bash") {
|
|
17
|
+
return bash(values);
|
|
18
|
+
}
|
|
19
|
+
if (shell === "zsh") {
|
|
20
|
+
return zsh(values);
|
|
21
|
+
}
|
|
22
|
+
if (shell === "fish") {
|
|
23
|
+
return fish(values);
|
|
24
|
+
}
|
|
25
|
+
return powershell(values);
|
|
26
|
+
}
|
|
27
|
+
function commandWords(command) {
|
|
28
|
+
return [command.name, ...(command.commands ?? []).flatMap(commandWords)];
|
|
29
|
+
}
|
|
30
|
+
function optionWords(command) {
|
|
31
|
+
return [
|
|
32
|
+
...(command.options ?? []).flatMap((option) => [option.name, ...(option.aliases ?? [])]),
|
|
33
|
+
...(command.commands ?? []).flatMap(optionWords),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
function shellWords(values) {
|
|
37
|
+
return values.map((value) => value.replace(/'/g, "'\\''")).join(" ");
|
|
38
|
+
}
|
|
39
|
+
function bash(values) {
|
|
40
|
+
return [
|
|
41
|
+
"# Generated by eprospera.",
|
|
42
|
+
"_eprospera_completions() {",
|
|
43
|
+
" local cur",
|
|
44
|
+
` cur="\${COMP_WORDS[COMP_CWORD]}"`,
|
|
45
|
+
` COMPREPLY=( $(compgen -W '${shellWords(values)}' -- "$cur") )`,
|
|
46
|
+
"}",
|
|
47
|
+
"complete -F _eprospera_completions eprospera",
|
|
48
|
+
"",
|
|
49
|
+
].join("\n");
|
|
50
|
+
}
|
|
51
|
+
function zsh(values) {
|
|
52
|
+
return [
|
|
53
|
+
"#compdef eprospera",
|
|
54
|
+
"# Generated by eprospera.",
|
|
55
|
+
`local -a commands=(${values.map((value) => `"${value}"`).join(" ")})`,
|
|
56
|
+
"_describe 'eprospera command' commands",
|
|
57
|
+
"",
|
|
58
|
+
].join("\n");
|
|
59
|
+
}
|
|
60
|
+
function fish(values) {
|
|
61
|
+
return [
|
|
62
|
+
"# Generated by eprospera.",
|
|
63
|
+
`complete -c eprospera -f -a '${shellWords(values)}'`,
|
|
64
|
+
"",
|
|
65
|
+
].join("\n");
|
|
66
|
+
}
|
|
67
|
+
function powershell(values) {
|
|
68
|
+
const quoted = values.map((value) => `'${value.replace(/'/g, "''")}'`).join(", ");
|
|
69
|
+
return [
|
|
70
|
+
"# Generated by eprospera.",
|
|
71
|
+
"Register-ArgumentCompleter -Native -CommandName eprospera -ScriptBlock {",
|
|
72
|
+
" param($wordToComplete)",
|
|
73
|
+
` ${quoted} | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {`,
|
|
74
|
+
" [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)",
|
|
75
|
+
" }",
|
|
76
|
+
"}",
|
|
77
|
+
"",
|
|
78
|
+
].join("\n");
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=completion.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { assertConfigKey, loadConfig } from "../../config/store.js";
|
|
2
|
+
import { print } from "../../output/format.js";
|
|
3
|
+
import { configStoreOptions, outputOptions, } from "../runtime.js";
|
|
4
|
+
export async function runConfigGet(key, globals, deps = {}) {
|
|
5
|
+
const configKey = assertConfigKey(key);
|
|
6
|
+
const config = await loadConfig(configStoreOptions(deps));
|
|
7
|
+
print({ key: configKey, value: config[configKey] ?? null }, outputOptions(globals, deps));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { loadConfig } from "../../config/store.js";
|
|
2
|
+
import { print } from "../../output/format.js";
|
|
3
|
+
import { configStoreOptions, outputOptions, } from "../runtime.js";
|
|
4
|
+
export async function runConfigList(globals, deps = {}) {
|
|
5
|
+
print(await loadConfig(configStoreOptions(deps)), outputOptions(globals, deps));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { assertConfigKey, setConfigValue } from "../../config/store.js";
|
|
2
|
+
import { print } from "../../output/format.js";
|
|
3
|
+
import { configStoreOptions, nonEmptyStringSchema, outputOptions, parseInput, } from "../runtime.js";
|
|
4
|
+
export async function runConfigSet(key, value, globals, deps = {}) {
|
|
5
|
+
const configKey = assertConfigKey(key);
|
|
6
|
+
const config = await setConfigValue(configKey, parseInput(nonEmptyStringSchema, value), configStoreOptions(deps));
|
|
7
|
+
print({ key: configKey, value: config[configKey] ?? null }, outputOptions(globals, deps));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=set.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { assertConfigKey, unsetConfigValue } from "../../config/store.js";
|
|
2
|
+
import { print } from "../../output/format.js";
|
|
3
|
+
import { configStoreOptions, outputOptions, } from "../runtime.js";
|
|
4
|
+
export async function runConfigUnset(key, globals, deps = {}) {
|
|
5
|
+
const configKey = assertConfigKey(key);
|
|
6
|
+
const deleted = await unsetConfigValue(configKey, configStoreOptions(deps));
|
|
7
|
+
print({ key: configKey, deleted }, outputOptions(globals, deps));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=unset.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { print } from "../../output/format.js";
|
|
2
|
+
import { authenticatedContext, parseInput, uuidSchema, } from "../runtime.js";
|
|
3
|
+
export async function runEntityDocuments(id, globals, deps = {}) {
|
|
4
|
+
const entityId = parseInput(uuidSchema, id);
|
|
5
|
+
const context = await authenticatedContext("entity.documents", globals, deps);
|
|
6
|
+
const response = await context.api.raw.GET("/api/v1/legal_entities/{id}/documents", {
|
|
7
|
+
params: { path: { id: entityId } },
|
|
8
|
+
});
|
|
9
|
+
print(response.data ?? null, { ...context.output, table: "documents" });
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=documents.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { print } from "../../output/format.js";
|
|
2
|
+
import { authenticatedContext, parseInput, uuidSchema, } from "../runtime.js";
|
|
3
|
+
export async function runEntityGet(id, globals, deps = {}) {
|
|
4
|
+
const entityId = parseInput(uuidSchema, id);
|
|
5
|
+
const context = await authenticatedContext("entity.get", globals, deps);
|
|
6
|
+
const response = await context.api.raw.GET("/api/v1/legal_entities/{id}", {
|
|
7
|
+
params: { path: { id: entityId } },
|
|
8
|
+
});
|
|
9
|
+
print(response.data ?? null, { ...context.output, table: "entities" });
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { print } from "../../output/format.js";
|
|
2
|
+
import { renderTable } from "../../output/table.js";
|
|
3
|
+
import { authenticatedContext, nonEmptyStringSchema, parseInput, } from "../runtime.js";
|
|
4
|
+
export async function runEntitySearch(query, globals, deps = {}) {
|
|
5
|
+
const body = { query: parseInput(nonEmptyStringSchema, query) };
|
|
6
|
+
const context = await authenticatedContext("entity.search", globals, deps);
|
|
7
|
+
const response = await context.api.raw.POST("/api/v1/registries/legal_entities/search", { body });
|
|
8
|
+
const data = response.data ?? { results: [] };
|
|
9
|
+
print(data, {
|
|
10
|
+
...context.output,
|
|
11
|
+
human: (value) => renderTable(isResultEnvelope(value) ? value.results : value, "entities"),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function isResultEnvelope(value) {
|
|
15
|
+
return typeof value === "object" && value !== null && "results" in value;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { print } from "../../output/format.js";
|
|
2
|
+
import { authenticatedContext, parseInput, rpnSchema, } from "../runtime.js";
|
|
3
|
+
export async function runEntityVerify(rpn, globals, deps = {}) {
|
|
4
|
+
const body = { rpn: parseInput(rpnSchema, rpn) };
|
|
5
|
+
const context = await authenticatedContext("entity.verify", globals, deps);
|
|
6
|
+
const response = await context.api.raw.POST("/api/v1/verify_rpn", { body });
|
|
7
|
+
print(response.data ?? null, context.output);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { access, readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
export async function findPackageRoot(fromUrl = import.meta.url) {
|
|
5
|
+
let current = dirname(fileURLToPath(fromUrl));
|
|
6
|
+
for (;;) {
|
|
7
|
+
try {
|
|
8
|
+
await access(join(current, "package.json"));
|
|
9
|
+
await access(join(current, "cli.ocs.yaml"));
|
|
10
|
+
return current;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
const parent = dirname(current);
|
|
14
|
+
if (parent === current) {
|
|
15
|
+
return process.cwd();
|
|
16
|
+
}
|
|
17
|
+
current = parent;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export async function readPackageFile(path, fromUrl = import.meta.url) {
|
|
22
|
+
return readFile(join(await findPackageRoot(fromUrl), path), "utf8");
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { print } from "../../output/format.js";
|
|
2
|
+
import { authenticatedContext } from "../runtime.js";
|
|
3
|
+
export async function runMeIdVerification(globals, deps = {}) {
|
|
4
|
+
const context = await authenticatedContext("me.id-verification", globals, deps);
|
|
5
|
+
const response = await context.api.raw.GET("/api/v1/me/natural-person/id-verification");
|
|
6
|
+
print(response.data ?? null, context.output);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=id-verification.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { print } from "../../output/format.js";
|
|
2
|
+
import { authenticatedContext } from "../runtime.js";
|
|
3
|
+
export async function runMeProfile(globals, deps = {}) {
|
|
4
|
+
const context = await authenticatedContext("me.profile", globals, deps);
|
|
5
|
+
const response = await context.api.raw.GET("/api/v1/me/natural-person");
|
|
6
|
+
print(response.data ?? null, context.output);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { print } from "../../output/format.js";
|
|
2
|
+
import { authenticatedContext } from "../runtime.js";
|
|
3
|
+
export async function runMeResidency(globals, deps = {}) {
|
|
4
|
+
const context = await authenticatedContext("me.residency", globals, deps);
|
|
5
|
+
const response = await context.api.raw.GET("/api/v1/me/natural-person/residency");
|
|
6
|
+
print(response.data ?? null, context.output);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=residency.js.map
|