@boltapp/bolt-app-db 0.0.15 → 0.0.16

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.
@@ -0,0 +1,23 @@
1
+ export interface ClientSchemaJournalEntry {
2
+ idx: number;
3
+ tag: string;
4
+ schemaVersion: number;
5
+ boltVersionRange: string;
6
+ dialect: "sqlite";
7
+ when: number;
8
+ checksum: string;
9
+ }
10
+ export interface ClientSchemaJournal {
11
+ formatVersion: number;
12
+ dialect: "sqlite";
13
+ entries: ClientSchemaJournalEntry[];
14
+ }
15
+ export declare function getClientSchemaJournal(): ClientSchemaJournal;
16
+ export declare function getLatestClientSchema(): {
17
+ entry: ClientSchemaJournalEntry;
18
+ sql: string;
19
+ };
20
+ export declare function resolveClientSchemaForBoltVersion(boltVersion: string): {
21
+ entry: ClientSchemaJournalEntry;
22
+ sql: string;
23
+ };
@@ -0,0 +1,51 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { satisfies } from "semver";
5
+ const packageDir = path.dirname(fileURLToPath(import.meta.url));
6
+ const snapshotDir = path.join(packageDir, "snapshots");
7
+ const clientJournalPath = path.join(snapshotDir, "meta", "journal.json");
8
+ function readClientJournal() {
9
+ const raw = fs.readFileSync(clientJournalPath, "utf8");
10
+ return JSON.parse(raw);
11
+ }
12
+ function readClientSqlByTag(tag) {
13
+ const sqlPath = path.join(snapshotDir, `${tag}.sql`);
14
+ if (!fs.existsSync(sqlPath)) {
15
+ throw new Error(`Client schema SQL file not found for tag '${tag}' at ${sqlPath}`);
16
+ }
17
+ return fs.readFileSync(sqlPath, "utf8");
18
+ }
19
+ function getLatestEntry(journal) {
20
+ if (journal.entries.length === 0) {
21
+ throw new Error("No client schema entries found in journal.");
22
+ }
23
+ return [...journal.entries].sort((a, b) => b.idx - a.idx)[0];
24
+ }
25
+ export function getClientSchemaJournal() {
26
+ return readClientJournal();
27
+ }
28
+ export function getLatestClientSchema() {
29
+ const journal = readClientJournal();
30
+ const entry = getLatestEntry(journal);
31
+ const sql = readClientSqlByTag(entry.tag);
32
+ return { entry, sql };
33
+ }
34
+ export function resolveClientSchemaForBoltVersion(boltVersion) {
35
+ const journal = readClientJournal();
36
+ const matching = journal.entries
37
+ .filter((entry) => {
38
+ try {
39
+ return satisfies(boltVersion, entry.boltVersionRange, {
40
+ includePrerelease: true,
41
+ });
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ })
47
+ .sort((a, b) => b.idx - a.idx);
48
+ const entry = matching[0] ?? getLatestEntry(journal);
49
+ const sql = readClientSqlByTag(entry.tag);
50
+ return { entry, sql };
51
+ }
@@ -0,0 +1,157 @@
1
+ -- AUTO-GENERATED FILE - DO NOT EDIT MANUALLY.
2
+ -- Generated by helpers/scripts/bolt-cli-generate-client-schema.ts
3
+ -- Tag: 0000_initial
4
+ -- Schema Version: 1
5
+ -- Bolt Version Range: *
6
+ -- Generated at: 2026-03-05T15:01:28.552Z
7
+ CREATE TABLE `bolt_app_versions` (
8
+ `id` text PRIMARY KEY NOT NULL,
9
+ `appId` text NOT NULL,
10
+ `incrementalId` integer NOT NULL,
11
+ `publishedAt` integer,
12
+ `notes` text,
13
+ `model` text,
14
+ `s3Url` text,
15
+ `createdAt` integer,
16
+ `updatedAt` integer,
17
+ `createdBy` text DEFAULT 'system' NOT NULL,
18
+ `updatedBy` text DEFAULT 'system' NOT NULL,
19
+ FOREIGN KEY (`appId`) REFERENCES `bolt_apps`(`id`) ON UPDATE no action ON DELETE cascade
20
+ );
21
+
22
+ CREATE INDEX `bolt_app_versions_app_id_idx` ON `bolt_app_versions` (`appId`);
23
+ CREATE UNIQUE INDEX `bolt_app_versions_app_incremental_idx` ON `bolt_app_versions` (`appId`,`incrementalId`);
24
+ CREATE TABLE `bolt_apps` (
25
+ `id` text PRIMARY KEY NOT NULL,
26
+ `name` text NOT NULL,
27
+ `title` text NOT NULL,
28
+ `description` text,
29
+ `status` text DEFAULT 'draft' NOT NULL,
30
+ `projectId` text NOT NULL,
31
+ `createdAt` integer,
32
+ `updatedAt` integer,
33
+ `createdBy` text DEFAULT 'system' NOT NULL,
34
+ `updatedBy` text DEFAULT 'system' NOT NULL,
35
+ FOREIGN KEY (`projectId`) REFERENCES `bolt_projects`(`id`) ON UPDATE no action ON DELETE cascade
36
+ );
37
+
38
+ CREATE UNIQUE INDEX `bolt_apps_name_unique_idx` ON `bolt_apps` (`name`);
39
+ CREATE INDEX `bolt_apps_project_id_idx` ON `bolt_apps` (`projectId`);
40
+ CREATE INDEX `bolt_apps_status_idx` ON `bolt_apps` (`status`);
41
+ CREATE TABLE `bolt_data_stores` (
42
+ `id` text PRIMARY KEY NOT NULL,
43
+ `name` text NOT NULL,
44
+ `label` text DEFAULT 'Untitled Store' NOT NULL,
45
+ `description` text,
46
+ `items` text,
47
+ `data` text NOT NULL,
48
+ `app_id` text NOT NULL,
49
+ `organization_id` text,
50
+ `createdBy` text DEFAULT 'system' NOT NULL,
51
+ `updatedBy` text DEFAULT 'system' NOT NULL,
52
+ `createdAt` integer,
53
+ `updatedAt` integer
54
+ );
55
+
56
+ CREATE UNIQUE INDEX `bolt_data_stores_app_name_unique_idx` ON `bolt_data_stores` (`app_id`,`name`);
57
+ CREATE INDEX `bolt_data_stores_app_idx` ON `bolt_data_stores` (`app_id`);
58
+ CREATE TABLE `bolt_files` (
59
+ `id` text PRIMARY KEY NOT NULL,
60
+ `app_id` text NOT NULL,
61
+ `organization_id` text,
62
+ `name` text NOT NULL,
63
+ `url` text NOT NULL,
64
+ `mime_type` text NOT NULL,
65
+ `extension` text,
66
+ `size` integer,
67
+ `width` integer,
68
+ `height` integer,
69
+ `alt` text,
70
+ `source` text DEFAULT 'local',
71
+ `storage_path` text NOT NULL,
72
+ `created_by` text DEFAULT 'system' NOT NULL,
73
+ `updated_by` text DEFAULT 'system',
74
+ `created_at` integer,
75
+ `updated_at` integer
76
+ );
77
+
78
+ CREATE INDEX `bolt_files_app_idx` ON `bolt_files` (`app_id`);
79
+ CREATE INDEX `bolt_files_name_idx` ON `bolt_files` (`name`);
80
+ CREATE TABLE `bolt_projects` (
81
+ `id` text PRIMARY KEY NOT NULL,
82
+ `name` text NOT NULL,
83
+ `description` text,
84
+ `slug` text NOT NULL,
85
+ `createdAt` integer,
86
+ `updatedAt` integer,
87
+ `createdBy` text DEFAULT 'system' NOT NULL,
88
+ `updatedBy` text DEFAULT 'system' NOT NULL
89
+ );
90
+
91
+ CREATE UNIQUE INDEX `bolt_projects_name_unique_idx` ON `bolt_projects` (`name`);
92
+ CREATE UNIQUE INDEX `bolt_projects_slug_unique_idx` ON `bolt_projects` (`slug`);
93
+ CREATE TABLE `bolt_table_ops` (
94
+ `id` text,
95
+ `server_seq` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
96
+ `clientActionId` text,
97
+ `type` text NOT NULL,
98
+ `rowId` text,
99
+ `colId` text,
100
+ `tableId` text NOT NULL,
101
+ `source` text DEFAULT 'server' NOT NULL,
102
+ `payload` text NOT NULL,
103
+ `basis_row_version` integer,
104
+ `basis_table_version` integer,
105
+ `userId` text NOT NULL,
106
+ `createdAt` integer,
107
+ FOREIGN KEY (`tableId`) REFERENCES `bolt_tables`(`id`) ON UPDATE no action ON DELETE cascade
108
+ );
109
+
110
+ CREATE INDEX `bolt_table_ops_table_seq_idx` ON `bolt_table_ops` (`tableId`,`server_seq`);
111
+ CREATE INDEX `bolt_table_ops_table_idx` ON `bolt_table_ops` (`tableId`);
112
+ CREATE INDEX `bolt_table_ops_row_idx` ON `bolt_table_ops` (`rowId`);
113
+ CREATE INDEX `bolt_table_ops_col_idx` ON `bolt_table_ops` (`colId`);
114
+ CREATE INDEX `bolt_table_ops_type_idx` ON `bolt_table_ops` (`type`);
115
+ CREATE TABLE `bolt_table_views` (
116
+ `id` text PRIMARY KEY NOT NULL,
117
+ `name` text NOT NULL,
118
+ `label` text DEFAULT 'Untitled View' NOT NULL,
119
+ `tableId` text NOT NULL,
120
+ `description` text,
121
+ `display` text DEFAULT 'table' NOT NULL,
122
+ `visibleColumnIds` text NOT NULL,
123
+ `sorting` text,
124
+ `showRowNumbers` integer,
125
+ `rowHeight` integer,
126
+ `displayConfig` text NOT NULL,
127
+ `projectId` text,
128
+ `organizationId` text,
129
+ `createdBy` text,
130
+ `createdAt` integer,
131
+ `updatedAt` integer,
132
+ FOREIGN KEY (`tableId`) REFERENCES `bolt_tables`(`id`) ON UPDATE no action ON DELETE cascade,
133
+ FOREIGN KEY (`projectId`) REFERENCES `bolt_projects`(`id`) ON UPDATE no action ON DELETE cascade
134
+ );
135
+
136
+ CREATE INDEX `bolt_table_views_table_id_idx` ON `bolt_table_views` (`tableId`);
137
+ CREATE INDEX `bolt_table_views_project_idx` ON `bolt_table_views` (`projectId`);
138
+ CREATE TABLE `bolt_tables` (
139
+ `id` text PRIMARY KEY NOT NULL,
140
+ `name` text NOT NULL,
141
+ `label` text DEFAULT 'Untitled Table' NOT NULL,
142
+ `description` text,
143
+ `idField` text DEFAULT 'id' NOT NULL,
144
+ `displayColumn` text NOT NULL,
145
+ `columns` text,
146
+ `rows` text,
147
+ `projectId` text NOT NULL,
148
+ `organizationId` text,
149
+ `createdBy` text DEFAULT 'system' NOT NULL,
150
+ `updatedBy` text DEFAULT 'system' NOT NULL,
151
+ `createdAt` integer,
152
+ `updatedAt` integer,
153
+ FOREIGN KEY (`projectId`) REFERENCES `bolt_projects`(`id`) ON UPDATE no action ON DELETE cascade
154
+ );
155
+
156
+ CREATE UNIQUE INDEX `bolt_tables_project_name_unique_idx` ON `bolt_tables` (`projectId`,`name`);
157
+ CREATE INDEX `bolt_tables_project_idx` ON `bolt_tables` (`projectId`);
@@ -0,0 +1,157 @@
1
+ -- AUTO-GENERATED FILE - DO NOT EDIT MANUALLY.
2
+ -- Generated by helpers/scripts/bolt-cli-generate-client-schema.ts
3
+ -- Tag: 0001_client_schema
4
+ -- Schema Version: 2
5
+ -- Bolt Version Range: *
6
+ -- Generated at: 2026-03-05T15:05:35.968Z
7
+ CREATE TABLE `bolt_app_versions` (
8
+ `id` text PRIMARY KEY NOT NULL,
9
+ `appId` text NOT NULL,
10
+ `incrementalId` integer NOT NULL,
11
+ `publishedAt` integer,
12
+ `notes` text,
13
+ `model` text,
14
+ `s3Url` text,
15
+ `createdAt` integer,
16
+ `updatedAt` integer,
17
+ `createdBy` text DEFAULT 'system' NOT NULL,
18
+ `updatedBy` text DEFAULT 'system' NOT NULL,
19
+ FOREIGN KEY (`appId`) REFERENCES `bolt_apps`(`id`) ON UPDATE no action ON DELETE cascade
20
+ );
21
+
22
+ CREATE INDEX `bolt_app_versions_app_id_idx` ON `bolt_app_versions` (`appId`);
23
+ CREATE UNIQUE INDEX `bolt_app_versions_app_incremental_idx` ON `bolt_app_versions` (`appId`,`incrementalId`);
24
+ CREATE TABLE `bolt_apps` (
25
+ `id` text PRIMARY KEY NOT NULL,
26
+ `name` text NOT NULL,
27
+ `title` text NOT NULL,
28
+ `description` text,
29
+ `status` text DEFAULT 'draft' NOT NULL,
30
+ `projectId` text NOT NULL,
31
+ `createdAt` integer,
32
+ `updatedAt` integer,
33
+ `createdBy` text DEFAULT 'system' NOT NULL,
34
+ `updatedBy` text DEFAULT 'system' NOT NULL,
35
+ FOREIGN KEY (`projectId`) REFERENCES `bolt_projects`(`id`) ON UPDATE no action ON DELETE cascade
36
+ );
37
+
38
+ CREATE UNIQUE INDEX `bolt_apps_name_unique_idx` ON `bolt_apps` (`name`);
39
+ CREATE INDEX `bolt_apps_project_id_idx` ON `bolt_apps` (`projectId`);
40
+ CREATE INDEX `bolt_apps_status_idx` ON `bolt_apps` (`status`);
41
+ CREATE TABLE `bolt_data_stores` (
42
+ `id` text PRIMARY KEY NOT NULL,
43
+ `name` text NOT NULL,
44
+ `label` text DEFAULT 'Untitled Store' NOT NULL,
45
+ `description` text,
46
+ `items` text,
47
+ `data` text NOT NULL,
48
+ `app_id` text NOT NULL,
49
+ `organization_id` text,
50
+ `createdBy` text DEFAULT 'system' NOT NULL,
51
+ `updatedBy` text DEFAULT 'system' NOT NULL,
52
+ `createdAt` integer,
53
+ `updatedAt` integer
54
+ );
55
+
56
+ CREATE UNIQUE INDEX `bolt_data_stores_app_name_unique_idx` ON `bolt_data_stores` (`app_id`,`name`);
57
+ CREATE INDEX `bolt_data_stores_app_idx` ON `bolt_data_stores` (`app_id`);
58
+ CREATE TABLE `bolt_files` (
59
+ `id` text PRIMARY KEY NOT NULL,
60
+ `app_id` text NOT NULL,
61
+ `organization_id` text,
62
+ `name` text NOT NULL,
63
+ `url` text NOT NULL,
64
+ `mime_type` text NOT NULL,
65
+ `extension` text,
66
+ `size` integer,
67
+ `width` integer,
68
+ `height` integer,
69
+ `alt` text,
70
+ `source` text DEFAULT 'local',
71
+ `storage_path` text NOT NULL,
72
+ `created_by` text DEFAULT 'system' NOT NULL,
73
+ `updated_by` text DEFAULT 'system',
74
+ `created_at` integer,
75
+ `updated_at` integer
76
+ );
77
+
78
+ CREATE INDEX `bolt_files_app_idx` ON `bolt_files` (`app_id`);
79
+ CREATE INDEX `bolt_files_name_idx` ON `bolt_files` (`name`);
80
+ CREATE TABLE `bolt_projects` (
81
+ `id` text PRIMARY KEY NOT NULL,
82
+ `name` text NOT NULL,
83
+ `description` text,
84
+ `slug` text NOT NULL,
85
+ `createdAt` integer,
86
+ `updatedAt` integer,
87
+ `createdBy` text DEFAULT 'system' NOT NULL,
88
+ `updatedBy` text DEFAULT 'system' NOT NULL
89
+ );
90
+
91
+ CREATE UNIQUE INDEX `bolt_projects_name_unique_idx` ON `bolt_projects` (`name`);
92
+ CREATE UNIQUE INDEX `bolt_projects_slug_unique_idx` ON `bolt_projects` (`slug`);
93
+ CREATE TABLE `bolt_table_ops` (
94
+ `id` text,
95
+ `server_seq` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
96
+ `clientActionId` text,
97
+ `type` text NOT NULL,
98
+ `rowId` text,
99
+ `colId` text,
100
+ `tableId` text NOT NULL,
101
+ `source` text DEFAULT 'server' NOT NULL,
102
+ `payload` text NOT NULL,
103
+ `basis_row_version` integer,
104
+ `basis_table_version` integer,
105
+ `userId` text NOT NULL,
106
+ `createdAt` integer,
107
+ FOREIGN KEY (`tableId`) REFERENCES `bolt_tables`(`id`) ON UPDATE no action ON DELETE cascade
108
+ );
109
+
110
+ CREATE INDEX `bolt_table_ops_table_seq_idx` ON `bolt_table_ops` (`tableId`,`server_seq`);
111
+ CREATE INDEX `bolt_table_ops_table_idx` ON `bolt_table_ops` (`tableId`);
112
+ CREATE INDEX `bolt_table_ops_row_idx` ON `bolt_table_ops` (`rowId`);
113
+ CREATE INDEX `bolt_table_ops_col_idx` ON `bolt_table_ops` (`colId`);
114
+ CREATE INDEX `bolt_table_ops_type_idx` ON `bolt_table_ops` (`type`);
115
+ CREATE TABLE `bolt_table_views` (
116
+ `id` text PRIMARY KEY NOT NULL,
117
+ `name` text NOT NULL,
118
+ `label` text DEFAULT 'Untitled View' NOT NULL,
119
+ `tableId` text NOT NULL,
120
+ `description` text,
121
+ `display` text DEFAULT 'table' NOT NULL,
122
+ `visibleColumnIds` text NOT NULL,
123
+ `sorting` text,
124
+ `showRowNumbers` integer,
125
+ `rowHeight` integer,
126
+ `displayConfig` text NOT NULL,
127
+ `projectId` text,
128
+ `organizationId` text,
129
+ `createdBy` text,
130
+ `createdAt` integer,
131
+ `updatedAt` integer,
132
+ FOREIGN KEY (`tableId`) REFERENCES `bolt_tables`(`id`) ON UPDATE no action ON DELETE cascade,
133
+ FOREIGN KEY (`projectId`) REFERENCES `bolt_projects`(`id`) ON UPDATE no action ON DELETE cascade
134
+ );
135
+
136
+ CREATE INDEX `bolt_table_views_table_id_idx` ON `bolt_table_views` (`tableId`);
137
+ CREATE INDEX `bolt_table_views_project_idx` ON `bolt_table_views` (`projectId`);
138
+ CREATE TABLE `bolt_tables` (
139
+ `id` text PRIMARY KEY NOT NULL,
140
+ `name` text NOT NULL,
141
+ `label` text DEFAULT 'Untitled Table' NOT NULL,
142
+ `description` text,
143
+ `idField` text DEFAULT 'id' NOT NULL,
144
+ `displayColumn` text NOT NULL,
145
+ `columns` text,
146
+ `rows` text,
147
+ `projectId` text NOT NULL,
148
+ `organizationId` text,
149
+ `createdBy` text DEFAULT 'system' NOT NULL,
150
+ `updatedBy` text DEFAULT 'system' NOT NULL,
151
+ `createdAt` integer,
152
+ `updatedAt` integer,
153
+ FOREIGN KEY (`projectId`) REFERENCES `bolt_projects`(`id`) ON UPDATE no action ON DELETE cascade
154
+ );
155
+
156
+ CREATE UNIQUE INDEX `bolt_tables_project_name_unique_idx` ON `bolt_tables` (`projectId`,`name`);
157
+ CREATE INDEX `bolt_tables_project_idx` ON `bolt_tables` (`projectId`);
@@ -0,0 +1,157 @@
1
+ -- AUTO-GENERATED FILE - DO NOT EDIT MANUALLY.
2
+ -- Generated by helpers/scripts/bolt-cli-generate-client-schema.ts
3
+ -- Tag: 0002_client_schema
4
+ -- Schema Version: 3
5
+ -- Bolt Version Range: *
6
+ -- Generated at: 2026-03-05T15:07:18.189Z
7
+ CREATE TABLE `bolt_app_versions` (
8
+ `id` text PRIMARY KEY NOT NULL,
9
+ `appId` text NOT NULL,
10
+ `incrementalId` integer NOT NULL,
11
+ `publishedAt` integer,
12
+ `notes` text,
13
+ `model` text,
14
+ `s3Url` text,
15
+ `createdAt` integer,
16
+ `updatedAt` integer,
17
+ `createdBy` text DEFAULT 'system' NOT NULL,
18
+ `updatedBy` text DEFAULT 'system' NOT NULL,
19
+ FOREIGN KEY (`appId`) REFERENCES `bolt_apps`(`id`) ON UPDATE no action ON DELETE cascade
20
+ );
21
+
22
+ CREATE INDEX `bolt_app_versions_app_id_idx` ON `bolt_app_versions` (`appId`);
23
+ CREATE UNIQUE INDEX `bolt_app_versions_app_incremental_idx` ON `bolt_app_versions` (`appId`,`incrementalId`);
24
+ CREATE TABLE `bolt_apps` (
25
+ `id` text PRIMARY KEY NOT NULL,
26
+ `name` text NOT NULL,
27
+ `title` text NOT NULL,
28
+ `description` text,
29
+ `status` text DEFAULT 'draft' NOT NULL,
30
+ `projectId` text NOT NULL,
31
+ `createdAt` integer,
32
+ `updatedAt` integer,
33
+ `createdBy` text DEFAULT 'system' NOT NULL,
34
+ `updatedBy` text DEFAULT 'system' NOT NULL,
35
+ FOREIGN KEY (`projectId`) REFERENCES `bolt_projects`(`id`) ON UPDATE no action ON DELETE cascade
36
+ );
37
+
38
+ CREATE UNIQUE INDEX `bolt_apps_name_unique_idx` ON `bolt_apps` (`name`);
39
+ CREATE INDEX `bolt_apps_project_id_idx` ON `bolt_apps` (`projectId`);
40
+ CREATE INDEX `bolt_apps_status_idx` ON `bolt_apps` (`status`);
41
+ CREATE TABLE `bolt_data_stores` (
42
+ `id` text PRIMARY KEY NOT NULL,
43
+ `name` text NOT NULL,
44
+ `label` text DEFAULT 'Untitled Store' NOT NULL,
45
+ `description` text,
46
+ `items` text,
47
+ `data` text NOT NULL,
48
+ `app_id` text NOT NULL,
49
+ `organization_id` text,
50
+ `createdBy` text DEFAULT 'system' NOT NULL,
51
+ `updatedBy` text DEFAULT 'system' NOT NULL,
52
+ `createdAt` integer,
53
+ `updatedAt` integer
54
+ );
55
+
56
+ CREATE UNIQUE INDEX `bolt_data_stores_app_name_unique_idx` ON `bolt_data_stores` (`app_id`,`name`);
57
+ CREATE INDEX `bolt_data_stores_app_idx` ON `bolt_data_stores` (`app_id`);
58
+ CREATE TABLE `bolt_files` (
59
+ `id` text PRIMARY KEY NOT NULL,
60
+ `app_id` text NOT NULL,
61
+ `organization_id` text,
62
+ `name` text NOT NULL,
63
+ `url` text NOT NULL,
64
+ `mime_type` text NOT NULL,
65
+ `extension` text,
66
+ `size` integer,
67
+ `width` integer,
68
+ `height` integer,
69
+ `alt` text,
70
+ `source` text DEFAULT 'local',
71
+ `storage_path` text NOT NULL,
72
+ `created_by` text DEFAULT 'system' NOT NULL,
73
+ `updated_by` text DEFAULT 'system',
74
+ `created_at` integer,
75
+ `updated_at` integer
76
+ );
77
+
78
+ CREATE INDEX `bolt_files_app_idx` ON `bolt_files` (`app_id`);
79
+ CREATE INDEX `bolt_files_name_idx` ON `bolt_files` (`name`);
80
+ CREATE TABLE `bolt_projects` (
81
+ `id` text PRIMARY KEY NOT NULL,
82
+ `name` text NOT NULL,
83
+ `description` text,
84
+ `slug` text NOT NULL,
85
+ `createdAt` integer,
86
+ `updatedAt` integer,
87
+ `createdBy` text DEFAULT 'system' NOT NULL,
88
+ `updatedBy` text DEFAULT 'system' NOT NULL
89
+ );
90
+
91
+ CREATE UNIQUE INDEX `bolt_projects_name_unique_idx` ON `bolt_projects` (`name`);
92
+ CREATE UNIQUE INDEX `bolt_projects_slug_unique_idx` ON `bolt_projects` (`slug`);
93
+ CREATE TABLE `bolt_table_ops` (
94
+ `id` text,
95
+ `server_seq` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
96
+ `clientActionId` text,
97
+ `type` text NOT NULL,
98
+ `rowId` text,
99
+ `colId` text,
100
+ `tableId` text NOT NULL,
101
+ `source` text DEFAULT 'server' NOT NULL,
102
+ `payload` text NOT NULL,
103
+ `basis_row_version` integer,
104
+ `basis_table_version` integer,
105
+ `userId` text NOT NULL,
106
+ `createdAt` integer,
107
+ FOREIGN KEY (`tableId`) REFERENCES `bolt_tables`(`id`) ON UPDATE no action ON DELETE cascade
108
+ );
109
+
110
+ CREATE INDEX `bolt_table_ops_table_seq_idx` ON `bolt_table_ops` (`tableId`,`server_seq`);
111
+ CREATE INDEX `bolt_table_ops_table_idx` ON `bolt_table_ops` (`tableId`);
112
+ CREATE INDEX `bolt_table_ops_row_idx` ON `bolt_table_ops` (`rowId`);
113
+ CREATE INDEX `bolt_table_ops_col_idx` ON `bolt_table_ops` (`colId`);
114
+ CREATE INDEX `bolt_table_ops_type_idx` ON `bolt_table_ops` (`type`);
115
+ CREATE TABLE `bolt_table_views` (
116
+ `id` text PRIMARY KEY NOT NULL,
117
+ `name` text NOT NULL,
118
+ `label` text DEFAULT 'Untitled View' NOT NULL,
119
+ `tableId` text NOT NULL,
120
+ `description` text,
121
+ `display` text DEFAULT 'table' NOT NULL,
122
+ `visibleColumnIds` text NOT NULL,
123
+ `sorting` text,
124
+ `showRowNumbers` integer,
125
+ `rowHeight` integer,
126
+ `displayConfig` text NOT NULL,
127
+ `projectId` text,
128
+ `organizationId` text,
129
+ `createdBy` text,
130
+ `createdAt` integer,
131
+ `updatedAt` integer,
132
+ FOREIGN KEY (`tableId`) REFERENCES `bolt_tables`(`id`) ON UPDATE no action ON DELETE cascade,
133
+ FOREIGN KEY (`projectId`) REFERENCES `bolt_projects`(`id`) ON UPDATE no action ON DELETE cascade
134
+ );
135
+
136
+ CREATE INDEX `bolt_table_views_table_id_idx` ON `bolt_table_views` (`tableId`);
137
+ CREATE INDEX `bolt_table_views_project_idx` ON `bolt_table_views` (`projectId`);
138
+ CREATE TABLE `bolt_tables` (
139
+ `id` text PRIMARY KEY NOT NULL,
140
+ `name` text NOT NULL,
141
+ `label` text DEFAULT 'Untitled Table' NOT NULL,
142
+ `description` text,
143
+ `idField` text DEFAULT 'id' NOT NULL,
144
+ `displayColumn` text NOT NULL,
145
+ `columns` text,
146
+ `rows` text,
147
+ `projectId` text NOT NULL,
148
+ `organizationId` text,
149
+ `createdBy` text DEFAULT 'system' NOT NULL,
150
+ `updatedBy` text DEFAULT 'system' NOT NULL,
151
+ `createdAt` integer,
152
+ `updatedAt` integer,
153
+ FOREIGN KEY (`projectId`) REFERENCES `bolt_projects`(`id`) ON UPDATE no action ON DELETE cascade
154
+ );
155
+
156
+ CREATE UNIQUE INDEX `bolt_tables_project_name_unique_idx` ON `bolt_tables` (`projectId`,`name`);
157
+ CREATE INDEX `bolt_tables_project_idx` ON `bolt_tables` (`projectId`);
@@ -0,0 +1,33 @@
1
+ {
2
+ "formatVersion": 1,
3
+ "dialect": "sqlite",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "tag": "0000_initial",
8
+ "schemaVersion": 1,
9
+ "boltVersionRange": "*",
10
+ "dialect": "sqlite",
11
+ "when": 1772722888555,
12
+ "checksum": "sha256:bd7919d45f2ab219d322c42fcc9dbda0ee5f7d81e88f03465c992866f82d4a8e"
13
+ },
14
+ {
15
+ "idx": 1,
16
+ "tag": "0001_client_schema",
17
+ "schemaVersion": 2,
18
+ "boltVersionRange": "*",
19
+ "dialect": "sqlite",
20
+ "when": 1772723135969,
21
+ "checksum": "sha256:bd7919d45f2ab219d322c42fcc9dbda0ee5f7d81e88f03465c992866f82d4a8e"
22
+ },
23
+ {
24
+ "idx": 2,
25
+ "tag": "0002_client_schema",
26
+ "schemaVersion": 3,
27
+ "boltVersionRange": "*",
28
+ "dialect": "sqlite",
29
+ "when": 1772723238190,
30
+ "checksum": "sha256:bd7919d45f2ab219d322c42fcc9dbda0ee5f7d81e88f03465c992866f82d4a8e"
31
+ }
32
+ ]
33
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "formatVersion": 1,
3
+ "dialect": "sqlite",
4
+ "entries": []
5
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * as clientSchema from "./client/schema/index.js";
2
+ export * from "./client/snapshot-resolver.js";
2
3
  export * as cloudAppSchema from "./cloud-app/schema/index.js";
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * as clientSchema from "./client/schema/index.js";
2
+ export * from "./client/snapshot-resolver.js";
2
3
  export * as cloudAppSchema from "./cloud-app/schema/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boltapp/bolt-app-db",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,7 +11,8 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "dev": "echo 'Add dev script here'",
