@lifestreamdynamics/vault-cli 1.3.7 → 1.3.9

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.
@@ -5,18 +5,24 @@ import { createOutput, handleError } from '../utils/output.js';
5
5
  import { generateVaultKey } from '@lifestreamdynamics/vault-sdk';
6
6
  import { getCredentialManager } from '../config.js';
7
7
  import { resolveVaultId } from '../utils/resolve-vault.js';
8
+ import { confirmAction } from '../utils/confirm.js';
8
9
  export function registerVaultCommands(program) {
9
10
  const vaults = program.command('vaults').description('Create, list, and inspect document vaults');
10
11
  addGlobalFlags(vaults.command('list')
11
- .description('List all vaults accessible to the current user'))
12
+ .description('List all vaults accessible to the current user')
13
+ .option('--include-archived', 'Include archived vaults in the list'))
12
14
  .action(async (_opts) => {
13
15
  const flags = resolveFlags(_opts);
14
16
  const out = createOutput(flags);
15
17
  out.startSpinner('Fetching vaults...');
16
18
  try {
19
+ out.debug('API: GET vaults');
17
20
  const client = await getClientAsync();
18
- const vaultList = await client.vaults.list();
21
+ const vaultList = await client.vaults.list({
22
+ includeArchived: _opts.includeArchived === true,
23
+ });
19
24
  out.stopSpinner();
25
+ out.debug(`Response: ${vaultList.length} vaults`);
20
26
  out.list(vaultList.map(v => ({ name: v.name, slug: v.slug, encrypted: v.encryptionEnabled ? 'yes' : 'no', description: v.description ?? null, id: v.id })), {
21
27
  emptyMessage: 'No vaults found.',
22
28
  columns: [
@@ -45,6 +51,7 @@ export function registerVaultCommands(program) {
45
51
  const out = createOutput(flags);
46
52
  out.startSpinner('Fetching vault...');
47
53
  try {
54
+ vaultId = await resolveVaultId(vaultId);
48
55
  const client = await getClientAsync();
49
56
  const vault = await client.vaults.get(vaultId);
50
57
  out.stopSpinner();
@@ -196,12 +203,18 @@ EXAMPLES
196
203
  // vault archive
197
204
  addGlobalFlags(vaults.command('archive')
198
205
  .description('Archive a vault')
199
- .argument('<vaultId>', 'Vault ID'))
206
+ .argument('<vaultId>', 'Vault ID')
207
+ .option('-y, --yes', 'Skip confirmation prompt'))
200
208
  .action(async (vaultId, _opts) => {
201
209
  const flags = resolveFlags(_opts);
202
210
  const out = createOutput(flags);
203
- out.startSpinner('Archiving vault...');
204
211
  try {
212
+ const confirmed = await confirmAction(`Archive vault ${vaultId}?`, { yes: _opts.yes });
213
+ if (!confirmed) {
214
+ out.status('Archive cancelled.');
215
+ return;
216
+ }
217
+ out.startSpinner('Archiving vault...');
205
218
  const client = await getClientAsync();
206
219
  const vault = await client.vaults.archive(vaultId);
207
220
  out.success(`Vault archived: ${vault.name}`, { id: vault.id, name: vault.name, isArchived: vault.isArchived });
@@ -96,6 +96,8 @@ export class Output {
96
96
  * - table: prints a single-row table
97
97
  */
98
98
  record(data, columns) {
99
+ if (this.flags.quiet)
100
+ return;
99
101
  switch (this.flags.output) {
100
102
  case 'json':
101
103
  process.stdout.write(JSON.stringify(data) + '\n');
@@ -116,9 +118,9 @@ export class Output {
116
118
  * - table: prints an ASCII table
117
119
  */
118
120
  list(data, options) {
121
+ if (this.flags.quiet)
122
+ return;
119
123
  if (data.length === 0) {
120
- if (this.flags.quiet)
121
- return;
122
124
  if (this.flags.output === 'json') {
123
125
  process.stdout.write('[]\n');
124
126
  return;
@@ -133,9 +135,7 @@ export class Output {
133
135
  }
134
136
  switch (this.flags.output) {
135
137
  case 'json':
136
- for (const item of data) {
137
- process.stdout.write(JSON.stringify(item) + '\n');
138
- }
138
+ process.stdout.write(JSON.stringify(data) + '\n');
139
139
  break;
140
140
  case 'table':
141
141
  this.table(data, options?.columns);
@@ -166,8 +166,8 @@ export class Output {
166
166
  * Print a success result (used for create/update/delete confirmations).
167
167
  */
168
168
  success(message, data) {
169
- if (this.flags.output === 'json' && data) {
170
- process.stdout.write(JSON.stringify(data) + '\n');
169
+ if (this.flags.output === 'json') {
170
+ process.stdout.write(JSON.stringify(data ?? { success: true, message }) + '\n');
171
171
  }
172
172
  else if (!this.flags.quiet) {
173
173
  this.succeedSpinner(message);
@@ -11,7 +11,7 @@ export async function resolveVaultId(idOrSlug) {
11
11
  if (UUID_RE.test(idOrSlug))
12
12
  return idOrSlug;
13
13
  const client = await getClientAsync();
14
- const vaults = await client.vaults.list();
14
+ const vaults = await client.vaults.list({ includeArchived: true });
15
15
  const match = vaults.find(v => v.slug === idOrSlug);
16
16
  if (!match)
17
17
  throw new Error(`Vault not found: "${idOrSlug}"`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifestreamdynamics/vault-cli",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "Command-line interface for Lifestream Vault",
5
5
  "engines": {
6
6
  "node": ">=22"