@koda-sl/baker-cli 0.355.0-dev.c2de9a6fe → 0.355.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/cli.js CHANGED
@@ -68,7 +68,7 @@ import {
68
68
  validateCanvasDeep,
69
69
  withoutCastName,
70
70
  ytDlpBlockSignal
71
- } from "./chunk-B7MLH3K6.js";
71
+ } from "./chunk-4HRJQGVW.js";
72
72
  import {
73
73
  csvOrJson,
74
74
  daysAgoIso,
@@ -33563,6 +33563,19 @@ function pageOf(args5) {
33563
33563
  ...size ? { pageSize: Number(size) } : {}
33564
33564
  };
33565
33565
  }
33566
+ function isWholePositive(raw) {
33567
+ return /^[1-9]\d*$/.test(String(raw));
33568
+ }
33569
+ function paginationError(args5) {
33570
+ if (args5.page !== void 0 && !isWholePositive(args5.page)) {
33571
+ return `--page takes a page number of a list report (1, 2, \u2026), not "${String(args5.page)}". To narrow a report to one page of the site, pass --landing <internalId> (from \`baker analytics landings\`), or read one path with \`baker analytics page --path /pricing\`.`;
33572
+ }
33573
+ const size = args5["page-size"];
33574
+ if (size !== void 0 && !isWholePositive(size)) {
33575
+ return `--page-size takes a number of rows (1 to 200), not "${String(size)}".`;
33576
+ }
33577
+ return null;
33578
+ }
33566
33579
  function requestBody(args5, options) {
33567
33580
  const candidates = {
33568
33581
  preset: options.preset,
@@ -33627,6 +33640,11 @@ async function runPreset(args5, options) {
33627
33640
  });
33628
33641
  process.exit(1);
33629
33642
  }
33643
+ const pagination = paginationError(args5);
33644
+ if (pagination) {
33645
+ writeJsonEnvelope({ ok: false, error: { code: "VALIDATION_ERROR", message: pagination } });
33646
+ process.exit(1);
33647
+ }
33630
33648
  try {
33631
33649
  const response = await apiPost("/api/analytics/query", requestBody(args5, options));
33632
33650
  const requestedPlatform = args5.platform === void 0 ? "" : String(args5.platform);
@@ -39896,18 +39914,10 @@ function dropUncastVoices(nodes) {
39896
39914
  if (node && node.type === "voice_select" && !referenced.has(node.id)) nodes.splice(i, 1);
39897
39915
  }
39898
39916
  }