14
- "build": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});fs.rmSync('tsconfig.tsbuildinfo',{force:true});\" && tsc -p tsconfig.json && tsc-alias -p tsconfig.json --resolve-full-paths --resolve-full-extension .js && tsc-esm-fix --target=dist --ext=.js --dirnameVar=false --filenameVar=false",
14
+ "build": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});fs.rmSync('tsconfig.tsbuildinfo',{force:true});\" && tsc -p tsconfig.json && tsc-alias -p tsconfig.json --resolve-full-paths --resolve-full-extension .js && tsc-esm-fix --target=dist --ext=.js --dirnameVar=false --filenameVar=false && pnpm run build:assets",
15
+ "build:assets": "node -e \"const fs=require('fs');fs.cpSync('src/client/snapshots','dist/client/snapshots',{recursive:true});fs.cpSync('src/cloud-app/snapshots','dist/cloud-app/snapshots',{recursive:true})\"",
15
16
  "prepack": "pnpm build",
16
17
  "test": "echo 'Add test script here'",
17
18
  "lint": "echo 'Add lint script here'",
@@ -32,6 +33,10 @@
32
33
  "types": "./dist/client/schema/index.d.ts",
33
34
  "default": "./dist/client/schema/index.js"
34
35
  },
36
+ "./client/snapshot-resolver": {
37
+ "types": "./dist/client/snapshot-resolver.d.ts",
38
+ "default": "./dist/client/snapshot-resolver.js"
39
+ },
35
40
  "./cloud-app/schema": {
36
41
  "types": "./dist/cloud-app/schema/index.d.ts",
37
42
  "default": "./dist/cloud-app/schema/index.js"
@@ -41,9 +46,11 @@
41
46
  "dependencies": {
42
47
  "@boltapp/bolt-core": "npm:@boltapp/bolt-core@0.0.14",
43
48
  "drizzle-orm": "^0.44.4",
44
- "nanoid": "^5.1.5"
49
+ "nanoid": "^5.1.5",
50
+ "semver": "^7.7.3"
45
51
  },
46
52
  "devDependencies": {
53
+ "@types/semver": "^7.7.1",
47
54
  "@workspace/eslint-config": "workspace:*",
48
55
  "@workspace/typescript-config": "workspace:*",
49
56
  "tsc-alias": "^1.8.16",