@boltapp/bolt-app-db 0.0.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/README.md +1 -0
- package/dist/client/schema/app-schema.d.ts +409 -0
- package/dist/client/schema/app-schema.js +59 -0
- package/dist/client/schema/data-store-schema.d.ts +236 -0
- package/dist/client/schema/data-store-schema.js +29 -0
- package/dist/client/schema/file-schema.d.ts +324 -0
- package/dist/client/schema/file-schema.js +31 -0
- package/dist/client/schema/index.d.ts +5 -0
- package/dist/client/schema/index.js +5 -0
- package/dist/client/schema/project-schema.d.ts +156 -0
- package/dist/client/schema/project-schema.js +17 -0
- package/dist/client/schema/table-schema.d.ts +890 -0
- package/dist/client/schema/table-schema.js +99 -0
- package/dist/cloud-app/schema/data-store-schemas.d.ts +220 -0
- package/dist/cloud-app/schema/data-store-schemas.js +32 -0
- package/dist/cloud-app/schema/data-table-schemas.d.ts +839 -0
- package/dist/cloud-app/schema/data-table-schemas.js +103 -0
- package/dist/cloud-app/schema/file-schemas.d.ts +300 -0
- package/dist/cloud-app/schema/file-schemas.js +37 -0
- package/dist/cloud-app/schema/index.d.ts +4 -0
- package/dist/cloud-app/schema/index.js +4 -0
- package/dist/cloud-app/schema/schema.d.ts +379 -0
- package/dist/cloud-app/schema/schema.js +48 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +49 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { TABLE_VIEW_DISPLAY_TYPES } from "@boltapp/bolt-core/data-table/schemas/views/display";
|
|
2
|
+
import { ACTION_TYPES } from "@boltapp/bolt-core/data-table/table-action-schemas";
|
|
3
|
+
import { relations } from "drizzle-orm";
|
|
4
|
+
import { index, integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
5
|
+
import { nanoid } from "nanoid";
|
|
6
|
+
import { boltProjects } from "./project-schema";
|
|
7
|
+
export const boltTables = sqliteTable("bolt_tables", {
|
|
8
|
+
id: text()
|
|
9
|
+
.primaryKey()
|
|
10
|
+
.$defaultFn(() => nanoid()),
|
|
11
|
+
name: text().notNull(),
|
|
12
|
+
label: text().default("Untitled Table").notNull(),
|
|
13
|
+
description: text(),
|
|
14
|
+
idField: text().default("id").notNull(),
|
|
15
|
+
displayColumn: text().notNull(),
|
|
16
|
+
columns: text({ mode: "json" }).$type(),
|
|
17
|
+
rows: text({ mode: "json" }).$type(),
|
|
18
|
+
projectId: text()
|
|
19
|
+
.notNull()
|
|
20
|
+
.references(() => boltProjects.id, { onDelete: "cascade" }),
|
|
21
|
+
organizationId: text(),
|
|
22
|
+
createdBy: text().default("system").notNull(),
|
|
23
|
+
updatedBy: text().default("system").notNull(),
|
|
24
|
+
createdAt: integer({ mode: "timestamp" }),
|
|
25
|
+
updatedAt: integer({ mode: "timestamp" }),
|
|
26
|
+
}, (table) => [
|
|
27
|
+
uniqueIndex("bolt_tables_project_name_unique_idx").on(table.projectId, table.name),
|
|
28
|
+
index("bolt_tables_project_idx").on(table.projectId),
|
|
29
|
+
]);
|
|
30
|
+
export const boltTableViews = sqliteTable("bolt_table_views", {
|
|
31
|
+
id: text()
|
|
32
|
+
.primaryKey()
|
|
33
|
+
.$defaultFn(() => nanoid()),
|
|
34
|
+
name: text().notNull(),
|
|
35
|
+
label: text().default("Untitled View").notNull(),
|
|
36
|
+
tableId: text()
|
|
37
|
+
.notNull()
|
|
38
|
+
.references(() => boltTables.id, { onDelete: "cascade" }),
|
|
39
|
+
description: text(),
|
|
40
|
+
display: text({ enum: TABLE_VIEW_DISPLAY_TYPES }).default("table").notNull(),
|
|
41
|
+
visibleColumnIds: text({ mode: "json" }).$type().notNull(),
|
|
42
|
+
sorting: text({ mode: "json" }).$type(),
|
|
43
|
+
showRowNumbers: integer({ mode: "boolean" }),
|
|
44
|
+
rowHeight: integer({ mode: "number" }),
|
|
45
|
+
displayConfig: text({ mode: "json" }).$type().notNull(),
|
|
46
|
+
projectId: text().references(() => boltProjects.id, { onDelete: "cascade" }),
|
|
47
|
+
organizationId: text(),
|
|
48
|
+
createdBy: text(),
|
|
49
|
+
createdAt: integer({ mode: "timestamp" }),
|
|
50
|
+
updatedAt: integer({ mode: "timestamp" }),
|
|
51
|
+
}, (table) => [
|
|
52
|
+
index("bolt_table_views_table_id_idx").on(table.tableId),
|
|
53
|
+
index("bolt_table_views_project_idx").on(table.projectId),
|
|
54
|
+
]);
|
|
55
|
+
export const boltTableOps = sqliteTable("bolt_table_ops", {
|
|
56
|
+
id: text().$defaultFn(() => nanoid()),
|
|
57
|
+
serverSeq: integer("server_seq").primaryKey({ autoIncrement: true }),
|
|
58
|
+
clientActionId: text(),
|
|
59
|
+
type: text({ enum: ACTION_TYPES }).notNull(),
|
|
60
|
+
rowId: text(),
|
|
61
|
+
colId: text(),
|
|
62
|
+
tableId: text()
|
|
63
|
+
.notNull()
|
|
64
|
+
.references(() => boltTables.id, { onDelete: "cascade" }),
|
|
65
|
+
source: text({ enum: ["client", "api", "server"] })
|
|
66
|
+
.default("server")
|
|
67
|
+
.notNull(),
|
|
68
|
+
payload: text({ mode: "json" }).$type().notNull(),
|
|
69
|
+
basisRowVersion: integer("basis_row_version", { mode: "number" }),
|
|
70
|
+
basisTableVersion: integer("basis_table_version", { mode: "number" }),
|
|
71
|
+
userId: text().notNull(),
|
|
72
|
+
createdAt: integer({ mode: "timestamp" }),
|
|
73
|
+
}, (table) => [
|
|
74
|
+
index("bolt_table_ops_table_seq_idx").on(table.tableId, table.serverSeq),
|
|
75
|
+
index("bolt_table_ops_table_idx").on(table.tableId),
|
|
76
|
+
index("bolt_table_ops_row_idx").on(table.rowId),
|
|
77
|
+
index("bolt_table_ops_col_idx").on(table.colId),
|
|
78
|
+
index("bolt_table_ops_type_idx").on(table.type),
|
|
79
|
+
]);
|
|
80
|
+
export const boltTablesRelations = relations(boltTables, ({ many, one }) => ({
|
|
81
|
+
views: many(boltTableViews),
|
|
82
|
+
ops: many(boltTableOps),
|
|
83
|
+
project: one(boltProjects, {
|
|
84
|
+
fields: [boltTables.projectId],
|
|
85
|
+
references: [boltProjects.id],
|
|
86
|
+
}),
|
|
87
|
+
}));
|
|
88
|
+
export const boltTableViewsRelations = relations(boltTableViews, ({ one }) => ({
|
|
89
|
+
table: one(boltTables, {
|
|
90
|
+
fields: [boltTableViews.tableId],
|
|
91
|
+
references: [boltTables.id],
|
|
92
|
+
}),
|
|
93
|
+
}));
|
|
94
|
+
export const boltTableOpsRelations = relations(boltTableOps, ({ one }) => ({
|
|
95
|
+
table: one(boltTables, {
|
|
96
|
+
fields: [boltTableOps.tableId],
|
|
97
|
+
references: [boltTables.id],
|
|
98
|
+
}),
|
|
99
|
+
}));
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { DataStoreItem } from "@boltapp/bolt-core/data-stores/types";
|
|
2
|
+
export declare const boltDataStores: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
3
|
+
name: "bolt_data_stores";
|
|
4
|
+
schema: undefined;
|
|
5
|
+
columns: {
|
|
6
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
7
|
+
name: "id";
|
|
8
|
+
tableName: "bolt_data_stores";
|
|
9
|
+
dataType: "string";
|
|
10
|
+
columnType: "PgText";
|
|
11
|
+
data: string;
|
|
12
|
+
driverParam: string;
|
|
13
|
+
notNull: true;
|
|
14
|
+
hasDefault: true;
|
|
15
|
+
isPrimaryKey: true;
|
|
16
|
+
isAutoincrement: false;
|
|
17
|
+
hasRuntimeDefault: true;
|
|
18
|
+
enumValues: [string, ...string[]];
|
|
19
|
+
baseColumn: never;
|
|
20
|
+
identity: undefined;
|
|
21
|
+
generated: undefined;
|
|
22
|
+
}, {}, {}>;
|
|
23
|
+
name: import("drizzle-orm/pg-core").PgColumn<{
|
|
24
|
+
name: "name";
|
|
25
|
+
tableName: "bolt_data_stores";
|
|
26
|
+
dataType: "string";
|
|
27
|
+
columnType: "PgText";
|
|
28
|
+
data: string;
|
|
29
|
+
driverParam: string;
|
|
30
|
+
notNull: true;
|
|
31
|
+
hasDefault: false;
|
|
32
|
+
isPrimaryKey: false;
|
|
33
|
+
isAutoincrement: false;
|
|
34
|
+
hasRuntimeDefault: false;
|
|
35
|
+
enumValues: [string, ...string[]];
|
|
36
|
+
baseColumn: never;
|
|
37
|
+
identity: undefined;
|
|
38
|
+
generated: undefined;
|
|
39
|
+
}, {}, {}>;
|
|
40
|
+
label: import("drizzle-orm/pg-core").PgColumn<{
|
|
41
|
+
name: "label";
|
|
42
|
+
tableName: "bolt_data_stores";
|
|
43
|
+
dataType: "string";
|
|
44
|
+
columnType: "PgText";
|
|
45
|
+
data: string;
|
|
46
|
+
driverParam: string;
|
|
47
|
+
notNull: true;
|
|
48
|
+
hasDefault: true;
|
|
49
|
+
isPrimaryKey: false;
|
|
50
|
+
isAutoincrement: false;
|
|
51
|
+
hasRuntimeDefault: false;
|
|
52
|
+
enumValues: [string, ...string[]];
|
|
53
|
+
baseColumn: never;
|
|
54
|
+
identity: undefined;
|
|
55
|
+
generated: undefined;
|
|
56
|
+
}, {}, {}>;
|
|
57
|
+
description: import("drizzle-orm/pg-core").PgColumn<{
|
|
58
|
+
name: "description";
|
|
59
|
+
tableName: "bolt_data_stores";
|
|
60
|
+
dataType: "string";
|
|
61
|
+
columnType: "PgText";
|
|
62
|
+
data: string;
|
|
63
|
+
driverParam: string;
|
|
64
|
+
notNull: false;
|
|
65
|
+
hasDefault: false;
|
|
66
|
+
isPrimaryKey: false;
|
|
67
|
+
isAutoincrement: false;
|
|
68
|
+
hasRuntimeDefault: false;
|
|
69
|
+
enumValues: [string, ...string[]];
|
|
70
|
+
baseColumn: never;
|
|
71
|
+
identity: undefined;
|
|
72
|
+
generated: undefined;
|
|
73
|
+
}, {}, {}>;
|
|
74
|
+
items: import("drizzle-orm/pg-core").PgColumn<{
|
|
75
|
+
name: "schema";
|
|
76
|
+
tableName: "bolt_data_stores";
|
|
77
|
+
dataType: "json";
|
|
78
|
+
columnType: "PgJsonb";
|
|
79
|
+
data: DataStoreItem[];
|
|
80
|
+
driverParam: unknown;
|
|
81
|
+
notNull: false;
|
|
82
|
+
hasDefault: false;
|
|
83
|
+
isPrimaryKey: false;
|
|
84
|
+
isAutoincrement: false;
|
|
85
|
+
hasRuntimeDefault: false;
|
|
86
|
+
enumValues: undefined;
|
|
87
|
+
baseColumn: never;
|
|
88
|
+
identity: undefined;
|
|
89
|
+
generated: undefined;
|
|
90
|
+
}, {}, {
|
|
91
|
+
$type: DataStoreItem[];
|
|
92
|
+
}>;
|
|
93
|
+
data: import("drizzle-orm/pg-core").PgColumn<{
|
|
94
|
+
name: "data";
|
|
95
|
+
tableName: "bolt_data_stores";
|
|
96
|
+
dataType: "json";
|
|
97
|
+
columnType: "PgJsonb";
|
|
98
|
+
data: Record<string, unknown>;
|
|
99
|
+
driverParam: unknown;
|
|
100
|
+
notNull: true;
|
|
101
|
+
hasDefault: true;
|
|
102
|
+
isPrimaryKey: false;
|
|
103
|
+
isAutoincrement: false;
|
|
104
|
+
hasRuntimeDefault: false;
|
|
105
|
+
enumValues: undefined;
|
|
106
|
+
baseColumn: never;
|
|
107
|
+
identity: undefined;
|
|
108
|
+
generated: undefined;
|
|
109
|
+
}, {}, {
|
|
110
|
+
$type: Record<string, unknown>;
|
|
111
|
+
}>;
|
|
112
|
+
appId: import("drizzle-orm/pg-core").PgColumn<{
|
|
113
|
+
name: "app_id";
|
|
114
|
+
tableName: "bolt_data_stores";
|
|
115
|
+
dataType: "string";
|
|
116
|
+
columnType: "PgText";
|
|
117
|
+
data: string;
|
|
118
|
+
driverParam: string;
|
|
119
|
+
notNull: true;
|
|
120
|
+
hasDefault: false;
|
|
121
|
+
isPrimaryKey: false;
|
|
122
|
+
isAutoincrement: false;
|
|
123
|
+
hasRuntimeDefault: false;
|
|
124
|
+
enumValues: [string, ...string[]];
|
|
125
|
+
baseColumn: never;
|
|
126
|
+
identity: undefined;
|
|
127
|
+
generated: undefined;
|
|
128
|
+
}, {}, {}>;
|
|
129
|
+
organizationId: import("drizzle-orm/pg-core").PgColumn<{
|
|
130
|
+
name: "organization_id";
|
|
131
|
+
tableName: "bolt_data_stores";
|
|
132
|
+
dataType: "string";
|
|
133
|
+
columnType: "PgText";
|
|
134
|
+
data: string;
|
|
135
|
+
driverParam: string;
|
|
136
|
+
notNull: false;
|
|
137
|
+
hasDefault: false;
|
|
138
|
+
isPrimaryKey: false;
|
|
139
|
+
isAutoincrement: false;
|
|
140
|
+
hasRuntimeDefault: false;
|
|
141
|
+
enumValues: [string, ...string[]];
|
|
142
|
+
baseColumn: never;
|
|
143
|
+
identity: undefined;
|
|
144
|
+
generated: undefined;
|
|
145
|
+
}, {}, {}>;
|
|
146
|
+
createdBy: import("drizzle-orm/pg-core").PgColumn<{
|
|
147
|
+
name: "created_by";
|
|
148
|
+
tableName: "bolt_data_stores";
|
|
149
|
+
dataType: "string";
|
|
150
|
+
columnType: "PgText";
|
|
151
|
+
data: string;
|
|
152
|
+
driverParam: string;
|
|
153
|
+
notNull: true;
|
|
154
|
+
hasDefault: true;
|
|
155
|
+
isPrimaryKey: false;
|
|
156
|
+
isAutoincrement: false;
|
|
157
|
+
hasRuntimeDefault: false;
|
|
158
|
+
enumValues: [string, ...string[]];
|
|
159
|
+
baseColumn: never;
|
|
160
|
+
identity: undefined;
|
|
161
|
+
generated: undefined;
|
|
162
|
+
}, {}, {}>;
|
|
163
|
+
updatedBy: import("drizzle-orm/pg-core").PgColumn<{
|
|
164
|
+
name: "updated_by";
|
|
165
|
+
tableName: "bolt_data_stores";
|
|
166
|
+
dataType: "string";
|
|
167
|
+
columnType: "PgText";
|
|
168
|
+
data: string;
|
|
169
|
+
driverParam: string;
|
|
170
|
+
notNull: true;
|
|
171
|
+
hasDefault: true;
|
|
172
|
+
isPrimaryKey: false;
|
|
173
|
+
isAutoincrement: false;
|
|
174
|
+
hasRuntimeDefault: false;
|
|
175
|
+
enumValues: [string, ...string[]];
|
|
176
|
+
baseColumn: never;
|
|
177
|
+
identity: undefined;
|
|
178
|
+
generated: undefined;
|
|
179
|
+
}, {}, {}>;
|
|
180
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
181
|
+
name: "created_at";
|
|
182
|
+
tableName: "bolt_data_stores";
|
|
183
|
+
dataType: "date";
|
|
184
|
+
columnType: "PgTimestamp";
|
|
185
|
+
data: Date;
|
|
186
|
+
driverParam: string;
|
|
187
|
+
notNull: false;
|
|
188
|
+
hasDefault: true;
|
|
189
|
+
isPrimaryKey: false;
|
|
190
|
+
isAutoincrement: false;
|
|
191
|
+
hasRuntimeDefault: false;
|
|
192
|
+
enumValues: undefined;
|
|
193
|
+
baseColumn: never;
|
|
194
|
+
identity: undefined;
|
|
195
|
+
generated: undefined;
|
|
196
|
+
}, {}, {}>;
|
|
197
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
198
|
+
name: "updated_at";
|
|
199
|
+
tableName: "bolt_data_stores";
|
|
200
|
+
dataType: "date";
|
|
201
|
+
columnType: "PgTimestamp";
|
|
202
|
+
data: Date;
|
|
203
|
+
driverParam: string;
|
|
204
|
+
notNull: false;
|
|
205
|
+
hasDefault: true;
|
|
206
|
+
isPrimaryKey: false;
|
|
207
|
+
isAutoincrement: false;
|
|
208
|
+
hasRuntimeDefault: false;
|
|
209
|
+
enumValues: undefined;
|
|
210
|
+
baseColumn: never;
|
|
211
|
+
identity: undefined;
|
|
212
|
+
generated: undefined;
|
|
213
|
+
}, {}, {}>;
|
|
214
|
+
};
|
|
215
|
+
dialect: "pg";
|
|
216
|
+
}>;
|
|
217
|
+
export declare const boltDataStoresRelations: import("drizzle-orm").Relations<"bolt_data_stores", {
|
|
218
|
+
app: import("drizzle-orm").One<"apps", true>;
|
|
219
|
+
}>;
|
|
220
|
+
export type BoltDataStoreCloud = typeof boltDataStores.$inferSelect;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { relations } from "drizzle-orm";
|
|
2
|
+
import { index, jsonb, pgTable, text, timestamp, uniqueIndex } from "drizzle-orm/pg-core";
|
|
3
|
+
import { nanoid } from "nanoid";
|
|
4
|
+
import { apps } from "./schema";
|
|
5
|
+
export const boltDataStores = pgTable("bolt_data_stores", {
|
|
6
|
+
id: text("id")
|
|
7
|
+
.primaryKey()
|
|
8
|
+
.$defaultFn(() => nanoid()),
|
|
9
|
+
name: text("name").notNull(),
|
|
10
|
+
label: text("label").default("Untitled Store").notNull(),
|
|
11
|
+
description: text("description"),
|
|
12
|
+
items: jsonb("schema").$type(),
|
|
13
|
+
data: jsonb("data").$type().default({}).notNull(),
|
|
14
|
+
appId: text("app_id")
|
|
15
|
+
.notNull()
|
|
16
|
+
.references(() => apps.id, { onDelete: "cascade" }),
|
|
17
|
+
organizationId: text("organization_id"),
|
|
18
|
+
createdBy: text("created_by").default("system").notNull(),
|
|
19
|
+
updatedBy: text("updated_by").default("system").notNull(),
|
|
20
|
+
createdAt: timestamp("created_at").defaultNow(),
|
|
21
|
+
updatedAt: timestamp("updated_at").defaultNow(),
|
|
22
|
+
}, (table) => [
|
|
23
|
+
uniqueIndex("bolt_data_stores_app_name_unique_idx").on(table.appId, table.name),
|
|
24
|
+
index("bolt_data_stores_app_idx").on(table.appId),
|
|
25
|
+
index("bolt_data_stores_organization_idx").on(table.organizationId),
|
|
26
|
+
]);
|
|
27
|
+
export const boltDataStoresRelations = relations(boltDataStores, ({ one }) => ({
|
|
28
|
+
app: one(apps, {
|
|
29
|
+
fields: [boltDataStores.appId],
|
|
30
|
+
references: [apps.id],
|
|
31
|
+
}),
|
|
32
|
+
}));
|