@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/bin.cjs CHANGED
@@ -1390,6 +1390,7 @@ function chooseIdMode(options, rows) {
1390
1390
  async function appImport(options) {
1391
1391
  const cfg = await loadProjectConfig(options.configPath);
1392
1392
  const out = options.stdout ?? console;
1393
+ const say = options.json ? (line) => out.error(line) : (line) => out.log(line);
1393
1394
  const doFetch = options.fetch ?? fetch;
1394
1395
  const { tenant } = resolveTenant(cfg, options.env);
1395
1396
  const text = options.file === "-" ? (options.readStdin ?? (() => (0, import_node_fs6.readFileSync)(0, "utf8")))() : (0, import_node_fs6.readFileSync)(options.file, "utf8");
@@ -1411,10 +1412,10 @@ ${detail}${more}`);
1411
1412
  }
1412
1413
  const chunks = (0, import_import.planImportChunks)(ops);
1413
1414
  const result = { tenant, rows: ops.length, chunks: chunks.length, committed: 0, duplicate: 0, txIds: [], ignored };
1414
- if (ignored.length > 0) out.log(`ignoring server-maintained field(s): ${ignored.join(", ")} \u2014 odla-db stamps these on write`);
1415
+ if (ignored.length > 0) say(`ignoring server-maintained field(s): ${ignored.join(", ")} \u2014 odla-db stamps these on write`);
1415
1416
  if (options.dryRun || options.yes !== true) {
1416
1417
  const why = options.dryRun ? "--dry-run" : "no --yes";
1417
- out.log(`${tenant}: would upsert ${ops.length} row(s) across ${chunks.length} transaction(s) \u2014 nothing written (${why})`);
1418
+ say(`${tenant}: would upsert ${ops.length} row(s) across ${chunks.length} transaction(s) \u2014 nothing written (${why})`);
1418
1419
  if (options.json) out.log(JSON.stringify(result, null, 2));
1419
1420
  return result;
1420
1421
  }
@@ -1623,6 +1624,7 @@ function printPlan(out, verb, pre, opts) {
1623
1624
  async function appTransfer(options) {
1624
1625
  const cfg = await loadProjectConfig(options.configPath);
1625
1626
  const out = options.stdout ?? console;
1627
+ const say = options.json ? (line) => out.error(line) : (line) => out.log(line);
1626
1628
  const doFetch = options.fetch ?? fetch;
1627
1629
  const tenants = bothTenants(cfg);
1628
1630
  const route2 = endpointsFor(options.verb, tenants);
@@ -1643,7 +1645,7 @@ async function appTransfer(options) {
1643
1645
  throw new Error(`pre-flight failed${pre.body.error?.code ? ` (${pre.body.error.code})` : ""}: ${pre.body.error?.message ?? pre.status}`);
1644
1646
  }
1645
1647
  const plan = pre.body;
1646
- printPlan(out, options.verb, plan, options);
1648
+ printPlan({ log: say }, options.verb, plan, options);
1647
1649
  if (options.verb === "go-live" && !plan.targetEmpty) {
1648
1650
  throw new Error(
1649
1651
  `${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.`
@@ -1651,7 +1653,7 @@ async function appTransfer(options) {
1651
1653
  }
1652
1654
  if (plan.blockers.length > 0) throw new Error(`cannot ${options.verb}: ${plan.blockers.map((b) => b.message).join("; ")}`);
1653
1655
  if (options.dryRun || options.yes !== true) {
1654
- out.log(`nothing written (${options.dryRun ? "--dry-run" : "no --yes"})`);
1656
+ say(`nothing written (${options.dryRun ? "--dry-run" : "no --yes"})`);
1655
1657
  if (options.json) out.log(JSON.stringify(plan, null, 2));
1656
1658
  return { ok: true, plan };
1657
1659
  }
@@ -1665,7 +1667,7 @@ async function appTransfer(options) {
1665
1667
  );
1666
1668
  if (res2.status !== 200) throw new Error(`promote failed${res2.body.error?.code ? ` (${res2.body.error.code})` : ""}: ${res2.body.error?.message ?? res2.status}`);
1667
1669
  if (options.json) out.log(JSON.stringify(res2.body, null, 2));
1668
- else out.log(`${route2.target}: promoted ${(res2.body.applied ?? []).join(", ")}`);
1670
+ else say(`${route2.target}: promoted ${(res2.body.applied ?? []).join(", ")}`);
1669
1671
  return { ok: true, plan, result: res2.body };
1670
1672
  }
1671
1673
  const res = await api(
@@ -1684,7 +1686,7 @@ async function appTransfer(options) {
1684
1686
  doFetch
1685
1687
  );
1686
1688
  if (res.status !== 200) throw new Error(`${options.verb} failed${res.body.error?.code ? ` (${res.body.error.code})` : ""}: ${res.body.error?.message ?? res.status}`);
1687
- out.log(`${route2.target}: replaced from ${route2.source} (tx ${res.body.destination?.maxTx}, epoch ${res.body.destination?.epoch}) \u2014 connected clients resync automatically`);
1689
+ say(`${route2.target}: replaced from ${route2.source} (tx ${res.body.destination?.maxTx}, epoch ${res.body.destination?.epoch}) \u2014 connected clients resync automatically`);
1688
1690
  if (options.includeFiles) await copyFiles(cfg, token, route2, doFetch, out);
1689
1691
  if (options.json) out.log(JSON.stringify(res.body, null, 2));
1690
1692
  return { ok: true, plan, result: res.body };