@odla-ai/cli 0.22.1 → 0.23.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/index.cjs CHANGED
@@ -1450,6 +1450,7 @@ function chooseIdMode(options, rows) {
1450
1450
  async function appImport(options) {
1451
1451
  const cfg = await loadProjectConfig(options.configPath);
1452
1452
  const out = options.stdout ?? console;
1453
+ const say = options.json ? (line) => out.error(line) : (line) => out.log(line);
1453
1454
  const doFetch = options.fetch ?? fetch;
1454
1455
  const { tenant } = resolveTenant(cfg, options.env);
1455
1456
  const text = options.file === "-" ? (options.readStdin ?? (() => (0, import_node_fs6.readFileSync)(0, "utf8")))() : (0, import_node_fs6.readFileSync)(options.file, "utf8");
@@ -1471,10 +1472,10 @@ ${detail}${more}`);
1471
1472
  }
1472
1473
  const chunks = (0, import_import.planImportChunks)(ops);
1473
1474
  const result = { tenant, rows: ops.length, chunks: chunks.length, committed: 0, duplicate: 0, txIds: [], ignored };
1474
- if (ignored.length > 0) out.log(`ignoring server-maintained field(s): ${ignored.join(", ")} \u2014 odla-db stamps these on write`);
1475
+ if (ignored.length > 0) say(`ignoring server-maintained field(s): ${ignored.join(", ")} \u2014 odla-db stamps these on write`);
1475
1476
  if (options.dryRun || options.yes !== true) {
1476
1477
  const why = options.dryRun ? "--dry-run" : "no --yes";
1477
- out.log(`${tenant}: would upsert ${ops.length} row(s) across ${chunks.length} transaction(s) \u2014 nothing written (${why})`);
1478
+ say(`${tenant}: would upsert ${ops.length} row(s) across ${chunks.length} transaction(s) \u2014 nothing written (${why})`);
1478
1479
  if (options.json) out.log(JSON.stringify(result, null, 2));
1479
1480
  return result;
1480
1481
  }
@@ -1683,6 +1684,7 @@ function printPlan(out, verb, pre, opts) {
1683
1684
  async function appTransfer(options) {
1684
1685
  const cfg = await loadProjectConfig(options.configPath);
1685
1686
  const out = options.stdout ?? console;
1687
+ const say = options.json ? (line) => out.error(line) : (line) => out.log(line);
1686
1688
  const doFetch = options.fetch ?? fetch;
1687
1689
  const tenants = bothTenants(cfg);
1688
1690
  const route2 = endpointsFor(options.verb, tenants);
@@ -1703,7 +1705,7 @@ async function appTransfer(options) {
1703
1705
  throw new Error(`pre-flight failed${pre.body.error?.code ? ` (${pre.body.error.code})` : ""}: ${pre.body.error?.message ?? pre.status}`);
1704
1706
  }
1705
1707
  const plan = pre.body;
1706
- printPlan(out, options.verb, plan, options);
1708
+ printPlan({ log: say }, options.verb, plan, options);
1707
1709
  if (options.verb === "go-live" && !plan.targetEmpty) {
1708
1710
  throw new Error(
1709
1711
  `${route2.target} already has data \u2014 go-live has already happened. Use \`odla-ai app promote --yes\` to push schema and rules, or \`odla-ai app refresh-sandbox --yes\` to pull live back down.`
@@ -1711,7 +1713,7 @@ async function appTransfer(options) {
1711
1713
  }
1712
1714
  if (plan.blockers.length > 0) throw new Error(`cannot ${options.verb}: ${plan.blockers.map((b) => b.message).join("; ")}`);
1713
1715
  if (options.dryRun || options.yes !== true) {
1714
- out.log(`nothing written (${options.dryRun ? "--dry-run" : "no --yes"})`);
1716
+ say(`nothing written (${options.dryRun ? "--dry-run" : "no --yes"})`);
1715
1717
  if (options.json) out.log(JSON.stringify(plan, null, 2));
1716
1718
  return { ok: true, plan };
1717
1719
  }
@@ -1725,7 +1727,7 @@ async function appTransfer(options) {
1725
1727
  );
1726
1728
  if (res2.status !== 200) throw new Error(`promote failed${res2.body.error?.code ? ` (${res2.body.error.code})` : ""}: ${res2.body.error?.message ?? res2.status}`);
1727
1729
  if (options.json) out.log(JSON.stringify(res2.body, null, 2));
1728
- else out.log(`${route2.target}: promoted ${(res2.body.applied ?? []).join(", ")}`);
1730
+ else say(`${route2.target}: promoted ${(res2.body.applied ?? []).join(", ")}`);
1729
1731
  return { ok: true, plan, result: res2.body };
1730
1732
  }
1731
1733
  const res = await api(
@@ -1744,7 +1746,7 @@ async function appTransfer(options) {
1744
1746
  doFetch
1745
1747
  );
1746
1748
  if (res.status !== 200) throw new Error(`${options.verb} failed${res.body.error?.code ? ` (${res.body.error.code})` : ""}: ${res.body.error?.message ?? res.status}`);
1747
- out.log(`${route2.target}: replaced from ${route2.source} (tx ${res.body.destination?.maxTx}, epoch ${res.body.destination?.epoch}) \u2014 connected clients resync automatically`);
1749
+ say(`${route2.target}: replaced from ${route2.source} (tx ${res.body.destination?.maxTx}, epoch ${res.body.destination?.epoch}) \u2014 connected clients resync automatically`);
1748
1750
  if (options.includeFiles) await copyFiles(cfg, token, route2, doFetch, out);
1749
1751
  if (options.json) out.log(JSON.stringify(res.body, null, 2));
1750
1752
  return { ok: true, plan, result: res.body };