zinkee 0.1.60 → 0.1.61

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-W3BI6KES.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-VXDDPC3X.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,22 @@ 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
+ }
814
825
  function createCommandContext(command, filePath) {
815
826
  try {
827
+ const overrides = command.optsWithGlobals();
828
+ const idempotencyKey = validateIdempotencyKey(overrides.idempotencyKey);
816
829
  const config = readRuntimeConfig(filePath);
817
- const runtime = resolveRuntimeContext(config, command.optsWithGlobals());
830
+ const runtime = resolveRuntimeContext(config, overrides);
818
831
  if (!runtime.baseUrl) {
819
832
  throw new CliError(
820
833
  "configuration_error",
@@ -823,7 +836,7 @@ function createCommandContext(command, filePath) {
823
836
  }
824
837
  const getToken = runtime.session && runtime.workspace ? createWorkspaceTokenProvider({ profile: runtime.profile, ...runtime.session }, runtime.workspace) : void 0;
825
838
  return {
826
- client: new ApiClient({ baseUrl: runtime.baseUrl, apiKey: runtime.apiKey, getToken }),
839
+ client: new ApiClient({ baseUrl: runtime.baseUrl, apiKey: runtime.apiKey, getToken, idempotencyKey }),
827
840
  json: runtime.json,
828
841
  profile: runtime.profile,
829
842
  readOnly: runtime.readOnly
@@ -6276,7 +6289,7 @@ var require2 = createRequire(import.meta.url);
6276
6289
  var { version } = require2("../package.json");
6277
6290
  function buildProgram(options = {}) {
6278
6291
  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");
6292
+ 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
6293
  registerProfilesCommands(program, options);
6281
6294
  registerSessionCommands(program, options);
6282
6295
  registerAutomationsCommands(program, options);