@hasna/cloud 0.1.9 → 0.1.11
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 +29 -3
- package/dist/index.js +29 -3
- package/dist/mcp/index.js +29 -3
- package/dist/sync.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -11490,7 +11490,20 @@ async function syncTransfer(source, target, options, _direction) {
|
|
|
11490
11490
|
continue;
|
|
11491
11491
|
}
|
|
11492
11492
|
const pkColumns = await resolvePrimaryKeys(source, target, table, pkOption);
|
|
11493
|
-
const
|
|
11493
|
+
const sourceColumns = Object.keys(rows[0]);
|
|
11494
|
+
let targetColumns = null;
|
|
11495
|
+
if (!isAsyncAdapter(target)) {
|
|
11496
|
+
try {
|
|
11497
|
+
const colInfo = target.all(`PRAGMA table_info("${table}")`);
|
|
11498
|
+
targetColumns = new Set(colInfo.map((c) => c.name));
|
|
11499
|
+
} catch {}
|
|
11500
|
+
} else {
|
|
11501
|
+
try {
|
|
11502
|
+
const colInfo = await target.all(`SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '${table}'`);
|
|
11503
|
+
targetColumns = new Set(colInfo.map((c) => c.column_name));
|
|
11504
|
+
} catch {}
|
|
11505
|
+
}
|
|
11506
|
+
const columns = targetColumns ? sourceColumns.filter((c) => targetColumns.has(c)) : sourceColumns;
|
|
11494
11507
|
if (pkColumns.length === 0) {
|
|
11495
11508
|
result.errors.push(`Table "${table}" has no primary key — inserting without conflict handling`);
|
|
11496
11509
|
onProgress?.({
|
|
@@ -11605,7 +11618,7 @@ function batchUpsertSqlite(target, table, columns, updateCols, primaryKeys, batc
|
|
|
11605
11618
|
const setClause = updateCols.length > 0 ? updateCols.map((c) => `"${c}" = EXCLUDED."${c}"`).join(", ") : `"${primaryKeys[0]}" = EXCLUDED."${primaryKeys[0]}"`;
|
|
11606
11619
|
const sql = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}
|
|
11607
11620
|
ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}`;
|
|
11608
|
-
const params = batch.flatMap((row) => columns.map((c) => row[c]
|
|
11621
|
+
const params = batch.flatMap((row) => columns.map((c) => coerceForSqlite(row[c])));
|
|
11609
11622
|
target.run(sql, ...params);
|
|
11610
11623
|
}
|
|
11611
11624
|
async function batchInsertPg(target, table, columns, batch) {
|
|
@@ -11626,9 +11639,22 @@ function batchInsertSqlite(target, table, columns, batch) {
|
|
|
11626
11639
|
const colList = columns.map((c) => `"${c}"`).join(", ");
|
|
11627
11640
|
const valuePlaceholders = batch.map(() => `(${columns.map(() => "?").join(", ")})`).join(", ");
|
|
11628
11641
|
const sql = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}`;
|
|
11629
|
-
const params = batch.flatMap((row) => columns.map((c) => row[c]
|
|
11642
|
+
const params = batch.flatMap((row) => columns.map((c) => coerceForSqlite(row[c])));
|
|
11630
11643
|
target.run(sql, ...params);
|
|
11631
11644
|
}
|
|
11645
|
+
function coerceForSqlite(value) {
|
|
11646
|
+
if (value === null || value === undefined)
|
|
11647
|
+
return null;
|
|
11648
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "bigint" || typeof value === "boolean")
|
|
11649
|
+
return value;
|
|
11650
|
+
if (value instanceof Date)
|
|
11651
|
+
return value.toISOString();
|
|
11652
|
+
if (Buffer.isBuffer(value) || value instanceof Uint8Array)
|
|
11653
|
+
return value;
|
|
11654
|
+
if (typeof value === "object")
|
|
11655
|
+
return JSON.stringify(value);
|
|
11656
|
+
return String(value);
|
|
11657
|
+
}
|
|
11632
11658
|
function isAsyncAdapter(adapter) {
|
|
11633
11659
|
return adapter.constructor.name === "PgAdapterAsync" || typeof adapter.raw?.connect === "function";
|
|
11634
11660
|
}
|
package/dist/index.js
CHANGED
|
@@ -9482,7 +9482,20 @@ async function syncTransfer(source, target, options, _direction) {
|
|
|
9482
9482
|
continue;
|
|
9483
9483
|
}
|
|
9484
9484
|
const pkColumns = await resolvePrimaryKeys(source, target, table, pkOption);
|
|
9485
|
-
const
|
|
9485
|
+
const sourceColumns = Object.keys(rows[0]);
|
|
9486
|
+
let targetColumns = null;
|
|
9487
|
+
if (!isAsyncAdapter(target)) {
|
|
9488
|
+
try {
|
|
9489
|
+
const colInfo = target.all(`PRAGMA table_info("${table}")`);
|
|
9490
|
+
targetColumns = new Set(colInfo.map((c) => c.name));
|
|
9491
|
+
} catch {}
|
|
9492
|
+
} else {
|
|
9493
|
+
try {
|
|
9494
|
+
const colInfo = await target.all(`SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '${table}'`);
|
|
9495
|
+
targetColumns = new Set(colInfo.map((c) => c.column_name));
|
|
9496
|
+
} catch {}
|
|
9497
|
+
}
|
|
9498
|
+
const columns = targetColumns ? sourceColumns.filter((c) => targetColumns.has(c)) : sourceColumns;
|
|
9486
9499
|
if (pkColumns.length === 0) {
|
|
9487
9500
|
result.errors.push(`Table "${table}" has no primary key — inserting without conflict handling`);
|
|
9488
9501
|
onProgress?.({
|
|
@@ -9597,7 +9610,7 @@ function batchUpsertSqlite(target, table, columns, updateCols, primaryKeys, batc
|
|
|
9597
9610
|
const setClause = updateCols.length > 0 ? updateCols.map((c) => `"${c}" = EXCLUDED."${c}"`).join(", ") : `"${primaryKeys[0]}" = EXCLUDED."${primaryKeys[0]}"`;
|
|
9598
9611
|
const sql = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}
|
|
9599
9612
|
ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}`;
|
|
9600
|
-
const params = batch.flatMap((row) => columns.map((c) => row[c]
|
|
9613
|
+
const params = batch.flatMap((row) => columns.map((c) => coerceForSqlite(row[c])));
|
|
9601
9614
|
target.run(sql, ...params);
|
|
9602
9615
|
}
|
|
9603
9616
|
async function batchInsertPg(target, table, columns, batch) {
|
|
@@ -9618,9 +9631,22 @@ function batchInsertSqlite(target, table, columns, batch) {
|
|
|
9618
9631
|
const colList = columns.map((c) => `"${c}"`).join(", ");
|
|
9619
9632
|
const valuePlaceholders = batch.map(() => `(${columns.map(() => "?").join(", ")})`).join(", ");
|
|
9620
9633
|
const sql = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}`;
|
|
9621
|
-
const params = batch.flatMap((row) => columns.map((c) => row[c]
|
|
9634
|
+
const params = batch.flatMap((row) => columns.map((c) => coerceForSqlite(row[c])));
|
|
9622
9635
|
target.run(sql, ...params);
|
|
9623
9636
|
}
|
|
9637
|
+
function coerceForSqlite(value) {
|
|
9638
|
+
if (value === null || value === undefined)
|
|
9639
|
+
return null;
|
|
9640
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "bigint" || typeof value === "boolean")
|
|
9641
|
+
return value;
|
|
9642
|
+
if (value instanceof Date)
|
|
9643
|
+
return value.toISOString();
|
|
9644
|
+
if (Buffer.isBuffer(value) || value instanceof Uint8Array)
|
|
9645
|
+
return value;
|
|
9646
|
+
if (typeof value === "object")
|
|
9647
|
+
return JSON.stringify(value);
|
|
9648
|
+
return String(value);
|
|
9649
|
+
}
|
|
9624
9650
|
function isAsyncAdapter(adapter) {
|
|
9625
9651
|
return adapter.constructor.name === "PgAdapterAsync" || typeof adapter.raw?.connect === "function";
|
|
9626
9652
|
}
|
package/dist/mcp/index.js
CHANGED
|
@@ -24829,7 +24829,20 @@ async function syncTransfer(source, target, options, _direction) {
|
|
|
24829
24829
|
continue;
|
|
24830
24830
|
}
|
|
24831
24831
|
const pkColumns = await resolvePrimaryKeys(source, target, table, pkOption);
|
|
24832
|
-
const
|
|
24832
|
+
const sourceColumns = Object.keys(rows[0]);
|
|
24833
|
+
let targetColumns = null;
|
|
24834
|
+
if (!isAsyncAdapter(target)) {
|
|
24835
|
+
try {
|
|
24836
|
+
const colInfo = target.all(`PRAGMA table_info("${table}")`);
|
|
24837
|
+
targetColumns = new Set(colInfo.map((c) => c.name));
|
|
24838
|
+
} catch {}
|
|
24839
|
+
} else {
|
|
24840
|
+
try {
|
|
24841
|
+
const colInfo = await target.all(`SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '${table}'`);
|
|
24842
|
+
targetColumns = new Set(colInfo.map((c) => c.column_name));
|
|
24843
|
+
} catch {}
|
|
24844
|
+
}
|
|
24845
|
+
const columns = targetColumns ? sourceColumns.filter((c) => targetColumns.has(c)) : sourceColumns;
|
|
24833
24846
|
if (pkColumns.length === 0) {
|
|
24834
24847
|
result.errors.push(`Table "${table}" has no primary key — inserting without conflict handling`);
|
|
24835
24848
|
onProgress?.({
|
|
@@ -24944,7 +24957,7 @@ function batchUpsertSqlite(target, table, columns, updateCols, primaryKeys, batc
|
|
|
24944
24957
|
const setClause = updateCols.length > 0 ? updateCols.map((c) => `"${c}" = EXCLUDED."${c}"`).join(", ") : `"${primaryKeys[0]}" = EXCLUDED."${primaryKeys[0]}"`;
|
|
24945
24958
|
const sql = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}
|
|
24946
24959
|
ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}`;
|
|
24947
|
-
const params = batch.flatMap((row) => columns.map((c) => row[c]
|
|
24960
|
+
const params = batch.flatMap((row) => columns.map((c) => coerceForSqlite(row[c])));
|
|
24948
24961
|
target.run(sql, ...params);
|
|
24949
24962
|
}
|
|
24950
24963
|
async function batchInsertPg(target, table, columns, batch) {
|
|
@@ -24965,9 +24978,22 @@ function batchInsertSqlite(target, table, columns, batch) {
|
|
|
24965
24978
|
const colList = columns.map((c) => `"${c}"`).join(", ");
|
|
24966
24979
|
const valuePlaceholders = batch.map(() => `(${columns.map(() => "?").join(", ")})`).join(", ");
|
|
24967
24980
|
const sql = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}`;
|
|
24968
|
-
const params = batch.flatMap((row) => columns.map((c) => row[c]
|
|
24981
|
+
const params = batch.flatMap((row) => columns.map((c) => coerceForSqlite(row[c])));
|
|
24969
24982
|
target.run(sql, ...params);
|
|
24970
24983
|
}
|
|
24984
|
+
function coerceForSqlite(value) {
|
|
24985
|
+
if (value === null || value === undefined)
|
|
24986
|
+
return null;
|
|
24987
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "bigint" || typeof value === "boolean")
|
|
24988
|
+
return value;
|
|
24989
|
+
if (value instanceof Date)
|
|
24990
|
+
return value.toISOString();
|
|
24991
|
+
if (Buffer.isBuffer(value) || value instanceof Uint8Array)
|
|
24992
|
+
return value;
|
|
24993
|
+
if (typeof value === "object")
|
|
24994
|
+
return JSON.stringify(value);
|
|
24995
|
+
return String(value);
|
|
24996
|
+
}
|
|
24971
24997
|
function isAsyncAdapter(adapter) {
|
|
24972
24998
|
return adapter.constructor.name === "PgAdapterAsync" || typeof adapter.raw?.connect === "function";
|
|
24973
24999
|
}
|
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,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,kCAAkC;IAClC,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,c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