zinkee 0.1.60 → 0.1.62

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
@@ -18,7 +18,7 @@ import {
18
18
  normalizeSchemaFieldUpdatePayload,
19
19
  printTable,
20
20
  toCliError
21
- } from "./chunk-RHSXS2M4.js";
21
+ } from "./chunk-JBTOZQSO.js";
22
22
 
23
23
  // src/cli-runner.ts
24
24
  import { realpathSync } from "fs";
@@ -32,6 +32,7 @@ var HOISTABLE_GLOBAL_FLAGS = {
32
32
  "--api-key": "value",
33
33
  "--workspace": "value",
34
34
  "--read-only": "boolean",
35
+ "--idempotency-key": "value",
35
36
  "--json": "boolean"
36
37
  };
37
38
  function isHoistableFlag(flagName) {
@@ -252,7 +253,7 @@ ${list}`
252
253
  };
253
254
  }
254
255
  async function showExamples(commandName, json, stdout, filters = {}) {
255
- const { getCommandExamples } = await import("./examples-ELI5SKQH.js");
256
+ const { getCommandExamples } = await import("./examples-W3D7LVWT.js");
256
257
  const examples = getCommandExamples(commandName, filters);
257
258
  if (examples.length === 0) {
258
259
  throw new CliError("invalid_cli_usage", `No examples registered for "${commandName}".`);
@@ -811,10 +812,28 @@ function resolveRuntimeContext(config, overrides = {}) {
811
812
  }
812
813
 
813
814
  // src/commands/shared.ts
815
+ var IDEMPOTENCY_KEY_PATTERN = /^[A-Za-z0-9._:-]{1,128}$/;
816
+ function validateIdempotencyKey(key) {
817
+ if (key !== void 0 && !IDEMPOTENCY_KEY_PATTERN.test(key)) {
818
+ throw new CliError(
819
+ "invalid_cli_usage",
820
+ `Invalid --idempotency-key "${key}": use 1-128 characters among letters, digits, ".", "_", ":" and "-".`
821
+ );
822
+ }
823
+ return key;
824
+ }
825
+ function noteRateLimitRetry({ retryAfterSeconds, nextAttempt, maxAttempts }) {
826
+ process.stderr.write(
827
+ `Rate limit reached; retrying in ${retryAfterSeconds} s (attempt ${nextAttempt} of ${maxAttempts}).
828
+ `
829
+ );
830
+ }
814
831
  function createCommandContext(command, filePath) {
815
832
  try {
833
+ const overrides = command.optsWithGlobals();
834
+ const idempotencyKey = validateIdempotencyKey(overrides.idempotencyKey);
816
835
  const config = readRuntimeConfig(filePath);
817
- const runtime = resolveRuntimeContext(config, command.optsWithGlobals());
836
+ const runtime = resolveRuntimeContext(config, overrides);
818
837
  if (!runtime.baseUrl) {
819
838
  throw new CliError(
820
839
  "configuration_error",
@@ -823,7 +842,13 @@ function createCommandContext(command, filePath) {
823
842
  }
824
843
  const getToken = runtime.session && runtime.workspace ? createWorkspaceTokenProvider({ profile: runtime.profile, ...runtime.session }, runtime.workspace) : void 0;
825
844
  return {
826
- client: new ApiClient({ baseUrl: runtime.baseUrl, apiKey: runtime.apiKey, getToken }),
845
+ client: new ApiClient({
846
+ baseUrl: runtime.baseUrl,
847
+ apiKey: runtime.apiKey,
848
+ getToken,
849
+ idempotencyKey,
850
+ onRateLimitRetry: noteRateLimitRetry
851
+ }),
827
852
  json: runtime.json,
828
853
  profile: runtime.profile,
829
854
  readOnly: runtime.readOnly
@@ -6276,7 +6301,7 @@ var require2 = createRequire(import.meta.url);
6276
6301
  var { version } = require2("../package.json");
6277
6302
  function buildProgram(options = {}) {
6278
6303
  const program = new Command4();
6279
- program.name("zinkee").description("CLI for Zinkee API v2").version(version).enablePositionalOptions().showHelpAfterError().option("--profile <name>", "select a profile from config").option("--base-url <url>", "override the configured base URL").option("--api-key <token>", "override the configured API key").option("--workspace <workspace>", "workspace name or id for a session profile (or ZINKEE_WORKSPACE)").option("--read-only", "run in read-only mode").option("--example", "show examples for a command").option("--json", "emit JSON output").option("--install-completion [shell]", "install shell completion (bash, zsh, fish, powershell)").option("--show-completion [shell]", "print shell completion script for the current shell");
6304
+ program.name("zinkee").description("CLI for Zinkee API v2").version(version).enablePositionalOptions().showHelpAfterError().option("--profile <name>", "select a profile from config").option("--base-url <url>", "override the configured base URL").option("--api-key <token>", "override the configured API key").option("--workspace <workspace>", "workspace name or id for a session profile (or ZINKEE_WORKSPACE)").option("--read-only", "run in read-only mode").option("--idempotency-key <key>", "send this Idempotency-Key on the write request so a retry does not repeat it").option("--example", "show examples for a command").option("--json", "emit JSON output").option("--install-completion [shell]", "install shell completion (bash, zsh, fish, powershell)").option("--show-completion [shell]", "print shell completion script for the current shell");
6280
6305
  registerProfilesCommands(program, options);
6281
6306
  registerSessionCommands(program, options);
6282
6307
  registerAutomationsCommands(program, options);