@hasna/cloud 0.1.12 → 0.1.14
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/index.js +25 -13
- package/dist/index.js +25 -13
- package/dist/mcp/index.js +25 -13
- package/dist/sync.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -11443,6 +11443,30 @@ async function resolvePrimaryKeys(source, target, table, pkOption) {
|
|
|
11443
11443
|
}
|
|
11444
11444
|
return pks;
|
|
11445
11445
|
}
|
|
11446
|
+
async function filterColumnsForTarget(target, table, sourceColumns) {
|
|
11447
|
+
try {
|
|
11448
|
+
if (!isAsyncAdapter(target)) {
|
|
11449
|
+
const colInfo = target.all(`PRAGMA table_info("${table}")`);
|
|
11450
|
+
if (Array.isArray(colInfo) && colInfo.length > 0) {
|
|
11451
|
+
const targetCols = new Set(colInfo.map((c) => c.name));
|
|
11452
|
+
const filtered = sourceColumns.filter((c) => targetCols.has(c));
|
|
11453
|
+
if (filtered.length < sourceColumns.length) {
|
|
11454
|
+
const dropped = sourceColumns.filter((c) => !targetCols.has(c));
|
|
11455
|
+
process.stderr.write(` [sync] ${table}: dropping ${dropped.length} columns not in target: ${dropped.join(", ")}
|
|
11456
|
+
`);
|
|
11457
|
+
}
|
|
11458
|
+
return filtered;
|
|
11459
|
+
}
|
|
11460
|
+
} else {
|
|
11461
|
+
const colInfo = await target.all(`SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '${table}'`);
|
|
11462
|
+
if (colInfo.length > 0) {
|
|
11463
|
+
const targetCols = new Set(colInfo.map((c) => c.column_name));
|
|
11464
|
+
return sourceColumns.filter((c) => targetCols.has(c));
|
|
11465
|
+
}
|
|
11466
|
+
}
|
|
11467
|
+
} catch {}
|
|
11468
|
+
return sourceColumns;
|
|
11469
|
+
}
|
|
11446
11470
|
async function syncTransfer(source, target, options, _direction) {
|
|
11447
11471
|
const {
|
|
11448
11472
|
tables,
|
|
@@ -11493,19 +11517,7 @@ async function syncTransfer(source, target, options, _direction) {
|
|
|
11493
11517
|
}
|
|
11494
11518
|
const pkColumns = await resolvePrimaryKeys(source, target, table, pkOption);
|
|
11495
11519
|
const sourceColumns = Object.keys(rows[0]);
|
|
11496
|
-
|
|
11497
|
-
if (!isAsyncAdapter(target)) {
|
|
11498
|
-
try {
|
|
11499
|
-
const colInfo = target.all(`PRAGMA table_info("${table}")`);
|
|
11500
|
-
targetColumns = new Set(colInfo.map((c) => c.name));
|
|
11501
|
-
} catch {}
|
|
11502
|
-
} else {
|
|
11503
|
-
try {
|
|
11504
|
-
const colInfo = await target.all(`SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '${table}'`);
|
|
11505
|
-
targetColumns = new Set(colInfo.map((c) => c.column_name));
|
|
11506
|
-
} catch {}
|
|
11507
|
-
}
|
|
11508
|
-
const columns = targetColumns ? sourceColumns.filter((c) => targetColumns.has(c)) : sourceColumns;
|
|
11520
|
+
const columns = await filterColumnsForTarget(target, table, sourceColumns);
|
|
11509
11521
|
if (pkColumns.length === 0) {
|
|
11510
11522
|
result.errors.push(`Table "${table}" has no primary key — inserting without conflict handling`);
|
|
11511
11523
|
onProgress?.({
|
package/dist/index.js
CHANGED
|
@@ -9435,6 +9435,30 @@ async function resolvePrimaryKeys(source, target, table, pkOption) {
|
|
|
9435
9435
|
}
|
|
9436
9436
|
return pks;
|
|
9437
9437
|
}
|
|
9438
|
+
async function filterColumnsForTarget(target, table, sourceColumns) {
|
|
9439
|
+
try {
|
|
9440
|
+
if (!isAsyncAdapter(target)) {
|
|
9441
|
+
const colInfo = target.all(`PRAGMA table_info("${table}")`);
|
|
9442
|
+
if (Array.isArray(colInfo) && colInfo.length > 0) {
|
|
9443
|
+
const targetCols = new Set(colInfo.map((c) => c.name));
|
|
9444
|
+
const filtered = sourceColumns.filter((c) => targetCols.has(c));
|
|
9445
|
+
if (filtered.length < sourceColumns.length) {
|
|
9446
|
+
const dropped = sourceColumns.filter((c) => !targetCols.has(c));
|
|
9447
|
+
process.stderr.write(` [sync] ${table}: dropping ${dropped.length} columns not in target: ${dropped.join(", ")}
|
|
9448
|
+
`);
|
|
9449
|
+
}
|
|
9450
|
+
return filtered;
|
|
9451
|
+
}
|
|
9452
|
+
} else {
|
|
9453
|
+
const colInfo = await target.all(`SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '${table}'`);
|
|
9454
|
+
if (colInfo.length > 0) {
|
|
9455
|
+
const targetCols = new Set(colInfo.map((c) => c.column_name));
|
|
9456
|
+
return sourceColumns.filter((c) => targetCols.has(c));
|
|
9457
|
+
}
|
|
9458
|
+
}
|
|
9459
|
+
} catch {}
|
|
9460
|
+
return sourceColumns;
|
|
9461
|
+
}
|
|
9438
9462
|
async function syncTransfer(source, target, options, _direction) {
|
|
9439
9463
|
const {
|
|
9440
9464
|
tables,
|
|
@@ -9485,19 +9509,7 @@ async function syncTransfer(source, target, options, _direction) {
|
|
|
9485
9509
|
}
|
|
9486
9510
|
const pkColumns = await resolvePrimaryKeys(source, target, table, pkOption);
|
|
9487
9511
|
const sourceColumns = Object.keys(rows[0]);
|
|
9488
|
-
|
|
9489
|
-
if (!isAsyncAdapter(target)) {
|
|
9490
|
-
try {
|
|
9491
|
-
const colInfo = target.all(`PRAGMA table_info("${table}")`);
|
|
9492
|
-
targetColumns = new Set(colInfo.map((c) => c.name));
|
|
9493
|
-
} catch {}
|
|
9494
|
-
} else {
|
|
9495
|
-
try {
|
|
9496
|
-
const colInfo = await target.all(`SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '${table}'`);
|
|
9497
|
-
targetColumns = new Set(colInfo.map((c) => c.column_name));
|
|
9498
|
-
} catch {}
|
|
9499
|
-
}
|
|
9500
|
-
const columns = targetColumns ? sourceColumns.filter((c) => targetColumns.has(c)) : sourceColumns;
|
|
9512
|
+
const columns = await filterColumnsForTarget(target, table, sourceColumns);
|
|
9501
9513
|
if (pkColumns.length === 0) {
|
|
9502
9514
|
result.errors.push(`Table "${table}" has no primary key — inserting without conflict handling`);
|
|
9503
9515
|
onProgress?.({
|
package/dist/mcp/index.js
CHANGED
|
@@ -24782,6 +24782,30 @@ async function resolvePrimaryKeys(source, target, table, pkOption) {
|
|
|
24782
24782
|
}
|
|
24783
24783
|
return pks;
|
|
24784
24784
|
}
|
|
24785
|
+
async function filterColumnsForTarget(target, table, sourceColumns) {
|
|
24786
|
+
try {
|
|
24787
|
+
if (!isAsyncAdapter(target)) {
|
|
24788
|
+
const colInfo = target.all(`PRAGMA table_info("${table}")`);
|
|
24789
|
+
if (Array.isArray(colInfo) && colInfo.length > 0) {
|
|
24790
|
+
const targetCols = new Set(colInfo.map((c) => c.name));
|
|
24791
|
+
const filtered = sourceColumns.filter((c) => targetCols.has(c));
|
|
24792
|
+
if (filtered.length < sourceColumns.length) {
|
|
24793
|
+
const dropped = sourceColumns.filter((c) => !targetCols.has(c));
|
|
24794
|
+
process.stderr.write(` [sync] ${table}: dropping ${dropped.length} columns not in target: ${dropped.join(", ")}
|
|
24795
|
+
`);
|
|
24796
|
+
}
|
|
24797
|
+
return filtered;
|
|
24798
|
+
}
|
|
24799
|
+
} else {
|
|
24800
|
+
const colInfo = await target.all(`SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '${table}'`);
|
|
24801
|
+
if (colInfo.length > 0) {
|
|
24802
|
+
const targetCols = new Set(colInfo.map((c) => c.column_name));
|
|
24803
|
+
return sourceColumns.filter((c) => targetCols.has(c));
|
|
24804
|
+
}
|
|
24805
|
+
}
|
|
24806
|
+
} catch {}
|
|
24807
|
+
return sourceColumns;
|
|
24808
|
+
}
|
|
24785
24809
|
async function syncTransfer(source, target, options, _direction) {
|
|
24786
24810
|
const {
|
|
24787
24811
|
tables,
|
|
@@ -24832,19 +24856,7 @@ async function syncTransfer(source, target, options, _direction) {
|
|
|
24832
24856
|
}
|
|
24833
24857
|
const pkColumns = await resolvePrimaryKeys(source, target, table, pkOption);
|
|
24834
24858
|
const sourceColumns = Object.keys(rows[0]);
|
|
24835
|
-
|
|
24836
|
-
if (!isAsyncAdapter(target)) {
|
|
24837
|
-
try {
|
|
24838
|
-
const colInfo = target.all(`PRAGMA table_info("${table}")`);
|
|
24839
|
-
targetColumns = new Set(colInfo.map((c) => c.name));
|
|
24840
|
-
} catch {}
|
|
24841
|
-
} else {
|
|
24842
|
-
try {
|
|
24843
|
-
const colInfo = await target.all(`SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '${table}'`);
|
|
24844
|
-
targetColumns = new Set(colInfo.map((c) => c.column_name));
|
|
24845
|
-
} catch {}
|
|
24846
|
-
}
|
|
24847
|
-
const columns = targetColumns ? sourceColumns.filter((c) => targetColumns.has(c)) : sourceColumns;
|
|
24859
|
+
const columns = await filterColumnsForTarget(target, table, sourceColumns);
|
|
24848
24860
|
if (pkColumns.length === 0) {
|
|
24849
24861
|
result.errors.push(`Table "${table}" has no primary key — inserting without conflict handling`);
|
|
24850
24862
|
onProgress?.({
|
package/dist/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAMnD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;AAEpE,MAAM,WAAW,WAAW;IAC1B,sBAAsB;IACtB,MA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