ardent-cli 0.0.1 → 0.0.3

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.
Files changed (2) hide show
  1. package/dist/index.js +17 -4
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -438,6 +438,17 @@ function truncate(str, maxLen) {
438
438
  if (str.length <= maxLen) return str;
439
439
  return str.slice(0, maxLen - 2) + "..";
440
440
  }
441
+ function parseDiffRow(raw) {
442
+ return {
443
+ schema_name: raw.schema_name,
444
+ table_name: raw.table_name,
445
+ primary_key: raw.primary_key,
446
+ first_op: raw.first_op,
447
+ last_op: raw.last_op,
448
+ first_data: raw.original_values ? JSON.parse(raw.original_values) : null,
449
+ last_data: raw.final_values ? JSON.parse(raw.final_values) : null
450
+ };
451
+ }
441
452
  var diffCommand = new Command3("diff").description("Show CDC changes on current branch").option("-b, --branch <name>", "Branch name (defaults to current)").option("--sql", "Output as replay SQL").action(async (options) => {
442
453
  let branch;
443
454
  if (options.branch) {
@@ -460,13 +471,15 @@ var diffCommand = new Command3("diff").description("Show CDC changes on current
460
471
  return;
461
472
  }
462
473
  try {
463
- const state = await api.get(`/v1/branches/${branch.job_id}/state`);
464
- if (!state || Object.keys(state).length === 0) {
474
+ const stateRaw = await api.get(`/v1/branches/${branch.job_id}/state`);
475
+ if (!stateRaw || Object.keys(stateRaw).length === 0) {
465
476
  console.log("No changes captured");
466
477
  return;
467
478
  }
468
- for (const [_branchId, branchState] of Object.entries(state)) {
469
- const { diff, ddl, replay_sql } = branchState;
479
+ for (const [_branchId, branchStateRaw] of Object.entries(stateRaw)) {
480
+ const ddl = branchStateRaw.ddl;
481
+ const replay_sql = branchStateRaw.replay_sql;
482
+ const diff = (branchStateRaw.diff || []).map(parseDiffRow);
470
483
  if (options.sql) {
471
484
  if (replay_sql) {
472
485
  console.log(replay_sql);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "ardent-cli",
3
- "version": "0.0.1",
4
- "description": "CLI for Ardent database branching",
3
+ "version": "0.0.3",
4
+ "description": "Git for Data infrastructure",
5
5
  "type": "module",
6
6
  "bin": {
7
- "ardent": "./dist/index.js"
7
+ "ardent": "dist/index.js"
8
8
  },
9
9
  "scripts": {
10
10
  "build": "tsup",