39899
- function framesReuseRefusal(blueprint, elements, requested) {
39900
- if (requested !== "reuse") return void 0;
39901
- const showsPeople = (blueprint.global?.cast ?? []).length > 0 || elements.some((e) => e.type.toLowerCase() === "person");
39902
- if (!showsPeople) return void 0;
39903
- return "--frames reuse was not applied: this video shows people, and reusing its frames would put the source's actors into our ad. Every frame is generated instead, recast to the el_* references. Reuse applies only to a video with nobody in it.";
39904
- }
39905
- function scaffoldVideoCanvas(input, elementsInput, requested) {
39917
+ function scaffoldVideoCanvas(input, elementsInput, opts) {
39906
39918
  const blueprint = VideoBlueprint.parse(input);
39907
39919
  injectHookPhysicality(blueprint);
39908
39920
  const elements = RecurringElements.parse(elementsInput);
39909
- const reuseRefused = framesReuseRefusal(blueprint, elements, requested.frames);
39910
- const opts = reuseRefused ? { ...requested, frames: "generate" } : requested;
39911
39921
  const clock = spineClockFor(blueprint);
39912
39922
  const nodes = [];
39913
39923
  emitBlueprintIngests(opts, nodes);
@@ -40014,7 +40024,6 @@ function scaffoldVideoCanvas(input, elementsInput, requested) {
40014
40024
  }
40015
40025
  const todo = {
40016
40026
  ...buildVideoTodo(videoReport(input, elementsInput), overlays.length, floating.length, opts, blueprint),
40017
- ...reuseRefused ? { frames_reuse_refused: reuseRefused } : {},
40018
40027
  ...aspectRemapTodo(resolveAspect(blueprint.source?.aspect_ratio, opts.aspect, genAspectsFor(opts.videoModel))),
40019
40028
  model_constraints: buildModelConstraints()
40020
40029
  };
@@ -44822,12 +44831,6 @@ function videoDefinitionDescription(blueprint) {
44822
44831
  const product = g.branding?.product;
44823
44832
  return typeof product === "string" && product.trim() ? product.trim() : void 0;
44824
44833
  }
44825
- function framesModeReport(canvas, requested) {
44826
- const todo = canvas.metadata?.todo;
44827
- const mode = typeof todo?.frames_mode === "string" ? todo.frames_mode : requested;
44828
- const refused = typeof todo?.frames_reuse_refused === "string" ? todo.frames_reuse_refused : void 0;
44829
- return { frames_mode: mode, ...refused ? { frames_reuse_refused: refused } : {} };
44830
- }
44831
44834
  async function materializeReferenceVideo(fileArg2) {
44832
44835
  if (!/^https?:\/\//i.test(fileArg2)) return path26.resolve(fileArg2);
44833
44836
  let bytes;
@@ -44985,10 +44988,7 @@ var scaffoldVideoCommand = defineCommand116({
44985
44988
  type: "string",
44986
44989
  description: "Creative slug \u2014 writes the canvas to src/creatives/<slug>/<slug>.canvas.json (repo convention)"
44987
44990
  },
44988
- frames: {
44989
- type: "string",
44990
- description: `"generate" (default, every frame regenerated for our ad) or "reuse" (wire the source's real frames in). Reuse applies only to a video with nobody in it \u2014 on a video showing people it is refused and every frame is generated, so the source's actors never reach our ad.`
44991
- },
44991
+ frames: { type: "string", description: '"generate" (default, anchored regen) or "reuse" (wire real frames in)' },
44992
44992
  ambient: {
44993
44993
  type: "boolean",
44994
44994
  description: "Give silent b-roll scenes native diegetic ambient mixed deep under the music bed (off by default)"
@@ -45176,7 +45176,6 @@ var scaffoldVideoCommand = defineCommand116({
45176
45176
  error: { code: "validation", issues: validation.issues },
45177
45177
  canvas_path: outPath,
45178
45178
  prompt_path: blueprintPath,
45179
- ...framesModeReport(canvas, frames),
45180
45179
  note: "The canvas WAS written despite the blocking issue(s) \u2014 fix them in place, then `baker canvas validate` before running."
45181
45180
  },
45182
45181
  null,
@@ -45226,7 +45225,7 @@ var scaffoldVideoCommand = defineCommand116({
45226
45225
  source_reference: sourceRef.url,
45227
45226
  composition_dir: compositionDest,
45228
45227
  output: canvas.output,
45229
- ...framesModeReport(canvas, frames),
45228
+ frames_mode: frames,
45230
45229
  models: {
45231
45230
  deconstruct: deconstructModel,
45232
45231
  select: selectModel,
@@ -68791,19 +68790,36 @@ function findUnknownFlags(root, argv) {
68791
68790
  }
68792
68791
  return unknown;
68793
68792
  }
68793
+ var SYNONYMS = {
68794
+ from: ["start-date", "start", "since"],
68795
+ since: ["start-date", "start"],
68796
+ start: ["start-date", "since"],
68797
+ to: ["end-date", "end", "until"],
68798
+ until: ["end-date", "end"],
68799
+ end: ["end-date", "until"],
68800
+ path: ["landing"],
68801
+ url: ["landing"]
68802
+ };
68794
68803
  function closestFlag(unknown, command) {
68795
68804
  const accepted = acceptedNames(command);
68796
68805
  if (!accepted) {
68797
68806
  return null;
68798
68807
  }
68799
68808
  const name = unknown.replace(/^--/, "").split("=")[0] ?? "";
68809
+ const synonym = SYNONYMS[name]?.find((candidate) => accepted.has(candidate));
68810
+ if (synonym) {
68811
+ return `--${synonym}`;
68812
+ }
68800
68813
  const scored = [...accepted].filter((candidate) => !ALWAYS_ACCEPTED.has(candidate)).map((candidate) => ({
68801
68814
  candidate,
68802
68815
  prefix: sharedPrefix(name, candidate),
68803
68816
  distance: editDistance(name, candidate)
68804
- })).filter(({ prefix, distance }) => prefix >= 4 || distance <= 3).sort((a, b) => b.prefix - a.prefix || a.distance - b.distance);
68817
+ })).filter(({ prefix, distance }) => prefix >= 4 || distance <= typoBudget(name)).sort((a, b) => b.prefix - a.prefix || a.distance - b.distance);
68805
68818
  return scored[0] ? `--${scored[0].candidate}` : null;
68806
68819
  }
68820
+ function typoBudget(name) {
68821
+ return Math.max(1, Math.floor(name.length / 3));
68822
+ }
68807
68823
  function sharedPrefix(a, b) {
68808
68824
  let i = 0;
68809
68825
  while (i < a.length && i < b.length && a[i] === b[i]) {
@@ -68827,6 +68843,24 @@ function commandFor(root, argv) {
68827
68843
  const { command, resolved } = resolveCommand2(root, argv);
68828
68844
  return resolved ? command : null;
68829
68845
  }
68846
+ function suggestFlag(unknown, command) {
68847
+ const flag = closestFlag(unknown, command);
68848
+ if (!flag) {
68849
+ return null;
68850
+ }
68851
+ const args5 = argsOf(command) ?? {};
68852
+ const name = flag.slice(2);
68853
+ const def = args5[name] ?? args5[camel(name)];
68854
+ const described = def && typeof def === "object" ? def.description : void 0;
68855
+ const description = typeof described === "string" ? described.split(/(?<!\b(?:e\.g|i\.e|vs))\.\s/)[0]?.trim().replace(/\.$/, "") : "";
68856
+ return description ? { flag, description } : { flag };
68857
+ }
68858
+ function suggestionText(suggestion) {
68859
+ if (!suggestion) {
68860
+ return "";
68861
+ }
68862
+ return suggestion.description ? `Did you mean ${suggestion.flag}? It is described as: ${suggestion.description}. ` : `Did you mean ${suggestion.flag}? `;
68863
+ }
68830
68864
  var OUTPUT_EXPLANATION = "This command has no --output option: `--output json` is accepted by every command that prints the JSON envelope, and md or files only where `baker schema` lists `output`. Drop the option and read the default output. ";
68831
68865
  function unknownFlagEnvelope(unknown, commandPath, suggestion, hasSchema) {
68832
68866
  const list = unknown.join(", ");
@@ -68837,7 +68871,7 @@ function unknownFlagEnvelope(unknown, commandPath, suggestion, hasSchema) {
68837
68871
  message: `${list} ${unknown.length > 1 ? "are not options" : "is not an option"} of \`baker ${commandPath}\`.`,
68838
68872
  fix: {
68839
68873
  action: hasSchema ? "check_schema" : "check_help",
68840
- explanation: (unknown.some((flag) => flag === "--output" || flag.startsWith("--output=")) ? OUTPUT_EXPLANATION : "") + (suggestion ? `Did you mean ${suggestion}? ` : "") + `Run \`${hasSchema ? `baker schema ${commandPath}` : `baker ${commandPath} --help`}\` to see every option this command takes. Do not re-run the same call: until this version an unrecognised option was accepted and ignored, so a command that looked like it had filtered or narrowed the result was in fact answering the unfiltered question.`
68874
+ explanation: (unknown.some((flag) => flag === "--output" || flag.startsWith("--output=")) ? OUTPUT_EXPLANATION : "") + suggestionText(suggestion) + `Run \`${hasSchema ? `baker schema ${commandPath}` : `baker ${commandPath} --help`}\` to see every option this command takes. Do not re-run the same call: until this version an unrecognised option was accepted and ignored, so a command that looked like it had filtered or narrowed the result was in fact answering the unfiltered question.`
68841
68875
  },
68842
68876
  retryable: false
68843
68877
  }
@@ -68867,7 +68901,7 @@ function refuseUnknownFlags(root, argv) {
68867
68901
  }
68868
68902
  const command = commandFor(root, argv);
68869
68903
  const first = unknown[0];
68870
- const suggestion = command && first ? closestFlag(first, command) : null;
68904
+ const suggestion = command && first ? suggestFlag(first, command) : null;
68871
68905
  const path48 = commandPathOf(root, argv);
68872
68906
  process.stdout.write(
68873
68907
  `${JSON.stringify(unknownFlagEnvelope(unknown, path48, suggestion, findSchema(path48.split(" ")) !== void 0), null, 2)}