d1s 0.3.13 → 0.3.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.
Files changed (73) hide show
  1. package/dist/.next/BUILD_ID +1 -1
  2. package/dist/.next/app-build-manifest.json +43 -43
  3. package/dist/.next/app-path-routes-manifest.json +11 -11
  4. package/dist/.next/build-manifest.json +2 -2
  5. package/dist/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  6. package/dist/.next/server/app/_not-found.html +1 -1
  7. package/dist/.next/server/app/_not-found.rsc +1 -1
  8. package/dist/.next/server/app/api/cloudflare/route.js +1 -1
  9. package/dist/.next/server/app/api/cloudflare/route_client-reference-manifest.js +1 -1
  10. package/dist/.next/server/app/api/databases/route.js +1 -1
  11. package/dist/.next/server/app/api/databases/route_client-reference-manifest.js +1 -1
  12. package/dist/.next/server/app/api/migrations/list/route.js +2 -2
  13. package/dist/.next/server/app/api/migrations/list/route_client-reference-manifest.js +1 -1
  14. package/dist/.next/server/app/api/migrations/sync/route.js +3 -3
  15. package/dist/.next/server/app/api/migrations/sync/route_client-reference-manifest.js +1 -1
  16. package/dist/.next/server/app/api/migrations/sync-files/route.js +2 -2
  17. package/dist/.next/server/app/api/migrations/sync-files/route_client-reference-manifest.js +1 -1
  18. package/dist/.next/server/app/api/pro/route_client-reference-manifest.js +1 -1
  19. package/dist/.next/server/app/api/pull-data/confirm/route.js +1 -1
  20. package/dist/.next/server/app/api/pull-data/confirm/route_client-reference-manifest.js +1 -1
  21. package/dist/.next/server/app/api/pull-remote/confirm/route.js +2 -2
  22. package/dist/.next/server/app/api/pull-remote/confirm/route_client-reference-manifest.js +1 -1
  23. package/dist/.next/server/app/api/pull-remote/preview/route.js +2 -2
  24. package/dist/.next/server/app/api/pull-remote/preview/route_client-reference-manifest.js +1 -1
  25. package/dist/.next/server/app/api/push-remote/confirm/route.js +3 -3
  26. package/dist/.next/server/app/api/push-remote/confirm/route_client-reference-manifest.js +1 -1
  27. package/dist/.next/server/app/api/push-remote/preview/route.js +3 -3
  28. package/dist/.next/server/app/api/push-remote/preview/route_client-reference-manifest.js +1 -1
  29. package/dist/.next/server/app/api/query/route.js +3 -3
  30. package/dist/.next/server/app/api/query/route_client-reference-manifest.js +1 -1
  31. package/dist/.next/server/app/api/schema/route.js +1 -1
  32. package/dist/.next/server/app/api/schema/route_client-reference-manifest.js +1 -1
  33. package/dist/.next/server/app/api/tables/[name]/import/route.js +1 -1
  34. package/dist/.next/server/app/api/tables/[name]/import/route_client-reference-manifest.js +1 -1
  35. package/dist/.next/server/app/api/tables/[name]/route.js +2 -2
  36. package/dist/.next/server/app/api/tables/[name]/route_client-reference-manifest.js +1 -1
  37. package/dist/.next/server/app/api/tables/route.js +2 -2
  38. package/dist/.next/server/app/api/tables/route_client-reference-manifest.js +1 -1
  39. package/dist/.next/server/app/api/time-travel/preview/route.js +1 -1
  40. package/dist/.next/server/app/api/time-travel/preview/route_client-reference-manifest.js +1 -1
  41. package/dist/.next/server/app/api/time-travel/restore/route.js +1 -1
  42. package/dist/.next/server/app/api/time-travel/restore/route_client-reference-manifest.js +1 -1
  43. package/dist/.next/server/app/api/update/route.js +1 -1
  44. package/dist/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  45. package/dist/.next/server/app/index.html +2 -2
  46. package/dist/.next/server/app/index.rsc +2 -2
  47. package/dist/.next/server/app/page.js +1 -1
  48. package/dist/.next/server/app/page_client-reference-manifest.js +1 -1
  49. package/dist/.next/server/app-paths-manifest.json +11 -11
  50. package/dist/.next/server/chunks/366.js +1 -1
  51. package/dist/.next/server/chunks/386.js +4 -4
  52. package/dist/.next/server/chunks/626.js +1 -1
  53. package/dist/.next/server/pages/404.html +1 -1
  54. package/dist/.next/server/pages/500.html +1 -1
  55. package/dist/.next/server/pages-manifest.json +1 -1
  56. package/dist/.next/static/chunks/app/{page-39d6f7bc281c828c.js → page-5f5e2a64d451ecb1.js} +1 -1
  57. package/dist/.next/trace +3 -3
  58. package/dist/app/api/migrations/sync/route.js +1 -3
  59. package/dist/app/api/pull-data/confirm/route.js +2 -22
  60. package/dist/app/api/pull-remote/confirm/route.js +0 -15
  61. package/dist/app/api/push-remote/confirm/route.js +0 -6
  62. package/dist/app/api/push-remote/preview/route.js +0 -4
  63. package/dist/app/api/query/route.js +0 -6
  64. package/dist/app/api/tables/route.js +0 -3
  65. package/dist/app/api/time-travel/preview/route.js +0 -2
  66. package/dist/app/api/time-travel/restore/route.js +0 -2
  67. package/dist/app/api/update/route.js +1 -2
  68. package/dist/lib/find-wrangler-config.js +0 -3
  69. package/dist/lib/local-db.js +0 -6
  70. package/dist/lib/sql-operations.js +1 -15
  71. package/package.json +1 -1
  72. /package/dist/.next/static/{ghHdNJKQy3Hmu0UqGdL7v → o_MkOiVF7_eRHovqofgAP}/_buildManifest.js +0 -0
  73. /package/dist/.next/static/{ghHdNJKQy3Hmu0UqGdL7v → o_MkOiVF7_eRHovqofgAP}/_ssgManifest.js +0 -0
