@kanorio/cli 1.3.0 → 1.4.0

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/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createRequire } from "node:module";
3
3
  import { parseCliArgs, UsageError } from "./args.js";
4
4
  import { formatDeprecationWarning } from "./client.js";
5
- import { resolveCommand } from "./commands.js";
5
+ import { printsRawJson, resolveCommand } from "./commands.js";
6
6
  import { HELP } from "./help.js";
7
7
  import { formatError, formatResult } from "./output.js";
8
8
  const require = createRequire(import.meta.url);
@@ -29,7 +29,7 @@ async function main(argv) {
29
29
  // Deprecation warnings go to stderr: with --json, stdout stays clean JSON
30
30
  onDeprecation: (notice) => process.stderr.write(`${formatDeprecationWarning(notice)}\n`),
31
31
  });
32
- process.stdout.write(`${formatResult(result, json)}\n`);
32
+ process.stdout.write(`${formatResult(result, json || printsRawJson(cli.command))}\n`);
33
33
  return 0;
34
34
  }
35
35
  catch (error) {
package/dist/commands.js CHANGED
@@ -712,3 +712,8 @@ export const COMMANDS = {
712
712
  export function resolveCommand(command) {
713
713
  return COMMANDS[command.join(" ")] ?? null;
714
714
  }
715
+ /** Passthrough commands print the response as JSON even without --json: a table would drop nested fields */
716
+ const RAW_JSON_COMMANDS = new Set(["api"]);
717
+ export function printsRawJson(command) {
718
+ return RAW_JSON_COMMANDS.has(command.join(" "));
719
+ }
@@ -132,10 +132,18 @@ export interface DeliveryItemEnvelope<TFieldData, TExpanded = Record<string, unk
132
132
  /** Alt text written for an image where this item uses it (image and gallery fields that \`fieldData\` includes) */
133
133
  imageAlt: ImageAltMap;
134
134
  expanded?: TExpanded;
135
- /** Multilingual sites: the locale this item was served in (the requested locale when a translation exists, otherwise the primary locale) */
135
+ /**
136
+ * Multilingual sites: the locale this item was served in (the requested locale when at least one field has a translation,
137
+ * otherwise the primary locale). Fields fall back one by one: check \`fieldLocales\` for a particular field
138
+ */
136
139
  resolvedLocale?: string;
137
140
  /** Multilingual sites: secondary locales that have a published translation of this item */
138
141
  availableLocales?: string[];
142
+ /**
143
+ * Multilingual sites: the locale each translatable field was served in, keyed by its path in \`fieldData\` (\`content\`,
144
+ * \`seo.title\`). A field without a translation shows the primary locale. json, image and gallery fields are never machine-translated
145
+ */
146
+ fieldLocales?: Record<string, string>;
139
147
  /** Multilingual sites: the slug in every live locale */
140
148
  localeSlugs?: Record<string, string>;
141
149
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanorio/cli",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Thin command-line wrapper around the Kanorio Management API (/api/v1), TypeScript codegen (kanorio types), and external frontend doctor (kanorio doctor).",
5
5
  "license": "MIT",
6
6
  "private": false,