@tinycloud/cli 0.6.0-beta.10 → 0.6.0-beta.11

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/index.js CHANGED
@@ -2337,14 +2337,19 @@ async function readStdin2() {
2337
2337
  }
2338
2338
  return Buffer.concat(chunks);
2339
2339
  }
2340
+ async function kvHandle(node, spaceInput, profileName) {
2341
+ const spaceUri = await resolveSpaceUri(spaceInput, profileName);
2342
+ return spaceUri ? node.kvForSpace(spaceUri) : node.kv;
2343
+ }
2340
2344
  function registerKvCommand(program2) {
2341
2345
  const kv = program2.command("kv").description("Key-value store operations");
2342
- kv.command("get <key>").description("Get a value by key").option("--raw", "Output raw value (no JSON wrapping)").option("-o, --output <file>", "Write value to file").action(async (key, options, cmd) => {
2346
+ kv.command("get <key>").description("Get a value by key").option("--raw", "Output raw value (no JSON wrapping)").option("-o, --output <file>", "Write value to file").option("--space <name|uri>", "Target a non-primary space (short name or full URI)").action(async (key, options, cmd) => {
2343
2347
  try {
2344
2348
  const globalOpts = cmd.optsWithGlobals();
2345
2349
  const ctx = await ProfileManager.resolveContext(globalOpts);
2346
2350
  const node = await ensureAuthenticated(ctx);
2347
- const result = await withSpinner(`Getting ${key}...`, () => node.kv.get(key));
2351
+ const kv2 = await kvHandle(node, options.space, ctx.profile);
2352
+ const result = await withSpinner(`Getting ${key}...`, () => kv2.get(key));
2348
2353
  if (!result.ok) {
2349
2354
  if (result.error.code === "KV_NOT_FOUND" || result.error.code === "NOT_FOUND") {
2350
2355
  throw new CLIError("NOT_FOUND", `Key "${key}" not found`, ExitCode.NOT_FOUND);
@@ -2425,13 +2430,14 @@ function registerKvCommand(program2) {
2425
2430
  handleError(error);
2426
2431
  }
2427
2432
  });
2428
- kv.command("list").description("List keys").option("--prefix <prefix>", "Filter by key prefix").action(async (options, cmd) => {
2433
+ kv.command("list").description("List keys").option("--prefix <prefix>", "Filter by key prefix").option("--space <name|uri>", "Target a non-primary space (short name or full URI)").action(async (options, cmd) => {
2429
2434
  try {
2430
2435
  const globalOpts = cmd.optsWithGlobals();
2431
2436
  const ctx = await ProfileManager.resolveContext(globalOpts);
2432
2437
  const node = await ensureAuthenticated(ctx);
2438
+ const kv2 = await kvHandle(node, options.space, ctx.profile);
2433
2439
  const listOptions = options.prefix ? { prefix: options.prefix } : void 0;
2434
- const result = await withSpinner("Listing keys...", () => node.kv.list(listOptions));
2440
+ const result = await withSpinner("Listing keys...", () => kv2.list(listOptions));
2435
2441
  if (!result.ok) {
2436
2442
  throw new CLIError(result.error.code, result.error.message, ExitCode.ERROR);
2437
2443
  }
@@ -2459,12 +2465,13 @@ function registerKvCommand(program2) {
2459
2465
  handleError(error);
2460
2466
  }
2461
2467
  });
2462
- kv.command("head <key>").description("Get metadata for a key (no body)").action(async (key, _options, cmd) => {
2468
+ kv.command("head <key>").description("Get metadata for a key (no body)").option("--space <name|uri>", "Target a non-primary space (short name or full URI)").action(async (key, options, cmd) => {
2463
2469
  try {
2464
2470
  const globalOpts = cmd.optsWithGlobals();
2465
2471
  const ctx = await ProfileManager.resolveContext(globalOpts);
2466
2472
  const node = await ensureAuthenticated(ctx);
2467
- const result = await withSpinner(`Checking ${key}...`, () => node.kv.head(key));
2473
+ const kv2 = await kvHandle(node, options.space, ctx.profile);
2474
+ const result = await withSpinner(`Checking ${key}...`, () => kv2.head(key));
2468
2475
  if (!result.ok) {
2469
2476
  if (result.error.code === "KV_NOT_FOUND" || result.error.code === "NOT_FOUND") {
2470
2477
  outputJson({ key, exists: false, metadata: {} });