@deepagents/text2sql 7.31.0 → 7.32.1

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.js CHANGED
@@ -2105,6 +2105,9 @@ var SqliteFs = class {
2105
2105
  if (!srcEntry) {
2106
2106
  throw new Error(`ENOENT: no such file or directory: ${src}`);
2107
2107
  }
2108
+ if (srcPrefixed === destPrefixed) {
2109
+ return;
2110
+ }
2108
2111
  transaction(
2109
2112
  this.#db,
2110
2113
  () => {
@@ -2113,12 +2116,15 @@ var SqliteFs = class {
2113
2116
  const allEntries = z6.array(entryRow).parse(
2114
2117
  this.#sql.all`SELECT * FROM fs_entries WHERE path = ${srcPrefixed} OR path LIKE ${srcPrefixed} || '/%' ORDER BY path DESC`
2115
2118
  );
2119
+ this.#sql.run`DELETE FROM fs_entries WHERE path = ${destPrefixed} OR path LIKE ${destPrefixed} || '/%'`;
2116
2120
  for (const entry of allEntries.toReversed()) {
2117
2121
  const relativePath = path2.posix.relative(srcPrefixed, entry.path);
2118
2122
  const newPath = path2.posix.join(destPrefixed, relativePath);
2119
2123
  this.#sql.run`INSERT INTO fs_entries (path, type, mode, size, mtime, symlinkTarget)
2120
- VALUES (${newPath}, ${entry.type}, ${entry.mode}, ${entry.size}, ${Date.now()}, ${entry.symlinkTarget})`;
2124
+ VALUES (${newPath}, ${entry.type}, ${entry.mode}, ${entry.size}, ${Date.now()}, ${entry.symlinkTarget})
2125
+ ON CONFLICT (path) DO UPDATE SET type = excluded.type, mode = excluded.mode, size = excluded.size, mtime = excluded.mtime, symlinkTarget = excluded.symlinkTarget`;
2121
2126
  if (entry.type === "file") {
2127
+ this.#sql.run`DELETE FROM fs_chunks WHERE path = ${newPath}`;
2122
2128
  const chunks = this.#chunks(entry.path);
2123
2129
  for (const chunk of chunks) {
2124
2130
  this.#sql.run`INSERT INTO fs_chunks (path, chunkIndex, data) VALUES (${newPath}, ${chunk.chunkIndex}, ${chunk.data})`;
@@ -2128,8 +2134,10 @@ var SqliteFs = class {
2128
2134
  this.#sql.run`DELETE FROM fs_entries WHERE path = ${srcPrefixed} OR path LIKE ${srcPrefixed} || '/%'`;
2129
2135
  } else {
2130
2136
  this.#sql.run`INSERT INTO fs_entries (path, type, mode, size, mtime, symlinkTarget)
2131
- VALUES (${destPrefixed}, ${srcEntry.type}, ${srcEntry.mode}, ${srcEntry.size}, ${Date.now()}, ${srcEntry.symlinkTarget})`;
2137
+ VALUES (${destPrefixed}, ${srcEntry.type}, ${srcEntry.mode}, ${srcEntry.size}, ${Date.now()}, ${srcEntry.symlinkTarget})
2138
+ ON CONFLICT (path) DO UPDATE SET type = excluded.type, mode = excluded.mode, size = excluded.size, mtime = excluded.mtime, symlinkTarget = excluded.symlinkTarget`;
2132
2139
  if (srcEntry.type === "file") {
2140
+ this.#sql.run`DELETE FROM fs_chunks WHERE path = ${destPrefixed}`;
2133
2141
  const chunks = this.#chunks(srcPrefixed);
2134
2142
  for (const chunk of chunks) {
2135
2143
  this.#sql.run`INSERT INTO fs_chunks (path, chunkIndex, data) VALUES (${destPrefixed}, ${chunk.chunkIndex}, ${chunk.data})`;
@@ -3058,6 +3066,9 @@ var MssqlFs = class _MssqlFs {
3058
3066
  if (!srcEntry) {
3059
3067
  throw new Error(`ENOENT: no such file or directory: ${src}`);
3060
3068
  }
3069
+ if (srcPrefixed === destPrefixed) {
3070
+ return;
3071
+ }
3061
3072
  await this.#useTransaction(async (transaction2) => {
3062
3073
  await this.#ensureParentExists(destPrefixed, transaction2);
3063
3074
  if (srcEntry.type === "directory") {
@@ -4008,6 +4019,9 @@ var PostgresFs = class _PostgresFs {
4008
4019
  if (!srcEntry) {
4009
4020
  throw new Error(`ENOENT: no such file or directory: ${src}`);
4010
4021
  }
4022
+ if (srcPrefixed === destPrefixed) {
4023
+ return;
4024
+ }
4011
4025
  await this.#useTransaction(async (client) => {
4012
4026
  await this.#ensureParentExists(destPrefixed, client);
4013
4027
  if (srcEntry.type === "directory") {