d1s 0.2.9 → 0.2.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/.next/.next/BUILD_ID +1 -1
- package/dist/.next/.next/app-build-manifest.json +28 -28
- package/dist/.next/.next/app-path-routes-manifest.json +1 -1
- package/dist/.next/.next/build-manifest.json +3 -3
- package/dist/.next/.next/cache/.rscinfo +1 -1
- package/dist/.next/.next/cache/.tsbuildinfo +1 -1
- package/dist/.next/.next/cache/webpack/client-production/0.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/1.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/2.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/3.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/index.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/dist/.next/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/0.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/1.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/2.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/index.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/dist/.next/.next/next-minimal-server.js.nft.json +1 -1
- package/dist/.next/.next/next-server.js.nft.json +1 -1
- package/dist/.next/.next/prerender-manifest.json +1 -1
- package/dist/.next/.next/required-server-files.json +1 -1
- package/dist/.next/.next/server/app/_not-found/page.js +1 -1
- package/dist/.next/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/dist/.next/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/_not-found.html +1 -1
- package/dist/.next/.next/server/app/_not-found.rsc +4 -4
- package/dist/.next/.next/server/app/api/cloudflare/route.js +1 -1
- package/dist/.next/.next/server/app/api/cloudflare/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/databases/route.js +1 -1
- package/dist/.next/.next/server/app/api/databases/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync/route.js +3 -3
- package/dist/.next/.next/server/app/api/migrations/sync/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync-files/route.js +8 -8
- package/dist/.next/.next/server/app/api/migrations/sync-files/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/pull-data/confirm/route.js +1 -1
- package/dist/.next/.next/server/app/api/pull-data/confirm/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/confirm/route.js +2 -2
- package/dist/.next/.next/server/app/api/pull-remote/confirm/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/preview/route.js +2 -2
- package/dist/.next/.next/server/app/api/pull-remote/preview/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/push-remote/confirm/route.js +5 -5
- package/dist/.next/.next/server/app/api/push-remote/confirm/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/push-remote/preview/route.js +3 -3
- package/dist/.next/.next/server/app/api/push-remote/preview/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/query/route.js +3 -3
- package/dist/.next/.next/server/app/api/query/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/tables/[name]/route.js +2 -2
- package/dist/.next/.next/server/app/api/tables/[name]/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/tables/route.js +2 -2
- package/dist/.next/.next/server/app/api/tables/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/update/route.js +1 -5
- package/dist/.next/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/index.html +3 -3
- package/dist/.next/.next/server/app/index.rsc +5 -5
- package/dist/.next/.next/server/app/page.js +11 -13
- package/dist/.next/.next/server/app/page.js.nft.json +1 -1
- package/dist/.next/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app-paths-manifest.json +1 -1
- package/dist/.next/.next/server/chunks/226.js +6 -6
- package/dist/.next/.next/server/chunks/391.js +5 -5
- package/dist/.next/.next/server/chunks/452.js +1 -1
- package/dist/.next/.next/server/chunks/627.js +3 -3
- package/dist/.next/.next/server/chunks/638.js +3 -3
- package/dist/.next/.next/server/chunks/90.js +1 -0
- package/dist/.next/.next/server/chunks/992.js +3 -3
- package/dist/.next/.next/server/middleware-build-manifest.js +1 -1
- package/dist/.next/.next/server/next-font-manifest.js +1 -1
- package/dist/.next/.next/server/next-font-manifest.json +1 -1
- package/dist/.next/.next/server/pages/404.html +1 -1
- package/dist/.next/.next/server/pages/500.html +1 -1
- package/dist/.next/.next/server/pages/_app.js +1 -1
- package/dist/.next/.next/server/pages/_document.js +1 -1
- package/dist/.next/.next/server/pages/_error.js +1 -1
- package/dist/.next/.next/server/server-reference-manifest.json +1 -1
- package/dist/.next/.next/static/bHYW7fgIBDF8-Q33_WPoE/_buildManifest.js +1 -0
- package/dist/.next/.next/static/bHYW7fgIBDF8-Q33_WPoE/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/chunks/576-c4daf274bb6469a1.js +1 -0
- package/dist/.next/.next/static/chunks/app/layout-be6ee67cf0c92654.js +1 -0
- package/dist/.next/.next/static/chunks/app/page-36ed30b2266617f3.js +1 -0
- package/dist/.next/.next/static/chunks/{main-app-d36cdfb402b40f13.js → main-app-fa35024de9bd9284.js} +1 -1
- package/dist/.next/.next/static/css/9f6c25c5400f83d3.css +3 -0
- package/dist/.next/.next/trace +3 -3
- package/dist/.next/.next/types/app/api/cloudflare/route.ts +1 -1
- package/dist/.next/.next/types/app/api/databases/route.ts +1 -1
- package/dist/.next/.next/types/app/api/migrations/sync/route.ts +1 -1
- package/dist/.next/.next/types/app/api/migrations/sync-files/route.ts +1 -1
- package/dist/.next/.next/types/app/api/pull-data/confirm/route.ts +1 -1
- package/dist/.next/.next/types/app/api/pull-remote/confirm/route.ts +1 -1
- package/dist/.next/.next/types/app/api/pull-remote/preview/route.ts +1 -1
- package/dist/.next/.next/types/app/api/push-remote/confirm/route.ts +1 -1
- package/dist/.next/.next/types/app/api/push-remote/preview/route.ts +1 -1
- package/dist/.next/.next/types/app/api/query/route.ts +1 -1
- package/dist/.next/.next/types/app/api/tables/[name]/route.ts +1 -1
- package/dist/.next/.next/types/app/api/tables/route.ts +1 -1
- package/dist/.next/.next/types/app/api/update/route.ts +1 -1
- package/dist/.next/.next/types/app/page.ts +1 -1
- package/dist/.next/BUILD_ID +1 -1
- package/dist/.next/app-build-manifest.json +41 -41
- package/dist/.next/app-path-routes-manifest.json +1 -1
- package/dist/.next/build-manifest.json +3 -3
- package/dist/.next/cache/.rscinfo +1 -1
- package/dist/.next/cache/.tsbuildinfo +1 -1
- package/dist/.next/cache/webpack/client-production/0.pack +0 -0
- package/dist/.next/cache/webpack/client-production/index.pack +0 -0
- package/dist/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/dist/.next/cache/webpack/server-production/0.pack +0 -0
- package/dist/.next/cache/webpack/server-production/index.pack +0 -0
- package/dist/.next/next-minimal-server.js.nft.json +1 -1
- package/dist/.next/next-server.js.nft.json +1 -1
- package/dist/.next/prerender-manifest.json +1 -1
- package/dist/.next/required-server-files.json +1 -1
- package/dist/.next/server/app/_not-found/page.js +1 -1
- package/dist/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/dist/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/_not-found.html +1 -1
- package/dist/.next/server/app/_not-found.rsc +4 -4
- package/dist/.next/server/app/api/cloudflare/route.js +1 -1
- package/dist/.next/server/app/api/cloudflare/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/databases/route.js +1 -1
- package/dist/.next/server/app/api/databases/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/migrations/sync/route.js +3 -3
- package/dist/.next/server/app/api/migrations/sync/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/migrations/sync-files/route.js +8 -8
- package/dist/.next/server/app/api/migrations/sync-files/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/pull-data/confirm/route.js +1 -1
- package/dist/.next/server/app/api/pull-data/confirm/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/pull-remote/confirm/route.js +2 -2
- package/dist/.next/server/app/api/pull-remote/confirm/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/pull-remote/preview/route.js +2 -2
- package/dist/.next/server/app/api/pull-remote/preview/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/push-remote/confirm/route.js +5 -5
- package/dist/.next/server/app/api/push-remote/confirm/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/push-remote/preview/route.js +3 -3
- package/dist/.next/server/app/api/push-remote/preview/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/query/route.js +3 -3
- package/dist/.next/server/app/api/query/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/tables/[name]/route.js +2 -2
- package/dist/.next/server/app/api/tables/[name]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/tables/route.js +2 -2
- package/dist/.next/server/app/api/tables/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/update/route.js +1 -5
- package/dist/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/index.html +3 -3
- package/dist/.next/server/app/index.rsc +5 -5
- package/dist/.next/server/app/page.js +11 -13
- package/dist/.next/server/app/page.js.nft.json +1 -1
- package/dist/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app-paths-manifest.json +5 -5
- package/dist/.next/server/chunks/226.js +6 -6
- package/dist/.next/server/chunks/391.js +5 -5
- package/dist/.next/server/chunks/452.js +1 -1
- package/dist/.next/server/chunks/627.js +3 -3
- package/dist/.next/server/chunks/638.js +3 -3
- package/dist/.next/server/chunks/90.js +1 -0
- package/dist/.next/server/chunks/992.js +3 -3
- package/dist/.next/server/middleware-build-manifest.js +1 -1
- package/dist/.next/server/next-font-manifest.js +1 -1
- package/dist/.next/server/next-font-manifest.json +1 -1
- package/dist/.next/server/pages/404.html +1 -1
- package/dist/.next/server/pages/500.html +1 -1
- package/dist/.next/server/pages/_app.js +1 -1
- package/dist/.next/server/pages/_document.js +1 -1
- package/dist/.next/server/pages/_error.js +1 -1
- package/dist/.next/server/server-reference-manifest.json +1 -1
- package/dist/.next/static/ZBTCAyp1kO5FdEHMU-Dw2/_buildManifest.js +1 -0
- package/dist/.next/static/ZBTCAyp1kO5FdEHMU-Dw2/_ssgManifest.js +1 -0
- package/dist/.next/static/chunks/576-c4daf274bb6469a1.js +1 -0
- package/dist/.next/static/chunks/app/layout-be6ee67cf0c92654.js +1 -0
- package/dist/.next/static/chunks/app/page-36ed30b2266617f3.js +1 -0
- package/dist/.next/static/chunks/{main-app-d36cdfb402b40f13.js → main-app-fa35024de9bd9284.js} +1 -1
- package/dist/.next/static/css/9f6c25c5400f83d3.css +3 -0
- package/dist/.next/trace +14 -17
- package/dist/.next/types/app/api/cloudflare/route.ts +1 -1
- package/dist/.next/types/app/api/databases/route.ts +1 -1
- package/dist/.next/types/app/api/migrations/sync/route.ts +1 -1
- package/dist/.next/types/app/api/migrations/sync-files/route.ts +1 -1
- package/dist/.next/types/app/api/pull-data/confirm/route.ts +1 -1
- package/dist/.next/types/app/api/pull-remote/confirm/route.ts +1 -1
- package/dist/.next/types/app/api/pull-remote/preview/route.ts +1 -1
- package/dist/.next/types/app/api/push-remote/confirm/route.ts +1 -1
- package/dist/.next/types/app/api/push-remote/preview/route.ts +1 -1
- package/dist/.next/types/app/api/query/route.ts +1 -1
- package/dist/.next/types/app/api/tables/[name]/route.ts +1 -1
- package/dist/.next/types/app/api/tables/route.ts +1 -1
- package/dist/.next/types/app/api/update/route.ts +1 -1
- package/dist/.next/types/app/page.ts +1 -1
- package/dist/app/api/update/route.js +29 -20
- package/dist/app/app/api/update/route.js +29 -20
- package/dist/app/app/page.jsx +13 -23
- package/dist/app/page.jsx +13 -23
- package/dist/d1-studio.js +30 -194
- package/dist/lib/sql-operations.js +30 -24
- package/dist/lib/version-utils.js +34 -0
- package/package.json +2 -2
- package/scripts/studio.js +30 -194
- package/src/app/api/update/route.js +29 -20
- package/src/app/page.jsx +13 -23
- package/src/components/sidebar.jsx +2 -1
- package/src/components/table-view.jsx +1 -1
- package/src/components/update-banner.jsx +69 -38
- package/src/lib/sql-operations.js +30 -24
- package/src/lib/version-utils.js +34 -0
- package/dist/.next/.next/server/chunks/336.js +0 -1
- package/dist/.next/.next/static/chunks/176-9146975ef8699719.js +0 -1
- package/dist/.next/.next/static/chunks/app/layout-8360fab69b848283.js +0 -1
- package/dist/.next/.next/static/chunks/app/page-5990cb23b8bd27c4.js +0 -1
- package/dist/.next/.next/static/css/674bee6608c638e4.css +0 -3
- package/dist/.next/server/chunks/336.js +0 -1
- package/dist/.next/static/chunks/176-9146975ef8699719.js +0 -1
- package/dist/.next/static/chunks/app/layout-8360fab69b848283.js +0 -1
- package/dist/.next/static/chunks/app/page-5990cb23b8bd27c4.js +0 -1
- package/dist/.next/static/css/674bee6608c638e4.css +0 -3
- /package/dist/.next/.next/static/{7XBqETNmhSxMXhw8iUpEa → OUHnbB-64afrrZQL0Srn5}/_buildManifest.js +0 -0
- /package/dist/.next/.next/static/{7XBqETNmhSxMXhw8iUpEa → OUHnbB-64afrrZQL0Srn5}/_ssgManifest.js +0 -0
- /package/dist/.next/{static/MoZBULXFiTFzrY1JVK_Df → .next/static/ZBTCAyp1kO5FdEHMU-Dw2}/_buildManifest.js +0 -0
- /package/dist/.next/{static/MoZBULXFiTFzrY1JVK_Df → .next/static/ZBTCAyp1kO5FdEHMU-Dw2}/_ssgManifest.js +0 -0
|
@@ -112,26 +112,18 @@ export function parseStatement(sql) {
|
|
|
112
112
|
// Extract the index name.
|
|
113
113
|
const indexMatch = cleanSql.match(/INDEX\s+(?:IF\s+NOT\s+EXISTS\s+)?([\w$]+)/i);
|
|
114
114
|
const indexName = indexMatch ? indexMatch[1] : '';
|
|
115
|
-
// Extract the columns from the ON clause.
|
|
116
|
-
const onMatch = cleanSql.match(/ON\s+[\w$]+\s*\(([^)]+)\)/i);
|
|
117
|
-
const columns = onMatch ? onMatch[1].trim() : '';
|
|
118
|
-
// Remove spaces and replace commas with hyphens.
|
|
119
|
-
const formattedColumns = columns.replace(/\s+/g, '').replace(/,/g, '-').toLowerCase();
|
|
120
115
|
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
let description = indexName;
|
|
124
|
-
if (formattedColumns && !description.toLowerCase().includes(formattedColumns)) {
|
|
125
|
-
description += `-${formattedColumns}`;
|
|
126
|
-
}
|
|
116
|
+
// For index migrations, simply use the index name as the description.
|
|
117
|
+
const description = indexName;
|
|
127
118
|
|
|
128
119
|
return {
|
|
129
120
|
type: Operations.CREATE_INDEX,
|
|
130
121
|
tableName,
|
|
131
122
|
sql: cleanSql,
|
|
132
|
-
description // e.g. "
|
|
123
|
+
description // now simply the index name, e.g. "idx_technology_timestamp"
|
|
133
124
|
};
|
|
134
|
-
}
|
|
125
|
+
}
|
|
126
|
+
|
|
135
127
|
|
|
136
128
|
if (upperSql.startsWith('DROP INDEX')) {
|
|
137
129
|
const tableName = extractTableNameFromIndex(cleanSql);
|
|
@@ -559,14 +551,14 @@ export function formatMigrationContent(sql) {
|
|
|
559
551
|
* @returns {Promise<string>} The migration file content.
|
|
560
552
|
*/
|
|
561
553
|
|
|
562
|
-
|
|
554
|
+
export async function getMigrationFileContent(projectDir, databaseName, migrationFile, env) {
|
|
563
555
|
try {
|
|
564
556
|
// Extract table name using improved helper
|
|
565
557
|
const tableName = await extractTableNameFromMigration(migrationFile);
|
|
566
558
|
let sql;
|
|
567
559
|
|
|
568
|
-
|
|
569
|
-
|
|
560
|
+
// For non-index migrations, try getting SQL from sqlite_master for table
|
|
561
|
+
if (tableName && !migrationFile.includes('create-index')) {
|
|
570
562
|
const result = await executeSQL(
|
|
571
563
|
projectDir,
|
|
572
564
|
databaseName,
|
|
@@ -583,24 +575,38 @@ export function formatMigrationContent(sql) {
|
|
|
583
575
|
}
|
|
584
576
|
}
|
|
585
577
|
|
|
586
|
-
// If we couldn't get the SQL from table, try index
|
|
578
|
+
// If we couldn't get the SQL from table and it's an index migration, try fetching via index name.
|
|
587
579
|
if (!sql && migrationFile.includes('create-index')) {
|
|
588
|
-
const indexMatch = migrationFile.match(/create-index[-
|
|
580
|
+
const indexMatch = migrationFile.match(/create-index[_-](.+)\.sql$/i);
|
|
589
581
|
if (indexMatch) {
|
|
590
|
-
|
|
582
|
+
let indexName = indexMatch[1]; // e.g. "idx_technology_timestamp-technology-timestamp"
|
|
583
|
+
let result = await executeSQL(
|
|
591
584
|
projectDir,
|
|
592
585
|
databaseName,
|
|
593
|
-
`SELECT sql FROM sqlite_master WHERE type='index' AND name='${
|
|
586
|
+
`SELECT sql FROM sqlite_master WHERE type='index' AND name='${indexName}' COLLATE NOCASE;`,
|
|
594
587
|
env,
|
|
595
588
|
true
|
|
596
589
|
);
|
|
597
|
-
|
|
590
|
+
let parsed = JSON.parse(result);
|
|
598
591
|
sql = parsed[0]?.results?.[0]?.sql;
|
|
592
|
+
// Fallback: if no result, try using only the part before the first hyphen.
|
|
593
|
+
if (!sql) {
|
|
594
|
+
const fallbackIndexName = indexName.split('-')[0]; // "idx_technology_timestamp"
|
|
595
|
+
result = await executeSQL(
|
|
596
|
+
projectDir,
|
|
597
|
+
databaseName,
|
|
598
|
+
`SELECT sql FROM sqlite_master WHERE type='index' AND name='${fallbackIndexName}' COLLATE NOCASE;`,
|
|
599
|
+
env,
|
|
600
|
+
true
|
|
601
|
+
);
|
|
602
|
+
parsed = JSON.parse(result);
|
|
603
|
+
sql = parsed[0]?.results?.[0]?.sql;
|
|
604
|
+
}
|
|
599
605
|
}
|
|
600
|
-
}
|
|
606
|
+
}
|
|
601
607
|
|
|
602
|
-
// If still no SQL
|
|
603
|
-
if (!sql && tableName) {
|
|
608
|
+
// If still no SQL and it's not an index migration, try a fallback query
|
|
609
|
+
if (!sql && tableName && !migrationFile.includes('create-index')) {
|
|
604
610
|
const result = await executeSQL(
|
|
605
611
|
projectDir,
|
|
606
612
|
databaseName,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// lib/version-utils.js
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compares semantic versions to determine if v2 is newer than v1
|
|
5
|
+
* @param {string} v1 - First version (e.g. "1.0.0")
|
|
6
|
+
* @param {string} v2 - Second version (e.g. "1.0.1")
|
|
7
|
+
* @returns {boolean} True if v2 is newer than v1
|
|
8
|
+
*/
|
|
9
|
+
export function isNewerVersion(v1, v2) {
|
|
10
|
+
if (!v1 || !v2) return false;
|
|
11
|
+
|
|
12
|
+
// Split versions by dots
|
|
13
|
+
const v1Parts = v1.split('.').map(Number);
|
|
14
|
+
const v2Parts = v2.split('.').map(Number);
|
|
15
|
+
|
|
16
|
+
// Compare major, minor, and patch versions
|
|
17
|
+
for (let i = 0; i < 3; i++) {
|
|
18
|
+
if (v2Parts[i] > v1Parts[i]) return true;
|
|
19
|
+
if (v2Parts[i] < v1Parts[i]) return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// If we reach here, versions are equal
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Formats version strings for display by removing leading 'v' if present
|
|
28
|
+
* @param {string} version - The version string (e.g. "v1.0.0" or "1.0.0")
|
|
29
|
+
* @returns {string} Formatted version (e.g. "1.0.0")
|
|
30
|
+
*/
|
|
31
|
+
export function formatVersion(version) {
|
|
32
|
+
if (!version) return '';
|
|
33
|
+
return version.startsWith('v') ? version.substring(1) : version;
|
|
34
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
exports.id=336,exports.ids=[336],exports.modules={97928:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,13219,23)),Promise.resolve().then(r.t.bind(r,34863,23)),Promise.resolve().then(r.t.bind(r,25155,23)),Promise.resolve().then(r.t.bind(r,40802,23)),Promise.resolve().then(r.t.bind(r,9350,23)),Promise.resolve().then(r.t.bind(r,48530,23)),Promise.resolve().then(r.t.bind(r,88921,23))},61480:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,66959,23)),Promise.resolve().then(r.t.bind(r,33875,23)),Promise.resolve().then(r.t.bind(r,88903,23)),Promise.resolve().then(r.t.bind(r,57174,23)),Promise.resolve().then(r.t.bind(r,84178,23)),Promise.resolve().then(r.t.bind(r,87190,23)),Promise.resolve().then(r.t.bind(r,61365,23))},99233:(e,t,r)=>{Promise.resolve().then(r.bind(r,13164)),Promise.resolve().then(r.bind(r,91831))},12385:(e,t,r)=>{Promise.resolve().then(r.bind(r,52652)),Promise.resolve().then(r.bind(r,2899))},52652:(e,t,r)=>{"use strict";r.d(t,{Toaster:()=>v});var a=r(45512),s=r(46888),o=r(58009),i=r(68952),n=r(21643),c=r(51255),l=r(3603);let d=i.Kq,u=o.forwardRef(({className:e,...t},r)=>(0,a.jsx)(i.LM,{ref:r,className:(0,l.cn)("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));u.displayName=i.LM.displayName;let h=(0,n.F)("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),p=o.forwardRef(({className:e,variant:t,...r},s)=>(0,a.jsx)(i.bL,{ref:s,className:(0,l.cn)(h({variant:t}),e),...r}));p.displayName=i.bL.displayName,o.forwardRef(({className:e,...t},r)=>(0,a.jsx)(i.rc,{ref:r,className:(0,l.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t})).displayName=i.rc.displayName;let m=o.forwardRef(({className:e,...t},r)=>(0,a.jsx)(i.bm,{ref:r,className:(0,l.cn)("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:(0,a.jsx)(c.A,{className:"h-4 w-4"})}));m.displayName=i.bm.displayName;let f=o.forwardRef(({className:e,...t},r)=>(0,a.jsx)(i.hE,{ref:r,className:(0,l.cn)("text-sm font-semibold [&+div]:text-xs",e),...t}));f.displayName=i.hE.displayName;let b=o.forwardRef(({className:e,...t},r)=>(0,a.jsx)(i.VY,{ref:r,className:(0,l.cn)("text-sm opacity-90",e),...t}));function v(){let{toasts:e}=(0,s.dj)();return(0,a.jsxs)(d,{children:[e.map(function({id:e,title:t,description:r,action:s,...o}){return(0,a.jsxs)(p,{...o,children:[(0,a.jsxs)("div",{className:"grid gap-1",children:[t&&(0,a.jsx)(f,{children:t}),r&&(0,a.jsx)(b,{children:r})]}),s,(0,a.jsx)(m,{})]},e)}),(0,a.jsx)(u,{})]})}b.displayName=i.VY.displayName},98180:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>u,metadata:()=>d});var a=r(62740),s=r(27944),o=r.n(s),i=r(95510),n=r.n(i);r(61135);var c=r(91831),l=r(13164);let d={title:"d1-studio",description:"Native D1 database studio."};function u({children:e}){return(0,a.jsx)("html",{lang:"en",children:(0,a.jsx)("body",{className:`${o().variable} ${n().variable} antialiased`,children:(0,a.jsxs)(c.DatabaseProvider,{children:[e,(0,a.jsx)(l.Toaster,{})," "]})})})}},13164:(e,t,r)=>{"use strict";r.d(t,{Toaster:()=>a});let a=(0,r(46760).registerClientReference)(function(){throw Error("Attempted to call Toaster() from the server but Toaster is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/karenredona/Desktop/d1studio/src/components/ui/toaster.jsx","Toaster")},61135:()=>{},2899:(e,t,r)=>{"use strict";r.d(t,{DatabaseProvider:()=>u,t:()=>h});var a=r(45512),s=r(58009),o=r(46888);let i=new Map;function n(e,t,r=2e3){let a=i.get(e);if(a&&Date.now()-a.timestamp<r)return a.promise;let s=t();return i.set(e,{promise:s,timestamp:Date.now()}),s.finally(()=>{setTimeout(()=>{i.delete(e)},r)}),s}let c=(0,s.createContext)(void 0);class l{constructor(){this.cache=new Map}get(e){return this.cache.get(e)||null}set(e,t,r,a){this.cache.set(e,{data:t,schema:r,meta:a,timestamp:Date.now()})}update(e,t,r,a){let s=this.cache.get(e);s&&this.cache.set(e,{data:t||s.data,schema:r||s.schema,meta:a||s.meta,timestamp:Date.now()})}invalidate(e){this.cache.delete(e)}clear(){this.cache.clear()}}class d{constructor(){this.queue=[],this.processing=!1}async add(e){return new Promise((t,r)=>{this.queue.push({operation:e,resolve:t,reject:r}),this.process()})}async process(){if(this.processing||0===this.queue.length)return;this.processing=!0;let{operation:e,resolve:t,reject:r}=this.queue.shift();try{let r=await e();t(r)}catch(e){r(e)}finally{this.processing=!1,this.process()}}}function u({children:e}){let{toast:t}=(0,o.dj)(),[r,i]=(0,s.useState)([]),[u,h]=(0,s.useState)(!0),[p,m]=(0,s.useState)(null),[f,b]=(0,s.useState)(null);(0,s.useRef)(new d);let[v,y]=(0,s.useState)(null),g=(0,s.useRef)(new l).current,w=(0,s.useCallback)((e,t=1,r=50)=>{let a=`table-${e}-${t}-${r}`;return g.get(a)},[]),x=(0,s.useCallback)(e=>{g.cache.forEach((t,r)=>{r.startsWith(`table-${e}-`)&&g.invalidate(r)})},[]),T=(0,s.useCallback)((e,t,r,a,s=1,o=50)=>{let i=`table-${e}-${s}-${o}`;g.update(i,t,r,a)},[]),S=(0,s.useCallback)(async e=>n(`query-${e}`,async()=>{try{let t=await fetch("/api/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e})});if(!t.ok){let e="Failed to execute query";try{let r=await t.json();e=r?.error?.message||e}catch(e){}throw Error(e)}let r=await t.json();if(!r.success)throw Error(r.error||"Query execution failed");return r}catch(e){throw e||Error("An unknown error occurred")}},1e3),[]),j=(0,s.useCallback)(async e=>{try{let t=await fetch(`/api/tables/${e}`),r=await t.json();if(!t.ok||!r.success)throw Error(r.error||"Failed to fetch table schema");return r.schema||[]}catch(e){throw console.error("Schema fetch error:",e),t({variant:"destructive",title:"Schema Fetch Failed",description:e.message}),e}},[t]),E=(0,s.useCallback)(async(e,r={})=>{let{forceFetch:a=!1,page:s=1,limit:o=50}=r,i=`table-${e}-${s}-${o}`;if(!a){let e=g.get(i);if(e)return e}return n(`table-${e}-${s}-${o}`,async()=>{try{let t=await fetch(`/api/tables/${e}?page=${s}&limit=${o}`,{headers:{"Cache-Control":"no-cache",Pragma:"no-cache"}});if(!t.ok)throw Error("Failed to fetch table data");let r=await t.json();if(!r.success)throw Error(r.error||"Failed to fetch table data");return g.set(i,r.data,r.schema,r.meta),r}catch(e){throw console.error("Error fetching table data:",e),t({variant:"destructive",title:"Data Fetch Failed",description:e.message}),e}},1e3)},[t]),C=(0,s.useCallback)(async e=>{try{return g.invalidate(e),await E(e,{forceFetch:!0})}catch(e){throw console.error("Error updating table data:",e),t({variant:"destructive",title:"Update Failed",description:e.message}),e}},[E,t]),P=(0,s.useCallback)(async(e,t={})=>(y(e),await E(e,t)),[E]),k=(0,s.useCallback)(async()=>n("refresh-tables",async()=>{h(!0),m(null);try{let e=await fetch("/api/tables");if(!e.ok)throw Error("Failed to fetch tables");let t=await e.json();if(t.error)throw Error(t.error);return i(t.tables||[]),t.tables||[]}catch(e){throw m(e.message),t({variant:"destructive",title:"Refresh Failed",description:e.message}),e}finally{h(!1)}},2e3),[t]),D=(0,s.useCallback)(async e=>{try{await S(e),g.clear(),await k(),t({title:"Success",description:"Table created successfully"})}catch(e){throw t({variant:"destructive",title:"Create Table Failed",description:e.message}),Error(`Failed to create table: ${e.message}`)}},[S,k,t]),N=(0,s.useCallback)(async e=>{try{await S(`DROP TABLE ${e};`),g.invalidate(e),await k(),t({title:"Success",description:"Table dropped successfully"})}catch(e){throw t({variant:"destructive",title:"Drop Table Failed",description:e.message}),Error(`Failed to drop table: ${e.message}`)}},[S,k,t]),$=(0,s.useCallback)(async e=>{try{let r=await fetch("/api/migrations/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){let e=await r.json();throw Error(e.error?.message||"Failed to sync migrations")}let a=await r.json();return t({title:"Success",description:"Migrations synced successfully"}),a}catch(e){throw console.error("Error syncing migrations:",e),t({variant:"destructive",title:"Sync Failed",description:e.message}),e}},[t]),F=(0,s.useCallback)(async()=>{try{let e=localStorage.getItem("cf_credentials");if(!e)throw Error("No Cloudflare credentials found. Please connect to Cloudflare first.");let t=JSON.parse(e);if(!t.accountId||!t.apiToken)throw Error("Invalid credentials stored. Please reconnect to Cloudflare.");let r=await fetch("/api/pull-remote/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accountId:t.accountId,apiToken:t.apiToken})}),a=await r.json();if(!r.ok||!a.success)throw Error(a.error?.message||"Failed to pull from remote");return g.clear(),await k(),a}catch(e){throw console.error("Error pulling from remote:",e),t({variant:"destructive",title:"Pull Failed",description:e.message}),e}},[k,t]),O=(0,s.useCallback)(async e=>{try{let t=await fetch("/api/push-remote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await t.json();if(!t.ok)throw Error(r.error?.message||"Failed to push to remote");return r}catch(e){throw console.error("Error pushing to remote:",e),e}},[t]),A=(0,s.useMemo)(()=>({tables:r,currentDatabase:f,isLoading:u,error:p,activeTable:v,refreshTables:k,executeQuery:S,fetchTableSchema:j,fetchTableData:E,updateTableData:C,createTable:D,dropTable:N,syncMigrations:$,pullFromRemote:F,pushToRemote:O,getCachedTable:w,updateTableCache:T,invalidateTable:x,switchTable:P}),[r,f,u,p,v,k,S,j,E,C,D,N,$,F,O,w,T,x,P]);return(0,a.jsx)(c.Provider,{value:A,children:e})}function h(){let e=(0,s.useContext)(c);if(!e)throw Error("useDatabase must be used within a DatabaseProvider");return e}},46888:(e,t,r)=>{"use strict";r.d(t,{dj:()=>h});var a=r(58009);let s=0,o=new Map,i=e=>{if(o.has(e))return;let t=setTimeout(()=>{o.delete(e),d({type:"REMOVE_TOAST",toastId:e})},1e6);o.set(e,t)},n=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{let{toastId:r}=t;return r?i(r):e.toasts.forEach(e=>{i(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===r||void 0===r?{...e,open:!1}:e)}}case"REMOVE_TOAST":if(void 0===t.toastId)return{...e,toasts:[]};return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},c=[],l={toasts:[]};function d(e){l=n(l,e),c.forEach(e=>{e(l)})}function u({...e}){let t=(s=(s+1)%Number.MAX_SAFE_INTEGER).toString(),r=()=>d({type:"DISMISS_TOAST",toastId:t});return d({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||r()}}}),{id:t,dismiss:r,update:e=>d({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function h(){let[e,t]=a.useState(l);return a.useEffect(()=>(c.push(t),()=>{let e=c.indexOf(t);e>-1&&c.splice(e,1)}),[e]),{...e,toast:u,dismiss:e=>d({type:"DISMISS_TOAST",toastId:e})}}},3603:(e,t,r)=>{"use strict";r.d(t,{cn:()=>o});var a=r(82281),s=r(94805);function o(...e){return(0,s.QP)((0,a.$)(e))}},91831:(e,t,r)=>{"use strict";r.d(t,{DatabaseProvider:()=>s});var a=r(46760);let s=(0,a.registerClientReference)(function(){throw Error("Attempted to call DatabaseProvider() from the server but DatabaseProvider is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/karenredona/Desktop/d1studio/src/context/database-context.js","DatabaseProvider");(0,a.registerClientReference)(function(){throw Error("Attempted to call useDatabase() from the server but useDatabase is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/karenredona/Desktop/d1studio/src/context/database-context.js","useDatabase")}};
|