@lifestreamdynamics/vault-cli 1.3.5 → 1.3.6
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/dist/commands/analytics.js +10 -3
- package/dist/commands/audit.js +56 -2
- package/dist/commands/auth.js +9 -1
- package/dist/commands/booking.js +39 -23
- package/dist/commands/calendar.js +107 -52
- package/dist/commands/connectors.js +21 -1
- package/dist/commands/docs.js +65 -23
- package/dist/commands/hooks.js +46 -8
- package/dist/commands/keys.js +9 -2
- package/dist/commands/links.js +13 -4
- package/dist/commands/mfa.js +5 -1
- package/dist/commands/plugins.js +4 -3
- package/dist/commands/publish.js +25 -8
- package/dist/commands/search.js +7 -0
- package/dist/commands/shares.js +12 -3
- package/dist/commands/sync.js +4 -2
- package/dist/commands/user.js +13 -3
- package/dist/commands/vaults.js +6 -3
- package/dist/commands/versions.js +27 -9
- package/dist/commands/webhooks.js +39 -7
- package/dist/utils/flags.js +1 -1
- package/dist/utils/output.d.ts +4 -1
- package/dist/utils/output.js +15 -3
- package/dist/utils/resolve-vault.d.ts +8 -0
- package/dist/utils/resolve-vault.js +19 -0
- package/package.json +1 -1
package/dist/utils/output.js
CHANGED
|
@@ -67,9 +67,19 @@ export class Output {
|
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Print an error message to stderr.
|
|
70
|
+
* When output format is json, writes a JSON error envelope instead of colored text.
|
|
70
71
|
*/
|
|
71
72
|
error(message) {
|
|
72
|
-
|
|
73
|
+
if (this.flags.output === 'json') {
|
|
74
|
+
process.stderr.write(JSON.stringify({ error: true, message }) + '\n');
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
process.stderr.write(chalk.red(message) + '\n');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Expose the current output format (for error handlers that need it). */
|
|
81
|
+
get format() {
|
|
82
|
+
return this.flags.output;
|
|
73
83
|
}
|
|
74
84
|
/**
|
|
75
85
|
* Print a warning message to stderr.
|
|
@@ -107,14 +117,16 @@ export class Output {
|
|
|
107
117
|
*/
|
|
108
118
|
list(data, options) {
|
|
109
119
|
if (data.length === 0) {
|
|
120
|
+
if (this.flags.quiet)
|
|
121
|
+
return;
|
|
110
122
|
if (this.flags.output === 'json') {
|
|
111
123
|
process.stdout.write('[]\n');
|
|
112
124
|
return;
|
|
113
125
|
}
|
|
114
|
-
if (options?.emptyMessage
|
|
126
|
+
if (options?.emptyMessage) {
|
|
115
127
|
this.status(options.emptyMessage);
|
|
116
128
|
}
|
|
117
|
-
else
|
|
129
|
+
else {
|
|
118
130
|
process.stdout.write('No results found.\n');
|
|
119
131
|
}
|
|
120
132
|
return;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accepts either a vault UUID or a vault slug. If a UUID is given it is
|
|
3
|
+
* returned unchanged. If a slug is given, the vault list is fetched and the
|
|
4
|
+
* matching vault's ID is returned.
|
|
5
|
+
*
|
|
6
|
+
* @throws {Error} If the slug does not match any vault.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveVaultId(idOrSlug: string): Promise<string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getClientAsync } from '../client.js';
|
|
2
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
3
|
+
/**
|
|
4
|
+
* Accepts either a vault UUID or a vault slug. If a UUID is given it is
|
|
5
|
+
* returned unchanged. If a slug is given, the vault list is fetched and the
|
|
6
|
+
* matching vault's ID is returned.
|
|
7
|
+
*
|
|
8
|
+
* @throws {Error} If the slug does not match any vault.
|
|
9
|
+
*/
|
|
10
|
+
export async function resolveVaultId(idOrSlug) {
|
|
11
|
+
if (UUID_RE.test(idOrSlug))
|
|
12
|
+
return idOrSlug;
|
|
13
|
+
const client = await getClientAsync();
|
|
14
|
+
const vaults = await client.vaults.list();
|
|
15
|
+
const match = vaults.find(v => v.slug === idOrSlug);
|
|
16
|
+
if (!match)
|
|
17
|
+
throw new Error(`Vault not found: "${idOrSlug}"`);
|
|
18
|
+
return match.id;
|
|
19
|
+
}
|