zinkee 0.1.35 → 0.1.37

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
@@ -4311,7 +4311,7 @@ var specificExamples = {
4311
4311
  "required": false,
4312
4312
  "system": false,
4313
4313
  "config": {
4314
- "formulaText": "date_format(d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f90, "AAAA-MM")",
4314
+ "formulaText": "date_format(d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f90, \\"AAAA-MM\\")",
4315
4315
  "uiFormatKind": "date",
4316
4316
  "status": "ACTIVE",
4317
4317
  "defaultValue": null,
@@ -6306,10 +6306,23 @@ function buildSchemaFieldCreateExamples(type) {
6306
6306
  );
6307
6307
  }
6308
6308
  function getCommandExamples(commandName, filters = {}) {
6309
- if (commandName === "schemas fields create") {
6310
- return buildSchemaFieldCreateExamples(filters.type);
6309
+ const examples = commandName === "schemas fields create" ? buildSchemaFieldCreateExamples(filters.type) : specificExamples[commandName] ?? fallbackExamples(commandName);
6310
+ return examples.map((example) => withResponseEnvelope(example, commandName));
6311
+ }
6312
+ function withResponseEnvelope(example, commandName) {
6313
+ if (example.response === void 0) {
6314
+ return example;
6315
+ }
6316
+ let payload;
6317
+ try {
6318
+ payload = JSON.parse(example.response);
6319
+ } catch {
6320
+ return example;
6311
6321
  }
6312
- return specificExamples[commandName] ?? fallbackExamples(commandName);
6322
+ return {
6323
+ ...example,
6324
+ response: JSON.stringify(buildJsonSuccess(payload, { command: commandName }), null, 2)
6325
+ };
6313
6326
  }
6314
6327
  function getResolvedCommandExamples(commandName, filters = {}) {
6315
6328
  return getCommandExamples(commandName, filters);
@@ -6341,7 +6354,22 @@ function extractExampleRequest(argv, optionMeta = createDefaultOptionMetadata())
6341
6354
  const operands = collectOperandTokens(userArgs, optionMeta, { skipFlag: "--example" });
6342
6355
  const cmdPath = findCommandPath(operands, commandRegistry);
6343
6356
  if (!cmdPath) {
6344
- throw new CliError("invalid_cli_usage", 'Provide a command after "--example".');
6357
+ const typed = operands.map((operand) => operand.token).join(" ");
6358
+ if (typed.length === 0) {
6359
+ throw new CliError("invalid_cli_usage", 'Provide a command after "--example".');
6360
+ }
6361
+ const subcommands = Object.keys(commandRegistry).filter(
6362
+ (name) => name.startsWith(`${typed} `)
6363
+ );
6364
+ if (subcommands.length > 0) {
6365
+ const list = subcommands.map((name) => ` zinkee --example ${name}`).join("\n");
6366
+ throw new CliError(
6367
+ "invalid_cli_usage",
6368
+ `"${typed}" is a command group, not a runnable command. Available subcommands:
6369
+ ${list}`
6370
+ );
6371
+ }
6372
+ throw new CliError("invalid_cli_usage", `Unknown command "${typed}".`);
6345
6373
  }
6346
6374
  const remainingTokens = userArgs.slice(cmdPath.lastArgvIndex + 1);
6347
6375
  return {