@@ -46,12 +46,9 @@ async function applyPullMigrations(projectDir, dbConfig) {
46
46
  await Promise.all(stagedFilesList.map(file => unlink(path.join(stagingDir, file))));
47
47
 
48
48
  // --- STEP 1: Fetch remote migration metadata ---
49
- logger.debug('Fetching remote migration metadata...');
50
49
  const remoteMigrations = await getRemoteMigrations(projectDir, databaseName, env);
51
- logger.debug('Remote migration metadata:', remoteMigrations);
52
50
 
53
51
  // --- STEP 2: Read migration content from local files ---
54
- logger.debug('Reading migration files from local migrations folder...');
55
52
  const stagedFiles = new Map();
56
53
  for (const migration of remoteMigrations) {
57
54
  const migrationFileName = migration.name;
@@ -60,7 +57,6 @@ async function applyPullMigrations(projectDir, dbConfig) {
60
57
  const content = await readFile(localFilePath, 'utf8');
61
58
  stagedFiles.set(migrationFileName, content);
62
59
  await writeFile(path.join(stagingDir, migrationFileName), content, 'utf8');
63
- logger.debug(`Staged migration file: ${migrationFileName}`);
64
60
  } catch (fileError) {
65
61
  logger.error(`Migration file not found locally: ${migrationFileName}`, fileError.message);
66
62
  throw new Error(`Migration file not found locally: ${migrationFileName}`);
@@ -68,7 +64,6 @@ async function applyPullMigrations(projectDir, dbConfig) {
68
64
  }
69
65
 
70
66
  // --- STEP 3: Get local schema for drop order ---
71
- logger.debug('Fetching local schema...');
72
67
  const currentSchema = await getCurrentSchema(projectDir, databaseName, env, false);
73
68
  const tableSchema = currentSchema.filter(obj =>
74
69
  obj.type === 'table' && obj.name && obj.name.toLowerCase() !== 'if'
@@ -85,7 +80,6 @@ async function applyPullMigrations(projectDir, dbConfig) {
85
80
  const indexes = currentSchema.filter(obj => obj.type === 'index' && !SYSTEM_OBJECT.test(obj.name));
86
81
  const reversedDropOrder = [...dropOrder].filter(t => !SYSTEM_OBJECT.test(t)).reverse();
87
82
 
88
- logger.debug('Beginning destructive update...');
89
83
  const db = getLocalDb(projectDir, dbConfig);
90
84
 
91
85
  if (db) {
@@ -93,15 +87,12 @@ async function applyPullMigrations(projectDir, dbConfig) {
93
87
  try {
94
88
  db.pragma('foreign_keys = OFF');
95
89
  for (const trigger of triggers) {
96
- logger.debug(`Dropping trigger: ${trigger.name}`);
97
90
  db.prepare(`DROP TRIGGER IF EXISTS "${trigger.name}"`).run();
98
91
  }
99
92
  for (const index of indexes) {
100
- logger.debug(`Dropping index: ${index.name}`);
101
93
  db.prepare(`DROP INDEX IF EXISTS "${index.name}"`).run();
102
94
  }
103
95
  for (const tableName of reversedDropOrder) {
104
- logger.debug(`Dropping table: ${tableName}`);
105
96
  db.prepare(`DROP TABLE IF EXISTS "${tableName}"`).run();
106
97
  }
107
98
  } finally {
@@ -110,7 +101,6 @@ async function applyPullMigrations(projectDir, dbConfig) {
110
101
  } else {
111
102
  // Wrangler CLI fallback: drop in correct order (child-first) so FK constraints
112
103
  // are satisfied without needing PRAGMA — PRAGMA is blocked by SQLITE_AUTH anyway.
113
- logger.debug('better-sqlite3 unavailable, falling back to wrangler CLI for destructive update');
114
104
  const stmts = [
115
105
  ...triggers.map(t => `DROP TRIGGER IF EXISTS "${t.name}"`),
116
106
  ...indexes.map(i => `DROP INDEX IF EXISTS "${i.name}"`),
@@ -122,7 +112,6 @@ async function applyPullMigrations(projectDir, dbConfig) {
122
112
  }
123
113
 
124
114
  // --- STEP 5: Reset the local migrations table ---
125
- logger.debug('Resetting local migrations table...');
126
115
  try {
127
116
  await initMigrationsTable(projectDir, databaseName, 'local', true);
128
117
  } catch (initError) {
@@ -144,7 +133,6 @@ async function applyPullMigrations(projectDir, dbConfig) {
144
133
  try {
145
134
  for (const [filename, content] of stagedFiles.entries()) {
146
135
  currentFilename = filename;
147
- logger.debug(`Applying migration: ${filename}`);
148
136
 
149
137
  const filePath = path.join(migrationsDir, filename);
150
138
  await writeFile(filePath, content, 'utf8');
@@ -164,7 +152,6 @@ async function applyPullMigrations(projectDir, dbConfig) {
164
152
 
165
153
  if (!usedLocal) {
166
154
  // Wrangler CLI fallback: --file preserves SQL as-is (no whitespace collapse, no escaping)
167
- logger.debug(`Applying ${filename} via wrangler --file`);
168
155
  const { stdout } = await execAsync(
169
156
  `${npxCommand} wrangler d1 execute ${databaseName} --local --file="${filePath}" --json`,
170
157
  { cwd: projectDir, env: { ...process.env, ...env }, maxBuffer: 1024 * 1024 * 10 }
@@ -186,7 +173,6 @@ async function applyPullMigrations(projectDir, dbConfig) {
186
173
  }
187
174
 
188
175
  // --- STEP 7: Replace migrations folder with only staged (remote) files ---
189
- logger.debug('Replacing migrations folder with staged files...');
190
176
  const mainFiles = await readdir(migrationsDir).catch(() => []);
191
177
  for (const file of mainFiles) {
192
178
  await unlink(path.join(migrationsDir, file));
@@ -195,7 +181,6 @@ async function applyPullMigrations(projectDir, dbConfig) {
195
181
  await writeFile(path.join(migrationsDir, filename), content, 'utf8');
196
182
  }
197
183
 
198
- logger.debug('Pull migration applied successfully.');
199
184
  return {
200
185
  appliedMigrations: Array.from(stagedFiles.keys()),
201
186
  details: appliedPreview
@@ -49,8 +49,6 @@ async function pushToRemote(projectDir, databaseName, preview = false, dbMigrati
49
49
  }
50
50
  };
51
51
  const parsedRemoteRows = parseResults(remoteMigrations);
52
- console.log(`[push-confirm] remote d1_migrations raw response: ${remoteMigrations}`);
53
- console.log(`[push-confirm] remote d1_migrations parsed rows (${parsedRemoteRows.length}): ${JSON.stringify(parsedRemoteRows)}`);
54
52
  const remoteMigrationsMap = new Map(
55
53
  parsedRemoteRows.map(m => [m.name, m])
56
54
  );
@@ -76,7 +74,6 @@ for (const migrationFile of migrationFiles) {
76
74
  }
77
75
  // For remote, compare by migration file name.
78
76
  if (remoteMigrationsMap.has(migrationFile)) {
79
- console.log(`[push-confirm] SKIP ${migrationFile} — found in remote d1_migrations`);
80
77
  previewRecord.action = 'skipped';
81
78
  previewRecord.reason = 'Already applied';
82
79
  results.preview.push(previewRecord);
@@ -94,9 +91,7 @@ for (const migrationFile of migrationFiles) {
94
91
  // Only if the migration is a CREATE_TABLE do we check for existing table.
95
92
  if (parsedStatement.type === 'CREATE_TABLE' && tableName) {
96
93
  const exists = await tableExists(projectDir, databaseName, env, tableName, true);
97
- console.log(`[push-confirm] tableExists(${tableName}, remote) = ${exists}`);
98
94
  if (exists) {
99
- console.log(`[push-confirm] SKIP ${migrationFile} — table "${tableName}" already exists on remote`);
100
95
  previewRecord.action = 'skipped';
101
96
  previewRecord.reason = `Table "${tableName}" already exists`;
102
97
  results.skipped.push({ name: migrationFile, reason: previewRecord.reason });
@@ -214,4 +209,3 @@ export async function OPTIONS() {
214
209
  return new NextResponse(null, { status: 204 });
215
210
  }
216
211
 
217
-
@@ -57,8 +57,6 @@ async function pushToRemote(projectDir, databaseName, preview = true, dbMigratio
57
57
  };
58
58
  // Use migration file name as key
59
59
  const parsedRemoteRows = parseResults(remoteMigrations);
60
- console.log(`[push-preview] remote d1_migrations raw response: ${remoteMigrations}`);
61
- console.log(`[push-preview] remote d1_migrations parsed rows (${parsedRemoteRows.length}): ${JSON.stringify(parsedRemoteRows)}`);
62
60
  const remoteMigrationsMap = new Map(
63
61
  parsedRemoteRows.map(m => [m.name, m])
64
62
  );
@@ -100,7 +98,6 @@ async function pushToRemote(projectDir, databaseName, preview = true, dbMigratio
100
98
  }
101
99
  }
102
100
 
103
- logger.debug("Push Preview Result (server):", results);
104
101
  return { success: true, preview: true, applied: results.applied.length, skipped: results.skipped.length, details: results };
105
102
  } catch (error) {
106
103
  throw {
@@ -191,4 +188,3 @@ export async function POST(req) {
191
188
  export async function OPTIONS() {
192
189
  return new NextResponse(null, { status: 204 });
193
190
  }
194
-
@@ -17,8 +17,6 @@ import logger from '@/lib/logger';
17
17
  * API POST handler to execute SQL queries against the configured D1 database.
18
18
  */
19
19
  export async function POST(req) {
20
- logger.logRequest('POST', '/api/query');
21
-
22
20
  try {
23
21
  // Ensure that the project directory is set.
24
22
  const projectDir = process.env.D1_PROJECT_DIR;
@@ -35,10 +33,6 @@ export async function POST(req) {
35
33
  const executionTarget = target === 'remote' ? 'remote' : 'local';
36
34
  const isRemote = executionTarget === 'remote';
37
35
 
38
- if (logger.shouldLog('debug')) {
39
- logger.debug('Received query:', query);
40
- }
41
-
42
36
  if (!query?.trim()) {
43
37
  return NextResponse.json(
44
38
  { success: false, error: { message: 'Query cannot be empty' } },
@@ -63,7 +63,6 @@ async function retryWithTimeout(fn, retries = 3, timeout = 1000) {
63
63
  } catch (error) {
64
64
  if (i === retries - 1) throw error;
65
65
  if (error.message.includes('database is locked')) {
66
- console.log(`Database locked, retrying in ${timeout}ms... (attempt ${i + 1}/${retries})`);
67
66
  await new Promise(resolve => setTimeout(resolve, timeout));
68
67
  continue;
69
68
  }
@@ -77,8 +76,6 @@ async function retryWithTimeout(fn, retries = 3, timeout = 1000) {
77
76
  * It uses the Wrangler configuration (via findWranglerConfig) to determine the D1 database.
78
77
  */
79
78
  export async function GET(request) {
80
- logger.logRequest('GET', '/api/tables');
81
-
82
79
  try {
83
80
  const { searchParams } = new URL(request.url);
84
81
  const dbParam = searchParams.get('db');
@@ -53,7 +53,6 @@ export async function GET(req) {
53
53
  const { projectDir, databaseName } = await resolveDb(req);
54
54
  const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
55
55
  const command = `${npxCmd} wrangler d1 time-travel info ${databaseName} --json`;
56
- logger.debug(`Time travel GET: ${command}`);
57
56
 
58
57
  const { stdout } = await execAsync(command, {
59
58
  cwd: projectDir, env: process.env,
@@ -100,7 +99,6 @@ export async function POST(req) {
100
99
  const unixTs = Math.floor(new Date(timestamp).getTime() / 1000);
101
100
  const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
102
101
  const command = `${npxCmd} wrangler d1 time-travel info ${databaseName} --timestamp=${unixTs} --json`;
103
- logger.debug(`Time travel POST: ${command}`);
104
102
 
105
103
  const { stdout } = await execAsync(command, {
106
104
  cwd: projectDir, env: process.env,
@@ -60,8 +60,6 @@ export async function POST(req) {
60
60
  command = `${npxCmd} wrangler d1 time-travel restore ${databaseName} --timestamp=${unixTs} --json`;
61
61
  }
62
62
 
63
- logger.debug('Time travel restore command:', command);
64
-
65
63
  const { stdout, stderr } = await execAsync(command, {
66
64
  cwd: projectDir,
67
65
  env: process.env,
@@ -26,7 +26,6 @@ export async function GET() {
26
26
 
27
27
  // Compare versions - only return update info if there's a newer version
28
28
  if (latestVersion && currentVersion && latestVersion !== currentVersion) {
29
- console.log(`Update available: ${currentVersion} → ${latestVersion}`);
30
29
  return NextResponse.json({
31
30
  update: {
32
31
  latest: latestVersion,
@@ -42,4 +41,4 @@ export async function GET() {
42
41
  // Return null on error to prevent banner from showing
43
42
  return NextResponse.json({ update: null });
44
43
  }
45
- }
44
+ }
@@ -41,12 +41,9 @@ export async function findWranglerConfig(userProjectPath) {
41
41
  }
42
42
 
43
43
  if (!configPath) {
44
- logger.warn(`No Wrangler configuration file found in: ${userProjectPath}`);
45
44
  return null;
46
45
  }
47
46
 
48
- logger.info(`Found ${configFileUsed} at: ${configPath}`);
49
-
50
47
  // Read the configuration file.
51
48
  let configContent = await readFile(configPath, 'utf-8');
52
49
  let config;
@@ -6,7 +6,6 @@ import crypto from 'crypto';
6
6
  import path from 'path';
7
7
  import fs from 'fs';
8
8
  import Database from 'better-sqlite3';
9
- import logger from './logger.js';
10
9
 
11
10
  const MINIFLARE_DIR = path.join('.wrangler', 'state', 'v3', 'd1', 'miniflare-D1DatabaseObject');
12
11
 
@@ -60,11 +59,6 @@ function findSqliteFile(projectDir, databaseConfig) {
60
59
  return files[0].fullPath;
61
60
  }
62
61
 
63
- if (files.length > 1) {
64
- logger.debug(`[local-db] Multiple SQLite files, no hash matched — falling back to wrangler CLI. dir=${dir}, tried ids=${JSON.stringify(ids)}`);
65
- }
66
-
67
- logger.debug(`[local-db] No SQLite files found. dir=${dir}, tried ids=${JSON.stringify(ids)}`);
68
62
  return null;
69
63
  }
70
64
 
@@ -316,12 +316,6 @@ export async function executeSQL(projectDir, databaseName, sql, env = {}, remote
316
316
  const shellEscapedSQL = cleanSQL.replace(/"/g, '\\"').replace(/\$/g, '\\$');
317
317
  const command = `${npxCommand} wrangler d1 execute ${databaseName} ${executionFlag} --command="${shellEscapedSQL}" --json`;
318
318
 
319
- if (remote) {
320
- console.log(`[executeSQL --remote] ${command}`);
321
- } else if (logger.shouldLog('debug')) {
322
- logger.debug('Executing command:', command);
323
- }
324
-
325
319
  const execOptions = {
326
320
  cwd: projectDir,
327
321
  env: { ...process.env, ...env },
@@ -330,9 +324,6 @@ export async function executeSQL(projectDir, databaseName, sql, env = {}, remote
330
324
  };
331
325
  // console.log('Executing command:', command);
332
326
  const { stdout, stderr } = await execAsync(command, execOptions);
333
- if (remote && stderr) {
334
- console.log(`[executeSQL --remote stderr]: ${stderr.substring(0, 800)}`);
335
- }
336
327
  if (stderr && !stderr.includes('🌀')) {
337
328
  throw new Error(stderr);
338
329
  }
@@ -341,14 +332,9 @@ export async function executeSQL(projectDir, databaseName, sql, env = {}, remote
341
332
  if (jsonStart !== -1) {
342
333
  return stdout.substring(jsonStart);
343
334
  }
344
- } catch (parseError) {
345
- console.warn('JSON parse warning:', parseError);
346
- }
335
+ } catch (parseError) {}
347
336
  return stdout;
348
337
  } catch (error) {
349
- if (logger.shouldLog('debug')) {
350
- logger.debug('SQL execution error:', error.message || error);
351
- }
352
338
  // Instead of creating a new error object, preserve the original error details
353
339
  throw {
354
340
  type: ErrorTypes.EXECUTION_ERROR,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "d1s",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "description": "The first native studio for Cloudflare D1. Zero setup. No extra dependencies.",